Commit | Line | Data |
---|---|---|
5e6e3a92 BZ |
1 | /* |
2 | * Marvell Wireless LAN device driver: station command response handling | |
3 | * | |
65da33f5 | 4 | * Copyright (C) 2011-2014, Marvell International Ltd. |
5e6e3a92 BZ |
5 | * |
6 | * This software file (the "File") is distributed by Marvell International | |
7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 | |
8 | * (the "License"). You may use, redistribute and/or modify this File in | |
9 | * accordance with the terms and conditions of the License, a copy of which | |
10 | * is available by writing to the Free Software Foundation, Inc., | |
11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the | |
12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | |
13 | * | |
14 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE | |
15 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE | |
16 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about | |
17 | * this warranty disclaimer. | |
18 | */ | |
19 | ||
20 | #include "decl.h" | |
21 | #include "ioctl.h" | |
22 | #include "util.h" | |
23 | #include "fw.h" | |
24 | #include "main.h" | |
25 | #include "wmm.h" | |
26 | #include "11n.h" | |
a5f39056 | 27 | #include "11ac.h" |
5e6e3a92 BZ |
28 | |
29 | ||
30 | /* | |
31 | * This function handles the command response error case. | |
32 | * | |
33 | * For scan response error, the function cancels all the pending | |
34 | * scan commands and generates an event to inform the applications | |
35 | * of the scan completion. | |
36 | * | |
37 | * For Power Save command failure, we do not retry enter PS | |
38 | * command in case of Ad-hoc mode. | |
39 | * | |
40 | * For all other response errors, the current command buffer is freed | |
41 | * and returned to the free command queue. | |
42 | */ | |
43 | static void | |
44 | mwifiex_process_cmdresp_error(struct mwifiex_private *priv, | |
600f5d90 | 45 | struct host_cmd_ds_command *resp) |
5e6e3a92 | 46 | { |
270e58e8 | 47 | struct cmd_ctrl_node *cmd_node = NULL, *tmp_node; |
5e6e3a92 | 48 | struct mwifiex_adapter *adapter = priv->adapter; |
2b06bdbe | 49 | struct host_cmd_ds_802_11_ps_mode_enh *pm; |
5e6e3a92 BZ |
50 | unsigned long flags; |
51 | ||
acebe8c1 ZL |
52 | mwifiex_dbg(adapter, ERROR, |
53 | "CMD_RESP: cmd %#x error, result=%#x\n", | |
54 | resp->command, resp->result); | |
600f5d90 AK |
55 | |
56 | if (adapter->curr_cmd->wait_q_enabled) | |
57 | adapter->cmd_wait_q.status = -1; | |
5e6e3a92 BZ |
58 | |
59 | switch (le16_to_cpu(resp->command)) { | |
60 | case HostCmd_CMD_802_11_PS_MODE_ENH: | |
2b06bdbe | 61 | pm = &resp->params.psmode_enh; |
acebe8c1 ZL |
62 | mwifiex_dbg(adapter, ERROR, |
63 | "PS_MODE_ENH cmd failed: result=0x%x action=0x%X\n", | |
64 | resp->result, le16_to_cpu(pm->action)); | |
2b06bdbe MY |
65 | /* We do not re-try enter-ps command in ad-hoc mode. */ |
66 | if (le16_to_cpu(pm->action) == EN_AUTO_PS && | |
9c05fd72 YAP |
67 | (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) && |
68 | priv->bss_mode == NL80211_IFTYPE_ADHOC) | |
2b06bdbe MY |
69 | adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM; |
70 | ||
5e6e3a92 BZ |
71 | break; |
72 | case HostCmd_CMD_802_11_SCAN: | |
21f58d20 | 73 | case HostCmd_CMD_802_11_SCAN_EXT: |
5e6e3a92 BZ |
74 | /* Cancel all pending scan command */ |
75 | spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); | |
76 | list_for_each_entry_safe(cmd_node, tmp_node, | |
77 | &adapter->scan_pending_q, list) { | |
78 | list_del(&cmd_node->list); | |
79 | spin_unlock_irqrestore(&adapter->scan_pending_q_lock, | |
80 | flags); | |
81 | mwifiex_insert_cmd_to_free_q(adapter, cmd_node); | |
82 | spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); | |
83 | } | |
84 | spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); | |
85 | ||
86 | spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); | |
87 | adapter->scan_processing = false; | |
88 | spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); | |
5e6e3a92 BZ |
89 | break; |
90 | ||
91 | case HostCmd_CMD_MAC_CONTROL: | |
92 | break; | |
93 | ||
92263a84 | 94 | case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG: |
acebe8c1 ZL |
95 | mwifiex_dbg(adapter, MSG, |
96 | "SDIO RX single-port aggregation Not support\n"); | |
92263a84 ZL |
97 | break; |
98 | ||
5e6e3a92 BZ |
99 | default: |
100 | break; | |
101 | } | |
102 | /* Handling errors here */ | |
9908b074 | 103 | mwifiex_recycle_cmd_node(adapter, adapter->curr_cmd); |
5e6e3a92 BZ |
104 | |
105 | spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); | |
106 | adapter->curr_cmd = NULL; | |
107 | spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); | |
5e6e3a92 BZ |
108 | } |
109 | ||
110 | /* | |
111 | * This function handles the command response of get RSSI info. | |
112 | * | |
113 | * Handling includes changing the header fields into CPU format | |
114 | * and saving the following parameters in driver - | |
115 | * - Last data and beacon RSSI value | |
116 | * - Average data and beacon RSSI value | |
117 | * - Last data and beacon NF value | |
118 | * - Average data and beacon NF value | |
119 | * | |
120 | * The parameters are send to the application as well, along with | |
121 | * calculated SNR values. | |
122 | */ | |
123 | static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv, | |
958a4a86 | 124 | struct host_cmd_ds_command *resp) |
5e6e3a92 BZ |
125 | { |
126 | struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp = | |
9c05fd72 | 127 | &resp->params.rssi_info_rsp; |
908fe113 JD |
128 | struct mwifiex_ds_misc_subsc_evt *subsc_evt = |
129 | &priv->async_subsc_evt_storage; | |
5e6e3a92 BZ |
130 | |
131 | priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last); | |
132 | priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last); | |
133 | ||
134 | priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg); | |
135 | priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg); | |
136 | ||
137 | priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last); | |
138 | priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last); | |
139 | ||
140 | priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg); | |
141 | priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg); | |
142 | ||
fa444bf8 AK |
143 | if (priv->subsc_evt_rssi_state == EVENT_HANDLED) |
144 | return 0; | |
145 | ||
908fe113 JD |
146 | memset(subsc_evt, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt)); |
147 | ||
fa444bf8 | 148 | /* Resubscribe low and high rssi events with new thresholds */ |
908fe113 JD |
149 | subsc_evt->events = BITMASK_BCN_RSSI_LOW | BITMASK_BCN_RSSI_HIGH; |
150 | subsc_evt->action = HostCmd_ACT_BITWISE_SET; | |
fa444bf8 | 151 | if (priv->subsc_evt_rssi_state == RSSI_LOW_RECVD) { |
908fe113 | 152 | subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg - |
fa444bf8 | 153 | priv->cqm_rssi_hyst); |
908fe113 | 154 | subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold); |
fa444bf8 | 155 | } else if (priv->subsc_evt_rssi_state == RSSI_HIGH_RECVD) { |
908fe113 JD |
156 | subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold); |
157 | subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg + | |
fa444bf8 AK |
158 | priv->cqm_rssi_hyst); |
159 | } | |
908fe113 JD |
160 | subsc_evt->bcn_l_rssi_cfg.evt_freq = 1; |
161 | subsc_evt->bcn_h_rssi_cfg.evt_freq = 1; | |
fa444bf8 AK |
162 | |
163 | priv->subsc_evt_rssi_state = EVENT_HANDLED; | |
164 | ||
fa0ecbb9 BZ |
165 | mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SUBSCRIBE_EVENT, |
166 | 0, 0, subsc_evt, false); | |
fa444bf8 | 167 | |
5e6e3a92 BZ |
168 | return 0; |
169 | } | |
170 | ||
171 | /* | |
172 | * This function handles the command response of set/get SNMP | |
173 | * MIB parameters. | |
174 | * | |
175 | * Handling includes changing the header fields into CPU format | |
176 | * and saving the parameter in driver. | |
177 | * | |
178 | * The following parameters are supported - | |
179 | * - Fragmentation threshold | |
180 | * - RTS threshold | |
181 | * - Short retry limit | |
182 | */ | |
183 | static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, | |
184 | struct host_cmd_ds_command *resp, | |
a5e5aa6c | 185 | u32 *data_buf) |
5e6e3a92 BZ |
186 | { |
187 | struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib; | |
188 | u16 oid = le16_to_cpu(smib->oid); | |
189 | u16 query_type = le16_to_cpu(smib->query_type); | |
a5e5aa6c | 190 | u32 ul_temp; |
5e6e3a92 | 191 | |
acebe8c1 ZL |
192 | mwifiex_dbg(priv->adapter, INFO, |
193 | "info: SNMP_RESP: oid value = %#x,\t" | |
194 | "query_type = %#x, buf size = %#x\n", | |
195 | oid, query_type, le16_to_cpu(smib->buf_size)); | |
5e6e3a92 | 196 | if (query_type == HostCmd_ACT_GEN_GET) { |
a5e5aa6c DC |
197 | ul_temp = le16_to_cpu(*((__le16 *) (smib->value))); |
198 | if (data_buf) | |
199 | *data_buf = ul_temp; | |
5e6e3a92 BZ |
200 | switch (oid) { |
201 | case FRAG_THRESH_I: | |
acebe8c1 ZL |
202 | mwifiex_dbg(priv->adapter, INFO, |
203 | "info: SNMP_RESP: FragThsd =%u\n", | |
204 | ul_temp); | |
5e6e3a92 BZ |
205 | break; |
206 | case RTS_THRESH_I: | |
acebe8c1 ZL |
207 | mwifiex_dbg(priv->adapter, INFO, |
208 | "info: SNMP_RESP: RTSThsd =%u\n", | |
209 | ul_temp); | |
5e6e3a92 BZ |
210 | break; |
211 | case SHORT_RETRY_LIM_I: | |
acebe8c1 ZL |
212 | mwifiex_dbg(priv->adapter, INFO, |
213 | "info: SNMP_RESP: TxRetryCount=%u\n", | |
214 | ul_temp); | |
5e6e3a92 | 215 | break; |
caf60a6c | 216 | case DTIM_PERIOD_I: |
acebe8c1 ZL |
217 | mwifiex_dbg(priv->adapter, INFO, |
218 | "info: SNMP_RESP: DTIM period=%u\n", | |
219 | ul_temp); | |
5e6e3a92 BZ |
220 | default: |
221 | break; | |
222 | } | |
223 | } | |
224 | ||
225 | return 0; | |
226 | } | |
227 | ||
228 | /* | |
229 | * This function handles the command response of get log request | |
230 | * | |
231 | * Handling includes changing the header fields into CPU format | |
232 | * and sending the received parameters to application. | |
233 | */ | |
234 | static int mwifiex_ret_get_log(struct mwifiex_private *priv, | |
235 | struct host_cmd_ds_command *resp, | |
a5ffddb7 | 236 | struct mwifiex_ds_get_stats *stats) |
5e6e3a92 BZ |
237 | { |
238 | struct host_cmd_ds_802_11_get_log *get_log = | |
2c208890 | 239 | &resp->params.get_log; |
5e6e3a92 | 240 | |
a5ffddb7 | 241 | if (stats) { |
5e6e3a92 BZ |
242 | stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame); |
243 | stats->failed = le32_to_cpu(get_log->failed); | |
244 | stats->retry = le32_to_cpu(get_log->retry); | |
245 | stats->multi_retry = le32_to_cpu(get_log->multi_retry); | |
246 | stats->frame_dup = le32_to_cpu(get_log->frame_dup); | |
247 | stats->rts_success = le32_to_cpu(get_log->rts_success); | |
248 | stats->rts_failure = le32_to_cpu(get_log->rts_failure); | |
249 | stats->ack_failure = le32_to_cpu(get_log->ack_failure); | |
250 | stats->rx_frag = le32_to_cpu(get_log->rx_frag); | |
251 | stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame); | |
252 | stats->fcs_error = le32_to_cpu(get_log->fcs_error); | |
253 | stats->tx_frame = le32_to_cpu(get_log->tx_frame); | |
254 | stats->wep_icv_error[0] = | |
255 | le32_to_cpu(get_log->wep_icv_err_cnt[0]); | |
256 | stats->wep_icv_error[1] = | |
257 | le32_to_cpu(get_log->wep_icv_err_cnt[1]); | |
258 | stats->wep_icv_error[2] = | |
259 | le32_to_cpu(get_log->wep_icv_err_cnt[2]); | |
260 | stats->wep_icv_error[3] = | |
261 | le32_to_cpu(get_log->wep_icv_err_cnt[3]); | |
d35b6392 XH |
262 | stats->bcn_rcv_cnt = le32_to_cpu(get_log->bcn_rcv_cnt); |
263 | stats->bcn_miss_cnt = le32_to_cpu(get_log->bcn_miss_cnt); | |
5e6e3a92 BZ |
264 | } |
265 | ||
266 | return 0; | |
267 | } | |
268 | ||
269 | /* | |
270 | * This function handles the command response of set/get Tx rate | |
271 | * configurations. | |
272 | * | |
273 | * Handling includes changing the header fields into CPU format | |
274 | * and saving the following parameters in driver - | |
275 | * - DSSS rate bitmap | |
276 | * - OFDM rate bitmap | |
277 | * - HT MCS rate bitmaps | |
278 | * | |
279 | * Based on the new rate bitmaps, the function re-evaluates if | |
280 | * auto data rate has been activated. If not, it sends another | |
006606c0 | 281 | * query to the firmware to get the current Tx data rate. |
5e6e3a92 BZ |
282 | */ |
283 | static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, | |
006606c0 | 284 | struct host_cmd_ds_command *resp) |
5e6e3a92 | 285 | { |
5e6e3a92 BZ |
286 | struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; |
287 | struct mwifiex_rate_scope *rate_scope; | |
270e58e8 | 288 | struct mwifiex_ie_types_header *head; |
2636c308 | 289 | u16 tlv, tlv_buf_len, tlv_buf_left; |
5e6e3a92 BZ |
290 | u8 *tlv_buf; |
291 | u32 i; | |
5e6e3a92 | 292 | |
2636c308 AK |
293 | tlv_buf = ((u8 *)rate_cfg) + sizeof(struct host_cmd_ds_tx_rate_cfg); |
294 | tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*rate_cfg); | |
5e6e3a92 | 295 | |
2636c308 AK |
296 | while (tlv_buf_left >= sizeof(*head)) { |
297 | head = (struct mwifiex_ie_types_header *)tlv_buf; | |
298 | tlv = le16_to_cpu(head->type); | |
299 | tlv_buf_len = le16_to_cpu(head->len); | |
300 | ||
301 | if (tlv_buf_left < (sizeof(*head) + tlv_buf_len)) | |
302 | break; | |
5e6e3a92 BZ |
303 | |
304 | switch (tlv) { | |
305 | case TLV_TYPE_RATE_SCOPE: | |
306 | rate_scope = (struct mwifiex_rate_scope *) tlv_buf; | |
307 | priv->bitmap_rates[0] = | |
308 | le16_to_cpu(rate_scope->hr_dsss_rate_bitmap); | |
309 | priv->bitmap_rates[1] = | |
310 | le16_to_cpu(rate_scope->ofdm_rate_bitmap); | |
311 | for (i = 0; | |
312 | i < | |
313 | sizeof(rate_scope->ht_mcs_rate_bitmap) / | |
314 | sizeof(u16); i++) | |
315 | priv->bitmap_rates[2 + i] = | |
316 | le16_to_cpu(rate_scope-> | |
317 | ht_mcs_rate_bitmap[i]); | |
a0b7315a AK |
318 | |
319 | if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) { | |
320 | for (i = 0; i < ARRAY_SIZE(rate_scope-> | |
321 | vht_mcs_rate_bitmap); | |
322 | i++) | |
323 | priv->bitmap_rates[10 + i] = | |
324 | le16_to_cpu(rate_scope-> | |
325 | vht_mcs_rate_bitmap[i]); | |
326 | } | |
5e6e3a92 BZ |
327 | break; |
328 | /* Add RATE_DROP tlv here */ | |
329 | } | |
330 | ||
2636c308 AK |
331 | tlv_buf += (sizeof(*head) + tlv_buf_len); |
332 | tlv_buf_left -= (sizeof(*head) + tlv_buf_len); | |
5e6e3a92 BZ |
333 | } |
334 | ||
335 | priv->is_data_rate_auto = mwifiex_is_rate_auto(priv); | |
336 | ||
337 | if (priv->is_data_rate_auto) | |
338 | priv->data_rate = 0; | |
339 | else | |
fa0ecbb9 BZ |
340 | return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY, |
341 | HostCmd_ACT_GEN_GET, 0, NULL, false); | |
5e6e3a92 | 342 | |
006606c0 | 343 | return 0; |
5e6e3a92 BZ |
344 | } |
345 | ||
346 | /* | |
347 | * This function handles the command response of get Tx power level. | |
348 | * | |
349 | * Handling includes saving the maximum and minimum Tx power levels | |
350 | * in driver, as well as sending the values to user. | |
351 | */ | |
352 | static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf) | |
353 | { | |
270e58e8 YAP |
354 | int length, max_power = -1, min_power = -1; |
355 | struct mwifiex_types_power_group *pg_tlv_hdr; | |
356 | struct mwifiex_power_group *pg; | |
5e6e3a92 | 357 | |
bb7de2ba YAP |
358 | if (!data_buf) |
359 | return -1; | |
360 | ||
d8d13d32 | 361 | pg_tlv_hdr = (struct mwifiex_types_power_group *)((u8 *)data_buf); |
bb7de2ba YAP |
362 | pg = (struct mwifiex_power_group *) |
363 | ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group)); | |
930fd35c | 364 | length = le16_to_cpu(pg_tlv_hdr->length); |
fe1c9a44 AK |
365 | |
366 | /* At least one structure required to update power */ | |
367 | if (length < sizeof(struct mwifiex_power_group)) | |
368 | return 0; | |
369 | ||
370 | max_power = pg->power_max; | |
371 | min_power = pg->power_min; | |
372 | length -= sizeof(struct mwifiex_power_group); | |
373 | ||
374 | while (length >= sizeof(struct mwifiex_power_group)) { | |
bb7de2ba YAP |
375 | pg++; |
376 | if (max_power < pg->power_max) | |
5e6e3a92 | 377 | max_power = pg->power_max; |
5e6e3a92 | 378 | |
bb7de2ba YAP |
379 | if (min_power > pg->power_min) |
380 | min_power = pg->power_min; | |
5e6e3a92 | 381 | |
bb7de2ba YAP |
382 | length -= sizeof(struct mwifiex_power_group); |
383 | } | |
fe1c9a44 AK |
384 | priv->min_tx_power_level = (u8) min_power; |
385 | priv->max_tx_power_level = (u8) max_power; | |
5e6e3a92 BZ |
386 | |
387 | return 0; | |
388 | } | |
389 | ||
390 | /* | |
391 | * This function handles the command response of set/get Tx power | |
392 | * configurations. | |
393 | * | |
394 | * Handling includes changing the header fields into CPU format | |
395 | * and saving the current Tx power level in driver. | |
396 | */ | |
397 | static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv, | |
a5ffddb7 | 398 | struct host_cmd_ds_command *resp) |
5e6e3a92 BZ |
399 | { |
400 | struct mwifiex_adapter *adapter = priv->adapter; | |
401 | struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg; | |
270e58e8 YAP |
402 | struct mwifiex_types_power_group *pg_tlv_hdr; |
403 | struct mwifiex_power_group *pg; | |
5e6e3a92 | 404 | u16 action = le16_to_cpu(txp_cfg->action); |
d8d13d32 | 405 | u16 tlv_buf_left; |
5e6e3a92 | 406 | |
d8d13d32 AK |
407 | pg_tlv_hdr = (struct mwifiex_types_power_group *) |
408 | ((u8 *)txp_cfg + | |
409 | sizeof(struct host_cmd_ds_txpwr_cfg)); | |
985d68a3 | 410 | |
d8d13d32 AK |
411 | pg = (struct mwifiex_power_group *) |
412 | ((u8 *)pg_tlv_hdr + | |
413 | sizeof(struct mwifiex_types_power_group)); | |
985d68a3 | 414 | |
d8d13d32 AK |
415 | tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*txp_cfg); |
416 | if (tlv_buf_left < | |
417 | le16_to_cpu(pg_tlv_hdr->length) + sizeof(*pg_tlv_hdr)) | |
418 | return 0; | |
419 | ||
420 | switch (action) { | |
421 | case HostCmd_ACT_GEN_GET: | |
985d68a3 | 422 | if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) |
d8d13d32 | 423 | mwifiex_get_power_level(priv, pg_tlv_hdr); |
985d68a3 YAP |
424 | |
425 | priv->tx_power_level = (u16) pg->power_min; | |
426 | break; | |
427 | ||
5e6e3a92 | 428 | case HostCmd_ACT_GEN_SET: |
985d68a3 YAP |
429 | if (!le32_to_cpu(txp_cfg->mode)) |
430 | break; | |
431 | ||
985d68a3 YAP |
432 | if (pg->power_max == pg->power_min) |
433 | priv->tx_power_level = (u16) pg->power_min; | |
5e6e3a92 BZ |
434 | break; |
435 | default: | |
acebe8c1 ZL |
436 | mwifiex_dbg(adapter, ERROR, |
437 | "CMD_RESP: unknown cmd action %d\n", | |
438 | action); | |
5e6e3a92 BZ |
439 | return 0; |
440 | } | |
acebe8c1 ZL |
441 | mwifiex_dbg(adapter, INFO, |
442 | "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n", | |
443 | priv->tx_power_level, priv->max_tx_power_level, | |
444 | priv->min_tx_power_level); | |
5e6e3a92 BZ |
445 | |
446 | return 0; | |
447 | } | |
448 | ||
caa8984f AK |
449 | /* |
450 | * This function handles the command response of get RF Tx power. | |
451 | */ | |
452 | static int mwifiex_ret_rf_tx_power(struct mwifiex_private *priv, | |
453 | struct host_cmd_ds_command *resp) | |
454 | { | |
455 | struct host_cmd_ds_rf_tx_pwr *txp = &resp->params.txp; | |
456 | u16 action = le16_to_cpu(txp->action); | |
457 | ||
458 | priv->tx_power_level = le16_to_cpu(txp->cur_level); | |
459 | ||
460 | if (action == HostCmd_ACT_GEN_GET) { | |
461 | priv->max_tx_power_level = txp->max_power; | |
462 | priv->min_tx_power_level = txp->min_power; | |
463 | } | |
464 | ||
acebe8c1 ZL |
465 | mwifiex_dbg(priv->adapter, INFO, |
466 | "Current TxPower Level=%d, Max Power=%d, Min Power=%d\n", | |
467 | priv->tx_power_level, priv->max_tx_power_level, | |
468 | priv->min_tx_power_level); | |
caa8984f AK |
469 | |
470 | return 0; | |
471 | } | |
472 | ||
8a279d5b AK |
473 | /* |
474 | * This function handles the command response of set rf antenna | |
475 | */ | |
476 | static int mwifiex_ret_rf_antenna(struct mwifiex_private *priv, | |
477 | struct host_cmd_ds_command *resp) | |
478 | { | |
479 | struct host_cmd_ds_rf_ant_mimo *ant_mimo = &resp->params.ant_mimo; | |
480 | struct host_cmd_ds_rf_ant_siso *ant_siso = &resp->params.ant_siso; | |
481 | struct mwifiex_adapter *adapter = priv->adapter; | |
482 | ||
483 | if (adapter->hw_dev_mcs_support == HT_STREAM_2X2) | |
acebe8c1 ZL |
484 | mwifiex_dbg(adapter, INFO, |
485 | "RF_ANT_RESP: Tx action = 0x%x, Tx Mode = 0x%04x\t" | |
486 | "Rx action = 0x%x, Rx Mode = 0x%04x\n", | |
487 | le16_to_cpu(ant_mimo->action_tx), | |
488 | le16_to_cpu(ant_mimo->tx_ant_mode), | |
489 | le16_to_cpu(ant_mimo->action_rx), | |
490 | le16_to_cpu(ant_mimo->rx_ant_mode)); | |
8a279d5b | 491 | else |
acebe8c1 ZL |
492 | mwifiex_dbg(adapter, INFO, |
493 | "RF_ANT_RESP: action = 0x%x, Mode = 0x%04x\n", | |
494 | le16_to_cpu(ant_siso->action), | |
495 | le16_to_cpu(ant_siso->ant_mode)); | |
8a279d5b AK |
496 | |
497 | return 0; | |
498 | } | |
499 | ||
5e6e3a92 BZ |
500 | /* |
501 | * This function handles the command response of set/get MAC address. | |
502 | * | |
503 | * Handling includes saving the MAC address in driver. | |
504 | */ | |
505 | static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv, | |
506 | struct host_cmd_ds_command *resp) | |
507 | { | |
508 | struct host_cmd_ds_802_11_mac_address *cmd_mac_addr = | |
9c05fd72 | 509 | &resp->params.mac_addr; |
5e6e3a92 BZ |
510 | |
511 | memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN); | |
512 | ||
acebe8c1 ZL |
513 | mwifiex_dbg(priv->adapter, INFO, |
514 | "info: set mac address: %pM\n", priv->curr_addr); | |
5e6e3a92 BZ |
515 | |
516 | return 0; | |
517 | } | |
518 | ||
519 | /* | |
520 | * This function handles the command response of set/get MAC multicast | |
521 | * address. | |
522 | */ | |
523 | static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv, | |
524 | struct host_cmd_ds_command *resp) | |
525 | { | |
526 | return 0; | |
527 | } | |
528 | ||
529 | /* | |
530 | * This function handles the command response of get Tx rate query. | |
531 | * | |
532 | * Handling includes changing the header fields into CPU format | |
533 | * and saving the Tx rate and HT information parameters in driver. | |
534 | * | |
535 | * Both rate configuration and current data rate can be retrieved | |
536 | * with this request. | |
537 | */ | |
538 | static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv, | |
539 | struct host_cmd_ds_command *resp) | |
540 | { | |
5e6e3a92 BZ |
541 | priv->tx_rate = resp->params.tx_rate.tx_rate; |
542 | priv->tx_htinfo = resp->params.tx_rate.ht_info; | |
543 | if (!priv->is_data_rate_auto) | |
544 | priv->data_rate = | |
e3bea1c8 | 545 | mwifiex_index_to_data_rate(priv, priv->tx_rate, |
5e6e3a92 BZ |
546 | priv->tx_htinfo); |
547 | ||
548 | return 0; | |
549 | } | |
550 | ||
551 | /* | |
552 | * This function handles the command response of a deauthenticate | |
553 | * command. | |
554 | * | |
555 | * If the deauthenticated MAC matches the current BSS MAC, the connection | |
556 | * state is reset. | |
557 | */ | |
558 | static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv, | |
559 | struct host_cmd_ds_command *resp) | |
560 | { | |
561 | struct mwifiex_adapter *adapter = priv->adapter; | |
562 | ||
563 | adapter->dbg.num_cmd_deauth++; | |
564 | if (!memcmp(resp->params.deauth.mac_addr, | |
565 | &priv->curr_bss_params.bss_descriptor.mac_address, | |
566 | sizeof(resp->params.deauth.mac_addr))) | |
8cc1d523 | 567 | mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING); |
5e6e3a92 BZ |
568 | |
569 | return 0; | |
570 | } | |
571 | ||
572 | /* | |
573 | * This function handles the command response of ad-hoc stop. | |
574 | * | |
575 | * The function resets the connection state in driver. | |
576 | */ | |
577 | static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv, | |
578 | struct host_cmd_ds_command *resp) | |
579 | { | |
8cc1d523 | 580 | mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING); |
5e6e3a92 BZ |
581 | return 0; |
582 | } | |
583 | ||
584 | /* | |
e57f1734 | 585 | * This function handles the command response of set/get v1 key material. |
5e6e3a92 BZ |
586 | * |
587 | * Handling includes updating the driver parameters to reflect the | |
588 | * changes. | |
589 | */ | |
e57f1734 AP |
590 | static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv, |
591 | struct host_cmd_ds_command *resp) | |
5e6e3a92 BZ |
592 | { |
593 | struct host_cmd_ds_802_11_key_material *key = | |
9c05fd72 | 594 | &resp->params.key_material; |
5e6e3a92 BZ |
595 | |
596 | if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) { | |
6a35a0ac | 597 | if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) { |
acebe8c1 ZL |
598 | mwifiex_dbg(priv->adapter, INFO, |
599 | "info: key: GTK is set\n"); | |
5e6e3a92 BZ |
600 | priv->wpa_is_gtk_set = true; |
601 | priv->scan_block = false; | |
602 | } | |
603 | } | |
604 | ||
605 | memset(priv->aes_key.key_param_set.key, 0, | |
606 | sizeof(key->key_param_set.key)); | |
607 | priv->aes_key.key_param_set.key_len = key->key_param_set.key_len; | |
608 | memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, | |
609 | le16_to_cpu(priv->aes_key.key_param_set.key_len)); | |
610 | ||
611 | return 0; | |
612 | } | |
613 | ||
e57f1734 AP |
614 | /* |
615 | * This function handles the command response of set/get v2 key material. | |
616 | * | |
617 | * Handling includes updating the driver parameters to reflect the | |
618 | * changes. | |
619 | */ | |
620 | static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv, | |
621 | struct host_cmd_ds_command *resp) | |
622 | { | |
623 | struct host_cmd_ds_802_11_key_material_v2 *key_v2; | |
624 | __le16 len; | |
625 | ||
626 | key_v2 = &resp->params.key_material_v2; | |
627 | if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) { | |
628 | if ((le16_to_cpu(key_v2->key_param_set.key_info) & KEY_MCAST)) { | |
acebe8c1 | 629 | mwifiex_dbg(priv->adapter, INFO, "info: key: GTK is set\n"); |
e57f1734 AP |
630 | priv->wpa_is_gtk_set = true; |
631 | priv->scan_block = false; | |
632 | } | |
633 | } | |
634 | ||
635 | if (key_v2->key_param_set.key_type != KEY_TYPE_ID_AES) | |
636 | return 0; | |
637 | ||
638 | memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0, | |
639 | WLAN_KEY_LEN_CCMP); | |
640 | priv->aes_key_v2.key_param_set.key_params.aes.key_len = | |
641 | key_v2->key_param_set.key_params.aes.key_len; | |
642 | len = priv->aes_key_v2.key_param_set.key_params.aes.key_len; | |
643 | memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key, | |
644 | key_v2->key_param_set.key_params.aes.key, le16_to_cpu(len)); | |
645 | ||
646 | return 0; | |
647 | } | |
648 | ||
649 | /* Wrapper function for processing response of key material command */ | |
650 | static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv, | |
651 | struct host_cmd_ds_command *resp) | |
652 | { | |
4b9fede5 | 653 | if (priv->adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2) |
e57f1734 AP |
654 | return mwifiex_ret_802_11_key_material_v2(priv, resp); |
655 | else | |
656 | return mwifiex_ret_802_11_key_material_v1(priv, resp); | |
657 | } | |
658 | ||
5e6e3a92 BZ |
659 | /* |
660 | * This function handles the command response of get 11d domain information. | |
661 | */ | |
662 | static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv, | |
663 | struct host_cmd_ds_command *resp) | |
664 | { | |
665 | struct host_cmd_ds_802_11d_domain_info_rsp *domain_info = | |
666 | &resp->params.domain_info_resp; | |
667 | struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain; | |
668 | u16 action = le16_to_cpu(domain_info->action); | |
270e58e8 | 669 | u8 no_of_triplet; |
5e6e3a92 | 670 | |
9c05fd72 YAP |
671 | no_of_triplet = (u8) ((le16_to_cpu(domain->header.len) |
672 | - IEEE80211_COUNTRY_STRING_LEN) | |
673 | / sizeof(struct ieee80211_country_ie_triplet)); | |
5e6e3a92 | 674 | |
acebe8c1 ZL |
675 | mwifiex_dbg(priv->adapter, INFO, |
676 | "info: 11D Domain Info Resp: no_of_triplet=%d\n", | |
677 | no_of_triplet); | |
5e6e3a92 BZ |
678 | |
679 | if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) { | |
acebe8c1 ZL |
680 | mwifiex_dbg(priv->adapter, FATAL, |
681 | "11D: invalid number of triplets %d returned\n", | |
682 | no_of_triplet); | |
5e6e3a92 BZ |
683 | return -1; |
684 | } | |
685 | ||
686 | switch (action) { | |
687 | case HostCmd_ACT_GEN_SET: /* Proc Set Action */ | |
688 | break; | |
689 | case HostCmd_ACT_GEN_GET: | |
690 | break; | |
691 | default: | |
acebe8c1 ZL |
692 | mwifiex_dbg(priv->adapter, ERROR, |
693 | "11D: invalid action:%d\n", domain_info->action); | |
5e6e3a92 BZ |
694 | return -1; |
695 | } | |
696 | ||
697 | return 0; | |
698 | } | |
699 | ||
5e6e3a92 BZ |
700 | /* |
701 | * This function handles the command response of get extended version. | |
702 | * | |
703 | * Handling includes forming the extended version string and sending it | |
704 | * to application. | |
705 | */ | |
706 | static int mwifiex_ret_ver_ext(struct mwifiex_private *priv, | |
707 | struct host_cmd_ds_command *resp, | |
a5ffddb7 | 708 | struct host_cmd_ds_version_ext *version_ext) |
5e6e3a92 BZ |
709 | { |
710 | struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext; | |
5e6e3a92 | 711 | |
a5ffddb7 | 712 | if (version_ext) { |
5e6e3a92 BZ |
713 | version_ext->version_str_sel = ver_ext->version_str_sel; |
714 | memcpy(version_ext->version_str, ver_ext->version_str, | |
715 | sizeof(char) * 128); | |
716 | memcpy(priv->version_str, ver_ext->version_str, 128); | |
717 | } | |
718 | return 0; | |
719 | } | |
720 | ||
7feb4c48 SP |
721 | /* |
722 | * This function handles the command response of remain on channel. | |
723 | */ | |
724 | static int | |
725 | mwifiex_ret_remain_on_chan(struct mwifiex_private *priv, | |
726 | struct host_cmd_ds_command *resp, | |
727 | struct host_cmd_ds_remain_on_chan *roc_cfg) | |
728 | { | |
729 | struct host_cmd_ds_remain_on_chan *resp_cfg = &resp->params.roc_cfg; | |
730 | ||
731 | if (roc_cfg) | |
732 | memcpy(roc_cfg, resp_cfg, sizeof(*roc_cfg)); | |
733 | ||
734 | return 0; | |
735 | } | |
736 | ||
e1a2b7a3 SP |
737 | /* |
738 | * This function handles the command response of P2P mode cfg. | |
739 | */ | |
740 | static int | |
741 | mwifiex_ret_p2p_mode_cfg(struct mwifiex_private *priv, | |
742 | struct host_cmd_ds_command *resp, | |
743 | void *data_buf) | |
744 | { | |
745 | struct host_cmd_ds_p2p_mode_cfg *mode_cfg = &resp->params.mode_cfg; | |
746 | ||
747 | if (data_buf) | |
748 | *((u16 *)data_buf) = le16_to_cpu(mode_cfg->mode); | |
749 | ||
750 | return 0; | |
751 | } | |
752 | ||
c2c6c85f CL |
753 | /* This function handles the command response of mem_access command |
754 | */ | |
755 | static int | |
756 | mwifiex_ret_mem_access(struct mwifiex_private *priv, | |
757 | struct host_cmd_ds_command *resp, void *pioctl_buf) | |
758 | { | |
759 | struct host_cmd_ds_mem_access *mem = (void *)&resp->params.mem; | |
760 | ||
761 | priv->mem_rw.addr = le32_to_cpu(mem->addr); | |
762 | priv->mem_rw.value = le32_to_cpu(mem->value); | |
763 | ||
764 | return 0; | |
765 | } | |
5e6e3a92 BZ |
766 | /* |
767 | * This function handles the command response of register access. | |
768 | * | |
769 | * The register value and offset are returned to the user. For EEPROM | |
770 | * access, the byte count is also returned. | |
771 | */ | |
772 | static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp, | |
773 | void *data_buf) | |
774 | { | |
270e58e8 YAP |
775 | struct mwifiex_ds_reg_rw *reg_rw; |
776 | struct mwifiex_ds_read_eeprom *eeprom; | |
985d68a3 YAP |
777 | union reg { |
778 | struct host_cmd_ds_mac_reg_access *mac; | |
779 | struct host_cmd_ds_bbp_reg_access *bbp; | |
780 | struct host_cmd_ds_rf_reg_access *rf; | |
781 | struct host_cmd_ds_pmic_reg_access *pmic; | |
782 | struct host_cmd_ds_802_11_eeprom_access *eeprom; | |
783 | } r; | |
784 | ||
785 | if (!data_buf) | |
786 | return 0; | |
5e6e3a92 | 787 | |
985d68a3 YAP |
788 | reg_rw = data_buf; |
789 | eeprom = data_buf; | |
790 | switch (type) { | |
791 | case HostCmd_CMD_MAC_REG_ACCESS: | |
2c208890 | 792 | r.mac = &resp->params.mac_reg; |
985d68a3 YAP |
793 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset)); |
794 | reg_rw->value = r.mac->value; | |
795 | break; | |
796 | case HostCmd_CMD_BBP_REG_ACCESS: | |
2c208890 | 797 | r.bbp = &resp->params.bbp_reg; |
985d68a3 YAP |
798 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset)); |
799 | reg_rw->value = cpu_to_le32((u32) r.bbp->value); | |
800 | break; | |
5e6e3a92 | 801 | |
985d68a3 | 802 | case HostCmd_CMD_RF_REG_ACCESS: |
2c208890 | 803 | r.rf = &resp->params.rf_reg; |
985d68a3 YAP |
804 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset)); |
805 | reg_rw->value = cpu_to_le32((u32) r.bbp->value); | |
806 | break; | |
807 | case HostCmd_CMD_PMIC_REG_ACCESS: | |
2c208890 | 808 | r.pmic = &resp->params.pmic_reg; |
985d68a3 YAP |
809 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset)); |
810 | reg_rw->value = cpu_to_le32((u32) r.pmic->value); | |
811 | break; | |
812 | case HostCmd_CMD_CAU_REG_ACCESS: | |
2c208890 | 813 | r.rf = &resp->params.rf_reg; |
985d68a3 YAP |
814 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset)); |
815 | reg_rw->value = cpu_to_le32((u32) r.rf->value); | |
816 | break; | |
817 | case HostCmd_CMD_802_11_EEPROM_ACCESS: | |
2c208890 | 818 | r.eeprom = &resp->params.eeprom; |
985d68a3 YAP |
819 | pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count); |
820 | if (le16_to_cpu(eeprom->byte_count) < | |
821 | le16_to_cpu(r.eeprom->byte_count)) { | |
822 | eeprom->byte_count = cpu_to_le16(0); | |
823 | pr_debug("info: EEPROM read length is too big\n"); | |
5e6e3a92 BZ |
824 | return -1; |
825 | } | |
985d68a3 YAP |
826 | eeprom->offset = r.eeprom->offset; |
827 | eeprom->byte_count = r.eeprom->byte_count; | |
828 | if (le16_to_cpu(eeprom->byte_count) > 0) | |
829 | memcpy(&eeprom->value, &r.eeprom->value, | |
830 | le16_to_cpu(r.eeprom->byte_count)); | |
831 | ||
832 | break; | |
833 | default: | |
834 | return -1; | |
5e6e3a92 BZ |
835 | } |
836 | return 0; | |
837 | } | |
838 | ||
839 | /* | |
840 | * This function handles the command response of get IBSS coalescing status. | |
841 | * | |
842 | * If the received BSSID is different than the current one, the current BSSID, | |
843 | * beacon interval, ATIM window and ERP information are updated, along with | |
844 | * changing the ad-hoc state accordingly. | |
845 | */ | |
846 | static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv, | |
847 | struct host_cmd_ds_command *resp) | |
848 | { | |
849 | struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp = | |
9c05fd72 | 850 | &(resp->params.ibss_coalescing); |
5e6e3a92 BZ |
851 | |
852 | if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET) | |
853 | return 0; | |
854 | ||
acebe8c1 ZL |
855 | mwifiex_dbg(priv->adapter, INFO, |
856 | "info: new BSSID %pM\n", ibss_coal_resp->bssid); | |
5e6e3a92 BZ |
857 | |
858 | /* If rsp has NULL BSSID, Just return..... No Action */ | |
626a43de | 859 | if (is_zero_ether_addr(ibss_coal_resp->bssid)) { |
acebe8c1 | 860 | mwifiex_dbg(priv->adapter, FATAL, "new BSSID is NULL\n"); |
5e6e3a92 BZ |
861 | return 0; |
862 | } | |
863 | ||
864 | /* If BSSID is diff, modify current BSS parameters */ | |
fcad7668 | 865 | if (!ether_addr_equal(priv->curr_bss_params.bss_descriptor.mac_address, ibss_coal_resp->bssid)) { |
5e6e3a92 BZ |
866 | /* BSSID */ |
867 | memcpy(priv->curr_bss_params.bss_descriptor.mac_address, | |
868 | ibss_coal_resp->bssid, ETH_ALEN); | |
869 | ||
870 | /* Beacon Interval */ | |
871 | priv->curr_bss_params.bss_descriptor.beacon_period | |
872 | = le16_to_cpu(ibss_coal_resp->beacon_interval); | |
873 | ||
874 | /* ERP Information */ | |
875 | priv->curr_bss_params.bss_descriptor.erp_flags = | |
876 | (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect); | |
877 | ||
878 | priv->adhoc_state = ADHOC_COALESCED; | |
879 | } | |
880 | ||
881 | return 0; | |
882 | } | |
429d90d2 AP |
883 | static int mwifiex_ret_tdls_oper(struct mwifiex_private *priv, |
884 | struct host_cmd_ds_command *resp) | |
885 | { | |
886 | struct host_cmd_ds_tdls_oper *cmd_tdls_oper = &resp->params.tdls_oper; | |
887 | u16 reason = le16_to_cpu(cmd_tdls_oper->reason); | |
888 | u16 action = le16_to_cpu(cmd_tdls_oper->tdls_action); | |
e48e0de0 AP |
889 | struct mwifiex_sta_node *node = |
890 | mwifiex_get_sta_entry(priv, cmd_tdls_oper->peer_mac); | |
5e6e3a92 | 891 | |
429d90d2 AP |
892 | switch (action) { |
893 | case ACT_TDLS_DELETE: | |
d8d2f19f AP |
894 | if (reason) { |
895 | if (!node || reason == TDLS_ERR_LINK_NONEXISTENT) | |
acebe8c1 ZL |
896 | mwifiex_dbg(priv->adapter, ERROR, |
897 | "TDLS link delete for %pM failed: reason %d\n", | |
898 | cmd_tdls_oper->peer_mac, reason); | |
d8d2f19f | 899 | else |
acebe8c1 ZL |
900 | mwifiex_dbg(priv->adapter, ERROR, |
901 | "TDLS link delete for %pM failed: reason %d\n", | |
902 | cmd_tdls_oper->peer_mac, reason); | |
d8d2f19f | 903 | } else { |
acebe8c1 ZL |
904 | mwifiex_dbg(priv->adapter, MSG, |
905 | "TDLS link delete for %pM successful\n", | |
906 | cmd_tdls_oper->peer_mac); | |
d8d2f19f | 907 | } |
429d90d2 | 908 | break; |
e48e0de0 AP |
909 | case ACT_TDLS_CREATE: |
910 | if (reason) { | |
acebe8c1 ZL |
911 | mwifiex_dbg(priv->adapter, ERROR, |
912 | "TDLS link creation for %pM failed: reason %d", | |
913 | cmd_tdls_oper->peer_mac, reason); | |
e48e0de0 AP |
914 | if (node && reason != TDLS_ERR_LINK_EXISTS) |
915 | node->tdls_status = TDLS_SETUP_FAILURE; | |
916 | } else { | |
acebe8c1 ZL |
917 | mwifiex_dbg(priv->adapter, MSG, |
918 | "TDLS link creation for %pM successful", | |
919 | cmd_tdls_oper->peer_mac); | |
e48e0de0 AP |
920 | } |
921 | break; | |
1f4dfd8a AP |
922 | case ACT_TDLS_CONFIG: |
923 | if (reason) { | |
acebe8c1 ZL |
924 | mwifiex_dbg(priv->adapter, ERROR, |
925 | "TDLS link config for %pM failed, reason %d\n", | |
926 | cmd_tdls_oper->peer_mac, reason); | |
1f4dfd8a AP |
927 | if (node) |
928 | node->tdls_status = TDLS_SETUP_FAILURE; | |
929 | } else { | |
acebe8c1 ZL |
930 | mwifiex_dbg(priv->adapter, MSG, |
931 | "TDLS link config for %pM successful\n", | |
932 | cmd_tdls_oper->peer_mac); | |
1f4dfd8a AP |
933 | } |
934 | break; | |
429d90d2 | 935 | default: |
acebe8c1 ZL |
936 | mwifiex_dbg(priv->adapter, ERROR, |
937 | "Unknown TDLS command action response %d", action); | |
429d90d2 AP |
938 | return -1; |
939 | } | |
940 | ||
941 | return 0; | |
942 | } | |
fa444bf8 AK |
943 | /* |
944 | * This function handles the command response for subscribe event command. | |
945 | */ | |
946 | static int mwifiex_ret_subsc_evt(struct mwifiex_private *priv, | |
e69d1ff1 | 947 | struct host_cmd_ds_command *resp) |
fa444bf8 AK |
948 | { |
949 | struct host_cmd_ds_802_11_subsc_evt *cmd_sub_event = | |
2c208890 | 950 | &resp->params.subsc_evt; |
fa444bf8 AK |
951 | |
952 | /* For every subscribe event command (Get/Set/Clear), FW reports the | |
953 | * current set of subscribed events*/ | |
acebe8c1 ZL |
954 | mwifiex_dbg(priv->adapter, EVENT, |
955 | "Bitmap of currently subscribed events: %16x\n", | |
956 | le16_to_cpu(cmd_sub_event->events)); | |
fa444bf8 | 957 | |
fa444bf8 AK |
958 | return 0; |
959 | } | |
960 | ||
388ec385 AK |
961 | /* This function handles the command response of set_cfg_data */ |
962 | static int mwifiex_ret_cfg_data(struct mwifiex_private *priv, | |
963 | struct host_cmd_ds_command *resp) | |
964 | { | |
965 | if (resp->result != HostCmd_RESULT_OK) { | |
acebe8c1 | 966 | mwifiex_dbg(priv->adapter, ERROR, "Cal data cmd resp failed\n"); |
388ec385 AK |
967 | return -1; |
968 | } | |
969 | ||
970 | return 0; | |
971 | } | |
972 | ||
92263a84 ZL |
973 | /** This Function handles the command response of sdio rx aggr */ |
974 | static int mwifiex_ret_sdio_rx_aggr_cfg(struct mwifiex_private *priv, | |
975 | struct host_cmd_ds_command *resp) | |
976 | { | |
977 | struct mwifiex_adapter *adapter = priv->adapter; | |
978 | struct host_cmd_sdio_sp_rx_aggr_cfg *cfg = | |
979 | &resp->params.sdio_rx_aggr_cfg; | |
980 | ||
981 | adapter->sdio_rx_aggr_enable = cfg->enable; | |
982 | adapter->sdio_rx_block_size = le16_to_cpu(cfg->block_size); | |
983 | ||
984 | return 0; | |
985 | } | |
986 | ||
5e6e3a92 BZ |
987 | /* |
988 | * This function handles the command responses. | |
989 | * | |
990 | * This is a generic function, which calls command specific | |
991 | * response handlers based on the command ID. | |
992 | */ | |
a5ffddb7 AK |
993 | int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, |
994 | struct host_cmd_ds_command *resp) | |
5e6e3a92 BZ |
995 | { |
996 | int ret = 0; | |
997 | struct mwifiex_adapter *adapter = priv->adapter; | |
5e6e3a92 BZ |
998 | void *data_buf = adapter->curr_cmd->data_buf; |
999 | ||
1000 | /* If the command is not successful, cleanup and return failure */ | |
1001 | if (resp->result != HostCmd_RESULT_OK) { | |
600f5d90 | 1002 | mwifiex_process_cmdresp_error(priv, resp); |
5e6e3a92 BZ |
1003 | return -1; |
1004 | } | |
1005 | /* Command successful, handle response */ | |
1006 | switch (cmdresp_no) { | |
1007 | case HostCmd_CMD_GET_HW_SPEC: | |
1008 | ret = mwifiex_ret_get_hw_spec(priv, resp); | |
1009 | break; | |
388ec385 AK |
1010 | case HostCmd_CMD_CFG_DATA: |
1011 | ret = mwifiex_ret_cfg_data(priv, resp); | |
1012 | break; | |
5e6e3a92 BZ |
1013 | case HostCmd_CMD_MAC_CONTROL: |
1014 | break; | |
1015 | case HostCmd_CMD_802_11_MAC_ADDRESS: | |
1016 | ret = mwifiex_ret_802_11_mac_address(priv, resp); | |
1017 | break; | |
1018 | case HostCmd_CMD_MAC_MULTICAST_ADR: | |
1019 | ret = mwifiex_ret_mac_multicast_adr(priv, resp); | |
1020 | break; | |
1021 | case HostCmd_CMD_TX_RATE_CFG: | |
006606c0 | 1022 | ret = mwifiex_ret_tx_rate_cfg(priv, resp); |
5e6e3a92 BZ |
1023 | break; |
1024 | case HostCmd_CMD_802_11_SCAN: | |
600f5d90 AK |
1025 | ret = mwifiex_ret_802_11_scan(priv, resp); |
1026 | adapter->curr_cmd->wait_q_enabled = false; | |
5e6e3a92 | 1027 | break; |
21f58d20 | 1028 | case HostCmd_CMD_802_11_SCAN_EXT: |
bf354433 | 1029 | ret = mwifiex_ret_802_11_scan_ext(priv, resp); |
21f58d20 AK |
1030 | adapter->curr_cmd->wait_q_enabled = false; |
1031 | break; | |
5e6e3a92 | 1032 | case HostCmd_CMD_802_11_BG_SCAN_QUERY: |
600f5d90 | 1033 | ret = mwifiex_ret_802_11_scan(priv, resp); |
acebe8c1 ZL |
1034 | mwifiex_dbg(adapter, CMD, |
1035 | "info: CMD_RESP: BG_SCAN result is ready!\n"); | |
5e6e3a92 BZ |
1036 | break; |
1037 | case HostCmd_CMD_TXPWR_CFG: | |
a5ffddb7 | 1038 | ret = mwifiex_ret_tx_power_cfg(priv, resp); |
5e6e3a92 | 1039 | break; |
caa8984f AK |
1040 | case HostCmd_CMD_RF_TX_PWR: |
1041 | ret = mwifiex_ret_rf_tx_power(priv, resp); | |
1042 | break; | |
8a279d5b AK |
1043 | case HostCmd_CMD_RF_ANTENNA: |
1044 | ret = mwifiex_ret_rf_antenna(priv, resp); | |
1045 | break; | |
5e6e3a92 BZ |
1046 | case HostCmd_CMD_802_11_PS_MODE_ENH: |
1047 | ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf); | |
1048 | break; | |
1049 | case HostCmd_CMD_802_11_HS_CFG_ENH: | |
1050 | ret = mwifiex_ret_802_11_hs_cfg(priv, resp); | |
1051 | break; | |
1052 | case HostCmd_CMD_802_11_ASSOCIATE: | |
600f5d90 | 1053 | ret = mwifiex_ret_802_11_associate(priv, resp); |
5e6e3a92 BZ |
1054 | break; |
1055 | case HostCmd_CMD_802_11_DEAUTHENTICATE: | |
1056 | ret = mwifiex_ret_802_11_deauthenticate(priv, resp); | |
1057 | break; | |
1058 | case HostCmd_CMD_802_11_AD_HOC_START: | |
1059 | case HostCmd_CMD_802_11_AD_HOC_JOIN: | |
600f5d90 | 1060 | ret = mwifiex_ret_802_11_ad_hoc(priv, resp); |
5e6e3a92 BZ |
1061 | break; |
1062 | case HostCmd_CMD_802_11_AD_HOC_STOP: | |
1063 | ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp); | |
1064 | break; | |
1065 | case HostCmd_CMD_802_11_GET_LOG: | |
1066 | ret = mwifiex_ret_get_log(priv, resp, data_buf); | |
1067 | break; | |
1068 | case HostCmd_CMD_RSSI_INFO: | |
958a4a86 | 1069 | ret = mwifiex_ret_802_11_rssi_info(priv, resp); |
5e6e3a92 BZ |
1070 | break; |
1071 | case HostCmd_CMD_802_11_SNMP_MIB: | |
1072 | ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf); | |
1073 | break; | |
1074 | case HostCmd_CMD_802_11_TX_RATE_QUERY: | |
1075 | ret = mwifiex_ret_802_11_tx_rate_query(priv, resp); | |
1076 | break; | |
5e6e3a92 BZ |
1077 | case HostCmd_CMD_VERSION_EXT: |
1078 | ret = mwifiex_ret_ver_ext(priv, resp, data_buf); | |
1079 | break; | |
7feb4c48 SP |
1080 | case HostCmd_CMD_REMAIN_ON_CHAN: |
1081 | ret = mwifiex_ret_remain_on_chan(priv, resp, data_buf); | |
1082 | break; | |
83c78da9 YAP |
1083 | case HostCmd_CMD_11AC_CFG: |
1084 | break; | |
e1a2b7a3 SP |
1085 | case HostCmd_CMD_P2P_MODE_CFG: |
1086 | ret = mwifiex_ret_p2p_mode_cfg(priv, resp, data_buf); | |
1087 | break; | |
3cec6870 | 1088 | case HostCmd_CMD_MGMT_FRAME_REG: |
5e6e3a92 BZ |
1089 | case HostCmd_CMD_FUNC_INIT: |
1090 | case HostCmd_CMD_FUNC_SHUTDOWN: | |
1091 | break; | |
1092 | case HostCmd_CMD_802_11_KEY_MATERIAL: | |
1093 | ret = mwifiex_ret_802_11_key_material(priv, resp); | |
1094 | break; | |
1095 | case HostCmd_CMD_802_11D_DOMAIN_INFO: | |
1096 | ret = mwifiex_ret_802_11d_domain_info(priv, resp); | |
1097 | break; | |
1098 | case HostCmd_CMD_11N_ADDBA_REQ: | |
1099 | ret = mwifiex_ret_11n_addba_req(priv, resp); | |
1100 | break; | |
1101 | case HostCmd_CMD_11N_DELBA: | |
1102 | ret = mwifiex_ret_11n_delba(priv, resp); | |
1103 | break; | |
1104 | case HostCmd_CMD_11N_ADDBA_RSP: | |
1105 | ret = mwifiex_ret_11n_addba_resp(priv, resp); | |
1106 | break; | |
1107 | case HostCmd_CMD_RECONFIGURE_TX_BUFF: | |
1108 | adapter->tx_buf_size = (u16) le16_to_cpu(resp->params. | |
1109 | tx_buf.buff_size); | |
9c05fd72 YAP |
1110 | adapter->tx_buf_size = (adapter->tx_buf_size |
1111 | / MWIFIEX_SDIO_BLOCK_SIZE) | |
1112 | * MWIFIEX_SDIO_BLOCK_SIZE; | |
5e6e3a92 | 1113 | adapter->curr_tx_buf_size = adapter->tx_buf_size; |
acebe8c1 ZL |
1114 | mwifiex_dbg(adapter, CMD, "cmd: curr_tx_buf_size=%d\n", |
1115 | adapter->curr_tx_buf_size); | |
5e6e3a92 BZ |
1116 | |
1117 | if (adapter->if_ops.update_mp_end_port) | |
1118 | adapter->if_ops.update_mp_end_port(adapter, | |
9c05fd72 | 1119 | le16_to_cpu(resp->params.tx_buf.mp_end_port)); |
5e6e3a92 BZ |
1120 | break; |
1121 | case HostCmd_CMD_AMSDU_AGGR_CTRL: | |
5e6e3a92 BZ |
1122 | break; |
1123 | case HostCmd_CMD_WMM_GET_STATUS: | |
1124 | ret = mwifiex_ret_wmm_get_status(priv, resp); | |
1125 | break; | |
1126 | case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS: | |
1127 | ret = mwifiex_ret_ibss_coalescing_status(priv, resp); | |
1128 | break; | |
c2c6c85f CL |
1129 | case HostCmd_CMD_MEM_ACCESS: |
1130 | ret = mwifiex_ret_mem_access(priv, resp, data_buf); | |
1131 | break; | |
5e6e3a92 BZ |
1132 | case HostCmd_CMD_MAC_REG_ACCESS: |
1133 | case HostCmd_CMD_BBP_REG_ACCESS: | |
1134 | case HostCmd_CMD_RF_REG_ACCESS: | |
1135 | case HostCmd_CMD_PMIC_REG_ACCESS: | |
1136 | case HostCmd_CMD_CAU_REG_ACCESS: | |
1137 | case HostCmd_CMD_802_11_EEPROM_ACCESS: | |
1138 | ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf); | |
1139 | break; | |
1140 | case HostCmd_CMD_SET_BSS_MODE: | |
1141 | break; | |
1142 | case HostCmd_CMD_11N_CFG: | |
5e6e3a92 | 1143 | break; |
d930faee AK |
1144 | case HostCmd_CMD_PCIE_DESC_DETAILS: |
1145 | break; | |
fa444bf8 | 1146 | case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: |
e69d1ff1 | 1147 | ret = mwifiex_ret_subsc_evt(priv, resp); |
fa444bf8 | 1148 | break; |
40d07030 AP |
1149 | case HostCmd_CMD_UAP_SYS_CONFIG: |
1150 | break; | |
1151 | case HostCmd_CMD_UAP_BSS_START: | |
fc8f0456 AK |
1152 | adapter->tx_lock_flag = false; |
1153 | adapter->pps_uapsd_mode = false; | |
1154 | adapter->delay_null_pkt = false; | |
40d07030 AP |
1155 | priv->bss_started = 1; |
1156 | break; | |
1157 | case HostCmd_CMD_UAP_BSS_STOP: | |
1158 | priv->bss_started = 0; | |
1159 | break; | |
0f9e9b8b AP |
1160 | case HostCmd_CMD_UAP_STA_DEAUTH: |
1161 | break; | |
7da060c1 AK |
1162 | case HostCmd_CMD_MEF_CFG: |
1163 | break; | |
562fc5b3 AK |
1164 | case HostCmd_CMD_COALESCE_CFG: |
1165 | break; | |
429d90d2 AP |
1166 | case HostCmd_CMD_TDLS_OPER: |
1167 | ret = mwifiex_ret_tdls_oper(priv, resp); | |
1168 | break; | |
85afb186 AP |
1169 | case HostCmd_CMD_CHAN_REPORT_REQUEST: |
1170 | break; | |
92263a84 ZL |
1171 | case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG: |
1172 | ret = mwifiex_ret_sdio_rx_aggr_cfg(priv, resp); | |
1173 | break; | |
5e6e3a92 | 1174 | default: |
acebe8c1 ZL |
1175 | mwifiex_dbg(adapter, ERROR, |
1176 | "CMD_RESP: unknown cmd response %#x\n", | |
1177 | resp->command); | |
5e6e3a92 BZ |
1178 | break; |
1179 | } | |
1180 | ||
1181 | return ret; | |
1182 | } |