2 * Marvell Wireless LAN device driver: station command response handling
4 * Copyright (C) 2011, Marvell International Ltd.
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.
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.
30 * This function handles the command response error case.
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.
36 * For Power Save command failure, we do not retry enter PS
37 * command in case of Ad-hoc mode.
39 * For all other response errors, the current command buffer is freed
40 * and returned to the free command queue.
43 mwifiex_process_cmdresp_error(struct mwifiex_private
*priv
,
44 struct host_cmd_ds_command
*resp
)
46 struct cmd_ctrl_node
*cmd_node
= NULL
, *tmp_node
;
47 struct mwifiex_adapter
*adapter
= priv
->adapter
;
48 struct host_cmd_ds_802_11_ps_mode_enh
*pm
;
51 dev_err(adapter
->dev
, "CMD_RESP: cmd %#x error, result=%#x\n",
52 resp
->command
, resp
->result
);
54 if (adapter
->curr_cmd
->wait_q_enabled
)
55 adapter
->cmd_wait_q
.status
= -1;
57 switch (le16_to_cpu(resp
->command
)) {
58 case HostCmd_CMD_802_11_PS_MODE_ENH
:
59 pm
= &resp
->params
.psmode_enh
;
60 dev_err(adapter
->dev
, "PS_MODE_ENH cmd failed: "
61 "result=0x%x action=0x%X\n",
62 resp
->result
, le16_to_cpu(pm
->action
));
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
;
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
,
78 mwifiex_insert_cmd_to_free_q(adapter
, cmd_node
);
79 spin_lock_irqsave(&adapter
->scan_pending_q_lock
, flags
);
81 spin_unlock_irqrestore(&adapter
->scan_pending_q_lock
, flags
);
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;
94 case HostCmd_CMD_MAC_CONTROL
:
100 /* Handling errors here */
101 mwifiex_insert_cmd_to_free_q(adapter
, adapter
->curr_cmd
);
103 spin_lock_irqsave(&adapter
->mwifiex_cmd_lock
, flags
);
104 adapter
->curr_cmd
= NULL
;
105 spin_unlock_irqrestore(&adapter
->mwifiex_cmd_lock
, flags
);
109 * This function handles the command response of get RSSI info.
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
118 * The parameters are send to the application as well, along with
119 * calculated SNR values.
121 static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private
*priv
,
122 struct host_cmd_ds_command
*resp
,
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
;
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
);
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
);
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
);
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
);
141 /* Need to indicate IOCTL complete */
143 signal
= (struct mwifiex_ds_get_signal
*) data_buf
;
144 memset(signal
, 0, sizeof(struct mwifiex_ds_get_signal
));
146 signal
->selector
= ALL_RSSI_INFO_MASK
;
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
;
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
);
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
;
175 * This function handles the command response of set/get SNMP
178 * Handling includes changing the header fields into CPU format
179 * and saving the parameter in driver.
181 * The following parameters are supported -
182 * - Fragmentation threshold
184 * - Short retry limit
186 static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private
*priv
,
187 struct host_cmd_ds_command
*resp
,
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
);
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
)));
201 *(u32
*)data_buf
= ul_temp
;
204 dev_dbg(priv
->adapter
->dev
,
205 "info: SNMP_RESP: FragThsd =%u\n", ul_temp
);
208 dev_dbg(priv
->adapter
->dev
,
209 "info: SNMP_RESP: RTSThsd =%u\n", ul_temp
);
211 case SHORT_RETRY_LIM_I
:
212 dev_dbg(priv
->adapter
->dev
,
213 "info: SNMP_RESP: TxRetryCount=%u\n", ul_temp
);
224 * This function handles the command response of get log request
226 * Handling includes changing the header fields into CPU format
227 * and sending the received parameters to application.
229 static int mwifiex_ret_get_log(struct mwifiex_private
*priv
,
230 struct host_cmd_ds_command
*resp
,
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
;
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]);
265 * This function handles the command response of set/get Tx rate
268 * Handling includes changing the header fields into CPU format
269 * and saving the following parameters in driver -
272 * - HT MCS rate bitmaps
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
279 static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private
*priv
,
280 struct host_cmd_ds_command
*resp
,
283 struct mwifiex_rate_cfg
*ds_rate
;
284 struct host_cmd_ds_tx_rate_cfg
*rate_cfg
= &resp
->params
.tx_rate_cfg
;
285 struct mwifiex_rate_scope
*rate_scope
;
286 struct mwifiex_ie_types_header
*head
;
287 u16 tlv
, tlv_buf_len
;
292 tlv_buf
= (u8
*) ((u8
*) rate_cfg
) +
293 sizeof(struct host_cmd_ds_tx_rate_cfg
);
294 tlv_buf_len
= *(u16
*) (tlv_buf
+ sizeof(u16
));
296 while (tlv_buf
&& tlv_buf_len
> 0) {
298 tlv
= tlv
| (*(tlv_buf
+ 1) << 8);
301 case TLV_TYPE_RATE_SCOPE
:
302 rate_scope
= (struct mwifiex_rate_scope
*) tlv_buf
;
303 priv
->bitmap_rates
[0] =
304 le16_to_cpu(rate_scope
->hr_dsss_rate_bitmap
);
305 priv
->bitmap_rates
[1] =
306 le16_to_cpu(rate_scope
->ofdm_rate_bitmap
);
309 sizeof(rate_scope
->ht_mcs_rate_bitmap
) /
311 priv
->bitmap_rates
[2 + i
] =
312 le16_to_cpu(rate_scope
->
313 ht_mcs_rate_bitmap
[i
]);
315 /* Add RATE_DROP tlv here */
318 head
= (struct mwifiex_ie_types_header
*) tlv_buf
;
319 tlv_buf
+= le16_to_cpu(head
->len
) + sizeof(*head
);
320 tlv_buf_len
-= le16_to_cpu(head
->len
);
323 priv
->is_data_rate_auto
= mwifiex_is_rate_auto(priv
);
325 if (priv
->is_data_rate_auto
)
328 ret
= mwifiex_send_cmd_async(priv
,
329 HostCmd_CMD_802_11_TX_RATE_QUERY
,
330 HostCmd_ACT_GEN_GET
, 0, NULL
);
333 ds_rate
= (struct mwifiex_rate_cfg
*) data_buf
;
334 if (le16_to_cpu(rate_cfg
->action
) == HostCmd_ACT_GEN_GET
) {
335 if (priv
->is_data_rate_auto
) {
336 ds_rate
->is_rate_auto
= 1;
338 ds_rate
->rate
= mwifiex_get_rate_index(priv
->
343 MWIFIEX_RATE_BITMAP_OFDM0
345 MWIFIEX_RATE_BITMAP_OFDM7
)
347 (MWIFIEX_RATE_BITMAP_OFDM0
-
348 MWIFIEX_RATE_INDEX_OFDM0
);
350 MWIFIEX_RATE_BITMAP_MCS0
352 MWIFIEX_RATE_BITMAP_MCS127
)
354 (MWIFIEX_RATE_BITMAP_MCS0
-
355 MWIFIEX_RATE_INDEX_MCS0
);
364 * This function handles the command response of get Tx power level.
366 * Handling includes saving the maximum and minimum Tx power levels
367 * in driver, as well as sending the values to user.
369 static int mwifiex_get_power_level(struct mwifiex_private
*priv
, void *data_buf
)
371 int length
, max_power
= -1, min_power
= -1;
372 struct mwifiex_types_power_group
*pg_tlv_hdr
;
373 struct mwifiex_power_group
*pg
;
377 (struct mwifiex_types_power_group
*) ((u8
*) data_buf
378 + sizeof(struct host_cmd_ds_txpwr_cfg
));
379 pg
= (struct mwifiex_power_group
*) ((u8
*) pg_tlv_hdr
+
380 sizeof(struct mwifiex_types_power_group
));
381 length
= pg_tlv_hdr
->length
;
383 max_power
= pg
->power_max
;
384 min_power
= pg
->power_min
;
385 length
-= sizeof(struct mwifiex_power_group
);
389 if (max_power
< pg
->power_max
)
390 max_power
= pg
->power_max
;
392 if (min_power
> pg
->power_min
)
393 min_power
= pg
->power_min
;
395 length
-= sizeof(struct mwifiex_power_group
);
397 if (pg_tlv_hdr
->length
> 0) {
398 priv
->min_tx_power_level
= (u8
) min_power
;
399 priv
->max_tx_power_level
= (u8
) max_power
;
409 * This function handles the command response of set/get Tx power
412 * Handling includes changing the header fields into CPU format
413 * and saving the current Tx power level in driver.
415 static int mwifiex_ret_tx_power_cfg(struct mwifiex_private
*priv
,
416 struct host_cmd_ds_command
*resp
,
419 struct mwifiex_adapter
*adapter
= priv
->adapter
;
420 struct host_cmd_ds_txpwr_cfg
*txp_cfg
= &resp
->params
.txp_cfg
;
421 struct mwifiex_types_power_group
*pg_tlv_hdr
;
422 struct mwifiex_power_group
*pg
;
423 u16 action
= le16_to_cpu(txp_cfg
->action
);
426 case HostCmd_ACT_GEN_GET
:
429 (struct mwifiex_types_power_group
*) ((u8
*)
433 host_cmd_ds_txpwr_cfg
));
434 pg
= (struct mwifiex_power_group
*) ((u8
*)
437 mwifiex_types_power_group
));
438 if (adapter
->hw_status
==
439 MWIFIEX_HW_STATUS_INITIALIZING
)
440 mwifiex_get_power_level(priv
, txp_cfg
);
441 priv
->tx_power_level
= (u16
) pg
->power_min
;
444 case HostCmd_ACT_GEN_SET
:
445 if (le32_to_cpu(txp_cfg
->mode
)) {
447 (struct mwifiex_types_power_group
*) ((u8
*)
451 host_cmd_ds_txpwr_cfg
));
452 pg
= (struct mwifiex_power_group
*) ((u8
*) pg_tlv_hdr
455 mwifiex_types_power_group
));
456 if (pg
->power_max
== pg
->power_min
)
457 priv
->tx_power_level
= (u16
) pg
->power_min
;
461 dev_err(adapter
->dev
, "CMD_RESP: unknown cmd action %d\n",
465 dev_dbg(adapter
->dev
,
466 "info: 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
);
474 * This function handles the command response of set/get MAC address.
476 * Handling includes saving the MAC address in driver.
478 static int mwifiex_ret_802_11_mac_address(struct mwifiex_private
*priv
,
479 struct host_cmd_ds_command
*resp
)
481 struct host_cmd_ds_802_11_mac_address
*cmd_mac_addr
=
482 &resp
->params
.mac_addr
;
484 memcpy(priv
->curr_addr
, cmd_mac_addr
->mac_addr
, ETH_ALEN
);
486 dev_dbg(priv
->adapter
->dev
,
487 "info: set mac address: %pM\n", priv
->curr_addr
);
493 * This function handles the command response of set/get MAC multicast
496 static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private
*priv
,
497 struct host_cmd_ds_command
*resp
)
503 * This function handles the command response of get Tx rate query.
505 * Handling includes changing the header fields into CPU format
506 * and saving the Tx rate and HT information parameters in driver.
508 * Both rate configuration and current data rate can be retrieved
511 static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private
*priv
,
512 struct host_cmd_ds_command
*resp
)
514 priv
->tx_rate
= resp
->params
.tx_rate
.tx_rate
;
515 priv
->tx_htinfo
= resp
->params
.tx_rate
.ht_info
;
516 if (!priv
->is_data_rate_auto
)
518 mwifiex_index_to_data_rate(priv
->tx_rate
,
525 * This function handles the command response of a deauthenticate
528 * If the deauthenticated MAC matches the current BSS MAC, the connection
531 static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private
*priv
,
532 struct host_cmd_ds_command
*resp
)
534 struct mwifiex_adapter
*adapter
= priv
->adapter
;
536 adapter
->dbg
.num_cmd_deauth
++;
537 if (!memcmp(resp
->params
.deauth
.mac_addr
,
538 &priv
->curr_bss_params
.bss_descriptor
.mac_address
,
539 sizeof(resp
->params
.deauth
.mac_addr
)))
540 mwifiex_reset_connect_state(priv
);
546 * This function handles the command response of ad-hoc stop.
548 * The function resets the connection state in driver.
550 static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private
*priv
,
551 struct host_cmd_ds_command
*resp
)
553 mwifiex_reset_connect_state(priv
);
558 * This function handles the command response of set/get key material.
560 * Handling includes updating the driver parameters to reflect the
563 static int mwifiex_ret_802_11_key_material(struct mwifiex_private
*priv
,
564 struct host_cmd_ds_command
*resp
)
566 struct host_cmd_ds_802_11_key_material
*key
=
567 &resp
->params
.key_material
;
569 if (le16_to_cpu(key
->action
) == HostCmd_ACT_GEN_SET
) {
570 if ((le16_to_cpu(key
->key_param_set
.key_info
) & KEY_MCAST
)) {
571 dev_dbg(priv
->adapter
->dev
, "info: key: GTK is set\n");
572 priv
->wpa_is_gtk_set
= true;
573 priv
->scan_block
= false;
577 memset(priv
->aes_key
.key_param_set
.key
, 0,
578 sizeof(key
->key_param_set
.key
));
579 priv
->aes_key
.key_param_set
.key_len
= key
->key_param_set
.key_len
;
580 memcpy(priv
->aes_key
.key_param_set
.key
, key
->key_param_set
.key
,
581 le16_to_cpu(priv
->aes_key
.key_param_set
.key_len
));
587 * This function handles the command response of get 11d domain information.
589 static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private
*priv
,
590 struct host_cmd_ds_command
*resp
)
592 struct host_cmd_ds_802_11d_domain_info_rsp
*domain_info
=
593 &resp
->params
.domain_info_resp
;
594 struct mwifiex_ietypes_domain_param_set
*domain
= &domain_info
->domain
;
595 u16 action
= le16_to_cpu(domain_info
->action
);
598 no_of_triplet
= (u8
) ((le16_to_cpu(domain
->header
.len
) -
599 IEEE80211_COUNTRY_STRING_LEN
) /
600 sizeof(struct ieee80211_country_ie_triplet
));
602 dev_dbg(priv
->adapter
->dev
, "info: 11D Domain Info Resp:"
603 " no_of_triplet=%d\n", no_of_triplet
);
605 if (no_of_triplet
> MWIFIEX_MAX_TRIPLET_802_11D
) {
606 dev_warn(priv
->adapter
->dev
,
607 "11D: invalid number of triplets %d "
608 "returned!!\n", no_of_triplet
);
613 case HostCmd_ACT_GEN_SET
: /* Proc Set Action */
615 case HostCmd_ACT_GEN_GET
:
618 dev_err(priv
->adapter
->dev
,
619 "11D: invalid action:%d\n", domain_info
->action
);
627 * This function handles the command response of get RF channel.
629 * Handling includes changing the header fields into CPU format
630 * and saving the new channel in driver.
632 static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private
*priv
,
633 struct host_cmd_ds_command
*resp
,
636 struct host_cmd_ds_802_11_rf_channel
*rf_channel
=
637 &resp
->params
.rf_channel
;
638 u16 new_channel
= le16_to_cpu(rf_channel
->current_channel
);
640 if (priv
->curr_bss_params
.bss_descriptor
.channel
!= new_channel
) {
641 dev_dbg(priv
->adapter
->dev
, "cmd: Channel Switch: %d to %d\n",
642 priv
->curr_bss_params
.bss_descriptor
.channel
,
644 /* Update the channel again */
645 priv
->curr_bss_params
.bss_descriptor
.channel
= new_channel
;
648 *((u16
*)data_buf
) = new_channel
;
654 * This function handles the command response of get extended version.
656 * Handling includes forming the extended version string and sending it
659 static int mwifiex_ret_ver_ext(struct mwifiex_private
*priv
,
660 struct host_cmd_ds_command
*resp
,
663 struct host_cmd_ds_version_ext
*ver_ext
= &resp
->params
.verext
;
664 struct host_cmd_ds_version_ext
*version_ext
;
667 version_ext
= (struct host_cmd_ds_version_ext
*)data_buf
;
668 version_ext
->version_str_sel
= ver_ext
->version_str_sel
;
669 memcpy(version_ext
->version_str
, ver_ext
->version_str
,
671 memcpy(priv
->version_str
, ver_ext
->version_str
, 128);
677 * This function handles the command response of register access.
679 * The register value and offset are returned to the user. For EEPROM
680 * access, the byte count is also returned.
682 static int mwifiex_ret_reg_access(u16 type
, struct host_cmd_ds_command
*resp
,
685 struct mwifiex_ds_reg_rw
*reg_rw
;
686 struct mwifiex_ds_read_eeprom
*eeprom
;
689 reg_rw
= (struct mwifiex_ds_reg_rw
*) data_buf
;
690 eeprom
= (struct mwifiex_ds_read_eeprom
*) data_buf
;
692 case HostCmd_CMD_MAC_REG_ACCESS
:
694 struct host_cmd_ds_mac_reg_access
*reg
;
695 reg
= (struct host_cmd_ds_mac_reg_access
*)
696 &resp
->params
.mac_reg
;
697 reg_rw
->offset
= cpu_to_le32(
698 (u32
) le16_to_cpu(reg
->offset
));
699 reg_rw
->value
= reg
->value
;
702 case HostCmd_CMD_BBP_REG_ACCESS
:
704 struct host_cmd_ds_bbp_reg_access
*reg
;
705 reg
= (struct host_cmd_ds_bbp_reg_access
*)
706 &resp
->params
.bbp_reg
;
707 reg_rw
->offset
= cpu_to_le32(
708 (u32
) le16_to_cpu(reg
->offset
));
709 reg_rw
->value
= cpu_to_le32((u32
) reg
->value
);
713 case HostCmd_CMD_RF_REG_ACCESS
:
715 struct host_cmd_ds_rf_reg_access
*reg
;
716 reg
= (struct host_cmd_ds_rf_reg_access
*)
717 &resp
->params
.rf_reg
;
718 reg_rw
->offset
= cpu_to_le32(
719 (u32
) le16_to_cpu(reg
->offset
));
720 reg_rw
->value
= cpu_to_le32((u32
) reg
->value
);
723 case HostCmd_CMD_PMIC_REG_ACCESS
:
725 struct host_cmd_ds_pmic_reg_access
*reg
;
726 reg
= (struct host_cmd_ds_pmic_reg_access
*)
727 &resp
->params
.pmic_reg
;
728 reg_rw
->offset
= cpu_to_le32(
729 (u32
) le16_to_cpu(reg
->offset
));
730 reg_rw
->value
= cpu_to_le32((u32
) reg
->value
);
733 case HostCmd_CMD_CAU_REG_ACCESS
:
735 struct host_cmd_ds_rf_reg_access
*reg
;
736 reg
= (struct host_cmd_ds_rf_reg_access
*)
737 &resp
->params
.rf_reg
;
738 reg_rw
->offset
= cpu_to_le32(
739 (u32
) le16_to_cpu(reg
->offset
));
740 reg_rw
->value
= cpu_to_le32((u32
) reg
->value
);
743 case HostCmd_CMD_802_11_EEPROM_ACCESS
:
745 struct host_cmd_ds_802_11_eeprom_access
747 (struct host_cmd_ds_802_11_eeprom_access
748 *) &resp
->params
.eeprom
;
749 pr_debug("info: EEPROM read len=%x\n",
750 cmd_eeprom
->byte_count
);
751 if (le16_to_cpu(eeprom
->byte_count
) <
753 cmd_eeprom
->byte_count
)) {
754 eeprom
->byte_count
= cpu_to_le16(0);
755 pr_debug("info: EEPROM read "
756 "length is too big\n");
759 eeprom
->offset
= cmd_eeprom
->offset
;
760 eeprom
->byte_count
= cmd_eeprom
->byte_count
;
761 if (le16_to_cpu(eeprom
->byte_count
) > 0)
762 memcpy(&eeprom
->value
,
764 le16_to_cpu(eeprom
->byte_count
));
776 * This function handles the command response of get IBSS coalescing status.
778 * If the received BSSID is different than the current one, the current BSSID,
779 * beacon interval, ATIM window and ERP information are updated, along with
780 * changing the ad-hoc state accordingly.
782 static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private
*priv
,
783 struct host_cmd_ds_command
*resp
)
785 struct host_cmd_ds_802_11_ibss_status
*ibss_coal_resp
=
786 &(resp
->params
.ibss_coalescing
);
787 u8 zero_mac
[ETH_ALEN
] = { 0, 0, 0, 0, 0, 0 };
789 if (le16_to_cpu(ibss_coal_resp
->action
) == HostCmd_ACT_GEN_SET
)
792 dev_dbg(priv
->adapter
->dev
,
793 "info: new BSSID %pM\n", ibss_coal_resp
->bssid
);
795 /* If rsp has NULL BSSID, Just return..... No Action */
796 if (!memcmp(ibss_coal_resp
->bssid
, zero_mac
, ETH_ALEN
)) {
797 dev_warn(priv
->adapter
->dev
, "new BSSID is NULL\n");
801 /* If BSSID is diff, modify current BSS parameters */
802 if (memcmp(priv
->curr_bss_params
.bss_descriptor
.mac_address
,
803 ibss_coal_resp
->bssid
, ETH_ALEN
)) {
805 memcpy(priv
->curr_bss_params
.bss_descriptor
.mac_address
,
806 ibss_coal_resp
->bssid
, ETH_ALEN
);
808 /* Beacon Interval */
809 priv
->curr_bss_params
.bss_descriptor
.beacon_period
810 = le16_to_cpu(ibss_coal_resp
->beacon_interval
);
812 /* ERP Information */
813 priv
->curr_bss_params
.bss_descriptor
.erp_flags
=
814 (u8
) le16_to_cpu(ibss_coal_resp
->use_g_rate_protect
);
816 priv
->adhoc_state
= ADHOC_COALESCED
;
823 * This function handles the command responses.
825 * This is a generic function, which calls command specific
826 * response handlers based on the command ID.
828 int mwifiex_process_sta_cmdresp(struct mwifiex_private
*priv
,
829 u16 cmdresp_no
, void *cmd_buf
)
832 struct mwifiex_adapter
*adapter
= priv
->adapter
;
833 struct host_cmd_ds_command
*resp
=
834 (struct host_cmd_ds_command
*) cmd_buf
;
835 void *data_buf
= adapter
->curr_cmd
->data_buf
;
837 /* If the command is not successful, cleanup and return failure */
838 if (resp
->result
!= HostCmd_RESULT_OK
) {
839 mwifiex_process_cmdresp_error(priv
, resp
);
842 /* Command successful, handle response */
843 switch (cmdresp_no
) {
844 case HostCmd_CMD_GET_HW_SPEC
:
845 ret
= mwifiex_ret_get_hw_spec(priv
, resp
);
847 case HostCmd_CMD_MAC_CONTROL
:
849 case HostCmd_CMD_802_11_MAC_ADDRESS
:
850 ret
= mwifiex_ret_802_11_mac_address(priv
, resp
);
852 case HostCmd_CMD_MAC_MULTICAST_ADR
:
853 ret
= mwifiex_ret_mac_multicast_adr(priv
, resp
);
855 case HostCmd_CMD_TX_RATE_CFG
:
856 ret
= mwifiex_ret_tx_rate_cfg(priv
, resp
, data_buf
);
858 case HostCmd_CMD_802_11_SCAN
:
859 ret
= mwifiex_ret_802_11_scan(priv
, resp
);
860 adapter
->curr_cmd
->wait_q_enabled
= false;
862 case HostCmd_CMD_802_11_BG_SCAN_QUERY
:
863 ret
= mwifiex_ret_802_11_scan(priv
, resp
);
864 dev_dbg(adapter
->dev
,
865 "info: CMD_RESP: BG_SCAN result is ready!\n");
867 case HostCmd_CMD_TXPWR_CFG
:
868 ret
= mwifiex_ret_tx_power_cfg(priv
, resp
, data_buf
);
870 case HostCmd_CMD_802_11_PS_MODE_ENH
:
871 ret
= mwifiex_ret_enh_power_mode(priv
, resp
, data_buf
);
873 case HostCmd_CMD_802_11_HS_CFG_ENH
:
874 ret
= mwifiex_ret_802_11_hs_cfg(priv
, resp
);
876 case HostCmd_CMD_802_11_ASSOCIATE
:
877 ret
= mwifiex_ret_802_11_associate(priv
, resp
);
879 case HostCmd_CMD_802_11_DEAUTHENTICATE
:
880 ret
= mwifiex_ret_802_11_deauthenticate(priv
, resp
);
882 case HostCmd_CMD_802_11_AD_HOC_START
:
883 case HostCmd_CMD_802_11_AD_HOC_JOIN
:
884 ret
= mwifiex_ret_802_11_ad_hoc(priv
, resp
);
886 case HostCmd_CMD_802_11_AD_HOC_STOP
:
887 ret
= mwifiex_ret_802_11_ad_hoc_stop(priv
, resp
);
889 case HostCmd_CMD_802_11_GET_LOG
:
890 ret
= mwifiex_ret_get_log(priv
, resp
, data_buf
);
892 case HostCmd_CMD_RSSI_INFO
:
893 ret
= mwifiex_ret_802_11_rssi_info(priv
, resp
, data_buf
);
895 case HostCmd_CMD_802_11_SNMP_MIB
:
896 ret
= mwifiex_ret_802_11_snmp_mib(priv
, resp
, data_buf
);
898 case HostCmd_CMD_802_11_TX_RATE_QUERY
:
899 ret
= mwifiex_ret_802_11_tx_rate_query(priv
, resp
);
901 case HostCmd_CMD_802_11_RF_CHANNEL
:
902 ret
= mwifiex_ret_802_11_rf_channel(priv
, resp
, data_buf
);
904 case HostCmd_CMD_VERSION_EXT
:
905 ret
= mwifiex_ret_ver_ext(priv
, resp
, data_buf
);
907 case HostCmd_CMD_FUNC_INIT
:
908 case HostCmd_CMD_FUNC_SHUTDOWN
:
910 case HostCmd_CMD_802_11_KEY_MATERIAL
:
911 ret
= mwifiex_ret_802_11_key_material(priv
, resp
);
913 case HostCmd_CMD_802_11D_DOMAIN_INFO
:
914 ret
= mwifiex_ret_802_11d_domain_info(priv
, resp
);
916 case HostCmd_CMD_11N_ADDBA_REQ
:
917 ret
= mwifiex_ret_11n_addba_req(priv
, resp
);
919 case HostCmd_CMD_11N_DELBA
:
920 ret
= mwifiex_ret_11n_delba(priv
, resp
);
922 case HostCmd_CMD_11N_ADDBA_RSP
:
923 ret
= mwifiex_ret_11n_addba_resp(priv
, resp
);
925 case HostCmd_CMD_RECONFIGURE_TX_BUFF
:
926 adapter
->tx_buf_size
= (u16
) le16_to_cpu(resp
->params
.
928 adapter
->tx_buf_size
= (adapter
->tx_buf_size
/
929 MWIFIEX_SDIO_BLOCK_SIZE
) *
930 MWIFIEX_SDIO_BLOCK_SIZE
;
931 adapter
->curr_tx_buf_size
= adapter
->tx_buf_size
;
932 dev_dbg(adapter
->dev
,
933 "cmd: max_tx_buf_size=%d, tx_buf_size=%d\n",
934 adapter
->max_tx_buf_size
, adapter
->tx_buf_size
);
936 if (adapter
->if_ops
.update_mp_end_port
)
937 adapter
->if_ops
.update_mp_end_port(adapter
,
943 case HostCmd_CMD_AMSDU_AGGR_CTRL
:
944 ret
= mwifiex_ret_amsdu_aggr_ctrl(resp
, data_buf
);
946 case HostCmd_CMD_WMM_GET_STATUS
:
947 ret
= mwifiex_ret_wmm_get_status(priv
, resp
);
949 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS
:
950 ret
= mwifiex_ret_ibss_coalescing_status(priv
, resp
);
952 case HostCmd_CMD_MAC_REG_ACCESS
:
953 case HostCmd_CMD_BBP_REG_ACCESS
:
954 case HostCmd_CMD_RF_REG_ACCESS
:
955 case HostCmd_CMD_PMIC_REG_ACCESS
:
956 case HostCmd_CMD_CAU_REG_ACCESS
:
957 case HostCmd_CMD_802_11_EEPROM_ACCESS
:
958 ret
= mwifiex_ret_reg_access(cmdresp_no
, resp
, data_buf
);
960 case HostCmd_CMD_SET_BSS_MODE
:
962 case HostCmd_CMD_11N_CFG
:
963 ret
= mwifiex_ret_11n_cfg(resp
, data_buf
);
966 dev_err(adapter
->dev
, "CMD_RESP: unknown cmd response %#x\n",