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>
27 /* MAIN WMI cmd track */
28 static struct wmi_cmd_map wmi_cmd_map
= {
29 .init_cmdid
= WMI_INIT_CMDID
,
30 .start_scan_cmdid
= WMI_START_SCAN_CMDID
,
31 .stop_scan_cmdid
= WMI_STOP_SCAN_CMDID
,
32 .scan_chan_list_cmdid
= WMI_SCAN_CHAN_LIST_CMDID
,
33 .scan_sch_prio_tbl_cmdid
= WMI_SCAN_SCH_PRIO_TBL_CMDID
,
34 .pdev_set_regdomain_cmdid
= WMI_PDEV_SET_REGDOMAIN_CMDID
,
35 .pdev_set_channel_cmdid
= WMI_PDEV_SET_CHANNEL_CMDID
,
36 .pdev_set_param_cmdid
= WMI_PDEV_SET_PARAM_CMDID
,
37 .pdev_pktlog_enable_cmdid
= WMI_PDEV_PKTLOG_ENABLE_CMDID
,
38 .pdev_pktlog_disable_cmdid
= WMI_PDEV_PKTLOG_DISABLE_CMDID
,
39 .pdev_set_wmm_params_cmdid
= WMI_PDEV_SET_WMM_PARAMS_CMDID
,
40 .pdev_set_ht_cap_ie_cmdid
= WMI_PDEV_SET_HT_CAP_IE_CMDID
,
41 .pdev_set_vht_cap_ie_cmdid
= WMI_PDEV_SET_VHT_CAP_IE_CMDID
,
42 .pdev_set_dscp_tid_map_cmdid
= WMI_PDEV_SET_DSCP_TID_MAP_CMDID
,
43 .pdev_set_quiet_mode_cmdid
= WMI_PDEV_SET_QUIET_MODE_CMDID
,
44 .pdev_green_ap_ps_enable_cmdid
= WMI_PDEV_GREEN_AP_PS_ENABLE_CMDID
,
45 .pdev_get_tpc_config_cmdid
= WMI_PDEV_GET_TPC_CONFIG_CMDID
,
46 .pdev_set_base_macaddr_cmdid
= WMI_PDEV_SET_BASE_MACADDR_CMDID
,
47 .vdev_create_cmdid
= WMI_VDEV_CREATE_CMDID
,
48 .vdev_delete_cmdid
= WMI_VDEV_DELETE_CMDID
,
49 .vdev_start_request_cmdid
= WMI_VDEV_START_REQUEST_CMDID
,
50 .vdev_restart_request_cmdid
= WMI_VDEV_RESTART_REQUEST_CMDID
,
51 .vdev_up_cmdid
= WMI_VDEV_UP_CMDID
,
52 .vdev_stop_cmdid
= WMI_VDEV_STOP_CMDID
,
53 .vdev_down_cmdid
= WMI_VDEV_DOWN_CMDID
,
54 .vdev_set_param_cmdid
= WMI_VDEV_SET_PARAM_CMDID
,
55 .vdev_install_key_cmdid
= WMI_VDEV_INSTALL_KEY_CMDID
,
56 .peer_create_cmdid
= WMI_PEER_CREATE_CMDID
,
57 .peer_delete_cmdid
= WMI_PEER_DELETE_CMDID
,
58 .peer_flush_tids_cmdid
= WMI_PEER_FLUSH_TIDS_CMDID
,
59 .peer_set_param_cmdid
= WMI_PEER_SET_PARAM_CMDID
,
60 .peer_assoc_cmdid
= WMI_PEER_ASSOC_CMDID
,
61 .peer_add_wds_entry_cmdid
= WMI_PEER_ADD_WDS_ENTRY_CMDID
,
62 .peer_remove_wds_entry_cmdid
= WMI_PEER_REMOVE_WDS_ENTRY_CMDID
,
63 .peer_mcast_group_cmdid
= WMI_PEER_MCAST_GROUP_CMDID
,
64 .bcn_tx_cmdid
= WMI_BCN_TX_CMDID
,
65 .pdev_send_bcn_cmdid
= WMI_PDEV_SEND_BCN_CMDID
,
66 .bcn_tmpl_cmdid
= WMI_BCN_TMPL_CMDID
,
67 .bcn_filter_rx_cmdid
= WMI_BCN_FILTER_RX_CMDID
,
68 .prb_req_filter_rx_cmdid
= WMI_PRB_REQ_FILTER_RX_CMDID
,
69 .mgmt_tx_cmdid
= WMI_MGMT_TX_CMDID
,
70 .prb_tmpl_cmdid
= WMI_PRB_TMPL_CMDID
,
71 .addba_clear_resp_cmdid
= WMI_ADDBA_CLEAR_RESP_CMDID
,
72 .addba_send_cmdid
= WMI_ADDBA_SEND_CMDID
,
73 .addba_status_cmdid
= WMI_ADDBA_STATUS_CMDID
,
74 .delba_send_cmdid
= WMI_DELBA_SEND_CMDID
,
75 .addba_set_resp_cmdid
= WMI_ADDBA_SET_RESP_CMDID
,
76 .send_singleamsdu_cmdid
= WMI_SEND_SINGLEAMSDU_CMDID
,
77 .sta_powersave_mode_cmdid
= WMI_STA_POWERSAVE_MODE_CMDID
,
78 .sta_powersave_param_cmdid
= WMI_STA_POWERSAVE_PARAM_CMDID
,
79 .sta_mimo_ps_mode_cmdid
= WMI_STA_MIMO_PS_MODE_CMDID
,
80 .pdev_dfs_enable_cmdid
= WMI_PDEV_DFS_ENABLE_CMDID
,
81 .pdev_dfs_disable_cmdid
= WMI_PDEV_DFS_DISABLE_CMDID
,
82 .roam_scan_mode
= WMI_ROAM_SCAN_MODE
,
83 .roam_scan_rssi_threshold
= WMI_ROAM_SCAN_RSSI_THRESHOLD
,
84 .roam_scan_period
= WMI_ROAM_SCAN_PERIOD
,
85 .roam_scan_rssi_change_threshold
= WMI_ROAM_SCAN_RSSI_CHANGE_THRESHOLD
,
86 .roam_ap_profile
= WMI_ROAM_AP_PROFILE
,
87 .ofl_scan_add_ap_profile
= WMI_ROAM_AP_PROFILE
,
88 .ofl_scan_remove_ap_profile
= WMI_OFL_SCAN_REMOVE_AP_PROFILE
,
89 .ofl_scan_period
= WMI_OFL_SCAN_PERIOD
,
90 .p2p_dev_set_device_info
= WMI_P2P_DEV_SET_DEVICE_INFO
,
91 .p2p_dev_set_discoverability
= WMI_P2P_DEV_SET_DISCOVERABILITY
,
92 .p2p_go_set_beacon_ie
= WMI_P2P_GO_SET_BEACON_IE
,
93 .p2p_go_set_probe_resp_ie
= WMI_P2P_GO_SET_PROBE_RESP_IE
,
94 .p2p_set_vendor_ie_data_cmdid
= WMI_P2P_SET_VENDOR_IE_DATA_CMDID
,
95 .ap_ps_peer_param_cmdid
= WMI_AP_PS_PEER_PARAM_CMDID
,
96 .ap_ps_peer_uapsd_coex_cmdid
= WMI_AP_PS_PEER_UAPSD_COEX_CMDID
,
97 .peer_rate_retry_sched_cmdid
= WMI_PEER_RATE_RETRY_SCHED_CMDID
,
98 .wlan_profile_trigger_cmdid
= WMI_WLAN_PROFILE_TRIGGER_CMDID
,
99 .wlan_profile_set_hist_intvl_cmdid
=
100 WMI_WLAN_PROFILE_SET_HIST_INTVL_CMDID
,
101 .wlan_profile_get_profile_data_cmdid
=
102 WMI_WLAN_PROFILE_GET_PROFILE_DATA_CMDID
,
103 .wlan_profile_enable_profile_id_cmdid
=
104 WMI_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID
,
105 .wlan_profile_list_profile_id_cmdid
=
106 WMI_WLAN_PROFILE_LIST_PROFILE_ID_CMDID
,
107 .pdev_suspend_cmdid
= WMI_PDEV_SUSPEND_CMDID
,
108 .pdev_resume_cmdid
= WMI_PDEV_RESUME_CMDID
,
109 .add_bcn_filter_cmdid
= WMI_ADD_BCN_FILTER_CMDID
,
110 .rmv_bcn_filter_cmdid
= WMI_RMV_BCN_FILTER_CMDID
,
111 .wow_add_wake_pattern_cmdid
= WMI_WOW_ADD_WAKE_PATTERN_CMDID
,
112 .wow_del_wake_pattern_cmdid
= WMI_WOW_DEL_WAKE_PATTERN_CMDID
,
113 .wow_enable_disable_wake_event_cmdid
=
114 WMI_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID
,
115 .wow_enable_cmdid
= WMI_WOW_ENABLE_CMDID
,
116 .wow_hostwakeup_from_sleep_cmdid
= WMI_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID
,
117 .rtt_measreq_cmdid
= WMI_RTT_MEASREQ_CMDID
,
118 .rtt_tsf_cmdid
= WMI_RTT_TSF_CMDID
,
119 .vdev_spectral_scan_configure_cmdid
=
120 WMI_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID
,
121 .vdev_spectral_scan_enable_cmdid
= WMI_VDEV_SPECTRAL_SCAN_ENABLE_CMDID
,
122 .request_stats_cmdid
= WMI_REQUEST_STATS_CMDID
,
123 .set_arp_ns_offload_cmdid
= WMI_SET_ARP_NS_OFFLOAD_CMDID
,
124 .network_list_offload_config_cmdid
=
125 WMI_NETWORK_LIST_OFFLOAD_CONFIG_CMDID
,
126 .gtk_offload_cmdid
= WMI_GTK_OFFLOAD_CMDID
,
127 .csa_offload_enable_cmdid
= WMI_CSA_OFFLOAD_ENABLE_CMDID
,
128 .csa_offload_chanswitch_cmdid
= WMI_CSA_OFFLOAD_CHANSWITCH_CMDID
,
129 .chatter_set_mode_cmdid
= WMI_CHATTER_SET_MODE_CMDID
,
130 .peer_tid_addba_cmdid
= WMI_PEER_TID_ADDBA_CMDID
,
131 .peer_tid_delba_cmdid
= WMI_PEER_TID_DELBA_CMDID
,
132 .sta_dtim_ps_method_cmdid
= WMI_STA_DTIM_PS_METHOD_CMDID
,
133 .sta_uapsd_auto_trig_cmdid
= WMI_STA_UAPSD_AUTO_TRIG_CMDID
,
134 .sta_keepalive_cmd
= WMI_STA_KEEPALIVE_CMD
,
135 .echo_cmdid
= WMI_ECHO_CMDID
,
136 .pdev_utf_cmdid
= WMI_PDEV_UTF_CMDID
,
137 .dbglog_cfg_cmdid
= WMI_DBGLOG_CFG_CMDID
,
138 .pdev_qvit_cmdid
= WMI_PDEV_QVIT_CMDID
,
139 .pdev_ftm_intg_cmdid
= WMI_PDEV_FTM_INTG_CMDID
,
140 .vdev_set_keepalive_cmdid
= WMI_VDEV_SET_KEEPALIVE_CMDID
,
141 .vdev_get_keepalive_cmdid
= WMI_VDEV_GET_KEEPALIVE_CMDID
,
142 .force_fw_hang_cmdid
= WMI_FORCE_FW_HANG_CMDID
,
143 .gpio_config_cmdid
= WMI_GPIO_CONFIG_CMDID
,
144 .gpio_output_cmdid
= WMI_GPIO_OUTPUT_CMDID
,
147 /* 10.X WMI cmd track */
148 static struct wmi_cmd_map wmi_10x_cmd_map
= {
149 .init_cmdid
= WMI_10X_INIT_CMDID
,
150 .start_scan_cmdid
= WMI_10X_START_SCAN_CMDID
,
151 .stop_scan_cmdid
= WMI_10X_STOP_SCAN_CMDID
,
152 .scan_chan_list_cmdid
= WMI_10X_SCAN_CHAN_LIST_CMDID
,
153 .scan_sch_prio_tbl_cmdid
= WMI_CMD_UNSUPPORTED
,
154 .pdev_set_regdomain_cmdid
= WMI_10X_PDEV_SET_REGDOMAIN_CMDID
,
155 .pdev_set_channel_cmdid
= WMI_10X_PDEV_SET_CHANNEL_CMDID
,
156 .pdev_set_param_cmdid
= WMI_10X_PDEV_SET_PARAM_CMDID
,
157 .pdev_pktlog_enable_cmdid
= WMI_10X_PDEV_PKTLOG_ENABLE_CMDID
,
158 .pdev_pktlog_disable_cmdid
= WMI_10X_PDEV_PKTLOG_DISABLE_CMDID
,
159 .pdev_set_wmm_params_cmdid
= WMI_10X_PDEV_SET_WMM_PARAMS_CMDID
,
160 .pdev_set_ht_cap_ie_cmdid
= WMI_10X_PDEV_SET_HT_CAP_IE_CMDID
,
161 .pdev_set_vht_cap_ie_cmdid
= WMI_10X_PDEV_SET_VHT_CAP_IE_CMDID
,
162 .pdev_set_dscp_tid_map_cmdid
= WMI_10X_PDEV_SET_DSCP_TID_MAP_CMDID
,
163 .pdev_set_quiet_mode_cmdid
= WMI_10X_PDEV_SET_QUIET_MODE_CMDID
,
164 .pdev_green_ap_ps_enable_cmdid
= WMI_10X_PDEV_GREEN_AP_PS_ENABLE_CMDID
,
165 .pdev_get_tpc_config_cmdid
= WMI_10X_PDEV_GET_TPC_CONFIG_CMDID
,
166 .pdev_set_base_macaddr_cmdid
= WMI_10X_PDEV_SET_BASE_MACADDR_CMDID
,
167 .vdev_create_cmdid
= WMI_10X_VDEV_CREATE_CMDID
,
168 .vdev_delete_cmdid
= WMI_10X_VDEV_DELETE_CMDID
,
169 .vdev_start_request_cmdid
= WMI_10X_VDEV_START_REQUEST_CMDID
,
170 .vdev_restart_request_cmdid
= WMI_10X_VDEV_RESTART_REQUEST_CMDID
,
171 .vdev_up_cmdid
= WMI_10X_VDEV_UP_CMDID
,
172 .vdev_stop_cmdid
= WMI_10X_VDEV_STOP_CMDID
,
173 .vdev_down_cmdid
= WMI_10X_VDEV_DOWN_CMDID
,
174 .vdev_set_param_cmdid
= WMI_10X_VDEV_SET_PARAM_CMDID
,
175 .vdev_install_key_cmdid
= WMI_10X_VDEV_INSTALL_KEY_CMDID
,
176 .peer_create_cmdid
= WMI_10X_PEER_CREATE_CMDID
,
177 .peer_delete_cmdid
= WMI_10X_PEER_DELETE_CMDID
,
178 .peer_flush_tids_cmdid
= WMI_10X_PEER_FLUSH_TIDS_CMDID
,
179 .peer_set_param_cmdid
= WMI_10X_PEER_SET_PARAM_CMDID
,
180 .peer_assoc_cmdid
= WMI_10X_PEER_ASSOC_CMDID
,
181 .peer_add_wds_entry_cmdid
= WMI_10X_PEER_ADD_WDS_ENTRY_CMDID
,
182 .peer_remove_wds_entry_cmdid
= WMI_10X_PEER_REMOVE_WDS_ENTRY_CMDID
,
183 .peer_mcast_group_cmdid
= WMI_10X_PEER_MCAST_GROUP_CMDID
,
184 .bcn_tx_cmdid
= WMI_10X_BCN_TX_CMDID
,
185 .pdev_send_bcn_cmdid
= WMI_10X_PDEV_SEND_BCN_CMDID
,
186 .bcn_tmpl_cmdid
= WMI_CMD_UNSUPPORTED
,
187 .bcn_filter_rx_cmdid
= WMI_10X_BCN_FILTER_RX_CMDID
,
188 .prb_req_filter_rx_cmdid
= WMI_10X_PRB_REQ_FILTER_RX_CMDID
,
189 .mgmt_tx_cmdid
= WMI_10X_MGMT_TX_CMDID
,
190 .prb_tmpl_cmdid
= WMI_CMD_UNSUPPORTED
,
191 .addba_clear_resp_cmdid
= WMI_10X_ADDBA_CLEAR_RESP_CMDID
,
192 .addba_send_cmdid
= WMI_10X_ADDBA_SEND_CMDID
,
193 .addba_status_cmdid
= WMI_10X_ADDBA_STATUS_CMDID
,
194 .delba_send_cmdid
= WMI_10X_DELBA_SEND_CMDID
,
195 .addba_set_resp_cmdid
= WMI_10X_ADDBA_SET_RESP_CMDID
,
196 .send_singleamsdu_cmdid
= WMI_10X_SEND_SINGLEAMSDU_CMDID
,
197 .sta_powersave_mode_cmdid
= WMI_10X_STA_POWERSAVE_MODE_CMDID
,
198 .sta_powersave_param_cmdid
= WMI_10X_STA_POWERSAVE_PARAM_CMDID
,
199 .sta_mimo_ps_mode_cmdid
= WMI_10X_STA_MIMO_PS_MODE_CMDID
,
200 .pdev_dfs_enable_cmdid
= WMI_10X_PDEV_DFS_ENABLE_CMDID
,
201 .pdev_dfs_disable_cmdid
= WMI_10X_PDEV_DFS_DISABLE_CMDID
,
202 .roam_scan_mode
= WMI_10X_ROAM_SCAN_MODE
,
203 .roam_scan_rssi_threshold
= WMI_10X_ROAM_SCAN_RSSI_THRESHOLD
,
204 .roam_scan_period
= WMI_10X_ROAM_SCAN_PERIOD
,
205 .roam_scan_rssi_change_threshold
=
206 WMI_10X_ROAM_SCAN_RSSI_CHANGE_THRESHOLD
,
207 .roam_ap_profile
= WMI_10X_ROAM_AP_PROFILE
,
208 .ofl_scan_add_ap_profile
= WMI_10X_OFL_SCAN_ADD_AP_PROFILE
,
209 .ofl_scan_remove_ap_profile
= WMI_10X_OFL_SCAN_REMOVE_AP_PROFILE
,
210 .ofl_scan_period
= WMI_10X_OFL_SCAN_PERIOD
,
211 .p2p_dev_set_device_info
= WMI_10X_P2P_DEV_SET_DEVICE_INFO
,
212 .p2p_dev_set_discoverability
= WMI_10X_P2P_DEV_SET_DISCOVERABILITY
,
213 .p2p_go_set_beacon_ie
= WMI_10X_P2P_GO_SET_BEACON_IE
,
214 .p2p_go_set_probe_resp_ie
= WMI_10X_P2P_GO_SET_PROBE_RESP_IE
,
215 .p2p_set_vendor_ie_data_cmdid
= WMI_CMD_UNSUPPORTED
,
216 .ap_ps_peer_param_cmdid
= WMI_CMD_UNSUPPORTED
,
217 .ap_ps_peer_uapsd_coex_cmdid
= WMI_CMD_UNSUPPORTED
,
218 .peer_rate_retry_sched_cmdid
= WMI_10X_PEER_RATE_RETRY_SCHED_CMDID
,
219 .wlan_profile_trigger_cmdid
= WMI_10X_WLAN_PROFILE_TRIGGER_CMDID
,
220 .wlan_profile_set_hist_intvl_cmdid
=
221 WMI_10X_WLAN_PROFILE_SET_HIST_INTVL_CMDID
,
222 .wlan_profile_get_profile_data_cmdid
=
223 WMI_10X_WLAN_PROFILE_GET_PROFILE_DATA_CMDID
,
224 .wlan_profile_enable_profile_id_cmdid
=
225 WMI_10X_WLAN_PROFILE_ENABLE_PROFILE_ID_CMDID
,
226 .wlan_profile_list_profile_id_cmdid
=
227 WMI_10X_WLAN_PROFILE_LIST_PROFILE_ID_CMDID
,
228 .pdev_suspend_cmdid
= WMI_10X_PDEV_SUSPEND_CMDID
,
229 .pdev_resume_cmdid
= WMI_10X_PDEV_RESUME_CMDID
,
230 .add_bcn_filter_cmdid
= WMI_10X_ADD_BCN_FILTER_CMDID
,
231 .rmv_bcn_filter_cmdid
= WMI_10X_RMV_BCN_FILTER_CMDID
,
232 .wow_add_wake_pattern_cmdid
= WMI_10X_WOW_ADD_WAKE_PATTERN_CMDID
,
233 .wow_del_wake_pattern_cmdid
= WMI_10X_WOW_DEL_WAKE_PATTERN_CMDID
,
234 .wow_enable_disable_wake_event_cmdid
=
235 WMI_10X_WOW_ENABLE_DISABLE_WAKE_EVENT_CMDID
,
236 .wow_enable_cmdid
= WMI_10X_WOW_ENABLE_CMDID
,
237 .wow_hostwakeup_from_sleep_cmdid
=
238 WMI_10X_WOW_HOSTWAKEUP_FROM_SLEEP_CMDID
,
239 .rtt_measreq_cmdid
= WMI_10X_RTT_MEASREQ_CMDID
,
240 .rtt_tsf_cmdid
= WMI_10X_RTT_TSF_CMDID
,
241 .vdev_spectral_scan_configure_cmdid
=
242 WMI_10X_VDEV_SPECTRAL_SCAN_CONFIGURE_CMDID
,
243 .vdev_spectral_scan_enable_cmdid
=
244 WMI_10X_VDEV_SPECTRAL_SCAN_ENABLE_CMDID
,
245 .request_stats_cmdid
= WMI_10X_REQUEST_STATS_CMDID
,
246 .set_arp_ns_offload_cmdid
= WMI_CMD_UNSUPPORTED
,
247 .network_list_offload_config_cmdid
= WMI_CMD_UNSUPPORTED
,
248 .gtk_offload_cmdid
= WMI_CMD_UNSUPPORTED
,
249 .csa_offload_enable_cmdid
= WMI_CMD_UNSUPPORTED
,
250 .csa_offload_chanswitch_cmdid
= WMI_CMD_UNSUPPORTED
,
251 .chatter_set_mode_cmdid
= WMI_CMD_UNSUPPORTED
,
252 .peer_tid_addba_cmdid
= WMI_CMD_UNSUPPORTED
,
253 .peer_tid_delba_cmdid
= WMI_CMD_UNSUPPORTED
,
254 .sta_dtim_ps_method_cmdid
= WMI_CMD_UNSUPPORTED
,
255 .sta_uapsd_auto_trig_cmdid
= WMI_CMD_UNSUPPORTED
,
256 .sta_keepalive_cmd
= WMI_CMD_UNSUPPORTED
,
257 .echo_cmdid
= WMI_10X_ECHO_CMDID
,
258 .pdev_utf_cmdid
= WMI_10X_PDEV_UTF_CMDID
,
259 .dbglog_cfg_cmdid
= WMI_10X_DBGLOG_CFG_CMDID
,
260 .pdev_qvit_cmdid
= WMI_10X_PDEV_QVIT_CMDID
,
261 .pdev_ftm_intg_cmdid
= WMI_CMD_UNSUPPORTED
,
262 .vdev_set_keepalive_cmdid
= WMI_CMD_UNSUPPORTED
,
263 .vdev_get_keepalive_cmdid
= WMI_CMD_UNSUPPORTED
,
264 .force_fw_hang_cmdid
= WMI_CMD_UNSUPPORTED
,
265 .gpio_config_cmdid
= WMI_10X_GPIO_CONFIG_CMDID
,
266 .gpio_output_cmdid
= WMI_10X_GPIO_OUTPUT_CMDID
,
269 /* MAIN WMI VDEV param map */
270 static struct wmi_vdev_param_map wmi_vdev_param_map
= {
271 .rts_threshold
= WMI_VDEV_PARAM_RTS_THRESHOLD
,
272 .fragmentation_threshold
= WMI_VDEV_PARAM_FRAGMENTATION_THRESHOLD
,
273 .beacon_interval
= WMI_VDEV_PARAM_BEACON_INTERVAL
,
274 .listen_interval
= WMI_VDEV_PARAM_LISTEN_INTERVAL
,
275 .multicast_rate
= WMI_VDEV_PARAM_MULTICAST_RATE
,
276 .mgmt_tx_rate
= WMI_VDEV_PARAM_MGMT_TX_RATE
,
277 .slot_time
= WMI_VDEV_PARAM_SLOT_TIME
,
278 .preamble
= WMI_VDEV_PARAM_PREAMBLE
,
279 .swba_time
= WMI_VDEV_PARAM_SWBA_TIME
,
280 .wmi_vdev_stats_update_period
= WMI_VDEV_STATS_UPDATE_PERIOD
,
281 .wmi_vdev_pwrsave_ageout_time
= WMI_VDEV_PWRSAVE_AGEOUT_TIME
,
282 .wmi_vdev_host_swba_interval
= WMI_VDEV_HOST_SWBA_INTERVAL
,
283 .dtim_period
= WMI_VDEV_PARAM_DTIM_PERIOD
,
284 .wmi_vdev_oc_scheduler_air_time_limit
=
285 WMI_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT
,
286 .wds
= WMI_VDEV_PARAM_WDS
,
287 .atim_window
= WMI_VDEV_PARAM_ATIM_WINDOW
,
288 .bmiss_count_max
= WMI_VDEV_PARAM_BMISS_COUNT_MAX
,
289 .bmiss_first_bcnt
= WMI_VDEV_PARAM_BMISS_FIRST_BCNT
,
290 .bmiss_final_bcnt
= WMI_VDEV_PARAM_BMISS_FINAL_BCNT
,
291 .feature_wmm
= WMI_VDEV_PARAM_FEATURE_WMM
,
292 .chwidth
= WMI_VDEV_PARAM_CHWIDTH
,
293 .chextoffset
= WMI_VDEV_PARAM_CHEXTOFFSET
,
294 .disable_htprotection
= WMI_VDEV_PARAM_DISABLE_HTPROTECTION
,
295 .sta_quickkickout
= WMI_VDEV_PARAM_STA_QUICKKICKOUT
,
296 .mgmt_rate
= WMI_VDEV_PARAM_MGMT_RATE
,
297 .protection_mode
= WMI_VDEV_PARAM_PROTECTION_MODE
,
298 .fixed_rate
= WMI_VDEV_PARAM_FIXED_RATE
,
299 .sgi
= WMI_VDEV_PARAM_SGI
,
300 .ldpc
= WMI_VDEV_PARAM_LDPC
,
301 .tx_stbc
= WMI_VDEV_PARAM_TX_STBC
,
302 .rx_stbc
= WMI_VDEV_PARAM_RX_STBC
,
303 .intra_bss_fwd
= WMI_VDEV_PARAM_INTRA_BSS_FWD
,
304 .def_keyid
= WMI_VDEV_PARAM_DEF_KEYID
,
305 .nss
= WMI_VDEV_PARAM_NSS
,
306 .bcast_data_rate
= WMI_VDEV_PARAM_BCAST_DATA_RATE
,
307 .mcast_data_rate
= WMI_VDEV_PARAM_MCAST_DATA_RATE
,
308 .mcast_indicate
= WMI_VDEV_PARAM_MCAST_INDICATE
,
309 .dhcp_indicate
= WMI_VDEV_PARAM_DHCP_INDICATE
,
310 .unknown_dest_indicate
= WMI_VDEV_PARAM_UNKNOWN_DEST_INDICATE
,
311 .ap_keepalive_min_idle_inactive_time_secs
=
312 WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS
,
313 .ap_keepalive_max_idle_inactive_time_secs
=
314 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS
,
315 .ap_keepalive_max_unresponsive_time_secs
=
316 WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS
,
317 .ap_enable_nawds
= WMI_VDEV_PARAM_AP_ENABLE_NAWDS
,
318 .mcast2ucast_set
= WMI_VDEV_PARAM_UNSUPPORTED
,
319 .enable_rtscts
= WMI_VDEV_PARAM_ENABLE_RTSCTS
,
320 .txbf
= WMI_VDEV_PARAM_TXBF
,
321 .packet_powersave
= WMI_VDEV_PARAM_PACKET_POWERSAVE
,
322 .drop_unencry
= WMI_VDEV_PARAM_DROP_UNENCRY
,
323 .tx_encap_type
= WMI_VDEV_PARAM_TX_ENCAP_TYPE
,
324 .ap_detect_out_of_sync_sleeping_sta_time_secs
=
325 WMI_VDEV_PARAM_UNSUPPORTED
,
328 /* 10.X WMI VDEV param map */
329 static struct wmi_vdev_param_map wmi_10x_vdev_param_map
= {
330 .rts_threshold
= WMI_10X_VDEV_PARAM_RTS_THRESHOLD
,
331 .fragmentation_threshold
= WMI_10X_VDEV_PARAM_FRAGMENTATION_THRESHOLD
,
332 .beacon_interval
= WMI_10X_VDEV_PARAM_BEACON_INTERVAL
,
333 .listen_interval
= WMI_10X_VDEV_PARAM_LISTEN_INTERVAL
,
334 .multicast_rate
= WMI_10X_VDEV_PARAM_MULTICAST_RATE
,
335 .mgmt_tx_rate
= WMI_10X_VDEV_PARAM_MGMT_TX_RATE
,
336 .slot_time
= WMI_10X_VDEV_PARAM_SLOT_TIME
,
337 .preamble
= WMI_10X_VDEV_PARAM_PREAMBLE
,
338 .swba_time
= WMI_10X_VDEV_PARAM_SWBA_TIME
,
339 .wmi_vdev_stats_update_period
= WMI_10X_VDEV_STATS_UPDATE_PERIOD
,
340 .wmi_vdev_pwrsave_ageout_time
= WMI_10X_VDEV_PWRSAVE_AGEOUT_TIME
,
341 .wmi_vdev_host_swba_interval
= WMI_10X_VDEV_HOST_SWBA_INTERVAL
,
342 .dtim_period
= WMI_10X_VDEV_PARAM_DTIM_PERIOD
,
343 .wmi_vdev_oc_scheduler_air_time_limit
=
344 WMI_10X_VDEV_OC_SCHEDULER_AIR_TIME_LIMIT
,
345 .wds
= WMI_10X_VDEV_PARAM_WDS
,
346 .atim_window
= WMI_10X_VDEV_PARAM_ATIM_WINDOW
,
347 .bmiss_count_max
= WMI_10X_VDEV_PARAM_BMISS_COUNT_MAX
,
348 .bmiss_first_bcnt
= WMI_VDEV_PARAM_UNSUPPORTED
,
349 .bmiss_final_bcnt
= WMI_VDEV_PARAM_UNSUPPORTED
,
350 .feature_wmm
= WMI_10X_VDEV_PARAM_FEATURE_WMM
,
351 .chwidth
= WMI_10X_VDEV_PARAM_CHWIDTH
,
352 .chextoffset
= WMI_10X_VDEV_PARAM_CHEXTOFFSET
,
353 .disable_htprotection
= WMI_10X_VDEV_PARAM_DISABLE_HTPROTECTION
,
354 .sta_quickkickout
= WMI_10X_VDEV_PARAM_STA_QUICKKICKOUT
,
355 .mgmt_rate
= WMI_10X_VDEV_PARAM_MGMT_RATE
,
356 .protection_mode
= WMI_10X_VDEV_PARAM_PROTECTION_MODE
,
357 .fixed_rate
= WMI_10X_VDEV_PARAM_FIXED_RATE
,
358 .sgi
= WMI_10X_VDEV_PARAM_SGI
,
359 .ldpc
= WMI_10X_VDEV_PARAM_LDPC
,
360 .tx_stbc
= WMI_10X_VDEV_PARAM_TX_STBC
,
361 .rx_stbc
= WMI_10X_VDEV_PARAM_RX_STBC
,
362 .intra_bss_fwd
= WMI_10X_VDEV_PARAM_INTRA_BSS_FWD
,
363 .def_keyid
= WMI_10X_VDEV_PARAM_DEF_KEYID
,
364 .nss
= WMI_10X_VDEV_PARAM_NSS
,
365 .bcast_data_rate
= WMI_10X_VDEV_PARAM_BCAST_DATA_RATE
,
366 .mcast_data_rate
= WMI_10X_VDEV_PARAM_MCAST_DATA_RATE
,
367 .mcast_indicate
= WMI_10X_VDEV_PARAM_MCAST_INDICATE
,
368 .dhcp_indicate
= WMI_10X_VDEV_PARAM_DHCP_INDICATE
,
369 .unknown_dest_indicate
= WMI_10X_VDEV_PARAM_UNKNOWN_DEST_INDICATE
,
370 .ap_keepalive_min_idle_inactive_time_secs
=
371 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS
,
372 .ap_keepalive_max_idle_inactive_time_secs
=
373 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS
,
374 .ap_keepalive_max_unresponsive_time_secs
=
375 WMI_10X_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS
,
376 .ap_enable_nawds
= WMI_10X_VDEV_PARAM_AP_ENABLE_NAWDS
,
377 .mcast2ucast_set
= WMI_10X_VDEV_PARAM_MCAST2UCAST_SET
,
378 .enable_rtscts
= WMI_10X_VDEV_PARAM_ENABLE_RTSCTS
,
379 .txbf
= WMI_VDEV_PARAM_UNSUPPORTED
,
380 .packet_powersave
= WMI_VDEV_PARAM_UNSUPPORTED
,
381 .drop_unencry
= WMI_VDEV_PARAM_UNSUPPORTED
,
382 .tx_encap_type
= WMI_VDEV_PARAM_UNSUPPORTED
,
383 .ap_detect_out_of_sync_sleeping_sta_time_secs
=
384 WMI_10X_VDEV_PARAM_AP_DETECT_OUT_OF_SYNC_SLEEPING_STA_TIME_SECS
,
387 static struct wmi_pdev_param_map wmi_pdev_param_map
= {
388 .tx_chain_mask
= WMI_PDEV_PARAM_TX_CHAIN_MASK
,
389 .rx_chain_mask
= WMI_PDEV_PARAM_RX_CHAIN_MASK
,
390 .txpower_limit2g
= WMI_PDEV_PARAM_TXPOWER_LIMIT2G
,
391 .txpower_limit5g
= WMI_PDEV_PARAM_TXPOWER_LIMIT5G
,
392 .txpower_scale
= WMI_PDEV_PARAM_TXPOWER_SCALE
,
393 .beacon_gen_mode
= WMI_PDEV_PARAM_BEACON_GEN_MODE
,
394 .beacon_tx_mode
= WMI_PDEV_PARAM_BEACON_TX_MODE
,
395 .resmgr_offchan_mode
= WMI_PDEV_PARAM_RESMGR_OFFCHAN_MODE
,
396 .protection_mode
= WMI_PDEV_PARAM_PROTECTION_MODE
,
397 .dynamic_bw
= WMI_PDEV_PARAM_DYNAMIC_BW
,
398 .non_agg_sw_retry_th
= WMI_PDEV_PARAM_NON_AGG_SW_RETRY_TH
,
399 .agg_sw_retry_th
= WMI_PDEV_PARAM_AGG_SW_RETRY_TH
,
400 .sta_kickout_th
= WMI_PDEV_PARAM_STA_KICKOUT_TH
,
401 .ac_aggrsize_scaling
= WMI_PDEV_PARAM_AC_AGGRSIZE_SCALING
,
402 .ltr_enable
= WMI_PDEV_PARAM_LTR_ENABLE
,
403 .ltr_ac_latency_be
= WMI_PDEV_PARAM_LTR_AC_LATENCY_BE
,
404 .ltr_ac_latency_bk
= WMI_PDEV_PARAM_LTR_AC_LATENCY_BK
,
405 .ltr_ac_latency_vi
= WMI_PDEV_PARAM_LTR_AC_LATENCY_VI
,
406 .ltr_ac_latency_vo
= WMI_PDEV_PARAM_LTR_AC_LATENCY_VO
,
407 .ltr_ac_latency_timeout
= WMI_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT
,
408 .ltr_sleep_override
= WMI_PDEV_PARAM_LTR_SLEEP_OVERRIDE
,
409 .ltr_rx_override
= WMI_PDEV_PARAM_LTR_RX_OVERRIDE
,
410 .ltr_tx_activity_timeout
= WMI_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT
,
411 .l1ss_enable
= WMI_PDEV_PARAM_L1SS_ENABLE
,
412 .dsleep_enable
= WMI_PDEV_PARAM_DSLEEP_ENABLE
,
413 .pcielp_txbuf_flush
= WMI_PDEV_PARAM_PCIELP_TXBUF_FLUSH
,
414 .pcielp_txbuf_watermark
= WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN
,
415 .pcielp_txbuf_tmo_en
= WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_EN
,
416 .pcielp_txbuf_tmo_value
= WMI_PDEV_PARAM_PCIELP_TXBUF_TMO_VALUE
,
417 .pdev_stats_update_period
= WMI_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD
,
418 .vdev_stats_update_period
= WMI_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD
,
419 .peer_stats_update_period
= WMI_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD
,
420 .bcnflt_stats_update_period
= WMI_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD
,
421 .pmf_qos
= WMI_PDEV_PARAM_PMF_QOS
,
422 .arp_ac_override
= WMI_PDEV_PARAM_ARP_AC_OVERRIDE
,
423 .arpdhcp_ac_override
= WMI_PDEV_PARAM_UNSUPPORTED
,
424 .dcs
= WMI_PDEV_PARAM_DCS
,
425 .ani_enable
= WMI_PDEV_PARAM_ANI_ENABLE
,
426 .ani_poll_period
= WMI_PDEV_PARAM_ANI_POLL_PERIOD
,
427 .ani_listen_period
= WMI_PDEV_PARAM_ANI_LISTEN_PERIOD
,
428 .ani_ofdm_level
= WMI_PDEV_PARAM_ANI_OFDM_LEVEL
,
429 .ani_cck_level
= WMI_PDEV_PARAM_ANI_CCK_LEVEL
,
430 .dyntxchain
= WMI_PDEV_PARAM_DYNTXCHAIN
,
431 .proxy_sta
= WMI_PDEV_PARAM_PROXY_STA
,
432 .idle_ps_config
= WMI_PDEV_PARAM_IDLE_PS_CONFIG
,
433 .power_gating_sleep
= WMI_PDEV_PARAM_POWER_GATING_SLEEP
,
434 .fast_channel_reset
= WMI_PDEV_PARAM_UNSUPPORTED
,
435 .burst_dur
= WMI_PDEV_PARAM_UNSUPPORTED
,
436 .burst_enable
= WMI_PDEV_PARAM_UNSUPPORTED
,
439 static struct wmi_pdev_param_map wmi_10x_pdev_param_map
= {
440 .tx_chain_mask
= WMI_10X_PDEV_PARAM_TX_CHAIN_MASK
,
441 .rx_chain_mask
= WMI_10X_PDEV_PARAM_RX_CHAIN_MASK
,
442 .txpower_limit2g
= WMI_10X_PDEV_PARAM_TXPOWER_LIMIT2G
,
443 .txpower_limit5g
= WMI_10X_PDEV_PARAM_TXPOWER_LIMIT5G
,
444 .txpower_scale
= WMI_10X_PDEV_PARAM_TXPOWER_SCALE
,
445 .beacon_gen_mode
= WMI_10X_PDEV_PARAM_BEACON_GEN_MODE
,
446 .beacon_tx_mode
= WMI_10X_PDEV_PARAM_BEACON_TX_MODE
,
447 .resmgr_offchan_mode
= WMI_10X_PDEV_PARAM_RESMGR_OFFCHAN_MODE
,
448 .protection_mode
= WMI_10X_PDEV_PARAM_PROTECTION_MODE
,
449 .dynamic_bw
= WMI_10X_PDEV_PARAM_DYNAMIC_BW
,
450 .non_agg_sw_retry_th
= WMI_10X_PDEV_PARAM_NON_AGG_SW_RETRY_TH
,
451 .agg_sw_retry_th
= WMI_10X_PDEV_PARAM_AGG_SW_RETRY_TH
,
452 .sta_kickout_th
= WMI_10X_PDEV_PARAM_STA_KICKOUT_TH
,
453 .ac_aggrsize_scaling
= WMI_10X_PDEV_PARAM_AC_AGGRSIZE_SCALING
,
454 .ltr_enable
= WMI_10X_PDEV_PARAM_LTR_ENABLE
,
455 .ltr_ac_latency_be
= WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BE
,
456 .ltr_ac_latency_bk
= WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_BK
,
457 .ltr_ac_latency_vi
= WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VI
,
458 .ltr_ac_latency_vo
= WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_VO
,
459 .ltr_ac_latency_timeout
= WMI_10X_PDEV_PARAM_LTR_AC_LATENCY_TIMEOUT
,
460 .ltr_sleep_override
= WMI_10X_PDEV_PARAM_LTR_SLEEP_OVERRIDE
,
461 .ltr_rx_override
= WMI_10X_PDEV_PARAM_LTR_RX_OVERRIDE
,
462 .ltr_tx_activity_timeout
= WMI_10X_PDEV_PARAM_LTR_TX_ACTIVITY_TIMEOUT
,
463 .l1ss_enable
= WMI_10X_PDEV_PARAM_L1SS_ENABLE
,
464 .dsleep_enable
= WMI_10X_PDEV_PARAM_DSLEEP_ENABLE
,
465 .pcielp_txbuf_flush
= WMI_PDEV_PARAM_UNSUPPORTED
,
466 .pcielp_txbuf_watermark
= WMI_PDEV_PARAM_UNSUPPORTED
,
467 .pcielp_txbuf_tmo_en
= WMI_PDEV_PARAM_UNSUPPORTED
,
468 .pcielp_txbuf_tmo_value
= WMI_PDEV_PARAM_UNSUPPORTED
,
469 .pdev_stats_update_period
= WMI_10X_PDEV_PARAM_PDEV_STATS_UPDATE_PERIOD
,
470 .vdev_stats_update_period
= WMI_10X_PDEV_PARAM_VDEV_STATS_UPDATE_PERIOD
,
471 .peer_stats_update_period
= WMI_10X_PDEV_PARAM_PEER_STATS_UPDATE_PERIOD
,
472 .bcnflt_stats_update_period
=
473 WMI_10X_PDEV_PARAM_BCNFLT_STATS_UPDATE_PERIOD
,
474 .pmf_qos
= WMI_10X_PDEV_PARAM_PMF_QOS
,
475 .arp_ac_override
= WMI_PDEV_PARAM_UNSUPPORTED
,
476 .arpdhcp_ac_override
= WMI_10X_PDEV_PARAM_ARPDHCP_AC_OVERRIDE
,
477 .dcs
= WMI_10X_PDEV_PARAM_DCS
,
478 .ani_enable
= WMI_10X_PDEV_PARAM_ANI_ENABLE
,
479 .ani_poll_period
= WMI_10X_PDEV_PARAM_ANI_POLL_PERIOD
,
480 .ani_listen_period
= WMI_10X_PDEV_PARAM_ANI_LISTEN_PERIOD
,
481 .ani_ofdm_level
= WMI_10X_PDEV_PARAM_ANI_OFDM_LEVEL
,
482 .ani_cck_level
= WMI_10X_PDEV_PARAM_ANI_CCK_LEVEL
,
483 .dyntxchain
= WMI_10X_PDEV_PARAM_DYNTXCHAIN
,
484 .proxy_sta
= WMI_PDEV_PARAM_UNSUPPORTED
,
485 .idle_ps_config
= WMI_PDEV_PARAM_UNSUPPORTED
,
486 .power_gating_sleep
= WMI_PDEV_PARAM_UNSUPPORTED
,
487 .fast_channel_reset
= WMI_10X_PDEV_PARAM_FAST_CHANNEL_RESET
,
488 .burst_dur
= WMI_10X_PDEV_PARAM_BURST_DUR
,
489 .burst_enable
= WMI_10X_PDEV_PARAM_BURST_ENABLE
,
492 int ath10k_wmi_wait_for_service_ready(struct ath10k
*ar
)
495 ret
= wait_for_completion_timeout(&ar
->wmi
.service_ready
,
496 WMI_SERVICE_READY_TIMEOUT_HZ
);
500 int ath10k_wmi_wait_for_unified_ready(struct ath10k
*ar
)
503 ret
= wait_for_completion_timeout(&ar
->wmi
.unified_ready
,
504 WMI_UNIFIED_READY_TIMEOUT_HZ
);
508 static struct sk_buff
*ath10k_wmi_alloc_skb(u32 len
)
511 u32 round_len
= roundup(len
, 4);
513 skb
= ath10k_htc_alloc_skb(WMI_SKB_HEADROOM
+ round_len
);
517 skb_reserve(skb
, WMI_SKB_HEADROOM
);
518 if (!IS_ALIGNED((unsigned long)skb
->data
, 4))
519 ath10k_warn("Unaligned WMI skb\n");
521 skb_put(skb
, round_len
);
522 memset(skb
->data
, 0, round_len
);
527 static void ath10k_wmi_htc_tx_complete(struct ath10k
*ar
, struct sk_buff
*skb
)
532 static int ath10k_wmi_cmd_send_nowait(struct ath10k
*ar
, struct sk_buff
*skb
,
535 struct ath10k_skb_cb
*skb_cb
= ATH10K_SKB_CB(skb
);
536 struct wmi_cmd_hdr
*cmd_hdr
;
540 if (skb_push(skb
, sizeof(struct wmi_cmd_hdr
)) == NULL
)
543 cmd
|= SM(cmd_id
, WMI_CMD_HDR_CMD_ID
);
545 cmd_hdr
= (struct wmi_cmd_hdr
*)skb
->data
;
546 cmd_hdr
->cmd_id
= __cpu_to_le32(cmd
);
548 memset(skb_cb
, 0, sizeof(*skb_cb
));
549 ret
= ath10k_htc_send(&ar
->htc
, ar
->wmi
.eid
, skb
);
550 trace_ath10k_wmi_cmd(cmd_id
, skb
->data
, skb
->len
, ret
);
558 skb_pull(skb
, sizeof(struct wmi_cmd_hdr
));
562 static void ath10k_wmi_tx_beacon_nowait(struct ath10k_vif
*arvif
)
564 struct wmi_bcn_tx_arg arg
= {0};
567 lockdep_assert_held(&arvif
->ar
->data_lock
);
569 if (arvif
->beacon
== NULL
)
572 arg
.vdev_id
= arvif
->vdev_id
;
575 arg
.bcn
= arvif
->beacon
->data
;
576 arg
.bcn_len
= arvif
->beacon
->len
;
578 ret
= ath10k_wmi_beacon_send_nowait(arvif
->ar
, &arg
);
582 dev_kfree_skb_any(arvif
->beacon
);
583 arvif
->beacon
= NULL
;
586 static void ath10k_wmi_tx_beacons_iter(void *data
, u8
*mac
,
587 struct ieee80211_vif
*vif
)
589 struct ath10k_vif
*arvif
= ath10k_vif_to_arvif(vif
);
591 ath10k_wmi_tx_beacon_nowait(arvif
);
594 static void ath10k_wmi_tx_beacons_nowait(struct ath10k
*ar
)
596 spin_lock_bh(&ar
->data_lock
);
597 ieee80211_iterate_active_interfaces_atomic(ar
->hw
,
598 IEEE80211_IFACE_ITER_NORMAL
,
599 ath10k_wmi_tx_beacons_iter
,
601 spin_unlock_bh(&ar
->data_lock
);
604 static void ath10k_wmi_op_ep_tx_credits(struct ath10k
*ar
)
606 /* try to send pending beacons first. they take priority */
607 ath10k_wmi_tx_beacons_nowait(ar
);
609 wake_up(&ar
->wmi
.tx_credits_wq
);
612 static int ath10k_wmi_cmd_send(struct ath10k
*ar
, struct sk_buff
*skb
,
615 int ret
= -EOPNOTSUPP
;
619 if (cmd_id
== WMI_CMD_UNSUPPORTED
) {
620 ath10k_warn("wmi command %d is not supported by firmware\n",
625 wait_event_timeout(ar
->wmi
.tx_credits_wq
, ({
626 /* try to send pending beacons first. they take priority */
627 ath10k_wmi_tx_beacons_nowait(ar
);
629 ret
= ath10k_wmi_cmd_send_nowait(ar
, skb
, cmd_id
);
634 dev_kfree_skb_any(skb
);
639 int ath10k_wmi_mgmt_tx(struct ath10k
*ar
, struct sk_buff
*skb
)
642 struct wmi_mgmt_tx_cmd
*cmd
;
643 struct ieee80211_hdr
*hdr
;
644 struct sk_buff
*wmi_skb
;
645 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
649 hdr
= (struct ieee80211_hdr
*)skb
->data
;
650 fc
= le16_to_cpu(hdr
->frame_control
);
652 if (WARN_ON_ONCE(!ieee80211_is_mgmt(hdr
->frame_control
)))
655 len
= sizeof(cmd
->hdr
) + skb
->len
;
656 len
= round_up(len
, 4);
658 wmi_skb
= ath10k_wmi_alloc_skb(len
);
662 cmd
= (struct wmi_mgmt_tx_cmd
*)wmi_skb
->data
;
664 cmd
->hdr
.vdev_id
= __cpu_to_le32(ATH10K_SKB_CB(skb
)->vdev_id
);
665 cmd
->hdr
.tx_rate
= 0;
666 cmd
->hdr
.tx_power
= 0;
667 cmd
->hdr
.buf_len
= __cpu_to_le32((u32
)(skb
->len
));
669 memcpy(cmd
->hdr
.peer_macaddr
.addr
, ieee80211_get_DA(hdr
), ETH_ALEN
);
670 memcpy(cmd
->buf
, skb
->data
, skb
->len
);
672 ath10k_dbg(ATH10K_DBG_WMI
, "wmi mgmt tx skb %p len %d ftype %02x stype %02x\n",
673 wmi_skb
, wmi_skb
->len
, fc
& IEEE80211_FCTL_FTYPE
,
674 fc
& IEEE80211_FCTL_STYPE
);
676 /* Send the management frame buffer to the target */
677 ret
= ath10k_wmi_cmd_send(ar
, wmi_skb
, ar
->wmi
.cmd
->mgmt_tx_cmdid
);
681 /* TODO: report tx status to mac80211 - temporary just ACK */
682 info
->flags
|= IEEE80211_TX_STAT_ACK
;
683 ieee80211_tx_status_irqsafe(ar
->hw
, skb
);
688 static int ath10k_wmi_event_scan(struct ath10k
*ar
, struct sk_buff
*skb
)
690 struct wmi_scan_event
*event
= (struct wmi_scan_event
*)skb
->data
;
691 enum wmi_scan_event_type event_type
;
692 enum wmi_scan_completion_reason reason
;
698 event_type
= __le32_to_cpu(event
->event_type
);
699 reason
= __le32_to_cpu(event
->reason
);
700 freq
= __le32_to_cpu(event
->channel_freq
);
701 req_id
= __le32_to_cpu(event
->scan_req_id
);
702 scan_id
= __le32_to_cpu(event
->scan_id
);
703 vdev_id
= __le32_to_cpu(event
->vdev_id
);
705 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_SCAN_EVENTID\n");
706 ath10k_dbg(ATH10K_DBG_WMI
,
707 "scan event type %d reason %d freq %d req_id %d "
708 "scan_id %d vdev_id %d\n",
709 event_type
, reason
, freq
, req_id
, scan_id
, vdev_id
);
711 spin_lock_bh(&ar
->data_lock
);
713 switch (event_type
) {
714 case WMI_SCAN_EVENT_STARTED
:
715 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_EVENT_STARTED\n");
716 if (ar
->scan
.in_progress
&& ar
->scan
.is_roc
)
717 ieee80211_ready_on_channel(ar
->hw
);
719 complete(&ar
->scan
.started
);
721 case WMI_SCAN_EVENT_COMPLETED
:
722 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_EVENT_COMPLETED\n");
724 case WMI_SCAN_REASON_COMPLETED
:
725 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_REASON_COMPLETED\n");
727 case WMI_SCAN_REASON_CANCELLED
:
728 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_REASON_CANCELED\n");
730 case WMI_SCAN_REASON_PREEMPTED
:
731 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_REASON_PREEMPTED\n");
733 case WMI_SCAN_REASON_TIMEDOUT
:
734 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_REASON_TIMEDOUT\n");
740 ar
->scan_channel
= NULL
;
741 if (!ar
->scan
.in_progress
) {
742 ath10k_warn("no scan requested, ignoring\n");
746 if (ar
->scan
.is_roc
) {
747 ath10k_offchan_tx_purge(ar
);
749 if (!ar
->scan
.aborting
)
750 ieee80211_remain_on_channel_expired(ar
->hw
);
752 ieee80211_scan_completed(ar
->hw
, ar
->scan
.aborting
);
755 del_timer(&ar
->scan
.timeout
);
756 complete_all(&ar
->scan
.completed
);
757 ar
->scan
.in_progress
= false;
759 case WMI_SCAN_EVENT_BSS_CHANNEL
:
760 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_EVENT_BSS_CHANNEL\n");
761 ar
->scan_channel
= NULL
;
763 case WMI_SCAN_EVENT_FOREIGN_CHANNEL
:
764 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_EVENT_FOREIGN_CHANNEL\n");
765 ar
->scan_channel
= ieee80211_get_channel(ar
->hw
->wiphy
, freq
);
766 if (ar
->scan
.in_progress
&& ar
->scan
.is_roc
&&
767 ar
->scan
.roc_freq
== freq
) {
768 complete(&ar
->scan
.on_channel
);
771 case WMI_SCAN_EVENT_DEQUEUED
:
772 ath10k_dbg(ATH10K_DBG_WMI
, "SCAN_EVENT_DEQUEUED\n");
774 case WMI_SCAN_EVENT_PREEMPTED
:
775 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_SCAN_EVENT_PREEMPTED\n");
777 case WMI_SCAN_EVENT_START_FAILED
:
778 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_SCAN_EVENT_START_FAILED\n");
784 spin_unlock_bh(&ar
->data_lock
);
788 static inline enum ieee80211_band
phy_mode_to_band(u32 phy_mode
)
790 enum ieee80211_band band
;
796 case MODE_11AC_VHT20
:
797 case MODE_11AC_VHT40
:
798 case MODE_11AC_VHT80
:
799 band
= IEEE80211_BAND_5GHZ
;
806 case MODE_11AC_VHT20_2G
:
807 case MODE_11AC_VHT40_2G
:
808 case MODE_11AC_VHT80_2G
:
810 band
= IEEE80211_BAND_2GHZ
;
816 static inline u8
get_rate_idx(u32 rate
, enum ieee80211_band band
)
862 if (band
== IEEE80211_BAND_5GHZ
) {
873 static int ath10k_wmi_event_mgmt_rx(struct ath10k
*ar
, struct sk_buff
*skb
)
875 struct wmi_mgmt_rx_event_v1
*ev_v1
;
876 struct wmi_mgmt_rx_event_v2
*ev_v2
;
877 struct wmi_mgmt_rx_hdr_v1
*ev_hdr
;
878 struct ieee80211_rx_status
*status
= IEEE80211_SKB_RXCB(skb
);
879 struct ieee80211_channel
*ch
;
880 struct ieee80211_hdr
*hdr
;
890 if (test_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX
, ar
->fw_features
)) {
891 ev_v2
= (struct wmi_mgmt_rx_event_v2
*)skb
->data
;
892 ev_hdr
= &ev_v2
->hdr
.v1
;
893 pull_len
= sizeof(*ev_v2
);
895 ev_v1
= (struct wmi_mgmt_rx_event_v1
*)skb
->data
;
896 ev_hdr
= &ev_v1
->hdr
;
897 pull_len
= sizeof(*ev_v1
);
900 channel
= __le32_to_cpu(ev_hdr
->channel
);
901 buf_len
= __le32_to_cpu(ev_hdr
->buf_len
);
902 rx_status
= __le32_to_cpu(ev_hdr
->status
);
903 snr
= __le32_to_cpu(ev_hdr
->snr
);
904 phy_mode
= __le32_to_cpu(ev_hdr
->phy_mode
);
905 rate
= __le32_to_cpu(ev_hdr
->rate
);
907 memset(status
, 0, sizeof(*status
));
909 ath10k_dbg(ATH10K_DBG_MGMT
,
910 "event mgmt rx status %08x\n", rx_status
);
912 if (test_bit(ATH10K_CAC_RUNNING
, &ar
->dev_flags
)) {
917 if (rx_status
& WMI_RX_STATUS_ERR_DECRYPT
) {
922 if (rx_status
& WMI_RX_STATUS_ERR_KEY_CACHE_MISS
) {
927 if (rx_status
& WMI_RX_STATUS_ERR_CRC
)
928 status
->flag
|= RX_FLAG_FAILED_FCS_CRC
;
929 if (rx_status
& WMI_RX_STATUS_ERR_MIC
)
930 status
->flag
|= RX_FLAG_MMIC_ERROR
;
932 /* HW can Rx CCK rates on 5GHz. In that case phy_mode is set to
933 * MODE_11B. This means phy_mode is not a reliable source for the band
936 ch
= ar
->scan_channel
;
941 status
->band
= ch
->band
;
943 if (phy_mode
== MODE_11B
&&
944 status
->band
== IEEE80211_BAND_5GHZ
)
945 ath10k_dbg(ATH10K_DBG_MGMT
, "wmi mgmt rx 11b (CCK) on 5GHz\n");
947 ath10k_warn("using (unreliable) phy_mode to extract band for mgmt rx\n");
948 status
->band
= phy_mode_to_band(phy_mode
);
951 status
->freq
= ieee80211_channel_to_frequency(channel
, status
->band
);
952 status
->signal
= snr
+ ATH10K_DEFAULT_NOISE_FLOOR
;
953 status
->rate_idx
= get_rate_idx(rate
, status
->band
);
955 skb_pull(skb
, pull_len
);
957 hdr
= (struct ieee80211_hdr
*)skb
->data
;
958 fc
= le16_to_cpu(hdr
->frame_control
);
960 /* FW delivers WEP Shared Auth frame with Protected Bit set and
961 * encrypted payload. However in case of PMF it delivers decrypted
962 * frames with Protected Bit set. */
963 if (ieee80211_has_protected(hdr
->frame_control
) &&
964 !ieee80211_is_auth(hdr
->frame_control
)) {
965 status
->flag
|= RX_FLAG_DECRYPTED
| RX_FLAG_IV_STRIPPED
|
966 RX_FLAG_MMIC_STRIPPED
;
967 hdr
->frame_control
= __cpu_to_le16(fc
&
968 ~IEEE80211_FCTL_PROTECTED
);
971 ath10k_dbg(ATH10K_DBG_MGMT
,
972 "event mgmt rx skb %p len %d ftype %02x stype %02x\n",
974 fc
& IEEE80211_FCTL_FTYPE
, fc
& IEEE80211_FCTL_STYPE
);
976 ath10k_dbg(ATH10K_DBG_MGMT
,
977 "event mgmt rx freq %d band %d snr %d, rate_idx %d\n",
978 status
->freq
, status
->band
, status
->signal
,
982 * packets from HTC come aligned to 4byte boundaries
983 * because they can originally come in along with a trailer
985 skb_trim(skb
, buf_len
);
987 ieee80211_rx(ar
->hw
, skb
);
991 static int freq_to_idx(struct ath10k
*ar
, int freq
)
993 struct ieee80211_supported_band
*sband
;
994 int band
, ch
, idx
= 0;
996 for (band
= IEEE80211_BAND_2GHZ
; band
< IEEE80211_NUM_BANDS
; band
++) {
997 sband
= ar
->hw
->wiphy
->bands
[band
];
1001 for (ch
= 0; ch
< sband
->n_channels
; ch
++, idx
++)
1002 if (sband
->channels
[ch
].center_freq
== freq
)
1010 static void ath10k_wmi_event_chan_info(struct ath10k
*ar
, struct sk_buff
*skb
)
1012 struct wmi_chan_info_event
*ev
;
1013 struct survey_info
*survey
;
1014 u32 err_code
, freq
, cmd_flags
, noise_floor
, rx_clear_count
, cycle_count
;
1017 ev
= (struct wmi_chan_info_event
*)skb
->data
;
1019 err_code
= __le32_to_cpu(ev
->err_code
);
1020 freq
= __le32_to_cpu(ev
->freq
);
1021 cmd_flags
= __le32_to_cpu(ev
->cmd_flags
);
1022 noise_floor
= __le32_to_cpu(ev
->noise_floor
);
1023 rx_clear_count
= __le32_to_cpu(ev
->rx_clear_count
);
1024 cycle_count
= __le32_to_cpu(ev
->cycle_count
);
1026 ath10k_dbg(ATH10K_DBG_WMI
,
1027 "chan info err_code %d freq %d cmd_flags %d noise_floor %d rx_clear_count %d cycle_count %d\n",
1028 err_code
, freq
, cmd_flags
, noise_floor
, rx_clear_count
,
1031 spin_lock_bh(&ar
->data_lock
);
1033 if (!ar
->scan
.in_progress
) {
1034 ath10k_warn("chan info event without a scan request?\n");
1038 idx
= freq_to_idx(ar
, freq
);
1039 if (idx
>= ARRAY_SIZE(ar
->survey
)) {
1040 ath10k_warn("chan info: invalid frequency %d (idx %d out of bounds)\n",
1045 if (cmd_flags
& WMI_CHAN_INFO_FLAG_COMPLETE
) {
1046 /* During scanning chan info is reported twice for each
1047 * visited channel. The reported cycle count is global
1048 * and per-channel cycle count must be calculated */
1050 cycle_count
-= ar
->survey_last_cycle_count
;
1051 rx_clear_count
-= ar
->survey_last_rx_clear_count
;
1053 survey
= &ar
->survey
[idx
];
1054 survey
->channel_time
= WMI_CHAN_INFO_MSEC(cycle_count
);
1055 survey
->channel_time_rx
= WMI_CHAN_INFO_MSEC(rx_clear_count
);
1056 survey
->noise
= noise_floor
;
1057 survey
->filled
= SURVEY_INFO_CHANNEL_TIME
|
1058 SURVEY_INFO_CHANNEL_TIME_RX
|
1059 SURVEY_INFO_NOISE_DBM
;
1062 ar
->survey_last_rx_clear_count
= rx_clear_count
;
1063 ar
->survey_last_cycle_count
= cycle_count
;
1066 spin_unlock_bh(&ar
->data_lock
);
1069 static void ath10k_wmi_event_echo(struct ath10k
*ar
, struct sk_buff
*skb
)
1071 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_ECHO_EVENTID\n");
1074 static int ath10k_wmi_event_debug_mesg(struct ath10k
*ar
, struct sk_buff
*skb
)
1076 ath10k_dbg(ATH10K_DBG_WMI
, "wmi event debug mesg len %d\n",
1079 trace_ath10k_wmi_dbglog(skb
->data
, skb
->len
);
1084 static void ath10k_wmi_event_update_stats(struct ath10k
*ar
,
1085 struct sk_buff
*skb
)
1087 struct wmi_stats_event
*ev
= (struct wmi_stats_event
*)skb
->data
;
1089 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_UPDATE_STATS_EVENTID\n");
1091 ath10k_debug_read_target_stats(ar
, ev
);
1094 static void ath10k_wmi_event_vdev_start_resp(struct ath10k
*ar
,
1095 struct sk_buff
*skb
)
1097 struct wmi_vdev_start_response_event
*ev
;
1099 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_VDEV_START_RESP_EVENTID\n");
1101 ev
= (struct wmi_vdev_start_response_event
*)skb
->data
;
1103 if (WARN_ON(__le32_to_cpu(ev
->status
)))
1106 complete(&ar
->vdev_setup_done
);
1109 static void ath10k_wmi_event_vdev_stopped(struct ath10k
*ar
,
1110 struct sk_buff
*skb
)
1112 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_VDEV_STOPPED_EVENTID\n");
1113 complete(&ar
->vdev_setup_done
);
1116 static void ath10k_wmi_event_peer_sta_kickout(struct ath10k
*ar
,
1117 struct sk_buff
*skb
)
1119 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_PEER_STA_KICKOUT_EVENTID\n");
1125 * We don't report to mac80211 sleep state of connected
1126 * stations. Due to this mac80211 can't fill in TIM IE
1129 * I know of no way of getting nullfunc frames that contain
1130 * sleep transition from connected stations - these do not
1131 * seem to be sent from the target to the host. There also
1132 * doesn't seem to be a dedicated event for that. So the
1133 * only way left to do this would be to read tim_bitmap
1136 * We could probably try using tim_bitmap from SWBA to tell
1137 * mac80211 which stations are asleep and which are not. The
1138 * problem here is calling mac80211 functions so many times
1139 * could take too long and make us miss the time to submit
1140 * the beacon to the target.
1142 * So as a workaround we try to extend the TIM IE if there
1143 * is unicast buffered for stations with aid > 7 and fill it
1146 static void ath10k_wmi_update_tim(struct ath10k
*ar
,
1147 struct ath10k_vif
*arvif
,
1148 struct sk_buff
*bcn
,
1149 struct wmi_bcn_info
*bcn_info
)
1151 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)bcn
->data
;
1152 struct ieee80211_tim_ie
*tim
;
1156 /* if next SWBA has no tim_changed the tim_bitmap is garbage.
1157 * we must copy the bitmap upon change and reuse it later */
1158 if (__le32_to_cpu(bcn_info
->tim_info
.tim_changed
)) {
1161 BUILD_BUG_ON(sizeof(arvif
->u
.ap
.tim_bitmap
) !=
1162 sizeof(bcn_info
->tim_info
.tim_bitmap
));
1164 for (i
= 0; i
< sizeof(arvif
->u
.ap
.tim_bitmap
); i
++) {
1165 __le32 t
= bcn_info
->tim_info
.tim_bitmap
[i
/ 4];
1166 u32 v
= __le32_to_cpu(t
);
1167 arvif
->u
.ap
.tim_bitmap
[i
] = (v
>> ((i
% 4) * 8)) & 0xFF;
1170 /* FW reports either length 0 or 16
1171 * so we calculate this on our own */
1172 arvif
->u
.ap
.tim_len
= 0;
1173 for (i
= 0; i
< sizeof(arvif
->u
.ap
.tim_bitmap
); i
++)
1174 if (arvif
->u
.ap
.tim_bitmap
[i
])
1175 arvif
->u
.ap
.tim_len
= i
;
1177 arvif
->u
.ap
.tim_len
++;
1181 ies
+= ieee80211_hdrlen(hdr
->frame_control
);
1182 ies
+= 12; /* fixed parameters */
1184 ie
= (u8
*)cfg80211_find_ie(WLAN_EID_TIM
, ies
,
1185 (u8
*)skb_tail_pointer(bcn
) - ies
);
1187 if (arvif
->vdev_type
!= WMI_VDEV_TYPE_IBSS
)
1188 ath10k_warn("no tim ie found;\n");
1192 tim
= (void *)ie
+ 2;
1194 pvm_len
= ie_len
- 3; /* exclude dtim count, dtim period, bmap ctl */
1196 if (pvm_len
< arvif
->u
.ap
.tim_len
) {
1197 int expand_size
= sizeof(arvif
->u
.ap
.tim_bitmap
) - pvm_len
;
1198 int move_size
= skb_tail_pointer(bcn
) - (ie
+ 2 + ie_len
);
1199 void *next_ie
= ie
+ 2 + ie_len
;
1201 if (skb_put(bcn
, expand_size
)) {
1202 memmove(next_ie
+ expand_size
, next_ie
, move_size
);
1204 ie
[1] += expand_size
;
1205 ie_len
+= expand_size
;
1206 pvm_len
+= expand_size
;
1208 ath10k_warn("tim expansion failed\n");
1212 if (pvm_len
> sizeof(arvif
->u
.ap
.tim_bitmap
)) {
1213 ath10k_warn("tim pvm length is too great (%d)\n", pvm_len
);
1217 tim
->bitmap_ctrl
= !!__le32_to_cpu(bcn_info
->tim_info
.tim_mcast
);
1218 memcpy(tim
->virtual_map
, arvif
->u
.ap
.tim_bitmap
, pvm_len
);
1220 ath10k_dbg(ATH10K_DBG_MGMT
, "dtim %d/%d mcast %d pvmlen %d\n",
1221 tim
->dtim_count
, tim
->dtim_period
,
1222 tim
->bitmap_ctrl
, pvm_len
);
1225 static void ath10k_p2p_fill_noa_ie(u8
*data
, u32 len
,
1226 struct wmi_p2p_noa_info
*noa
)
1228 struct ieee80211_p2p_noa_attr
*noa_attr
;
1229 u8 ctwindow_oppps
= noa
->ctwindow_oppps
;
1230 u8 ctwindow
= ctwindow_oppps
>> WMI_P2P_OPPPS_CTWINDOW_OFFSET
;
1231 bool oppps
= !!(ctwindow_oppps
& WMI_P2P_OPPPS_ENABLE_BIT
);
1232 __le16
*noa_attr_len
;
1234 u8 noa_descriptors
= noa
->num_descriptors
;
1238 data
[0] = WLAN_EID_VENDOR_SPECIFIC
;
1240 data
[2] = (WLAN_OUI_WFA
>> 16) & 0xff;
1241 data
[3] = (WLAN_OUI_WFA
>> 8) & 0xff;
1242 data
[4] = (WLAN_OUI_WFA
>> 0) & 0xff;
1243 data
[5] = WLAN_OUI_TYPE_WFA_P2P
;
1246 data
[6] = IEEE80211_P2P_ATTR_ABSENCE_NOTICE
;
1247 noa_attr_len
= (__le16
*)&data
[7]; /* 2 bytes */
1248 noa_attr
= (struct ieee80211_p2p_noa_attr
*)&data
[9];
1250 noa_attr
->index
= noa
->index
;
1251 noa_attr
->oppps_ctwindow
= ctwindow
;
1253 noa_attr
->oppps_ctwindow
|= IEEE80211_P2P_OPPPS_ENABLE_BIT
;
1255 for (i
= 0; i
< noa_descriptors
; i
++) {
1256 noa_attr
->desc
[i
].count
=
1257 __le32_to_cpu(noa
->descriptors
[i
].type_count
);
1258 noa_attr
->desc
[i
].duration
= noa
->descriptors
[i
].duration
;
1259 noa_attr
->desc
[i
].interval
= noa
->descriptors
[i
].interval
;
1260 noa_attr
->desc
[i
].start_time
= noa
->descriptors
[i
].start_time
;
1263 attr_len
= 2; /* index + oppps_ctwindow */
1264 attr_len
+= noa_descriptors
* sizeof(struct ieee80211_p2p_noa_desc
);
1265 *noa_attr_len
= __cpu_to_le16(attr_len
);
1268 static u32
ath10k_p2p_calc_noa_ie_len(struct wmi_p2p_noa_info
*noa
)
1271 u8 noa_descriptors
= noa
->num_descriptors
;
1272 u8 opp_ps_info
= noa
->ctwindow_oppps
;
1273 bool opps_enabled
= !!(opp_ps_info
& WMI_P2P_OPPPS_ENABLE_BIT
);
1276 if (!noa_descriptors
&& !opps_enabled
)
1279 len
+= 1 + 1 + 4; /* EID + len + OUI */
1280 len
+= 1 + 2; /* noa attr + attr len */
1281 len
+= 1 + 1; /* index + oppps_ctwindow */
1282 len
+= noa_descriptors
* sizeof(struct ieee80211_p2p_noa_desc
);
1287 static void ath10k_wmi_update_noa(struct ath10k
*ar
, struct ath10k_vif
*arvif
,
1288 struct sk_buff
*bcn
,
1289 struct wmi_bcn_info
*bcn_info
)
1291 struct wmi_p2p_noa_info
*noa
= &bcn_info
->p2p_noa_info
;
1292 u8
*new_data
, *old_data
= arvif
->u
.ap
.noa_data
;
1295 if (arvif
->vdev_subtype
!= WMI_VDEV_SUBTYPE_P2P_GO
)
1298 ath10k_dbg(ATH10K_DBG_MGMT
, "noa changed: %d\n", noa
->changed
);
1299 if (noa
->changed
& WMI_P2P_NOA_CHANGED_BIT
) {
1300 new_len
= ath10k_p2p_calc_noa_ie_len(noa
);
1304 new_data
= kmalloc(new_len
, GFP_ATOMIC
);
1308 ath10k_p2p_fill_noa_ie(new_data
, new_len
, noa
);
1310 spin_lock_bh(&ar
->data_lock
);
1311 arvif
->u
.ap
.noa_data
= new_data
;
1312 arvif
->u
.ap
.noa_len
= new_len
;
1313 spin_unlock_bh(&ar
->data_lock
);
1317 if (arvif
->u
.ap
.noa_data
)
1318 if (!pskb_expand_head(bcn
, 0, arvif
->u
.ap
.noa_len
, GFP_ATOMIC
))
1319 memcpy(skb_put(bcn
, arvif
->u
.ap
.noa_len
),
1320 arvif
->u
.ap
.noa_data
,
1321 arvif
->u
.ap
.noa_len
);
1325 spin_lock_bh(&ar
->data_lock
);
1326 arvif
->u
.ap
.noa_data
= NULL
;
1327 arvif
->u
.ap
.noa_len
= 0;
1328 spin_unlock_bh(&ar
->data_lock
);
1333 static void ath10k_wmi_event_host_swba(struct ath10k
*ar
, struct sk_buff
*skb
)
1335 struct wmi_host_swba_event
*ev
;
1338 struct wmi_bcn_info
*bcn_info
;
1339 struct ath10k_vif
*arvif
;
1340 struct sk_buff
*bcn
;
1343 ath10k_dbg(ATH10K_DBG_MGMT
, "WMI_HOST_SWBA_EVENTID\n");
1345 ev
= (struct wmi_host_swba_event
*)skb
->data
;
1346 map
= __le32_to_cpu(ev
->vdev_map
);
1348 ath10k_dbg(ATH10K_DBG_MGMT
, "host swba:\n"
1352 for (; map
; map
>>= 1, vdev_id
++) {
1358 if (i
>= WMI_MAX_AP_VDEV
) {
1359 ath10k_warn("swba has corrupted vdev map\n");
1363 bcn_info
= &ev
->bcn_info
[i
];
1365 ath10k_dbg(ATH10K_DBG_MGMT
,
1369 "--tim_changed %d\n"
1370 "--tim_num_ps_pending %d\n"
1371 "--tim_bitmap 0x%08x%08x%08x%08x\n",
1373 __le32_to_cpu(bcn_info
->tim_info
.tim_len
),
1374 __le32_to_cpu(bcn_info
->tim_info
.tim_mcast
),
1375 __le32_to_cpu(bcn_info
->tim_info
.tim_changed
),
1376 __le32_to_cpu(bcn_info
->tim_info
.tim_num_ps_pending
),
1377 __le32_to_cpu(bcn_info
->tim_info
.tim_bitmap
[3]),
1378 __le32_to_cpu(bcn_info
->tim_info
.tim_bitmap
[2]),
1379 __le32_to_cpu(bcn_info
->tim_info
.tim_bitmap
[1]),
1380 __le32_to_cpu(bcn_info
->tim_info
.tim_bitmap
[0]));
1382 arvif
= ath10k_get_arvif(ar
, vdev_id
);
1383 if (arvif
== NULL
) {
1384 ath10k_warn("no vif for vdev_id %d found\n", vdev_id
);
1388 bcn
= ieee80211_beacon_get(ar
->hw
, arvif
->vif
);
1390 ath10k_warn("could not get mac80211 beacon\n");
1394 ath10k_tx_h_seq_no(bcn
);
1395 ath10k_wmi_update_tim(ar
, arvif
, bcn
, bcn_info
);
1396 ath10k_wmi_update_noa(ar
, arvif
, bcn
, bcn_info
);
1398 spin_lock_bh(&ar
->data_lock
);
1399 if (arvif
->beacon
) {
1400 ath10k_warn("SWBA overrun on vdev %d\n",
1402 dev_kfree_skb_any(arvif
->beacon
);
1405 arvif
->beacon
= bcn
;
1407 ath10k_wmi_tx_beacon_nowait(arvif
);
1408 spin_unlock_bh(&ar
->data_lock
);
1412 static void ath10k_wmi_event_tbttoffset_update(struct ath10k
*ar
,
1413 struct sk_buff
*skb
)
1415 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_TBTTOFFSET_UPDATE_EVENTID\n");
1418 static void ath10k_dfs_radar_report(struct ath10k
*ar
,
1419 struct wmi_single_phyerr_rx_event
*event
,
1420 struct phyerr_radar_report
*rr
,
1423 u32 reg0
, reg1
, tsf32l
;
1424 struct pulse_event pe
;
1428 reg0
= __le32_to_cpu(rr
->reg0
);
1429 reg1
= __le32_to_cpu(rr
->reg1
);
1431 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1432 "wmi phyerr radar report chirp %d max_width %d agc_total_gain %d pulse_delta_diff %d\n",
1433 MS(reg0
, RADAR_REPORT_REG0_PULSE_IS_CHIRP
),
1434 MS(reg0
, RADAR_REPORT_REG0_PULSE_IS_MAX_WIDTH
),
1435 MS(reg0
, RADAR_REPORT_REG0_AGC_TOTAL_GAIN
),
1436 MS(reg0
, RADAR_REPORT_REG0_PULSE_DELTA_DIFF
));
1437 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1438 "wmi phyerr radar report pulse_delta_pean %d pulse_sidx %d fft_valid %d agc_mb_gain %d subchan_mask %d\n",
1439 MS(reg0
, RADAR_REPORT_REG0_PULSE_DELTA_PEAK
),
1440 MS(reg0
, RADAR_REPORT_REG0_PULSE_SIDX
),
1441 MS(reg1
, RADAR_REPORT_REG1_PULSE_SRCH_FFT_VALID
),
1442 MS(reg1
, RADAR_REPORT_REG1_PULSE_AGC_MB_GAIN
),
1443 MS(reg1
, RADAR_REPORT_REG1_PULSE_SUBCHAN_MASK
));
1444 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1445 "wmi phyerr radar report pulse_tsf_offset 0x%X pulse_dur: %d\n",
1446 MS(reg1
, RADAR_REPORT_REG1_PULSE_TSF_OFFSET
),
1447 MS(reg1
, RADAR_REPORT_REG1_PULSE_DUR
));
1449 if (!ar
->dfs_detector
)
1452 /* report event to DFS pattern detector */
1453 tsf32l
= __le32_to_cpu(event
->hdr
.tsf_timestamp
);
1454 tsf64
= tsf
& (~0xFFFFFFFFULL
);
1457 width
= MS(reg1
, RADAR_REPORT_REG1_PULSE_DUR
);
1458 rssi
= event
->hdr
.rssi_combined
;
1460 /* hardware store this as 8 bit signed value,
1461 * set to zero if negative number
1467 pe
.freq
= ar
->hw
->conf
.chandef
.chan
->center_freq
;
1471 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1472 "dfs add pulse freq: %d, width: %d, rssi %d, tsf: %llX\n",
1473 pe
.freq
, pe
.width
, pe
.rssi
, pe
.ts
);
1475 ATH10K_DFS_STAT_INC(ar
, pulses_detected
);
1477 if (!ar
->dfs_detector
->add_pulse(ar
->dfs_detector
, &pe
)) {
1478 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1479 "dfs no pulse pattern detected, yet\n");
1483 ath10k_dbg(ATH10K_DBG_REGULATORY
, "dfs radar detected\n");
1484 ATH10K_DFS_STAT_INC(ar
, radar_detected
);
1486 /* Control radar events reporting in debugfs file
1487 dfs_block_radar_events */
1488 if (ar
->dfs_block_radar_events
) {
1489 ath10k_info("DFS Radar detected, but ignored as requested\n");
1493 ieee80211_radar_detected(ar
->hw
);
1496 static int ath10k_dfs_fft_report(struct ath10k
*ar
,
1497 struct wmi_single_phyerr_rx_event
*event
,
1498 struct phyerr_fft_report
*fftr
,
1504 reg0
= __le32_to_cpu(fftr
->reg0
);
1505 reg1
= __le32_to_cpu(fftr
->reg1
);
1506 rssi
= event
->hdr
.rssi_combined
;
1508 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1509 "wmi phyerr fft report total_gain_db %d base_pwr_db %d fft_chn_idx %d peak_sidx %d\n",
1510 MS(reg0
, SEARCH_FFT_REPORT_REG0_TOTAL_GAIN_DB
),
1511 MS(reg0
, SEARCH_FFT_REPORT_REG0_BASE_PWR_DB
),
1512 MS(reg0
, SEARCH_FFT_REPORT_REG0_FFT_CHN_IDX
),
1513 MS(reg0
, SEARCH_FFT_REPORT_REG0_PEAK_SIDX
));
1514 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1515 "wmi phyerr fft report rel_pwr_db %d avgpwr_db %d peak_mag %d num_store_bin %d\n",
1516 MS(reg1
, SEARCH_FFT_REPORT_REG1_RELPWR_DB
),
1517 MS(reg1
, SEARCH_FFT_REPORT_REG1_AVGPWR_DB
),
1518 MS(reg1
, SEARCH_FFT_REPORT_REG1_PEAK_MAG
),
1519 MS(reg1
, SEARCH_FFT_REPORT_REG1_NUM_STR_BINS_IB
));
1521 peak_mag
= MS(reg1
, SEARCH_FFT_REPORT_REG1_PEAK_MAG
);
1523 /* false event detection */
1524 if (rssi
== DFS_RSSI_POSSIBLY_FALSE
&&
1525 peak_mag
< 2 * DFS_PEAK_MAG_THOLD_POSSIBLY_FALSE
) {
1526 ath10k_dbg(ATH10K_DBG_REGULATORY
, "dfs false pulse detected\n");
1527 ATH10K_DFS_STAT_INC(ar
, pulses_discarded
);
1534 static void ath10k_wmi_event_dfs(struct ath10k
*ar
,
1535 struct wmi_single_phyerr_rx_event
*event
,
1538 int buf_len
, tlv_len
, res
, i
= 0;
1539 struct phyerr_tlv
*tlv
;
1540 struct phyerr_radar_report
*rr
;
1541 struct phyerr_fft_report
*fftr
;
1544 buf_len
= __le32_to_cpu(event
->hdr
.buf_len
);
1545 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1546 "wmi event dfs err_code %d rssi %d tsfl 0x%X tsf64 0x%llX len %d\n",
1547 event
->hdr
.phy_err_code
, event
->hdr
.rssi_combined
,
1548 __le32_to_cpu(event
->hdr
.tsf_timestamp
), tsf
, buf_len
);
1550 /* Skip event if DFS disabled */
1551 if (!config_enabled(CONFIG_ATH10K_DFS_CERTIFIED
))
1554 ATH10K_DFS_STAT_INC(ar
, pulses_total
);
1556 while (i
< buf_len
) {
1557 if (i
+ sizeof(*tlv
) > buf_len
) {
1558 ath10k_warn("too short buf for tlv header (%d)\n", i
);
1562 tlv
= (struct phyerr_tlv
*)&event
->bufp
[i
];
1563 tlv_len
= __le16_to_cpu(tlv
->len
);
1564 tlv_buf
= &event
->bufp
[i
+ sizeof(*tlv
)];
1565 ath10k_dbg(ATH10K_DBG_REGULATORY
,
1566 "wmi event dfs tlv_len %d tlv_tag 0x%02X tlv_sig 0x%02X\n",
1567 tlv_len
, tlv
->tag
, tlv
->sig
);
1570 case PHYERR_TLV_TAG_RADAR_PULSE_SUMMARY
:
1571 if (i
+ sizeof(*tlv
) + sizeof(*rr
) > buf_len
) {
1572 ath10k_warn("too short radar pulse summary (%d)\n",
1577 rr
= (struct phyerr_radar_report
*)tlv_buf
;
1578 ath10k_dfs_radar_report(ar
, event
, rr
, tsf
);
1580 case PHYERR_TLV_TAG_SEARCH_FFT_REPORT
:
1581 if (i
+ sizeof(*tlv
) + sizeof(*fftr
) > buf_len
) {
1582 ath10k_warn("too short fft report (%d)\n", i
);
1586 fftr
= (struct phyerr_fft_report
*)tlv_buf
;
1587 res
= ath10k_dfs_fft_report(ar
, event
, fftr
, tsf
);
1593 i
+= sizeof(*tlv
) + tlv_len
;
1597 static void ath10k_wmi_event_spectral_scan(struct ath10k
*ar
,
1598 struct wmi_single_phyerr_rx_event
*event
,
1601 ath10k_dbg(ATH10K_DBG_WMI
, "wmi event spectral scan\n");
1604 static void ath10k_wmi_event_phyerr(struct ath10k
*ar
, struct sk_buff
*skb
)
1606 struct wmi_comb_phyerr_rx_event
*comb_event
;
1607 struct wmi_single_phyerr_rx_event
*event
;
1608 u32 count
, i
, buf_len
, phy_err_code
;
1610 int left_len
= skb
->len
;
1612 ATH10K_DFS_STAT_INC(ar
, phy_errors
);
1614 /* Check if combined event available */
1615 if (left_len
< sizeof(*comb_event
)) {
1616 ath10k_warn("wmi phyerr combined event wrong len\n");
1620 left_len
-= sizeof(*comb_event
);
1622 /* Check number of included events */
1623 comb_event
= (struct wmi_comb_phyerr_rx_event
*)skb
->data
;
1624 count
= __le32_to_cpu(comb_event
->hdr
.num_phyerr_events
);
1626 tsf
= __le32_to_cpu(comb_event
->hdr
.tsf_u32
);
1628 tsf
|= __le32_to_cpu(comb_event
->hdr
.tsf_l32
);
1630 ath10k_dbg(ATH10K_DBG_WMI
,
1631 "wmi event phyerr count %d tsf64 0x%llX\n",
1634 event
= (struct wmi_single_phyerr_rx_event
*)comb_event
->bufp
;
1635 for (i
= 0; i
< count
; i
++) {
1636 /* Check if we can read event header */
1637 if (left_len
< sizeof(*event
)) {
1638 ath10k_warn("single event (%d) wrong head len\n", i
);
1642 left_len
-= sizeof(*event
);
1644 buf_len
= __le32_to_cpu(event
->hdr
.buf_len
);
1645 phy_err_code
= event
->hdr
.phy_err_code
;
1647 if (left_len
< buf_len
) {
1648 ath10k_warn("single event (%d) wrong buf len\n", i
);
1652 left_len
-= buf_len
;
1654 switch (phy_err_code
) {
1655 case PHY_ERROR_RADAR
:
1656 ath10k_wmi_event_dfs(ar
, event
, tsf
);
1658 case PHY_ERROR_SPECTRAL_SCAN
:
1659 ath10k_wmi_event_spectral_scan(ar
, event
, tsf
);
1661 case PHY_ERROR_FALSE_RADAR_EXT
:
1662 ath10k_wmi_event_dfs(ar
, event
, tsf
);
1663 ath10k_wmi_event_spectral_scan(ar
, event
, tsf
);
1669 event
+= sizeof(*event
) + buf_len
;
1673 static void ath10k_wmi_event_roam(struct ath10k
*ar
, struct sk_buff
*skb
)
1675 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_ROAM_EVENTID\n");
1678 static void ath10k_wmi_event_profile_match(struct ath10k
*ar
,
1679 struct sk_buff
*skb
)
1681 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_PROFILE_MATCH\n");
1684 static void ath10k_wmi_event_debug_print(struct ath10k
*ar
,
1685 struct sk_buff
*skb
)
1690 for (i
= 0; i
< sizeof(buf
) - 1; i
++) {
1699 if (isascii(c
) && isprint(c
))
1705 if (i
== sizeof(buf
) - 1)
1706 ath10k_warn("wmi debug print truncated: %d\n", skb
->len
);
1708 /* for some reason the debug prints end with \n, remove that */
1709 if (skb
->data
[i
- 1] == '\n')
1712 /* the last byte is always reserved for the null character */
1715 ath10k_dbg(ATH10K_DBG_WMI
, "wmi event debug print '%s'\n", buf
);
1718 static void ath10k_wmi_event_pdev_qvit(struct ath10k
*ar
, struct sk_buff
*skb
)
1720 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_PDEV_QVIT_EVENTID\n");
1723 static void ath10k_wmi_event_wlan_profile_data(struct ath10k
*ar
,
1724 struct sk_buff
*skb
)
1726 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_WLAN_PROFILE_DATA_EVENTID\n");
1729 static void ath10k_wmi_event_rtt_measurement_report(struct ath10k
*ar
,
1730 struct sk_buff
*skb
)
1732 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_RTT_MEASUREMENT_REPORT_EVENTID\n");
1735 static void ath10k_wmi_event_tsf_measurement_report(struct ath10k
*ar
,
1736 struct sk_buff
*skb
)
1738 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_TSF_MEASUREMENT_REPORT_EVENTID\n");
1741 static void ath10k_wmi_event_rtt_error_report(struct ath10k
*ar
,
1742 struct sk_buff
*skb
)
1744 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_RTT_ERROR_REPORT_EVENTID\n");
1747 static void ath10k_wmi_event_wow_wakeup_host(struct ath10k
*ar
,
1748 struct sk_buff
*skb
)
1750 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_WOW_WAKEUP_HOST_EVENTID\n");
1753 static void ath10k_wmi_event_dcs_interference(struct ath10k
*ar
,
1754 struct sk_buff
*skb
)
1756 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_DCS_INTERFERENCE_EVENTID\n");
1759 static void ath10k_wmi_event_pdev_tpc_config(struct ath10k
*ar
,
1760 struct sk_buff
*skb
)
1762 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_PDEV_TPC_CONFIG_EVENTID\n");
1765 static void ath10k_wmi_event_pdev_ftm_intg(struct ath10k
*ar
,
1766 struct sk_buff
*skb
)
1768 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_PDEV_FTM_INTG_EVENTID\n");
1771 static void ath10k_wmi_event_gtk_offload_status(struct ath10k
*ar
,
1772 struct sk_buff
*skb
)
1774 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_GTK_OFFLOAD_STATUS_EVENTID\n");
1777 static void ath10k_wmi_event_gtk_rekey_fail(struct ath10k
*ar
,
1778 struct sk_buff
*skb
)
1780 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_GTK_REKEY_FAIL_EVENTID\n");
1783 static void ath10k_wmi_event_delba_complete(struct ath10k
*ar
,
1784 struct sk_buff
*skb
)
1786 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_TX_DELBA_COMPLETE_EVENTID\n");
1789 static void ath10k_wmi_event_addba_complete(struct ath10k
*ar
,
1790 struct sk_buff
*skb
)
1792 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_TX_ADDBA_COMPLETE_EVENTID\n");
1795 static void ath10k_wmi_event_vdev_install_key_complete(struct ath10k
*ar
,
1796 struct sk_buff
*skb
)
1798 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID\n");
1801 static void ath10k_wmi_event_inst_rssi_stats(struct ath10k
*ar
,
1802 struct sk_buff
*skb
)
1804 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_INST_RSSI_STATS_EVENTID\n");
1807 static void ath10k_wmi_event_vdev_standby_req(struct ath10k
*ar
,
1808 struct sk_buff
*skb
)
1810 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_VDEV_STANDBY_REQ_EVENTID\n");
1813 static void ath10k_wmi_event_vdev_resume_req(struct ath10k
*ar
,
1814 struct sk_buff
*skb
)
1816 ath10k_dbg(ATH10K_DBG_WMI
, "WMI_VDEV_RESUME_REQ_EVENTID\n");
1819 static int ath10k_wmi_alloc_host_mem(struct ath10k
*ar
, u32 req_id
,
1820 u32 num_units
, u32 unit_len
)
1824 int idx
= ar
->wmi
.num_mem_chunks
;
1826 pool_size
= num_units
* round_up(unit_len
, 4);
1831 ar
->wmi
.mem_chunks
[idx
].vaddr
= dma_alloc_coherent(ar
->dev
,
1835 if (!ar
->wmi
.mem_chunks
[idx
].vaddr
) {
1836 ath10k_warn("failed to allocate memory chunk\n");
1840 memset(ar
->wmi
.mem_chunks
[idx
].vaddr
, 0, pool_size
);
1842 ar
->wmi
.mem_chunks
[idx
].paddr
= paddr
;
1843 ar
->wmi
.mem_chunks
[idx
].len
= pool_size
;
1844 ar
->wmi
.mem_chunks
[idx
].req_id
= req_id
;
1845 ar
->wmi
.num_mem_chunks
++;
1850 static void ath10k_wmi_service_ready_event_rx(struct ath10k
*ar
,
1851 struct sk_buff
*skb
)
1853 struct wmi_service_ready_event
*ev
= (void *)skb
->data
;
1855 if (skb
->len
< sizeof(*ev
)) {
1856 ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
1857 skb
->len
, sizeof(*ev
));
1861 ar
->hw_min_tx_power
= __le32_to_cpu(ev
->hw_min_tx_power
);
1862 ar
->hw_max_tx_power
= __le32_to_cpu(ev
->hw_max_tx_power
);
1863 ar
->ht_cap_info
= __le32_to_cpu(ev
->ht_cap_info
);
1864 ar
->vht_cap_info
= __le32_to_cpu(ev
->vht_cap_info
);
1865 ar
->fw_version_major
=
1866 (__le32_to_cpu(ev
->sw_version
) & 0xff000000) >> 24;
1867 ar
->fw_version_minor
= (__le32_to_cpu(ev
->sw_version
) & 0x00ffffff);
1868 ar
->fw_version_release
=
1869 (__le32_to_cpu(ev
->sw_version_1
) & 0xffff0000) >> 16;
1870 ar
->fw_version_build
= (__le32_to_cpu(ev
->sw_version_1
) & 0x0000ffff);
1871 ar
->phy_capability
= __le32_to_cpu(ev
->phy_capability
);
1872 ar
->num_rf_chains
= __le32_to_cpu(ev
->num_rf_chains
);
1874 /* only manually set fw features when not using FW IE format */
1875 if (ar
->fw_api
== 1 && ar
->fw_version_build
> 636)
1876 set_bit(ATH10K_FW_FEATURE_EXT_WMI_MGMT_RX
, ar
->fw_features
);
1878 if (ar
->num_rf_chains
> WMI_MAX_SPATIAL_STREAM
) {
1879 ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n",
1880 ar
->num_rf_chains
, WMI_MAX_SPATIAL_STREAM
);
1881 ar
->num_rf_chains
= WMI_MAX_SPATIAL_STREAM
;
1884 ar
->ath_common
.regulatory
.current_rd
=
1885 __le32_to_cpu(ev
->hal_reg_capabilities
.eeprom_rd
);
1887 ath10k_debug_read_service_map(ar
, ev
->wmi_service_bitmap
,
1888 sizeof(ev
->wmi_service_bitmap
));
1890 if (strlen(ar
->hw
->wiphy
->fw_version
) == 0) {
1891 snprintf(ar
->hw
->wiphy
->fw_version
,
1892 sizeof(ar
->hw
->wiphy
->fw_version
),
1894 ar
->fw_version_major
,
1895 ar
->fw_version_minor
,
1896 ar
->fw_version_release
,
1897 ar
->fw_version_build
);
1900 /* FIXME: it probably should be better to support this */
1901 if (__le32_to_cpu(ev
->num_mem_reqs
) > 0) {
1902 ath10k_warn("target requested %d memory chunks; ignoring\n",
1903 __le32_to_cpu(ev
->num_mem_reqs
));
1906 ath10k_dbg(ATH10K_DBG_WMI
,
1907 "wmi event service ready sw_ver 0x%08x sw_ver1 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n",
1908 __le32_to_cpu(ev
->sw_version
),
1909 __le32_to_cpu(ev
->sw_version_1
),
1910 __le32_to_cpu(ev
->abi_version
),
1911 __le32_to_cpu(ev
->phy_capability
),
1912 __le32_to_cpu(ev
->ht_cap_info
),
1913 __le32_to_cpu(ev
->vht_cap_info
),
1914 __le32_to_cpu(ev
->vht_supp_mcs
),
1915 __le32_to_cpu(ev
->sys_cap_info
),
1916 __le32_to_cpu(ev
->num_mem_reqs
),
1917 __le32_to_cpu(ev
->num_rf_chains
));
1919 complete(&ar
->wmi
.service_ready
);
1922 static void ath10k_wmi_10x_service_ready_event_rx(struct ath10k
*ar
,
1923 struct sk_buff
*skb
)
1925 u32 num_units
, req_id
, unit_size
, num_mem_reqs
, num_unit_info
, i
;
1927 struct wmi_service_ready_event_10x
*ev
= (void *)skb
->data
;
1929 if (skb
->len
< sizeof(*ev
)) {
1930 ath10k_warn("Service ready event was %d B but expected %zu B. Wrong firmware version?\n",
1931 skb
->len
, sizeof(*ev
));
1935 ar
->hw_min_tx_power
= __le32_to_cpu(ev
->hw_min_tx_power
);
1936 ar
->hw_max_tx_power
= __le32_to_cpu(ev
->hw_max_tx_power
);
1937 ar
->ht_cap_info
= __le32_to_cpu(ev
->ht_cap_info
);
1938 ar
->vht_cap_info
= __le32_to_cpu(ev
->vht_cap_info
);
1939 ar
->fw_version_major
=
1940 (__le32_to_cpu(ev
->sw_version
) & 0xff000000) >> 24;
1941 ar
->fw_version_minor
= (__le32_to_cpu(ev
->sw_version
) & 0x00ffffff);
1942 ar
->phy_capability
= __le32_to_cpu(ev
->phy_capability
);
1943 ar
->num_rf_chains
= __le32_to_cpu(ev
->num_rf_chains
);
1945 if (ar
->num_rf_chains
> WMI_MAX_SPATIAL_STREAM
) {
1946 ath10k_warn("hardware advertises support for more spatial streams than it should (%d > %d)\n",
1947 ar
->num_rf_chains
, WMI_MAX_SPATIAL_STREAM
);
1948 ar
->num_rf_chains
= WMI_MAX_SPATIAL_STREAM
;
1951 ar
->ath_common
.regulatory
.current_rd
=
1952 __le32_to_cpu(ev
->hal_reg_capabilities
.eeprom_rd
);
1954 ath10k_debug_read_service_map(ar
, ev
->wmi_service_bitmap
,
1955 sizeof(ev
->wmi_service_bitmap
));
1957 if (strlen(ar
->hw
->wiphy
->fw_version
) == 0) {
1958 snprintf(ar
->hw
->wiphy
->fw_version
,
1959 sizeof(ar
->hw
->wiphy
->fw_version
),
1961 ar
->fw_version_major
,
1962 ar
->fw_version_minor
);
1965 num_mem_reqs
= __le32_to_cpu(ev
->num_mem_reqs
);
1967 if (num_mem_reqs
> ATH10K_MAX_MEM_REQS
) {
1968 ath10k_warn("requested memory chunks number (%d) exceeds the limit\n",
1976 ath10k_dbg(ATH10K_DBG_WMI
, "firmware has requested %d memory chunks\n",
1979 for (i
= 0; i
< num_mem_reqs
; ++i
) {
1980 req_id
= __le32_to_cpu(ev
->mem_reqs
[i
].req_id
);
1981 num_units
= __le32_to_cpu(ev
->mem_reqs
[i
].num_units
);
1982 unit_size
= __le32_to_cpu(ev
->mem_reqs
[i
].unit_size
);
1983 num_unit_info
= __le32_to_cpu(ev
->mem_reqs
[i
].num_unit_info
);
1985 if (num_unit_info
& NUM_UNITS_IS_NUM_PEERS
)
1986 /* number of units to allocate is number of
1987 * peers, 1 extra for self peer on target */
1988 /* this needs to be tied, host and target
1989 * can get out of sync */
1990 num_units
= TARGET_10X_NUM_PEERS
+ 1;
1991 else if (num_unit_info
& NUM_UNITS_IS_NUM_VDEVS
)
1992 num_units
= TARGET_10X_NUM_VDEVS
+ 1;
1994 ath10k_dbg(ATH10K_DBG_WMI
,
1995 "wmi mem_req_id %d num_units %d num_unit_info %d unit size %d actual units %d\n",
1997 __le32_to_cpu(ev
->mem_reqs
[i
].num_units
),
2002 ret
= ath10k_wmi_alloc_host_mem(ar
, req_id
, num_units
,
2009 ath10k_dbg(ATH10K_DBG_WMI
,
2010 "wmi event service ready sw_ver 0x%08x abi_ver %u phy_cap 0x%08x ht_cap 0x%08x vht_cap 0x%08x vht_supp_msc 0x%08x sys_cap_info 0x%08x mem_reqs %u num_rf_chains %u\n",
2011 __le32_to_cpu(ev
->sw_version
),
2012 __le32_to_cpu(ev
->abi_version
),
2013 __le32_to_cpu(ev
->phy_capability
),
2014 __le32_to_cpu(ev
->ht_cap_info
),
2015 __le32_to_cpu(ev
->vht_cap_info
),
2016 __le32_to_cpu(ev
->vht_supp_mcs
),
2017 __le32_to_cpu(ev
->sys_cap_info
),
2018 __le32_to_cpu(ev
->num_mem_reqs
),
2019 __le32_to_cpu(ev
->num_rf_chains
));
2021 complete(&ar
->wmi
.service_ready
);
2024 static int ath10k_wmi_ready_event_rx(struct ath10k
*ar
, struct sk_buff
*skb
)
2026 struct wmi_ready_event
*ev
= (struct wmi_ready_event
*)skb
->data
;
2028 if (WARN_ON(skb
->len
< sizeof(*ev
)))
2031 memcpy(ar
->mac_addr
, ev
->mac_addr
.addr
, ETH_ALEN
);
2033 ath10k_dbg(ATH10K_DBG_WMI
,
2034 "wmi event ready sw_version %u abi_version %u mac_addr %pM status %d\n",
2035 __le32_to_cpu(ev
->sw_version
),
2036 __le32_to_cpu(ev
->abi_version
),
2038 __le32_to_cpu(ev
->status
));
2040 complete(&ar
->wmi
.unified_ready
);
2044 static void ath10k_wmi_main_process_rx(struct ath10k
*ar
, struct sk_buff
*skb
)
2046 struct wmi_cmd_hdr
*cmd_hdr
;
2047 enum wmi_event_id id
;
2050 cmd_hdr
= (struct wmi_cmd_hdr
*)skb
->data
;
2051 id
= MS(__le32_to_cpu(cmd_hdr
->cmd_id
), WMI_CMD_HDR_CMD_ID
);
2053 if (skb_pull(skb
, sizeof(struct wmi_cmd_hdr
)) == NULL
)
2058 trace_ath10k_wmi_event(id
, skb
->data
, skb
->len
);
2061 case WMI_MGMT_RX_EVENTID
:
2062 ath10k_wmi_event_mgmt_rx(ar
, skb
);
2063 /* mgmt_rx() owns the skb now! */
2065 case WMI_SCAN_EVENTID
:
2066 ath10k_wmi_event_scan(ar
, skb
);
2068 case WMI_CHAN_INFO_EVENTID
:
2069 ath10k_wmi_event_chan_info(ar
, skb
);
2071 case WMI_ECHO_EVENTID
:
2072 ath10k_wmi_event_echo(ar
, skb
);
2074 case WMI_DEBUG_MESG_EVENTID
:
2075 ath10k_wmi_event_debug_mesg(ar
, skb
);
2077 case WMI_UPDATE_STATS_EVENTID
:
2078 ath10k_wmi_event_update_stats(ar
, skb
);
2080 case WMI_VDEV_START_RESP_EVENTID
:
2081 ath10k_wmi_event_vdev_start_resp(ar
, skb
);
2083 case WMI_VDEV_STOPPED_EVENTID
:
2084 ath10k_wmi_event_vdev_stopped(ar
, skb
);
2086 case WMI_PEER_STA_KICKOUT_EVENTID
:
2087 ath10k_wmi_event_peer_sta_kickout(ar
, skb
);
2089 case WMI_HOST_SWBA_EVENTID
:
2090 ath10k_wmi_event_host_swba(ar
, skb
);
2092 case WMI_TBTTOFFSET_UPDATE_EVENTID
:
2093 ath10k_wmi_event_tbttoffset_update(ar
, skb
);
2095 case WMI_PHYERR_EVENTID
:
2096 ath10k_wmi_event_phyerr(ar
, skb
);
2098 case WMI_ROAM_EVENTID
:
2099 ath10k_wmi_event_roam(ar
, skb
);
2101 case WMI_PROFILE_MATCH
:
2102 ath10k_wmi_event_profile_match(ar
, skb
);
2104 case WMI_DEBUG_PRINT_EVENTID
:
2105 ath10k_wmi_event_debug_print(ar
, skb
);
2107 case WMI_PDEV_QVIT_EVENTID
:
2108 ath10k_wmi_event_pdev_qvit(ar
, skb
);
2110 case WMI_WLAN_PROFILE_DATA_EVENTID
:
2111 ath10k_wmi_event_wlan_profile_data(ar
, skb
);
2113 case WMI_RTT_MEASUREMENT_REPORT_EVENTID
:
2114 ath10k_wmi_event_rtt_measurement_report(ar
, skb
);
2116 case WMI_TSF_MEASUREMENT_REPORT_EVENTID
:
2117 ath10k_wmi_event_tsf_measurement_report(ar
, skb
);
2119 case WMI_RTT_ERROR_REPORT_EVENTID
:
2120 ath10k_wmi_event_rtt_error_report(ar
, skb
);
2122 case WMI_WOW_WAKEUP_HOST_EVENTID
:
2123 ath10k_wmi_event_wow_wakeup_host(ar
, skb
);
2125 case WMI_DCS_INTERFERENCE_EVENTID
:
2126 ath10k_wmi_event_dcs_interference(ar
, skb
);
2128 case WMI_PDEV_TPC_CONFIG_EVENTID
:
2129 ath10k_wmi_event_pdev_tpc_config(ar
, skb
);
2131 case WMI_PDEV_FTM_INTG_EVENTID
:
2132 ath10k_wmi_event_pdev_ftm_intg(ar
, skb
);
2134 case WMI_GTK_OFFLOAD_STATUS_EVENTID
:
2135 ath10k_wmi_event_gtk_offload_status(ar
, skb
);
2137 case WMI_GTK_REKEY_FAIL_EVENTID
:
2138 ath10k_wmi_event_gtk_rekey_fail(ar
, skb
);
2140 case WMI_TX_DELBA_COMPLETE_EVENTID
:
2141 ath10k_wmi_event_delba_complete(ar
, skb
);
2143 case WMI_TX_ADDBA_COMPLETE_EVENTID
:
2144 ath10k_wmi_event_addba_complete(ar
, skb
);
2146 case WMI_VDEV_INSTALL_KEY_COMPLETE_EVENTID
:
2147 ath10k_wmi_event_vdev_install_key_complete(ar
, skb
);
2149 case WMI_SERVICE_READY_EVENTID
:
2150 ath10k_wmi_service_ready_event_rx(ar
, skb
);
2152 case WMI_READY_EVENTID
:
2153 ath10k_wmi_ready_event_rx(ar
, skb
);
2156 ath10k_warn("Unknown eventid: %d\n", id
);
2163 static void ath10k_wmi_10x_process_rx(struct ath10k
*ar
, struct sk_buff
*skb
)
2165 struct wmi_cmd_hdr
*cmd_hdr
;
2166 enum wmi_10x_event_id id
;
2169 cmd_hdr
= (struct wmi_cmd_hdr
*)skb
->data
;
2170 id
= MS(__le32_to_cpu(cmd_hdr
->cmd_id
), WMI_CMD_HDR_CMD_ID
);
2172 if (skb_pull(skb
, sizeof(struct wmi_cmd_hdr
)) == NULL
)
2177 trace_ath10k_wmi_event(id
, skb
->data
, skb
->len
);
2180 case WMI_10X_MGMT_RX_EVENTID
:
2181 ath10k_wmi_event_mgmt_rx(ar
, skb
);
2182 /* mgmt_rx() owns the skb now! */
2184 case WMI_10X_SCAN_EVENTID
:
2185 ath10k_wmi_event_scan(ar
, skb
);
2187 case WMI_10X_CHAN_INFO_EVENTID
:
2188 ath10k_wmi_event_chan_info(ar
, skb
);
2190 case WMI_10X_ECHO_EVENTID
:
2191 ath10k_wmi_event_echo(ar
, skb
);
2193 case WMI_10X_DEBUG_MESG_EVENTID
:
2194 ath10k_wmi_event_debug_mesg(ar
, skb
);
2196 case WMI_10X_UPDATE_STATS_EVENTID
:
2197 ath10k_wmi_event_update_stats(ar
, skb
);
2199 case WMI_10X_VDEV_START_RESP_EVENTID
:
2200 ath10k_wmi_event_vdev_start_resp(ar
, skb
);
2202 case WMI_10X_VDEV_STOPPED_EVENTID
:
2203 ath10k_wmi_event_vdev_stopped(ar
, skb
);
2205 case WMI_10X_PEER_STA_KICKOUT_EVENTID
:
2206 ath10k_wmi_event_peer_sta_kickout(ar
, skb
);
2208 case WMI_10X_HOST_SWBA_EVENTID
:
2209 ath10k_wmi_event_host_swba(ar
, skb
);
2211 case WMI_10X_TBTTOFFSET_UPDATE_EVENTID
:
2212 ath10k_wmi_event_tbttoffset_update(ar
, skb
);
2214 case WMI_10X_PHYERR_EVENTID
:
2215 ath10k_wmi_event_phyerr(ar
, skb
);
2217 case WMI_10X_ROAM_EVENTID
:
2218 ath10k_wmi_event_roam(ar
, skb
);
2220 case WMI_10X_PROFILE_MATCH
:
2221 ath10k_wmi_event_profile_match(ar
, skb
);
2223 case WMI_10X_DEBUG_PRINT_EVENTID
:
2224 ath10k_wmi_event_debug_print(ar
, skb
);
2226 case WMI_10X_PDEV_QVIT_EVENTID
:
2227 ath10k_wmi_event_pdev_qvit(ar
, skb
);
2229 case WMI_10X_WLAN_PROFILE_DATA_EVENTID
:
2230 ath10k_wmi_event_wlan_profile_data(ar
, skb
);
2232 case WMI_10X_RTT_MEASUREMENT_REPORT_EVENTID
:
2233 ath10k_wmi_event_rtt_measurement_report(ar
, skb
);
2235 case WMI_10X_TSF_MEASUREMENT_REPORT_EVENTID
:
2236 ath10k_wmi_event_tsf_measurement_report(ar
, skb
);
2238 case WMI_10X_RTT_ERROR_REPORT_EVENTID
:
2239 ath10k_wmi_event_rtt_error_report(ar
, skb
);
2241 case WMI_10X_WOW_WAKEUP_HOST_EVENTID
:
2242 ath10k_wmi_event_wow_wakeup_host(ar
, skb
);
2244 case WMI_10X_DCS_INTERFERENCE_EVENTID
:
2245 ath10k_wmi_event_dcs_interference(ar
, skb
);
2247 case WMI_10X_PDEV_TPC_CONFIG_EVENTID
:
2248 ath10k_wmi_event_pdev_tpc_config(ar
, skb
);
2250 case WMI_10X_INST_RSSI_STATS_EVENTID
:
2251 ath10k_wmi_event_inst_rssi_stats(ar
, skb
);
2253 case WMI_10X_VDEV_STANDBY_REQ_EVENTID
:
2254 ath10k_wmi_event_vdev_standby_req(ar
, skb
);
2256 case WMI_10X_VDEV_RESUME_REQ_EVENTID
:
2257 ath10k_wmi_event_vdev_resume_req(ar
, skb
);
2259 case WMI_10X_SERVICE_READY_EVENTID
:
2260 ath10k_wmi_10x_service_ready_event_rx(ar
, skb
);
2262 case WMI_10X_READY_EVENTID
:
2263 ath10k_wmi_ready_event_rx(ar
, skb
);
2266 ath10k_warn("Unknown eventid: %d\n", id
);
2274 static void ath10k_wmi_process_rx(struct ath10k
*ar
, struct sk_buff
*skb
)
2276 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, ar
->fw_features
))
2277 ath10k_wmi_10x_process_rx(ar
, skb
);
2279 ath10k_wmi_main_process_rx(ar
, skb
);
2282 /* WMI Initialization functions */
2283 int ath10k_wmi_attach(struct ath10k
*ar
)
2285 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, ar
->fw_features
)) {
2286 ar
->wmi
.cmd
= &wmi_10x_cmd_map
;
2287 ar
->wmi
.vdev_param
= &wmi_10x_vdev_param_map
;
2288 ar
->wmi
.pdev_param
= &wmi_10x_pdev_param_map
;
2290 ar
->wmi
.cmd
= &wmi_cmd_map
;
2291 ar
->wmi
.vdev_param
= &wmi_vdev_param_map
;
2292 ar
->wmi
.pdev_param
= &wmi_pdev_param_map
;
2295 init_completion(&ar
->wmi
.service_ready
);
2296 init_completion(&ar
->wmi
.unified_ready
);
2297 init_waitqueue_head(&ar
->wmi
.tx_credits_wq
);
2302 void ath10k_wmi_detach(struct ath10k
*ar
)
2306 /* free the host memory chunks requested by firmware */
2307 for (i
= 0; i
< ar
->wmi
.num_mem_chunks
; i
++) {
2308 dma_free_coherent(ar
->dev
,
2309 ar
->wmi
.mem_chunks
[i
].len
,
2310 ar
->wmi
.mem_chunks
[i
].vaddr
,
2311 ar
->wmi
.mem_chunks
[i
].paddr
);
2314 ar
->wmi
.num_mem_chunks
= 0;
2317 int ath10k_wmi_connect_htc_service(struct ath10k
*ar
)
2320 struct ath10k_htc_svc_conn_req conn_req
;
2321 struct ath10k_htc_svc_conn_resp conn_resp
;
2323 memset(&conn_req
, 0, sizeof(conn_req
));
2324 memset(&conn_resp
, 0, sizeof(conn_resp
));
2326 /* these fields are the same for all service endpoints */
2327 conn_req
.ep_ops
.ep_tx_complete
= ath10k_wmi_htc_tx_complete
;
2328 conn_req
.ep_ops
.ep_rx_complete
= ath10k_wmi_process_rx
;
2329 conn_req
.ep_ops
.ep_tx_credits
= ath10k_wmi_op_ep_tx_credits
;
2331 /* connect to control service */
2332 conn_req
.service_id
= ATH10K_HTC_SVC_ID_WMI_CONTROL
;
2334 status
= ath10k_htc_connect_service(&ar
->htc
, &conn_req
, &conn_resp
);
2336 ath10k_warn("failed to connect to WMI CONTROL service status: %d\n",
2341 ar
->wmi
.eid
= conn_resp
.eid
;
2345 int ath10k_wmi_pdev_set_regdomain(struct ath10k
*ar
, u16 rd
, u16 rd2g
,
2346 u16 rd5g
, u16 ctl2g
, u16 ctl5g
)
2348 struct wmi_pdev_set_regdomain_cmd
*cmd
;
2349 struct sk_buff
*skb
;
2351 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2355 cmd
= (struct wmi_pdev_set_regdomain_cmd
*)skb
->data
;
2356 cmd
->reg_domain
= __cpu_to_le32(rd
);
2357 cmd
->reg_domain_2G
= __cpu_to_le32(rd2g
);
2358 cmd
->reg_domain_5G
= __cpu_to_le32(rd5g
);
2359 cmd
->conformance_test_limit_2G
= __cpu_to_le32(ctl2g
);
2360 cmd
->conformance_test_limit_5G
= __cpu_to_le32(ctl5g
);
2362 ath10k_dbg(ATH10K_DBG_WMI
,
2363 "wmi pdev regdomain rd %x rd2g %x rd5g %x ctl2g %x ctl5g %x\n",
2364 rd
, rd2g
, rd5g
, ctl2g
, ctl5g
);
2366 return ath10k_wmi_cmd_send(ar
, skb
,
2367 ar
->wmi
.cmd
->pdev_set_regdomain_cmdid
);
2370 int ath10k_wmi_pdev_set_channel(struct ath10k
*ar
,
2371 const struct wmi_channel_arg
*arg
)
2373 struct wmi_set_channel_cmd
*cmd
;
2374 struct sk_buff
*skb
;
2380 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2384 if (arg
->chan_radar
)
2385 ch_flags
|= WMI_CHAN_FLAG_DFS
;
2387 cmd
= (struct wmi_set_channel_cmd
*)skb
->data
;
2388 cmd
->chan
.mhz
= __cpu_to_le32(arg
->freq
);
2389 cmd
->chan
.band_center_freq1
= __cpu_to_le32(arg
->freq
);
2390 cmd
->chan
.mode
= arg
->mode
;
2391 cmd
->chan
.flags
|= __cpu_to_le32(ch_flags
);
2392 cmd
->chan
.min_power
= arg
->min_power
;
2393 cmd
->chan
.max_power
= arg
->max_power
;
2394 cmd
->chan
.reg_power
= arg
->max_reg_power
;
2395 cmd
->chan
.reg_classid
= arg
->reg_class_id
;
2396 cmd
->chan
.antenna_max
= arg
->max_antenna_gain
;
2398 ath10k_dbg(ATH10K_DBG_WMI
,
2399 "wmi set channel mode %d freq %d\n",
2400 arg
->mode
, arg
->freq
);
2402 return ath10k_wmi_cmd_send(ar
, skb
,
2403 ar
->wmi
.cmd
->pdev_set_channel_cmdid
);
2406 int ath10k_wmi_pdev_suspend_target(struct ath10k
*ar
)
2408 struct wmi_pdev_suspend_cmd
*cmd
;
2409 struct sk_buff
*skb
;
2411 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2415 cmd
= (struct wmi_pdev_suspend_cmd
*)skb
->data
;
2416 cmd
->suspend_opt
= WMI_PDEV_SUSPEND
;
2418 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->pdev_suspend_cmdid
);
2421 int ath10k_wmi_pdev_resume_target(struct ath10k
*ar
)
2423 struct sk_buff
*skb
;
2425 skb
= ath10k_wmi_alloc_skb(0);
2429 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->pdev_resume_cmdid
);
2432 int ath10k_wmi_pdev_set_param(struct ath10k
*ar
, u32 id
, u32 value
)
2434 struct wmi_pdev_set_param_cmd
*cmd
;
2435 struct sk_buff
*skb
;
2437 if (id
== WMI_PDEV_PARAM_UNSUPPORTED
) {
2438 ath10k_warn("pdev param %d not supported by firmware\n", id
);
2442 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2446 cmd
= (struct wmi_pdev_set_param_cmd
*)skb
->data
;
2447 cmd
->param_id
= __cpu_to_le32(id
);
2448 cmd
->param_value
= __cpu_to_le32(value
);
2450 ath10k_dbg(ATH10K_DBG_WMI
, "wmi pdev set param %d value %d\n",
2452 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->pdev_set_param_cmdid
);
2455 static int ath10k_wmi_main_cmd_init(struct ath10k
*ar
)
2457 struct wmi_init_cmd
*cmd
;
2458 struct sk_buff
*buf
;
2459 struct wmi_resource_config config
= {};
2463 config
.num_vdevs
= __cpu_to_le32(TARGET_NUM_VDEVS
);
2464 config
.num_peers
= __cpu_to_le32(TARGET_NUM_PEERS
+ TARGET_NUM_VDEVS
);
2465 config
.num_offload_peers
= __cpu_to_le32(TARGET_NUM_OFFLOAD_PEERS
);
2467 config
.num_offload_reorder_bufs
=
2468 __cpu_to_le32(TARGET_NUM_OFFLOAD_REORDER_BUFS
);
2470 config
.num_peer_keys
= __cpu_to_le32(TARGET_NUM_PEER_KEYS
);
2471 config
.num_tids
= __cpu_to_le32(TARGET_NUM_TIDS
);
2472 config
.ast_skid_limit
= __cpu_to_le32(TARGET_AST_SKID_LIMIT
);
2473 config
.tx_chain_mask
= __cpu_to_le32(TARGET_TX_CHAIN_MASK
);
2474 config
.rx_chain_mask
= __cpu_to_le32(TARGET_RX_CHAIN_MASK
);
2475 config
.rx_timeout_pri_vo
= __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI
);
2476 config
.rx_timeout_pri_vi
= __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI
);
2477 config
.rx_timeout_pri_be
= __cpu_to_le32(TARGET_RX_TIMEOUT_LO_PRI
);
2478 config
.rx_timeout_pri_bk
= __cpu_to_le32(TARGET_RX_TIMEOUT_HI_PRI
);
2479 config
.rx_decap_mode
= __cpu_to_le32(TARGET_RX_DECAP_MODE
);
2481 config
.scan_max_pending_reqs
=
2482 __cpu_to_le32(TARGET_SCAN_MAX_PENDING_REQS
);
2484 config
.bmiss_offload_max_vdev
=
2485 __cpu_to_le32(TARGET_BMISS_OFFLOAD_MAX_VDEV
);
2487 config
.roam_offload_max_vdev
=
2488 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_VDEV
);
2490 config
.roam_offload_max_ap_profiles
=
2491 __cpu_to_le32(TARGET_ROAM_OFFLOAD_MAX_AP_PROFILES
);
2493 config
.num_mcast_groups
= __cpu_to_le32(TARGET_NUM_MCAST_GROUPS
);
2494 config
.num_mcast_table_elems
=
2495 __cpu_to_le32(TARGET_NUM_MCAST_TABLE_ELEMS
);
2497 config
.mcast2ucast_mode
= __cpu_to_le32(TARGET_MCAST2UCAST_MODE
);
2498 config
.tx_dbg_log_size
= __cpu_to_le32(TARGET_TX_DBG_LOG_SIZE
);
2499 config
.num_wds_entries
= __cpu_to_le32(TARGET_NUM_WDS_ENTRIES
);
2500 config
.dma_burst_size
= __cpu_to_le32(TARGET_DMA_BURST_SIZE
);
2501 config
.mac_aggr_delim
= __cpu_to_le32(TARGET_MAC_AGGR_DELIM
);
2503 val
= TARGET_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK
;
2504 config
.rx_skip_defrag_timeout_dup_detection_check
= __cpu_to_le32(val
);
2506 config
.vow_config
= __cpu_to_le32(TARGET_VOW_CONFIG
);
2508 config
.gtk_offload_max_vdev
=
2509 __cpu_to_le32(TARGET_GTK_OFFLOAD_MAX_VDEV
);
2511 config
.num_msdu_desc
= __cpu_to_le32(TARGET_NUM_MSDU_DESC
);
2512 config
.max_frag_entries
= __cpu_to_le32(TARGET_MAX_FRAG_ENTRIES
);
2514 len
= sizeof(*cmd
) +
2515 (sizeof(struct host_memory_chunk
) * ar
->wmi
.num_mem_chunks
);
2517 buf
= ath10k_wmi_alloc_skb(len
);
2521 cmd
= (struct wmi_init_cmd
*)buf
->data
;
2523 if (ar
->wmi
.num_mem_chunks
== 0) {
2524 cmd
->num_host_mem_chunks
= 0;
2528 ath10k_dbg(ATH10K_DBG_WMI
, "wmi sending %d memory chunks info.\n",
2529 ar
->wmi
.num_mem_chunks
);
2531 cmd
->num_host_mem_chunks
= __cpu_to_le32(ar
->wmi
.num_mem_chunks
);
2533 for (i
= 0; i
< ar
->wmi
.num_mem_chunks
; i
++) {
2534 cmd
->host_mem_chunks
[i
].ptr
=
2535 __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].paddr
);
2536 cmd
->host_mem_chunks
[i
].size
=
2537 __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].len
);
2538 cmd
->host_mem_chunks
[i
].req_id
=
2539 __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].req_id
);
2541 ath10k_dbg(ATH10K_DBG_WMI
,
2542 "wmi chunk %d len %d requested, addr 0x%llx\n",
2544 ar
->wmi
.mem_chunks
[i
].len
,
2545 (unsigned long long)ar
->wmi
.mem_chunks
[i
].paddr
);
2548 memcpy(&cmd
->resource_config
, &config
, sizeof(config
));
2550 ath10k_dbg(ATH10K_DBG_WMI
, "wmi init\n");
2551 return ath10k_wmi_cmd_send(ar
, buf
, ar
->wmi
.cmd
->init_cmdid
);
2554 static int ath10k_wmi_10x_cmd_init(struct ath10k
*ar
)
2556 struct wmi_init_cmd_10x
*cmd
;
2557 struct sk_buff
*buf
;
2558 struct wmi_resource_config_10x config
= {};
2562 config
.num_vdevs
= __cpu_to_le32(TARGET_10X_NUM_VDEVS
);
2563 config
.num_peers
= __cpu_to_le32(TARGET_10X_NUM_PEERS
);
2564 config
.num_peer_keys
= __cpu_to_le32(TARGET_10X_NUM_PEER_KEYS
);
2565 config
.num_tids
= __cpu_to_le32(TARGET_10X_NUM_TIDS
);
2566 config
.ast_skid_limit
= __cpu_to_le32(TARGET_10X_AST_SKID_LIMIT
);
2567 config
.tx_chain_mask
= __cpu_to_le32(TARGET_10X_TX_CHAIN_MASK
);
2568 config
.rx_chain_mask
= __cpu_to_le32(TARGET_10X_RX_CHAIN_MASK
);
2569 config
.rx_timeout_pri_vo
= __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI
);
2570 config
.rx_timeout_pri_vi
= __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI
);
2571 config
.rx_timeout_pri_be
= __cpu_to_le32(TARGET_10X_RX_TIMEOUT_LO_PRI
);
2572 config
.rx_timeout_pri_bk
= __cpu_to_le32(TARGET_10X_RX_TIMEOUT_HI_PRI
);
2573 config
.rx_decap_mode
= __cpu_to_le32(TARGET_10X_RX_DECAP_MODE
);
2575 config
.scan_max_pending_reqs
=
2576 __cpu_to_le32(TARGET_10X_SCAN_MAX_PENDING_REQS
);
2578 config
.bmiss_offload_max_vdev
=
2579 __cpu_to_le32(TARGET_10X_BMISS_OFFLOAD_MAX_VDEV
);
2581 config
.roam_offload_max_vdev
=
2582 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_VDEV
);
2584 config
.roam_offload_max_ap_profiles
=
2585 __cpu_to_le32(TARGET_10X_ROAM_OFFLOAD_MAX_AP_PROFILES
);
2587 config
.num_mcast_groups
= __cpu_to_le32(TARGET_10X_NUM_MCAST_GROUPS
);
2588 config
.num_mcast_table_elems
=
2589 __cpu_to_le32(TARGET_10X_NUM_MCAST_TABLE_ELEMS
);
2591 config
.mcast2ucast_mode
= __cpu_to_le32(TARGET_10X_MCAST2UCAST_MODE
);
2592 config
.tx_dbg_log_size
= __cpu_to_le32(TARGET_10X_TX_DBG_LOG_SIZE
);
2593 config
.num_wds_entries
= __cpu_to_le32(TARGET_10X_NUM_WDS_ENTRIES
);
2594 config
.dma_burst_size
= __cpu_to_le32(TARGET_10X_DMA_BURST_SIZE
);
2595 config
.mac_aggr_delim
= __cpu_to_le32(TARGET_10X_MAC_AGGR_DELIM
);
2597 val
= TARGET_10X_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK
;
2598 config
.rx_skip_defrag_timeout_dup_detection_check
= __cpu_to_le32(val
);
2600 config
.vow_config
= __cpu_to_le32(TARGET_10X_VOW_CONFIG
);
2602 config
.num_msdu_desc
= __cpu_to_le32(TARGET_10X_NUM_MSDU_DESC
);
2603 config
.max_frag_entries
= __cpu_to_le32(TARGET_10X_MAX_FRAG_ENTRIES
);
2605 len
= sizeof(*cmd
) +
2606 (sizeof(struct host_memory_chunk
) * ar
->wmi
.num_mem_chunks
);
2608 buf
= ath10k_wmi_alloc_skb(len
);
2612 cmd
= (struct wmi_init_cmd_10x
*)buf
->data
;
2614 if (ar
->wmi
.num_mem_chunks
== 0) {
2615 cmd
->num_host_mem_chunks
= 0;
2619 ath10k_dbg(ATH10K_DBG_WMI
, "wmi sending %d memory chunks info.\n",
2620 ar
->wmi
.num_mem_chunks
);
2622 cmd
->num_host_mem_chunks
= __cpu_to_le32(ar
->wmi
.num_mem_chunks
);
2624 for (i
= 0; i
< ar
->wmi
.num_mem_chunks
; i
++) {
2625 cmd
->host_mem_chunks
[i
].ptr
=
2626 __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].paddr
);
2627 cmd
->host_mem_chunks
[i
].size
=
2628 __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].len
);
2629 cmd
->host_mem_chunks
[i
].req_id
=
2630 __cpu_to_le32(ar
->wmi
.mem_chunks
[i
].req_id
);
2632 ath10k_dbg(ATH10K_DBG_WMI
,
2633 "wmi chunk %d len %d requested, addr 0x%llx\n",
2635 ar
->wmi
.mem_chunks
[i
].len
,
2636 (unsigned long long)ar
->wmi
.mem_chunks
[i
].paddr
);
2639 memcpy(&cmd
->resource_config
, &config
, sizeof(config
));
2641 ath10k_dbg(ATH10K_DBG_WMI
, "wmi init 10x\n");
2642 return ath10k_wmi_cmd_send(ar
, buf
, ar
->wmi
.cmd
->init_cmdid
);
2645 int ath10k_wmi_cmd_init(struct ath10k
*ar
)
2649 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, ar
->fw_features
))
2650 ret
= ath10k_wmi_10x_cmd_init(ar
);
2652 ret
= ath10k_wmi_main_cmd_init(ar
);
2657 static int ath10k_wmi_start_scan_calc_len(struct ath10k
*ar
,
2658 const struct wmi_start_scan_arg
*arg
)
2662 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, ar
->fw_features
))
2663 len
= sizeof(struct wmi_start_scan_cmd_10x
);
2665 len
= sizeof(struct wmi_start_scan_cmd
);
2670 if (arg
->ie_len
> WLAN_SCAN_PARAMS_MAX_IE_LEN
)
2673 len
+= sizeof(struct wmi_ie_data
);
2674 len
+= roundup(arg
->ie_len
, 4);
2677 if (arg
->n_channels
) {
2680 if (arg
->n_channels
> ARRAY_SIZE(arg
->channels
))
2683 len
+= sizeof(struct wmi_chan_list
);
2684 len
+= sizeof(__le32
) * arg
->n_channels
;
2690 if (arg
->n_ssids
> WLAN_SCAN_PARAMS_MAX_SSID
)
2693 len
+= sizeof(struct wmi_ssid_list
);
2694 len
+= sizeof(struct wmi_ssid
) * arg
->n_ssids
;
2697 if (arg
->n_bssids
) {
2700 if (arg
->n_bssids
> WLAN_SCAN_PARAMS_MAX_BSSID
)
2703 len
+= sizeof(struct wmi_bssid_list
);
2704 len
+= sizeof(struct wmi_mac_addr
) * arg
->n_bssids
;
2710 int ath10k_wmi_start_scan(struct ath10k
*ar
,
2711 const struct wmi_start_scan_arg
*arg
)
2713 struct wmi_start_scan_cmd
*cmd
;
2714 struct sk_buff
*skb
;
2715 struct wmi_ie_data
*ie
;
2716 struct wmi_chan_list
*channels
;
2717 struct wmi_ssid_list
*ssids
;
2718 struct wmi_bssid_list
*bssids
;
2725 len
= ath10k_wmi_start_scan_calc_len(ar
, arg
);
2727 return len
; /* len contains error code here */
2729 skb
= ath10k_wmi_alloc_skb(len
);
2733 scan_id
= WMI_HOST_SCAN_REQ_ID_PREFIX
;
2734 scan_id
|= arg
->scan_id
;
2736 scan_req_id
= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX
;
2737 scan_req_id
|= arg
->scan_req_id
;
2739 cmd
= (struct wmi_start_scan_cmd
*)skb
->data
;
2740 cmd
->scan_id
= __cpu_to_le32(scan_id
);
2741 cmd
->scan_req_id
= __cpu_to_le32(scan_req_id
);
2742 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
2743 cmd
->scan_priority
= __cpu_to_le32(arg
->scan_priority
);
2744 cmd
->notify_scan_events
= __cpu_to_le32(arg
->notify_scan_events
);
2745 cmd
->dwell_time_active
= __cpu_to_le32(arg
->dwell_time_active
);
2746 cmd
->dwell_time_passive
= __cpu_to_le32(arg
->dwell_time_passive
);
2747 cmd
->min_rest_time
= __cpu_to_le32(arg
->min_rest_time
);
2748 cmd
->max_rest_time
= __cpu_to_le32(arg
->max_rest_time
);
2749 cmd
->repeat_probe_time
= __cpu_to_le32(arg
->repeat_probe_time
);
2750 cmd
->probe_spacing_time
= __cpu_to_le32(arg
->probe_spacing_time
);
2751 cmd
->idle_time
= __cpu_to_le32(arg
->idle_time
);
2752 cmd
->max_scan_time
= __cpu_to_le32(arg
->max_scan_time
);
2753 cmd
->probe_delay
= __cpu_to_le32(arg
->probe_delay
);
2754 cmd
->scan_ctrl_flags
= __cpu_to_le32(arg
->scan_ctrl_flags
);
2756 /* TLV list starts after fields included in the struct */
2757 /* There's just one filed that differes the two start_scan
2758 * structures - burst_duration, which we are not using btw,
2759 no point to make the split here, just shift the buffer to fit with
2761 if (test_bit(ATH10K_FW_FEATURE_WMI_10X
, ar
->fw_features
))
2762 off
= sizeof(struct wmi_start_scan_cmd_10x
);
2764 off
= sizeof(struct wmi_start_scan_cmd
);
2766 if (arg
->n_channels
) {
2767 channels
= (void *)skb
->data
+ off
;
2768 channels
->tag
= __cpu_to_le32(WMI_CHAN_LIST_TAG
);
2769 channels
->num_chan
= __cpu_to_le32(arg
->n_channels
);
2771 for (i
= 0; i
< arg
->n_channels
; i
++)
2772 channels
->channel_list
[i
] =
2773 __cpu_to_le32(arg
->channels
[i
]);
2775 off
+= sizeof(*channels
);
2776 off
+= sizeof(__le32
) * arg
->n_channels
;
2780 ssids
= (void *)skb
->data
+ off
;
2781 ssids
->tag
= __cpu_to_le32(WMI_SSID_LIST_TAG
);
2782 ssids
->num_ssids
= __cpu_to_le32(arg
->n_ssids
);
2784 for (i
= 0; i
< arg
->n_ssids
; i
++) {
2785 ssids
->ssids
[i
].ssid_len
=
2786 __cpu_to_le32(arg
->ssids
[i
].len
);
2787 memcpy(&ssids
->ssids
[i
].ssid
,
2792 off
+= sizeof(*ssids
);
2793 off
+= sizeof(struct wmi_ssid
) * arg
->n_ssids
;
2796 if (arg
->n_bssids
) {
2797 bssids
= (void *)skb
->data
+ off
;
2798 bssids
->tag
= __cpu_to_le32(WMI_BSSID_LIST_TAG
);
2799 bssids
->num_bssid
= __cpu_to_le32(arg
->n_bssids
);
2801 for (i
= 0; i
< arg
->n_bssids
; i
++)
2802 memcpy(&bssids
->bssid_list
[i
],
2803 arg
->bssids
[i
].bssid
,
2806 off
+= sizeof(*bssids
);
2807 off
+= sizeof(struct wmi_mac_addr
) * arg
->n_bssids
;
2811 ie
= (void *)skb
->data
+ off
;
2812 ie
->tag
= __cpu_to_le32(WMI_IE_TAG
);
2813 ie
->ie_len
= __cpu_to_le32(arg
->ie_len
);
2814 memcpy(ie
->ie_data
, arg
->ie
, arg
->ie_len
);
2817 off
+= roundup(arg
->ie_len
, 4);
2820 if (off
!= skb
->len
) {
2825 ath10k_dbg(ATH10K_DBG_WMI
, "wmi start scan\n");
2826 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->start_scan_cmdid
);
2829 void ath10k_wmi_start_scan_init(struct ath10k
*ar
,
2830 struct wmi_start_scan_arg
*arg
)
2832 /* setup commonly used values */
2833 arg
->scan_req_id
= 1;
2834 arg
->scan_priority
= WMI_SCAN_PRIORITY_LOW
;
2835 arg
->dwell_time_active
= 50;
2836 arg
->dwell_time_passive
= 150;
2837 arg
->min_rest_time
= 50;
2838 arg
->max_rest_time
= 500;
2839 arg
->repeat_probe_time
= 0;
2840 arg
->probe_spacing_time
= 0;
2842 arg
->max_scan_time
= 20000;
2843 arg
->probe_delay
= 5;
2844 arg
->notify_scan_events
= WMI_SCAN_EVENT_STARTED
2845 | WMI_SCAN_EVENT_COMPLETED
2846 | WMI_SCAN_EVENT_BSS_CHANNEL
2847 | WMI_SCAN_EVENT_FOREIGN_CHANNEL
2848 | WMI_SCAN_EVENT_DEQUEUED
;
2849 arg
->scan_ctrl_flags
|= WMI_SCAN_ADD_OFDM_RATES
;
2850 arg
->scan_ctrl_flags
|= WMI_SCAN_CHAN_STAT_EVENT
;
2852 arg
->bssids
[0].bssid
= "\xFF\xFF\xFF\xFF\xFF\xFF";
2855 int ath10k_wmi_stop_scan(struct ath10k
*ar
, const struct wmi_stop_scan_arg
*arg
)
2857 struct wmi_stop_scan_cmd
*cmd
;
2858 struct sk_buff
*skb
;
2862 if (arg
->req_id
> 0xFFF)
2864 if (arg
->req_type
== WMI_SCAN_STOP_ONE
&& arg
->u
.scan_id
> 0xFFF)
2867 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2871 scan_id
= arg
->u
.scan_id
;
2872 scan_id
|= WMI_HOST_SCAN_REQ_ID_PREFIX
;
2874 req_id
= arg
->req_id
;
2875 req_id
|= WMI_HOST_SCAN_REQUESTOR_ID_PREFIX
;
2877 cmd
= (struct wmi_stop_scan_cmd
*)skb
->data
;
2878 cmd
->req_type
= __cpu_to_le32(arg
->req_type
);
2879 cmd
->vdev_id
= __cpu_to_le32(arg
->u
.vdev_id
);
2880 cmd
->scan_id
= __cpu_to_le32(scan_id
);
2881 cmd
->scan_req_id
= __cpu_to_le32(req_id
);
2883 ath10k_dbg(ATH10K_DBG_WMI
,
2884 "wmi stop scan reqid %d req_type %d vdev/scan_id %d\n",
2885 arg
->req_id
, arg
->req_type
, arg
->u
.scan_id
);
2886 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->stop_scan_cmdid
);
2889 int ath10k_wmi_vdev_create(struct ath10k
*ar
, u32 vdev_id
,
2890 enum wmi_vdev_type type
,
2891 enum wmi_vdev_subtype subtype
,
2892 const u8 macaddr
[ETH_ALEN
])
2894 struct wmi_vdev_create_cmd
*cmd
;
2895 struct sk_buff
*skb
;
2897 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2901 cmd
= (struct wmi_vdev_create_cmd
*)skb
->data
;
2902 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2903 cmd
->vdev_type
= __cpu_to_le32(type
);
2904 cmd
->vdev_subtype
= __cpu_to_le32(subtype
);
2905 memcpy(cmd
->vdev_macaddr
.addr
, macaddr
, ETH_ALEN
);
2907 ath10k_dbg(ATH10K_DBG_WMI
,
2908 "WMI vdev create: id %d type %d subtype %d macaddr %pM\n",
2909 vdev_id
, type
, subtype
, macaddr
);
2911 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->vdev_create_cmdid
);
2914 int ath10k_wmi_vdev_delete(struct ath10k
*ar
, u32 vdev_id
)
2916 struct wmi_vdev_delete_cmd
*cmd
;
2917 struct sk_buff
*skb
;
2919 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2923 cmd
= (struct wmi_vdev_delete_cmd
*)skb
->data
;
2924 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
2926 ath10k_dbg(ATH10K_DBG_WMI
,
2927 "WMI vdev delete id %d\n", vdev_id
);
2929 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->vdev_delete_cmdid
);
2932 static int ath10k_wmi_vdev_start_restart(struct ath10k
*ar
,
2933 const struct wmi_vdev_start_request_arg
*arg
,
2936 struct wmi_vdev_start_request_cmd
*cmd
;
2937 struct sk_buff
*skb
;
2938 const char *cmdname
;
2942 if (cmd_id
!= ar
->wmi
.cmd
->vdev_start_request_cmdid
&&
2943 cmd_id
!= ar
->wmi
.cmd
->vdev_restart_request_cmdid
)
2945 if (WARN_ON(arg
->ssid
&& arg
->ssid_len
== 0))
2947 if (WARN_ON(arg
->hidden_ssid
&& !arg
->ssid
))
2949 if (WARN_ON(arg
->ssid_len
> sizeof(cmd
->ssid
.ssid
)))
2952 if (cmd_id
== ar
->wmi
.cmd
->vdev_start_request_cmdid
)
2954 else if (cmd_id
== ar
->wmi
.cmd
->vdev_restart_request_cmdid
)
2955 cmdname
= "restart";
2957 return -EINVAL
; /* should not happen, we already check cmd_id */
2959 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
2963 if (arg
->hidden_ssid
)
2964 flags
|= WMI_VDEV_START_HIDDEN_SSID
;
2965 if (arg
->pmf_enabled
)
2966 flags
|= WMI_VDEV_START_PMF_ENABLED
;
2967 if (arg
->channel
.chan_radar
)
2968 ch_flags
|= WMI_CHAN_FLAG_DFS
;
2970 cmd
= (struct wmi_vdev_start_request_cmd
*)skb
->data
;
2971 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
2972 cmd
->disable_hw_ack
= __cpu_to_le32(arg
->disable_hw_ack
);
2973 cmd
->beacon_interval
= __cpu_to_le32(arg
->bcn_intval
);
2974 cmd
->dtim_period
= __cpu_to_le32(arg
->dtim_period
);
2975 cmd
->flags
= __cpu_to_le32(flags
);
2976 cmd
->bcn_tx_rate
= __cpu_to_le32(arg
->bcn_tx_rate
);
2977 cmd
->bcn_tx_power
= __cpu_to_le32(arg
->bcn_tx_power
);
2980 cmd
->ssid
.ssid_len
= __cpu_to_le32(arg
->ssid_len
);
2981 memcpy(cmd
->ssid
.ssid
, arg
->ssid
, arg
->ssid_len
);
2984 cmd
->chan
.mhz
= __cpu_to_le32(arg
->channel
.freq
);
2986 cmd
->chan
.band_center_freq1
=
2987 __cpu_to_le32(arg
->channel
.band_center_freq1
);
2989 cmd
->chan
.mode
= arg
->channel
.mode
;
2990 cmd
->chan
.flags
|= __cpu_to_le32(ch_flags
);
2991 cmd
->chan
.min_power
= arg
->channel
.min_power
;
2992 cmd
->chan
.max_power
= arg
->channel
.max_power
;
2993 cmd
->chan
.reg_power
= arg
->channel
.max_reg_power
;
2994 cmd
->chan
.reg_classid
= arg
->channel
.reg_class_id
;
2995 cmd
->chan
.antenna_max
= arg
->channel
.max_antenna_gain
;
2997 ath10k_dbg(ATH10K_DBG_WMI
,
2998 "wmi vdev %s id 0x%x flags: 0x%0X, freq %d, mode %d, "
2999 "ch_flags: 0x%0X, max_power: %d\n", cmdname
, arg
->vdev_id
,
3000 flags
, arg
->channel
.freq
, arg
->channel
.mode
,
3001 cmd
->chan
.flags
, arg
->channel
.max_power
);
3003 return ath10k_wmi_cmd_send(ar
, skb
, cmd_id
);
3006 int ath10k_wmi_vdev_start(struct ath10k
*ar
,
3007 const struct wmi_vdev_start_request_arg
*arg
)
3009 u32 cmd_id
= ar
->wmi
.cmd
->vdev_start_request_cmdid
;
3011 return ath10k_wmi_vdev_start_restart(ar
, arg
, cmd_id
);
3014 int ath10k_wmi_vdev_restart(struct ath10k
*ar
,
3015 const struct wmi_vdev_start_request_arg
*arg
)
3017 u32 cmd_id
= ar
->wmi
.cmd
->vdev_restart_request_cmdid
;
3019 return ath10k_wmi_vdev_start_restart(ar
, arg
, cmd_id
);
3022 int ath10k_wmi_vdev_stop(struct ath10k
*ar
, u32 vdev_id
)
3024 struct wmi_vdev_stop_cmd
*cmd
;
3025 struct sk_buff
*skb
;
3027 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3031 cmd
= (struct wmi_vdev_stop_cmd
*)skb
->data
;
3032 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3034 ath10k_dbg(ATH10K_DBG_WMI
, "wmi vdev stop id 0x%x\n", vdev_id
);
3036 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->vdev_stop_cmdid
);
3039 int ath10k_wmi_vdev_up(struct ath10k
*ar
, u32 vdev_id
, u32 aid
, const u8
*bssid
)
3041 struct wmi_vdev_up_cmd
*cmd
;
3042 struct sk_buff
*skb
;
3044 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3048 cmd
= (struct wmi_vdev_up_cmd
*)skb
->data
;
3049 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3050 cmd
->vdev_assoc_id
= __cpu_to_le32(aid
);
3051 memcpy(&cmd
->vdev_bssid
.addr
, bssid
, ETH_ALEN
);
3053 ath10k_dbg(ATH10K_DBG_WMI
,
3054 "wmi mgmt vdev up id 0x%x assoc id %d bssid %pM\n",
3055 vdev_id
, aid
, bssid
);
3057 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->vdev_up_cmdid
);
3060 int ath10k_wmi_vdev_down(struct ath10k
*ar
, u32 vdev_id
)
3062 struct wmi_vdev_down_cmd
*cmd
;
3063 struct sk_buff
*skb
;
3065 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3069 cmd
= (struct wmi_vdev_down_cmd
*)skb
->data
;
3070 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3072 ath10k_dbg(ATH10K_DBG_WMI
,
3073 "wmi mgmt vdev down id 0x%x\n", vdev_id
);
3075 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->vdev_down_cmdid
);
3078 int ath10k_wmi_vdev_set_param(struct ath10k
*ar
, u32 vdev_id
,
3079 u32 param_id
, u32 param_value
)
3081 struct wmi_vdev_set_param_cmd
*cmd
;
3082 struct sk_buff
*skb
;
3084 if (param_id
== WMI_VDEV_PARAM_UNSUPPORTED
) {
3085 ath10k_dbg(ATH10K_DBG_WMI
,
3086 "vdev param %d not supported by firmware\n",
3091 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3095 cmd
= (struct wmi_vdev_set_param_cmd
*)skb
->data
;
3096 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3097 cmd
->param_id
= __cpu_to_le32(param_id
);
3098 cmd
->param_value
= __cpu_to_le32(param_value
);
3100 ath10k_dbg(ATH10K_DBG_WMI
,
3101 "wmi vdev id 0x%x set param %d value %d\n",
3102 vdev_id
, param_id
, param_value
);
3104 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->vdev_set_param_cmdid
);
3107 int ath10k_wmi_vdev_install_key(struct ath10k
*ar
,
3108 const struct wmi_vdev_install_key_arg
*arg
)
3110 struct wmi_vdev_install_key_cmd
*cmd
;
3111 struct sk_buff
*skb
;
3113 if (arg
->key_cipher
== WMI_CIPHER_NONE
&& arg
->key_data
!= NULL
)
3115 if (arg
->key_cipher
!= WMI_CIPHER_NONE
&& arg
->key_data
== NULL
)
3118 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
) + arg
->key_len
);
3122 cmd
= (struct wmi_vdev_install_key_cmd
*)skb
->data
;
3123 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
3124 cmd
->key_idx
= __cpu_to_le32(arg
->key_idx
);
3125 cmd
->key_flags
= __cpu_to_le32(arg
->key_flags
);
3126 cmd
->key_cipher
= __cpu_to_le32(arg
->key_cipher
);
3127 cmd
->key_len
= __cpu_to_le32(arg
->key_len
);
3128 cmd
->key_txmic_len
= __cpu_to_le32(arg
->key_txmic_len
);
3129 cmd
->key_rxmic_len
= __cpu_to_le32(arg
->key_rxmic_len
);
3132 memcpy(cmd
->peer_macaddr
.addr
, arg
->macaddr
, ETH_ALEN
);
3134 memcpy(cmd
->key_data
, arg
->key_data
, arg
->key_len
);
3136 ath10k_dbg(ATH10K_DBG_WMI
,
3137 "wmi vdev install key idx %d cipher %d len %d\n",
3138 arg
->key_idx
, arg
->key_cipher
, arg
->key_len
);
3139 return ath10k_wmi_cmd_send(ar
, skb
,
3140 ar
->wmi
.cmd
->vdev_install_key_cmdid
);
3143 int ath10k_wmi_peer_create(struct ath10k
*ar
, u32 vdev_id
,
3144 const u8 peer_addr
[ETH_ALEN
])
3146 struct wmi_peer_create_cmd
*cmd
;
3147 struct sk_buff
*skb
;
3149 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3153 cmd
= (struct wmi_peer_create_cmd
*)skb
->data
;
3154 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3155 memcpy(cmd
->peer_macaddr
.addr
, peer_addr
, ETH_ALEN
);
3157 ath10k_dbg(ATH10K_DBG_WMI
,
3158 "wmi peer create vdev_id %d peer_addr %pM\n",
3159 vdev_id
, peer_addr
);
3160 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->peer_create_cmdid
);
3163 int ath10k_wmi_peer_delete(struct ath10k
*ar
, u32 vdev_id
,
3164 const u8 peer_addr
[ETH_ALEN
])
3166 struct wmi_peer_delete_cmd
*cmd
;
3167 struct sk_buff
*skb
;
3169 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3173 cmd
= (struct wmi_peer_delete_cmd
*)skb
->data
;
3174 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3175 memcpy(cmd
->peer_macaddr
.addr
, peer_addr
, ETH_ALEN
);
3177 ath10k_dbg(ATH10K_DBG_WMI
,
3178 "wmi peer delete vdev_id %d peer_addr %pM\n",
3179 vdev_id
, peer_addr
);
3180 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->peer_delete_cmdid
);
3183 int ath10k_wmi_peer_flush(struct ath10k
*ar
, u32 vdev_id
,
3184 const u8 peer_addr
[ETH_ALEN
], u32 tid_bitmap
)
3186 struct wmi_peer_flush_tids_cmd
*cmd
;
3187 struct sk_buff
*skb
;
3189 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3193 cmd
= (struct wmi_peer_flush_tids_cmd
*)skb
->data
;
3194 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3195 cmd
->peer_tid_bitmap
= __cpu_to_le32(tid_bitmap
);
3196 memcpy(cmd
->peer_macaddr
.addr
, peer_addr
, ETH_ALEN
);
3198 ath10k_dbg(ATH10K_DBG_WMI
,
3199 "wmi peer flush vdev_id %d peer_addr %pM tids %08x\n",
3200 vdev_id
, peer_addr
, tid_bitmap
);
3201 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->peer_flush_tids_cmdid
);
3204 int ath10k_wmi_peer_set_param(struct ath10k
*ar
, u32 vdev_id
,
3205 const u8
*peer_addr
, enum wmi_peer_param param_id
,
3208 struct wmi_peer_set_param_cmd
*cmd
;
3209 struct sk_buff
*skb
;
3211 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3215 cmd
= (struct wmi_peer_set_param_cmd
*)skb
->data
;
3216 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3217 cmd
->param_id
= __cpu_to_le32(param_id
);
3218 cmd
->param_value
= __cpu_to_le32(param_value
);
3219 memcpy(&cmd
->peer_macaddr
.addr
, peer_addr
, ETH_ALEN
);
3221 ath10k_dbg(ATH10K_DBG_WMI
,
3222 "wmi vdev %d peer 0x%pM set param %d value %d\n",
3223 vdev_id
, peer_addr
, param_id
, param_value
);
3225 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->peer_set_param_cmdid
);
3228 int ath10k_wmi_set_psmode(struct ath10k
*ar
, u32 vdev_id
,
3229 enum wmi_sta_ps_mode psmode
)
3231 struct wmi_sta_powersave_mode_cmd
*cmd
;
3232 struct sk_buff
*skb
;
3234 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3238 cmd
= (struct wmi_sta_powersave_mode_cmd
*)skb
->data
;
3239 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3240 cmd
->sta_ps_mode
= __cpu_to_le32(psmode
);
3242 ath10k_dbg(ATH10K_DBG_WMI
,
3243 "wmi set powersave id 0x%x mode %d\n",
3246 return ath10k_wmi_cmd_send(ar
, skb
,
3247 ar
->wmi
.cmd
->sta_powersave_mode_cmdid
);
3250 int ath10k_wmi_set_sta_ps_param(struct ath10k
*ar
, u32 vdev_id
,
3251 enum wmi_sta_powersave_param param_id
,
3254 struct wmi_sta_powersave_param_cmd
*cmd
;
3255 struct sk_buff
*skb
;
3257 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3261 cmd
= (struct wmi_sta_powersave_param_cmd
*)skb
->data
;
3262 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3263 cmd
->param_id
= __cpu_to_le32(param_id
);
3264 cmd
->param_value
= __cpu_to_le32(value
);
3266 ath10k_dbg(ATH10K_DBG_WMI
,
3267 "wmi sta ps param vdev_id 0x%x param %d value %d\n",
3268 vdev_id
, param_id
, value
);
3269 return ath10k_wmi_cmd_send(ar
, skb
,
3270 ar
->wmi
.cmd
->sta_powersave_param_cmdid
);
3273 int ath10k_wmi_set_ap_ps_param(struct ath10k
*ar
, u32 vdev_id
, const u8
*mac
,
3274 enum wmi_ap_ps_peer_param param_id
, u32 value
)
3276 struct wmi_ap_ps_peer_cmd
*cmd
;
3277 struct sk_buff
*skb
;
3282 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3286 cmd
= (struct wmi_ap_ps_peer_cmd
*)skb
->data
;
3287 cmd
->vdev_id
= __cpu_to_le32(vdev_id
);
3288 cmd
->param_id
= __cpu_to_le32(param_id
);
3289 cmd
->param_value
= __cpu_to_le32(value
);
3290 memcpy(&cmd
->peer_macaddr
, mac
, ETH_ALEN
);
3292 ath10k_dbg(ATH10K_DBG_WMI
,
3293 "wmi ap ps param vdev_id 0x%X param %d value %d mac_addr %pM\n",
3294 vdev_id
, param_id
, value
, mac
);
3296 return ath10k_wmi_cmd_send(ar
, skb
,
3297 ar
->wmi
.cmd
->ap_ps_peer_param_cmdid
);
3300 int ath10k_wmi_scan_chan_list(struct ath10k
*ar
,
3301 const struct wmi_scan_chan_list_arg
*arg
)
3303 struct wmi_scan_chan_list_cmd
*cmd
;
3304 struct sk_buff
*skb
;
3305 struct wmi_channel_arg
*ch
;
3306 struct wmi_channel
*ci
;
3310 len
= sizeof(*cmd
) + arg
->n_channels
* sizeof(struct wmi_channel
);
3312 skb
= ath10k_wmi_alloc_skb(len
);
3316 cmd
= (struct wmi_scan_chan_list_cmd
*)skb
->data
;
3317 cmd
->num_scan_chans
= __cpu_to_le32(arg
->n_channels
);
3319 for (i
= 0; i
< arg
->n_channels
; i
++) {
3322 ch
= &arg
->channels
[i
];
3323 ci
= &cmd
->chan_info
[i
];
3326 flags
|= WMI_CHAN_FLAG_PASSIVE
;
3328 flags
|= WMI_CHAN_FLAG_ADHOC_ALLOWED
;
3330 flags
|= WMI_CHAN_FLAG_ALLOW_HT
;
3332 flags
|= WMI_CHAN_FLAG_ALLOW_VHT
;
3334 flags
|= WMI_CHAN_FLAG_HT40_PLUS
;
3336 flags
|= WMI_CHAN_FLAG_DFS
;
3338 ci
->mhz
= __cpu_to_le32(ch
->freq
);
3339 ci
->band_center_freq1
= __cpu_to_le32(ch
->freq
);
3340 ci
->band_center_freq2
= 0;
3341 ci
->min_power
= ch
->min_power
;
3342 ci
->max_power
= ch
->max_power
;
3343 ci
->reg_power
= ch
->max_reg_power
;
3344 ci
->antenna_max
= ch
->max_antenna_gain
;
3345 ci
->antenna_max
= 0;
3347 /* mode & flags share storage */
3348 ci
->mode
= ch
->mode
;
3349 ci
->flags
|= __cpu_to_le32(flags
);
3352 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->scan_chan_list_cmdid
);
3355 int ath10k_wmi_peer_assoc(struct ath10k
*ar
,
3356 const struct wmi_peer_assoc_complete_arg
*arg
)
3358 struct wmi_peer_assoc_complete_cmd
*cmd
;
3359 struct sk_buff
*skb
;
3361 if (arg
->peer_mpdu_density
> 16)
3363 if (arg
->peer_legacy_rates
.num_rates
> MAX_SUPPORTED_RATES
)
3365 if (arg
->peer_ht_rates
.num_rates
> MAX_SUPPORTED_RATES
)
3368 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3372 cmd
= (struct wmi_peer_assoc_complete_cmd
*)skb
->data
;
3373 cmd
->vdev_id
= __cpu_to_le32(arg
->vdev_id
);
3374 cmd
->peer_new_assoc
= __cpu_to_le32(arg
->peer_reassoc
? 0 : 1);
3375 cmd
->peer_associd
= __cpu_to_le32(arg
->peer_aid
);
3376 cmd
->peer_flags
= __cpu_to_le32(arg
->peer_flags
);
3377 cmd
->peer_caps
= __cpu_to_le32(arg
->peer_caps
);
3378 cmd
->peer_listen_intval
= __cpu_to_le32(arg
->peer_listen_intval
);
3379 cmd
->peer_ht_caps
= __cpu_to_le32(arg
->peer_ht_caps
);
3380 cmd
->peer_max_mpdu
= __cpu_to_le32(arg
->peer_max_mpdu
);
3381 cmd
->peer_mpdu_density
= __cpu_to_le32(arg
->peer_mpdu_density
);
3382 cmd
->peer_rate_caps
= __cpu_to_le32(arg
->peer_rate_caps
);
3383 cmd
->peer_nss
= __cpu_to_le32(arg
->peer_num_spatial_streams
);
3384 cmd
->peer_vht_caps
= __cpu_to_le32(arg
->peer_vht_caps
);
3385 cmd
->peer_phymode
= __cpu_to_le32(arg
->peer_phymode
);
3387 memcpy(cmd
->peer_macaddr
.addr
, arg
->addr
, ETH_ALEN
);
3389 cmd
->peer_legacy_rates
.num_rates
=
3390 __cpu_to_le32(arg
->peer_legacy_rates
.num_rates
);
3391 memcpy(cmd
->peer_legacy_rates
.rates
, arg
->peer_legacy_rates
.rates
,
3392 arg
->peer_legacy_rates
.num_rates
);
3394 cmd
->peer_ht_rates
.num_rates
=
3395 __cpu_to_le32(arg
->peer_ht_rates
.num_rates
);
3396 memcpy(cmd
->peer_ht_rates
.rates
, arg
->peer_ht_rates
.rates
,
3397 arg
->peer_ht_rates
.num_rates
);
3399 cmd
->peer_vht_rates
.rx_max_rate
=
3400 __cpu_to_le32(arg
->peer_vht_rates
.rx_max_rate
);
3401 cmd
->peer_vht_rates
.rx_mcs_set
=
3402 __cpu_to_le32(arg
->peer_vht_rates
.rx_mcs_set
);
3403 cmd
->peer_vht_rates
.tx_max_rate
=
3404 __cpu_to_le32(arg
->peer_vht_rates
.tx_max_rate
);
3405 cmd
->peer_vht_rates
.tx_mcs_set
=
3406 __cpu_to_le32(arg
->peer_vht_rates
.tx_mcs_set
);
3408 ath10k_dbg(ATH10K_DBG_WMI
,
3409 "wmi peer assoc vdev %d addr %pM\n",
3410 arg
->vdev_id
, arg
->addr
);
3411 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->peer_assoc_cmdid
);
3414 int ath10k_wmi_beacon_send_nowait(struct ath10k
*ar
,
3415 const struct wmi_bcn_tx_arg
*arg
)
3417 struct wmi_bcn_tx_cmd
*cmd
;
3418 struct sk_buff
*skb
;
3421 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
) + arg
->bcn_len
);
3425 cmd
= (struct wmi_bcn_tx_cmd
*)skb
->data
;
3426 cmd
->hdr
.vdev_id
= __cpu_to_le32(arg
->vdev_id
);
3427 cmd
->hdr
.tx_rate
= __cpu_to_le32(arg
->tx_rate
);
3428 cmd
->hdr
.tx_power
= __cpu_to_le32(arg
->tx_power
);
3429 cmd
->hdr
.bcn_len
= __cpu_to_le32(arg
->bcn_len
);
3430 memcpy(cmd
->bcn
, arg
->bcn
, arg
->bcn_len
);
3432 ret
= ath10k_wmi_cmd_send_nowait(ar
, skb
, ar
->wmi
.cmd
->bcn_tx_cmdid
);
3439 static void ath10k_wmi_pdev_set_wmm_param(struct wmi_wmm_params
*params
,
3440 const struct wmi_wmm_params_arg
*arg
)
3442 params
->cwmin
= __cpu_to_le32(arg
->cwmin
);
3443 params
->cwmax
= __cpu_to_le32(arg
->cwmax
);
3444 params
->aifs
= __cpu_to_le32(arg
->aifs
);
3445 params
->txop
= __cpu_to_le32(arg
->txop
);
3446 params
->acm
= __cpu_to_le32(arg
->acm
);
3447 params
->no_ack
= __cpu_to_le32(arg
->no_ack
);
3450 int ath10k_wmi_pdev_set_wmm_params(struct ath10k
*ar
,
3451 const struct wmi_pdev_set_wmm_params_arg
*arg
)
3453 struct wmi_pdev_set_wmm_params
*cmd
;
3454 struct sk_buff
*skb
;
3456 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3460 cmd
= (struct wmi_pdev_set_wmm_params
*)skb
->data
;
3461 ath10k_wmi_pdev_set_wmm_param(&cmd
->ac_be
, &arg
->ac_be
);
3462 ath10k_wmi_pdev_set_wmm_param(&cmd
->ac_bk
, &arg
->ac_bk
);
3463 ath10k_wmi_pdev_set_wmm_param(&cmd
->ac_vi
, &arg
->ac_vi
);
3464 ath10k_wmi_pdev_set_wmm_param(&cmd
->ac_vo
, &arg
->ac_vo
);
3466 ath10k_dbg(ATH10K_DBG_WMI
, "wmi pdev set wmm params\n");
3467 return ath10k_wmi_cmd_send(ar
, skb
,
3468 ar
->wmi
.cmd
->pdev_set_wmm_params_cmdid
);
3471 int ath10k_wmi_request_stats(struct ath10k
*ar
, enum wmi_stats_id stats_id
)
3473 struct wmi_request_stats_cmd
*cmd
;
3474 struct sk_buff
*skb
;
3476 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3480 cmd
= (struct wmi_request_stats_cmd
*)skb
->data
;
3481 cmd
->stats_id
= __cpu_to_le32(stats_id
);
3483 ath10k_dbg(ATH10K_DBG_WMI
, "wmi request stats %d\n", (int)stats_id
);
3484 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->request_stats_cmdid
);
3487 int ath10k_wmi_force_fw_hang(struct ath10k
*ar
,
3488 enum wmi_force_fw_hang_type type
, u32 delay_ms
)
3490 struct wmi_force_fw_hang_cmd
*cmd
;
3491 struct sk_buff
*skb
;
3493 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3497 cmd
= (struct wmi_force_fw_hang_cmd
*)skb
->data
;
3498 cmd
->type
= __cpu_to_le32(type
);
3499 cmd
->delay_ms
= __cpu_to_le32(delay_ms
);
3501 ath10k_dbg(ATH10K_DBG_WMI
, "wmi force fw hang %d delay %d\n",
3503 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->force_fw_hang_cmdid
);
3506 int ath10k_wmi_dbglog_cfg(struct ath10k
*ar
, u32 module_enable
)
3508 struct wmi_dbglog_cfg_cmd
*cmd
;
3509 struct sk_buff
*skb
;
3512 skb
= ath10k_wmi_alloc_skb(sizeof(*cmd
));
3516 cmd
= (struct wmi_dbglog_cfg_cmd
*)skb
->data
;
3518 if (module_enable
) {
3519 cfg
= SM(ATH10K_DBGLOG_LEVEL_VERBOSE
,
3520 ATH10K_DBGLOG_CFG_LOG_LVL
);
3522 /* set back defaults, all modules with WARN level */
3523 cfg
= SM(ATH10K_DBGLOG_LEVEL_WARN
,
3524 ATH10K_DBGLOG_CFG_LOG_LVL
);
3528 cmd
->module_enable
= __cpu_to_le32(module_enable
);
3529 cmd
->module_valid
= __cpu_to_le32(~0);
3530 cmd
->config_enable
= __cpu_to_le32(cfg
);
3531 cmd
->config_valid
= __cpu_to_le32(ATH10K_DBGLOG_CFG_LOG_LVL_MASK
);
3533 ath10k_dbg(ATH10K_DBG_WMI
,
3534 "wmi dbglog cfg modules %08x %08x config %08x %08x\n",
3535 __le32_to_cpu(cmd
->module_enable
),
3536 __le32_to_cpu(cmd
->module_valid
),
3537 __le32_to_cpu(cmd
->config_enable
),
3538 __le32_to_cpu(cmd
->config_valid
));
3540 return ath10k_wmi_cmd_send(ar
, skb
, ar
->wmi
.cmd
->dbglog_cfg_cmdid
);