mwifiex: remove redundant "return" at end of void function
[deliverable/linux.git] / drivers / net / wireless / mwifiex / sta_cmdresp.c
CommitLineData
5e6e3a92
BZ
1/*
2 * Marvell Wireless LAN device driver: station command response handling
3 *
4 * Copyright (C) 2011, Marvell International Ltd.
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"
27
28
29/*
30 * This function handles the command response error case.
31 *
32 * For scan response error, the function cancels all the pending
33 * scan commands and generates an event to inform the applications
34 * of the scan completion.
35 *
36 * For Power Save command failure, we do not retry enter PS
37 * command in case of Ad-hoc mode.
38 *
39 * For all other response errors, the current command buffer is freed
40 * and returned to the free command queue.
41 */
42static void
43mwifiex_process_cmdresp_error(struct mwifiex_private *priv,
600f5d90 44 struct host_cmd_ds_command *resp)
5e6e3a92
BZ
45{
46 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
47 struct mwifiex_adapter *adapter = priv->adapter;
2b06bdbe 48 struct host_cmd_ds_802_11_ps_mode_enh *pm;
5e6e3a92
BZ
49 unsigned long flags;
50
51 dev_err(adapter->dev, "CMD_RESP: cmd %#x error, result=%#x\n",
52 resp->command, resp->result);
600f5d90
AK
53
54 if (adapter->curr_cmd->wait_q_enabled)
55 adapter->cmd_wait_q.status = -1;
5e6e3a92
BZ
56
57 switch (le16_to_cpu(resp->command)) {
58 case HostCmd_CMD_802_11_PS_MODE_ENH:
2b06bdbe
MY
59 pm = &resp->params.psmode_enh;
60 dev_err(adapter->dev, "PS_MODE_ENH cmd failed: "
61 "result=0x%x action=0x%X\n",
5e6e3a92 62 resp->result, le16_to_cpu(pm->action));
2b06bdbe
MY
63 /* We do not re-try enter-ps command in ad-hoc mode. */
64 if (le16_to_cpu(pm->action) == EN_AUTO_PS &&
65 (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) &&
66 priv->bss_mode == NL80211_IFTYPE_ADHOC)
67 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
68
5e6e3a92
BZ
69 break;
70 case HostCmd_CMD_802_11_SCAN:
71 /* Cancel all pending scan command */
72 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
73 list_for_each_entry_safe(cmd_node, tmp_node,
74 &adapter->scan_pending_q, list) {
75 list_del(&cmd_node->list);
76 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
77 flags);
78 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
79 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
80 }
81 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
82
83 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
84 adapter->scan_processing = false;
85 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
86 if (priv->report_scan_result)
87 priv->report_scan_result = false;
88 if (priv->scan_pending_on_block) {
89 priv->scan_pending_on_block = false;
90 up(&priv->async_sem);
91 }
92 break;
93
94 case HostCmd_CMD_MAC_CONTROL:
95 break;
96
97 default:
98 break;
99 }
100 /* Handling errors here */
101 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
102
103 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
104 adapter->curr_cmd = NULL;
105 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
5e6e3a92
BZ
106}
107
108/*
109 * This function handles the command response of get RSSI info.
110 *
111 * Handling includes changing the header fields into CPU format
112 * and saving the following parameters in driver -
113 * - Last data and beacon RSSI value
114 * - Average data and beacon RSSI value
115 * - Last data and beacon NF value
116 * - Average data and beacon NF value
117 *
118 * The parameters are send to the application as well, along with
119 * calculated SNR values.
120 */
121static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv,
122 struct host_cmd_ds_command *resp,
123 void *data_buf)
124{
125 struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp =
126 &resp->params.rssi_info_rsp;
127 struct mwifiex_ds_get_signal *signal = NULL;
128
129 priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last);
130 priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last);
131
132 priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg);
133 priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg);
134
135 priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last);
136 priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last);
137
138 priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg);
139 priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg);
140
141 /* Need to indicate IOCTL complete */
142 if (data_buf) {
143 signal = (struct mwifiex_ds_get_signal *) data_buf;
144 memset(signal, 0, sizeof(struct mwifiex_ds_get_signal));
145
146 signal->selector = ALL_RSSI_INFO_MASK;
147
148 /* RSSI */
149 signal->bcn_rssi_last = priv->bcn_rssi_last;
150 signal->bcn_rssi_avg = priv->bcn_rssi_avg;
151 signal->data_rssi_last = priv->data_rssi_last;
152 signal->data_rssi_avg = priv->data_rssi_avg;
153
154 /* SNR */
155 signal->bcn_snr_last =
156 CAL_SNR(priv->bcn_rssi_last, priv->bcn_nf_last);
157 signal->bcn_snr_avg =
158 CAL_SNR(priv->bcn_rssi_avg, priv->bcn_nf_avg);
159 signal->data_snr_last =
160 CAL_SNR(priv->data_rssi_last, priv->data_nf_last);
161 signal->data_snr_avg =
162 CAL_SNR(priv->data_rssi_avg, priv->data_nf_avg);
163
164 /* NF */
165 signal->bcn_nf_last = priv->bcn_nf_last;
166 signal->bcn_nf_avg = priv->bcn_nf_avg;
167 signal->data_nf_last = priv->data_nf_last;
168 signal->data_nf_avg = priv->data_nf_avg;
169 }
170
171 return 0;
172}
173
174/*
175 * This function handles the command response of set/get SNMP
176 * MIB parameters.
177 *
178 * Handling includes changing the header fields into CPU format
179 * and saving the parameter in driver.
180 *
181 * The following parameters are supported -
182 * - Fragmentation threshold
183 * - RTS threshold
184 * - Short retry limit
185 */
186static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv,
187 struct host_cmd_ds_command *resp,
188 void *data_buf)
189{
190 struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
191 u16 oid = le16_to_cpu(smib->oid);
192 u16 query_type = le16_to_cpu(smib->query_type);
193 u32 ul_temp;
194
195 dev_dbg(priv->adapter->dev, "info: SNMP_RESP: oid value = %#x,"
196 " query_type = %#x, buf size = %#x\n",
197 oid, query_type, le16_to_cpu(smib->buf_size));
198 if (query_type == HostCmd_ACT_GEN_GET) {
199 ul_temp = le16_to_cpu(*((__le16 *) (smib->value)));
200 if (data_buf)
201 *(u32 *)data_buf = ul_temp;
202 switch (oid) {
203 case FRAG_THRESH_I:
204 dev_dbg(priv->adapter->dev,
205 "info: SNMP_RESP: FragThsd =%u\n", ul_temp);
206 break;
207 case RTS_THRESH_I:
208 dev_dbg(priv->adapter->dev,
209 "info: SNMP_RESP: RTSThsd =%u\n", ul_temp);
210 break;
211 case SHORT_RETRY_LIM_I:
212 dev_dbg(priv->adapter->dev,
213 "info: SNMP_RESP: TxRetryCount=%u\n", ul_temp);
214 break;
215 default:
216 break;
217 }
218 }
219
220 return 0;
221}
222
223/*
224 * This function handles the command response of get log request
225 *
226 * Handling includes changing the header fields into CPU format
227 * and sending the received parameters to application.
228 */
229static int mwifiex_ret_get_log(struct mwifiex_private *priv,
230 struct host_cmd_ds_command *resp,
231 void *data_buf)
232{
233 struct host_cmd_ds_802_11_get_log *get_log =
234 (struct host_cmd_ds_802_11_get_log *) &resp->params.get_log;
235 struct mwifiex_ds_get_stats *stats = NULL;
236
237 if (data_buf) {
238 stats = (struct mwifiex_ds_get_stats *) data_buf;
239 stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame);
240 stats->failed = le32_to_cpu(get_log->failed);
241 stats->retry = le32_to_cpu(get_log->retry);
242 stats->multi_retry = le32_to_cpu(get_log->multi_retry);
243 stats->frame_dup = le32_to_cpu(get_log->frame_dup);
244 stats->rts_success = le32_to_cpu(get_log->rts_success);
245 stats->rts_failure = le32_to_cpu(get_log->rts_failure);
246 stats->ack_failure = le32_to_cpu(get_log->ack_failure);
247 stats->rx_frag = le32_to_cpu(get_log->rx_frag);
248 stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame);
249 stats->fcs_error = le32_to_cpu(get_log->fcs_error);
250 stats->tx_frame = le32_to_cpu(get_log->tx_frame);
251 stats->wep_icv_error[0] =
252 le32_to_cpu(get_log->wep_icv_err_cnt[0]);
253 stats->wep_icv_error[1] =
254 le32_to_cpu(get_log->wep_icv_err_cnt[1]);
255 stats->wep_icv_error[2] =
256 le32_to_cpu(get_log->wep_icv_err_cnt[2]);
257 stats->wep_icv_error[3] =
258 le32_to_cpu(get_log->wep_icv_err_cnt[3]);
259 }
260
261 return 0;
262}
263
264/*
265 * This function handles the command response of set/get Tx rate
266 * configurations.
267 *
268 * Handling includes changing the header fields into CPU format
269 * and saving the following parameters in driver -
270 * - DSSS rate bitmap
271 * - OFDM rate bitmap
272 * - HT MCS rate bitmaps
273 *
274 * Based on the new rate bitmaps, the function re-evaluates if
275 * auto data rate has been activated. If not, it sends another
276 * query to the firmware to get the current Tx data rate and updates
277 * the driver value.
278 */
279static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
280 struct host_cmd_ds_command *resp,
281 void *data_buf)
282{
283 struct mwifiex_adapter *adapter = priv->adapter;
284 struct mwifiex_rate_cfg *ds_rate = NULL;
285 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
286 struct mwifiex_rate_scope *rate_scope;
287 struct mwifiex_ie_types_header *head = NULL;
288 u16 tlv, tlv_buf_len;
289 u8 *tlv_buf;
290 u32 i;
291 int ret = 0;
292
293 tlv_buf = (u8 *) ((u8 *) rate_cfg) +
294 sizeof(struct host_cmd_ds_tx_rate_cfg);
295 tlv_buf_len = *(u16 *) (tlv_buf + sizeof(u16));
296
297 while (tlv_buf && tlv_buf_len > 0) {
298 tlv = (*tlv_buf);
299 tlv = tlv | (*(tlv_buf + 1) << 8);
300
301 switch (tlv) {
302 case TLV_TYPE_RATE_SCOPE:
303 rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
304 priv->bitmap_rates[0] =
305 le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
306 priv->bitmap_rates[1] =
307 le16_to_cpu(rate_scope->ofdm_rate_bitmap);
308 for (i = 0;
309 i <
310 sizeof(rate_scope->ht_mcs_rate_bitmap) /
311 sizeof(u16); i++)
312 priv->bitmap_rates[2 + i] =
313 le16_to_cpu(rate_scope->
314 ht_mcs_rate_bitmap[i]);
315 break;
316 /* Add RATE_DROP tlv here */
317 }
318
319 head = (struct mwifiex_ie_types_header *) tlv_buf;
320 tlv_buf += le16_to_cpu(head->len) + sizeof(*head);
321 tlv_buf_len -= le16_to_cpu(head->len);
322 }
323
324 priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
325
326 if (priv->is_data_rate_auto)
327 priv->data_rate = 0;
328 else
600f5d90 329 ret = mwifiex_send_cmd_async(priv,
5e6e3a92 330 HostCmd_CMD_802_11_TX_RATE_QUERY,
600f5d90 331 HostCmd_ACT_GEN_GET, 0, NULL);
5e6e3a92
BZ
332
333 if (data_buf) {
334 ds_rate = (struct mwifiex_rate_cfg *) data_buf;
335 if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
336 if (priv->is_data_rate_auto) {
337 ds_rate->is_rate_auto = 1;
338 } else {
339 ds_rate->rate =
340 mwifiex_get_rate_index(adapter,
341 priv->
342 bitmap_rates,
343 sizeof(priv->
344 bitmap_rates));
345 if (ds_rate->rate >=
346 MWIFIEX_RATE_BITMAP_OFDM0
347 && ds_rate->rate <=
348 MWIFIEX_RATE_BITMAP_OFDM7)
349 ds_rate->rate -=
350 (MWIFIEX_RATE_BITMAP_OFDM0 -
351 MWIFIEX_RATE_INDEX_OFDM0);
352 if (ds_rate->rate >=
353 MWIFIEX_RATE_BITMAP_MCS0
354 && ds_rate->rate <=
355 MWIFIEX_RATE_BITMAP_MCS127)
356 ds_rate->rate -=
357 (MWIFIEX_RATE_BITMAP_MCS0 -
358 MWIFIEX_RATE_INDEX_MCS0);
359 }
360 }
361 }
362
363 return ret;
364}
365
366/*
367 * This function handles the command response of get Tx power level.
368 *
369 * Handling includes saving the maximum and minimum Tx power levels
370 * in driver, as well as sending the values to user.
371 */
372static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
373{
374 int length = -1, max_power = -1, min_power = -1;
375 struct mwifiex_types_power_group *pg_tlv_hdr = NULL;
376 struct mwifiex_power_group *pg = NULL;
377
378 if (data_buf) {
379 pg_tlv_hdr =
380 (struct mwifiex_types_power_group *) ((u8 *) data_buf
381 + sizeof(struct host_cmd_ds_txpwr_cfg));
382 pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr +
383 sizeof(struct mwifiex_types_power_group));
384 length = pg_tlv_hdr->length;
385 if (length > 0) {
386 max_power = pg->power_max;
387 min_power = pg->power_min;
388 length -= sizeof(struct mwifiex_power_group);
389 }
390 while (length) {
391 pg++;
392 if (max_power < pg->power_max)
393 max_power = pg->power_max;
394
395 if (min_power > pg->power_min)
396 min_power = pg->power_min;
397
398 length -= sizeof(struct mwifiex_power_group);
399 }
400 if (pg_tlv_hdr->length > 0) {
401 priv->min_tx_power_level = (u8) min_power;
402 priv->max_tx_power_level = (u8) max_power;
403 }
404 } else {
405 return -1;
406 }
407
408 return 0;
409}
410
411/*
412 * This function handles the command response of set/get Tx power
413 * configurations.
414 *
415 * Handling includes changing the header fields into CPU format
416 * and saving the current Tx power level in driver.
417 */
418static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
419 struct host_cmd_ds_command *resp,
420 void *data_buf)
421{
422 struct mwifiex_adapter *adapter = priv->adapter;
423 struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg;
424 struct mwifiex_types_power_group *pg_tlv_hdr = NULL;
425 struct mwifiex_power_group *pg = NULL;
426 u16 action = le16_to_cpu(txp_cfg->action);
427
428 switch (action) {
429 case HostCmd_ACT_GEN_GET:
430 {
431 pg_tlv_hdr =
432 (struct mwifiex_types_power_group *) ((u8 *)
433 txp_cfg +
434 sizeof
435 (struct
436 host_cmd_ds_txpwr_cfg));
437 pg = (struct mwifiex_power_group *) ((u8 *)
438 pg_tlv_hdr +
439 sizeof(struct
440 mwifiex_types_power_group));
441 if (adapter->hw_status ==
442 MWIFIEX_HW_STATUS_INITIALIZING)
443 mwifiex_get_power_level(priv, txp_cfg);
444 priv->tx_power_level = (u16) pg->power_min;
445 break;
446 }
447 case HostCmd_ACT_GEN_SET:
448 if (le32_to_cpu(txp_cfg->mode)) {
449 pg_tlv_hdr =
450 (struct mwifiex_types_power_group *) ((u8 *)
451 txp_cfg +
452 sizeof
453 (struct
454 host_cmd_ds_txpwr_cfg));
455 pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr
456 +
457 sizeof(struct
458 mwifiex_types_power_group));
459 if (pg->power_max == pg->power_min)
460 priv->tx_power_level = (u16) pg->power_min;
461 }
462 break;
463 default:
464 dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n",
465 action);
466 return 0;
467 }
468 dev_dbg(adapter->dev,
469 "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n",
470 priv->tx_power_level, priv->max_tx_power_level,
471 priv->min_tx_power_level);
472
473 return 0;
474}
475
476/*
477 * This function handles the command response of set/get MAC address.
478 *
479 * Handling includes saving the MAC address in driver.
480 */
481static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv,
482 struct host_cmd_ds_command *resp)
483{
484 struct host_cmd_ds_802_11_mac_address *cmd_mac_addr =
485 &resp->params.mac_addr;
486
487 memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN);
488
489 dev_dbg(priv->adapter->dev,
490 "info: set mac address: %pM\n", priv->curr_addr);
491
492 return 0;
493}
494
495/*
496 * This function handles the command response of set/get MAC multicast
497 * address.
498 */
499static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv,
500 struct host_cmd_ds_command *resp)
501{
502 return 0;
503}
504
505/*
506 * This function handles the command response of get Tx rate query.
507 *
508 * Handling includes changing the header fields into CPU format
509 * and saving the Tx rate and HT information parameters in driver.
510 *
511 * Both rate configuration and current data rate can be retrieved
512 * with this request.
513 */
514static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv,
515 struct host_cmd_ds_command *resp)
516{
517 struct mwifiex_adapter *adapter = priv->adapter;
518
519 priv->tx_rate = resp->params.tx_rate.tx_rate;
520 priv->tx_htinfo = resp->params.tx_rate.ht_info;
521 if (!priv->is_data_rate_auto)
522 priv->data_rate =
523 mwifiex_index_to_data_rate(adapter, priv->tx_rate,
524 priv->tx_htinfo);
525
526 return 0;
527}
528
529/*
530 * This function handles the command response of a deauthenticate
531 * command.
532 *
533 * If the deauthenticated MAC matches the current BSS MAC, the connection
534 * state is reset.
535 */
536static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
537 struct host_cmd_ds_command *resp)
538{
539 struct mwifiex_adapter *adapter = priv->adapter;
540
541 adapter->dbg.num_cmd_deauth++;
542 if (!memcmp(resp->params.deauth.mac_addr,
543 &priv->curr_bss_params.bss_descriptor.mac_address,
544 sizeof(resp->params.deauth.mac_addr)))
545 mwifiex_reset_connect_state(priv);
546
547 return 0;
548}
549
550/*
551 * This function handles the command response of ad-hoc stop.
552 *
553 * The function resets the connection state in driver.
554 */
555static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
556 struct host_cmd_ds_command *resp)
557{
558 mwifiex_reset_connect_state(priv);
559 return 0;
560}
561
562/*
563 * This function handles the command response of set/get key material.
564 *
565 * Handling includes updating the driver parameters to reflect the
566 * changes.
567 */
568static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv,
569 struct host_cmd_ds_command *resp)
570{
571 struct host_cmd_ds_802_11_key_material *key =
572 &resp->params.key_material;
573
574 if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
6a35a0ac 575 if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
5e6e3a92
BZ
576 dev_dbg(priv->adapter->dev, "info: key: GTK is set\n");
577 priv->wpa_is_gtk_set = true;
578 priv->scan_block = false;
579 }
580 }
581
582 memset(priv->aes_key.key_param_set.key, 0,
583 sizeof(key->key_param_set.key));
584 priv->aes_key.key_param_set.key_len = key->key_param_set.key_len;
585 memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key,
586 le16_to_cpu(priv->aes_key.key_param_set.key_len));
587
588 return 0;
589}
590
591/*
592 * This function handles the command response of get 11d domain information.
593 */
594static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
595 struct host_cmd_ds_command *resp)
596{
597 struct host_cmd_ds_802_11d_domain_info_rsp *domain_info =
598 &resp->params.domain_info_resp;
599 struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain;
600 u16 action = le16_to_cpu(domain_info->action);
601 u8 no_of_triplet = 0;
602
603 no_of_triplet = (u8) ((le16_to_cpu(domain->header.len) -
604 IEEE80211_COUNTRY_STRING_LEN) /
605 sizeof(struct ieee80211_country_ie_triplet));
606
607 dev_dbg(priv->adapter->dev, "info: 11D Domain Info Resp:"
608 " no_of_triplet=%d\n", no_of_triplet);
609
610 if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) {
611 dev_warn(priv->adapter->dev,
612 "11D: invalid number of triplets %d "
613 "returned!!\n", no_of_triplet);
614 return -1;
615 }
616
617 switch (action) {
618 case HostCmd_ACT_GEN_SET: /* Proc Set Action */
619 break;
620 case HostCmd_ACT_GEN_GET:
621 break;
622 default:
623 dev_err(priv->adapter->dev,
624 "11D: invalid action:%d\n", domain_info->action);
625 return -1;
626 }
627
628 return 0;
629}
630
631/*
632 * This function handles the command response of get RF channel.
633 *
634 * Handling includes changing the header fields into CPU format
635 * and saving the new channel in driver.
636 */
637static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv,
638 struct host_cmd_ds_command *resp,
639 void *data_buf)
640{
641 struct host_cmd_ds_802_11_rf_channel *rf_channel =
642 &resp->params.rf_channel;
643 u16 new_channel = le16_to_cpu(rf_channel->current_channel);
644
645 if (priv->curr_bss_params.bss_descriptor.channel != new_channel) {
646 dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n",
647 priv->curr_bss_params.bss_descriptor.channel,
648 new_channel);
649 /* Update the channel again */
650 priv->curr_bss_params.bss_descriptor.channel = new_channel;
651 }
652 if (data_buf)
653 *((u16 *)data_buf) = new_channel;
654
655 return 0;
656}
657
658/*
659 * This function handles the command response of get extended version.
660 *
661 * Handling includes forming the extended version string and sending it
662 * to application.
663 */
664static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
665 struct host_cmd_ds_command *resp,
666 void *data_buf)
667{
668 struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext;
669 struct host_cmd_ds_version_ext *version_ext = NULL;
670
671 if (data_buf) {
672 version_ext = (struct host_cmd_ds_version_ext *)data_buf;
673 version_ext->version_str_sel = ver_ext->version_str_sel;
674 memcpy(version_ext->version_str, ver_ext->version_str,
675 sizeof(char) * 128);
676 memcpy(priv->version_str, ver_ext->version_str, 128);
677 }
678 return 0;
679}
680
681/*
682 * This function handles the command response of register access.
683 *
684 * The register value and offset are returned to the user. For EEPROM
685 * access, the byte count is also returned.
686 */
687static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
688 void *data_buf)
689{
690 struct mwifiex_ds_reg_rw *reg_rw = NULL;
691 struct mwifiex_ds_read_eeprom *eeprom = NULL;
692
693 if (data_buf) {
694 reg_rw = (struct mwifiex_ds_reg_rw *) data_buf;
695 eeprom = (struct mwifiex_ds_read_eeprom *) data_buf;
696 switch (type) {
697 case HostCmd_CMD_MAC_REG_ACCESS:
698 {
699 struct host_cmd_ds_mac_reg_access *reg;
700 reg = (struct host_cmd_ds_mac_reg_access *)
701 &resp->params.mac_reg;
702 reg_rw->offset = cpu_to_le32(
703 (u32) le16_to_cpu(reg->offset));
704 reg_rw->value = reg->value;
705 break;
706 }
707 case HostCmd_CMD_BBP_REG_ACCESS:
708 {
709 struct host_cmd_ds_bbp_reg_access *reg;
710 reg = (struct host_cmd_ds_bbp_reg_access *)
711 &resp->params.bbp_reg;
712 reg_rw->offset = cpu_to_le32(
713 (u32) le16_to_cpu(reg->offset));
714 reg_rw->value = cpu_to_le32((u32) reg->value);
715 break;
716 }
717
718 case HostCmd_CMD_RF_REG_ACCESS:
719 {
720 struct host_cmd_ds_rf_reg_access *reg;
721 reg = (struct host_cmd_ds_rf_reg_access *)
722 &resp->params.rf_reg;
723 reg_rw->offset = cpu_to_le32(
724 (u32) le16_to_cpu(reg->offset));
725 reg_rw->value = cpu_to_le32((u32) reg->value);
726 break;
727 }
728 case HostCmd_CMD_PMIC_REG_ACCESS:
729 {
730 struct host_cmd_ds_pmic_reg_access *reg;
731 reg = (struct host_cmd_ds_pmic_reg_access *)
732 &resp->params.pmic_reg;
733 reg_rw->offset = cpu_to_le32(
734 (u32) le16_to_cpu(reg->offset));
735 reg_rw->value = cpu_to_le32((u32) reg->value);
736 break;
737 }
738 case HostCmd_CMD_CAU_REG_ACCESS:
739 {
740 struct host_cmd_ds_rf_reg_access *reg;
741 reg = (struct host_cmd_ds_rf_reg_access *)
742 &resp->params.rf_reg;
743 reg_rw->offset = cpu_to_le32(
744 (u32) le16_to_cpu(reg->offset));
745 reg_rw->value = cpu_to_le32((u32) reg->value);
746 break;
747 }
748 case HostCmd_CMD_802_11_EEPROM_ACCESS:
749 {
750 struct host_cmd_ds_802_11_eeprom_access
751 *cmd_eeprom =
752 (struct host_cmd_ds_802_11_eeprom_access
753 *) &resp->params.eeprom;
754 pr_debug("info: EEPROM read len=%x\n",
755 cmd_eeprom->byte_count);
756 if (le16_to_cpu(eeprom->byte_count) <
757 le16_to_cpu(
758 cmd_eeprom->byte_count)) {
759 eeprom->byte_count = cpu_to_le16(0);
760 pr_debug("info: EEPROM read "
761 "length is too big\n");
762 return -1;
763 }
764 eeprom->offset = cmd_eeprom->offset;
765 eeprom->byte_count = cmd_eeprom->byte_count;
766 if (le16_to_cpu(eeprom->byte_count) > 0)
767 memcpy(&eeprom->value,
768 &cmd_eeprom->value,
769 le16_to_cpu(eeprom->byte_count));
770
771 break;
772 }
773 default:
774 return -1;
775 }
776 }
777 return 0;
778}
779
780/*
781 * This function handles the command response of get IBSS coalescing status.
782 *
783 * If the received BSSID is different than the current one, the current BSSID,
784 * beacon interval, ATIM window and ERP information are updated, along with
785 * changing the ad-hoc state accordingly.
786 */
787static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
788 struct host_cmd_ds_command *resp)
789{
790 struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp =
791 &(resp->params.ibss_coalescing);
792 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
793
794 if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET)
795 return 0;
796
797 dev_dbg(priv->adapter->dev,
798 "info: new BSSID %pM\n", ibss_coal_resp->bssid);
799
800 /* If rsp has NULL BSSID, Just return..... No Action */
801 if (!memcmp(ibss_coal_resp->bssid, zero_mac, ETH_ALEN)) {
802 dev_warn(priv->adapter->dev, "new BSSID is NULL\n");
803 return 0;
804 }
805
806 /* If BSSID is diff, modify current BSS parameters */
807 if (memcmp(priv->curr_bss_params.bss_descriptor.mac_address,
808 ibss_coal_resp->bssid, ETH_ALEN)) {
809 /* BSSID */
810 memcpy(priv->curr_bss_params.bss_descriptor.mac_address,
811 ibss_coal_resp->bssid, ETH_ALEN);
812
813 /* Beacon Interval */
814 priv->curr_bss_params.bss_descriptor.beacon_period
815 = le16_to_cpu(ibss_coal_resp->beacon_interval);
816
817 /* ERP Information */
818 priv->curr_bss_params.bss_descriptor.erp_flags =
819 (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect);
820
821 priv->adhoc_state = ADHOC_COALESCED;
822 }
823
824 return 0;
825}
826
827/*
828 * This function handles the command responses.
829 *
830 * This is a generic function, which calls command specific
831 * response handlers based on the command ID.
832 */
833int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv,
600f5d90 834 u16 cmdresp_no, void *cmd_buf)
5e6e3a92
BZ
835{
836 int ret = 0;
837 struct mwifiex_adapter *adapter = priv->adapter;
838 struct host_cmd_ds_command *resp =
839 (struct host_cmd_ds_command *) cmd_buf;
5e6e3a92
BZ
840 void *data_buf = adapter->curr_cmd->data_buf;
841
842 /* If the command is not successful, cleanup and return failure */
843 if (resp->result != HostCmd_RESULT_OK) {
600f5d90 844 mwifiex_process_cmdresp_error(priv, resp);
5e6e3a92
BZ
845 return -1;
846 }
847 /* Command successful, handle response */
848 switch (cmdresp_no) {
849 case HostCmd_CMD_GET_HW_SPEC:
850 ret = mwifiex_ret_get_hw_spec(priv, resp);
851 break;
852 case HostCmd_CMD_MAC_CONTROL:
853 break;
854 case HostCmd_CMD_802_11_MAC_ADDRESS:
855 ret = mwifiex_ret_802_11_mac_address(priv, resp);
856 break;
857 case HostCmd_CMD_MAC_MULTICAST_ADR:
858 ret = mwifiex_ret_mac_multicast_adr(priv, resp);
859 break;
860 case HostCmd_CMD_TX_RATE_CFG:
861 ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf);
862 break;
863 case HostCmd_CMD_802_11_SCAN:
600f5d90
AK
864 ret = mwifiex_ret_802_11_scan(priv, resp);
865 adapter->curr_cmd->wait_q_enabled = false;
5e6e3a92
BZ
866 break;
867 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
600f5d90 868 ret = mwifiex_ret_802_11_scan(priv, resp);
5e6e3a92
BZ
869 dev_dbg(adapter->dev,
870 "info: CMD_RESP: BG_SCAN result is ready!\n");
871 break;
872 case HostCmd_CMD_TXPWR_CFG:
873 ret = mwifiex_ret_tx_power_cfg(priv, resp, data_buf);
874 break;
875 case HostCmd_CMD_802_11_PS_MODE_ENH:
876 ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf);
877 break;
878 case HostCmd_CMD_802_11_HS_CFG_ENH:
879 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
880 break;
881 case HostCmd_CMD_802_11_ASSOCIATE:
600f5d90 882 ret = mwifiex_ret_802_11_associate(priv, resp);
5e6e3a92
BZ
883 break;
884 case HostCmd_CMD_802_11_DEAUTHENTICATE:
885 ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
886 break;
887 case HostCmd_CMD_802_11_AD_HOC_START:
888 case HostCmd_CMD_802_11_AD_HOC_JOIN:
600f5d90 889 ret = mwifiex_ret_802_11_ad_hoc(priv, resp);
5e6e3a92
BZ
890 break;
891 case HostCmd_CMD_802_11_AD_HOC_STOP:
892 ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
893 break;
894 case HostCmd_CMD_802_11_GET_LOG:
895 ret = mwifiex_ret_get_log(priv, resp, data_buf);
896 break;
897 case HostCmd_CMD_RSSI_INFO:
898 ret = mwifiex_ret_802_11_rssi_info(priv, resp, data_buf);
899 break;
900 case HostCmd_CMD_802_11_SNMP_MIB:
901 ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf);
902 break;
903 case HostCmd_CMD_802_11_TX_RATE_QUERY:
904 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
905 break;
906 case HostCmd_CMD_802_11_RF_CHANNEL:
907 ret = mwifiex_ret_802_11_rf_channel(priv, resp, data_buf);
908 break;
909 case HostCmd_CMD_VERSION_EXT:
910 ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
911 break;
912 case HostCmd_CMD_FUNC_INIT:
913 case HostCmd_CMD_FUNC_SHUTDOWN:
914 break;
915 case HostCmd_CMD_802_11_KEY_MATERIAL:
916 ret = mwifiex_ret_802_11_key_material(priv, resp);
917 break;
918 case HostCmd_CMD_802_11D_DOMAIN_INFO:
919 ret = mwifiex_ret_802_11d_domain_info(priv, resp);
920 break;
921 case HostCmd_CMD_11N_ADDBA_REQ:
922 ret = mwifiex_ret_11n_addba_req(priv, resp);
923 break;
924 case HostCmd_CMD_11N_DELBA:
925 ret = mwifiex_ret_11n_delba(priv, resp);
926 break;
927 case HostCmd_CMD_11N_ADDBA_RSP:
928 ret = mwifiex_ret_11n_addba_resp(priv, resp);
929 break;
930 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
931 adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
932 tx_buf.buff_size);
933 adapter->tx_buf_size = (adapter->tx_buf_size /
934 MWIFIEX_SDIO_BLOCK_SIZE) *
935 MWIFIEX_SDIO_BLOCK_SIZE;
936 adapter->curr_tx_buf_size = adapter->tx_buf_size;
937 dev_dbg(adapter->dev,
938 "cmd: max_tx_buf_size=%d, tx_buf_size=%d\n",
939 adapter->max_tx_buf_size, adapter->tx_buf_size);
940
941 if (adapter->if_ops.update_mp_end_port)
942 adapter->if_ops.update_mp_end_port(adapter,
943 le16_to_cpu(resp->
944 params.
945 tx_buf.
946 mp_end_port));
947 break;
948 case HostCmd_CMD_AMSDU_AGGR_CTRL:
949 ret = mwifiex_ret_amsdu_aggr_ctrl(priv, resp, data_buf);
950 break;
951 case HostCmd_CMD_WMM_GET_STATUS:
952 ret = mwifiex_ret_wmm_get_status(priv, resp);
953 break;
954 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
955 ret = mwifiex_ret_ibss_coalescing_status(priv, resp);
956 break;
957 case HostCmd_CMD_MAC_REG_ACCESS:
958 case HostCmd_CMD_BBP_REG_ACCESS:
959 case HostCmd_CMD_RF_REG_ACCESS:
960 case HostCmd_CMD_PMIC_REG_ACCESS:
961 case HostCmd_CMD_CAU_REG_ACCESS:
962 case HostCmd_CMD_802_11_EEPROM_ACCESS:
963 ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf);
964 break;
965 case HostCmd_CMD_SET_BSS_MODE:
966 break;
967 case HostCmd_CMD_11N_CFG:
968 ret = mwifiex_ret_11n_cfg(priv, resp, data_buf);
969 break;
970 default:
971 dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n",
972 resp->command);
973 break;
974 }
975
976 return ret;
977}
This page took 0.081847 seconds and 5 git commands to generate.