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,
45 struct mwifiex_wait_queue *wq_buf)
47 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
48 struct mwifiex_adapter *adapter = priv->adapter;
51 dev_err(adapter->dev, "CMD_RESP: cmd %#x error, result=%#x\n",
52 resp->command, resp->result);
54 wq_buf->status = MWIFIEX_ERROR_FW_CMDRESP;
56 switch (le16_to_cpu(resp->command)) {
57 case HostCmd_CMD_802_11_PS_MODE_ENH:
59 struct host_cmd_ds_802_11_ps_mode_enh *pm =
60 &resp->params.psmode_enh;
61 dev_err(adapter->dev, "PS_MODE_ENH cmd failed: "
62 "result=0x%x action=0x%X\n",
63 resp->result, le16_to_cpu(pm->action));
64 /* We do not re-try enter-ps command in ad-hoc mode. */
65 if (le16_to_cpu(pm->action) == EN_AUTO_PS &&
66 (le16_to_cpu(pm->params.auto_ps.ps_bitmap) &
68 && priv->bss_mode == MWIFIEX_BSS_MODE_IBSS)
70 MWIFIEX_802_11_POWER_MODE_CAM;
73 case HostCmd_CMD_802_11_SCAN:
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,
81 mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
82 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
84 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
86 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
87 adapter->scan_processing = false;
88 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
89 if (priv->report_scan_result)
90 priv->report_scan_result = false;
91 if (priv->scan_pending_on_block) {
92 priv->scan_pending_on_block = false;
97 case HostCmd_CMD_MAC_CONTROL:
103 /* Handling errors here */
104 mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
106 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
107 adapter->curr_cmd = NULL;
108 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
114 * This function handles the command response of get RSSI info.
116 * Handling includes changing the header fields into CPU format
117 * and saving the following parameters in driver -
118 * - Last data and beacon RSSI value
119 * - Average data and beacon RSSI value
120 * - Last data and beacon NF value
121 * - Average data and beacon NF value
123 * The parameters are send to the application as well, along with
124 * calculated SNR values.
126 static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv,
127 struct host_cmd_ds_command *resp,
130 struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp =
131 &resp->params.rssi_info_rsp;
132 struct mwifiex_ds_get_signal *signal = NULL;
134 priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last);
135 priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last);
137 priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg);
138 priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg);
140 priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last);
141 priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last);
143 priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg);
144 priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg);
146 /* Need to indicate IOCTL complete */
148 signal = (struct mwifiex_ds_get_signal *) data_buf;
149 memset(signal, 0, sizeof(struct mwifiex_ds_get_signal));
151 signal->selector = ALL_RSSI_INFO_MASK;
154 signal->bcn_rssi_last = priv->bcn_rssi_last;
155 signal->bcn_rssi_avg = priv->bcn_rssi_avg;
156 signal->data_rssi_last = priv->data_rssi_last;
157 signal->data_rssi_avg = priv->data_rssi_avg;
160 signal->bcn_snr_last =
161 CAL_SNR(priv->bcn_rssi_last, priv->bcn_nf_last);
162 signal->bcn_snr_avg =
163 CAL_SNR(priv->bcn_rssi_avg, priv->bcn_nf_avg);
164 signal->data_snr_last =
165 CAL_SNR(priv->data_rssi_last, priv->data_nf_last);
166 signal->data_snr_avg =
167 CAL_SNR(priv->data_rssi_avg, priv->data_nf_avg);
170 signal->bcn_nf_last = priv->bcn_nf_last;
171 signal->bcn_nf_avg = priv->bcn_nf_avg;
172 signal->data_nf_last = priv->data_nf_last;
173 signal->data_nf_avg = priv->data_nf_avg;
180 * This function handles the command response of set/get SNMP
183 * Handling includes changing the header fields into CPU format
184 * and saving the parameter in driver.
186 * The following parameters are supported -
187 * - Fragmentation threshold
189 * - Short retry limit
191 static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv,
192 struct host_cmd_ds_command *resp,
195 struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
196 u16 oid = le16_to_cpu(smib->oid);
197 u16 query_type = le16_to_cpu(smib->query_type);
200 dev_dbg(priv->adapter->dev, "info: SNMP_RESP: oid value = %#x,"
201 " query_type = %#x, buf size = %#x\n",
202 oid, query_type, le16_to_cpu(smib->buf_size));
203 if (query_type == HostCmd_ACT_GEN_GET) {
204 ul_temp = le16_to_cpu(*((__le16 *) (smib->value)));
206 *(u32 *)data_buf = ul_temp;
209 dev_dbg(priv->adapter->dev,
210 "info: SNMP_RESP: FragThsd =%u\n", ul_temp);
213 dev_dbg(priv->adapter->dev,
214 "info: SNMP_RESP: RTSThsd =%u\n", ul_temp);
216 case SHORT_RETRY_LIM_I:
217 dev_dbg(priv->adapter->dev,
218 "info: SNMP_RESP: TxRetryCount=%u\n", ul_temp);
229 * This function handles the command response of get log request
231 * Handling includes changing the header fields into CPU format
232 * and sending the received parameters to application.
234 static int mwifiex_ret_get_log(struct mwifiex_private *priv,
235 struct host_cmd_ds_command *resp,
238 struct host_cmd_ds_802_11_get_log *get_log =
239 (struct host_cmd_ds_802_11_get_log *) &resp->params.get_log;
240 struct mwifiex_ds_get_stats *stats = NULL;
243 stats = (struct mwifiex_ds_get_stats *) data_buf;
244 stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame);
245 stats->failed = le32_to_cpu(get_log->failed);
246 stats->retry = le32_to_cpu(get_log->retry);
247 stats->multi_retry = le32_to_cpu(get_log->multi_retry);
248 stats->frame_dup = le32_to_cpu(get_log->frame_dup);
249 stats->rts_success = le32_to_cpu(get_log->rts_success);
250 stats->rts_failure = le32_to_cpu(get_log->rts_failure);
251 stats->ack_failure = le32_to_cpu(get_log->ack_failure);
252 stats->rx_frag = le32_to_cpu(get_log->rx_frag);
253 stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame);
254 stats->fcs_error = le32_to_cpu(get_log->fcs_error);
255 stats->tx_frame = le32_to_cpu(get_log->tx_frame);
256 stats->wep_icv_error[0] =
257 le32_to_cpu(get_log->wep_icv_err_cnt[0]);
258 stats->wep_icv_error[1] =
259 le32_to_cpu(get_log->wep_icv_err_cnt[1]);
260 stats->wep_icv_error[2] =
261 le32_to_cpu(get_log->wep_icv_err_cnt[2]);
262 stats->wep_icv_error[3] =
263 le32_to_cpu(get_log->wep_icv_err_cnt[3]);
270 * This function handles the command response of set/get Tx rate
273 * Handling includes changing the header fields into CPU format
274 * and saving the following parameters in driver -
277 * - HT MCS rate bitmaps
279 * Based on the new rate bitmaps, the function re-evaluates if
280 * auto data rate has been activated. If not, it sends another
281 * query to the firmware to get the current Tx data rate and updates
284 static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
285 struct host_cmd_ds_command *resp,
288 struct mwifiex_adapter *adapter = priv->adapter;
289 struct mwifiex_rate_cfg *ds_rate = NULL;
290 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
291 struct mwifiex_rate_scope *rate_scope;
292 struct mwifiex_ie_types_header *head = NULL;
293 u16 tlv, tlv_buf_len;
298 tlv_buf = (u8 *) ((u8 *) rate_cfg) +
299 sizeof(struct host_cmd_ds_tx_rate_cfg);
300 tlv_buf_len = *(u16 *) (tlv_buf + sizeof(u16));
302 while (tlv_buf && tlv_buf_len > 0) {
304 tlv = tlv | (*(tlv_buf + 1) << 8);
307 case TLV_TYPE_RATE_SCOPE:
308 rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
309 priv->bitmap_rates[0] =
310 le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
311 priv->bitmap_rates[1] =
312 le16_to_cpu(rate_scope->ofdm_rate_bitmap);
315 sizeof(rate_scope->ht_mcs_rate_bitmap) /
317 priv->bitmap_rates[2 + i] =
318 le16_to_cpu(rate_scope->
319 ht_mcs_rate_bitmap[i]);
321 /* Add RATE_DROP tlv here */
324 head = (struct mwifiex_ie_types_header *) tlv_buf;
325 tlv_buf += le16_to_cpu(head->len) + sizeof(*head);
326 tlv_buf_len -= le16_to_cpu(head->len);
329 priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
331 if (priv->is_data_rate_auto)
334 ret = mwifiex_prepare_cmd(priv,
335 HostCmd_CMD_802_11_TX_RATE_QUERY,
336 HostCmd_ACT_GEN_GET, 0, NULL, NULL);
339 ds_rate = (struct mwifiex_rate_cfg *) data_buf;
340 if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
341 if (priv->is_data_rate_auto) {
342 ds_rate->is_rate_auto = 1;
345 mwifiex_get_rate_index(adapter,
351 MWIFIEX_RATE_BITMAP_OFDM0
353 MWIFIEX_RATE_BITMAP_OFDM7)
355 (MWIFIEX_RATE_BITMAP_OFDM0 -
356 MWIFIEX_RATE_INDEX_OFDM0);
358 MWIFIEX_RATE_BITMAP_MCS0
360 MWIFIEX_RATE_BITMAP_MCS127)
362 (MWIFIEX_RATE_BITMAP_MCS0 -
363 MWIFIEX_RATE_INDEX_MCS0);
372 * This function handles the command response of get Tx power level.
374 * Handling includes saving the maximum and minimum Tx power levels
375 * in driver, as well as sending the values to user.
377 static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
379 int length = -1, max_power = -1, min_power = -1;
380 struct mwifiex_types_power_group *pg_tlv_hdr = NULL;
381 struct mwifiex_power_group *pg = NULL;
385 (struct mwifiex_types_power_group *) ((u8 *) data_buf
386 + sizeof(struct host_cmd_ds_txpwr_cfg));
387 pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr +
388 sizeof(struct mwifiex_types_power_group));
389 length = pg_tlv_hdr->length;
391 max_power = pg->power_max;
392 min_power = pg->power_min;
393 length -= sizeof(struct mwifiex_power_group);
397 if (max_power < pg->power_max)
398 max_power = pg->power_max;
400 if (min_power > pg->power_min)
401 min_power = pg->power_min;
403 length -= sizeof(struct mwifiex_power_group);
405 if (pg_tlv_hdr->length > 0) {
406 priv->min_tx_power_level = (u8) min_power;
407 priv->max_tx_power_level = (u8) max_power;
417 * This function handles the command response of set/get Tx power
420 * Handling includes changing the header fields into CPU format
421 * and saving the current Tx power level in driver.
423 static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
424 struct host_cmd_ds_command *resp,
427 struct mwifiex_adapter *adapter = priv->adapter;
428 struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg;
429 struct mwifiex_types_power_group *pg_tlv_hdr = NULL;
430 struct mwifiex_power_group *pg = NULL;
431 u16 action = le16_to_cpu(txp_cfg->action);
434 case HostCmd_ACT_GEN_GET:
437 (struct mwifiex_types_power_group *) ((u8 *)
441 host_cmd_ds_txpwr_cfg));
442 pg = (struct mwifiex_power_group *) ((u8 *)
445 mwifiex_types_power_group));
446 if (adapter->hw_status ==
447 MWIFIEX_HW_STATUS_INITIALIZING)
448 mwifiex_get_power_level(priv, txp_cfg);
449 priv->tx_power_level = (u16) pg->power_min;
452 case HostCmd_ACT_GEN_SET:
453 if (le32_to_cpu(txp_cfg->mode)) {
455 (struct mwifiex_types_power_group *) ((u8 *)
459 host_cmd_ds_txpwr_cfg));
460 pg = (struct mwifiex_power_group *) ((u8 *) pg_tlv_hdr
463 mwifiex_types_power_group));
464 if (pg->power_max == pg->power_min)
465 priv->tx_power_level = (u16) pg->power_min;
469 dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n",
473 dev_dbg(adapter->dev,
474 "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n",
475 priv->tx_power_level, priv->max_tx_power_level,
476 priv->min_tx_power_level);
482 * This function handles the command response of set/get MAC address.
484 * Handling includes saving the MAC address in driver.
486 static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv,
487 struct host_cmd_ds_command *resp)
489 struct host_cmd_ds_802_11_mac_address *cmd_mac_addr =
490 &resp->params.mac_addr;
492 memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN);
494 dev_dbg(priv->adapter->dev,
495 "info: set mac address: %pM\n", priv->curr_addr);
501 * This function handles the command response of set/get MAC multicast
504 static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv,
505 struct host_cmd_ds_command *resp)
511 * This function handles the command response of get Tx rate query.
513 * Handling includes changing the header fields into CPU format
514 * and saving the Tx rate and HT information parameters in driver.
516 * Both rate configuration and current data rate can be retrieved
519 static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv,
520 struct host_cmd_ds_command *resp)
522 struct mwifiex_adapter *adapter = priv->adapter;
524 priv->tx_rate = resp->params.tx_rate.tx_rate;
525 priv->tx_htinfo = resp->params.tx_rate.ht_info;
526 if (!priv->is_data_rate_auto)
528 mwifiex_index_to_data_rate(adapter, priv->tx_rate,
535 * This function handles the command response of a deauthenticate
538 * If the deauthenticated MAC matches the current BSS MAC, the connection
541 static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
542 struct host_cmd_ds_command *resp)
544 struct mwifiex_adapter *adapter = priv->adapter;
546 adapter->dbg.num_cmd_deauth++;
547 if (!memcmp(resp->params.deauth.mac_addr,
548 &priv->curr_bss_params.bss_descriptor.mac_address,
549 sizeof(resp->params.deauth.mac_addr)))
550 mwifiex_reset_connect_state(priv);
556 * This function handles the command response of ad-hoc stop.
558 * The function resets the connection state in driver.
560 static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
561 struct host_cmd_ds_command *resp)
563 mwifiex_reset_connect_state(priv);
568 * This function handles the command response of set/get key material.
570 * Handling includes updating the driver parameters to reflect the
573 static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv,
574 struct host_cmd_ds_command *resp)
576 struct host_cmd_ds_802_11_key_material *key =
577 &resp->params.key_material;
579 if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
580 if ((le16_to_cpu(key->key_param_set.key_info) &
581 KEY_INFO_TKIP_MCAST)) {
582 dev_dbg(priv->adapter->dev, "info: key: GTK is set\n");
583 priv->wpa_is_gtk_set = true;
584 priv->scan_block = false;
588 memset(priv->aes_key.key_param_set.key, 0,
589 sizeof(key->key_param_set.key));
590 priv->aes_key.key_param_set.key_len = key->key_param_set.key_len;
591 memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key,
592 le16_to_cpu(priv->aes_key.key_param_set.key_len));
598 * This function handles the command response of get 11d domain information.
600 static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
601 struct host_cmd_ds_command *resp)
603 struct host_cmd_ds_802_11d_domain_info_rsp *domain_info =
604 &resp->params.domain_info_resp;
605 struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain;
606 u16 action = le16_to_cpu(domain_info->action);
607 u8 no_of_triplet = 0;
609 no_of_triplet = (u8) ((le16_to_cpu(domain->header.len) -
610 IEEE80211_COUNTRY_STRING_LEN) /
611 sizeof(struct ieee80211_country_ie_triplet));
613 dev_dbg(priv->adapter->dev, "info: 11D Domain Info Resp:"
614 " no_of_triplet=%d\n", no_of_triplet);
616 if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) {
617 dev_warn(priv->adapter->dev,
618 "11D: invalid number of triplets %d "
619 "returned!!\n", no_of_triplet);
624 case HostCmd_ACT_GEN_SET: /* Proc Set Action */
626 case HostCmd_ACT_GEN_GET:
629 dev_err(priv->adapter->dev,
630 "11D: invalid action:%d\n", domain_info->action);
638 * This function handles the command response of get RF channel.
640 * Handling includes changing the header fields into CPU format
641 * and saving the new channel in driver.
643 static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv,
644 struct host_cmd_ds_command *resp,
647 struct host_cmd_ds_802_11_rf_channel *rf_channel =
648 &resp->params.rf_channel;
649 u16 new_channel = le16_to_cpu(rf_channel->current_channel);
651 if (priv->curr_bss_params.bss_descriptor.channel != new_channel) {
652 dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n",
653 priv->curr_bss_params.bss_descriptor.channel,
655 /* Update the channel again */
656 priv->curr_bss_params.bss_descriptor.channel = new_channel;
659 *((u16 *)data_buf) = new_channel;
665 * This function handles the command response of get extended version.
667 * Handling includes forming the extended version string and sending it
670 static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
671 struct host_cmd_ds_command *resp,
674 struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext;
675 struct host_cmd_ds_version_ext *version_ext = NULL;
678 version_ext = (struct host_cmd_ds_version_ext *)data_buf;
679 version_ext->version_str_sel = ver_ext->version_str_sel;
680 memcpy(version_ext->version_str, ver_ext->version_str,
682 memcpy(priv->version_str, ver_ext->version_str, 128);
688 * This function handles the command response of register access.
690 * The register value and offset are returned to the user. For EEPROM
691 * access, the byte count is also returned.
693 static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
696 struct mwifiex_ds_reg_rw *reg_rw = NULL;
697 struct mwifiex_ds_read_eeprom *eeprom = NULL;
700 reg_rw = (struct mwifiex_ds_reg_rw *) data_buf;
701 eeprom = (struct mwifiex_ds_read_eeprom *) data_buf;
703 case HostCmd_CMD_MAC_REG_ACCESS:
705 struct host_cmd_ds_mac_reg_access *reg;
706 reg = (struct host_cmd_ds_mac_reg_access *)
707 &resp->params.mac_reg;
708 reg_rw->offset = cpu_to_le32(
709 (u32) le16_to_cpu(reg->offset));
710 reg_rw->value = reg->value;
713 case HostCmd_CMD_BBP_REG_ACCESS:
715 struct host_cmd_ds_bbp_reg_access *reg;
716 reg = (struct host_cmd_ds_bbp_reg_access *)
717 &resp->params.bbp_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);
724 case HostCmd_CMD_RF_REG_ACCESS:
726 struct host_cmd_ds_rf_reg_access *reg;
727 reg = (struct host_cmd_ds_rf_reg_access *)
728 &resp->params.rf_reg;
729 reg_rw->offset = cpu_to_le32(
730 (u32) le16_to_cpu(reg->offset));
731 reg_rw->value = cpu_to_le32((u32) reg->value);
734 case HostCmd_CMD_PMIC_REG_ACCESS:
736 struct host_cmd_ds_pmic_reg_access *reg;
737 reg = (struct host_cmd_ds_pmic_reg_access *)
738 &resp->params.pmic_reg;
739 reg_rw->offset = cpu_to_le32(
740 (u32) le16_to_cpu(reg->offset));
741 reg_rw->value = cpu_to_le32((u32) reg->value);
744 case HostCmd_CMD_CAU_REG_ACCESS:
746 struct host_cmd_ds_rf_reg_access *reg;
747 reg = (struct host_cmd_ds_rf_reg_access *)
748 &resp->params.rf_reg;
749 reg_rw->offset = cpu_to_le32(
750 (u32) le16_to_cpu(reg->offset));
751 reg_rw->value = cpu_to_le32((u32) reg->value);
754 case HostCmd_CMD_802_11_EEPROM_ACCESS:
756 struct host_cmd_ds_802_11_eeprom_access
758 (struct host_cmd_ds_802_11_eeprom_access
759 *) &resp->params.eeprom;
760 pr_debug("info: EEPROM read len=%x\n",
761 cmd_eeprom->byte_count);
762 if (le16_to_cpu(eeprom->byte_count) <
764 cmd_eeprom->byte_count)) {
765 eeprom->byte_count = cpu_to_le16(0);
766 pr_debug("info: EEPROM read "
767 "length is too big\n");
770 eeprom->offset = cmd_eeprom->offset;
771 eeprom->byte_count = cmd_eeprom->byte_count;
772 if (le16_to_cpu(eeprom->byte_count) > 0)
773 memcpy(&eeprom->value,
775 le16_to_cpu(eeprom->byte_count));
787 * This function handles the command response of get IBSS coalescing status.
789 * If the received BSSID is different than the current one, the current BSSID,
790 * beacon interval, ATIM window and ERP information are updated, along with
791 * changing the ad-hoc state accordingly.
793 static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
794 struct host_cmd_ds_command *resp)
796 struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp =
797 &(resp->params.ibss_coalescing);
798 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
800 if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET)
803 dev_dbg(priv->adapter->dev,
804 "info: new BSSID %pM\n", ibss_coal_resp->bssid);
806 /* If rsp has NULL BSSID, Just return..... No Action */
807 if (!memcmp(ibss_coal_resp->bssid, zero_mac, ETH_ALEN)) {
808 dev_warn(priv->adapter->dev, "new BSSID is NULL\n");
812 /* If BSSID is diff, modify current BSS parameters */
813 if (memcmp(priv->curr_bss_params.bss_descriptor.mac_address,
814 ibss_coal_resp->bssid, ETH_ALEN)) {
816 memcpy(priv->curr_bss_params.bss_descriptor.mac_address,
817 ibss_coal_resp->bssid, ETH_ALEN);
819 /* Beacon Interval */
820 priv->curr_bss_params.bss_descriptor.beacon_period
821 = le16_to_cpu(ibss_coal_resp->beacon_interval);
823 /* ERP Information */
824 priv->curr_bss_params.bss_descriptor.erp_flags =
825 (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect);
827 priv->adhoc_state = ADHOC_COALESCED;
834 * This function handles the command responses.
836 * This is a generic function, which calls command specific
837 * response handlers based on the command ID.
839 int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv,
840 u16 cmdresp_no, void *cmd_buf, void *wq_buf)
843 struct mwifiex_adapter *adapter = priv->adapter;
844 struct host_cmd_ds_command *resp =
845 (struct host_cmd_ds_command *) cmd_buf;
846 struct mwifiex_wait_queue *wait_queue =
847 (struct mwifiex_wait_queue *) wq_buf;
848 void *data_buf = adapter->curr_cmd->data_buf;
850 /* If the command is not successful, cleanup and return failure */
851 if (resp->result != HostCmd_RESULT_OK) {
852 mwifiex_process_cmdresp_error(priv, resp, wait_queue);
855 /* Command successful, handle response */
856 switch (cmdresp_no) {
857 case HostCmd_CMD_GET_HW_SPEC:
858 ret = mwifiex_ret_get_hw_spec(priv, resp);
860 case HostCmd_CMD_MAC_CONTROL:
862 case HostCmd_CMD_802_11_MAC_ADDRESS:
863 ret = mwifiex_ret_802_11_mac_address(priv, resp);
865 case HostCmd_CMD_MAC_MULTICAST_ADR:
866 ret = mwifiex_ret_mac_multicast_adr(priv, resp);
868 case HostCmd_CMD_TX_RATE_CFG:
869 ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf);
871 case HostCmd_CMD_802_11_SCAN:
872 ret = mwifiex_ret_802_11_scan(priv, resp, wait_queue);
874 adapter->curr_cmd->wq_buf = NULL;
876 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
877 ret = mwifiex_ret_802_11_scan(priv, resp, wait_queue);
878 dev_dbg(adapter->dev,
879 "info: CMD_RESP: BG_SCAN result is ready!\n");
881 case HostCmd_CMD_TXPWR_CFG:
882 ret = mwifiex_ret_tx_power_cfg(priv, resp, data_buf);
884 case HostCmd_CMD_802_11_PS_MODE_ENH:
885 ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf);
887 case HostCmd_CMD_802_11_HS_CFG_ENH:
888 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
890 case HostCmd_CMD_802_11_ASSOCIATE:
891 ret = mwifiex_ret_802_11_associate(priv, resp, wait_queue);
893 case HostCmd_CMD_802_11_DEAUTHENTICATE:
894 ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
896 case HostCmd_CMD_802_11_AD_HOC_START:
897 case HostCmd_CMD_802_11_AD_HOC_JOIN:
898 ret = mwifiex_ret_802_11_ad_hoc(priv, resp, wait_queue);
900 case HostCmd_CMD_802_11_AD_HOC_STOP:
901 ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
903 case HostCmd_CMD_802_11_GET_LOG:
904 ret = mwifiex_ret_get_log(priv, resp, data_buf);
906 case HostCmd_CMD_RSSI_INFO:
907 ret = mwifiex_ret_802_11_rssi_info(priv, resp, data_buf);
909 case HostCmd_CMD_802_11_SNMP_MIB:
910 ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf);
912 case HostCmd_CMD_802_11_TX_RATE_QUERY:
913 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
915 case HostCmd_CMD_802_11_RF_CHANNEL:
916 ret = mwifiex_ret_802_11_rf_channel(priv, resp, data_buf);
918 case HostCmd_CMD_VERSION_EXT:
919 ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
921 case HostCmd_CMD_FUNC_INIT:
922 case HostCmd_CMD_FUNC_SHUTDOWN:
924 case HostCmd_CMD_802_11_KEY_MATERIAL:
925 ret = mwifiex_ret_802_11_key_material(priv, resp);
927 case HostCmd_CMD_802_11D_DOMAIN_INFO:
928 ret = mwifiex_ret_802_11d_domain_info(priv, resp);
930 case HostCmd_CMD_11N_ADDBA_REQ:
931 ret = mwifiex_ret_11n_addba_req(priv, resp);
933 case HostCmd_CMD_11N_DELBA:
934 ret = mwifiex_ret_11n_delba(priv, resp);
936 case HostCmd_CMD_11N_ADDBA_RSP:
937 ret = mwifiex_ret_11n_addba_resp(priv, resp);
939 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
940 adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
942 adapter->tx_buf_size = (adapter->tx_buf_size /
943 MWIFIEX_SDIO_BLOCK_SIZE) *
944 MWIFIEX_SDIO_BLOCK_SIZE;
945 adapter->curr_tx_buf_size = adapter->tx_buf_size;
946 dev_dbg(adapter->dev,
947 "cmd: max_tx_buf_size=%d, tx_buf_size=%d\n",
948 adapter->max_tx_buf_size, adapter->tx_buf_size);
950 if (adapter->if_ops.update_mp_end_port)
951 adapter->if_ops.update_mp_end_port(adapter,
957 case HostCmd_CMD_AMSDU_AGGR_CTRL:
958 ret = mwifiex_ret_amsdu_aggr_ctrl(priv, resp, data_buf);
960 case HostCmd_CMD_WMM_GET_STATUS:
961 ret = mwifiex_ret_wmm_get_status(priv, resp);
963 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
964 ret = mwifiex_ret_ibss_coalescing_status(priv, resp);
966 case HostCmd_CMD_MAC_REG_ACCESS:
967 case HostCmd_CMD_BBP_REG_ACCESS:
968 case HostCmd_CMD_RF_REG_ACCESS:
969 case HostCmd_CMD_PMIC_REG_ACCESS:
970 case HostCmd_CMD_CAU_REG_ACCESS:
971 case HostCmd_CMD_802_11_EEPROM_ACCESS:
972 ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf);
974 case HostCmd_CMD_SET_BSS_MODE:
976 case HostCmd_CMD_11N_CFG:
977 ret = mwifiex_ret_11n_cfg(priv, resp, data_buf);
980 dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n",