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;
61 "PS_MODE_ENH cmd failed: 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,
123 struct mwifiex_ds_get_signal *signal)
125 struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp =
126 &resp->params.rssi_info_rsp;
128 priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last);
129 priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last);
131 priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg);
132 priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg);
134 priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last);
135 priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last);
137 priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg);
138 priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg);
140 /* Need to indicate IOCTL complete */
142 memset(signal, 0, sizeof(*signal));
144 signal->selector = ALL_RSSI_INFO_MASK;
147 signal->bcn_rssi_last = priv->bcn_rssi_last;
148 signal->bcn_rssi_avg = priv->bcn_rssi_avg;
149 signal->data_rssi_last = priv->data_rssi_last;
150 signal->data_rssi_avg = priv->data_rssi_avg;
153 signal->bcn_snr_last =
154 CAL_SNR(priv->bcn_rssi_last, priv->bcn_nf_last);
155 signal->bcn_snr_avg =
156 CAL_SNR(priv->bcn_rssi_avg, priv->bcn_nf_avg);
157 signal->data_snr_last =
158 CAL_SNR(priv->data_rssi_last, priv->data_nf_last);
159 signal->data_snr_avg =
160 CAL_SNR(priv->data_rssi_avg, priv->data_nf_avg);
163 signal->bcn_nf_last = priv->bcn_nf_last;
164 signal->bcn_nf_avg = priv->bcn_nf_avg;
165 signal->data_nf_last = priv->data_nf_last;
166 signal->data_nf_avg = priv->data_nf_avg;
173 * This function handles the command response of set/get SNMP
176 * Handling includes changing the header fields into CPU format
177 * and saving the parameter in driver.
179 * The following parameters are supported -
180 * - Fragmentation threshold
182 * - Short retry limit
184 static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv,
185 struct host_cmd_ds_command *resp,
188 struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
189 u16 oid = le16_to_cpu(smib->oid);
190 u16 query_type = le16_to_cpu(smib->query_type);
193 dev_dbg(priv->adapter->dev, "info: SNMP_RESP: oid value = %#x,"
194 " query_type = %#x, buf size = %#x\n",
195 oid, query_type, le16_to_cpu(smib->buf_size));
196 if (query_type == HostCmd_ACT_GEN_GET) {
197 ul_temp = le16_to_cpu(*((__le16 *) (smib->value)));
202 dev_dbg(priv->adapter->dev,
203 "info: SNMP_RESP: FragThsd =%u\n", ul_temp);
206 dev_dbg(priv->adapter->dev,
207 "info: SNMP_RESP: RTSThsd =%u\n", ul_temp);
209 case SHORT_RETRY_LIM_I:
210 dev_dbg(priv->adapter->dev,
211 "info: SNMP_RESP: TxRetryCount=%u\n", ul_temp);
214 dev_dbg(priv->adapter->dev,
215 "info: SNMP_RESP: DTIM period=%u\n", ul_temp);
225 * This function handles the command response of get log request
227 * Handling includes changing the header fields into CPU format
228 * and sending the received parameters to application.
230 static int mwifiex_ret_get_log(struct mwifiex_private *priv,
231 struct host_cmd_ds_command *resp,
232 struct mwifiex_ds_get_stats *stats)
234 struct host_cmd_ds_802_11_get_log *get_log =
235 (struct host_cmd_ds_802_11_get_log *) &resp->params.get_log;
238 stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame);
239 stats->failed = le32_to_cpu(get_log->failed);
240 stats->retry = le32_to_cpu(get_log->retry);
241 stats->multi_retry = le32_to_cpu(get_log->multi_retry);
242 stats->frame_dup = le32_to_cpu(get_log->frame_dup);
243 stats->rts_success = le32_to_cpu(get_log->rts_success);
244 stats->rts_failure = le32_to_cpu(get_log->rts_failure);
245 stats->ack_failure = le32_to_cpu(get_log->ack_failure);
246 stats->rx_frag = le32_to_cpu(get_log->rx_frag);
247 stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame);
248 stats->fcs_error = le32_to_cpu(get_log->fcs_error);
249 stats->tx_frame = le32_to_cpu(get_log->tx_frame);
250 stats->wep_icv_error[0] =
251 le32_to_cpu(get_log->wep_icv_err_cnt[0]);
252 stats->wep_icv_error[1] =
253 le32_to_cpu(get_log->wep_icv_err_cnt[1]);
254 stats->wep_icv_error[2] =
255 le32_to_cpu(get_log->wep_icv_err_cnt[2]);
256 stats->wep_icv_error[3] =
257 le32_to_cpu(get_log->wep_icv_err_cnt[3]);
264 * This function handles the command response of set/get Tx rate
267 * Handling includes changing the header fields into CPU format
268 * and saving the following parameters in driver -
271 * - HT MCS rate bitmaps
273 * Based on the new rate bitmaps, the function re-evaluates if
274 * auto data rate has been activated. If not, it sends another
275 * query to the firmware to get the current Tx data rate and updates
278 static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
279 struct host_cmd_ds_command *resp,
280 struct mwifiex_rate_cfg *ds_rate)
282 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
283 struct mwifiex_rate_scope *rate_scope;
284 struct mwifiex_ie_types_header *head;
285 u16 tlv, tlv_buf_len;
290 tlv_buf = (u8 *) ((u8 *) rate_cfg) +
291 sizeof(struct host_cmd_ds_tx_rate_cfg);
292 tlv_buf_len = *(u16 *) (tlv_buf + sizeof(u16));
294 while (tlv_buf && tlv_buf_len > 0) {
296 tlv = tlv | (*(tlv_buf + 1) << 8);
299 case TLV_TYPE_RATE_SCOPE:
300 rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
301 priv->bitmap_rates[0] =
302 le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
303 priv->bitmap_rates[1] =
304 le16_to_cpu(rate_scope->ofdm_rate_bitmap);
307 sizeof(rate_scope->ht_mcs_rate_bitmap) /
309 priv->bitmap_rates[2 + i] =
310 le16_to_cpu(rate_scope->
311 ht_mcs_rate_bitmap[i]);
313 /* Add RATE_DROP tlv here */
316 head = (struct mwifiex_ie_types_header *) tlv_buf;
317 tlv_buf += le16_to_cpu(head->len) + sizeof(*head);
318 tlv_buf_len -= le16_to_cpu(head->len);
321 priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
323 if (priv->is_data_rate_auto)
326 ret = mwifiex_send_cmd_async(priv,
327 HostCmd_CMD_802_11_TX_RATE_QUERY,
328 HostCmd_ACT_GEN_GET, 0, NULL);
333 if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
334 if (priv->is_data_rate_auto) {
335 ds_rate->is_rate_auto = 1;
338 ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates,
339 sizeof(priv->bitmap_rates));
341 if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 &&
342 ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7)
343 ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 -
344 MWIFIEX_RATE_INDEX_OFDM0);
346 if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 &&
347 ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127)
348 ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 -
349 MWIFIEX_RATE_INDEX_MCS0);
356 * This function handles the command response of get Tx power level.
358 * Handling includes saving the maximum and minimum Tx power levels
359 * in driver, as well as sending the values to user.
361 static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
363 int length, max_power = -1, min_power = -1;
364 struct mwifiex_types_power_group *pg_tlv_hdr;
365 struct mwifiex_power_group *pg;
370 pg_tlv_hdr = (struct mwifiex_types_power_group *)
371 ((u8 *) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg));
372 pg = (struct mwifiex_power_group *)
373 ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group));
374 length = pg_tlv_hdr->length;
376 max_power = pg->power_max;
377 min_power = pg->power_min;
378 length -= sizeof(struct mwifiex_power_group);
382 if (max_power < pg->power_max)
383 max_power = pg->power_max;
385 if (min_power > pg->power_min)
386 min_power = pg->power_min;
388 length -= sizeof(struct mwifiex_power_group);
390 if (pg_tlv_hdr->length > 0) {
391 priv->min_tx_power_level = (u8) min_power;
392 priv->max_tx_power_level = (u8) max_power;
399 * This function handles the command response of set/get Tx power
402 * Handling includes changing the header fields into CPU format
403 * and saving the current Tx power level in driver.
405 static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
406 struct host_cmd_ds_command *resp)
408 struct mwifiex_adapter *adapter = priv->adapter;
409 struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg;
410 struct mwifiex_types_power_group *pg_tlv_hdr;
411 struct mwifiex_power_group *pg;
412 u16 action = le16_to_cpu(txp_cfg->action);
415 case HostCmd_ACT_GEN_GET:
416 pg_tlv_hdr = (struct mwifiex_types_power_group *)
418 sizeof(struct host_cmd_ds_txpwr_cfg));
420 pg = (struct mwifiex_power_group *)
422 sizeof(struct mwifiex_types_power_group));
424 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
425 mwifiex_get_power_level(priv, txp_cfg);
427 priv->tx_power_level = (u16) pg->power_min;
430 case HostCmd_ACT_GEN_SET:
431 if (!le32_to_cpu(txp_cfg->mode))
434 pg_tlv_hdr = (struct mwifiex_types_power_group *)
436 sizeof(struct host_cmd_ds_txpwr_cfg));
438 pg = (struct mwifiex_power_group *)
440 sizeof(struct mwifiex_types_power_group));
442 if (pg->power_max == pg->power_min)
443 priv->tx_power_level = (u16) pg->power_min;
446 dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n",
450 dev_dbg(adapter->dev,
451 "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n",
452 priv->tx_power_level, priv->max_tx_power_level,
453 priv->min_tx_power_level);
459 * This function handles the command response of set/get MAC address.
461 * Handling includes saving the MAC address in driver.
463 static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv,
464 struct host_cmd_ds_command *resp)
466 struct host_cmd_ds_802_11_mac_address *cmd_mac_addr =
467 &resp->params.mac_addr;
469 memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN);
471 dev_dbg(priv->adapter->dev,
472 "info: set mac address: %pM\n", priv->curr_addr);
478 * This function handles the command response of set/get MAC multicast
481 static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv,
482 struct host_cmd_ds_command *resp)
488 * This function handles the command response of get Tx rate query.
490 * Handling includes changing the header fields into CPU format
491 * and saving the Tx rate and HT information parameters in driver.
493 * Both rate configuration and current data rate can be retrieved
496 static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv,
497 struct host_cmd_ds_command *resp)
499 priv->tx_rate = resp->params.tx_rate.tx_rate;
500 priv->tx_htinfo = resp->params.tx_rate.ht_info;
501 if (!priv->is_data_rate_auto)
503 mwifiex_index_to_data_rate(priv, priv->tx_rate,
510 * This function handles the command response of a deauthenticate
513 * If the deauthenticated MAC matches the current BSS MAC, the connection
516 static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
517 struct host_cmd_ds_command *resp)
519 struct mwifiex_adapter *adapter = priv->adapter;
521 adapter->dbg.num_cmd_deauth++;
522 if (!memcmp(resp->params.deauth.mac_addr,
523 &priv->curr_bss_params.bss_descriptor.mac_address,
524 sizeof(resp->params.deauth.mac_addr)))
525 mwifiex_reset_connect_state(priv);
531 * This function handles the command response of ad-hoc stop.
533 * The function resets the connection state in driver.
535 static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
536 struct host_cmd_ds_command *resp)
538 mwifiex_reset_connect_state(priv);
543 * This function handles the command response of set/get key material.
545 * Handling includes updating the driver parameters to reflect the
548 static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv,
549 struct host_cmd_ds_command *resp)
551 struct host_cmd_ds_802_11_key_material *key =
552 &resp->params.key_material;
554 if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
555 if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
556 dev_dbg(priv->adapter->dev, "info: key: GTK is set\n");
557 priv->wpa_is_gtk_set = true;
558 priv->scan_block = false;
562 memset(priv->aes_key.key_param_set.key, 0,
563 sizeof(key->key_param_set.key));
564 priv->aes_key.key_param_set.key_len = key->key_param_set.key_len;
565 memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key,
566 le16_to_cpu(priv->aes_key.key_param_set.key_len));
572 * This function handles the command response of get 11d domain information.
574 static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
575 struct host_cmd_ds_command *resp)
577 struct host_cmd_ds_802_11d_domain_info_rsp *domain_info =
578 &resp->params.domain_info_resp;
579 struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain;
580 u16 action = le16_to_cpu(domain_info->action);
583 no_of_triplet = (u8) ((le16_to_cpu(domain->header.len)
584 - IEEE80211_COUNTRY_STRING_LEN)
585 / sizeof(struct ieee80211_country_ie_triplet));
587 dev_dbg(priv->adapter->dev,
588 "info: 11D Domain Info Resp: no_of_triplet=%d\n",
591 if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) {
592 dev_warn(priv->adapter->dev,
593 "11D: invalid number of triplets %d returned\n",
599 case HostCmd_ACT_GEN_SET: /* Proc Set Action */
601 case HostCmd_ACT_GEN_GET:
604 dev_err(priv->adapter->dev,
605 "11D: invalid action:%d\n", domain_info->action);
613 * This function handles the command response of get RF channel.
615 * Handling includes changing the header fields into CPU format
616 * and saving the new channel in driver.
618 static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv,
619 struct host_cmd_ds_command *resp,
622 struct host_cmd_ds_802_11_rf_channel *rf_channel =
623 &resp->params.rf_channel;
624 u16 new_channel = le16_to_cpu(rf_channel->current_channel);
626 if (priv->curr_bss_params.bss_descriptor.channel != new_channel) {
627 dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n",
628 priv->curr_bss_params.bss_descriptor.channel,
630 /* Update the channel again */
631 priv->curr_bss_params.bss_descriptor.channel = new_channel;
635 *data_buf = new_channel;
641 * This function handles the command response of get extended version.
643 * Handling includes forming the extended version string and sending it
646 static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
647 struct host_cmd_ds_command *resp,
648 struct host_cmd_ds_version_ext *version_ext)
650 struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext;
653 version_ext->version_str_sel = ver_ext->version_str_sel;
654 memcpy(version_ext->version_str, ver_ext->version_str,
656 memcpy(priv->version_str, ver_ext->version_str, 128);
662 * This function handles the command response of register access.
664 * The register value and offset are returned to the user. For EEPROM
665 * access, the byte count is also returned.
667 static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
670 struct mwifiex_ds_reg_rw *reg_rw;
671 struct mwifiex_ds_read_eeprom *eeprom;
673 struct host_cmd_ds_mac_reg_access *mac;
674 struct host_cmd_ds_bbp_reg_access *bbp;
675 struct host_cmd_ds_rf_reg_access *rf;
676 struct host_cmd_ds_pmic_reg_access *pmic;
677 struct host_cmd_ds_802_11_eeprom_access *eeprom;
686 case HostCmd_CMD_MAC_REG_ACCESS:
687 r.mac = (struct host_cmd_ds_mac_reg_access *)
688 &resp->params.mac_reg;
689 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset));
690 reg_rw->value = r.mac->value;
692 case HostCmd_CMD_BBP_REG_ACCESS:
693 r.bbp = (struct host_cmd_ds_bbp_reg_access *)
694 &resp->params.bbp_reg;
695 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset));
696 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
699 case HostCmd_CMD_RF_REG_ACCESS:
700 r.rf = (struct host_cmd_ds_rf_reg_access *)
701 &resp->params.rf_reg;
702 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
703 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
705 case HostCmd_CMD_PMIC_REG_ACCESS:
706 r.pmic = (struct host_cmd_ds_pmic_reg_access *)
707 &resp->params.pmic_reg;
708 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset));
709 reg_rw->value = cpu_to_le32((u32) r.pmic->value);
711 case HostCmd_CMD_CAU_REG_ACCESS:
712 r.rf = (struct host_cmd_ds_rf_reg_access *)
713 &resp->params.rf_reg;
714 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
715 reg_rw->value = cpu_to_le32((u32) r.rf->value);
717 case HostCmd_CMD_802_11_EEPROM_ACCESS:
718 r.eeprom = (struct host_cmd_ds_802_11_eeprom_access *)
719 &resp->params.eeprom;
720 pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count);
721 if (le16_to_cpu(eeprom->byte_count) <
722 le16_to_cpu(r.eeprom->byte_count)) {
723 eeprom->byte_count = cpu_to_le16(0);
724 pr_debug("info: EEPROM read length is too big\n");
727 eeprom->offset = r.eeprom->offset;
728 eeprom->byte_count = r.eeprom->byte_count;
729 if (le16_to_cpu(eeprom->byte_count) > 0)
730 memcpy(&eeprom->value, &r.eeprom->value,
731 le16_to_cpu(r.eeprom->byte_count));
741 * This function handles the command response of get IBSS coalescing status.
743 * If the received BSSID is different than the current one, the current BSSID,
744 * beacon interval, ATIM window and ERP information are updated, along with
745 * changing the ad-hoc state accordingly.
747 static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
748 struct host_cmd_ds_command *resp)
750 struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp =
751 &(resp->params.ibss_coalescing);
752 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
754 if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET)
757 dev_dbg(priv->adapter->dev,
758 "info: new BSSID %pM\n", ibss_coal_resp->bssid);
760 /* If rsp has NULL BSSID, Just return..... No Action */
761 if (!memcmp(ibss_coal_resp->bssid, zero_mac, ETH_ALEN)) {
762 dev_warn(priv->adapter->dev, "new BSSID is NULL\n");
766 /* If BSSID is diff, modify current BSS parameters */
767 if (memcmp(priv->curr_bss_params.bss_descriptor.mac_address,
768 ibss_coal_resp->bssid, ETH_ALEN)) {
770 memcpy(priv->curr_bss_params.bss_descriptor.mac_address,
771 ibss_coal_resp->bssid, ETH_ALEN);
773 /* Beacon Interval */
774 priv->curr_bss_params.bss_descriptor.beacon_period
775 = le16_to_cpu(ibss_coal_resp->beacon_interval);
777 /* ERP Information */
778 priv->curr_bss_params.bss_descriptor.erp_flags =
779 (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect);
781 priv->adhoc_state = ADHOC_COALESCED;
788 * This function handles the command responses.
790 * This is a generic function, which calls command specific
791 * response handlers based on the command ID.
793 int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
794 struct host_cmd_ds_command *resp)
797 struct mwifiex_adapter *adapter = priv->adapter;
798 void *data_buf = adapter->curr_cmd->data_buf;
800 /* If the command is not successful, cleanup and return failure */
801 if (resp->result != HostCmd_RESULT_OK) {
802 mwifiex_process_cmdresp_error(priv, resp);
805 /* Command successful, handle response */
806 switch (cmdresp_no) {
807 case HostCmd_CMD_GET_HW_SPEC:
808 ret = mwifiex_ret_get_hw_spec(priv, resp);
810 case HostCmd_CMD_MAC_CONTROL:
812 case HostCmd_CMD_802_11_MAC_ADDRESS:
813 ret = mwifiex_ret_802_11_mac_address(priv, resp);
815 case HostCmd_CMD_MAC_MULTICAST_ADR:
816 ret = mwifiex_ret_mac_multicast_adr(priv, resp);
818 case HostCmd_CMD_TX_RATE_CFG:
819 ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf);
821 case HostCmd_CMD_802_11_SCAN:
822 ret = mwifiex_ret_802_11_scan(priv, resp);
823 adapter->curr_cmd->wait_q_enabled = false;
825 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
826 ret = mwifiex_ret_802_11_scan(priv, resp);
827 dev_dbg(adapter->dev,
828 "info: CMD_RESP: BG_SCAN result is ready!\n");
830 case HostCmd_CMD_TXPWR_CFG:
831 ret = mwifiex_ret_tx_power_cfg(priv, resp);
833 case HostCmd_CMD_802_11_PS_MODE_ENH:
834 ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf);
836 case HostCmd_CMD_802_11_HS_CFG_ENH:
837 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
839 case HostCmd_CMD_802_11_ASSOCIATE:
840 ret = mwifiex_ret_802_11_associate(priv, resp);
842 case HostCmd_CMD_802_11_DEAUTHENTICATE:
843 ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
845 case HostCmd_CMD_802_11_AD_HOC_START:
846 case HostCmd_CMD_802_11_AD_HOC_JOIN:
847 ret = mwifiex_ret_802_11_ad_hoc(priv, resp);
849 case HostCmd_CMD_802_11_AD_HOC_STOP:
850 ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
852 case HostCmd_CMD_802_11_GET_LOG:
853 ret = mwifiex_ret_get_log(priv, resp, data_buf);
855 case HostCmd_CMD_RSSI_INFO:
856 ret = mwifiex_ret_802_11_rssi_info(priv, resp, data_buf);
858 case HostCmd_CMD_802_11_SNMP_MIB:
859 ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf);
861 case HostCmd_CMD_802_11_TX_RATE_QUERY:
862 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
864 case HostCmd_CMD_802_11_RF_CHANNEL:
865 ret = mwifiex_ret_802_11_rf_channel(priv, resp, data_buf);
867 case HostCmd_CMD_VERSION_EXT:
868 ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
870 case HostCmd_CMD_FUNC_INIT:
871 case HostCmd_CMD_FUNC_SHUTDOWN:
873 case HostCmd_CMD_802_11_KEY_MATERIAL:
874 ret = mwifiex_ret_802_11_key_material(priv, resp);
876 case HostCmd_CMD_802_11D_DOMAIN_INFO:
877 ret = mwifiex_ret_802_11d_domain_info(priv, resp);
879 case HostCmd_CMD_11N_ADDBA_REQ:
880 ret = mwifiex_ret_11n_addba_req(priv, resp);
882 case HostCmd_CMD_11N_DELBA:
883 ret = mwifiex_ret_11n_delba(priv, resp);
885 case HostCmd_CMD_11N_ADDBA_RSP:
886 ret = mwifiex_ret_11n_addba_resp(priv, resp);
888 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
889 adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
891 adapter->tx_buf_size = (adapter->tx_buf_size
892 / MWIFIEX_SDIO_BLOCK_SIZE)
893 * MWIFIEX_SDIO_BLOCK_SIZE;
894 adapter->curr_tx_buf_size = adapter->tx_buf_size;
895 dev_dbg(adapter->dev,
896 "cmd: max_tx_buf_size=%d, tx_buf_size=%d\n",
897 adapter->max_tx_buf_size, adapter->tx_buf_size);
899 if (adapter->if_ops.update_mp_end_port)
900 adapter->if_ops.update_mp_end_port(adapter,
901 le16_to_cpu(resp->params.tx_buf.mp_end_port));
903 case HostCmd_CMD_AMSDU_AGGR_CTRL:
904 ret = mwifiex_ret_amsdu_aggr_ctrl(resp, data_buf);
906 case HostCmd_CMD_WMM_GET_STATUS:
907 ret = mwifiex_ret_wmm_get_status(priv, resp);
909 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
910 ret = mwifiex_ret_ibss_coalescing_status(priv, resp);
912 case HostCmd_CMD_MAC_REG_ACCESS:
913 case HostCmd_CMD_BBP_REG_ACCESS:
914 case HostCmd_CMD_RF_REG_ACCESS:
915 case HostCmd_CMD_PMIC_REG_ACCESS:
916 case HostCmd_CMD_CAU_REG_ACCESS:
917 case HostCmd_CMD_802_11_EEPROM_ACCESS:
918 ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf);
920 case HostCmd_CMD_SET_BSS_MODE:
922 case HostCmd_CMD_11N_CFG:
923 ret = mwifiex_ret_11n_cfg(resp, data_buf);
925 case HostCmd_CMD_PCIE_DESC_DETAILS:
928 dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n",