Linux 4.4.145
[linux/fpc-iii.git] / drivers / net / wireless / ath / ath10k / wmi.c
blob7569db0f69b5eed8f69d65c3e881f56bf54129b4
1 /*
2 * Copyright (c) 2005-2011 Atheros Communications Inc.
3 * Copyright (c) 2011-2013 Qualcomm Atheros, Inc.
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.
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.
18 #include <linux/skbuff.h>
19 #include <linux/ctype.h>
21 #include "core.h"
22 #include "htc.h"
23 #include "debug.h"
24 #include "wmi.h"
25 #include "wmi-tlv.h"
26 #include "mac.h"
27 #include "testmode.h"
28 #include "wmi-ops.h"
29 #include "p2p.h"
30 #include "hw.h"
32 /* MAIN WMI cmd track */
33 static 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,
150 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
151 .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
152 .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,
196 /* 10.X WMI cmd track */
197 static 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,
202 .scan_sch_prio_tbl_cmdid = WMI_CMD_UNSUPPORTED,
203 .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,
235 .bcn_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
236 .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,
239 .prb_tmpl_cmdid = WMI_CMD_UNSUPPORTED,
240 .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,
264 .p2p_set_vendor_ie_data_cmdid = WMI_CMD_UNSUPPORTED,
265 .ap_ps_peer_param_cmdid = WMI_10X_AP_PS_PEER_PARAM_CMDID,
266 .ap_ps_peer_uapsd_coex_cmdid = WMI_CMD_UNSUPPORTED,
267 .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,
295 .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,
306 .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,
310 .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,
314 .gpio_config_cmdid = WMI_10X_GPIO_CONFIG_CMDID,
315 .gpio_output_cmdid = WMI_10X_GPIO_OUTPUT_CMDID,
316 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
317 .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
318 .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,
362 /* 10.2.4 WMI cmd track */
363 static 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,
481 .pdev_get_temperature_cmdid = WMI_10_2_PDEV_GET_TEMPERATURE_CMDID,
482 .pdev_enable_adaptive_cca_cmdid = WMI_10_2_SET_CCA_PARAMS,
483 .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,
527 /* 10.4 WMI cmd track */
528 static 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,
710 /* MAIN WMI VDEV param map */
711 static 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,
767 .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,
785 /* 10.X WMI VDEV param map */
786 static 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,
842 .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,
860 static 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,
916 .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,
934 static 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,
1009 static 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,
1045 .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,
1058 .cal_period = WMI_PDEV_PARAM_UNSUPPORTED,
1059 .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,
1103 static 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,
1139 .arp_ac_override = WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE,
1140 .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,
1153 .cal_period = WMI_10X_PDEV_PARAM_CAL_PERIOD,
1154 .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,
1198 static 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,
1249 .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,
1293 /* firmware 10.2 specific mappings */
1294 static 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,
1412 .pdev_get_temperature_cmdid = WMI_CMD_UNSUPPORTED,
1413 .pdev_enable_adaptive_cca_cmdid = WMI_CMD_UNSUPPORTED,
1414 .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,
1448 static 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,
1549 void ath10k_wmi_put_wmi_channel(struct wmi_channel *ch,
1550 const struct wmi_channel_arg *arg)
1552 u32 flags = 0;
1554 memset(ch, 0, sizeof(*ch));
1556 if (arg->passive)
1557 flags |= WMI_CHAN_FLAG_PASSIVE;
1558 if (arg->allow_ibss)
1559 flags |= WMI_CHAN_FLAG_ADHOC_ALLOWED;
1560 if (arg->allow_ht)
1561 flags |= WMI_CHAN_FLAG_ALLOW_HT;
1562 if (arg->allow_vht)
1563 flags |= WMI_CHAN_FLAG_ALLOW_VHT;
1564 if (arg->ht40plus)
1565 flags |= WMI_CHAN_FLAG_HT40_PLUS;
1566 if (arg->chan_radar)
1567 flags |= WMI_CHAN_FLAG_DFS;
1569 ch->mhz = __cpu_to_le32(arg->freq);
1570 ch->band_center_freq1 = __cpu_to_le32(arg->band_center_freq1);
1571 ch->band_center_freq2 = 0;
1572 ch->min_power = arg->min_power;
1573 ch->max_power = arg->max_power;
1574 ch->reg_power = arg->max_reg_power;
1575 ch->antenna_max = arg->max_antenna_gain;
1577 /* mode & flags share storage */
1578 ch->mode = arg->mode;
1579 ch->flags |= __cpu_to_le32(flags);
1582 int ath10k_wmi_wait_for_service_ready(struct ath10k *ar)
1584 unsigned long time_left;
1586 time_left = wait_for_completion_timeout(&ar->wmi.service_ready,
1587 WMI_SERVICE_READY_TIMEOUT_HZ);
1588 if (!time_left)
1589 return -ETIMEDOUT;
1590 return 0;
1593 int ath10k_wmi_wait_for_unified_ready(struct ath10k *ar)
1595 unsigned long time_left;
1597 time_left = wait_for_completion_timeout(&ar->wmi.unified_ready,
1598 WMI_UNIFIED_READY_TIMEOUT_HZ);
1599 if (!time_left)
1600 return -ETIMEDOUT;
1601 return 0;
1604 struct sk_buff *ath10k_wmi_alloc_skb(struct ath10k *ar, u32 len)
1606 struct sk_buff *skb;
1607 u32 round_len = roundup(len, 4);
1609 skb = ath10k_htc_alloc_skb(ar, WMI_SKB_HEADROOM + round_len);
1610 if (!skb)
1611 return NULL;
1613 skb_reserve(skb, WMI_SKB_HEADROOM);
1614 if (!IS_ALIGNED((unsigned long)skb->data, 4))
1615 ath10k_warn(ar, "Unaligned WMI skb\n");
1617 skb_put(skb, round_len);
1618 memset(skb->data, 0, round_len);
1620 return skb;
1623 static void ath10k_wmi_htc_tx_complete(struct ath10k *ar, struct sk_buff *skb)
1625 dev_kfree_skb(skb);
1628 int ath10k_wmi_cmd_send_nowait(struct ath10k *ar, struct sk_buff *skb,
1629 u32 cmd_id)
1631 struct ath10k_skb_cb *skb_cb = ATH10K_SKB_CB(skb);
1632 struct wmi_cmd_hdr *cmd_hdr;
1633 int ret;
1634 u32 cmd = 0;
1636 if (skb_push(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
1637 return -ENOMEM;
1639 cmd |= SM(cmd_id, WMI_CMD_HDR_CMD_ID);
1641 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
1642 cmd_hdr->cmd_id = __cpu_to_le32(cmd);
1644 memset(skb_cb, 0, sizeof(*skb_cb));
1645 ret = ath10k_htc_send(&ar->htc, ar->wmi.eid, skb);
1646 trace_ath10k_wmi_cmd(ar, cmd_id, skb->data, skb->len, ret);
1648 if (ret)
1649 goto err_pull;
1651 return 0;
1653 err_pull:
1654 skb_pull(skb, sizeof(struct wmi_cmd_hdr));
1655 return ret;
1658 static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif *arvif)
1660 struct ath10k *ar = arvif->ar;
1661 struct ath10k_skb_cb *cb;
1662 struct sk_buff *bcn;
1663 int ret;
1665 spin_lock_bh(&ar->data_lock);
1667 bcn = arvif->beacon;
1669 if (!bcn)
1670 goto unlock;
1672 cb = ATH10K_SKB_CB(bcn);
1674 switch (arvif->beacon_state) {
1675 case ATH10K_BEACON_SENDING:
1676 case ATH10K_BEACON_SENT:
1677 break;
1678 case ATH10K_BEACON_SCHEDULED:
1679 arvif->beacon_state = ATH10K_BEACON_SENDING;
1680 spin_unlock_bh(&ar->data_lock);
1682 ret = ath10k_wmi_beacon_send_ref_nowait(arvif->ar,
1683 arvif->vdev_id,
1684 bcn->data, bcn->len,
1685 cb->paddr,
1686 cb->bcn.dtim_zero,
1687 cb->bcn.deliver_cab);
1689 spin_lock_bh(&ar->data_lock);
1691 if (ret == 0)
1692 arvif->beacon_state = ATH10K_BEACON_SENT;
1693 else
1694 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
1697 unlock:
1698 spin_unlock_bh(&ar->data_lock);
1701 static void ath10k_wmi_tx_beacons_iter(void *data, u8 *mac,
1702 struct ieee80211_vif *vif)
1704 struct ath10k_vif *arvif = ath10k_vif_to_arvif(vif);
1706 ath10k_wmi_tx_beacon_nowait(arvif);
1709 static void ath10k_wmi_tx_beacons_nowait(struct ath10k *ar)
1711 ieee80211_iterate_active_interfaces_atomic(ar->hw,
1712 IEEE80211_IFACE_ITER_NORMAL,
1713 ath10k_wmi_tx_beacons_iter,
1714 NULL);
1717 static void ath10k_wmi_op_ep_tx_credits(struct ath10k *ar)
1719 /* try to send pending beacons first. they take priority */
1720 ath10k_wmi_tx_beacons_nowait(ar);
1722 wake_up(&ar->wmi.tx_credits_wq);
1725 int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
1727 int ret = -EOPNOTSUPP;
1729 might_sleep();
1731 if (cmd_id == WMI_CMD_UNSUPPORTED) {
1732 ath10k_warn(ar, "wmi command %d is not supported by firmware\n",
1733 cmd_id);
1734 return ret;
1737 wait_event_timeout(ar->wmi.tx_credits_wq, ({
1738 /* try to send pending beacons first. they take priority */
1739 ath10k_wmi_tx_beacons_nowait(ar);
1741 ret = ath10k_wmi_cmd_send_nowait(ar, skb, cmd_id);
1743 if (ret && test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags))
1744 ret = -ESHUTDOWN;
1746 (ret != -EAGAIN);
1747 }), 3*HZ);
1749 if (ret)
1750 dev_kfree_skb_any(skb);
1752 return ret;
1755 static struct sk_buff *
1756 ath10k_wmi_op_gen_mgmt_tx(struct ath10k *ar, struct sk_buff *msdu)
1758 struct wmi_mgmt_tx_cmd *cmd;
1759 struct ieee80211_hdr *hdr;
1760 struct sk_buff *skb;
1761 int len;
1762 u32 buf_len = msdu->len;
1763 u16 fc;
1765 hdr = (struct ieee80211_hdr *)msdu->data;
1766 fc = le16_to_cpu(hdr->frame_control);
1768 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr->frame_control)))
1769 return ERR_PTR(-EINVAL);
1771 len = sizeof(cmd->hdr) + msdu->len;
1773 if ((ieee80211_is_action(hdr->frame_control) ||
1774 ieee80211_is_deauth(hdr->frame_control) ||
1775 ieee80211_is_disassoc(hdr->frame_control)) &&
1776 ieee80211_has_protected(hdr->frame_control)) {
1777 len += IEEE80211_CCMP_MIC_LEN;
1778 buf_len += IEEE80211_CCMP_MIC_LEN;
1781 len = round_up(len, 4);
1783 skb = ath10k_wmi_alloc_skb(ar, len);
1784 if (!skb)
1785 return ERR_PTR(-ENOMEM);
1787 cmd = (struct wmi_mgmt_tx_cmd *)skb->data;
1789 cmd->hdr.vdev_id = __cpu_to_le32(ATH10K_SKB_CB(msdu)->vdev_id);
1790 cmd->hdr.tx_rate = 0;
1791 cmd->hdr.tx_power = 0;
1792 cmd->hdr.buf_len = __cpu_to_le32(buf_len);
1794 ether_addr_copy(cmd->hdr.peer_macaddr.addr, ieee80211_get_DA(hdr));
1795 memcpy(cmd->buf, msdu->data, msdu->len);
1797 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
1798 msdu, skb->len, fc & IEEE80211_FCTL_FTYPE,
1799 fc & IEEE80211_FCTL_STYPE);
1800 trace_ath10k_tx_hdr(ar, skb->data, skb->len);
1801 trace_ath10k_tx_payload(ar, skb->data, skb->len);
1803 return skb;
1806 static void ath10k_wmi_event_scan_started(struct ath10k *ar)
1808 lockdep_assert_held(&ar->data_lock);
1810 switch (ar->scan.state) {
1811 case ATH10K_SCAN_IDLE:
1812 case ATH10K_SCAN_RUNNING:
1813 case ATH10K_SCAN_ABORTING:
1814 ath10k_warn(ar, "received scan started event in an invalid scan state: %s (%d)\n",
1815 ath10k_scan_state_str(ar->scan.state),
1816 ar->scan.state);
1817 break;
1818 case ATH10K_SCAN_STARTING:
1819 ar->scan.state = ATH10K_SCAN_RUNNING;
1821 if (ar->scan.is_roc)
1822 ieee80211_ready_on_channel(ar->hw);
1824 complete(&ar->scan.started);
1825 break;
1829 static void ath10k_wmi_event_scan_start_failed(struct ath10k *ar)
1831 lockdep_assert_held(&ar->data_lock);
1833 switch (ar->scan.state) {
1834 case ATH10K_SCAN_IDLE:
1835 case ATH10K_SCAN_RUNNING:
1836 case ATH10K_SCAN_ABORTING:
1837 ath10k_warn(ar, "received scan start failed event in an invalid scan state: %s (%d)\n",
1838 ath10k_scan_state_str(ar->scan.state),
1839 ar->scan.state);
1840 break;
1841 case ATH10K_SCAN_STARTING:
1842 complete(&ar->scan.started);
1843 __ath10k_scan_finish(ar);
1844 break;
1848 static void ath10k_wmi_event_scan_completed(struct ath10k *ar)
1850 lockdep_assert_held(&ar->data_lock);
1852 switch (ar->scan.state) {
1853 case ATH10K_SCAN_IDLE:
1854 case ATH10K_SCAN_STARTING:
1855 /* One suspected reason scan can be completed while starting is
1856 * if firmware fails to deliver all scan events to the host,
1857 * e.g. when transport pipe is full. This has been observed
1858 * with spectral scan phyerr events starving wmi transport
1859 * pipe. In such case the "scan completed" event should be (and
1860 * is) ignored by the host as it may be just firmware's scan
1861 * state machine recovering.
1863 ath10k_warn(ar, "received scan completed event in an invalid scan state: %s (%d)\n",
1864 ath10k_scan_state_str(ar->scan.state),
1865 ar->scan.state);
1866 break;
1867 case ATH10K_SCAN_RUNNING:
1868 case ATH10K_SCAN_ABORTING:
1869 __ath10k_scan_finish(ar);
1870 break;
1874 static void ath10k_wmi_event_scan_bss_chan(struct ath10k *ar)
1876 lockdep_assert_held(&ar->data_lock);
1878 switch (ar->scan.state) {
1879 case ATH10K_SCAN_IDLE:
1880 case ATH10K_SCAN_STARTING:
1881 ath10k_warn(ar, "received scan bss chan event in an invalid scan state: %s (%d)\n",
1882 ath10k_scan_state_str(ar->scan.state),
1883 ar->scan.state);
1884 break;
1885 case ATH10K_SCAN_RUNNING:
1886 case ATH10K_SCAN_ABORTING:
1887 ar->scan_channel = NULL;
1888 break;
1892 static void ath10k_wmi_event_scan_foreign_chan(struct ath10k *ar, u32 freq)
1894 lockdep_assert_held(&ar->data_lock);
1896 switch (ar->scan.state) {
1897 case ATH10K_SCAN_IDLE:
1898 case ATH10K_SCAN_STARTING:
1899 ath10k_warn(ar, "received scan foreign chan event in an invalid scan state: %s (%d)\n",
1900 ath10k_scan_state_str(ar->scan.state),
1901 ar->scan.state);
1902 break;
1903 case ATH10K_SCAN_RUNNING:
1904 case ATH10K_SCAN_ABORTING:
1905 ar->scan_channel = ieee80211_get_channel(ar->hw->wiphy, freq);
1907 if (ar->scan.is_roc && ar->scan.roc_freq == freq)
1908 complete(&ar->scan.on_channel);
1909 break;
1913 static const char *
1914 ath10k_wmi_event_scan_type_str(enum wmi_scan_event_type type,
1915 enum wmi_scan_completion_reason reason)
1917 switch (type) {
1918 case WMI_SCAN_EVENT_STARTED:
1919 return "started";
1920 case WMI_SCAN_EVENT_COMPLETED:
1921 switch (reason) {
1922 case WMI_SCAN_REASON_COMPLETED:
1923 return "completed";
1924 case WMI_SCAN_REASON_CANCELLED:
1925 return "completed [cancelled]";
1926 case WMI_SCAN_REASON_PREEMPTED:
1927 return "completed [preempted]";
1928 case WMI_SCAN_REASON_TIMEDOUT:
1929 return "completed [timedout]";
1930 case WMI_SCAN_REASON_INTERNAL_FAILURE:
1931 return "completed [internal err]";
1932 case WMI_SCAN_REASON_MAX:
1933 break;
1935 return "completed [unknown]";
1936 case WMI_SCAN_EVENT_BSS_CHANNEL:
1937 return "bss channel";
1938 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
1939 return "foreign channel";
1940 case WMI_SCAN_EVENT_DEQUEUED:
1941 return "dequeued";
1942 case WMI_SCAN_EVENT_PREEMPTED:
1943 return "preempted";
1944 case WMI_SCAN_EVENT_START_FAILED:
1945 return "start failed";
1946 case WMI_SCAN_EVENT_RESTARTED:
1947 return "restarted";
1948 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
1949 return "foreign channel exit";
1950 default:
1951 return "unknown";
1955 static int ath10k_wmi_op_pull_scan_ev(struct ath10k *ar, struct sk_buff *skb,
1956 struct wmi_scan_ev_arg *arg)
1958 struct wmi_scan_event *ev = (void *)skb->data;
1960 if (skb->len < sizeof(*ev))
1961 return -EPROTO;
1963 skb_pull(skb, sizeof(*ev));
1964 arg->event_type = ev->event_type;
1965 arg->reason = ev->reason;
1966 arg->channel_freq = ev->channel_freq;
1967 arg->scan_req_id = ev->scan_req_id;
1968 arg->scan_id = ev->scan_id;
1969 arg->vdev_id = ev->vdev_id;
1971 return 0;
1974 int ath10k_wmi_event_scan(struct ath10k *ar, struct sk_buff *skb)
1976 struct wmi_scan_ev_arg arg = {};
1977 enum wmi_scan_event_type event_type;
1978 enum wmi_scan_completion_reason reason;
1979 u32 freq;
1980 u32 req_id;
1981 u32 scan_id;
1982 u32 vdev_id;
1983 int ret;
1985 ret = ath10k_wmi_pull_scan(ar, skb, &arg);
1986 if (ret) {
1987 ath10k_warn(ar, "failed to parse scan event: %d\n", ret);
1988 return ret;
1991 event_type = __le32_to_cpu(arg.event_type);
1992 reason = __le32_to_cpu(arg.reason);
1993 freq = __le32_to_cpu(arg.channel_freq);
1994 req_id = __le32_to_cpu(arg.scan_req_id);
1995 scan_id = __le32_to_cpu(arg.scan_id);
1996 vdev_id = __le32_to_cpu(arg.vdev_id);
1998 spin_lock_bh(&ar->data_lock);
2000 ath10k_dbg(ar, ATH10K_DBG_WMI,
2001 "scan event %s type %d reason %d freq %d req_id %d scan_id %d vdev_id %d state %s (%d)\n",
2002 ath10k_wmi_event_scan_type_str(event_type, reason),
2003 event_type, reason, freq, req_id, scan_id, vdev_id,
2004 ath10k_scan_state_str(ar->scan.state), ar->scan.state);
2006 switch (event_type) {
2007 case WMI_SCAN_EVENT_STARTED:
2008 ath10k_wmi_event_scan_started(ar);
2009 break;
2010 case WMI_SCAN_EVENT_COMPLETED:
2011 ath10k_wmi_event_scan_completed(ar);
2012 break;
2013 case WMI_SCAN_EVENT_BSS_CHANNEL:
2014 ath10k_wmi_event_scan_bss_chan(ar);
2015 break;
2016 case WMI_SCAN_EVENT_FOREIGN_CHANNEL:
2017 ath10k_wmi_event_scan_foreign_chan(ar, freq);
2018 break;
2019 case WMI_SCAN_EVENT_START_FAILED:
2020 ath10k_warn(ar, "received scan start failure event\n");
2021 ath10k_wmi_event_scan_start_failed(ar);
2022 break;
2023 case WMI_SCAN_EVENT_DEQUEUED:
2024 case WMI_SCAN_EVENT_PREEMPTED:
2025 case WMI_SCAN_EVENT_RESTARTED:
2026 case WMI_SCAN_EVENT_FOREIGN_CHANNEL_EXIT:
2027 default:
2028 break;
2031 spin_unlock_bh(&ar->data_lock);
2032 return 0;
2035 static inline enum ieee80211_band phy_mode_to_band(u32 phy_mode)
2037 enum ieee80211_band band;
2039 switch (phy_mode) {
2040 case MODE_11A:
2041 case MODE_11NA_HT20:
2042 case MODE_11NA_HT40:
2043 case MODE_11AC_VHT20:
2044 case MODE_11AC_VHT40:
2045 case MODE_11AC_VHT80:
2046 band = IEEE80211_BAND_5GHZ;
2047 break;
2048 case MODE_11G:
2049 case MODE_11B:
2050 case MODE_11GONLY:
2051 case MODE_11NG_HT20:
2052 case MODE_11NG_HT40:
2053 case MODE_11AC_VHT20_2G:
2054 case MODE_11AC_VHT40_2G:
2055 case MODE_11AC_VHT80_2G:
2056 default:
2057 band = IEEE80211_BAND_2GHZ;
2060 return band;
2063 /* If keys are configured, HW decrypts all frames
2064 * with protected bit set. Mark such frames as decrypted.
2066 static void ath10k_wmi_handle_wep_reauth(struct ath10k *ar,
2067 struct sk_buff *skb,
2068 struct ieee80211_rx_status *status)
2070 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
2071 unsigned int hdrlen;
2072 bool peer_key;
2073 u8 *addr, keyidx;
2075 if (!ieee80211_is_auth(hdr->frame_control) ||
2076 !ieee80211_has_protected(hdr->frame_control))
2077 return;
2079 hdrlen = ieee80211_hdrlen(hdr->frame_control);
2080 if (skb->len < (hdrlen + IEEE80211_WEP_IV_LEN))
2081 return;
2083 keyidx = skb->data[hdrlen + (IEEE80211_WEP_IV_LEN - 1)] >> WEP_KEYID_SHIFT;
2084 addr = ieee80211_get_SA(hdr);
2086 spin_lock_bh(&ar->data_lock);
2087 peer_key = ath10k_mac_is_peer_wep_key_set(ar, addr, keyidx);
2088 spin_unlock_bh(&ar->data_lock);
2090 if (peer_key) {
2091 ath10k_dbg(ar, ATH10K_DBG_MAC,
2092 "mac wep key present for peer %pM\n", addr);
2093 status->flag |= RX_FLAG_DECRYPTED;
2097 static int ath10k_wmi_op_pull_mgmt_rx_ev(struct ath10k *ar, struct sk_buff *skb,
2098 struct wmi_mgmt_rx_ev_arg *arg)
2100 struct wmi_mgmt_rx_event_v1 *ev_v1;
2101 struct wmi_mgmt_rx_event_v2 *ev_v2;
2102 struct wmi_mgmt_rx_hdr_v1 *ev_hdr;
2103 size_t pull_len;
2104 u32 msdu_len;
2106 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features)) {
2107 ev_v2 = (struct wmi_mgmt_rx_event_v2 *)skb->data;
2108 ev_hdr = &ev_v2->hdr.v1;
2109 pull_len = sizeof(*ev_v2);
2110 } else {
2111 ev_v1 = (struct wmi_mgmt_rx_event_v1 *)skb->data;
2112 ev_hdr = &ev_v1->hdr;
2113 pull_len = sizeof(*ev_v1);
2116 if (skb->len < pull_len)
2117 return -EPROTO;
2119 skb_pull(skb, pull_len);
2120 arg->channel = ev_hdr->channel;
2121 arg->buf_len = ev_hdr->buf_len;
2122 arg->status = ev_hdr->status;
2123 arg->snr = ev_hdr->snr;
2124 arg->phy_mode = ev_hdr->phy_mode;
2125 arg->rate = ev_hdr->rate;
2127 msdu_len = __le32_to_cpu(arg->buf_len);
2128 if (skb->len < msdu_len)
2129 return -EPROTO;
2131 /* the WMI buffer might've ended up being padded to 4 bytes due to HTC
2132 * trailer with credit update. Trim the excess garbage.
2134 skb_trim(skb, msdu_len);
2136 return 0;
2139 static int ath10k_wmi_10_4_op_pull_mgmt_rx_ev(struct ath10k *ar,
2140 struct sk_buff *skb,
2141 struct wmi_mgmt_rx_ev_arg *arg)
2143 struct wmi_10_4_mgmt_rx_event *ev;
2144 struct wmi_10_4_mgmt_rx_hdr *ev_hdr;
2145 size_t pull_len;
2146 u32 msdu_len;
2148 ev = (struct wmi_10_4_mgmt_rx_event *)skb->data;
2149 ev_hdr = &ev->hdr;
2150 pull_len = sizeof(*ev);
2152 if (skb->len < pull_len)
2153 return -EPROTO;
2155 skb_pull(skb, pull_len);
2156 arg->channel = ev_hdr->channel;
2157 arg->buf_len = ev_hdr->buf_len;
2158 arg->status = ev_hdr->status;
2159 arg->snr = ev_hdr->snr;
2160 arg->phy_mode = ev_hdr->phy_mode;
2161 arg->rate = ev_hdr->rate;
2163 msdu_len = __le32_to_cpu(arg->buf_len);
2164 if (skb->len < msdu_len)
2165 return -EPROTO;
2167 /* Make sure bytes added for padding are removed. */
2168 skb_trim(skb, msdu_len);
2170 return 0;
2173 int ath10k_wmi_event_mgmt_rx(struct ath10k *ar, struct sk_buff *skb)
2175 struct wmi_mgmt_rx_ev_arg arg = {};
2176 struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
2177 struct ieee80211_hdr *hdr;
2178 struct ieee80211_supported_band *sband;
2179 u32 rx_status;
2180 u32 channel;
2181 u32 phy_mode;
2182 u32 snr;
2183 u32 rate;
2184 u32 buf_len;
2185 u16 fc;
2186 int ret;
2188 ret = ath10k_wmi_pull_mgmt_rx(ar, skb, &arg);
2189 if (ret) {
2190 ath10k_warn(ar, "failed to parse mgmt rx event: %d\n", ret);
2191 dev_kfree_skb(skb);
2192 return ret;
2195 channel = __le32_to_cpu(arg.channel);
2196 buf_len = __le32_to_cpu(arg.buf_len);
2197 rx_status = __le32_to_cpu(arg.status);
2198 snr = __le32_to_cpu(arg.snr);
2199 phy_mode = __le32_to_cpu(arg.phy_mode);
2200 rate = __le32_to_cpu(arg.rate);
2202 memset(status, 0, sizeof(*status));
2204 ath10k_dbg(ar, ATH10K_DBG_MGMT,
2205 "event mgmt rx status %08x\n", rx_status);
2207 if (test_bit(ATH10K_CAC_RUNNING, &ar->dev_flags)) {
2208 dev_kfree_skb(skb);
2209 return 0;
2212 if (rx_status & WMI_RX_STATUS_ERR_DECRYPT) {
2213 dev_kfree_skb(skb);
2214 return 0;
2217 if (rx_status & WMI_RX_STATUS_ERR_KEY_CACHE_MISS) {
2218 dev_kfree_skb(skb);
2219 return 0;
2222 if (rx_status & WMI_RX_STATUS_ERR_CRC) {
2223 dev_kfree_skb(skb);
2224 return 0;
2227 if (rx_status & WMI_RX_STATUS_ERR_MIC)
2228 status->flag |= RX_FLAG_MMIC_ERROR;
2230 /* Hardware can Rx CCK rates on 5GHz. In that case phy_mode is set to
2231 * MODE_11B. This means phy_mode is not a reliable source for the band
2232 * of mgmt rx.
2234 if (channel >= 1 && channel <= 14) {
2235 status->band = IEEE80211_BAND_2GHZ;
2236 } else if (channel >= 36 && channel <= 165) {
2237 status->band = IEEE80211_BAND_5GHZ;
2238 } else {
2239 /* Shouldn't happen unless list of advertised channels to
2240 * mac80211 has been changed.
2242 WARN_ON_ONCE(1);
2243 dev_kfree_skb(skb);
2244 return 0;
2247 if (phy_mode == MODE_11B && status->band == IEEE80211_BAND_5GHZ)
2248 ath10k_dbg(ar, ATH10K_DBG_MGMT, "wmi mgmt rx 11b (CCK) on 5GHz\n");
2250 sband = &ar->mac.sbands[status->band];
2252 status->freq = ieee80211_channel_to_frequency(channel, status->band);
2253 status->signal = snr + ATH10K_DEFAULT_NOISE_FLOOR;
2254 status->rate_idx = ath10k_mac_bitrate_to_idx(sband, rate / 100);
2256 hdr = (struct ieee80211_hdr *)skb->data;
2257 fc = le16_to_cpu(hdr->frame_control);
2259 ath10k_wmi_handle_wep_reauth(ar, skb, status);
2261 /* FW delivers WEP Shared Auth frame with Protected Bit set and
2262 * encrypted payload. However in case of PMF it delivers decrypted
2263 * frames with Protected Bit set. */
2264 if (ieee80211_has_protected(hdr->frame_control) &&
2265 !ieee80211_is_auth(hdr->frame_control)) {
2266 status->flag |= RX_FLAG_DECRYPTED;
2268 if (!ieee80211_is_action(hdr->frame_control) &&
2269 !ieee80211_is_deauth(hdr->frame_control) &&
2270 !ieee80211_is_disassoc(hdr->frame_control)) {
2271 status->flag |= RX_FLAG_IV_STRIPPED |
2272 RX_FLAG_MMIC_STRIPPED;
2273 hdr->frame_control = __cpu_to_le16(fc &
2274 ~IEEE80211_FCTL_PROTECTED);
2278 if (ieee80211_is_beacon(hdr->frame_control))
2279 ath10k_mac_handle_beacon(ar, skb);
2281 ath10k_dbg(ar, ATH10K_DBG_MGMT,
2282 "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
2283 skb, skb->len,
2284 fc & IEEE80211_FCTL_FTYPE, fc & IEEE80211_FCTL_STYPE);
2286 ath10k_dbg(ar, ATH10K_DBG_MGMT,
2287 "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
2288 status->freq, status->band, status->signal,
2289 status->rate_idx);
2291 ieee80211_rx(ar->hw, skb);
2292 return 0;
2295 static int freq_to_idx(struct ath10k *ar, int freq)
2297 struct ieee80211_supported_band *sband;
2298 int band, ch, idx = 0;
2300 for (band = IEEE80211_BAND_2GHZ; band < IEEE80211_NUM_BANDS; band++) {
2301 sband = ar->hw->wiphy->bands[band];
2302 if (!sband)
2303 continue;
2305 for (ch = 0; ch < sband->n_channels; ch++, idx++)
2306 if (sband->channels[ch].center_freq == freq)
2307 goto exit;
2310 exit:
2311 return idx;
2314 static int ath10k_wmi_op_pull_ch_info_ev(struct ath10k *ar, struct sk_buff *skb,
2315 struct wmi_ch_info_ev_arg *arg)
2317 struct wmi_chan_info_event *ev = (void *)skb->data;
2319 if (skb->len < sizeof(*ev))
2320 return -EPROTO;
2322 skb_pull(skb, sizeof(*ev));
2323 arg->err_code = ev->err_code;
2324 arg->freq = ev->freq;
2325 arg->cmd_flags = ev->cmd_flags;
2326 arg->noise_floor = ev->noise_floor;
2327 arg->rx_clear_count = ev->rx_clear_count;
2328 arg->cycle_count = ev->cycle_count;
2330 return 0;
2333 static int ath10k_wmi_10_4_op_pull_ch_info_ev(struct ath10k *ar,
2334 struct sk_buff *skb,
2335 struct wmi_ch_info_ev_arg *arg)
2337 struct wmi_10_4_chan_info_event *ev = (void *)skb->data;
2339 if (skb->len < sizeof(*ev))
2340 return -EPROTO;
2342 skb_pull(skb, sizeof(*ev));
2343 arg->err_code = ev->err_code;
2344 arg->freq = ev->freq;
2345 arg->cmd_flags = ev->cmd_flags;
2346 arg->noise_floor = ev->noise_floor;
2347 arg->rx_clear_count = ev->rx_clear_count;
2348 arg->cycle_count = ev->cycle_count;
2349 arg->chan_tx_pwr_range = ev->chan_tx_pwr_range;
2350 arg->chan_tx_pwr_tp = ev->chan_tx_pwr_tp;
2351 arg->rx_frame_count = ev->rx_frame_count;
2353 return 0;
2356 void ath10k_wmi_event_chan_info(struct ath10k *ar, struct sk_buff *skb)
2358 struct wmi_ch_info_ev_arg arg = {};
2359 struct survey_info *survey;
2360 u32 err_code, freq, cmd_flags, noise_floor, rx_clear_count, cycle_count;
2361 int idx, ret;
2363 ret = ath10k_wmi_pull_ch_info(ar, skb, &arg);
2364 if (ret) {
2365 ath10k_warn(ar, "failed to parse chan info event: %d\n", ret);
2366 return;
2369 err_code = __le32_to_cpu(arg.err_code);
2370 freq = __le32_to_cpu(arg.freq);
2371 cmd_flags = __le32_to_cpu(arg.cmd_flags);
2372 noise_floor = __le32_to_cpu(arg.noise_floor);
2373 rx_clear_count = __le32_to_cpu(arg.rx_clear_count);
2374 cycle_count = __le32_to_cpu(arg.cycle_count);
2376 ath10k_dbg(ar, ATH10K_DBG_WMI,
2377 "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
2378 err_code, freq, cmd_flags, noise_floor, rx_clear_count,
2379 cycle_count);
2381 spin_lock_bh(&ar->data_lock);
2383 switch (ar->scan.state) {
2384 case ATH10K_SCAN_IDLE:
2385 case ATH10K_SCAN_STARTING:
2386 ath10k_warn(ar, "received chan info event without a scan request, ignoring\n");
2387 goto exit;
2388 case ATH10K_SCAN_RUNNING:
2389 case ATH10K_SCAN_ABORTING:
2390 break;
2393 idx = freq_to_idx(ar, freq);
2394 if (idx >= ARRAY_SIZE(ar->survey)) {
2395 ath10k_warn(ar, "chan info: invalid frequency %d (idx %d out of bounds)\n",
2396 freq, idx);
2397 goto exit;
2400 if (cmd_flags & WMI_CHAN_INFO_FLAG_COMPLETE) {
2401 if (ar->ch_info_can_report_survey) {
2402 survey = &ar->survey[idx];
2403 survey->noise = noise_floor;
2404 survey->filled = SURVEY_INFO_NOISE_DBM;
2406 ath10k_hw_fill_survey_time(ar,
2407 survey,
2408 cycle_count,
2409 rx_clear_count,
2410 ar->survey_last_cycle_count,
2411 ar->survey_last_rx_clear_count);
2414 ar->ch_info_can_report_survey = false;
2415 } else {
2416 ar->ch_info_can_report_survey = true;
2419 if (!(cmd_flags & WMI_CHAN_INFO_FLAG_PRE_COMPLETE)) {
2420 ar->survey_last_rx_clear_count = rx_clear_count;
2421 ar->survey_last_cycle_count = cycle_count;
2424 exit:
2425 spin_unlock_bh(&ar->data_lock);
2428 void ath10k_wmi_event_echo(struct ath10k *ar, struct sk_buff *skb)
2430 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_ECHO_EVENTID\n");
2433 int ath10k_wmi_event_debug_mesg(struct ath10k *ar, struct sk_buff *skb)
2435 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event debug mesg len %d\n",
2436 skb->len);
2438 trace_ath10k_wmi_dbglog(ar, skb->data, skb->len);
2440 return 0;
2443 void ath10k_wmi_pull_pdev_stats_base(const struct wmi_pdev_stats_base *src,
2444 struct ath10k_fw_stats_pdev *dst)
2446 dst->ch_noise_floor = __le32_to_cpu(src->chan_nf);
2447 dst->tx_frame_count = __le32_to_cpu(src->tx_frame_count);
2448 dst->rx_frame_count = __le32_to_cpu(src->rx_frame_count);
2449 dst->rx_clear_count = __le32_to_cpu(src->rx_clear_count);
2450 dst->cycle_count = __le32_to_cpu(src->cycle_count);
2451 dst->phy_err_count = __le32_to_cpu(src->phy_err_count);
2452 dst->chan_tx_power = __le32_to_cpu(src->chan_tx_pwr);
2455 void ath10k_wmi_pull_pdev_stats_tx(const struct wmi_pdev_stats_tx *src,
2456 struct ath10k_fw_stats_pdev *dst)
2458 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2459 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2460 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2461 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2462 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2463 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2464 dst->local_freed = __le32_to_cpu(src->local_freed);
2465 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2466 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2467 dst->underrun = __le32_to_cpu(src->underrun);
2468 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2469 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2470 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2471 dst->data_rc = __le32_to_cpu(src->data_rc);
2472 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2473 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2474 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2475 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2476 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2477 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2478 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2479 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2482 static void
2483 ath10k_wmi_10_4_pull_pdev_stats_tx(const struct wmi_10_4_pdev_stats_tx *src,
2484 struct ath10k_fw_stats_pdev *dst)
2486 dst->comp_queued = __le32_to_cpu(src->comp_queued);
2487 dst->comp_delivered = __le32_to_cpu(src->comp_delivered);
2488 dst->msdu_enqued = __le32_to_cpu(src->msdu_enqued);
2489 dst->mpdu_enqued = __le32_to_cpu(src->mpdu_enqued);
2490 dst->wmm_drop = __le32_to_cpu(src->wmm_drop);
2491 dst->local_enqued = __le32_to_cpu(src->local_enqued);
2492 dst->local_freed = __le32_to_cpu(src->local_freed);
2493 dst->hw_queued = __le32_to_cpu(src->hw_queued);
2494 dst->hw_reaped = __le32_to_cpu(src->hw_reaped);
2495 dst->underrun = __le32_to_cpu(src->underrun);
2496 dst->tx_abort = __le32_to_cpu(src->tx_abort);
2497 dst->mpdus_requed = __le32_to_cpu(src->mpdus_requed);
2498 dst->tx_ko = __le32_to_cpu(src->tx_ko);
2499 dst->data_rc = __le32_to_cpu(src->data_rc);
2500 dst->self_triggers = __le32_to_cpu(src->self_triggers);
2501 dst->sw_retry_failure = __le32_to_cpu(src->sw_retry_failure);
2502 dst->illgl_rate_phy_err = __le32_to_cpu(src->illgl_rate_phy_err);
2503 dst->pdev_cont_xretry = __le32_to_cpu(src->pdev_cont_xretry);
2504 dst->pdev_tx_timeout = __le32_to_cpu(src->pdev_tx_timeout);
2505 dst->pdev_resets = __le32_to_cpu(src->pdev_resets);
2506 dst->phy_underrun = __le32_to_cpu(src->phy_underrun);
2507 dst->txop_ovf = __le32_to_cpu(src->txop_ovf);
2508 dst->hw_paused = __le32_to_cpu(src->hw_paused);
2509 dst->seq_posted = __le32_to_cpu(src->seq_posted);
2510 dst->seq_failed_queueing =
2511 __le32_to_cpu(src->seq_failed_queueing);
2512 dst->seq_completed = __le32_to_cpu(src->seq_completed);
2513 dst->seq_restarted = __le32_to_cpu(src->seq_restarted);
2514 dst->mu_seq_posted = __le32_to_cpu(src->mu_seq_posted);
2515 dst->mpdus_sw_flush = __le32_to_cpu(src->mpdus_sw_flush);
2516 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2517 dst->mpdus_truncated = __le32_to_cpu(src->mpdus_truncated);
2518 dst->mpdus_ack_failed = __le32_to_cpu(src->mpdus_ack_failed);
2519 dst->mpdus_hw_filter = __le32_to_cpu(src->mpdus_hw_filter);
2520 dst->mpdus_expired = __le32_to_cpu(src->mpdus_expired);
2523 void ath10k_wmi_pull_pdev_stats_rx(const struct wmi_pdev_stats_rx *src,
2524 struct ath10k_fw_stats_pdev *dst)
2526 dst->mid_ppdu_route_change = __le32_to_cpu(src->mid_ppdu_route_change);
2527 dst->status_rcvd = __le32_to_cpu(src->status_rcvd);
2528 dst->r0_frags = __le32_to_cpu(src->r0_frags);
2529 dst->r1_frags = __le32_to_cpu(src->r1_frags);
2530 dst->r2_frags = __le32_to_cpu(src->r2_frags);
2531 dst->r3_frags = __le32_to_cpu(src->r3_frags);
2532 dst->htt_msdus = __le32_to_cpu(src->htt_msdus);
2533 dst->htt_mpdus = __le32_to_cpu(src->htt_mpdus);
2534 dst->loc_msdus = __le32_to_cpu(src->loc_msdus);
2535 dst->loc_mpdus = __le32_to_cpu(src->loc_mpdus);
2536 dst->oversize_amsdu = __le32_to_cpu(src->oversize_amsdu);
2537 dst->phy_errs = __le32_to_cpu(src->phy_errs);
2538 dst->phy_err_drop = __le32_to_cpu(src->phy_err_drop);
2539 dst->mpdu_errs = __le32_to_cpu(src->mpdu_errs);
2542 void ath10k_wmi_pull_pdev_stats_extra(const struct wmi_pdev_stats_extra *src,
2543 struct ath10k_fw_stats_pdev *dst)
2545 dst->ack_rx_bad = __le32_to_cpu(src->ack_rx_bad);
2546 dst->rts_bad = __le32_to_cpu(src->rts_bad);
2547 dst->rts_good = __le32_to_cpu(src->rts_good);
2548 dst->fcs_bad = __le32_to_cpu(src->fcs_bad);
2549 dst->no_beacons = __le32_to_cpu(src->no_beacons);
2550 dst->mib_int_count = __le32_to_cpu(src->mib_int_count);
2553 void ath10k_wmi_pull_peer_stats(const struct wmi_peer_stats *src,
2554 struct ath10k_fw_stats_peer *dst)
2556 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2557 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2558 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2561 static int ath10k_wmi_main_op_pull_fw_stats(struct ath10k *ar,
2562 struct sk_buff *skb,
2563 struct ath10k_fw_stats *stats)
2565 const struct wmi_stats_event *ev = (void *)skb->data;
2566 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2567 int i;
2569 if (!skb_pull(skb, sizeof(*ev)))
2570 return -EPROTO;
2572 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2573 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2574 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2576 for (i = 0; i < num_pdev_stats; i++) {
2577 const struct wmi_pdev_stats *src;
2578 struct ath10k_fw_stats_pdev *dst;
2580 src = (void *)skb->data;
2581 if (!skb_pull(skb, sizeof(*src)))
2582 return -EPROTO;
2584 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2585 if (!dst)
2586 continue;
2588 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2589 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2590 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2592 list_add_tail(&dst->list, &stats->pdevs);
2595 /* fw doesn't implement vdev stats */
2597 for (i = 0; i < num_peer_stats; i++) {
2598 const struct wmi_peer_stats *src;
2599 struct ath10k_fw_stats_peer *dst;
2601 src = (void *)skb->data;
2602 if (!skb_pull(skb, sizeof(*src)))
2603 return -EPROTO;
2605 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2606 if (!dst)
2607 continue;
2609 ath10k_wmi_pull_peer_stats(src, dst);
2610 list_add_tail(&dst->list, &stats->peers);
2613 return 0;
2616 static int ath10k_wmi_10x_op_pull_fw_stats(struct ath10k *ar,
2617 struct sk_buff *skb,
2618 struct ath10k_fw_stats *stats)
2620 const struct wmi_stats_event *ev = (void *)skb->data;
2621 u32 num_pdev_stats, num_vdev_stats, num_peer_stats;
2622 int i;
2624 if (!skb_pull(skb, sizeof(*ev)))
2625 return -EPROTO;
2627 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2628 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2629 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2631 for (i = 0; i < num_pdev_stats; i++) {
2632 const struct wmi_10x_pdev_stats *src;
2633 struct ath10k_fw_stats_pdev *dst;
2635 src = (void *)skb->data;
2636 if (!skb_pull(skb, sizeof(*src)))
2637 return -EPROTO;
2639 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2640 if (!dst)
2641 continue;
2643 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2644 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2645 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2646 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2648 list_add_tail(&dst->list, &stats->pdevs);
2651 /* fw doesn't implement vdev stats */
2653 for (i = 0; i < num_peer_stats; i++) {
2654 const struct wmi_10x_peer_stats *src;
2655 struct ath10k_fw_stats_peer *dst;
2657 src = (void *)skb->data;
2658 if (!skb_pull(skb, sizeof(*src)))
2659 return -EPROTO;
2661 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2662 if (!dst)
2663 continue;
2665 ath10k_wmi_pull_peer_stats(&src->old, dst);
2667 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2669 list_add_tail(&dst->list, &stats->peers);
2672 return 0;
2675 static int ath10k_wmi_10_2_op_pull_fw_stats(struct ath10k *ar,
2676 struct sk_buff *skb,
2677 struct ath10k_fw_stats *stats)
2679 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2680 u32 num_pdev_stats;
2681 u32 num_pdev_ext_stats;
2682 u32 num_vdev_stats;
2683 u32 num_peer_stats;
2684 int i;
2686 if (!skb_pull(skb, sizeof(*ev)))
2687 return -EPROTO;
2689 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2690 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2691 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2692 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2694 for (i = 0; i < num_pdev_stats; i++) {
2695 const struct wmi_10_2_pdev_stats *src;
2696 struct ath10k_fw_stats_pdev *dst;
2698 src = (void *)skb->data;
2699 if (!skb_pull(skb, sizeof(*src)))
2700 return -EPROTO;
2702 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2703 if (!dst)
2704 continue;
2706 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2707 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2708 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2709 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2710 /* FIXME: expose 10.2 specific values */
2712 list_add_tail(&dst->list, &stats->pdevs);
2715 for (i = 0; i < num_pdev_ext_stats; i++) {
2716 const struct wmi_10_2_pdev_ext_stats *src;
2718 src = (void *)skb->data;
2719 if (!skb_pull(skb, sizeof(*src)))
2720 return -EPROTO;
2722 /* FIXME: expose values to userspace
2724 * Note: Even though this loop seems to do nothing it is
2725 * required to parse following sub-structures properly.
2729 /* fw doesn't implement vdev stats */
2731 for (i = 0; i < num_peer_stats; i++) {
2732 const struct wmi_10_2_peer_stats *src;
2733 struct ath10k_fw_stats_peer *dst;
2735 src = (void *)skb->data;
2736 if (!skb_pull(skb, sizeof(*src)))
2737 return -EPROTO;
2739 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2740 if (!dst)
2741 continue;
2743 ath10k_wmi_pull_peer_stats(&src->old, dst);
2745 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2746 /* FIXME: expose 10.2 specific values */
2748 list_add_tail(&dst->list, &stats->peers);
2751 return 0;
2754 static int ath10k_wmi_10_2_4_op_pull_fw_stats(struct ath10k *ar,
2755 struct sk_buff *skb,
2756 struct ath10k_fw_stats *stats)
2758 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2759 u32 num_pdev_stats;
2760 u32 num_pdev_ext_stats;
2761 u32 num_vdev_stats;
2762 u32 num_peer_stats;
2763 int i;
2765 if (!skb_pull(skb, sizeof(*ev)))
2766 return -EPROTO;
2768 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2769 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2770 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2771 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2773 for (i = 0; i < num_pdev_stats; i++) {
2774 const struct wmi_10_2_pdev_stats *src;
2775 struct ath10k_fw_stats_pdev *dst;
2777 src = (void *)skb->data;
2778 if (!skb_pull(skb, sizeof(*src)))
2779 return -EPROTO;
2781 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2782 if (!dst)
2783 continue;
2785 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2786 ath10k_wmi_pull_pdev_stats_tx(&src->tx, dst);
2787 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2788 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2789 /* FIXME: expose 10.2 specific values */
2791 list_add_tail(&dst->list, &stats->pdevs);
2794 for (i = 0; i < num_pdev_ext_stats; i++) {
2795 const struct wmi_10_2_pdev_ext_stats *src;
2797 src = (void *)skb->data;
2798 if (!skb_pull(skb, sizeof(*src)))
2799 return -EPROTO;
2801 /* FIXME: expose values to userspace
2803 * Note: Even though this loop seems to do nothing it is
2804 * required to parse following sub-structures properly.
2808 /* fw doesn't implement vdev stats */
2810 for (i = 0; i < num_peer_stats; i++) {
2811 const struct wmi_10_2_4_peer_stats *src;
2812 struct ath10k_fw_stats_peer *dst;
2814 src = (void *)skb->data;
2815 if (!skb_pull(skb, sizeof(*src)))
2816 return -EPROTO;
2818 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2819 if (!dst)
2820 continue;
2822 ath10k_wmi_pull_peer_stats(&src->common.old, dst);
2824 dst->peer_rx_rate = __le32_to_cpu(src->common.peer_rx_rate);
2825 /* FIXME: expose 10.2 specific values */
2827 list_add_tail(&dst->list, &stats->peers);
2830 return 0;
2833 static int ath10k_wmi_10_4_op_pull_fw_stats(struct ath10k *ar,
2834 struct sk_buff *skb,
2835 struct ath10k_fw_stats *stats)
2837 const struct wmi_10_2_stats_event *ev = (void *)skb->data;
2838 u32 num_pdev_stats;
2839 u32 num_pdev_ext_stats;
2840 u32 num_vdev_stats;
2841 u32 num_peer_stats;
2842 int i;
2844 if (!skb_pull(skb, sizeof(*ev)))
2845 return -EPROTO;
2847 num_pdev_stats = __le32_to_cpu(ev->num_pdev_stats);
2848 num_pdev_ext_stats = __le32_to_cpu(ev->num_pdev_ext_stats);
2849 num_vdev_stats = __le32_to_cpu(ev->num_vdev_stats);
2850 num_peer_stats = __le32_to_cpu(ev->num_peer_stats);
2852 for (i = 0; i < num_pdev_stats; i++) {
2853 const struct wmi_10_4_pdev_stats *src;
2854 struct ath10k_fw_stats_pdev *dst;
2856 src = (void *)skb->data;
2857 if (!skb_pull(skb, sizeof(*src)))
2858 return -EPROTO;
2860 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2861 if (!dst)
2862 continue;
2864 ath10k_wmi_pull_pdev_stats_base(&src->base, dst);
2865 ath10k_wmi_10_4_pull_pdev_stats_tx(&src->tx, dst);
2866 ath10k_wmi_pull_pdev_stats_rx(&src->rx, dst);
2867 dst->rx_ovfl_errs = __le32_to_cpu(src->rx_ovfl_errs);
2868 ath10k_wmi_pull_pdev_stats_extra(&src->extra, dst);
2870 list_add_tail(&dst->list, &stats->pdevs);
2873 for (i = 0; i < num_pdev_ext_stats; i++) {
2874 const struct wmi_10_2_pdev_ext_stats *src;
2876 src = (void *)skb->data;
2877 if (!skb_pull(skb, sizeof(*src)))
2878 return -EPROTO;
2880 /* FIXME: expose values to userspace
2882 * Note: Even though this loop seems to do nothing it is
2883 * required to parse following sub-structures properly.
2887 /* fw doesn't implement vdev stats */
2889 for (i = 0; i < num_peer_stats; i++) {
2890 const struct wmi_10_4_peer_stats *src;
2891 struct ath10k_fw_stats_peer *dst;
2893 src = (void *)skb->data;
2894 if (!skb_pull(skb, sizeof(*src)))
2895 return -EPROTO;
2897 dst = kzalloc(sizeof(*dst), GFP_ATOMIC);
2898 if (!dst)
2899 continue;
2901 ether_addr_copy(dst->peer_macaddr, src->peer_macaddr.addr);
2902 dst->peer_rssi = __le32_to_cpu(src->peer_rssi);
2903 dst->peer_tx_rate = __le32_to_cpu(src->peer_tx_rate);
2904 dst->peer_rx_rate = __le32_to_cpu(src->peer_rx_rate);
2905 /* FIXME: expose 10.4 specific values */
2907 list_add_tail(&dst->list, &stats->peers);
2910 return 0;
2913 void ath10k_wmi_event_update_stats(struct ath10k *ar, struct sk_buff *skb)
2915 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_UPDATE_STATS_EVENTID\n");
2916 ath10k_debug_fw_stats_process(ar, skb);
2919 static int
2920 ath10k_wmi_op_pull_vdev_start_ev(struct ath10k *ar, struct sk_buff *skb,
2921 struct wmi_vdev_start_ev_arg *arg)
2923 struct wmi_vdev_start_response_event *ev = (void *)skb->data;
2925 if (skb->len < sizeof(*ev))
2926 return -EPROTO;
2928 skb_pull(skb, sizeof(*ev));
2929 arg->vdev_id = ev->vdev_id;
2930 arg->req_id = ev->req_id;
2931 arg->resp_type = ev->resp_type;
2932 arg->status = ev->status;
2934 return 0;
2937 void ath10k_wmi_event_vdev_start_resp(struct ath10k *ar, struct sk_buff *skb)
2939 struct wmi_vdev_start_ev_arg arg = {};
2940 int ret;
2942 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_START_RESP_EVENTID\n");
2944 ret = ath10k_wmi_pull_vdev_start(ar, skb, &arg);
2945 if (ret) {
2946 ath10k_warn(ar, "failed to parse vdev start event: %d\n", ret);
2947 return;
2950 if (WARN_ON(__le32_to_cpu(arg.status)))
2951 return;
2953 complete(&ar->vdev_setup_done);
2956 void ath10k_wmi_event_vdev_stopped(struct ath10k *ar, struct sk_buff *skb)
2958 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STOPPED_EVENTID\n");
2959 complete(&ar->vdev_setup_done);
2962 static int
2963 ath10k_wmi_op_pull_peer_kick_ev(struct ath10k *ar, struct sk_buff *skb,
2964 struct wmi_peer_kick_ev_arg *arg)
2966 struct wmi_peer_sta_kickout_event *ev = (void *)skb->data;
2968 if (skb->len < sizeof(*ev))
2969 return -EPROTO;
2971 skb_pull(skb, sizeof(*ev));
2972 arg->mac_addr = ev->peer_macaddr.addr;
2974 return 0;
2977 void ath10k_wmi_event_peer_sta_kickout(struct ath10k *ar, struct sk_buff *skb)
2979 struct wmi_peer_kick_ev_arg arg = {};
2980 struct ieee80211_sta *sta;
2981 int ret;
2983 ret = ath10k_wmi_pull_peer_kick(ar, skb, &arg);
2984 if (ret) {
2985 ath10k_warn(ar, "failed to parse peer kickout event: %d\n",
2986 ret);
2987 return;
2990 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi event peer sta kickout %pM\n",
2991 arg.mac_addr);
2993 rcu_read_lock();
2995 sta = ieee80211_find_sta_by_ifaddr(ar->hw, arg.mac_addr, NULL);
2996 if (!sta) {
2997 ath10k_warn(ar, "Spurious quick kickout for STA %pM\n",
2998 arg.mac_addr);
2999 goto exit;
3002 ieee80211_report_low_ack(sta, 10);
3004 exit:
3005 rcu_read_unlock();
3009 * FIXME
3011 * We don't report to mac80211 sleep state of connected
3012 * stations. Due to this mac80211 can't fill in TIM IE
3013 * correctly.
3015 * I know of no way of getting nullfunc frames that contain
3016 * sleep transition from connected stations - these do not
3017 * seem to be sent from the target to the host. There also
3018 * doesn't seem to be a dedicated event for that. So the
3019 * only way left to do this would be to read tim_bitmap
3020 * during SWBA.
3022 * We could probably try using tim_bitmap from SWBA to tell
3023 * mac80211 which stations are asleep and which are not. The
3024 * problem here is calling mac80211 functions so many times
3025 * could take too long and make us miss the time to submit
3026 * the beacon to the target.
3028 * So as a workaround we try to extend the TIM IE if there
3029 * is unicast buffered for stations with aid > 7 and fill it
3030 * in ourselves.
3032 static void ath10k_wmi_update_tim(struct ath10k *ar,
3033 struct ath10k_vif *arvif,
3034 struct sk_buff *bcn,
3035 const struct wmi_tim_info_arg *tim_info)
3037 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)bcn->data;
3038 struct ieee80211_tim_ie *tim;
3039 u8 *ies, *ie;
3040 u8 ie_len, pvm_len;
3041 __le32 t;
3042 u32 v, tim_len;
3044 /* When FW reports 0 in tim_len, ensure atleast first byte
3045 * in tim_bitmap is considered for pvm calculation.
3047 tim_len = tim_info->tim_len ? __le32_to_cpu(tim_info->tim_len) : 1;
3049 /* if next SWBA has no tim_changed the tim_bitmap is garbage.
3050 * we must copy the bitmap upon change and reuse it later */
3051 if (__le32_to_cpu(tim_info->tim_changed)) {
3052 int i;
3054 if (sizeof(arvif->u.ap.tim_bitmap) < tim_len) {
3055 ath10k_warn(ar, "SWBA TIM field is too big (%u), truncated it to %zu",
3056 tim_len, sizeof(arvif->u.ap.tim_bitmap));
3057 tim_len = sizeof(arvif->u.ap.tim_bitmap);
3060 for (i = 0; i < tim_len; i++) {
3061 t = tim_info->tim_bitmap[i / 4];
3062 v = __le32_to_cpu(t);
3063 arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF;
3066 /* FW reports either length 0 or length based on max supported
3067 * station. so we calculate this on our own
3069 arvif->u.ap.tim_len = 0;
3070 for (i = 0; i < tim_len; i++)
3071 if (arvif->u.ap.tim_bitmap[i])
3072 arvif->u.ap.tim_len = i;
3074 arvif->u.ap.tim_len++;
3077 ies = bcn->data;
3078 ies += ieee80211_hdrlen(hdr->frame_control);
3079 ies += 12; /* fixed parameters */
3081 ie = (u8 *)cfg80211_find_ie(WLAN_EID_TIM, ies,
3082 (u8 *)skb_tail_pointer(bcn) - ies);
3083 if (!ie) {
3084 if (arvif->vdev_type != WMI_VDEV_TYPE_IBSS)
3085 ath10k_warn(ar, "no tim ie found;\n");
3086 return;
3089 tim = (void *)ie + 2;
3090 ie_len = ie[1];
3091 pvm_len = ie_len - 3; /* exclude dtim count, dtim period, bmap ctl */
3093 if (pvm_len < arvif->u.ap.tim_len) {
3094 int expand_size = tim_len - pvm_len;
3095 int move_size = skb_tail_pointer(bcn) - (ie + 2 + ie_len);
3096 void *next_ie = ie + 2 + ie_len;
3098 if (skb_put(bcn, expand_size)) {
3099 memmove(next_ie + expand_size, next_ie, move_size);
3101 ie[1] += expand_size;
3102 ie_len += expand_size;
3103 pvm_len += expand_size;
3104 } else {
3105 ath10k_warn(ar, "tim expansion failed\n");
3109 if (pvm_len > tim_len) {
3110 ath10k_warn(ar, "tim pvm length is too great (%d)\n", pvm_len);
3111 return;
3114 tim->bitmap_ctrl = !!__le32_to_cpu(tim_info->tim_mcast);
3115 memcpy(tim->virtual_map, arvif->u.ap.tim_bitmap, pvm_len);
3117 if (tim->dtim_count == 0) {
3118 ATH10K_SKB_CB(bcn)->bcn.dtim_zero = true;
3120 if (__le32_to_cpu(tim_info->tim_mcast) == 1)
3121 ATH10K_SKB_CB(bcn)->bcn.deliver_cab = true;
3124 ath10k_dbg(ar, ATH10K_DBG_MGMT, "dtim %d/%d mcast %d pvmlen %d\n",
3125 tim->dtim_count, tim->dtim_period,
3126 tim->bitmap_ctrl, pvm_len);
3129 static void ath10k_wmi_update_noa(struct ath10k *ar, struct ath10k_vif *arvif,
3130 struct sk_buff *bcn,
3131 const struct wmi_p2p_noa_info *noa)
3133 if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO)
3134 return;
3136 ath10k_dbg(ar, ATH10K_DBG_MGMT, "noa changed: %d\n", noa->changed);
3138 if (noa->changed & WMI_P2P_NOA_CHANGED_BIT)
3139 ath10k_p2p_noa_update(arvif, noa);
3141 if (arvif->u.ap.noa_data)
3142 if (!pskb_expand_head(bcn, 0, arvif->u.ap.noa_len, GFP_ATOMIC))
3143 memcpy(skb_put(bcn, arvif->u.ap.noa_len),
3144 arvif->u.ap.noa_data,
3145 arvif->u.ap.noa_len);
3148 static int ath10k_wmi_op_pull_swba_ev(struct ath10k *ar, struct sk_buff *skb,
3149 struct wmi_swba_ev_arg *arg)
3151 struct wmi_host_swba_event *ev = (void *)skb->data;
3152 u32 map;
3153 size_t i;
3155 if (skb->len < sizeof(*ev))
3156 return -EPROTO;
3158 skb_pull(skb, sizeof(*ev));
3159 arg->vdev_map = ev->vdev_map;
3161 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3162 if (!(map & BIT(0)))
3163 continue;
3165 /* If this happens there were some changes in firmware and
3166 * ath10k should update the max size of tim_info array.
3168 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3169 break;
3171 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3172 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3173 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3174 return -EPROTO;
3177 arg->tim_info[i].tim_len = ev->bcn_info[i].tim_info.tim_len;
3178 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3179 arg->tim_info[i].tim_bitmap =
3180 ev->bcn_info[i].tim_info.tim_bitmap;
3181 arg->tim_info[i].tim_changed =
3182 ev->bcn_info[i].tim_info.tim_changed;
3183 arg->tim_info[i].tim_num_ps_pending =
3184 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3186 arg->noa_info[i] = &ev->bcn_info[i].p2p_noa_info;
3187 i++;
3190 return 0;
3193 static int ath10k_wmi_10_4_op_pull_swba_ev(struct ath10k *ar,
3194 struct sk_buff *skb,
3195 struct wmi_swba_ev_arg *arg)
3197 struct wmi_10_4_host_swba_event *ev = (void *)skb->data;
3198 u32 map, tim_len;
3199 size_t i;
3201 if (skb->len < sizeof(*ev))
3202 return -EPROTO;
3204 skb_pull(skb, sizeof(*ev));
3205 arg->vdev_map = ev->vdev_map;
3207 for (i = 0, map = __le32_to_cpu(ev->vdev_map); map; map >>= 1) {
3208 if (!(map & BIT(0)))
3209 continue;
3211 /* If this happens there were some changes in firmware and
3212 * ath10k should update the max size of tim_info array.
3214 if (WARN_ON_ONCE(i == ARRAY_SIZE(arg->tim_info)))
3215 break;
3217 if (__le32_to_cpu(ev->bcn_info[i].tim_info.tim_len) >
3218 sizeof(ev->bcn_info[i].tim_info.tim_bitmap)) {
3219 ath10k_warn(ar, "refusing to parse invalid swba structure\n");
3220 return -EPROTO;
3223 tim_len = __le32_to_cpu(ev->bcn_info[i].tim_info.tim_len);
3224 if (tim_len) {
3225 /* Exclude 4 byte guard length */
3226 tim_len -= 4;
3227 arg->tim_info[i].tim_len = __cpu_to_le32(tim_len);
3228 } else {
3229 arg->tim_info[i].tim_len = 0;
3232 arg->tim_info[i].tim_mcast = ev->bcn_info[i].tim_info.tim_mcast;
3233 arg->tim_info[i].tim_bitmap =
3234 ev->bcn_info[i].tim_info.tim_bitmap;
3235 arg->tim_info[i].tim_changed =
3236 ev->bcn_info[i].tim_info.tim_changed;
3237 arg->tim_info[i].tim_num_ps_pending =
3238 ev->bcn_info[i].tim_info.tim_num_ps_pending;
3240 /* 10.4 firmware doesn't have p2p support. notice of absence
3241 * info can be ignored for now.
3244 i++;
3247 return 0;
3250 static enum wmi_txbf_conf ath10k_wmi_10_4_txbf_conf_scheme(struct ath10k *ar)
3252 return WMI_TXBF_CONF_BEFORE_ASSOC;
3255 void ath10k_wmi_event_host_swba(struct ath10k *ar, struct sk_buff *skb)
3257 struct wmi_swba_ev_arg arg = {};
3258 u32 map;
3259 int i = -1;
3260 const struct wmi_tim_info_arg *tim_info;
3261 const struct wmi_p2p_noa_info *noa_info;
3262 struct ath10k_vif *arvif;
3263 struct sk_buff *bcn;
3264 dma_addr_t paddr;
3265 int ret, vdev_id = 0;
3267 ret = ath10k_wmi_pull_swba(ar, skb, &arg);
3268 if (ret) {
3269 ath10k_warn(ar, "failed to parse swba event: %d\n", ret);
3270 return;
3273 map = __le32_to_cpu(arg.vdev_map);
3275 ath10k_dbg(ar, ATH10K_DBG_MGMT, "mgmt swba vdev_map 0x%x\n",
3276 map);
3278 for (; map; map >>= 1, vdev_id++) {
3279 if (!(map & 0x1))
3280 continue;
3282 i++;
3284 if (i >= WMI_MAX_AP_VDEV) {
3285 ath10k_warn(ar, "swba has corrupted vdev map\n");
3286 break;
3289 tim_info = &arg.tim_info[i];
3290 noa_info = arg.noa_info[i];
3292 ath10k_dbg(ar, ATH10K_DBG_MGMT,
3293 "mgmt event bcn_info %d tim_len %d mcast %d changed %d num_ps_pending %d bitmap 0x%08x%08x%08x%08x\n",
3295 __le32_to_cpu(tim_info->tim_len),
3296 __le32_to_cpu(tim_info->tim_mcast),
3297 __le32_to_cpu(tim_info->tim_changed),
3298 __le32_to_cpu(tim_info->tim_num_ps_pending),
3299 __le32_to_cpu(tim_info->tim_bitmap[3]),
3300 __le32_to_cpu(tim_info->tim_bitmap[2]),
3301 __le32_to_cpu(tim_info->tim_bitmap[1]),
3302 __le32_to_cpu(tim_info->tim_bitmap[0]));
3304 /* TODO: Only first 4 word from tim_bitmap is dumped.
3305 * Extend debug code to dump full tim_bitmap.
3308 arvif = ath10k_get_arvif(ar, vdev_id);
3309 if (arvif == NULL) {
3310 ath10k_warn(ar, "no vif for vdev_id %d found\n",
3311 vdev_id);
3312 continue;
3315 /* There are no completions for beacons so wait for next SWBA
3316 * before telling mac80211 to decrement CSA counter
3318 * Once CSA counter is completed stop sending beacons until
3319 * actual channel switch is done */
3320 if (arvif->vif->csa_active &&
3321 ieee80211_csa_is_complete(arvif->vif)) {
3322 ieee80211_csa_finish(arvif->vif);
3323 continue;
3326 bcn = ieee80211_beacon_get(ar->hw, arvif->vif);
3327 if (!bcn) {
3328 ath10k_warn(ar, "could not get mac80211 beacon\n");
3329 continue;
3332 ath10k_tx_h_seq_no(arvif->vif, bcn);
3333 ath10k_wmi_update_tim(ar, arvif, bcn, tim_info);
3334 ath10k_wmi_update_noa(ar, arvif, bcn, noa_info);
3336 spin_lock_bh(&ar->data_lock);
3338 if (arvif->beacon) {
3339 switch (arvif->beacon_state) {
3340 case ATH10K_BEACON_SENT:
3341 break;
3342 case ATH10K_BEACON_SCHEDULED:
3343 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped old beacon\n",
3344 arvif->vdev_id);
3345 break;
3346 case ATH10K_BEACON_SENDING:
3347 ath10k_warn(ar, "SWBA overrun on vdev %d, skipped new beacon\n",
3348 arvif->vdev_id);
3349 dev_kfree_skb(bcn);
3350 goto skip;
3353 ath10k_mac_vif_beacon_free(arvif);
3356 if (!arvif->beacon_buf) {
3357 paddr = dma_map_single(arvif->ar->dev, bcn->data,
3358 bcn->len, DMA_TO_DEVICE);
3359 ret = dma_mapping_error(arvif->ar->dev, paddr);
3360 if (ret) {
3361 ath10k_warn(ar, "failed to map beacon: %d\n",
3362 ret);
3363 dev_kfree_skb_any(bcn);
3364 ret = -EIO;
3365 goto skip;
3368 ATH10K_SKB_CB(bcn)->paddr = paddr;
3369 } else {
3370 if (bcn->len > IEEE80211_MAX_FRAME_LEN) {
3371 ath10k_warn(ar, "trimming beacon %d -> %d bytes!\n",
3372 bcn->len, IEEE80211_MAX_FRAME_LEN);
3373 skb_trim(bcn, IEEE80211_MAX_FRAME_LEN);
3375 memcpy(arvif->beacon_buf, bcn->data, bcn->len);
3376 ATH10K_SKB_CB(bcn)->paddr = arvif->beacon_paddr;
3379 arvif->beacon = bcn;
3380 arvif->beacon_state = ATH10K_BEACON_SCHEDULED;
3382 trace_ath10k_tx_hdr(ar, bcn->data, bcn->len);
3383 trace_ath10k_tx_payload(ar, bcn->data, bcn->len);
3385 skip:
3386 spin_unlock_bh(&ar->data_lock);
3389 ath10k_wmi_tx_beacons_nowait(ar);
3392 void ath10k_wmi_event_tbttoffset_update(struct ath10k *ar, struct sk_buff *skb)
3394 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
3397 static void ath10k_dfs_radar_report(struct ath10k *ar,
3398 struct wmi_phyerr_ev_arg *phyerr,
3399 const struct phyerr_radar_report *rr,
3400 u64 tsf)
3402 u32 reg0, reg1, tsf32l;
3403 struct ieee80211_channel *ch;
3404 struct pulse_event pe;
3405 u64 tsf64;
3406 u8 rssi, width;
3408 reg0 = __le32_to_cpu(rr->reg0);
3409 reg1 = __le32_to_cpu(rr->reg1);
3411 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3412 "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
3413 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP),
3414 MS(reg0, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH),
3415 MS(reg0, RADAR_REPORT_REG0_AGC_TOTAL_GAIN),
3416 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_DIFF));
3417 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3418 "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
3419 MS(reg0, RADAR_REPORT_REG0_PULSE_DELTA_PEAK),
3420 MS(reg0, RADAR_REPORT_REG0_PULSE_SIDX),
3421 MS(reg1, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID),
3422 MS(reg1, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN),
3423 MS(reg1, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK));
3424 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3425 "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
3426 MS(reg1, RADAR_REPORT_REG1_PULSE_TSF_OFFSET),
3427 MS(reg1, RADAR_REPORT_REG1_PULSE_DUR));
3429 if (!ar->dfs_detector)
3430 return;
3432 spin_lock_bh(&ar->data_lock);
3433 ch = ar->rx_channel;
3434 spin_unlock_bh(&ar->data_lock);
3436 if (!ch) {
3437 ath10k_warn(ar, "failed to derive channel for radar pulse, treating as radar\n");
3438 goto radar_detected;
3441 /* report event to DFS pattern detector */
3442 tsf32l = phyerr->tsf_timestamp;
3443 tsf64 = tsf & (~0xFFFFFFFFULL);
3444 tsf64 |= tsf32l;
3446 width = MS(reg1, RADAR_REPORT_REG1_PULSE_DUR);
3447 rssi = phyerr->rssi_combined;
3449 /* hardware store this as 8 bit signed value,
3450 * set to zero if negative number
3452 if (rssi & 0x80)
3453 rssi = 0;
3455 pe.ts = tsf64;
3456 pe.freq = ch->center_freq;
3457 pe.width = width;
3458 pe.rssi = rssi;
3459 pe.chirp = (MS(reg0, RADAR_REPORT_REG0_PULSE_IS_CHIRP) != 0);
3460 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3461 "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
3462 pe.freq, pe.width, pe.rssi, pe.ts);
3464 ATH10K_DFS_STAT_INC(ar, pulses_detected);
3466 if (!ar->dfs_detector->add_pulse(ar->dfs_detector, &pe)) {
3467 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3468 "dfs no pulse pattern detected, yet\n");
3469 return;
3472 radar_detected:
3473 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs radar detected\n");
3474 ATH10K_DFS_STAT_INC(ar, radar_detected);
3476 /* Control radar events reporting in debugfs file
3477 dfs_block_radar_events */
3478 if (ar->dfs_block_radar_events) {
3479 ath10k_info(ar, "DFS Radar detected, but ignored as requested\n");
3480 return;
3483 ieee80211_radar_detected(ar->hw);
3486 static int ath10k_dfs_fft_report(struct ath10k *ar,
3487 struct wmi_phyerr_ev_arg *phyerr,
3488 const struct phyerr_fft_report *fftr,
3489 u64 tsf)
3491 u32 reg0, reg1;
3492 u8 rssi, peak_mag;
3494 reg0 = __le32_to_cpu(fftr->reg0);
3495 reg1 = __le32_to_cpu(fftr->reg1);
3496 rssi = phyerr->rssi_combined;
3498 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3499 "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
3500 MS(reg0, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB),
3501 MS(reg0, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB),
3502 MS(reg0, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX),
3503 MS(reg0, SEARCH_FFT_REPORT_REG0_PEAK_SIDX));
3504 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3505 "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
3506 MS(reg1, SEARCH_FFT_REPORT_REG1_RELPWR_DB),
3507 MS(reg1, SEARCH_FFT_REPORT_REG1_AVGPWR_DB),
3508 MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG),
3509 MS(reg1, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB));
3511 peak_mag = MS(reg1, SEARCH_FFT_REPORT_REG1_PEAK_MAG);
3513 /* false event detection */
3514 if (rssi == DFS_RSSI_POSSIBLY_FALSE &&
3515 peak_mag < 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE) {
3516 ath10k_dbg(ar, ATH10K_DBG_REGULATORY, "dfs false pulse detected\n");
3517 ATH10K_DFS_STAT_INC(ar, pulses_discarded);
3518 return -EINVAL;
3521 return 0;
3524 void ath10k_wmi_event_dfs(struct ath10k *ar,
3525 struct wmi_phyerr_ev_arg *phyerr,
3526 u64 tsf)
3528 int buf_len, tlv_len, res, i = 0;
3529 const struct phyerr_tlv *tlv;
3530 const struct phyerr_radar_report *rr;
3531 const struct phyerr_fft_report *fftr;
3532 const u8 *tlv_buf;
3534 buf_len = phyerr->buf_len;
3535 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3536 "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
3537 phyerr->phy_err_code, phyerr->rssi_combined,
3538 phyerr->tsf_timestamp, tsf, buf_len);
3540 /* Skip event if DFS disabled */
3541 if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED))
3542 return;
3544 ATH10K_DFS_STAT_INC(ar, pulses_total);
3546 while (i < buf_len) {
3547 if (i + sizeof(*tlv) > buf_len) {
3548 ath10k_warn(ar, "too short buf for tlv header (%d)\n",
3550 return;
3553 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
3554 tlv_len = __le16_to_cpu(tlv->len);
3555 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
3556 ath10k_dbg(ar, ATH10K_DBG_REGULATORY,
3557 "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
3558 tlv_len, tlv->tag, tlv->sig);
3560 switch (tlv->tag) {
3561 case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY:
3562 if (i + sizeof(*tlv) + sizeof(*rr) > buf_len) {
3563 ath10k_warn(ar, "too short radar pulse summary (%d)\n",
3565 return;
3568 rr = (struct phyerr_radar_report *)tlv_buf;
3569 ath10k_dfs_radar_report(ar, phyerr, rr, tsf);
3570 break;
3571 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3572 if (i + sizeof(*tlv) + sizeof(*fftr) > buf_len) {
3573 ath10k_warn(ar, "too short fft report (%d)\n",
3575 return;
3578 fftr = (struct phyerr_fft_report *)tlv_buf;
3579 res = ath10k_dfs_fft_report(ar, phyerr, fftr, tsf);
3580 if (res)
3581 return;
3582 break;
3585 i += sizeof(*tlv) + tlv_len;
3589 void ath10k_wmi_event_spectral_scan(struct ath10k *ar,
3590 struct wmi_phyerr_ev_arg *phyerr,
3591 u64 tsf)
3593 int buf_len, tlv_len, res, i = 0;
3594 struct phyerr_tlv *tlv;
3595 const void *tlv_buf;
3596 const struct phyerr_fft_report *fftr;
3597 size_t fftr_len;
3599 buf_len = phyerr->buf_len;
3601 while (i < buf_len) {
3602 if (i + sizeof(*tlv) > buf_len) {
3603 ath10k_warn(ar, "failed to parse phyerr tlv header at byte %d\n",
3605 return;
3608 tlv = (struct phyerr_tlv *)&phyerr->buf[i];
3609 tlv_len = __le16_to_cpu(tlv->len);
3610 tlv_buf = &phyerr->buf[i + sizeof(*tlv)];
3612 if (i + sizeof(*tlv) + tlv_len > buf_len) {
3613 ath10k_warn(ar, "failed to parse phyerr tlv payload at byte %d\n",
3615 return;
3618 switch (tlv->tag) {
3619 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT:
3620 if (sizeof(*fftr) > tlv_len) {
3621 ath10k_warn(ar, "failed to parse fft report at byte %d\n",
3623 return;
3626 fftr_len = tlv_len - sizeof(*fftr);
3627 fftr = tlv_buf;
3628 res = ath10k_spectral_process_fft(ar, phyerr,
3629 fftr, fftr_len,
3630 tsf);
3631 if (res < 0) {
3632 ath10k_dbg(ar, ATH10K_DBG_WMI, "failed to process fft report: %d\n",
3633 res);
3634 return;
3636 break;
3639 i += sizeof(*tlv) + tlv_len;
3643 static int ath10k_wmi_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3644 struct sk_buff *skb,
3645 struct wmi_phyerr_hdr_arg *arg)
3647 struct wmi_phyerr_event *ev = (void *)skb->data;
3649 if (skb->len < sizeof(*ev))
3650 return -EPROTO;
3652 arg->num_phyerrs = __le32_to_cpu(ev->num_phyerrs);
3653 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3654 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3655 arg->buf_len = skb->len - sizeof(*ev);
3656 arg->phyerrs = ev->phyerrs;
3658 return 0;
3661 static int ath10k_wmi_10_4_op_pull_phyerr_ev_hdr(struct ath10k *ar,
3662 struct sk_buff *skb,
3663 struct wmi_phyerr_hdr_arg *arg)
3665 struct wmi_10_4_phyerr_event *ev = (void *)skb->data;
3667 if (skb->len < sizeof(*ev))
3668 return -EPROTO;
3670 /* 10.4 firmware always reports only one phyerr */
3671 arg->num_phyerrs = 1;
3673 arg->tsf_l32 = __le32_to_cpu(ev->tsf_l32);
3674 arg->tsf_u32 = __le32_to_cpu(ev->tsf_u32);
3675 arg->buf_len = skb->len;
3676 arg->phyerrs = skb->data;
3678 return 0;
3681 int ath10k_wmi_op_pull_phyerr_ev(struct ath10k *ar,
3682 const void *phyerr_buf,
3683 int left_len,
3684 struct wmi_phyerr_ev_arg *arg)
3686 const struct wmi_phyerr *phyerr = phyerr_buf;
3687 int i;
3689 if (left_len < sizeof(*phyerr)) {
3690 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
3691 left_len, sizeof(*phyerr));
3692 return -EINVAL;
3695 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3696 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3697 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3698 arg->rssi_combined = phyerr->rssi_combined;
3699 arg->chan_width_mhz = phyerr->chan_width_mhz;
3700 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3701 arg->buf = phyerr->buf;
3702 arg->hdr_len = sizeof(*phyerr);
3704 for (i = 0; i < 4; i++)
3705 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3707 switch (phyerr->phy_err_code) {
3708 case PHY_ERROR_GEN_SPECTRAL_SCAN:
3709 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3710 break;
3711 case PHY_ERROR_GEN_FALSE_RADAR_EXT:
3712 arg->phy_err_code = PHY_ERROR_FALSE_RADAR_EXT;
3713 break;
3714 case PHY_ERROR_GEN_RADAR:
3715 arg->phy_err_code = PHY_ERROR_RADAR;
3716 break;
3717 default:
3718 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3719 break;
3722 return 0;
3725 static int ath10k_wmi_10_4_op_pull_phyerr_ev(struct ath10k *ar,
3726 const void *phyerr_buf,
3727 int left_len,
3728 struct wmi_phyerr_ev_arg *arg)
3730 const struct wmi_10_4_phyerr_event *phyerr = phyerr_buf;
3731 u32 phy_err_mask;
3732 int i;
3734 if (left_len < sizeof(*phyerr)) {
3735 ath10k_warn(ar, "wrong phyerr event head len %d (need: >=%zd)\n",
3736 left_len, sizeof(*phyerr));
3737 return -EINVAL;
3740 arg->tsf_timestamp = __le32_to_cpu(phyerr->tsf_timestamp);
3741 arg->freq1 = __le16_to_cpu(phyerr->freq1);
3742 arg->freq2 = __le16_to_cpu(phyerr->freq2);
3743 arg->rssi_combined = phyerr->rssi_combined;
3744 arg->chan_width_mhz = phyerr->chan_width_mhz;
3745 arg->buf_len = __le32_to_cpu(phyerr->buf_len);
3746 arg->buf = phyerr->buf;
3747 arg->hdr_len = sizeof(*phyerr);
3749 for (i = 0; i < 4; i++)
3750 arg->nf_chains[i] = __le16_to_cpu(phyerr->nf_chains[i]);
3752 phy_err_mask = __le32_to_cpu(phyerr->phy_err_mask[0]);
3754 if (phy_err_mask & PHY_ERROR_10_4_SPECTRAL_SCAN_MASK)
3755 arg->phy_err_code = PHY_ERROR_SPECTRAL_SCAN;
3756 else if (phy_err_mask & PHY_ERROR_10_4_RADAR_MASK)
3757 arg->phy_err_code = PHY_ERROR_RADAR;
3758 else
3759 arg->phy_err_code = PHY_ERROR_UNKNOWN;
3761 return 0;
3764 void ath10k_wmi_event_phyerr(struct ath10k *ar, struct sk_buff *skb)
3766 struct wmi_phyerr_hdr_arg hdr_arg = {};
3767 struct wmi_phyerr_ev_arg phyerr_arg = {};
3768 const void *phyerr;
3769 u32 count, i, buf_len, phy_err_code;
3770 u64 tsf;
3771 int left_len, ret;
3773 ATH10K_DFS_STAT_INC(ar, phy_errors);
3775 ret = ath10k_wmi_pull_phyerr_hdr(ar, skb, &hdr_arg);
3776 if (ret) {
3777 ath10k_warn(ar, "failed to parse phyerr event hdr: %d\n", ret);
3778 return;
3781 /* Check number of included events */
3782 count = hdr_arg.num_phyerrs;
3784 left_len = hdr_arg.buf_len;
3786 tsf = hdr_arg.tsf_u32;
3787 tsf <<= 32;
3788 tsf |= hdr_arg.tsf_l32;
3790 ath10k_dbg(ar, ATH10K_DBG_WMI,
3791 "wmi event phyerr count %d tsf64 0x%llX\n",
3792 count, tsf);
3794 phyerr = hdr_arg.phyerrs;
3795 for (i = 0; i < count; i++) {
3796 ret = ath10k_wmi_pull_phyerr(ar, phyerr, left_len, &phyerr_arg);
3797 if (ret) {
3798 ath10k_warn(ar, "failed to parse phyerr event (%d)\n",
3800 return;
3803 left_len -= phyerr_arg.hdr_len;
3804 buf_len = phyerr_arg.buf_len;
3805 phy_err_code = phyerr_arg.phy_err_code;
3807 if (left_len < buf_len) {
3808 ath10k_warn(ar, "single event (%d) wrong buf len\n", i);
3809 return;
3812 left_len -= buf_len;
3814 switch (phy_err_code) {
3815 case PHY_ERROR_RADAR:
3816 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
3817 break;
3818 case PHY_ERROR_SPECTRAL_SCAN:
3819 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
3820 break;
3821 case PHY_ERROR_FALSE_RADAR_EXT:
3822 ath10k_wmi_event_dfs(ar, &phyerr_arg, tsf);
3823 ath10k_wmi_event_spectral_scan(ar, &phyerr_arg, tsf);
3824 break;
3825 default:
3826 break;
3829 phyerr = phyerr + phyerr_arg.hdr_len + buf_len;
3833 void ath10k_wmi_event_roam(struct ath10k *ar, struct sk_buff *skb)
3835 struct wmi_roam_ev_arg arg = {};
3836 int ret;
3837 u32 vdev_id;
3838 u32 reason;
3839 s32 rssi;
3841 ret = ath10k_wmi_pull_roam_ev(ar, skb, &arg);
3842 if (ret) {
3843 ath10k_warn(ar, "failed to parse roam event: %d\n", ret);
3844 return;
3847 vdev_id = __le32_to_cpu(arg.vdev_id);
3848 reason = __le32_to_cpu(arg.reason);
3849 rssi = __le32_to_cpu(arg.rssi);
3850 rssi += WMI_SPECTRAL_NOISE_FLOOR_REF_DEFAULT;
3852 ath10k_dbg(ar, ATH10K_DBG_WMI,
3853 "wmi roam event vdev %u reason 0x%08x rssi %d\n",
3854 vdev_id, reason, rssi);
3856 if (reason >= WMI_ROAM_REASON_MAX)
3857 ath10k_warn(ar, "ignoring unknown roam event reason %d on vdev %i\n",
3858 reason, vdev_id);
3860 switch (reason) {
3861 case WMI_ROAM_REASON_BEACON_MISS:
3862 ath10k_mac_handle_beacon_miss(ar, vdev_id);
3863 break;
3864 case WMI_ROAM_REASON_BETTER_AP:
3865 case WMI_ROAM_REASON_LOW_RSSI:
3866 case WMI_ROAM_REASON_SUITABLE_AP_FOUND:
3867 case WMI_ROAM_REASON_HO_FAILED:
3868 ath10k_warn(ar, "ignoring not implemented roam event reason %d on vdev %i\n",
3869 reason, vdev_id);
3870 break;
3874 void ath10k_wmi_event_profile_match(struct ath10k *ar, struct sk_buff *skb)
3876 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PROFILE_MATCH\n");
3879 void ath10k_wmi_event_debug_print(struct ath10k *ar, struct sk_buff *skb)
3881 char buf[101], c;
3882 int i;
3884 for (i = 0; i < sizeof(buf) - 1; i++) {
3885 if (i >= skb->len)
3886 break;
3888 c = skb->data[i];
3890 if (c == '\0')
3891 break;
3893 if (isascii(c) && isprint(c))
3894 buf[i] = c;
3895 else
3896 buf[i] = '.';
3899 if (i == sizeof(buf) - 1)
3900 ath10k_warn(ar, "wmi debug print truncated: %d\n", skb->len);
3902 /* for some reason the debug prints end with \n, remove that */
3903 if (skb->data[i - 1] == '\n')
3904 i--;
3906 /* the last byte is always reserved for the null character */
3907 buf[i] = '\0';
3909 ath10k_dbg(ar, ATH10K_DBG_WMI_PRINT, "wmi print '%s'\n", buf);
3912 void ath10k_wmi_event_pdev_qvit(struct ath10k *ar, struct sk_buff *skb)
3914 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_QVIT_EVENTID\n");
3917 void ath10k_wmi_event_wlan_profile_data(struct ath10k *ar, struct sk_buff *skb)
3919 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
3922 void ath10k_wmi_event_rtt_measurement_report(struct ath10k *ar,
3923 struct sk_buff *skb)
3925 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
3928 void ath10k_wmi_event_tsf_measurement_report(struct ath10k *ar,
3929 struct sk_buff *skb)
3931 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
3934 void ath10k_wmi_event_rtt_error_report(struct ath10k *ar, struct sk_buff *skb)
3936 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_RTT_ERROR_REPORT_EVENTID\n");
3939 void ath10k_wmi_event_wow_wakeup_host(struct ath10k *ar, struct sk_buff *skb)
3941 struct wmi_wow_ev_arg ev = {};
3942 int ret;
3944 complete(&ar->wow.wakeup_completed);
3946 ret = ath10k_wmi_pull_wow_event(ar, skb, &ev);
3947 if (ret) {
3948 ath10k_warn(ar, "failed to parse wow wakeup event: %d\n", ret);
3949 return;
3952 ath10k_dbg(ar, ATH10K_DBG_WMI, "wow wakeup host reason %s\n",
3953 wow_reason(ev.wake_reason));
3956 void ath10k_wmi_event_dcs_interference(struct ath10k *ar, struct sk_buff *skb)
3958 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_DCS_INTERFERENCE_EVENTID\n");
3961 static u8 ath10k_tpc_config_get_rate(struct ath10k *ar,
3962 struct wmi_pdev_tpc_config_event *ev,
3963 u32 rate_idx, u32 num_chains,
3964 u32 rate_code, u8 type)
3966 u8 tpc, num_streams, preamble, ch, stm_idx;
3968 num_streams = ATH10K_HW_NSS(rate_code);
3969 preamble = ATH10K_HW_PREAMBLE(rate_code);
3970 ch = num_chains - 1;
3972 tpc = min_t(u8, ev->rates_array[rate_idx], ev->max_reg_allow_pow[ch]);
3974 if (__le32_to_cpu(ev->num_tx_chain) <= 1)
3975 goto out;
3977 if (preamble == WMI_RATE_PREAMBLE_CCK)
3978 goto out;
3980 stm_idx = num_streams - 1;
3981 if (num_chains <= num_streams)
3982 goto out;
3984 switch (type) {
3985 case WMI_TPC_TABLE_TYPE_STBC:
3986 tpc = min_t(u8, tpc,
3987 ev->max_reg_allow_pow_agstbc[ch - 1][stm_idx]);
3988 break;
3989 case WMI_TPC_TABLE_TYPE_TXBF:
3990 tpc = min_t(u8, tpc,
3991 ev->max_reg_allow_pow_agtxbf[ch - 1][stm_idx]);
3992 break;
3993 case WMI_TPC_TABLE_TYPE_CDD:
3994 tpc = min_t(u8, tpc,
3995 ev->max_reg_allow_pow_agcdd[ch - 1][stm_idx]);
3996 break;
3997 default:
3998 ath10k_warn(ar, "unknown wmi tpc table type: %d\n", type);
3999 tpc = 0;
4000 break;
4003 out:
4004 return tpc;
4007 static void ath10k_tpc_config_disp_tables(struct ath10k *ar,
4008 struct wmi_pdev_tpc_config_event *ev,
4009 struct ath10k_tpc_stats *tpc_stats,
4010 u8 *rate_code, u16 *pream_table, u8 type)
4012 u32 i, j, pream_idx, flags;
4013 u8 tpc[WMI_TPC_TX_N_CHAIN];
4014 char tpc_value[WMI_TPC_TX_N_CHAIN * WMI_TPC_BUF_SIZE];
4015 char buff[WMI_TPC_BUF_SIZE];
4017 flags = __le32_to_cpu(ev->flags);
4019 switch (type) {
4020 case WMI_TPC_TABLE_TYPE_CDD:
4021 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_CDD)) {
4022 ath10k_dbg(ar, ATH10K_DBG_WMI, "CDD not supported\n");
4023 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4024 return;
4026 break;
4027 case WMI_TPC_TABLE_TYPE_STBC:
4028 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_STBC)) {
4029 ath10k_dbg(ar, ATH10K_DBG_WMI, "STBC not supported\n");
4030 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4031 return;
4033 break;
4034 case WMI_TPC_TABLE_TYPE_TXBF:
4035 if (!(flags & WMI_TPC_CONFIG_EVENT_FLAG_TABLE_TXBF)) {
4036 ath10k_dbg(ar, ATH10K_DBG_WMI, "TXBF not supported\n");
4037 tpc_stats->flag[type] = ATH10K_TPC_TABLE_TYPE_FLAG;
4038 return;
4040 break;
4041 default:
4042 ath10k_dbg(ar, ATH10K_DBG_WMI,
4043 "invalid table type in wmi tpc event: %d\n", type);
4044 return;
4047 pream_idx = 0;
4048 for (i = 0; i < __le32_to_cpu(ev->rate_max); i++) {
4049 memset(tpc_value, 0, sizeof(tpc_value));
4050 memset(buff, 0, sizeof(buff));
4051 if (i == pream_table[pream_idx])
4052 pream_idx++;
4054 for (j = 0; j < WMI_TPC_TX_N_CHAIN; j++) {
4055 if (j >= __le32_to_cpu(ev->num_tx_chain))
4056 break;
4058 tpc[j] = ath10k_tpc_config_get_rate(ar, ev, i, j + 1,
4059 rate_code[i],
4060 type);
4061 snprintf(buff, sizeof(buff), "%8d ", tpc[j]);
4062 strncat(tpc_value, buff, strlen(buff));
4064 tpc_stats->tpc_table[type].pream_idx[i] = pream_idx;
4065 tpc_stats->tpc_table[type].rate_code[i] = rate_code[i];
4066 memcpy(tpc_stats->tpc_table[type].tpc_value[i],
4067 tpc_value, sizeof(tpc_value));
4071 void ath10k_wmi_event_pdev_tpc_config(struct ath10k *ar, struct sk_buff *skb)
4073 u32 i, j, pream_idx, num_tx_chain;
4074 u8 rate_code[WMI_TPC_RATE_MAX], rate_idx;
4075 u16 pream_table[WMI_TPC_PREAM_TABLE_MAX];
4076 struct wmi_pdev_tpc_config_event *ev;
4077 struct ath10k_tpc_stats *tpc_stats;
4079 ev = (struct wmi_pdev_tpc_config_event *)skb->data;
4081 tpc_stats = kzalloc(sizeof(*tpc_stats), GFP_ATOMIC);
4082 if (!tpc_stats)
4083 return;
4085 /* Create the rate code table based on the chains supported */
4086 rate_idx = 0;
4087 pream_idx = 0;
4089 /* Fill CCK rate code */
4090 for (i = 0; i < 4; i++) {
4091 rate_code[rate_idx] =
4092 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_CCK);
4093 rate_idx++;
4095 pream_table[pream_idx] = rate_idx;
4096 pream_idx++;
4098 /* Fill OFDM rate code */
4099 for (i = 0; i < 8; i++) {
4100 rate_code[rate_idx] =
4101 ATH10K_HW_RATECODE(i, 0, WMI_RATE_PREAMBLE_OFDM);
4102 rate_idx++;
4104 pream_table[pream_idx] = rate_idx;
4105 pream_idx++;
4107 num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4109 /* Fill HT20 rate code */
4110 for (i = 0; i < num_tx_chain; i++) {
4111 for (j = 0; j < 8; j++) {
4112 rate_code[rate_idx] =
4113 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4114 rate_idx++;
4117 pream_table[pream_idx] = rate_idx;
4118 pream_idx++;
4120 /* Fill HT40 rate code */
4121 for (i = 0; i < num_tx_chain; i++) {
4122 for (j = 0; j < 8; j++) {
4123 rate_code[rate_idx] =
4124 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_HT);
4125 rate_idx++;
4128 pream_table[pream_idx] = rate_idx;
4129 pream_idx++;
4131 /* Fill VHT20 rate code */
4132 for (i = 0; i < __le32_to_cpu(ev->num_tx_chain); i++) {
4133 for (j = 0; j < 10; j++) {
4134 rate_code[rate_idx] =
4135 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4136 rate_idx++;
4139 pream_table[pream_idx] = rate_idx;
4140 pream_idx++;
4142 /* Fill VHT40 rate code */
4143 for (i = 0; i < num_tx_chain; i++) {
4144 for (j = 0; j < 10; j++) {
4145 rate_code[rate_idx] =
4146 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4147 rate_idx++;
4150 pream_table[pream_idx] = rate_idx;
4151 pream_idx++;
4153 /* Fill VHT80 rate code */
4154 for (i = 0; i < num_tx_chain; i++) {
4155 for (j = 0; j < 10; j++) {
4156 rate_code[rate_idx] =
4157 ATH10K_HW_RATECODE(j, i, WMI_RATE_PREAMBLE_VHT);
4158 rate_idx++;
4161 pream_table[pream_idx] = rate_idx;
4162 pream_idx++;
4164 rate_code[rate_idx++] =
4165 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4166 rate_code[rate_idx++] =
4167 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4168 rate_code[rate_idx++] =
4169 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_CCK);
4170 rate_code[rate_idx++] =
4171 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4172 rate_code[rate_idx++] =
4173 ATH10K_HW_RATECODE(0, 0, WMI_RATE_PREAMBLE_OFDM);
4175 pream_table[pream_idx] = ATH10K_TPC_PREAM_TABLE_END;
4177 tpc_stats->chan_freq = __le32_to_cpu(ev->chan_freq);
4178 tpc_stats->phy_mode = __le32_to_cpu(ev->phy_mode);
4179 tpc_stats->ctl = __le32_to_cpu(ev->ctl);
4180 tpc_stats->reg_domain = __le32_to_cpu(ev->reg_domain);
4181 tpc_stats->twice_antenna_gain = a_sle32_to_cpu(ev->twice_antenna_gain);
4182 tpc_stats->twice_antenna_reduction =
4183 __le32_to_cpu(ev->twice_antenna_reduction);
4184 tpc_stats->power_limit = __le32_to_cpu(ev->power_limit);
4185 tpc_stats->twice_max_rd_power = __le32_to_cpu(ev->twice_max_rd_power);
4186 tpc_stats->num_tx_chain = __le32_to_cpu(ev->num_tx_chain);
4187 tpc_stats->rate_max = __le32_to_cpu(ev->rate_max);
4189 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4190 rate_code, pream_table,
4191 WMI_TPC_TABLE_TYPE_CDD);
4192 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4193 rate_code, pream_table,
4194 WMI_TPC_TABLE_TYPE_STBC);
4195 ath10k_tpc_config_disp_tables(ar, ev, tpc_stats,
4196 rate_code, pream_table,
4197 WMI_TPC_TABLE_TYPE_TXBF);
4199 ath10k_debug_tpc_stats_process(ar, tpc_stats);
4201 ath10k_dbg(ar, ATH10K_DBG_WMI,
4202 "wmi event tpc config channel %d mode %d ctl %d regd %d gain %d %d limit %d max_power %d tx_chanins %d rates %d\n",
4203 __le32_to_cpu(ev->chan_freq),
4204 __le32_to_cpu(ev->phy_mode),
4205 __le32_to_cpu(ev->ctl),
4206 __le32_to_cpu(ev->reg_domain),
4207 a_sle32_to_cpu(ev->twice_antenna_gain),
4208 __le32_to_cpu(ev->twice_antenna_reduction),
4209 __le32_to_cpu(ev->power_limit),
4210 __le32_to_cpu(ev->twice_max_rd_power) / 2,
4211 __le32_to_cpu(ev->num_tx_chain),
4212 __le32_to_cpu(ev->rate_max));
4215 void ath10k_wmi_event_pdev_ftm_intg(struct ath10k *ar, struct sk_buff *skb)
4217 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_PDEV_FTM_INTG_EVENTID\n");
4220 void ath10k_wmi_event_gtk_offload_status(struct ath10k *ar, struct sk_buff *skb)
4222 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
4225 void ath10k_wmi_event_gtk_rekey_fail(struct ath10k *ar, struct sk_buff *skb)
4227 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_GTK_REKEY_FAIL_EVENTID\n");
4230 void ath10k_wmi_event_delba_complete(struct ath10k *ar, struct sk_buff *skb)
4232 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
4235 void ath10k_wmi_event_addba_complete(struct ath10k *ar, struct sk_buff *skb)
4237 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
4240 void ath10k_wmi_event_vdev_install_key_complete(struct ath10k *ar,
4241 struct sk_buff *skb)
4243 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
4246 void ath10k_wmi_event_inst_rssi_stats(struct ath10k *ar, struct sk_buff *skb)
4248 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_INST_RSSI_STATS_EVENTID\n");
4251 void ath10k_wmi_event_vdev_standby_req(struct ath10k *ar, struct sk_buff *skb)
4253 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
4256 void ath10k_wmi_event_vdev_resume_req(struct ath10k *ar, struct sk_buff *skb)
4258 ath10k_dbg(ar, ATH10K_DBG_WMI, "WMI_VDEV_RESUME_REQ_EVENTID\n");
4261 static int ath10k_wmi_alloc_host_mem(struct ath10k *ar, u32 req_id,
4262 u32 num_units, u32 unit_len)
4264 dma_addr_t paddr;
4265 u32 pool_size;
4266 int idx = ar->wmi.num_mem_chunks;
4268 pool_size = num_units * round_up(unit_len, 4);
4270 if (!pool_size)
4271 return -EINVAL;
4273 ar->wmi.mem_chunks[idx].vaddr = dma_alloc_coherent(ar->dev,
4274 pool_size,
4275 &paddr,
4276 GFP_KERNEL);
4277 if (!ar->wmi.mem_chunks[idx].vaddr) {
4278 ath10k_warn(ar, "failed to allocate memory chunk\n");
4279 return -ENOMEM;
4282 memset(ar->wmi.mem_chunks[idx].vaddr, 0, pool_size);
4284 ar->wmi.mem_chunks[idx].paddr = paddr;
4285 ar->wmi.mem_chunks[idx].len = pool_size;
4286 ar->wmi.mem_chunks[idx].req_id = req_id;
4287 ar->wmi.num_mem_chunks++;
4289 return 0;
4292 static bool
4293 ath10k_wmi_is_host_mem_allocated(struct ath10k *ar,
4294 const struct wlan_host_mem_req **mem_reqs,
4295 u32 num_mem_reqs)
4297 u32 req_id, num_units, unit_size, num_unit_info;
4298 u32 pool_size;
4299 int i, j;
4300 bool found;
4302 if (ar->wmi.num_mem_chunks != num_mem_reqs)
4303 return false;
4305 for (i = 0; i < num_mem_reqs; ++i) {
4306 req_id = __le32_to_cpu(mem_reqs[i]->req_id);
4307 num_units = __le32_to_cpu(mem_reqs[i]->num_units);
4308 unit_size = __le32_to_cpu(mem_reqs[i]->unit_size);
4309 num_unit_info = __le32_to_cpu(mem_reqs[i]->num_unit_info);
4311 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4312 if (ar->num_active_peers)
4313 num_units = ar->num_active_peers + 1;
4314 else
4315 num_units = ar->max_num_peers + 1;
4316 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4317 num_units = ar->max_num_peers + 1;
4318 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4319 num_units = ar->max_num_vdevs + 1;
4322 found = false;
4323 for (j = 0; j < ar->wmi.num_mem_chunks; j++) {
4324 if (ar->wmi.mem_chunks[j].req_id == req_id) {
4325 pool_size = num_units * round_up(unit_size, 4);
4326 if (ar->wmi.mem_chunks[j].len == pool_size) {
4327 found = true;
4328 break;
4332 if (!found)
4333 return false;
4336 return true;
4339 static int
4340 ath10k_wmi_main_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4341 struct wmi_svc_rdy_ev_arg *arg)
4343 struct wmi_service_ready_event *ev;
4344 size_t i, n;
4346 if (skb->len < sizeof(*ev))
4347 return -EPROTO;
4349 ev = (void *)skb->data;
4350 skb_pull(skb, sizeof(*ev));
4351 arg->min_tx_power = ev->hw_min_tx_power;
4352 arg->max_tx_power = ev->hw_max_tx_power;
4353 arg->ht_cap = ev->ht_cap_info;
4354 arg->vht_cap = ev->vht_cap_info;
4355 arg->sw_ver0 = ev->sw_version;
4356 arg->sw_ver1 = ev->sw_version_1;
4357 arg->phy_capab = ev->phy_capability;
4358 arg->num_rf_chains = ev->num_rf_chains;
4359 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4360 arg->num_mem_reqs = ev->num_mem_reqs;
4361 arg->service_map = ev->wmi_service_bitmap;
4362 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
4364 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4365 ARRAY_SIZE(arg->mem_reqs));
4366 for (i = 0; i < n; i++)
4367 arg->mem_reqs[i] = &ev->mem_reqs[i];
4369 if (skb->len <
4370 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4371 return -EPROTO;
4373 return 0;
4376 static int
4377 ath10k_wmi_10x_op_pull_svc_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4378 struct wmi_svc_rdy_ev_arg *arg)
4380 struct wmi_10x_service_ready_event *ev;
4381 int i, n;
4383 if (skb->len < sizeof(*ev))
4384 return -EPROTO;
4386 ev = (void *)skb->data;
4387 skb_pull(skb, sizeof(*ev));
4388 arg->min_tx_power = ev->hw_min_tx_power;
4389 arg->max_tx_power = ev->hw_max_tx_power;
4390 arg->ht_cap = ev->ht_cap_info;
4391 arg->vht_cap = ev->vht_cap_info;
4392 arg->sw_ver0 = ev->sw_version;
4393 arg->phy_capab = ev->phy_capability;
4394 arg->num_rf_chains = ev->num_rf_chains;
4395 arg->eeprom_rd = ev->hal_reg_capabilities.eeprom_rd;
4396 arg->num_mem_reqs = ev->num_mem_reqs;
4397 arg->service_map = ev->wmi_service_bitmap;
4398 arg->service_map_len = sizeof(ev->wmi_service_bitmap);
4400 n = min_t(size_t, __le32_to_cpu(arg->num_mem_reqs),
4401 ARRAY_SIZE(arg->mem_reqs));
4402 for (i = 0; i < n; i++)
4403 arg->mem_reqs[i] = &ev->mem_reqs[i];
4405 if (skb->len <
4406 __le32_to_cpu(arg->num_mem_reqs) * sizeof(arg->mem_reqs[0]))
4407 return -EPROTO;
4409 return 0;
4412 static void ath10k_wmi_event_service_ready_work(struct work_struct *work)
4414 struct ath10k *ar = container_of(work, struct ath10k, svc_rdy_work);
4415 struct sk_buff *skb = ar->svc_rdy_skb;
4416 struct wmi_svc_rdy_ev_arg arg = {};
4417 u32 num_units, req_id, unit_size, num_mem_reqs, num_unit_info, i;
4418 int ret;
4419 bool allocated;
4421 if (!skb) {
4422 ath10k_warn(ar, "invalid service ready event skb\n");
4423 return;
4426 ret = ath10k_wmi_pull_svc_rdy(ar, skb, &arg);
4427 if (ret) {
4428 ath10k_warn(ar, "failed to parse service ready: %d\n", ret);
4429 return;
4432 memset(&ar->wmi.svc_map, 0, sizeof(ar->wmi.svc_map));
4433 ath10k_wmi_map_svc(ar, arg.service_map, ar->wmi.svc_map,
4434 arg.service_map_len);
4436 ar->hw_min_tx_power = __le32_to_cpu(arg.min_tx_power);
4437 ar->hw_max_tx_power = __le32_to_cpu(arg.max_tx_power);
4438 ar->ht_cap_info = __le32_to_cpu(arg.ht_cap);
4439 ar->vht_cap_info = __le32_to_cpu(arg.vht_cap);
4440 ar->fw_version_major =
4441 (__le32_to_cpu(arg.sw_ver0) & 0xff000000) >> 24;
4442 ar->fw_version_minor = (__le32_to_cpu(arg.sw_ver0) & 0x00ffffff);
4443 ar->fw_version_release =
4444 (__le32_to_cpu(arg.sw_ver1) & 0xffff0000) >> 16;
4445 ar->fw_version_build = (__le32_to_cpu(arg.sw_ver1) & 0x0000ffff);
4446 ar->phy_capability = __le32_to_cpu(arg.phy_capab);
4447 ar->num_rf_chains = __le32_to_cpu(arg.num_rf_chains);
4448 ar->ath_common.regulatory.current_rd = __le32_to_cpu(arg.eeprom_rd);
4450 ath10k_dbg_dump(ar, ATH10K_DBG_WMI, NULL, "wmi svc: ",
4451 arg.service_map, arg.service_map_len);
4453 /* only manually set fw features when not using FW IE format */
4454 if (ar->fw_api == 1 && ar->fw_version_build > 636)
4455 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX, ar->fw_features);
4457 if (ar->num_rf_chains > ar->max_spatial_stream) {
4458 ath10k_warn(ar, "hardware advertises support for more spatial streams than it should (%d > %d)\n",
4459 ar->num_rf_chains, ar->max_spatial_stream);
4460 ar->num_rf_chains = ar->max_spatial_stream;
4463 if (!ar->cfg_tx_chainmask) {
4464 ar->cfg_tx_chainmask = (1 << ar->num_rf_chains) - 1;
4465 ar->cfg_rx_chainmask = (1 << ar->num_rf_chains) - 1;
4468 if (strlen(ar->hw->wiphy->fw_version) == 0) {
4469 snprintf(ar->hw->wiphy->fw_version,
4470 sizeof(ar->hw->wiphy->fw_version),
4471 "%u.%u.%u.%u",
4472 ar->fw_version_major,
4473 ar->fw_version_minor,
4474 ar->fw_version_release,
4475 ar->fw_version_build);
4478 num_mem_reqs = __le32_to_cpu(arg.num_mem_reqs);
4479 if (num_mem_reqs > WMI_MAX_MEM_REQS) {
4480 ath10k_warn(ar, "requested memory chunks number (%d) exceeds the limit\n",
4481 num_mem_reqs);
4482 return;
4485 if (test_bit(WMI_SERVICE_PEER_CACHING, ar->wmi.svc_map)) {
4486 ar->max_num_peers = TARGET_10_4_NUM_QCACHE_PEERS_MAX +
4487 TARGET_10_4_NUM_VDEVS;
4488 ar->num_active_peers = TARGET_10_4_QCACHE_ACTIVE_PEERS +
4489 TARGET_10_4_NUM_VDEVS;
4490 ar->num_tids = ar->num_active_peers * 2;
4491 ar->max_num_stations = TARGET_10_4_NUM_QCACHE_PEERS_MAX;
4494 /* TODO: Adjust max peer count for cases like WMI_SERVICE_RATECTRL_CACHE
4495 * and WMI_SERVICE_IRAM_TIDS, etc.
4498 allocated = ath10k_wmi_is_host_mem_allocated(ar, arg.mem_reqs,
4499 num_mem_reqs);
4500 if (allocated)
4501 goto skip_mem_alloc;
4503 /* Either this event is received during boot time or there is a change
4504 * in memory requirement from firmware when compared to last request.
4505 * Free any old memory and do a fresh allocation based on the current
4506 * memory requirement.
4508 ath10k_wmi_free_host_mem(ar);
4510 for (i = 0; i < num_mem_reqs; ++i) {
4511 req_id = __le32_to_cpu(arg.mem_reqs[i]->req_id);
4512 num_units = __le32_to_cpu(arg.mem_reqs[i]->num_units);
4513 unit_size = __le32_to_cpu(arg.mem_reqs[i]->unit_size);
4514 num_unit_info = __le32_to_cpu(arg.mem_reqs[i]->num_unit_info);
4516 if (num_unit_info & NUM_UNITS_IS_NUM_ACTIVE_PEERS) {
4517 if (ar->num_active_peers)
4518 num_units = ar->num_active_peers + 1;
4519 else
4520 num_units = ar->max_num_peers + 1;
4521 } else if (num_unit_info & NUM_UNITS_IS_NUM_PEERS) {
4522 /* number of units to allocate is number of
4523 * peers, 1 extra for self peer on target */
4524 /* this needs to be tied, host and target
4525 * can get out of sync */
4526 num_units = ar->max_num_peers + 1;
4527 } else if (num_unit_info & NUM_UNITS_IS_NUM_VDEVS) {
4528 num_units = ar->max_num_vdevs + 1;
4531 ath10k_dbg(ar, ATH10K_DBG_WMI,
4532 "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
4533 req_id,
4534 __le32_to_cpu(arg.mem_reqs[i]->num_units),
4535 num_unit_info,
4536 unit_size,
4537 num_units);
4539 ret = ath10k_wmi_alloc_host_mem(ar, req_id, num_units,
4540 unit_size);
4541 if (ret)
4542 return;
4545 skip_mem_alloc:
4546 ath10k_dbg(ar, ATH10K_DBG_WMI,
4547 "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",
4548 __le32_to_cpu(arg.min_tx_power),
4549 __le32_to_cpu(arg.max_tx_power),
4550 __le32_to_cpu(arg.ht_cap),
4551 __le32_to_cpu(arg.vht_cap),
4552 __le32_to_cpu(arg.sw_ver0),
4553 __le32_to_cpu(arg.sw_ver1),
4554 __le32_to_cpu(arg.fw_build),
4555 __le32_to_cpu(arg.phy_capab),
4556 __le32_to_cpu(arg.num_rf_chains),
4557 __le32_to_cpu(arg.eeprom_rd),
4558 __le32_to_cpu(arg.num_mem_reqs));
4560 dev_kfree_skb(skb);
4561 ar->svc_rdy_skb = NULL;
4562 complete(&ar->wmi.service_ready);
4565 void ath10k_wmi_event_service_ready(struct ath10k *ar, struct sk_buff *skb)
4567 ar->svc_rdy_skb = skb;
4568 queue_work(ar->workqueue_aux, &ar->svc_rdy_work);
4571 static int ath10k_wmi_op_pull_rdy_ev(struct ath10k *ar, struct sk_buff *skb,
4572 struct wmi_rdy_ev_arg *arg)
4574 struct wmi_ready_event *ev = (void *)skb->data;
4576 if (skb->len < sizeof(*ev))
4577 return -EPROTO;
4579 skb_pull(skb, sizeof(*ev));
4580 arg->sw_version = ev->sw_version;
4581 arg->abi_version = ev->abi_version;
4582 arg->status = ev->status;
4583 arg->mac_addr = ev->mac_addr.addr;
4585 return 0;
4588 static int ath10k_wmi_op_pull_roam_ev(struct ath10k *ar, struct sk_buff *skb,
4589 struct wmi_roam_ev_arg *arg)
4591 struct wmi_roam_ev *ev = (void *)skb->data;
4593 if (skb->len < sizeof(*ev))
4594 return -EPROTO;
4596 skb_pull(skb, sizeof(*ev));
4597 arg->vdev_id = ev->vdev_id;
4598 arg->reason = ev->reason;
4600 return 0;
4603 int ath10k_wmi_event_ready(struct ath10k *ar, struct sk_buff *skb)
4605 struct wmi_rdy_ev_arg arg = {};
4606 int ret;
4608 ret = ath10k_wmi_pull_rdy(ar, skb, &arg);
4609 if (ret) {
4610 ath10k_warn(ar, "failed to parse ready event: %d\n", ret);
4611 return ret;
4614 ath10k_dbg(ar, ATH10K_DBG_WMI,
4615 "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
4616 __le32_to_cpu(arg.sw_version),
4617 __le32_to_cpu(arg.abi_version),
4618 arg.mac_addr,
4619 __le32_to_cpu(arg.status));
4621 ether_addr_copy(ar->mac_addr, arg.mac_addr);
4622 complete(&ar->wmi.unified_ready);
4623 return 0;
4626 static int ath10k_wmi_event_temperature(struct ath10k *ar, struct sk_buff *skb)
4628 const struct wmi_pdev_temperature_event *ev;
4630 ev = (struct wmi_pdev_temperature_event *)skb->data;
4631 if (WARN_ON(skb->len < sizeof(*ev)))
4632 return -EPROTO;
4634 ath10k_thermal_event_temperature(ar, __le32_to_cpu(ev->temperature));
4635 return 0;
4638 static void ath10k_wmi_op_rx(struct ath10k *ar, struct sk_buff *skb)
4640 struct wmi_cmd_hdr *cmd_hdr;
4641 enum wmi_event_id id;
4643 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4644 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4646 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
4647 goto out;
4649 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
4651 switch (id) {
4652 case WMI_MGMT_RX_EVENTID:
4653 ath10k_wmi_event_mgmt_rx(ar, skb);
4654 /* mgmt_rx() owns the skb now! */
4655 return;
4656 case WMI_SCAN_EVENTID:
4657 ath10k_wmi_event_scan(ar, skb);
4658 break;
4659 case WMI_CHAN_INFO_EVENTID:
4660 ath10k_wmi_event_chan_info(ar, skb);
4661 break;
4662 case WMI_ECHO_EVENTID:
4663 ath10k_wmi_event_echo(ar, skb);
4664 break;
4665 case WMI_DEBUG_MESG_EVENTID:
4666 ath10k_wmi_event_debug_mesg(ar, skb);
4667 break;
4668 case WMI_UPDATE_STATS_EVENTID:
4669 ath10k_wmi_event_update_stats(ar, skb);
4670 break;
4671 case WMI_VDEV_START_RESP_EVENTID:
4672 ath10k_wmi_event_vdev_start_resp(ar, skb);
4673 break;
4674 case WMI_VDEV_STOPPED_EVENTID:
4675 ath10k_wmi_event_vdev_stopped(ar, skb);
4676 break;
4677 case WMI_PEER_STA_KICKOUT_EVENTID:
4678 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4679 break;
4680 case WMI_HOST_SWBA_EVENTID:
4681 ath10k_wmi_event_host_swba(ar, skb);
4682 break;
4683 case WMI_TBTTOFFSET_UPDATE_EVENTID:
4684 ath10k_wmi_event_tbttoffset_update(ar, skb);
4685 break;
4686 case WMI_PHYERR_EVENTID:
4687 ath10k_wmi_event_phyerr(ar, skb);
4688 break;
4689 case WMI_ROAM_EVENTID:
4690 ath10k_wmi_event_roam(ar, skb);
4691 break;
4692 case WMI_PROFILE_MATCH:
4693 ath10k_wmi_event_profile_match(ar, skb);
4694 break;
4695 case WMI_DEBUG_PRINT_EVENTID:
4696 ath10k_wmi_event_debug_print(ar, skb);
4697 break;
4698 case WMI_PDEV_QVIT_EVENTID:
4699 ath10k_wmi_event_pdev_qvit(ar, skb);
4700 break;
4701 case WMI_WLAN_PROFILE_DATA_EVENTID:
4702 ath10k_wmi_event_wlan_profile_data(ar, skb);
4703 break;
4704 case WMI_RTT_MEASUREMENT_REPORT_EVENTID:
4705 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4706 break;
4707 case WMI_TSF_MEASUREMENT_REPORT_EVENTID:
4708 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4709 break;
4710 case WMI_RTT_ERROR_REPORT_EVENTID:
4711 ath10k_wmi_event_rtt_error_report(ar, skb);
4712 break;
4713 case WMI_WOW_WAKEUP_HOST_EVENTID:
4714 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4715 break;
4716 case WMI_DCS_INTERFERENCE_EVENTID:
4717 ath10k_wmi_event_dcs_interference(ar, skb);
4718 break;
4719 case WMI_PDEV_TPC_CONFIG_EVENTID:
4720 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4721 break;
4722 case WMI_PDEV_FTM_INTG_EVENTID:
4723 ath10k_wmi_event_pdev_ftm_intg(ar, skb);
4724 break;
4725 case WMI_GTK_OFFLOAD_STATUS_EVENTID:
4726 ath10k_wmi_event_gtk_offload_status(ar, skb);
4727 break;
4728 case WMI_GTK_REKEY_FAIL_EVENTID:
4729 ath10k_wmi_event_gtk_rekey_fail(ar, skb);
4730 break;
4731 case WMI_TX_DELBA_COMPLETE_EVENTID:
4732 ath10k_wmi_event_delba_complete(ar, skb);
4733 break;
4734 case WMI_TX_ADDBA_COMPLETE_EVENTID:
4735 ath10k_wmi_event_addba_complete(ar, skb);
4736 break;
4737 case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID:
4738 ath10k_wmi_event_vdev_install_key_complete(ar, skb);
4739 break;
4740 case WMI_SERVICE_READY_EVENTID:
4741 ath10k_wmi_event_service_ready(ar, skb);
4742 return;
4743 case WMI_READY_EVENTID:
4744 ath10k_wmi_event_ready(ar, skb);
4745 break;
4746 default:
4747 ath10k_warn(ar, "Unknown eventid: %d\n", id);
4748 break;
4751 out:
4752 dev_kfree_skb(skb);
4755 static void ath10k_wmi_10_1_op_rx(struct ath10k *ar, struct sk_buff *skb)
4757 struct wmi_cmd_hdr *cmd_hdr;
4758 enum wmi_10x_event_id id;
4759 bool consumed;
4761 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4762 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4764 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
4765 goto out;
4767 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
4769 consumed = ath10k_tm_event_wmi(ar, id, skb);
4771 /* Ready event must be handled normally also in UTF mode so that we
4772 * know the UTF firmware has booted, others we are just bypass WMI
4773 * events to testmode.
4775 if (consumed && id != WMI_10X_READY_EVENTID) {
4776 ath10k_dbg(ar, ATH10K_DBG_WMI,
4777 "wmi testmode consumed 0x%x\n", id);
4778 goto out;
4781 switch (id) {
4782 case WMI_10X_MGMT_RX_EVENTID:
4783 ath10k_wmi_event_mgmt_rx(ar, skb);
4784 /* mgmt_rx() owns the skb now! */
4785 return;
4786 case WMI_10X_SCAN_EVENTID:
4787 ath10k_wmi_event_scan(ar, skb);
4788 break;
4789 case WMI_10X_CHAN_INFO_EVENTID:
4790 ath10k_wmi_event_chan_info(ar, skb);
4791 break;
4792 case WMI_10X_ECHO_EVENTID:
4793 ath10k_wmi_event_echo(ar, skb);
4794 break;
4795 case WMI_10X_DEBUG_MESG_EVENTID:
4796 ath10k_wmi_event_debug_mesg(ar, skb);
4797 break;
4798 case WMI_10X_UPDATE_STATS_EVENTID:
4799 ath10k_wmi_event_update_stats(ar, skb);
4800 break;
4801 case WMI_10X_VDEV_START_RESP_EVENTID:
4802 ath10k_wmi_event_vdev_start_resp(ar, skb);
4803 break;
4804 case WMI_10X_VDEV_STOPPED_EVENTID:
4805 ath10k_wmi_event_vdev_stopped(ar, skb);
4806 break;
4807 case WMI_10X_PEER_STA_KICKOUT_EVENTID:
4808 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4809 break;
4810 case WMI_10X_HOST_SWBA_EVENTID:
4811 ath10k_wmi_event_host_swba(ar, skb);
4812 break;
4813 case WMI_10X_TBTTOFFSET_UPDATE_EVENTID:
4814 ath10k_wmi_event_tbttoffset_update(ar, skb);
4815 break;
4816 case WMI_10X_PHYERR_EVENTID:
4817 ath10k_wmi_event_phyerr(ar, skb);
4818 break;
4819 case WMI_10X_ROAM_EVENTID:
4820 ath10k_wmi_event_roam(ar, skb);
4821 break;
4822 case WMI_10X_PROFILE_MATCH:
4823 ath10k_wmi_event_profile_match(ar, skb);
4824 break;
4825 case WMI_10X_DEBUG_PRINT_EVENTID:
4826 ath10k_wmi_event_debug_print(ar, skb);
4827 break;
4828 case WMI_10X_PDEV_QVIT_EVENTID:
4829 ath10k_wmi_event_pdev_qvit(ar, skb);
4830 break;
4831 case WMI_10X_WLAN_PROFILE_DATA_EVENTID:
4832 ath10k_wmi_event_wlan_profile_data(ar, skb);
4833 break;
4834 case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID:
4835 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4836 break;
4837 case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID:
4838 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4839 break;
4840 case WMI_10X_RTT_ERROR_REPORT_EVENTID:
4841 ath10k_wmi_event_rtt_error_report(ar, skb);
4842 break;
4843 case WMI_10X_WOW_WAKEUP_HOST_EVENTID:
4844 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4845 break;
4846 case WMI_10X_DCS_INTERFERENCE_EVENTID:
4847 ath10k_wmi_event_dcs_interference(ar, skb);
4848 break;
4849 case WMI_10X_PDEV_TPC_CONFIG_EVENTID:
4850 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4851 break;
4852 case WMI_10X_INST_RSSI_STATS_EVENTID:
4853 ath10k_wmi_event_inst_rssi_stats(ar, skb);
4854 break;
4855 case WMI_10X_VDEV_STANDBY_REQ_EVENTID:
4856 ath10k_wmi_event_vdev_standby_req(ar, skb);
4857 break;
4858 case WMI_10X_VDEV_RESUME_REQ_EVENTID:
4859 ath10k_wmi_event_vdev_resume_req(ar, skb);
4860 break;
4861 case WMI_10X_SERVICE_READY_EVENTID:
4862 ath10k_wmi_event_service_ready(ar, skb);
4863 return;
4864 case WMI_10X_READY_EVENTID:
4865 ath10k_wmi_event_ready(ar, skb);
4866 break;
4867 case WMI_10X_PDEV_UTF_EVENTID:
4868 /* ignore utf events */
4869 break;
4870 default:
4871 ath10k_warn(ar, "Unknown eventid: %d\n", id);
4872 break;
4875 out:
4876 dev_kfree_skb(skb);
4879 static void ath10k_wmi_10_2_op_rx(struct ath10k *ar, struct sk_buff *skb)
4881 struct wmi_cmd_hdr *cmd_hdr;
4882 enum wmi_10_2_event_id id;
4884 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
4885 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
4887 if (skb_pull(skb, sizeof(struct wmi_cmd_hdr)) == NULL)
4888 goto out;
4890 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
4892 switch (id) {
4893 case WMI_10_2_MGMT_RX_EVENTID:
4894 ath10k_wmi_event_mgmt_rx(ar, skb);
4895 /* mgmt_rx() owns the skb now! */
4896 return;
4897 case WMI_10_2_SCAN_EVENTID:
4898 ath10k_wmi_event_scan(ar, skb);
4899 break;
4900 case WMI_10_2_CHAN_INFO_EVENTID:
4901 ath10k_wmi_event_chan_info(ar, skb);
4902 break;
4903 case WMI_10_2_ECHO_EVENTID:
4904 ath10k_wmi_event_echo(ar, skb);
4905 break;
4906 case WMI_10_2_DEBUG_MESG_EVENTID:
4907 ath10k_wmi_event_debug_mesg(ar, skb);
4908 break;
4909 case WMI_10_2_UPDATE_STATS_EVENTID:
4910 ath10k_wmi_event_update_stats(ar, skb);
4911 break;
4912 case WMI_10_2_VDEV_START_RESP_EVENTID:
4913 ath10k_wmi_event_vdev_start_resp(ar, skb);
4914 break;
4915 case WMI_10_2_VDEV_STOPPED_EVENTID:
4916 ath10k_wmi_event_vdev_stopped(ar, skb);
4917 break;
4918 case WMI_10_2_PEER_STA_KICKOUT_EVENTID:
4919 ath10k_wmi_event_peer_sta_kickout(ar, skb);
4920 break;
4921 case WMI_10_2_HOST_SWBA_EVENTID:
4922 ath10k_wmi_event_host_swba(ar, skb);
4923 break;
4924 case WMI_10_2_TBTTOFFSET_UPDATE_EVENTID:
4925 ath10k_wmi_event_tbttoffset_update(ar, skb);
4926 break;
4927 case WMI_10_2_PHYERR_EVENTID:
4928 ath10k_wmi_event_phyerr(ar, skb);
4929 break;
4930 case WMI_10_2_ROAM_EVENTID:
4931 ath10k_wmi_event_roam(ar, skb);
4932 break;
4933 case WMI_10_2_PROFILE_MATCH:
4934 ath10k_wmi_event_profile_match(ar, skb);
4935 break;
4936 case WMI_10_2_DEBUG_PRINT_EVENTID:
4937 ath10k_wmi_event_debug_print(ar, skb);
4938 break;
4939 case WMI_10_2_PDEV_QVIT_EVENTID:
4940 ath10k_wmi_event_pdev_qvit(ar, skb);
4941 break;
4942 case WMI_10_2_WLAN_PROFILE_DATA_EVENTID:
4943 ath10k_wmi_event_wlan_profile_data(ar, skb);
4944 break;
4945 case WMI_10_2_RTT_MEASUREMENT_REPORT_EVENTID:
4946 ath10k_wmi_event_rtt_measurement_report(ar, skb);
4947 break;
4948 case WMI_10_2_TSF_MEASUREMENT_REPORT_EVENTID:
4949 ath10k_wmi_event_tsf_measurement_report(ar, skb);
4950 break;
4951 case WMI_10_2_RTT_ERROR_REPORT_EVENTID:
4952 ath10k_wmi_event_rtt_error_report(ar, skb);
4953 break;
4954 case WMI_10_2_WOW_WAKEUP_HOST_EVENTID:
4955 ath10k_wmi_event_wow_wakeup_host(ar, skb);
4956 break;
4957 case WMI_10_2_DCS_INTERFERENCE_EVENTID:
4958 ath10k_wmi_event_dcs_interference(ar, skb);
4959 break;
4960 case WMI_10_2_PDEV_TPC_CONFIG_EVENTID:
4961 ath10k_wmi_event_pdev_tpc_config(ar, skb);
4962 break;
4963 case WMI_10_2_INST_RSSI_STATS_EVENTID:
4964 ath10k_wmi_event_inst_rssi_stats(ar, skb);
4965 break;
4966 case WMI_10_2_VDEV_STANDBY_REQ_EVENTID:
4967 ath10k_wmi_event_vdev_standby_req(ar, skb);
4968 break;
4969 case WMI_10_2_VDEV_RESUME_REQ_EVENTID:
4970 ath10k_wmi_event_vdev_resume_req(ar, skb);
4971 break;
4972 case WMI_10_2_SERVICE_READY_EVENTID:
4973 ath10k_wmi_event_service_ready(ar, skb);
4974 return;
4975 case WMI_10_2_READY_EVENTID:
4976 ath10k_wmi_event_ready(ar, skb);
4977 break;
4978 case WMI_10_2_PDEV_TEMPERATURE_EVENTID:
4979 ath10k_wmi_event_temperature(ar, skb);
4980 break;
4981 case WMI_10_2_RTT_KEEPALIVE_EVENTID:
4982 case WMI_10_2_GPIO_INPUT_EVENTID:
4983 case WMI_10_2_PEER_RATECODE_LIST_EVENTID:
4984 case WMI_10_2_GENERIC_BUFFER_EVENTID:
4985 case WMI_10_2_MCAST_BUF_RELEASE_EVENTID:
4986 case WMI_10_2_MCAST_LIST_AGEOUT_EVENTID:
4987 case WMI_10_2_WDS_PEER_EVENTID:
4988 ath10k_dbg(ar, ATH10K_DBG_WMI,
4989 "received event id %d not implemented\n", id);
4990 break;
4991 default:
4992 ath10k_warn(ar, "Unknown eventid: %d\n", id);
4993 break;
4996 out:
4997 dev_kfree_skb(skb);
5000 static void ath10k_wmi_10_4_op_rx(struct ath10k *ar, struct sk_buff *skb)
5002 struct wmi_cmd_hdr *cmd_hdr;
5003 enum wmi_10_4_event_id id;
5005 cmd_hdr = (struct wmi_cmd_hdr *)skb->data;
5006 id = MS(__le32_to_cpu(cmd_hdr->cmd_id), WMI_CMD_HDR_CMD_ID);
5008 if (!skb_pull(skb, sizeof(struct wmi_cmd_hdr)))
5009 goto out;
5011 trace_ath10k_wmi_event(ar, id, skb->data, skb->len);
5013 switch (id) {
5014 case WMI_10_4_MGMT_RX_EVENTID:
5015 ath10k_wmi_event_mgmt_rx(ar, skb);
5016 /* mgmt_rx() owns the skb now! */
5017 return;
5018 case WMI_10_4_ECHO_EVENTID:
5019 ath10k_wmi_event_echo(ar, skb);
5020 break;
5021 case WMI_10_4_DEBUG_MESG_EVENTID:
5022 ath10k_wmi_event_debug_mesg(ar, skb);
5023 break;
5024 case WMI_10_4_SERVICE_READY_EVENTID:
5025 ath10k_wmi_event_service_ready(ar, skb);
5026 return;
5027 case WMI_10_4_SCAN_EVENTID:
5028 ath10k_wmi_event_scan(ar, skb);
5029 break;
5030 case WMI_10_4_CHAN_INFO_EVENTID:
5031 ath10k_wmi_event_chan_info(ar, skb);
5032 break;
5033 case WMI_10_4_PHYERR_EVENTID:
5034 ath10k_wmi_event_phyerr(ar, skb);
5035 break;
5036 case WMI_10_4_READY_EVENTID:
5037 ath10k_wmi_event_ready(ar, skb);
5038 break;
5039 case WMI_10_4_PEER_STA_KICKOUT_EVENTID:
5040 ath10k_wmi_event_peer_sta_kickout(ar, skb);
5041 break;
5042 case WMI_10_4_HOST_SWBA_EVENTID:
5043 ath10k_wmi_event_host_swba(ar, skb);
5044 break;
5045 case WMI_10_4_TBTTOFFSET_UPDATE_EVENTID:
5046 ath10k_wmi_event_tbttoffset_update(ar, skb);
5047 break;
5048 case WMI_10_4_DEBUG_PRINT_EVENTID:
5049 ath10k_wmi_event_debug_print(ar, skb);
5050 break;
5051 case WMI_10_4_VDEV_START_RESP_EVENTID:
5052 ath10k_wmi_event_vdev_start_resp(ar, skb);
5053 break;
5054 case WMI_10_4_VDEV_STOPPED_EVENTID:
5055 ath10k_wmi_event_vdev_stopped(ar, skb);
5056 break;
5057 case WMI_10_4_WOW_WAKEUP_HOST_EVENTID:
5058 ath10k_dbg(ar, ATH10K_DBG_WMI,
5059 "received event id %d not implemented\n", id);
5060 break;
5061 case WMI_10_4_UPDATE_STATS_EVENTID:
5062 ath10k_wmi_event_update_stats(ar, skb);
5063 break;
5064 default:
5065 ath10k_warn(ar, "Unknown eventid: %d\n", id);
5066 break;
5069 out:
5070 dev_kfree_skb(skb);
5073 static void ath10k_wmi_process_rx(struct ath10k *ar, struct sk_buff *skb)
5075 int ret;
5077 ret = ath10k_wmi_rx(ar, skb);
5078 if (ret)
5079 ath10k_warn(ar, "failed to process wmi rx: %d\n", ret);
5082 int ath10k_wmi_connect(struct ath10k *ar)
5084 int status;
5085 struct ath10k_htc_svc_conn_req conn_req;
5086 struct ath10k_htc_svc_conn_resp conn_resp;
5088 memset(&conn_req, 0, sizeof(conn_req));
5089 memset(&conn_resp, 0, sizeof(conn_resp));
5091 /* these fields are the same for all service endpoints */
5092 conn_req.ep_ops.ep_tx_complete = ath10k_wmi_htc_tx_complete;
5093 conn_req.ep_ops.ep_rx_complete = ath10k_wmi_process_rx;
5094 conn_req.ep_ops.ep_tx_credits = ath10k_wmi_op_ep_tx_credits;
5096 /* connect to control service */
5097 conn_req.service_id = ATH10K_HTC_SVC_ID_WMI_CONTROL;
5099 status = ath10k_htc_connect_service(&ar->htc, &conn_req, &conn_resp);
5100 if (status) {
5101 ath10k_warn(ar, "failed to connect to WMI CONTROL service status: %d\n",
5102 status);
5103 return status;
5106 ar->wmi.eid = conn_resp.eid;
5107 return 0;
5110 static struct sk_buff *
5111 ath10k_wmi_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16 rd5g,
5112 u16 ctl2g, u16 ctl5g,
5113 enum wmi_dfs_region dfs_reg)
5115 struct wmi_pdev_set_regdomain_cmd *cmd;
5116 struct sk_buff *skb;
5118 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5119 if (!skb)
5120 return ERR_PTR(-ENOMEM);
5122 cmd = (struct wmi_pdev_set_regdomain_cmd *)skb->data;
5123 cmd->reg_domain = __cpu_to_le32(rd);
5124 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5125 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5126 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5127 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5129 ath10k_dbg(ar, ATH10K_DBG_WMI,
5130 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
5131 rd, rd2g, rd5g, ctl2g, ctl5g);
5132 return skb;
5135 static struct sk_buff *
5136 ath10k_wmi_10x_op_gen_pdev_set_rd(struct ath10k *ar, u16 rd, u16 rd2g, u16
5137 rd5g, u16 ctl2g, u16 ctl5g,
5138 enum wmi_dfs_region dfs_reg)
5140 struct wmi_pdev_set_regdomain_cmd_10x *cmd;
5141 struct sk_buff *skb;
5143 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5144 if (!skb)
5145 return ERR_PTR(-ENOMEM);
5147 cmd = (struct wmi_pdev_set_regdomain_cmd_10x *)skb->data;
5148 cmd->reg_domain = __cpu_to_le32(rd);
5149 cmd->reg_domain_2G = __cpu_to_le32(rd2g);
5150 cmd->reg_domain_5G = __cpu_to_le32(rd5g);
5151 cmd->conformance_test_limit_2G = __cpu_to_le32(ctl2g);
5152 cmd->conformance_test_limit_5G = __cpu_to_le32(ctl5g);
5153 cmd->dfs_domain = __cpu_to_le32(dfs_reg);
5155 ath10k_dbg(ar, ATH10K_DBG_WMI,
5156 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x dfs_region %x\n",
5157 rd, rd2g, rd5g, ctl2g, ctl5g, dfs_reg);
5158 return skb;
5161 static struct sk_buff *
5162 ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)
5164 struct wmi_pdev_suspend_cmd *cmd;
5165 struct sk_buff *skb;
5167 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5168 if (!skb)
5169 return ERR_PTR(-ENOMEM);
5171 cmd = (struct wmi_pdev_suspend_cmd *)skb->data;
5172 cmd->suspend_opt = __cpu_to_le32(suspend_opt);
5174 return skb;
5177 static struct sk_buff *
5178 ath10k_wmi_op_gen_pdev_resume(struct ath10k *ar)
5180 struct sk_buff *skb;
5182 skb = ath10k_wmi_alloc_skb(ar, 0);
5183 if (!skb)
5184 return ERR_PTR(-ENOMEM);
5186 return skb;
5189 static struct sk_buff *
5190 ath10k_wmi_op_gen_pdev_set_param(struct ath10k *ar, u32 id, u32 value)
5192 struct wmi_pdev_set_param_cmd *cmd;
5193 struct sk_buff *skb;
5195 if (id == WMI_PDEV_PARAM_UNSUPPORTED) {
5196 ath10k_warn(ar, "pdev param %d not supported by firmware\n",
5197 id);
5198 return ERR_PTR(-EOPNOTSUPP);
5201 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5202 if (!skb)
5203 return ERR_PTR(-ENOMEM);
5205 cmd = (struct wmi_pdev_set_param_cmd *)skb->data;
5206 cmd->param_id = __cpu_to_le32(id);
5207 cmd->param_value = __cpu_to_le32(value);
5209 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set param %d value %d\n",
5210 id, value);
5211 return skb;
5214 void ath10k_wmi_put_host_mem_chunks(struct ath10k *ar,
5215 struct wmi_host_mem_chunks *chunks)
5217 struct host_memory_chunk *chunk;
5218 int i;
5220 chunks->count = __cpu_to_le32(ar->wmi.num_mem_chunks);
5222 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
5223 chunk = &chunks->items[i];
5224 chunk->ptr = __cpu_to_le32(ar->wmi.mem_chunks[i].paddr);
5225 chunk->size = __cpu_to_le32(ar->wmi.mem_chunks[i].len);
5226 chunk->req_id = __cpu_to_le32(ar->wmi.mem_chunks[i].req_id);
5228 ath10k_dbg(ar, ATH10K_DBG_WMI,
5229 "wmi chunk %d len %d requested, addr 0x%llx\n",
5231 ar->wmi.mem_chunks[i].len,
5232 (unsigned long long)ar->wmi.mem_chunks[i].paddr);
5236 static struct sk_buff *ath10k_wmi_op_gen_init(struct ath10k *ar)
5238 struct wmi_init_cmd *cmd;
5239 struct sk_buff *buf;
5240 struct wmi_resource_config config = {};
5241 u32 len, val;
5243 config.num_vdevs = __cpu_to_le32(TARGET_NUM_VDEVS);
5244 config.num_peers = __cpu_to_le32(TARGET_NUM_PEERS);
5245 config.num_offload_peers = __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS);
5247 config.num_offload_reorder_bufs =
5248 __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS);
5250 config.num_peer_keys = __cpu_to_le32(TARGET_NUM_PEER_KEYS);
5251 config.num_tids = __cpu_to_le32(TARGET_NUM_TIDS);
5252 config.ast_skid_limit = __cpu_to_le32(TARGET_AST_SKID_LIMIT);
5253 config.tx_chain_mask = __cpu_to_le32(TARGET_TX_CHAIN_MASK);
5254 config.rx_chain_mask = __cpu_to_le32(TARGET_RX_CHAIN_MASK);
5255 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5256 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5257 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI);
5258 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI);
5259 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
5260 config.scan_max_pending_reqs =
5261 __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS);
5263 config.bmiss_offload_max_vdev =
5264 __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV);
5266 config.roam_offload_max_vdev =
5267 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV);
5269 config.roam_offload_max_ap_profiles =
5270 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES);
5272 config.num_mcast_groups = __cpu_to_le32(TARGET_NUM_MCAST_GROUPS);
5273 config.num_mcast_table_elems =
5274 __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS);
5276 config.mcast2ucast_mode = __cpu_to_le32(TARGET_MCAST2UCAST_MODE);
5277 config.tx_dbg_log_size = __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE);
5278 config.num_wds_entries = __cpu_to_le32(TARGET_NUM_WDS_ENTRIES);
5279 config.dma_burst_size = __cpu_to_le32(TARGET_DMA_BURST_SIZE);
5280 config.mac_aggr_delim = __cpu_to_le32(TARGET_MAC_AGGR_DELIM);
5282 val = TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5283 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5285 config.vow_config = __cpu_to_le32(TARGET_VOW_CONFIG);
5287 config.gtk_offload_max_vdev =
5288 __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV);
5290 config.num_msdu_desc = __cpu_to_le32(TARGET_NUM_MSDU_DESC);
5291 config.max_frag_entries = __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES);
5293 len = sizeof(*cmd) +
5294 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5296 buf = ath10k_wmi_alloc_skb(ar, len);
5297 if (!buf)
5298 return ERR_PTR(-ENOMEM);
5300 cmd = (struct wmi_init_cmd *)buf->data;
5302 memcpy(&cmd->resource_config, &config, sizeof(config));
5303 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5305 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init\n");
5306 return buf;
5309 static struct sk_buff *ath10k_wmi_10_1_op_gen_init(struct ath10k *ar)
5311 struct wmi_init_cmd_10x *cmd;
5312 struct sk_buff *buf;
5313 struct wmi_resource_config_10x config = {};
5314 u32 len, val;
5316 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5317 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5318 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5319 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5320 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5321 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5322 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5323 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5324 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5325 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5326 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
5327 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
5328 config.scan_max_pending_reqs =
5329 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
5331 config.bmiss_offload_max_vdev =
5332 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
5334 config.roam_offload_max_vdev =
5335 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
5337 config.roam_offload_max_ap_profiles =
5338 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
5340 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
5341 config.num_mcast_table_elems =
5342 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
5344 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5345 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5346 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
5347 config.dma_burst_size = __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE);
5348 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
5350 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5351 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5353 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
5355 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5356 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
5358 len = sizeof(*cmd) +
5359 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5361 buf = ath10k_wmi_alloc_skb(ar, len);
5362 if (!buf)
5363 return ERR_PTR(-ENOMEM);
5365 cmd = (struct wmi_init_cmd_10x *)buf->data;
5367 memcpy(&cmd->resource_config, &config, sizeof(config));
5368 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5370 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10x\n");
5371 return buf;
5374 static struct sk_buff *ath10k_wmi_10_2_op_gen_init(struct ath10k *ar)
5376 struct wmi_init_cmd_10_2 *cmd;
5377 struct sk_buff *buf;
5378 struct wmi_resource_config_10x config = {};
5379 u32 len, val, features;
5381 config.num_vdevs = __cpu_to_le32(TARGET_10X_NUM_VDEVS);
5382 config.num_peers = __cpu_to_le32(TARGET_10X_NUM_PEERS);
5383 config.num_peer_keys = __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS);
5384 config.num_tids = __cpu_to_le32(TARGET_10X_NUM_TIDS);
5385 config.ast_skid_limit = __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT);
5386 config.tx_chain_mask = __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK);
5387 config.rx_chain_mask = __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK);
5388 config.rx_timeout_pri_vo = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5389 config.rx_timeout_pri_vi = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5390 config.rx_timeout_pri_be = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI);
5391 config.rx_timeout_pri_bk = __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI);
5392 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
5394 config.scan_max_pending_reqs =
5395 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS);
5397 config.bmiss_offload_max_vdev =
5398 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV);
5400 config.roam_offload_max_vdev =
5401 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV);
5403 config.roam_offload_max_ap_profiles =
5404 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES);
5406 config.num_mcast_groups = __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS);
5407 config.num_mcast_table_elems =
5408 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS);
5410 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE);
5411 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE);
5412 config.num_wds_entries = __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES);
5413 config.dma_burst_size = __cpu_to_le32(TARGET_10_2_DMA_BURST_SIZE);
5414 config.mac_aggr_delim = __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM);
5416 val = TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK;
5417 config.rx_skip_defrag_timeout_dup_detection_check = __cpu_to_le32(val);
5419 config.vow_config = __cpu_to_le32(TARGET_10X_VOW_CONFIG);
5421 config.num_msdu_desc = __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC);
5422 config.max_frag_entries = __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES);
5424 len = sizeof(*cmd) +
5425 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5427 buf = ath10k_wmi_alloc_skb(ar, len);
5428 if (!buf)
5429 return ERR_PTR(-ENOMEM);
5431 cmd = (struct wmi_init_cmd_10_2 *)buf->data;
5433 features = WMI_10_2_RX_BATCH_MODE;
5434 if (test_bit(WMI_SERVICE_COEX_GPIO, ar->wmi.svc_map))
5435 features |= WMI_10_2_COEX_GPIO;
5436 cmd->resource_config.feature_mask = __cpu_to_le32(features);
5438 memcpy(&cmd->resource_config.common, &config, sizeof(config));
5439 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5441 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.2\n");
5442 return buf;
5445 static struct sk_buff *ath10k_wmi_10_4_op_gen_init(struct ath10k *ar)
5447 struct wmi_init_cmd_10_4 *cmd;
5448 struct sk_buff *buf;
5449 struct wmi_resource_config_10_4 config = {};
5450 u32 len;
5452 config.num_vdevs = __cpu_to_le32(ar->max_num_vdevs);
5453 config.num_peers = __cpu_to_le32(ar->max_num_peers);
5454 config.num_active_peers = __cpu_to_le32(ar->num_active_peers);
5455 config.num_tids = __cpu_to_le32(ar->num_tids);
5457 config.num_offload_peers = __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_PEERS);
5458 config.num_offload_reorder_buffs =
5459 __cpu_to_le32(TARGET_10_4_NUM_OFFLOAD_REORDER_BUFFS);
5460 config.num_peer_keys = __cpu_to_le32(TARGET_10_4_NUM_PEER_KEYS);
5461 config.ast_skid_limit = __cpu_to_le32(TARGET_10_4_AST_SKID_LIMIT);
5462 config.tx_chain_mask = __cpu_to_le32(TARGET_10_4_TX_CHAIN_MASK);
5463 config.rx_chain_mask = __cpu_to_le32(TARGET_10_4_RX_CHAIN_MASK);
5465 config.rx_timeout_pri[0] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5466 config.rx_timeout_pri[1] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5467 config.rx_timeout_pri[2] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_LO_PRI);
5468 config.rx_timeout_pri[3] = __cpu_to_le32(TARGET_10_4_RX_TIMEOUT_HI_PRI);
5470 config.rx_decap_mode = __cpu_to_le32(ar->wmi.rx_decap_mode);
5471 config.scan_max_pending_req = __cpu_to_le32(TARGET_10_4_SCAN_MAX_REQS);
5472 config.bmiss_offload_max_vdev =
5473 __cpu_to_le32(TARGET_10_4_BMISS_OFFLOAD_MAX_VDEV);
5474 config.roam_offload_max_vdev =
5475 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_VDEV);
5476 config.roam_offload_max_ap_profiles =
5477 __cpu_to_le32(TARGET_10_4_ROAM_OFFLOAD_MAX_PROFILES);
5478 config.num_mcast_groups = __cpu_to_le32(TARGET_10_4_NUM_MCAST_GROUPS);
5479 config.num_mcast_table_elems =
5480 __cpu_to_le32(TARGET_10_4_NUM_MCAST_TABLE_ELEMS);
5482 config.mcast2ucast_mode = __cpu_to_le32(TARGET_10_4_MCAST2UCAST_MODE);
5483 config.tx_dbg_log_size = __cpu_to_le32(TARGET_10_4_TX_DBG_LOG_SIZE);
5484 config.num_wds_entries = __cpu_to_le32(TARGET_10_4_NUM_WDS_ENTRIES);
5485 config.dma_burst_size = __cpu_to_le32(TARGET_10_4_DMA_BURST_SIZE);
5486 config.mac_aggr_delim = __cpu_to_le32(TARGET_10_4_MAC_AGGR_DELIM);
5488 config.rx_skip_defrag_timeout_dup_detection_check =
5489 __cpu_to_le32(TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK);
5491 config.vow_config = __cpu_to_le32(TARGET_10_4_VOW_CONFIG);
5492 config.gtk_offload_max_vdev =
5493 __cpu_to_le32(TARGET_10_4_GTK_OFFLOAD_MAX_VDEV);
5494 config.num_msdu_desc = __cpu_to_le32(TARGET_10_4_NUM_MSDU_DESC);
5495 config.max_frag_entries = __cpu_to_le32(TARGET_10_4_11AC_TX_MAX_FRAGS);
5496 config.max_peer_ext_stats =
5497 __cpu_to_le32(TARGET_10_4_MAX_PEER_EXT_STATS);
5498 config.smart_ant_cap = __cpu_to_le32(TARGET_10_4_SMART_ANT_CAP);
5500 config.bk_minfree = __cpu_to_le32(TARGET_10_4_BK_MIN_FREE);
5501 config.be_minfree = __cpu_to_le32(TARGET_10_4_BE_MIN_FREE);
5502 config.vi_minfree = __cpu_to_le32(TARGET_10_4_VI_MIN_FREE);
5503 config.vo_minfree = __cpu_to_le32(TARGET_10_4_VO_MIN_FREE);
5505 config.rx_batchmode = __cpu_to_le32(TARGET_10_4_RX_BATCH_MODE);
5506 config.tt_support =
5507 __cpu_to_le32(TARGET_10_4_THERMAL_THROTTLING_CONFIG);
5508 config.atf_config = __cpu_to_le32(TARGET_10_4_ATF_CONFIG);
5509 config.iphdr_pad_config = __cpu_to_le32(TARGET_10_4_IPHDR_PAD_CONFIG);
5510 config.qwrap_config = __cpu_to_le32(TARGET_10_4_QWRAP_CONFIG);
5512 len = sizeof(*cmd) +
5513 (sizeof(struct host_memory_chunk) * ar->wmi.num_mem_chunks);
5515 buf = ath10k_wmi_alloc_skb(ar, len);
5516 if (!buf)
5517 return ERR_PTR(-ENOMEM);
5519 cmd = (struct wmi_init_cmd_10_4 *)buf->data;
5520 memcpy(&cmd->resource_config, &config, sizeof(config));
5521 ath10k_wmi_put_host_mem_chunks(ar, &cmd->mem_chunks);
5523 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi init 10.4\n");
5524 return buf;
5527 int ath10k_wmi_start_scan_verify(const struct wmi_start_scan_arg *arg)
5529 if (arg->ie_len && !arg->ie)
5530 return -EINVAL;
5531 if (arg->n_channels && !arg->channels)
5532 return -EINVAL;
5533 if (arg->n_ssids && !arg->ssids)
5534 return -EINVAL;
5535 if (arg->n_bssids && !arg->bssids)
5536 return -EINVAL;
5538 if (arg->ie_len > WLAN_SCAN_PARAMS_MAX_IE_LEN)
5539 return -EINVAL;
5540 if (arg->n_channels > ARRAY_SIZE(arg->channels))
5541 return -EINVAL;
5542 if (arg->n_ssids > WLAN_SCAN_PARAMS_MAX_SSID)
5543 return -EINVAL;
5544 if (arg->n_bssids > WLAN_SCAN_PARAMS_MAX_BSSID)
5545 return -EINVAL;
5547 return 0;
5550 static size_t
5551 ath10k_wmi_start_scan_tlvs_len(const struct wmi_start_scan_arg *arg)
5553 int len = 0;
5555 if (arg->ie_len) {
5556 len += sizeof(struct wmi_ie_data);
5557 len += roundup(arg->ie_len, 4);
5560 if (arg->n_channels) {
5561 len += sizeof(struct wmi_chan_list);
5562 len += sizeof(__le32) * arg->n_channels;
5565 if (arg->n_ssids) {
5566 len += sizeof(struct wmi_ssid_list);
5567 len += sizeof(struct wmi_ssid) * arg->n_ssids;
5570 if (arg->n_bssids) {
5571 len += sizeof(struct wmi_bssid_list);
5572 len += sizeof(struct wmi_mac_addr) * arg->n_bssids;
5575 return len;
5578 void ath10k_wmi_put_start_scan_common(struct wmi_start_scan_common *cmn,
5579 const struct wmi_start_scan_arg *arg)
5581 u32 scan_id;
5582 u32 scan_req_id;
5584 scan_id = WMI_HOST_SCAN_REQ_ID_PREFIX;
5585 scan_id |= arg->scan_id;
5587 scan_req_id = WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5588 scan_req_id |= arg->scan_req_id;
5590 cmn->scan_id = __cpu_to_le32(scan_id);
5591 cmn->scan_req_id = __cpu_to_le32(scan_req_id);
5592 cmn->vdev_id = __cpu_to_le32(arg->vdev_id);
5593 cmn->scan_priority = __cpu_to_le32(arg->scan_priority);
5594 cmn->notify_scan_events = __cpu_to_le32(arg->notify_scan_events);
5595 cmn->dwell_time_active = __cpu_to_le32(arg->dwell_time_active);
5596 cmn->dwell_time_passive = __cpu_to_le32(arg->dwell_time_passive);
5597 cmn->min_rest_time = __cpu_to_le32(arg->min_rest_time);
5598 cmn->max_rest_time = __cpu_to_le32(arg->max_rest_time);
5599 cmn->repeat_probe_time = __cpu_to_le32(arg->repeat_probe_time);
5600 cmn->probe_spacing_time = __cpu_to_le32(arg->probe_spacing_time);
5601 cmn->idle_time = __cpu_to_le32(arg->idle_time);
5602 cmn->max_scan_time = __cpu_to_le32(arg->max_scan_time);
5603 cmn->probe_delay = __cpu_to_le32(arg->probe_delay);
5604 cmn->scan_ctrl_flags = __cpu_to_le32(arg->scan_ctrl_flags);
5607 static void
5608 ath10k_wmi_put_start_scan_tlvs(struct wmi_start_scan_tlvs *tlvs,
5609 const struct wmi_start_scan_arg *arg)
5611 struct wmi_ie_data *ie;
5612 struct wmi_chan_list *channels;
5613 struct wmi_ssid_list *ssids;
5614 struct wmi_bssid_list *bssids;
5615 void *ptr = tlvs->tlvs;
5616 int i;
5618 if (arg->n_channels) {
5619 channels = ptr;
5620 channels->tag = __cpu_to_le32(WMI_CHAN_LIST_TAG);
5621 channels->num_chan = __cpu_to_le32(arg->n_channels);
5623 for (i = 0; i < arg->n_channels; i++)
5624 channels->channel_list[i].freq =
5625 __cpu_to_le16(arg->channels[i]);
5627 ptr += sizeof(*channels);
5628 ptr += sizeof(__le32) * arg->n_channels;
5631 if (arg->n_ssids) {
5632 ssids = ptr;
5633 ssids->tag = __cpu_to_le32(WMI_SSID_LIST_TAG);
5634 ssids->num_ssids = __cpu_to_le32(arg->n_ssids);
5636 for (i = 0; i < arg->n_ssids; i++) {
5637 ssids->ssids[i].ssid_len =
5638 __cpu_to_le32(arg->ssids[i].len);
5639 memcpy(&ssids->ssids[i].ssid,
5640 arg->ssids[i].ssid,
5641 arg->ssids[i].len);
5644 ptr += sizeof(*ssids);
5645 ptr += sizeof(struct wmi_ssid) * arg->n_ssids;
5648 if (arg->n_bssids) {
5649 bssids = ptr;
5650 bssids->tag = __cpu_to_le32(WMI_BSSID_LIST_TAG);
5651 bssids->num_bssid = __cpu_to_le32(arg->n_bssids);
5653 for (i = 0; i < arg->n_bssids; i++)
5654 memcpy(&bssids->bssid_list[i],
5655 arg->bssids[i].bssid,
5656 ETH_ALEN);
5658 ptr += sizeof(*bssids);
5659 ptr += sizeof(struct wmi_mac_addr) * arg->n_bssids;
5662 if (arg->ie_len) {
5663 ie = ptr;
5664 ie->tag = __cpu_to_le32(WMI_IE_TAG);
5665 ie->ie_len = __cpu_to_le32(arg->ie_len);
5666 memcpy(ie->ie_data, arg->ie, arg->ie_len);
5668 ptr += sizeof(*ie);
5669 ptr += roundup(arg->ie_len, 4);
5673 static struct sk_buff *
5674 ath10k_wmi_op_gen_start_scan(struct ath10k *ar,
5675 const struct wmi_start_scan_arg *arg)
5677 struct wmi_start_scan_cmd *cmd;
5678 struct sk_buff *skb;
5679 size_t len;
5680 int ret;
5682 ret = ath10k_wmi_start_scan_verify(arg);
5683 if (ret)
5684 return ERR_PTR(ret);
5686 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
5687 skb = ath10k_wmi_alloc_skb(ar, len);
5688 if (!skb)
5689 return ERR_PTR(-ENOMEM);
5691 cmd = (struct wmi_start_scan_cmd *)skb->data;
5693 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5694 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
5696 cmd->burst_duration_ms = __cpu_to_le32(0);
5698 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi start scan\n");
5699 return skb;
5702 static struct sk_buff *
5703 ath10k_wmi_10x_op_gen_start_scan(struct ath10k *ar,
5704 const struct wmi_start_scan_arg *arg)
5706 struct wmi_10x_start_scan_cmd *cmd;
5707 struct sk_buff *skb;
5708 size_t len;
5709 int ret;
5711 ret = ath10k_wmi_start_scan_verify(arg);
5712 if (ret)
5713 return ERR_PTR(ret);
5715 len = sizeof(*cmd) + ath10k_wmi_start_scan_tlvs_len(arg);
5716 skb = ath10k_wmi_alloc_skb(ar, len);
5717 if (!skb)
5718 return ERR_PTR(-ENOMEM);
5720 cmd = (struct wmi_10x_start_scan_cmd *)skb->data;
5722 ath10k_wmi_put_start_scan_common(&cmd->common, arg);
5723 ath10k_wmi_put_start_scan_tlvs(&cmd->tlvs, arg);
5725 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi 10x start scan\n");
5726 return skb;
5729 void ath10k_wmi_start_scan_init(struct ath10k *ar,
5730 struct wmi_start_scan_arg *arg)
5732 /* setup commonly used values */
5733 arg->scan_req_id = 1;
5734 arg->scan_priority = WMI_SCAN_PRIORITY_LOW;
5735 arg->dwell_time_active = 50;
5736 arg->dwell_time_passive = 150;
5737 arg->min_rest_time = 50;
5738 arg->max_rest_time = 500;
5739 arg->repeat_probe_time = 0;
5740 arg->probe_spacing_time = 0;
5741 arg->idle_time = 0;
5742 arg->max_scan_time = 20000;
5743 arg->probe_delay = 5;
5744 arg->notify_scan_events = WMI_SCAN_EVENT_STARTED
5745 | WMI_SCAN_EVENT_COMPLETED
5746 | WMI_SCAN_EVENT_BSS_CHANNEL
5747 | WMI_SCAN_EVENT_FOREIGN_CHANNEL
5748 | WMI_SCAN_EVENT_DEQUEUED;
5749 arg->scan_ctrl_flags |= WMI_SCAN_CHAN_STAT_EVENT;
5750 arg->n_bssids = 1;
5751 arg->bssids[0].bssid = "\xFF\xFF\xFF\xFF\xFF\xFF";
5754 static struct sk_buff *
5755 ath10k_wmi_op_gen_stop_scan(struct ath10k *ar,
5756 const struct wmi_stop_scan_arg *arg)
5758 struct wmi_stop_scan_cmd *cmd;
5759 struct sk_buff *skb;
5760 u32 scan_id;
5761 u32 req_id;
5763 if (arg->req_id > 0xFFF)
5764 return ERR_PTR(-EINVAL);
5765 if (arg->req_type == WMI_SCAN_STOP_ONE && arg->u.scan_id > 0xFFF)
5766 return ERR_PTR(-EINVAL);
5768 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5769 if (!skb)
5770 return ERR_PTR(-ENOMEM);
5772 scan_id = arg->u.scan_id;
5773 scan_id |= WMI_HOST_SCAN_REQ_ID_PREFIX;
5775 req_id = arg->req_id;
5776 req_id |= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX;
5778 cmd = (struct wmi_stop_scan_cmd *)skb->data;
5779 cmd->req_type = __cpu_to_le32(arg->req_type);
5780 cmd->vdev_id = __cpu_to_le32(arg->u.vdev_id);
5781 cmd->scan_id = __cpu_to_le32(scan_id);
5782 cmd->scan_req_id = __cpu_to_le32(req_id);
5784 ath10k_dbg(ar, ATH10K_DBG_WMI,
5785 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
5786 arg->req_id, arg->req_type, arg->u.scan_id);
5787 return skb;
5790 static struct sk_buff *
5791 ath10k_wmi_op_gen_vdev_create(struct ath10k *ar, u32 vdev_id,
5792 enum wmi_vdev_type type,
5793 enum wmi_vdev_subtype subtype,
5794 const u8 macaddr[ETH_ALEN])
5796 struct wmi_vdev_create_cmd *cmd;
5797 struct sk_buff *skb;
5799 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5800 if (!skb)
5801 return ERR_PTR(-ENOMEM);
5803 cmd = (struct wmi_vdev_create_cmd *)skb->data;
5804 cmd->vdev_id = __cpu_to_le32(vdev_id);
5805 cmd->vdev_type = __cpu_to_le32(type);
5806 cmd->vdev_subtype = __cpu_to_le32(subtype);
5807 ether_addr_copy(cmd->vdev_macaddr.addr, macaddr);
5809 ath10k_dbg(ar, ATH10K_DBG_WMI,
5810 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
5811 vdev_id, type, subtype, macaddr);
5812 return skb;
5815 static struct sk_buff *
5816 ath10k_wmi_op_gen_vdev_delete(struct ath10k *ar, u32 vdev_id)
5818 struct wmi_vdev_delete_cmd *cmd;
5819 struct sk_buff *skb;
5821 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5822 if (!skb)
5823 return ERR_PTR(-ENOMEM);
5825 cmd = (struct wmi_vdev_delete_cmd *)skb->data;
5826 cmd->vdev_id = __cpu_to_le32(vdev_id);
5828 ath10k_dbg(ar, ATH10K_DBG_WMI,
5829 "WMI vdev delete id %d\n", vdev_id);
5830 return skb;
5833 static struct sk_buff *
5834 ath10k_wmi_op_gen_vdev_start(struct ath10k *ar,
5835 const struct wmi_vdev_start_request_arg *arg,
5836 bool restart)
5838 struct wmi_vdev_start_request_cmd *cmd;
5839 struct sk_buff *skb;
5840 const char *cmdname;
5841 u32 flags = 0;
5843 if (WARN_ON(arg->hidden_ssid && !arg->ssid))
5844 return ERR_PTR(-EINVAL);
5845 if (WARN_ON(arg->ssid_len > sizeof(cmd->ssid.ssid)))
5846 return ERR_PTR(-EINVAL);
5848 if (restart)
5849 cmdname = "restart";
5850 else
5851 cmdname = "start";
5853 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5854 if (!skb)
5855 return ERR_PTR(-ENOMEM);
5857 if (arg->hidden_ssid)
5858 flags |= WMI_VDEV_START_HIDDEN_SSID;
5859 if (arg->pmf_enabled)
5860 flags |= WMI_VDEV_START_PMF_ENABLED;
5862 cmd = (struct wmi_vdev_start_request_cmd *)skb->data;
5863 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
5864 cmd->disable_hw_ack = __cpu_to_le32(arg->disable_hw_ack);
5865 cmd->beacon_interval = __cpu_to_le32(arg->bcn_intval);
5866 cmd->dtim_period = __cpu_to_le32(arg->dtim_period);
5867 cmd->flags = __cpu_to_le32(flags);
5868 cmd->bcn_tx_rate = __cpu_to_le32(arg->bcn_tx_rate);
5869 cmd->bcn_tx_power = __cpu_to_le32(arg->bcn_tx_power);
5871 if (arg->ssid) {
5872 cmd->ssid.ssid_len = __cpu_to_le32(arg->ssid_len);
5873 memcpy(cmd->ssid.ssid, arg->ssid, arg->ssid_len);
5876 ath10k_wmi_put_wmi_channel(&cmd->chan, &arg->channel);
5878 ath10k_dbg(ar, ATH10K_DBG_WMI,
5879 "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, ch_flags: 0x%0X, max_power: %d\n",
5880 cmdname, arg->vdev_id,
5881 flags, arg->channel.freq, arg->channel.mode,
5882 cmd->chan.flags, arg->channel.max_power);
5884 return skb;
5887 static struct sk_buff *
5888 ath10k_wmi_op_gen_vdev_stop(struct ath10k *ar, u32 vdev_id)
5890 struct wmi_vdev_stop_cmd *cmd;
5891 struct sk_buff *skb;
5893 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5894 if (!skb)
5895 return ERR_PTR(-ENOMEM);
5897 cmd = (struct wmi_vdev_stop_cmd *)skb->data;
5898 cmd->vdev_id = __cpu_to_le32(vdev_id);
5900 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi vdev stop id 0x%x\n", vdev_id);
5901 return skb;
5904 static struct sk_buff *
5905 ath10k_wmi_op_gen_vdev_up(struct ath10k *ar, u32 vdev_id, u32 aid,
5906 const u8 *bssid)
5908 struct wmi_vdev_up_cmd *cmd;
5909 struct sk_buff *skb;
5911 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5912 if (!skb)
5913 return ERR_PTR(-ENOMEM);
5915 cmd = (struct wmi_vdev_up_cmd *)skb->data;
5916 cmd->vdev_id = __cpu_to_le32(vdev_id);
5917 cmd->vdev_assoc_id = __cpu_to_le32(aid);
5918 ether_addr_copy(cmd->vdev_bssid.addr, bssid);
5920 ath10k_dbg(ar, ATH10K_DBG_WMI,
5921 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
5922 vdev_id, aid, bssid);
5923 return skb;
5926 static struct sk_buff *
5927 ath10k_wmi_op_gen_vdev_down(struct ath10k *ar, u32 vdev_id)
5929 struct wmi_vdev_down_cmd *cmd;
5930 struct sk_buff *skb;
5932 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5933 if (!skb)
5934 return ERR_PTR(-ENOMEM);
5936 cmd = (struct wmi_vdev_down_cmd *)skb->data;
5937 cmd->vdev_id = __cpu_to_le32(vdev_id);
5939 ath10k_dbg(ar, ATH10K_DBG_WMI,
5940 "wmi mgmt vdev down id 0x%x\n", vdev_id);
5941 return skb;
5944 static struct sk_buff *
5945 ath10k_wmi_op_gen_vdev_set_param(struct ath10k *ar, u32 vdev_id,
5946 u32 param_id, u32 param_value)
5948 struct wmi_vdev_set_param_cmd *cmd;
5949 struct sk_buff *skb;
5951 if (param_id == WMI_VDEV_PARAM_UNSUPPORTED) {
5952 ath10k_dbg(ar, ATH10K_DBG_WMI,
5953 "vdev param %d not supported by firmware\n",
5954 param_id);
5955 return ERR_PTR(-EOPNOTSUPP);
5958 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
5959 if (!skb)
5960 return ERR_PTR(-ENOMEM);
5962 cmd = (struct wmi_vdev_set_param_cmd *)skb->data;
5963 cmd->vdev_id = __cpu_to_le32(vdev_id);
5964 cmd->param_id = __cpu_to_le32(param_id);
5965 cmd->param_value = __cpu_to_le32(param_value);
5967 ath10k_dbg(ar, ATH10K_DBG_WMI,
5968 "wmi vdev id 0x%x set param %d value %d\n",
5969 vdev_id, param_id, param_value);
5970 return skb;
5973 static struct sk_buff *
5974 ath10k_wmi_op_gen_vdev_install_key(struct ath10k *ar,
5975 const struct wmi_vdev_install_key_arg *arg)
5977 struct wmi_vdev_install_key_cmd *cmd;
5978 struct sk_buff *skb;
5980 if (arg->key_cipher == WMI_CIPHER_NONE && arg->key_data != NULL)
5981 return ERR_PTR(-EINVAL);
5982 if (arg->key_cipher != WMI_CIPHER_NONE && arg->key_data == NULL)
5983 return ERR_PTR(-EINVAL);
5985 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd) + arg->key_len);
5986 if (!skb)
5987 return ERR_PTR(-ENOMEM);
5989 cmd = (struct wmi_vdev_install_key_cmd *)skb->data;
5990 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
5991 cmd->key_idx = __cpu_to_le32(arg->key_idx);
5992 cmd->key_flags = __cpu_to_le32(arg->key_flags);
5993 cmd->key_cipher = __cpu_to_le32(arg->key_cipher);
5994 cmd->key_len = __cpu_to_le32(arg->key_len);
5995 cmd->key_txmic_len = __cpu_to_le32(arg->key_txmic_len);
5996 cmd->key_rxmic_len = __cpu_to_le32(arg->key_rxmic_len);
5998 if (arg->macaddr)
5999 ether_addr_copy(cmd->peer_macaddr.addr, arg->macaddr);
6000 if (arg->key_data)
6001 memcpy(cmd->key_data, arg->key_data, arg->key_len);
6003 ath10k_dbg(ar, ATH10K_DBG_WMI,
6004 "wmi vdev install key idx %d cipher %d len %d\n",
6005 arg->key_idx, arg->key_cipher, arg->key_len);
6006 return skb;
6009 static struct sk_buff *
6010 ath10k_wmi_op_gen_vdev_spectral_conf(struct ath10k *ar,
6011 const struct wmi_vdev_spectral_conf_arg *arg)
6013 struct wmi_vdev_spectral_conf_cmd *cmd;
6014 struct sk_buff *skb;
6016 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6017 if (!skb)
6018 return ERR_PTR(-ENOMEM);
6020 cmd = (struct wmi_vdev_spectral_conf_cmd *)skb->data;
6021 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6022 cmd->scan_count = __cpu_to_le32(arg->scan_count);
6023 cmd->scan_period = __cpu_to_le32(arg->scan_period);
6024 cmd->scan_priority = __cpu_to_le32(arg->scan_priority);
6025 cmd->scan_fft_size = __cpu_to_le32(arg->scan_fft_size);
6026 cmd->scan_gc_ena = __cpu_to_le32(arg->scan_gc_ena);
6027 cmd->scan_restart_ena = __cpu_to_le32(arg->scan_restart_ena);
6028 cmd->scan_noise_floor_ref = __cpu_to_le32(arg->scan_noise_floor_ref);
6029 cmd->scan_init_delay = __cpu_to_le32(arg->scan_init_delay);
6030 cmd->scan_nb_tone_thr = __cpu_to_le32(arg->scan_nb_tone_thr);
6031 cmd->scan_str_bin_thr = __cpu_to_le32(arg->scan_str_bin_thr);
6032 cmd->scan_wb_rpt_mode = __cpu_to_le32(arg->scan_wb_rpt_mode);
6033 cmd->scan_rssi_rpt_mode = __cpu_to_le32(arg->scan_rssi_rpt_mode);
6034 cmd->scan_rssi_thr = __cpu_to_le32(arg->scan_rssi_thr);
6035 cmd->scan_pwr_format = __cpu_to_le32(arg->scan_pwr_format);
6036 cmd->scan_rpt_mode = __cpu_to_le32(arg->scan_rpt_mode);
6037 cmd->scan_bin_scale = __cpu_to_le32(arg->scan_bin_scale);
6038 cmd->scan_dbm_adj = __cpu_to_le32(arg->scan_dbm_adj);
6039 cmd->scan_chn_mask = __cpu_to_le32(arg->scan_chn_mask);
6041 return skb;
6044 static struct sk_buff *
6045 ath10k_wmi_op_gen_vdev_spectral_enable(struct ath10k *ar, u32 vdev_id,
6046 u32 trigger, u32 enable)
6048 struct wmi_vdev_spectral_enable_cmd *cmd;
6049 struct sk_buff *skb;
6051 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6052 if (!skb)
6053 return ERR_PTR(-ENOMEM);
6055 cmd = (struct wmi_vdev_spectral_enable_cmd *)skb->data;
6056 cmd->vdev_id = __cpu_to_le32(vdev_id);
6057 cmd->trigger_cmd = __cpu_to_le32(trigger);
6058 cmd->enable_cmd = __cpu_to_le32(enable);
6060 return skb;
6063 static struct sk_buff *
6064 ath10k_wmi_op_gen_peer_create(struct ath10k *ar, u32 vdev_id,
6065 const u8 peer_addr[ETH_ALEN],
6066 enum wmi_peer_type peer_type)
6068 struct wmi_peer_create_cmd *cmd;
6069 struct sk_buff *skb;
6071 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6072 if (!skb)
6073 return ERR_PTR(-ENOMEM);
6075 cmd = (struct wmi_peer_create_cmd *)skb->data;
6076 cmd->vdev_id = __cpu_to_le32(vdev_id);
6077 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6079 ath10k_dbg(ar, ATH10K_DBG_WMI,
6080 "wmi peer create vdev_id %d peer_addr %pM\n",
6081 vdev_id, peer_addr);
6082 return skb;
6085 static struct sk_buff *
6086 ath10k_wmi_op_gen_peer_delete(struct ath10k *ar, u32 vdev_id,
6087 const u8 peer_addr[ETH_ALEN])
6089 struct wmi_peer_delete_cmd *cmd;
6090 struct sk_buff *skb;
6092 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6093 if (!skb)
6094 return ERR_PTR(-ENOMEM);
6096 cmd = (struct wmi_peer_delete_cmd *)skb->data;
6097 cmd->vdev_id = __cpu_to_le32(vdev_id);
6098 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6100 ath10k_dbg(ar, ATH10K_DBG_WMI,
6101 "wmi peer delete vdev_id %d peer_addr %pM\n",
6102 vdev_id, peer_addr);
6103 return skb;
6106 static struct sk_buff *
6107 ath10k_wmi_op_gen_peer_flush(struct ath10k *ar, u32 vdev_id,
6108 const u8 peer_addr[ETH_ALEN], u32 tid_bitmap)
6110 struct wmi_peer_flush_tids_cmd *cmd;
6111 struct sk_buff *skb;
6113 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6114 if (!skb)
6115 return ERR_PTR(-ENOMEM);
6117 cmd = (struct wmi_peer_flush_tids_cmd *)skb->data;
6118 cmd->vdev_id = __cpu_to_le32(vdev_id);
6119 cmd->peer_tid_bitmap = __cpu_to_le32(tid_bitmap);
6120 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6122 ath10k_dbg(ar, ATH10K_DBG_WMI,
6123 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
6124 vdev_id, peer_addr, tid_bitmap);
6125 return skb;
6128 static struct sk_buff *
6129 ath10k_wmi_op_gen_peer_set_param(struct ath10k *ar, u32 vdev_id,
6130 const u8 *peer_addr,
6131 enum wmi_peer_param param_id,
6132 u32 param_value)
6134 struct wmi_peer_set_param_cmd *cmd;
6135 struct sk_buff *skb;
6137 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6138 if (!skb)
6139 return ERR_PTR(-ENOMEM);
6141 cmd = (struct wmi_peer_set_param_cmd *)skb->data;
6142 cmd->vdev_id = __cpu_to_le32(vdev_id);
6143 cmd->param_id = __cpu_to_le32(param_id);
6144 cmd->param_value = __cpu_to_le32(param_value);
6145 ether_addr_copy(cmd->peer_macaddr.addr, peer_addr);
6147 ath10k_dbg(ar, ATH10K_DBG_WMI,
6148 "wmi vdev %d peer 0x%pM set param %d value %d\n",
6149 vdev_id, peer_addr, param_id, param_value);
6150 return skb;
6153 static struct sk_buff *
6154 ath10k_wmi_op_gen_set_psmode(struct ath10k *ar, u32 vdev_id,
6155 enum wmi_sta_ps_mode psmode)
6157 struct wmi_sta_powersave_mode_cmd *cmd;
6158 struct sk_buff *skb;
6160 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6161 if (!skb)
6162 return ERR_PTR(-ENOMEM);
6164 cmd = (struct wmi_sta_powersave_mode_cmd *)skb->data;
6165 cmd->vdev_id = __cpu_to_le32(vdev_id);
6166 cmd->sta_ps_mode = __cpu_to_le32(psmode);
6168 ath10k_dbg(ar, ATH10K_DBG_WMI,
6169 "wmi set powersave id 0x%x mode %d\n",
6170 vdev_id, psmode);
6171 return skb;
6174 static struct sk_buff *
6175 ath10k_wmi_op_gen_set_sta_ps(struct ath10k *ar, u32 vdev_id,
6176 enum wmi_sta_powersave_param param_id,
6177 u32 value)
6179 struct wmi_sta_powersave_param_cmd *cmd;
6180 struct sk_buff *skb;
6182 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6183 if (!skb)
6184 return ERR_PTR(-ENOMEM);
6186 cmd = (struct wmi_sta_powersave_param_cmd *)skb->data;
6187 cmd->vdev_id = __cpu_to_le32(vdev_id);
6188 cmd->param_id = __cpu_to_le32(param_id);
6189 cmd->param_value = __cpu_to_le32(value);
6191 ath10k_dbg(ar, ATH10K_DBG_WMI,
6192 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
6193 vdev_id, param_id, value);
6194 return skb;
6197 static struct sk_buff *
6198 ath10k_wmi_op_gen_set_ap_ps(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6199 enum wmi_ap_ps_peer_param param_id, u32 value)
6201 struct wmi_ap_ps_peer_cmd *cmd;
6202 struct sk_buff *skb;
6204 if (!mac)
6205 return ERR_PTR(-EINVAL);
6207 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6208 if (!skb)
6209 return ERR_PTR(-ENOMEM);
6211 cmd = (struct wmi_ap_ps_peer_cmd *)skb->data;
6212 cmd->vdev_id = __cpu_to_le32(vdev_id);
6213 cmd->param_id = __cpu_to_le32(param_id);
6214 cmd->param_value = __cpu_to_le32(value);
6215 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6217 ath10k_dbg(ar, ATH10K_DBG_WMI,
6218 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
6219 vdev_id, param_id, value, mac);
6220 return skb;
6223 static struct sk_buff *
6224 ath10k_wmi_op_gen_scan_chan_list(struct ath10k *ar,
6225 const struct wmi_scan_chan_list_arg *arg)
6227 struct wmi_scan_chan_list_cmd *cmd;
6228 struct sk_buff *skb;
6229 struct wmi_channel_arg *ch;
6230 struct wmi_channel *ci;
6231 int len;
6232 int i;
6234 len = sizeof(*cmd) + arg->n_channels * sizeof(struct wmi_channel);
6236 skb = ath10k_wmi_alloc_skb(ar, len);
6237 if (!skb)
6238 return ERR_PTR(-EINVAL);
6240 cmd = (struct wmi_scan_chan_list_cmd *)skb->data;
6241 cmd->num_scan_chans = __cpu_to_le32(arg->n_channels);
6243 for (i = 0; i < arg->n_channels; i++) {
6244 ch = &arg->channels[i];
6245 ci = &cmd->chan_info[i];
6247 ath10k_wmi_put_wmi_channel(ci, ch);
6250 return skb;
6253 static void
6254 ath10k_wmi_peer_assoc_fill(struct ath10k *ar, void *buf,
6255 const struct wmi_peer_assoc_complete_arg *arg)
6257 struct wmi_common_peer_assoc_complete_cmd *cmd = buf;
6259 cmd->vdev_id = __cpu_to_le32(arg->vdev_id);
6260 cmd->peer_new_assoc = __cpu_to_le32(arg->peer_reassoc ? 0 : 1);
6261 cmd->peer_associd = __cpu_to_le32(arg->peer_aid);
6262 cmd->peer_flags = __cpu_to_le32(arg->peer_flags);
6263 cmd->peer_caps = __cpu_to_le32(arg->peer_caps);
6264 cmd->peer_listen_intval = __cpu_to_le32(arg->peer_listen_intval);
6265 cmd->peer_ht_caps = __cpu_to_le32(arg->peer_ht_caps);
6266 cmd->peer_max_mpdu = __cpu_to_le32(arg->peer_max_mpdu);
6267 cmd->peer_mpdu_density = __cpu_to_le32(arg->peer_mpdu_density);
6268 cmd->peer_rate_caps = __cpu_to_le32(arg->peer_rate_caps);
6269 cmd->peer_nss = __cpu_to_le32(arg->peer_num_spatial_streams);
6270 cmd->peer_vht_caps = __cpu_to_le32(arg->peer_vht_caps);
6271 cmd->peer_phymode = __cpu_to_le32(arg->peer_phymode);
6273 ether_addr_copy(cmd->peer_macaddr.addr, arg->addr);
6275 cmd->peer_legacy_rates.num_rates =
6276 __cpu_to_le32(arg->peer_legacy_rates.num_rates);
6277 memcpy(cmd->peer_legacy_rates.rates, arg->peer_legacy_rates.rates,
6278 arg->peer_legacy_rates.num_rates);
6280 cmd->peer_ht_rates.num_rates =
6281 __cpu_to_le32(arg->peer_ht_rates.num_rates);
6282 memcpy(cmd->peer_ht_rates.rates, arg->peer_ht_rates.rates,
6283 arg->peer_ht_rates.num_rates);
6285 cmd->peer_vht_rates.rx_max_rate =
6286 __cpu_to_le32(arg->peer_vht_rates.rx_max_rate);
6287 cmd->peer_vht_rates.rx_mcs_set =
6288 __cpu_to_le32(arg->peer_vht_rates.rx_mcs_set);
6289 cmd->peer_vht_rates.tx_max_rate =
6290 __cpu_to_le32(arg->peer_vht_rates.tx_max_rate);
6291 cmd->peer_vht_rates.tx_mcs_set =
6292 __cpu_to_le32(arg->peer_vht_rates.tx_mcs_set);
6295 static void
6296 ath10k_wmi_peer_assoc_fill_main(struct ath10k *ar, void *buf,
6297 const struct wmi_peer_assoc_complete_arg *arg)
6299 struct wmi_main_peer_assoc_complete_cmd *cmd = buf;
6301 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6302 memset(cmd->peer_ht_info, 0, sizeof(cmd->peer_ht_info));
6305 static void
6306 ath10k_wmi_peer_assoc_fill_10_1(struct ath10k *ar, void *buf,
6307 const struct wmi_peer_assoc_complete_arg *arg)
6309 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6312 static void
6313 ath10k_wmi_peer_assoc_fill_10_2(struct ath10k *ar, void *buf,
6314 const struct wmi_peer_assoc_complete_arg *arg)
6316 struct wmi_10_2_peer_assoc_complete_cmd *cmd = buf;
6317 int max_mcs, max_nss;
6318 u32 info0;
6320 /* TODO: Is using max values okay with firmware? */
6321 max_mcs = 0xf;
6322 max_nss = 0xf;
6324 info0 = SM(max_mcs, WMI_PEER_ASSOC_INFO0_MAX_MCS_IDX) |
6325 SM(max_nss, WMI_PEER_ASSOC_INFO0_MAX_NSS);
6327 ath10k_wmi_peer_assoc_fill(ar, buf, arg);
6328 cmd->info0 = __cpu_to_le32(info0);
6331 static int
6332 ath10k_wmi_peer_assoc_check_arg(const struct wmi_peer_assoc_complete_arg *arg)
6334 if (arg->peer_mpdu_density > 16)
6335 return -EINVAL;
6336 if (arg->peer_legacy_rates.num_rates > MAX_SUPPORTED_RATES)
6337 return -EINVAL;
6338 if (arg->peer_ht_rates.num_rates > MAX_SUPPORTED_RATES)
6339 return -EINVAL;
6341 return 0;
6344 static struct sk_buff *
6345 ath10k_wmi_op_gen_peer_assoc(struct ath10k *ar,
6346 const struct wmi_peer_assoc_complete_arg *arg)
6348 size_t len = sizeof(struct wmi_main_peer_assoc_complete_cmd);
6349 struct sk_buff *skb;
6350 int ret;
6352 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6353 if (ret)
6354 return ERR_PTR(ret);
6356 skb = ath10k_wmi_alloc_skb(ar, len);
6357 if (!skb)
6358 return ERR_PTR(-ENOMEM);
6360 ath10k_wmi_peer_assoc_fill_main(ar, skb->data, arg);
6362 ath10k_dbg(ar, ATH10K_DBG_WMI,
6363 "wmi peer assoc vdev %d addr %pM (%s)\n",
6364 arg->vdev_id, arg->addr,
6365 arg->peer_reassoc ? "reassociate" : "new");
6366 return skb;
6369 static struct sk_buff *
6370 ath10k_wmi_10_1_op_gen_peer_assoc(struct ath10k *ar,
6371 const struct wmi_peer_assoc_complete_arg *arg)
6373 size_t len = sizeof(struct wmi_10_1_peer_assoc_complete_cmd);
6374 struct sk_buff *skb;
6375 int ret;
6377 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6378 if (ret)
6379 return ERR_PTR(ret);
6381 skb = ath10k_wmi_alloc_skb(ar, len);
6382 if (!skb)
6383 return ERR_PTR(-ENOMEM);
6385 ath10k_wmi_peer_assoc_fill_10_1(ar, skb->data, arg);
6387 ath10k_dbg(ar, ATH10K_DBG_WMI,
6388 "wmi peer assoc vdev %d addr %pM (%s)\n",
6389 arg->vdev_id, arg->addr,
6390 arg->peer_reassoc ? "reassociate" : "new");
6391 return skb;
6394 static struct sk_buff *
6395 ath10k_wmi_10_2_op_gen_peer_assoc(struct ath10k *ar,
6396 const struct wmi_peer_assoc_complete_arg *arg)
6398 size_t len = sizeof(struct wmi_10_2_peer_assoc_complete_cmd);
6399 struct sk_buff *skb;
6400 int ret;
6402 ret = ath10k_wmi_peer_assoc_check_arg(arg);
6403 if (ret)
6404 return ERR_PTR(ret);
6406 skb = ath10k_wmi_alloc_skb(ar, len);
6407 if (!skb)
6408 return ERR_PTR(-ENOMEM);
6410 ath10k_wmi_peer_assoc_fill_10_2(ar, skb->data, arg);
6412 ath10k_dbg(ar, ATH10K_DBG_WMI,
6413 "wmi peer assoc vdev %d addr %pM (%s)\n",
6414 arg->vdev_id, arg->addr,
6415 arg->peer_reassoc ? "reassociate" : "new");
6416 return skb;
6419 static struct sk_buff *
6420 ath10k_wmi_10_2_op_gen_pdev_get_temperature(struct ath10k *ar)
6422 struct sk_buff *skb;
6424 skb = ath10k_wmi_alloc_skb(ar, 0);
6425 if (!skb)
6426 return ERR_PTR(-ENOMEM);
6428 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev get temperature\n");
6429 return skb;
6432 /* This function assumes the beacon is already DMA mapped */
6433 static struct sk_buff *
6434 ath10k_wmi_op_gen_beacon_dma(struct ath10k *ar, u32 vdev_id, const void *bcn,
6435 size_t bcn_len, u32 bcn_paddr, bool dtim_zero,
6436 bool deliver_cab)
6438 struct wmi_bcn_tx_ref_cmd *cmd;
6439 struct sk_buff *skb;
6440 struct ieee80211_hdr *hdr;
6441 u16 fc;
6443 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6444 if (!skb)
6445 return ERR_PTR(-ENOMEM);
6447 hdr = (struct ieee80211_hdr *)bcn;
6448 fc = le16_to_cpu(hdr->frame_control);
6450 cmd = (struct wmi_bcn_tx_ref_cmd *)skb->data;
6451 cmd->vdev_id = __cpu_to_le32(vdev_id);
6452 cmd->data_len = __cpu_to_le32(bcn_len);
6453 cmd->data_ptr = __cpu_to_le32(bcn_paddr);
6454 cmd->msdu_id = 0;
6455 cmd->frame_control = __cpu_to_le32(fc);
6456 cmd->flags = 0;
6457 cmd->antenna_mask = __cpu_to_le32(WMI_BCN_TX_REF_DEF_ANTENNA);
6459 if (dtim_zero)
6460 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DTIM_ZERO);
6462 if (deliver_cab)
6463 cmd->flags |= __cpu_to_le32(WMI_BCN_TX_REF_FLAG_DELIVER_CAB);
6465 return skb;
6468 void ath10k_wmi_set_wmm_param(struct wmi_wmm_params *params,
6469 const struct wmi_wmm_params_arg *arg)
6471 params->cwmin = __cpu_to_le32(arg->cwmin);
6472 params->cwmax = __cpu_to_le32(arg->cwmax);
6473 params->aifs = __cpu_to_le32(arg->aifs);
6474 params->txop = __cpu_to_le32(arg->txop);
6475 params->acm = __cpu_to_le32(arg->acm);
6476 params->no_ack = __cpu_to_le32(arg->no_ack);
6479 static struct sk_buff *
6480 ath10k_wmi_op_gen_pdev_set_wmm(struct ath10k *ar,
6481 const struct wmi_wmm_params_all_arg *arg)
6483 struct wmi_pdev_set_wmm_params *cmd;
6484 struct sk_buff *skb;
6486 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6487 if (!skb)
6488 return ERR_PTR(-ENOMEM);
6490 cmd = (struct wmi_pdev_set_wmm_params *)skb->data;
6491 ath10k_wmi_set_wmm_param(&cmd->ac_be, &arg->ac_be);
6492 ath10k_wmi_set_wmm_param(&cmd->ac_bk, &arg->ac_bk);
6493 ath10k_wmi_set_wmm_param(&cmd->ac_vi, &arg->ac_vi);
6494 ath10k_wmi_set_wmm_param(&cmd->ac_vo, &arg->ac_vo);
6496 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi pdev set wmm params\n");
6497 return skb;
6500 static struct sk_buff *
6501 ath10k_wmi_op_gen_request_stats(struct ath10k *ar, u32 stats_mask)
6503 struct wmi_request_stats_cmd *cmd;
6504 struct sk_buff *skb;
6506 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6507 if (!skb)
6508 return ERR_PTR(-ENOMEM);
6510 cmd = (struct wmi_request_stats_cmd *)skb->data;
6511 cmd->stats_id = __cpu_to_le32(stats_mask);
6513 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi request stats 0x%08x\n",
6514 stats_mask);
6515 return skb;
6518 static struct sk_buff *
6519 ath10k_wmi_op_gen_force_fw_hang(struct ath10k *ar,
6520 enum wmi_force_fw_hang_type type, u32 delay_ms)
6522 struct wmi_force_fw_hang_cmd *cmd;
6523 struct sk_buff *skb;
6525 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6526 if (!skb)
6527 return ERR_PTR(-ENOMEM);
6529 cmd = (struct wmi_force_fw_hang_cmd *)skb->data;
6530 cmd->type = __cpu_to_le32(type);
6531 cmd->delay_ms = __cpu_to_le32(delay_ms);
6533 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi force fw hang %d delay %d\n",
6534 type, delay_ms);
6535 return skb;
6538 static struct sk_buff *
6539 ath10k_wmi_op_gen_dbglog_cfg(struct ath10k *ar, u32 module_enable,
6540 u32 log_level)
6542 struct wmi_dbglog_cfg_cmd *cmd;
6543 struct sk_buff *skb;
6544 u32 cfg;
6546 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6547 if (!skb)
6548 return ERR_PTR(-ENOMEM);
6550 cmd = (struct wmi_dbglog_cfg_cmd *)skb->data;
6552 if (module_enable) {
6553 cfg = SM(log_level,
6554 ATH10K_DBGLOG_CFG_LOG_LVL);
6555 } else {
6556 /* set back defaults, all modules with WARN level */
6557 cfg = SM(ATH10K_DBGLOG_LEVEL_WARN,
6558 ATH10K_DBGLOG_CFG_LOG_LVL);
6559 module_enable = ~0;
6562 cmd->module_enable = __cpu_to_le32(module_enable);
6563 cmd->module_valid = __cpu_to_le32(~0);
6564 cmd->config_enable = __cpu_to_le32(cfg);
6565 cmd->config_valid = __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK);
6567 ath10k_dbg(ar, ATH10K_DBG_WMI,
6568 "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
6569 __le32_to_cpu(cmd->module_enable),
6570 __le32_to_cpu(cmd->module_valid),
6571 __le32_to_cpu(cmd->config_enable),
6572 __le32_to_cpu(cmd->config_valid));
6573 return skb;
6576 static struct sk_buff *
6577 ath10k_wmi_op_gen_pktlog_enable(struct ath10k *ar, u32 ev_bitmap)
6579 struct wmi_pdev_pktlog_enable_cmd *cmd;
6580 struct sk_buff *skb;
6582 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6583 if (!skb)
6584 return ERR_PTR(-ENOMEM);
6586 ev_bitmap &= ATH10K_PKTLOG_ANY;
6588 cmd = (struct wmi_pdev_pktlog_enable_cmd *)skb->data;
6589 cmd->ev_bitmap = __cpu_to_le32(ev_bitmap);
6591 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi enable pktlog filter 0x%08x\n",
6592 ev_bitmap);
6593 return skb;
6596 static struct sk_buff *
6597 ath10k_wmi_op_gen_pktlog_disable(struct ath10k *ar)
6599 struct sk_buff *skb;
6601 skb = ath10k_wmi_alloc_skb(ar, 0);
6602 if (!skb)
6603 return ERR_PTR(-ENOMEM);
6605 ath10k_dbg(ar, ATH10K_DBG_WMI, "wmi disable pktlog\n");
6606 return skb;
6609 static struct sk_buff *
6610 ath10k_wmi_op_gen_pdev_set_quiet_mode(struct ath10k *ar, u32 period,
6611 u32 duration, u32 next_offset,
6612 u32 enabled)
6614 struct wmi_pdev_set_quiet_cmd *cmd;
6615 struct sk_buff *skb;
6617 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6618 if (!skb)
6619 return ERR_PTR(-ENOMEM);
6621 cmd = (struct wmi_pdev_set_quiet_cmd *)skb->data;
6622 cmd->period = __cpu_to_le32(period);
6623 cmd->duration = __cpu_to_le32(duration);
6624 cmd->next_start = __cpu_to_le32(next_offset);
6625 cmd->enabled = __cpu_to_le32(enabled);
6627 ath10k_dbg(ar, ATH10K_DBG_WMI,
6628 "wmi quiet param: period %u duration %u enabled %d\n",
6629 period, duration, enabled);
6630 return skb;
6633 static struct sk_buff *
6634 ath10k_wmi_op_gen_addba_clear_resp(struct ath10k *ar, u32 vdev_id,
6635 const u8 *mac)
6637 struct wmi_addba_clear_resp_cmd *cmd;
6638 struct sk_buff *skb;
6640 if (!mac)
6641 return ERR_PTR(-EINVAL);
6643 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6644 if (!skb)
6645 return ERR_PTR(-ENOMEM);
6647 cmd = (struct wmi_addba_clear_resp_cmd *)skb->data;
6648 cmd->vdev_id = __cpu_to_le32(vdev_id);
6649 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6651 ath10k_dbg(ar, ATH10K_DBG_WMI,
6652 "wmi addba clear resp vdev_id 0x%X mac_addr %pM\n",
6653 vdev_id, mac);
6654 return skb;
6657 static struct sk_buff *
6658 ath10k_wmi_op_gen_addba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6659 u32 tid, u32 buf_size)
6661 struct wmi_addba_send_cmd *cmd;
6662 struct sk_buff *skb;
6664 if (!mac)
6665 return ERR_PTR(-EINVAL);
6667 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6668 if (!skb)
6669 return ERR_PTR(-ENOMEM);
6671 cmd = (struct wmi_addba_send_cmd *)skb->data;
6672 cmd->vdev_id = __cpu_to_le32(vdev_id);
6673 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6674 cmd->tid = __cpu_to_le32(tid);
6675 cmd->buffersize = __cpu_to_le32(buf_size);
6677 ath10k_dbg(ar, ATH10K_DBG_WMI,
6678 "wmi addba send vdev_id 0x%X mac_addr %pM tid %u bufsize %u\n",
6679 vdev_id, mac, tid, buf_size);
6680 return skb;
6683 static struct sk_buff *
6684 ath10k_wmi_op_gen_addba_set_resp(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6685 u32 tid, u32 status)
6687 struct wmi_addba_setresponse_cmd *cmd;
6688 struct sk_buff *skb;
6690 if (!mac)
6691 return ERR_PTR(-EINVAL);
6693 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6694 if (!skb)
6695 return ERR_PTR(-ENOMEM);
6697 cmd = (struct wmi_addba_setresponse_cmd *)skb->data;
6698 cmd->vdev_id = __cpu_to_le32(vdev_id);
6699 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6700 cmd->tid = __cpu_to_le32(tid);
6701 cmd->statuscode = __cpu_to_le32(status);
6703 ath10k_dbg(ar, ATH10K_DBG_WMI,
6704 "wmi addba set resp vdev_id 0x%X mac_addr %pM tid %u status %u\n",
6705 vdev_id, mac, tid, status);
6706 return skb;
6709 static struct sk_buff *
6710 ath10k_wmi_op_gen_delba_send(struct ath10k *ar, u32 vdev_id, const u8 *mac,
6711 u32 tid, u32 initiator, u32 reason)
6713 struct wmi_delba_send_cmd *cmd;
6714 struct sk_buff *skb;
6716 if (!mac)
6717 return ERR_PTR(-EINVAL);
6719 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6720 if (!skb)
6721 return ERR_PTR(-ENOMEM);
6723 cmd = (struct wmi_delba_send_cmd *)skb->data;
6724 cmd->vdev_id = __cpu_to_le32(vdev_id);
6725 ether_addr_copy(cmd->peer_macaddr.addr, mac);
6726 cmd->tid = __cpu_to_le32(tid);
6727 cmd->initiator = __cpu_to_le32(initiator);
6728 cmd->reasoncode = __cpu_to_le32(reason);
6730 ath10k_dbg(ar, ATH10K_DBG_WMI,
6731 "wmi delba send vdev_id 0x%X mac_addr %pM tid %u initiator %u reason %u\n",
6732 vdev_id, mac, tid, initiator, reason);
6733 return skb;
6736 static struct sk_buff *
6737 ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config(struct ath10k *ar, u32 param)
6739 struct wmi_pdev_get_tpc_config_cmd *cmd;
6740 struct sk_buff *skb;
6742 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
6743 if (!skb)
6744 return ERR_PTR(-ENOMEM);
6746 cmd = (struct wmi_pdev_get_tpc_config_cmd *)skb->data;
6747 cmd->param = __cpu_to_le32(param);
6749 ath10k_dbg(ar, ATH10K_DBG_WMI,
6750 "wmi pdev get tcp config param:%d\n", param);
6751 return skb;
6754 size_t ath10k_wmi_fw_stats_num_peers(struct list_head *head)
6756 struct ath10k_fw_stats_peer *i;
6757 size_t num = 0;
6759 list_for_each_entry(i, head, list)
6760 ++num;
6762 return num;
6765 size_t ath10k_wmi_fw_stats_num_vdevs(struct list_head *head)
6767 struct ath10k_fw_stats_vdev *i;
6768 size_t num = 0;
6770 list_for_each_entry(i, head, list)
6771 ++num;
6773 return num;
6776 static void
6777 ath10k_wmi_fw_pdev_base_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6778 char *buf, u32 *length)
6780 u32 len = *length;
6781 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6783 len += scnprintf(buf + len, buf_len - len, "\n");
6784 len += scnprintf(buf + len, buf_len - len, "%30s\n",
6785 "ath10k PDEV stats");
6786 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6787 "=================");
6789 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6790 "Channel noise floor", pdev->ch_noise_floor);
6791 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6792 "Channel TX power", pdev->chan_tx_power);
6793 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6794 "TX frame count", pdev->tx_frame_count);
6795 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6796 "RX frame count", pdev->rx_frame_count);
6797 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6798 "RX clear count", pdev->rx_clear_count);
6799 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6800 "Cycle count", pdev->cycle_count);
6801 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6802 "PHY error count", pdev->phy_err_count);
6804 *length = len;
6807 static void
6808 ath10k_wmi_fw_pdev_extra_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6809 char *buf, u32 *length)
6811 u32 len = *length;
6812 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6814 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6815 "RTS bad count", pdev->rts_bad);
6816 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6817 "RTS good count", pdev->rts_good);
6818 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6819 "FCS bad count", pdev->fcs_bad);
6820 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6821 "No beacon count", pdev->no_beacons);
6822 len += scnprintf(buf + len, buf_len - len, "%30s %10u\n",
6823 "MIB int count", pdev->mib_int_count);
6825 len += scnprintf(buf + len, buf_len - len, "\n");
6826 *length = len;
6829 static void
6830 ath10k_wmi_fw_pdev_tx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6831 char *buf, u32 *length)
6833 u32 len = *length;
6834 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6836 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
6837 "ath10k PDEV TX stats");
6838 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6839 "=================");
6841 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6842 "HTT cookies queued", pdev->comp_queued);
6843 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6844 "HTT cookies disp.", pdev->comp_delivered);
6845 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6846 "MSDU queued", pdev->msdu_enqued);
6847 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6848 "MPDU queued", pdev->mpdu_enqued);
6849 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6850 "MSDUs dropped", pdev->wmm_drop);
6851 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6852 "Local enqued", pdev->local_enqued);
6853 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6854 "Local freed", pdev->local_freed);
6855 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6856 "HW queued", pdev->hw_queued);
6857 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6858 "PPDUs reaped", pdev->hw_reaped);
6859 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6860 "Num underruns", pdev->underrun);
6861 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6862 "PPDUs cleaned", pdev->tx_abort);
6863 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6864 "MPDUs requed", pdev->mpdus_requed);
6865 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6866 "Excessive retries", pdev->tx_ko);
6867 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6868 "HW rate", pdev->data_rc);
6869 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6870 "Sched self tiggers", pdev->self_triggers);
6871 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6872 "Dropped due to SW retries",
6873 pdev->sw_retry_failure);
6874 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6875 "Illegal rate phy errors",
6876 pdev->illgl_rate_phy_err);
6877 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6878 "Pdev continuous xretry", pdev->pdev_cont_xretry);
6879 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6880 "TX timeout", pdev->pdev_tx_timeout);
6881 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6882 "PDEV resets", pdev->pdev_resets);
6883 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6884 "PHY underrun", pdev->phy_underrun);
6885 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6886 "MPDU is more than txop limit", pdev->txop_ovf);
6887 *length = len;
6890 static void
6891 ath10k_wmi_fw_pdev_rx_stats_fill(const struct ath10k_fw_stats_pdev *pdev,
6892 char *buf, u32 *length)
6894 u32 len = *length;
6895 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6897 len += scnprintf(buf + len, buf_len - len, "\n%30s\n",
6898 "ath10k PDEV RX stats");
6899 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
6900 "=================");
6902 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6903 "Mid PPDU route change",
6904 pdev->mid_ppdu_route_change);
6905 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6906 "Tot. number of statuses", pdev->status_rcvd);
6907 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6908 "Extra frags on rings 0", pdev->r0_frags);
6909 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6910 "Extra frags on rings 1", pdev->r1_frags);
6911 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6912 "Extra frags on rings 2", pdev->r2_frags);
6913 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6914 "Extra frags on rings 3", pdev->r3_frags);
6915 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6916 "MSDUs delivered to HTT", pdev->htt_msdus);
6917 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6918 "MPDUs delivered to HTT", pdev->htt_mpdus);
6919 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6920 "MSDUs delivered to stack", pdev->loc_msdus);
6921 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6922 "MPDUs delivered to stack", pdev->loc_mpdus);
6923 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6924 "Oversized AMSUs", pdev->oversize_amsdu);
6925 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6926 "PHY errors", pdev->phy_errs);
6927 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6928 "PHY errors drops", pdev->phy_err_drop);
6929 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
6930 "MPDU errors (FCS, MIC, ENC)", pdev->mpdu_errs);
6931 *length = len;
6934 static void
6935 ath10k_wmi_fw_vdev_stats_fill(const struct ath10k_fw_stats_vdev *vdev,
6936 char *buf, u32 *length)
6938 u32 len = *length;
6939 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
6940 int i;
6942 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6943 "vdev id", vdev->vdev_id);
6944 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6945 "beacon snr", vdev->beacon_snr);
6946 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6947 "data snr", vdev->data_snr);
6948 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6949 "num rx frames", vdev->num_rx_frames);
6950 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6951 "num rts fail", vdev->num_rts_fail);
6952 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6953 "num rts success", vdev->num_rts_success);
6954 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6955 "num rx err", vdev->num_rx_err);
6956 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6957 "num rx discard", vdev->num_rx_discard);
6958 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
6959 "num tx not acked", vdev->num_tx_not_acked);
6961 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames); i++)
6962 len += scnprintf(buf + len, buf_len - len,
6963 "%25s [%02d] %u\n",
6964 "num tx frames", i,
6965 vdev->num_tx_frames[i]);
6967 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_retries); i++)
6968 len += scnprintf(buf + len, buf_len - len,
6969 "%25s [%02d] %u\n",
6970 "num tx frames retries", i,
6971 vdev->num_tx_frames_retries[i]);
6973 for (i = 0 ; i < ARRAY_SIZE(vdev->num_tx_frames_failures); i++)
6974 len += scnprintf(buf + len, buf_len - len,
6975 "%25s [%02d] %u\n",
6976 "num tx frames failures", i,
6977 vdev->num_tx_frames_failures[i]);
6979 for (i = 0 ; i < ARRAY_SIZE(vdev->tx_rate_history); i++)
6980 len += scnprintf(buf + len, buf_len - len,
6981 "%25s [%02d] 0x%08x\n",
6982 "tx rate history", i,
6983 vdev->tx_rate_history[i]);
6985 for (i = 0 ; i < ARRAY_SIZE(vdev->beacon_rssi_history); i++)
6986 len += scnprintf(buf + len, buf_len - len,
6987 "%25s [%02d] %u\n",
6988 "beacon rssi history", i,
6989 vdev->beacon_rssi_history[i]);
6991 len += scnprintf(buf + len, buf_len - len, "\n");
6992 *length = len;
6995 static void
6996 ath10k_wmi_fw_peer_stats_fill(const struct ath10k_fw_stats_peer *peer,
6997 char *buf, u32 *length)
6999 u32 len = *length;
7000 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7002 len += scnprintf(buf + len, buf_len - len, "%30s %pM\n",
7003 "Peer MAC address", peer->peer_macaddr);
7004 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7005 "Peer RSSI", peer->peer_rssi);
7006 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7007 "Peer TX rate", peer->peer_tx_rate);
7008 len += scnprintf(buf + len, buf_len - len, "%30s %u\n",
7009 "Peer RX rate", peer->peer_rx_rate);
7010 len += scnprintf(buf + len, buf_len - len, "\n");
7011 *length = len;
7014 void ath10k_wmi_main_op_fw_stats_fill(struct ath10k *ar,
7015 struct ath10k_fw_stats *fw_stats,
7016 char *buf)
7018 u32 len = 0;
7019 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7020 const struct ath10k_fw_stats_pdev *pdev;
7021 const struct ath10k_fw_stats_vdev *vdev;
7022 const struct ath10k_fw_stats_peer *peer;
7023 size_t num_peers;
7024 size_t num_vdevs;
7026 spin_lock_bh(&ar->data_lock);
7028 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7029 struct ath10k_fw_stats_pdev, list);
7030 if (!pdev) {
7031 ath10k_warn(ar, "failed to get pdev stats\n");
7032 goto unlock;
7035 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7036 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7038 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7039 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7040 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7042 len += scnprintf(buf + len, buf_len - len, "\n");
7043 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7044 "ath10k VDEV stats", num_vdevs);
7045 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7046 "=================");
7048 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7049 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7052 len += scnprintf(buf + len, buf_len - len, "\n");
7053 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7054 "ath10k PEER stats", num_peers);
7055 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7056 "=================");
7058 list_for_each_entry(peer, &fw_stats->peers, list) {
7059 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7062 unlock:
7063 spin_unlock_bh(&ar->data_lock);
7065 if (len >= buf_len)
7066 buf[len - 1] = 0;
7067 else
7068 buf[len] = 0;
7071 void ath10k_wmi_10x_op_fw_stats_fill(struct ath10k *ar,
7072 struct ath10k_fw_stats *fw_stats,
7073 char *buf)
7075 unsigned int len = 0;
7076 unsigned int buf_len = ATH10K_FW_STATS_BUF_SIZE;
7077 const struct ath10k_fw_stats_pdev *pdev;
7078 const struct ath10k_fw_stats_vdev *vdev;
7079 const struct ath10k_fw_stats_peer *peer;
7080 size_t num_peers;
7081 size_t num_vdevs;
7083 spin_lock_bh(&ar->data_lock);
7085 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7086 struct ath10k_fw_stats_pdev, list);
7087 if (!pdev) {
7088 ath10k_warn(ar, "failed to get pdev stats\n");
7089 goto unlock;
7092 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7093 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7095 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7096 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7097 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7098 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7100 len += scnprintf(buf + len, buf_len - len, "\n");
7101 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7102 "ath10k VDEV stats", num_vdevs);
7103 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7104 "=================");
7106 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7107 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7110 len += scnprintf(buf + len, buf_len - len, "\n");
7111 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7112 "ath10k PEER stats", num_peers);
7113 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7114 "=================");
7116 list_for_each_entry(peer, &fw_stats->peers, list) {
7117 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7120 unlock:
7121 spin_unlock_bh(&ar->data_lock);
7123 if (len >= buf_len)
7124 buf[len - 1] = 0;
7125 else
7126 buf[len] = 0;
7129 static struct sk_buff *
7130 ath10k_wmi_op_gen_pdev_enable_adaptive_cca(struct ath10k *ar, u8 enable,
7131 u32 detect_level, u32 detect_margin)
7133 struct wmi_pdev_set_adaptive_cca_params *cmd;
7134 struct sk_buff *skb;
7136 skb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));
7137 if (!skb)
7138 return ERR_PTR(-ENOMEM);
7140 cmd = (struct wmi_pdev_set_adaptive_cca_params *)skb->data;
7141 cmd->enable = __cpu_to_le32(enable);
7142 cmd->cca_detect_level = __cpu_to_le32(detect_level);
7143 cmd->cca_detect_margin = __cpu_to_le32(detect_margin);
7145 ath10k_dbg(ar, ATH10K_DBG_WMI,
7146 "wmi pdev set adaptive cca params enable:%d detection level:%d detection margin:%d\n",
7147 enable, detect_level, detect_margin);
7148 return skb;
7151 void ath10k_wmi_10_4_op_fw_stats_fill(struct ath10k *ar,
7152 struct ath10k_fw_stats *fw_stats,
7153 char *buf)
7155 u32 len = 0;
7156 u32 buf_len = ATH10K_FW_STATS_BUF_SIZE;
7157 const struct ath10k_fw_stats_pdev *pdev;
7158 const struct ath10k_fw_stats_vdev *vdev;
7159 const struct ath10k_fw_stats_peer *peer;
7160 size_t num_peers;
7161 size_t num_vdevs;
7163 spin_lock_bh(&ar->data_lock);
7165 pdev = list_first_entry_or_null(&fw_stats->pdevs,
7166 struct ath10k_fw_stats_pdev, list);
7167 if (!pdev) {
7168 ath10k_warn(ar, "failed to get pdev stats\n");
7169 goto unlock;
7172 num_peers = ath10k_wmi_fw_stats_num_peers(&fw_stats->peers);
7173 num_vdevs = ath10k_wmi_fw_stats_num_vdevs(&fw_stats->vdevs);
7175 ath10k_wmi_fw_pdev_base_stats_fill(pdev, buf, &len);
7176 ath10k_wmi_fw_pdev_extra_stats_fill(pdev, buf, &len);
7177 ath10k_wmi_fw_pdev_tx_stats_fill(pdev, buf, &len);
7179 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7180 "HW paused", pdev->hw_paused);
7181 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7182 "Seqs posted", pdev->seq_posted);
7183 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7184 "Seqs failed queueing", pdev->seq_failed_queueing);
7185 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7186 "Seqs completed", pdev->seq_completed);
7187 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7188 "Seqs restarted", pdev->seq_restarted);
7189 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7190 "MU Seqs posted", pdev->mu_seq_posted);
7191 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7192 "MPDUs SW flushed", pdev->mpdus_sw_flush);
7193 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7194 "MPDUs HW filtered", pdev->mpdus_hw_filter);
7195 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7196 "MPDUs truncated", pdev->mpdus_truncated);
7197 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7198 "MPDUs receive no ACK", pdev->mpdus_ack_failed);
7199 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7200 "MPDUs expired", pdev->mpdus_expired);
7202 ath10k_wmi_fw_pdev_rx_stats_fill(pdev, buf, &len);
7203 len += scnprintf(buf + len, buf_len - len, "%30s %10d\n",
7204 "Num Rx Overflow errors", pdev->rx_ovfl_errs);
7206 len += scnprintf(buf + len, buf_len - len, "\n");
7207 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7208 "ath10k VDEV stats", num_vdevs);
7209 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7210 "=================");
7212 list_for_each_entry(vdev, &fw_stats->vdevs, list) {
7213 ath10k_wmi_fw_vdev_stats_fill(vdev, buf, &len);
7216 len += scnprintf(buf + len, buf_len - len, "\n");
7217 len += scnprintf(buf + len, buf_len - len, "%30s (%zu)\n",
7218 "ath10k PEER stats", num_peers);
7219 len += scnprintf(buf + len, buf_len - len, "%30s\n\n",
7220 "=================");
7222 list_for_each_entry(peer, &fw_stats->peers, list) {
7223 ath10k_wmi_fw_peer_stats_fill(peer, buf, &len);
7226 unlock:
7227 spin_unlock_bh(&ar->data_lock);
7229 if (len >= buf_len)
7230 buf[len - 1] = 0;
7231 else
7232 buf[len] = 0;
7235 static const struct wmi_ops wmi_ops = {
7236 .rx = ath10k_wmi_op_rx,
7237 .map_svc = wmi_main_svc_map,
7239 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7240 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7241 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7242 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7243 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7244 .pull_swba = ath10k_wmi_op_pull_swba_ev,
7245 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
7246 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7247 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
7248 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7249 .pull_fw_stats = ath10k_wmi_main_op_pull_fw_stats,
7250 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
7252 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7253 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7254 .gen_pdev_set_rd = ath10k_wmi_op_gen_pdev_set_rd,
7255 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7256 .gen_init = ath10k_wmi_op_gen_init,
7257 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7258 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7259 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7260 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7261 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7262 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7263 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7264 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7265 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7266 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7267 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7268 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7269 /* .gen_vdev_wmm_conf not implemented */
7270 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7271 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7272 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7273 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7274 .gen_peer_assoc = ath10k_wmi_op_gen_peer_assoc,
7275 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7276 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7277 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7278 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7279 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7280 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7281 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7282 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7283 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7284 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7285 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7286 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7287 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
7288 /* .gen_pdev_get_temperature not implemented */
7289 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7290 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7291 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7292 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
7293 .fw_stats_fill = ath10k_wmi_main_op_fw_stats_fill,
7294 /* .gen_bcn_tmpl not implemented */
7295 /* .gen_prb_tmpl not implemented */
7296 /* .gen_p2p_go_bcn_ie not implemented */
7297 /* .gen_adaptive_qcs not implemented */
7298 /* .gen_pdev_enable_adaptive_cca not implemented */
7301 static const struct wmi_ops wmi_10_1_ops = {
7302 .rx = ath10k_wmi_10_1_op_rx,
7303 .map_svc = wmi_10x_svc_map,
7304 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
7305 .pull_fw_stats = ath10k_wmi_10x_op_pull_fw_stats,
7306 .gen_init = ath10k_wmi_10_1_op_gen_init,
7307 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7308 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7309 .gen_peer_assoc = ath10k_wmi_10_1_op_gen_peer_assoc,
7310 /* .gen_pdev_get_temperature not implemented */
7312 /* shared with main branch */
7313 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7314 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7315 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7316 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7317 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7318 .pull_swba = ath10k_wmi_op_pull_swba_ev,
7319 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
7320 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7321 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7322 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
7324 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7325 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7326 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7327 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7328 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7329 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7330 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7331 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7332 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7333 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7334 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7335 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7336 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7337 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7338 /* .gen_vdev_wmm_conf not implemented */
7339 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7340 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7341 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7342 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7343 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7344 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7345 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7346 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7347 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7348 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7349 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7350 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7351 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7352 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7353 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7354 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7355 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
7356 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7357 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7358 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7359 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
7360 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
7361 /* .gen_bcn_tmpl not implemented */
7362 /* .gen_prb_tmpl not implemented */
7363 /* .gen_p2p_go_bcn_ie not implemented */
7364 /* .gen_adaptive_qcs not implemented */
7365 /* .gen_pdev_enable_adaptive_cca not implemented */
7368 static const struct wmi_ops wmi_10_2_ops = {
7369 .rx = ath10k_wmi_10_2_op_rx,
7370 .pull_fw_stats = ath10k_wmi_10_2_op_pull_fw_stats,
7371 .gen_init = ath10k_wmi_10_2_op_gen_init,
7372 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
7373 /* .gen_pdev_get_temperature not implemented */
7375 /* shared with 10.1 */
7376 .map_svc = wmi_10x_svc_map,
7377 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
7378 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7379 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7381 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7382 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7383 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7384 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7385 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7386 .pull_swba = ath10k_wmi_op_pull_swba_ev,
7387 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
7388 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7389 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7390 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
7392 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7393 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7394 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7395 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7396 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7397 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7398 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7399 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7400 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7401 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7402 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7403 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7404 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7405 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7406 /* .gen_vdev_wmm_conf not implemented */
7407 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7408 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7409 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7410 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7411 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7412 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7413 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7414 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7415 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7416 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7417 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7418 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7419 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7420 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7421 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7422 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7423 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
7424 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7425 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7426 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7427 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
7428 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
7429 /* .gen_pdev_enable_adaptive_cca not implemented */
7432 static const struct wmi_ops wmi_10_2_4_ops = {
7433 .rx = ath10k_wmi_10_2_op_rx,
7434 .pull_fw_stats = ath10k_wmi_10_2_4_op_pull_fw_stats,
7435 .gen_init = ath10k_wmi_10_2_op_gen_init,
7436 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
7437 .gen_pdev_get_temperature = ath10k_wmi_10_2_op_gen_pdev_get_temperature,
7439 /* shared with 10.1 */
7440 .map_svc = wmi_10x_svc_map,
7441 .pull_svc_rdy = ath10k_wmi_10x_op_pull_svc_rdy_ev,
7442 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7443 .gen_start_scan = ath10k_wmi_10x_op_gen_start_scan,
7445 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7446 .pull_mgmt_rx = ath10k_wmi_op_pull_mgmt_rx_ev,
7447 .pull_ch_info = ath10k_wmi_op_pull_ch_info_ev,
7448 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7449 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7450 .pull_swba = ath10k_wmi_op_pull_swba_ev,
7451 .pull_phyerr_hdr = ath10k_wmi_op_pull_phyerr_ev_hdr,
7452 .pull_phyerr = ath10k_wmi_op_pull_phyerr_ev,
7453 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7454 .pull_roam_ev = ath10k_wmi_op_pull_roam_ev,
7456 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7457 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7458 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7459 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7460 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7461 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7462 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7463 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7464 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7465 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7466 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7467 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7468 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7469 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7470 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7471 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7472 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7473 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7474 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7475 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7476 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7477 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7478 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7479 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7480 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7481 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7482 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7483 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7484 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7485 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7486 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
7487 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7488 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7489 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7490 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
7491 .gen_pdev_get_tpc_config = ath10k_wmi_10_2_4_op_gen_pdev_get_tpc_config,
7492 .fw_stats_fill = ath10k_wmi_10x_op_fw_stats_fill,
7493 .gen_pdev_enable_adaptive_cca =
7494 ath10k_wmi_op_gen_pdev_enable_adaptive_cca,
7495 /* .gen_bcn_tmpl not implemented */
7496 /* .gen_prb_tmpl not implemented */
7497 /* .gen_p2p_go_bcn_ie not implemented */
7498 /* .gen_adaptive_qcs not implemented */
7501 static const struct wmi_ops wmi_10_4_ops = {
7502 .rx = ath10k_wmi_10_4_op_rx,
7503 .map_svc = wmi_10_4_svc_map,
7505 .pull_fw_stats = ath10k_wmi_10_4_op_pull_fw_stats,
7506 .pull_scan = ath10k_wmi_op_pull_scan_ev,
7507 .pull_mgmt_rx = ath10k_wmi_10_4_op_pull_mgmt_rx_ev,
7508 .pull_ch_info = ath10k_wmi_10_4_op_pull_ch_info_ev,
7509 .pull_vdev_start = ath10k_wmi_op_pull_vdev_start_ev,
7510 .pull_peer_kick = ath10k_wmi_op_pull_peer_kick_ev,
7511 .pull_swba = ath10k_wmi_10_4_op_pull_swba_ev,
7512 .pull_phyerr_hdr = ath10k_wmi_10_4_op_pull_phyerr_ev_hdr,
7513 .pull_phyerr = ath10k_wmi_10_4_op_pull_phyerr_ev,
7514 .pull_svc_rdy = ath10k_wmi_main_op_pull_svc_rdy_ev,
7515 .pull_rdy = ath10k_wmi_op_pull_rdy_ev,
7516 .get_txbf_conf_scheme = ath10k_wmi_10_4_txbf_conf_scheme,
7518 .gen_pdev_suspend = ath10k_wmi_op_gen_pdev_suspend,
7519 .gen_pdev_resume = ath10k_wmi_op_gen_pdev_resume,
7520 .gen_pdev_set_rd = ath10k_wmi_10x_op_gen_pdev_set_rd,
7521 .gen_pdev_set_param = ath10k_wmi_op_gen_pdev_set_param,
7522 .gen_init = ath10k_wmi_10_4_op_gen_init,
7523 .gen_start_scan = ath10k_wmi_op_gen_start_scan,
7524 .gen_stop_scan = ath10k_wmi_op_gen_stop_scan,
7525 .gen_vdev_create = ath10k_wmi_op_gen_vdev_create,
7526 .gen_vdev_delete = ath10k_wmi_op_gen_vdev_delete,
7527 .gen_vdev_start = ath10k_wmi_op_gen_vdev_start,
7528 .gen_vdev_stop = ath10k_wmi_op_gen_vdev_stop,
7529 .gen_vdev_up = ath10k_wmi_op_gen_vdev_up,
7530 .gen_vdev_down = ath10k_wmi_op_gen_vdev_down,
7531 .gen_vdev_set_param = ath10k_wmi_op_gen_vdev_set_param,
7532 .gen_vdev_install_key = ath10k_wmi_op_gen_vdev_install_key,
7533 .gen_vdev_spectral_conf = ath10k_wmi_op_gen_vdev_spectral_conf,
7534 .gen_vdev_spectral_enable = ath10k_wmi_op_gen_vdev_spectral_enable,
7535 .gen_peer_create = ath10k_wmi_op_gen_peer_create,
7536 .gen_peer_delete = ath10k_wmi_op_gen_peer_delete,
7537 .gen_peer_flush = ath10k_wmi_op_gen_peer_flush,
7538 .gen_peer_set_param = ath10k_wmi_op_gen_peer_set_param,
7539 .gen_set_psmode = ath10k_wmi_op_gen_set_psmode,
7540 .gen_set_sta_ps = ath10k_wmi_op_gen_set_sta_ps,
7541 .gen_set_ap_ps = ath10k_wmi_op_gen_set_ap_ps,
7542 .gen_scan_chan_list = ath10k_wmi_op_gen_scan_chan_list,
7543 .gen_beacon_dma = ath10k_wmi_op_gen_beacon_dma,
7544 .gen_pdev_set_wmm = ath10k_wmi_op_gen_pdev_set_wmm,
7545 .gen_force_fw_hang = ath10k_wmi_op_gen_force_fw_hang,
7546 .gen_mgmt_tx = ath10k_wmi_op_gen_mgmt_tx,
7547 .gen_dbglog_cfg = ath10k_wmi_op_gen_dbglog_cfg,
7548 .gen_pktlog_enable = ath10k_wmi_op_gen_pktlog_enable,
7549 .gen_pktlog_disable = ath10k_wmi_op_gen_pktlog_disable,
7550 .gen_pdev_set_quiet_mode = ath10k_wmi_op_gen_pdev_set_quiet_mode,
7551 .gen_addba_clear_resp = ath10k_wmi_op_gen_addba_clear_resp,
7552 .gen_addba_send = ath10k_wmi_op_gen_addba_send,
7553 .gen_addba_set_resp = ath10k_wmi_op_gen_addba_set_resp,
7554 .gen_delba_send = ath10k_wmi_op_gen_delba_send,
7555 .fw_stats_fill = ath10k_wmi_10_4_op_fw_stats_fill,
7557 /* shared with 10.2 */
7558 .gen_peer_assoc = ath10k_wmi_10_2_op_gen_peer_assoc,
7559 .gen_request_stats = ath10k_wmi_op_gen_request_stats,
7562 int ath10k_wmi_attach(struct ath10k *ar)
7564 switch (ar->wmi.op_version) {
7565 case ATH10K_FW_WMI_OP_VERSION_10_4:
7566 ar->wmi.ops = &wmi_10_4_ops;
7567 ar->wmi.cmd = &wmi_10_4_cmd_map;
7568 ar->wmi.vdev_param = &wmi_10_4_vdev_param_map;
7569 ar->wmi.pdev_param = &wmi_10_4_pdev_param_map;
7570 break;
7571 case ATH10K_FW_WMI_OP_VERSION_10_2_4:
7572 ar->wmi.cmd = &wmi_10_2_4_cmd_map;
7573 ar->wmi.ops = &wmi_10_2_4_ops;
7574 ar->wmi.vdev_param = &wmi_10_2_4_vdev_param_map;
7575 ar->wmi.pdev_param = &wmi_10_2_4_pdev_param_map;
7576 break;
7577 case ATH10K_FW_WMI_OP_VERSION_10_2:
7578 ar->wmi.cmd = &wmi_10_2_cmd_map;
7579 ar->wmi.ops = &wmi_10_2_ops;
7580 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7581 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
7582 break;
7583 case ATH10K_FW_WMI_OP_VERSION_10_1:
7584 ar->wmi.cmd = &wmi_10x_cmd_map;
7585 ar->wmi.ops = &wmi_10_1_ops;
7586 ar->wmi.vdev_param = &wmi_10x_vdev_param_map;
7587 ar->wmi.pdev_param = &wmi_10x_pdev_param_map;
7588 break;
7589 case ATH10K_FW_WMI_OP_VERSION_MAIN:
7590 ar->wmi.cmd = &wmi_cmd_map;
7591 ar->wmi.ops = &wmi_ops;
7592 ar->wmi.vdev_param = &wmi_vdev_param_map;
7593 ar->wmi.pdev_param = &wmi_pdev_param_map;
7594 break;
7595 case ATH10K_FW_WMI_OP_VERSION_TLV:
7596 ath10k_wmi_tlv_attach(ar);
7597 break;
7598 case ATH10K_FW_WMI_OP_VERSION_UNSET:
7599 case ATH10K_FW_WMI_OP_VERSION_MAX:
7600 ath10k_err(ar, "unsupported WMI op version: %d\n",
7601 ar->wmi.op_version);
7602 return -EINVAL;
7605 init_completion(&ar->wmi.service_ready);
7606 init_completion(&ar->wmi.unified_ready);
7608 INIT_WORK(&ar->svc_rdy_work, ath10k_wmi_event_service_ready_work);
7610 return 0;
7613 void ath10k_wmi_free_host_mem(struct ath10k *ar)
7615 int i;
7617 /* free the host memory chunks requested by firmware */
7618 for (i = 0; i < ar->wmi.num_mem_chunks; i++) {
7619 dma_free_coherent(ar->dev,
7620 ar->wmi.mem_chunks[i].len,
7621 ar->wmi.mem_chunks[i].vaddr,
7622 ar->wmi.mem_chunks[i].paddr);
7625 ar->wmi.num_mem_chunks = 0;
7628 void ath10k_wmi_detach(struct ath10k *ar)
7630 cancel_work_sync(&ar->svc_rdy_work);
7632 if (ar->svc_rdy_skb)
7633 dev_kfree_skb(ar->svc_rdy_skb);