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)
124 struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp =
125 &resp->params.rssi_info_rsp;
126 struct mwifiex_ds_misc_subsc_evt *subsc_evt =
127 &priv->async_subsc_evt_storage;
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 if (priv->subsc_evt_rssi_state == EVENT_HANDLED)
145 * Ideally, our use of async_subsc_evt_storage would be symmetric such
146 * that we could prove that the previous async call had completed before
147 * this one starts but this would require identifying where right point
148 * to relinguish the resource is and it isn't clear if there is such a
149 * point in the current implementation.
151 memset(subsc_evt, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt));
153 /* Resubscribe low and high rssi events with new thresholds */
154 subsc_evt->events = BITMASK_BCN_RSSI_LOW | BITMASK_BCN_RSSI_HIGH;
155 subsc_evt->action = HostCmd_ACT_BITWISE_SET;
156 if (priv->subsc_evt_rssi_state == RSSI_LOW_RECVD) {
157 subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg -
158 priv->cqm_rssi_hyst);
159 subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
160 } else if (priv->subsc_evt_rssi_state == RSSI_HIGH_RECVD) {
161 subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
162 subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg +
163 priv->cqm_rssi_hyst);
165 subsc_evt->bcn_l_rssi_cfg.evt_freq = 1;
166 subsc_evt->bcn_h_rssi_cfg.evt_freq = 1;
168 priv->subsc_evt_rssi_state = EVENT_HANDLED;
170 mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SUBSCRIBE_EVENT,
177 * This function handles the command response of set/get SNMP
180 * Handling includes changing the header fields into CPU format
181 * and saving the parameter in driver.
183 * The following parameters are supported -
184 * - Fragmentation threshold
186 * - Short retry limit
188 static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv,
189 struct host_cmd_ds_command *resp,
192 struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
193 u16 oid = le16_to_cpu(smib->oid);
194 u16 query_type = le16_to_cpu(smib->query_type);
197 dev_dbg(priv->adapter->dev, "info: SNMP_RESP: oid value = %#x,"
198 " query_type = %#x, buf size = %#x\n",
199 oid, query_type, le16_to_cpu(smib->buf_size));
200 if (query_type == HostCmd_ACT_GEN_GET) {
201 ul_temp = le16_to_cpu(*((__le16 *) (smib->value)));
206 dev_dbg(priv->adapter->dev,
207 "info: SNMP_RESP: FragThsd =%u\n", ul_temp);
210 dev_dbg(priv->adapter->dev,
211 "info: SNMP_RESP: RTSThsd =%u\n", ul_temp);
213 case SHORT_RETRY_LIM_I:
214 dev_dbg(priv->adapter->dev,
215 "info: SNMP_RESP: TxRetryCount=%u\n", ul_temp);
218 dev_dbg(priv->adapter->dev,
219 "info: SNMP_RESP: DTIM period=%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,
236 struct mwifiex_ds_get_stats *stats)
238 struct host_cmd_ds_802_11_get_log *get_log =
239 (struct host_cmd_ds_802_11_get_log *) &resp->params.get_log;
242 stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame);
243 stats->failed = le32_to_cpu(get_log->failed);
244 stats->retry = le32_to_cpu(get_log->retry);
245 stats->multi_retry = le32_to_cpu(get_log->multi_retry);
246 stats->frame_dup = le32_to_cpu(get_log->frame_dup);
247 stats->rts_success = le32_to_cpu(get_log->rts_success);
248 stats->rts_failure = le32_to_cpu(get_log->rts_failure);
249 stats->ack_failure = le32_to_cpu(get_log->ack_failure);
250 stats->rx_frag = le32_to_cpu(get_log->rx_frag);
251 stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame);
252 stats->fcs_error = le32_to_cpu(get_log->fcs_error);
253 stats->tx_frame = le32_to_cpu(get_log->tx_frame);
254 stats->wep_icv_error[0] =
255 le32_to_cpu(get_log->wep_icv_err_cnt[0]);
256 stats->wep_icv_error[1] =
257 le32_to_cpu(get_log->wep_icv_err_cnt[1]);
258 stats->wep_icv_error[2] =
259 le32_to_cpu(get_log->wep_icv_err_cnt[2]);
260 stats->wep_icv_error[3] =
261 le32_to_cpu(get_log->wep_icv_err_cnt[3]);
268 * This function handles the command response of set/get Tx rate
271 * Handling includes changing the header fields into CPU format
272 * and saving the following parameters in driver -
275 * - HT MCS rate bitmaps
277 * Based on the new rate bitmaps, the function re-evaluates if
278 * auto data rate has been activated. If not, it sends another
279 * query to the firmware to get the current Tx data rate and updates
282 static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
283 struct host_cmd_ds_command *resp,
284 struct mwifiex_rate_cfg *ds_rate)
286 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
287 struct mwifiex_rate_scope *rate_scope;
288 struct mwifiex_ie_types_header *head;
289 u16 tlv, tlv_buf_len;
294 tlv_buf = (u8 *) ((u8 *) rate_cfg) +
295 sizeof(struct host_cmd_ds_tx_rate_cfg);
296 tlv_buf_len = *(u16 *) (tlv_buf + sizeof(u16));
298 while (tlv_buf && tlv_buf_len > 0) {
300 tlv = tlv | (*(tlv_buf + 1) << 8);
303 case TLV_TYPE_RATE_SCOPE:
304 rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
305 priv->bitmap_rates[0] =
306 le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
307 priv->bitmap_rates[1] =
308 le16_to_cpu(rate_scope->ofdm_rate_bitmap);
311 sizeof(rate_scope->ht_mcs_rate_bitmap) /
313 priv->bitmap_rates[2 + i] =
314 le16_to_cpu(rate_scope->
315 ht_mcs_rate_bitmap[i]);
317 /* Add RATE_DROP tlv here */
320 head = (struct mwifiex_ie_types_header *) tlv_buf;
321 tlv_buf += le16_to_cpu(head->len) + sizeof(*head);
322 tlv_buf_len -= le16_to_cpu(head->len);
325 priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
327 if (priv->is_data_rate_auto)
330 ret = mwifiex_send_cmd_async(priv,
331 HostCmd_CMD_802_11_TX_RATE_QUERY,
332 HostCmd_ACT_GEN_GET, 0, NULL);
337 if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) {
338 if (priv->is_data_rate_auto) {
339 ds_rate->is_rate_auto = 1;
342 ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates,
343 sizeof(priv->bitmap_rates));
345 if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 &&
346 ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7)
347 ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 -
348 MWIFIEX_RATE_INDEX_OFDM0);
350 if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 &&
351 ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127)
352 ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 -
353 MWIFIEX_RATE_INDEX_MCS0);
360 * This function handles the command response of get Tx power level.
362 * Handling includes saving the maximum and minimum Tx power levels
363 * in driver, as well as sending the values to user.
365 static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
367 int length, max_power = -1, min_power = -1;
368 struct mwifiex_types_power_group *pg_tlv_hdr;
369 struct mwifiex_power_group *pg;
374 pg_tlv_hdr = (struct mwifiex_types_power_group *)
375 ((u8 *) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg));
376 pg = (struct mwifiex_power_group *)
377 ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group));
378 length = pg_tlv_hdr->length;
380 max_power = pg->power_max;
381 min_power = pg->power_min;
382 length -= sizeof(struct mwifiex_power_group);
386 if (max_power < pg->power_max)
387 max_power = pg->power_max;
389 if (min_power > pg->power_min)
390 min_power = pg->power_min;
392 length -= sizeof(struct mwifiex_power_group);
394 if (pg_tlv_hdr->length > 0) {
395 priv->min_tx_power_level = (u8) min_power;
396 priv->max_tx_power_level = (u8) max_power;
403 * This function handles the command response of set/get Tx power
406 * Handling includes changing the header fields into CPU format
407 * and saving the current Tx power level in driver.
409 static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
410 struct host_cmd_ds_command *resp)
412 struct mwifiex_adapter *adapter = priv->adapter;
413 struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg;
414 struct mwifiex_types_power_group *pg_tlv_hdr;
415 struct mwifiex_power_group *pg;
416 u16 action = le16_to_cpu(txp_cfg->action);
419 case HostCmd_ACT_GEN_GET:
420 pg_tlv_hdr = (struct mwifiex_types_power_group *)
422 sizeof(struct host_cmd_ds_txpwr_cfg));
424 pg = (struct mwifiex_power_group *)
426 sizeof(struct mwifiex_types_power_group));
428 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
429 mwifiex_get_power_level(priv, txp_cfg);
431 priv->tx_power_level = (u16) pg->power_min;
434 case HostCmd_ACT_GEN_SET:
435 if (!le32_to_cpu(txp_cfg->mode))
438 pg_tlv_hdr = (struct mwifiex_types_power_group *)
440 sizeof(struct host_cmd_ds_txpwr_cfg));
442 pg = (struct mwifiex_power_group *)
444 sizeof(struct mwifiex_types_power_group));
446 if (pg->power_max == pg->power_min)
447 priv->tx_power_level = (u16) pg->power_min;
450 dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n",
454 dev_dbg(adapter->dev,
455 "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n",
456 priv->tx_power_level, priv->max_tx_power_level,
457 priv->min_tx_power_level);
463 * This function handles the command response of set/get MAC address.
465 * Handling includes saving the MAC address in driver.
467 static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv,
468 struct host_cmd_ds_command *resp)
470 struct host_cmd_ds_802_11_mac_address *cmd_mac_addr =
471 &resp->params.mac_addr;
473 memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN);
475 dev_dbg(priv->adapter->dev,
476 "info: set mac address: %pM\n", priv->curr_addr);
482 * This function handles the command response of set/get MAC multicast
485 static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv,
486 struct host_cmd_ds_command *resp)
492 * This function handles the command response of get Tx rate query.
494 * Handling includes changing the header fields into CPU format
495 * and saving the Tx rate and HT information parameters in driver.
497 * Both rate configuration and current data rate can be retrieved
500 static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv,
501 struct host_cmd_ds_command *resp)
503 priv->tx_rate = resp->params.tx_rate.tx_rate;
504 priv->tx_htinfo = resp->params.tx_rate.ht_info;
505 if (!priv->is_data_rate_auto)
507 mwifiex_index_to_data_rate(priv, priv->tx_rate,
514 * This function handles the command response of a deauthenticate
517 * If the deauthenticated MAC matches the current BSS MAC, the connection
520 static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
521 struct host_cmd_ds_command *resp)
523 struct mwifiex_adapter *adapter = priv->adapter;
525 adapter->dbg.num_cmd_deauth++;
526 if (!memcmp(resp->params.deauth.mac_addr,
527 &priv->curr_bss_params.bss_descriptor.mac_address,
528 sizeof(resp->params.deauth.mac_addr)))
529 mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
535 * This function handles the command response of ad-hoc stop.
537 * The function resets the connection state in driver.
539 static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
540 struct host_cmd_ds_command *resp)
542 mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
547 * This function handles the command response of set/get key material.
549 * Handling includes updating the driver parameters to reflect the
552 static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv,
553 struct host_cmd_ds_command *resp)
555 struct host_cmd_ds_802_11_key_material *key =
556 &resp->params.key_material;
558 if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
559 if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
560 dev_dbg(priv->adapter->dev, "info: key: GTK is set\n");
561 priv->wpa_is_gtk_set = true;
562 priv->scan_block = false;
566 memset(priv->aes_key.key_param_set.key, 0,
567 sizeof(key->key_param_set.key));
568 priv->aes_key.key_param_set.key_len = key->key_param_set.key_len;
569 memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key,
570 le16_to_cpu(priv->aes_key.key_param_set.key_len));
576 * This function handles the command response of get 11d domain information.
578 static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
579 struct host_cmd_ds_command *resp)
581 struct host_cmd_ds_802_11d_domain_info_rsp *domain_info =
582 &resp->params.domain_info_resp;
583 struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain;
584 u16 action = le16_to_cpu(domain_info->action);
587 no_of_triplet = (u8) ((le16_to_cpu(domain->header.len)
588 - IEEE80211_COUNTRY_STRING_LEN)
589 / sizeof(struct ieee80211_country_ie_triplet));
591 dev_dbg(priv->adapter->dev,
592 "info: 11D Domain Info Resp: no_of_triplet=%d\n",
595 if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) {
596 dev_warn(priv->adapter->dev,
597 "11D: invalid number of triplets %d returned\n",
603 case HostCmd_ACT_GEN_SET: /* Proc Set Action */
605 case HostCmd_ACT_GEN_GET:
608 dev_err(priv->adapter->dev,
609 "11D: invalid action:%d\n", domain_info->action);
617 * This function handles the command response of get RF channel.
619 * Handling includes changing the header fields into CPU format
620 * and saving the new channel in driver.
622 static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv,
623 struct host_cmd_ds_command *resp,
626 struct host_cmd_ds_802_11_rf_channel *rf_channel =
627 &resp->params.rf_channel;
628 u16 new_channel = le16_to_cpu(rf_channel->current_channel);
630 if (priv->curr_bss_params.bss_descriptor.channel != new_channel) {
631 dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n",
632 priv->curr_bss_params.bss_descriptor.channel,
634 /* Update the channel again */
635 priv->curr_bss_params.bss_descriptor.channel = new_channel;
639 *data_buf = new_channel;
645 * This function handles the command response of get extended version.
647 * Handling includes forming the extended version string and sending it
650 static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
651 struct host_cmd_ds_command *resp,
652 struct host_cmd_ds_version_ext *version_ext)
654 struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext;
657 version_ext->version_str_sel = ver_ext->version_str_sel;
658 memcpy(version_ext->version_str, ver_ext->version_str,
660 memcpy(priv->version_str, ver_ext->version_str, 128);
666 * This function handles the command response of register access.
668 * The register value and offset are returned to the user. For EEPROM
669 * access, the byte count is also returned.
671 static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
674 struct mwifiex_ds_reg_rw *reg_rw;
675 struct mwifiex_ds_read_eeprom *eeprom;
677 struct host_cmd_ds_mac_reg_access *mac;
678 struct host_cmd_ds_bbp_reg_access *bbp;
679 struct host_cmd_ds_rf_reg_access *rf;
680 struct host_cmd_ds_pmic_reg_access *pmic;
681 struct host_cmd_ds_802_11_eeprom_access *eeprom;
690 case HostCmd_CMD_MAC_REG_ACCESS:
691 r.mac = (struct host_cmd_ds_mac_reg_access *)
692 &resp->params.mac_reg;
693 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset));
694 reg_rw->value = r.mac->value;
696 case HostCmd_CMD_BBP_REG_ACCESS:
697 r.bbp = (struct host_cmd_ds_bbp_reg_access *)
698 &resp->params.bbp_reg;
699 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset));
700 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
703 case HostCmd_CMD_RF_REG_ACCESS:
704 r.rf = (struct host_cmd_ds_rf_reg_access *)
705 &resp->params.rf_reg;
706 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
707 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
709 case HostCmd_CMD_PMIC_REG_ACCESS:
710 r.pmic = (struct host_cmd_ds_pmic_reg_access *)
711 &resp->params.pmic_reg;
712 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset));
713 reg_rw->value = cpu_to_le32((u32) r.pmic->value);
715 case HostCmd_CMD_CAU_REG_ACCESS:
716 r.rf = (struct host_cmd_ds_rf_reg_access *)
717 &resp->params.rf_reg;
718 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
719 reg_rw->value = cpu_to_le32((u32) r.rf->value);
721 case HostCmd_CMD_802_11_EEPROM_ACCESS:
722 r.eeprom = (struct host_cmd_ds_802_11_eeprom_access *)
723 &resp->params.eeprom;
724 pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count);
725 if (le16_to_cpu(eeprom->byte_count) <
726 le16_to_cpu(r.eeprom->byte_count)) {
727 eeprom->byte_count = cpu_to_le16(0);
728 pr_debug("info: EEPROM read length is too big\n");
731 eeprom->offset = r.eeprom->offset;
732 eeprom->byte_count = r.eeprom->byte_count;
733 if (le16_to_cpu(eeprom->byte_count) > 0)
734 memcpy(&eeprom->value, &r.eeprom->value,
735 le16_to_cpu(r.eeprom->byte_count));
745 * This function handles the command response of get IBSS coalescing status.
747 * If the received BSSID is different than the current one, the current BSSID,
748 * beacon interval, ATIM window and ERP information are updated, along with
749 * changing the ad-hoc state accordingly.
751 static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
752 struct host_cmd_ds_command *resp)
754 struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp =
755 &(resp->params.ibss_coalescing);
756 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
758 if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET)
761 dev_dbg(priv->adapter->dev,
762 "info: new BSSID %pM\n", ibss_coal_resp->bssid);
764 /* If rsp has NULL BSSID, Just return..... No Action */
765 if (!memcmp(ibss_coal_resp->bssid, zero_mac, ETH_ALEN)) {
766 dev_warn(priv->adapter->dev, "new BSSID is NULL\n");
770 /* If BSSID is diff, modify current BSS parameters */
771 if (memcmp(priv->curr_bss_params.bss_descriptor.mac_address,
772 ibss_coal_resp->bssid, ETH_ALEN)) {
774 memcpy(priv->curr_bss_params.bss_descriptor.mac_address,
775 ibss_coal_resp->bssid, ETH_ALEN);
777 /* Beacon Interval */
778 priv->curr_bss_params.bss_descriptor.beacon_period
779 = le16_to_cpu(ibss_coal_resp->beacon_interval);
781 /* ERP Information */
782 priv->curr_bss_params.bss_descriptor.erp_flags =
783 (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect);
785 priv->adhoc_state = ADHOC_COALESCED;
792 * This function handles the command response for subscribe event command.
794 static int mwifiex_ret_subsc_evt(struct mwifiex_private *priv,
795 struct host_cmd_ds_command *resp)
797 struct host_cmd_ds_802_11_subsc_evt *cmd_sub_event =
798 (struct host_cmd_ds_802_11_subsc_evt *)&resp->params.subsc_evt;
800 dev_dbg(priv->adapter->dev, "Bitmap of currently subscribed events: %16x\n",
801 le16_to_cpu(cmd_sub_event->events));
807 * This function handles the command responses.
809 * This is a generic function, which calls command specific
810 * response handlers based on the command ID.
812 int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
813 struct host_cmd_ds_command *resp)
816 struct mwifiex_adapter *adapter = priv->adapter;
817 void *data_buf = adapter->curr_cmd->data_buf;
819 /* If the command is not successful, cleanup and return failure */
820 if (resp->result != HostCmd_RESULT_OK) {
821 mwifiex_process_cmdresp_error(priv, resp);
824 /* Command successful, handle response */
825 switch (cmdresp_no) {
826 case HostCmd_CMD_GET_HW_SPEC:
827 ret = mwifiex_ret_get_hw_spec(priv, resp);
829 case HostCmd_CMD_MAC_CONTROL:
831 case HostCmd_CMD_802_11_MAC_ADDRESS:
832 ret = mwifiex_ret_802_11_mac_address(priv, resp);
834 case HostCmd_CMD_MAC_MULTICAST_ADR:
835 ret = mwifiex_ret_mac_multicast_adr(priv, resp);
837 case HostCmd_CMD_TX_RATE_CFG:
838 ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf);
840 case HostCmd_CMD_802_11_SCAN:
841 ret = mwifiex_ret_802_11_scan(priv, resp);
842 adapter->curr_cmd->wait_q_enabled = false;
844 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
845 ret = mwifiex_ret_802_11_scan(priv, resp);
846 dev_dbg(adapter->dev,
847 "info: CMD_RESP: BG_SCAN result is ready!\n");
849 case HostCmd_CMD_TXPWR_CFG:
850 ret = mwifiex_ret_tx_power_cfg(priv, resp);
852 case HostCmd_CMD_802_11_PS_MODE_ENH:
853 ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf);
855 case HostCmd_CMD_802_11_HS_CFG_ENH:
856 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
858 case HostCmd_CMD_802_11_ASSOCIATE:
859 ret = mwifiex_ret_802_11_associate(priv, resp);
861 case HostCmd_CMD_802_11_DEAUTHENTICATE:
862 ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
864 case HostCmd_CMD_802_11_AD_HOC_START:
865 case HostCmd_CMD_802_11_AD_HOC_JOIN:
866 ret = mwifiex_ret_802_11_ad_hoc(priv, resp);
868 case HostCmd_CMD_802_11_AD_HOC_STOP:
869 ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
871 case HostCmd_CMD_802_11_GET_LOG:
872 ret = mwifiex_ret_get_log(priv, resp, data_buf);
874 case HostCmd_CMD_RSSI_INFO:
875 ret = mwifiex_ret_802_11_rssi_info(priv, resp);
877 case HostCmd_CMD_802_11_SNMP_MIB:
878 ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf);
880 case HostCmd_CMD_802_11_TX_RATE_QUERY:
881 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
883 case HostCmd_CMD_802_11_RF_CHANNEL:
884 ret = mwifiex_ret_802_11_rf_channel(priv, resp, data_buf);
886 case HostCmd_CMD_VERSION_EXT:
887 ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
889 case HostCmd_CMD_MGMT_FRAME_REG:
890 case HostCmd_CMD_FUNC_INIT:
891 case HostCmd_CMD_FUNC_SHUTDOWN:
893 case HostCmd_CMD_802_11_KEY_MATERIAL:
894 ret = mwifiex_ret_802_11_key_material(priv, resp);
896 case HostCmd_CMD_802_11D_DOMAIN_INFO:
897 ret = mwifiex_ret_802_11d_domain_info(priv, resp);
899 case HostCmd_CMD_11N_ADDBA_REQ:
900 ret = mwifiex_ret_11n_addba_req(priv, resp);
902 case HostCmd_CMD_11N_DELBA:
903 ret = mwifiex_ret_11n_delba(priv, resp);
905 case HostCmd_CMD_11N_ADDBA_RSP:
906 ret = mwifiex_ret_11n_addba_resp(priv, resp);
908 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
909 adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
911 adapter->tx_buf_size = (adapter->tx_buf_size
912 / MWIFIEX_SDIO_BLOCK_SIZE)
913 * MWIFIEX_SDIO_BLOCK_SIZE;
914 adapter->curr_tx_buf_size = adapter->tx_buf_size;
915 dev_dbg(adapter->dev,
916 "cmd: max_tx_buf_size=%d, tx_buf_size=%d\n",
917 adapter->max_tx_buf_size, adapter->tx_buf_size);
919 if (adapter->if_ops.update_mp_end_port)
920 adapter->if_ops.update_mp_end_port(adapter,
921 le16_to_cpu(resp->params.tx_buf.mp_end_port));
923 case HostCmd_CMD_AMSDU_AGGR_CTRL:
925 case HostCmd_CMD_WMM_GET_STATUS:
926 ret = mwifiex_ret_wmm_get_status(priv, resp);
928 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
929 ret = mwifiex_ret_ibss_coalescing_status(priv, resp);
931 case HostCmd_CMD_MAC_REG_ACCESS:
932 case HostCmd_CMD_BBP_REG_ACCESS:
933 case HostCmd_CMD_RF_REG_ACCESS:
934 case HostCmd_CMD_PMIC_REG_ACCESS:
935 case HostCmd_CMD_CAU_REG_ACCESS:
936 case HostCmd_CMD_802_11_EEPROM_ACCESS:
937 ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf);
939 case HostCmd_CMD_SET_BSS_MODE:
941 case HostCmd_CMD_11N_CFG:
943 case HostCmd_CMD_PCIE_DESC_DETAILS:
945 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
946 ret = mwifiex_ret_subsc_evt(priv, resp);
949 dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n",