2 * Marvell Wireless LAN device driver: station command response handling
4 * Copyright (C) 2011-2014, 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.
31 * This function handles the command response error case.
33 * For scan response error, the function cancels all the pending
34 * scan commands and generates an event to inform the applications
35 * of the scan completion.
37 * For Power Save command failure, we do not retry enter PS
38 * command in case of Ad-hoc mode.
40 * For all other response errors, the current command buffer is freed
41 * and returned to the free command queue.
44 mwifiex_process_cmdresp_error(struct mwifiex_private *priv,
45 struct host_cmd_ds_command *resp)
47 struct cmd_ctrl_node *cmd_node = NULL, *tmp_node;
48 struct mwifiex_adapter *adapter = priv->adapter;
49 struct host_cmd_ds_802_11_ps_mode_enh *pm;
52 mwifiex_dbg(adapter, ERROR,
53 "CMD_RESP: cmd %#x error, result=%#x\n",
54 resp->command, resp->result);
56 if (adapter->curr_cmd->wait_q_enabled)
57 adapter->cmd_wait_q.status = -1;
59 switch (le16_to_cpu(resp->command)) {
60 case HostCmd_CMD_802_11_PS_MODE_ENH:
61 pm = &resp->params.psmode_enh;
62 mwifiex_dbg(adapter, ERROR,
63 "PS_MODE_ENH cmd failed: result=0x%x action=0x%X\n",
64 resp->result, le16_to_cpu(pm->action));
65 /* We do not re-try enter-ps command in ad-hoc mode. */
66 if (le16_to_cpu(pm->action) == EN_AUTO_PS &&
67 (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) &&
68 priv->bss_mode == NL80211_IFTYPE_ADHOC)
69 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
72 case HostCmd_CMD_802_11_SCAN:
73 case HostCmd_CMD_802_11_SCAN_EXT:
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);
91 case HostCmd_CMD_MAC_CONTROL:
94 case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG:
95 mwifiex_dbg(adapter, MSG,
96 "SDIO RX single-port aggregation Not support\n");
102 /* Handling errors here */
103 mwifiex_recycle_cmd_node(adapter, adapter->curr_cmd);
105 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
106 adapter->curr_cmd = NULL;
107 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
111 * This function handles the command response of get RSSI info.
113 * Handling includes changing the header fields into CPU format
114 * and saving the following parameters in driver -
115 * - Last data and beacon RSSI value
116 * - Average data and beacon RSSI value
117 * - Last data and beacon NF value
118 * - Average data and beacon NF value
120 * The parameters are send to the application as well, along with
121 * calculated SNR values.
123 static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv,
124 struct host_cmd_ds_command *resp)
126 struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp =
127 &resp->params.rssi_info_rsp;
128 struct mwifiex_ds_misc_subsc_evt *subsc_evt =
129 &priv->async_subsc_evt_storage;
131 priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last);
132 priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last);
134 priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg);
135 priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg);
137 priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last);
138 priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last);
140 priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg);
141 priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg);
143 if (priv->subsc_evt_rssi_state == EVENT_HANDLED)
146 memset(subsc_evt, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt));
148 /* Resubscribe low and high rssi events with new thresholds */
149 subsc_evt->events = BITMASK_BCN_RSSI_LOW | BITMASK_BCN_RSSI_HIGH;
150 subsc_evt->action = HostCmd_ACT_BITWISE_SET;
151 if (priv->subsc_evt_rssi_state == RSSI_LOW_RECVD) {
152 subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg -
153 priv->cqm_rssi_hyst);
154 subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
155 } else if (priv->subsc_evt_rssi_state == RSSI_HIGH_RECVD) {
156 subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
157 subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg +
158 priv->cqm_rssi_hyst);
160 subsc_evt->bcn_l_rssi_cfg.evt_freq = 1;
161 subsc_evt->bcn_h_rssi_cfg.evt_freq = 1;
163 priv->subsc_evt_rssi_state = EVENT_HANDLED;
165 mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SUBSCRIBE_EVENT,
166 0, 0, subsc_evt, false);
172 * This function handles the command response of set/get SNMP
175 * Handling includes changing the header fields into CPU format
176 * and saving the parameter in driver.
178 * The following parameters are supported -
179 * - Fragmentation threshold
181 * - Short retry limit
183 static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv,
184 struct host_cmd_ds_command *resp,
187 struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
188 u16 oid = le16_to_cpu(smib->oid);
189 u16 query_type = le16_to_cpu(smib->query_type);
192 mwifiex_dbg(priv->adapter, INFO,
193 "info: SNMP_RESP: oid value = %#x,\t"
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 mwifiex_dbg(priv->adapter, INFO,
203 "info: SNMP_RESP: FragThsd =%u\n",
207 mwifiex_dbg(priv->adapter, INFO,
208 "info: SNMP_RESP: RTSThsd =%u\n",
211 case SHORT_RETRY_LIM_I:
212 mwifiex_dbg(priv->adapter, INFO,
213 "info: SNMP_RESP: TxRetryCount=%u\n",
217 mwifiex_dbg(priv->adapter, INFO,
218 "info: SNMP_RESP: DTIM period=%u\n",
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 &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]);
262 stats->bcn_rcv_cnt = le32_to_cpu(get_log->bcn_rcv_cnt);
263 stats->bcn_miss_cnt = le32_to_cpu(get_log->bcn_miss_cnt);
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.
283 static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
284 struct host_cmd_ds_command *resp)
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, tlv_buf_left;
293 tlv_buf = ((u8 *)rate_cfg) + sizeof(struct host_cmd_ds_tx_rate_cfg);
294 tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*rate_cfg);
296 while (tlv_buf_left >= sizeof(*head)) {
297 head = (struct mwifiex_ie_types_header *)tlv_buf;
298 tlv = le16_to_cpu(head->type);
299 tlv_buf_len = le16_to_cpu(head->len);
301 if (tlv_buf_left < (sizeof(*head) + tlv_buf_len))
305 case TLV_TYPE_RATE_SCOPE:
306 rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
307 priv->bitmap_rates[0] =
308 le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
309 priv->bitmap_rates[1] =
310 le16_to_cpu(rate_scope->ofdm_rate_bitmap);
313 sizeof(rate_scope->ht_mcs_rate_bitmap) /
315 priv->bitmap_rates[2 + i] =
316 le16_to_cpu(rate_scope->
317 ht_mcs_rate_bitmap[i]);
319 if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) {
320 for (i = 0; i < ARRAY_SIZE(rate_scope->
321 vht_mcs_rate_bitmap);
323 priv->bitmap_rates[10 + i] =
324 le16_to_cpu(rate_scope->
325 vht_mcs_rate_bitmap[i]);
328 /* Add RATE_DROP tlv here */
331 tlv_buf += (sizeof(*head) + tlv_buf_len);
332 tlv_buf_left -= (sizeof(*head) + tlv_buf_len);
335 priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
337 if (priv->is_data_rate_auto)
340 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
341 HostCmd_ACT_GEN_GET, 0, NULL, false);
347 * This function handles the command response of get Tx power level.
349 * Handling includes saving the maximum and minimum Tx power levels
350 * in driver, as well as sending the values to user.
352 static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
354 int length, max_power = -1, min_power = -1;
355 struct mwifiex_types_power_group *pg_tlv_hdr;
356 struct mwifiex_power_group *pg;
361 pg_tlv_hdr = (struct mwifiex_types_power_group *)((u8 *)data_buf);
362 pg = (struct mwifiex_power_group *)
363 ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group));
364 length = le16_to_cpu(pg_tlv_hdr->length);
366 /* At least one structure required to update power */
367 if (length < sizeof(struct mwifiex_power_group))
370 max_power = pg->power_max;
371 min_power = pg->power_min;
372 length -= sizeof(struct mwifiex_power_group);
374 while (length >= sizeof(struct mwifiex_power_group)) {
376 if (max_power < pg->power_max)
377 max_power = pg->power_max;
379 if (min_power > pg->power_min)
380 min_power = pg->power_min;
382 length -= sizeof(struct mwifiex_power_group);
384 priv->min_tx_power_level = (u8) min_power;
385 priv->max_tx_power_level = (u8) max_power;
391 * This function handles the command response of set/get Tx power
394 * Handling includes changing the header fields into CPU format
395 * and saving the current Tx power level in driver.
397 static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
398 struct host_cmd_ds_command *resp)
400 struct mwifiex_adapter *adapter = priv->adapter;
401 struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg;
402 struct mwifiex_types_power_group *pg_tlv_hdr;
403 struct mwifiex_power_group *pg;
404 u16 action = le16_to_cpu(txp_cfg->action);
407 pg_tlv_hdr = (struct mwifiex_types_power_group *)
409 sizeof(struct host_cmd_ds_txpwr_cfg));
411 pg = (struct mwifiex_power_group *)
413 sizeof(struct mwifiex_types_power_group));
415 tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*txp_cfg);
417 le16_to_cpu(pg_tlv_hdr->length) + sizeof(*pg_tlv_hdr))
421 case HostCmd_ACT_GEN_GET:
422 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
423 mwifiex_get_power_level(priv, pg_tlv_hdr);
425 priv->tx_power_level = (u16) pg->power_min;
428 case HostCmd_ACT_GEN_SET:
429 if (!le32_to_cpu(txp_cfg->mode))
432 if (pg->power_max == pg->power_min)
433 priv->tx_power_level = (u16) pg->power_min;
436 mwifiex_dbg(adapter, ERROR,
437 "CMD_RESP: unknown cmd action %d\n",
441 mwifiex_dbg(adapter, INFO,
442 "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n",
443 priv->tx_power_level, priv->max_tx_power_level,
444 priv->min_tx_power_level);
450 * This function handles the command response of get RF Tx power.
452 static int mwifiex_ret_rf_tx_power(struct mwifiex_private *priv,
453 struct host_cmd_ds_command *resp)
455 struct host_cmd_ds_rf_tx_pwr *txp = &resp->params.txp;
456 u16 action = le16_to_cpu(txp->action);
458 priv->tx_power_level = le16_to_cpu(txp->cur_level);
460 if (action == HostCmd_ACT_GEN_GET) {
461 priv->max_tx_power_level = txp->max_power;
462 priv->min_tx_power_level = txp->min_power;
465 mwifiex_dbg(priv->adapter, INFO,
466 "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 rf antenna
476 static int mwifiex_ret_rf_antenna(struct mwifiex_private *priv,
477 struct host_cmd_ds_command *resp)
479 struct host_cmd_ds_rf_ant_mimo *ant_mimo = &resp->params.ant_mimo;
480 struct host_cmd_ds_rf_ant_siso *ant_siso = &resp->params.ant_siso;
481 struct mwifiex_adapter *adapter = priv->adapter;
483 if (adapter->hw_dev_mcs_support == HT_STREAM_2X2)
484 mwifiex_dbg(adapter, INFO,
485 "RF_ANT_RESP: Tx action = 0x%x, Tx Mode = 0x%04x\t"
486 "Rx action = 0x%x, Rx Mode = 0x%04x\n",
487 le16_to_cpu(ant_mimo->action_tx),
488 le16_to_cpu(ant_mimo->tx_ant_mode),
489 le16_to_cpu(ant_mimo->action_rx),
490 le16_to_cpu(ant_mimo->rx_ant_mode));
492 mwifiex_dbg(adapter, INFO,
493 "RF_ANT_RESP: action = 0x%x, Mode = 0x%04x\n",
494 le16_to_cpu(ant_siso->action),
495 le16_to_cpu(ant_siso->ant_mode));
501 * This function handles the command response of set/get MAC address.
503 * Handling includes saving the MAC address in driver.
505 static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv,
506 struct host_cmd_ds_command *resp)
508 struct host_cmd_ds_802_11_mac_address *cmd_mac_addr =
509 &resp->params.mac_addr;
511 memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN);
513 mwifiex_dbg(priv->adapter, INFO,
514 "info: set mac address: %pM\n", priv->curr_addr);
520 * This function handles the command response of set/get MAC multicast
523 static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv,
524 struct host_cmd_ds_command *resp)
530 * This function handles the command response of get Tx rate query.
532 * Handling includes changing the header fields into CPU format
533 * and saving the Tx rate and HT information parameters in driver.
535 * Both rate configuration and current data rate can be retrieved
538 static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv,
539 struct host_cmd_ds_command *resp)
541 priv->tx_rate = resp->params.tx_rate.tx_rate;
542 priv->tx_htinfo = resp->params.tx_rate.ht_info;
543 if (!priv->is_data_rate_auto)
545 mwifiex_index_to_data_rate(priv, priv->tx_rate,
552 * This function handles the command response of a deauthenticate
555 * If the deauthenticated MAC matches the current BSS MAC, the connection
558 static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
559 struct host_cmd_ds_command *resp)
561 struct mwifiex_adapter *adapter = priv->adapter;
563 adapter->dbg.num_cmd_deauth++;
564 if (!memcmp(resp->params.deauth.mac_addr,
565 &priv->curr_bss_params.bss_descriptor.mac_address,
566 sizeof(resp->params.deauth.mac_addr)))
567 mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
573 * This function handles the command response of ad-hoc stop.
575 * The function resets the connection state in driver.
577 static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
578 struct host_cmd_ds_command *resp)
580 mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
585 * This function handles the command response of set/get v1 key material.
587 * Handling includes updating the driver parameters to reflect the
590 static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,
591 struct host_cmd_ds_command *resp)
593 struct host_cmd_ds_802_11_key_material *key =
594 &resp->params.key_material;
597 len = le16_to_cpu(key->key_param_set.key_len);
598 if (len > sizeof(key->key_param_set.key))
601 if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
602 if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
603 mwifiex_dbg(priv->adapter, INFO,
604 "info: key: GTK is set\n");
605 priv->wpa_is_gtk_set = true;
606 priv->scan_block = false;
607 priv->port_open = true;
611 memset(priv->aes_key.key_param_set.key, 0,
612 sizeof(key->key_param_set.key));
613 priv->aes_key.key_param_set.key_len = cpu_to_le16(len);
614 memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, len);
620 * This function handles the command response of set/get v2 key material.
622 * Handling includes updating the driver parameters to reflect the
625 static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,
626 struct host_cmd_ds_command *resp)
628 struct host_cmd_ds_802_11_key_material_v2 *key_v2;
631 key_v2 = &resp->params.key_material_v2;
633 len = le16_to_cpu(key_v2->key_param_set.key_params.aes.key_len);
634 if (len > sizeof(key_v2->key_param_set.key_params.aes.key))
637 if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) {
638 if ((le16_to_cpu(key_v2->key_param_set.key_info) & KEY_MCAST)) {
639 mwifiex_dbg(priv->adapter, INFO, "info: key: GTK is set\n");
640 priv->wpa_is_gtk_set = true;
641 priv->scan_block = false;
642 priv->port_open = true;
646 if (key_v2->key_param_set.key_type != KEY_TYPE_ID_AES)
649 memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0,
650 sizeof(key_v2->key_param_set.key_params.aes.key));
651 priv->aes_key_v2.key_param_set.key_params.aes.key_len =
653 memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key,
654 key_v2->key_param_set.key_params.aes.key, len);
659 /* Wrapper function for processing response of key material command */
660 static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv,
661 struct host_cmd_ds_command *resp)
663 if (priv->adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2)
664 return mwifiex_ret_802_11_key_material_v2(priv, resp);
666 return mwifiex_ret_802_11_key_material_v1(priv, resp);
670 * This function handles the command response of get 11d domain information.
672 static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
673 struct host_cmd_ds_command *resp)
675 struct host_cmd_ds_802_11d_domain_info_rsp *domain_info =
676 &resp->params.domain_info_resp;
677 struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain;
678 u16 action = le16_to_cpu(domain_info->action);
681 no_of_triplet = (u8) ((le16_to_cpu(domain->header.len)
682 - IEEE80211_COUNTRY_STRING_LEN)
683 / sizeof(struct ieee80211_country_ie_triplet));
685 mwifiex_dbg(priv->adapter, INFO,
686 "info: 11D Domain Info Resp: no_of_triplet=%d\n",
689 if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) {
690 mwifiex_dbg(priv->adapter, FATAL,
691 "11D: invalid number of triplets %d returned\n",
697 case HostCmd_ACT_GEN_SET: /* Proc Set Action */
699 case HostCmd_ACT_GEN_GET:
702 mwifiex_dbg(priv->adapter, ERROR,
703 "11D: invalid action:%d\n", domain_info->action);
711 * This function handles the command response of get extended version.
713 * Handling includes forming the extended version string and sending it
716 static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
717 struct host_cmd_ds_command *resp,
718 struct host_cmd_ds_version_ext *version_ext)
720 struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext;
723 version_ext->version_str_sel = ver_ext->version_str_sel;
724 memcpy(version_ext->version_str, ver_ext->version_str,
726 memcpy(priv->version_str, ver_ext->version_str, 128);
732 * This function handles the command response of remain on channel.
735 mwifiex_ret_remain_on_chan(struct mwifiex_private *priv,
736 struct host_cmd_ds_command *resp,
737 struct host_cmd_ds_remain_on_chan *roc_cfg)
739 struct host_cmd_ds_remain_on_chan *resp_cfg = &resp->params.roc_cfg;
742 memcpy(roc_cfg, resp_cfg, sizeof(*roc_cfg));
748 * This function handles the command response of P2P mode cfg.
751 mwifiex_ret_p2p_mode_cfg(struct mwifiex_private *priv,
752 struct host_cmd_ds_command *resp,
755 struct host_cmd_ds_p2p_mode_cfg *mode_cfg = &resp->params.mode_cfg;
758 *((u16 *)data_buf) = le16_to_cpu(mode_cfg->mode);
763 /* This function handles the command response of mem_access command
766 mwifiex_ret_mem_access(struct mwifiex_private *priv,
767 struct host_cmd_ds_command *resp, void *pioctl_buf)
769 struct host_cmd_ds_mem_access *mem = (void *)&resp->params.mem;
771 priv->mem_rw.addr = le32_to_cpu(mem->addr);
772 priv->mem_rw.value = le32_to_cpu(mem->value);
777 * This function handles the command response of register access.
779 * The register value and offset are returned to the user. For EEPROM
780 * access, the byte count is also returned.
782 static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
785 struct mwifiex_ds_reg_rw *reg_rw;
786 struct mwifiex_ds_read_eeprom *eeprom;
788 struct host_cmd_ds_mac_reg_access *mac;
789 struct host_cmd_ds_bbp_reg_access *bbp;
790 struct host_cmd_ds_rf_reg_access *rf;
791 struct host_cmd_ds_pmic_reg_access *pmic;
792 struct host_cmd_ds_802_11_eeprom_access *eeprom;
801 case HostCmd_CMD_MAC_REG_ACCESS:
802 r.mac = &resp->params.mac_reg;
803 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset));
804 reg_rw->value = r.mac->value;
806 case HostCmd_CMD_BBP_REG_ACCESS:
807 r.bbp = &resp->params.bbp_reg;
808 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset));
809 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
812 case HostCmd_CMD_RF_REG_ACCESS:
813 r.rf = &resp->params.rf_reg;
814 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
815 reg_rw->value = cpu_to_le32((u32) r.bbp->value);
817 case HostCmd_CMD_PMIC_REG_ACCESS:
818 r.pmic = &resp->params.pmic_reg;
819 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset));
820 reg_rw->value = cpu_to_le32((u32) r.pmic->value);
822 case HostCmd_CMD_CAU_REG_ACCESS:
823 r.rf = &resp->params.rf_reg;
824 reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
825 reg_rw->value = cpu_to_le32((u32) r.rf->value);
827 case HostCmd_CMD_802_11_EEPROM_ACCESS:
828 r.eeprom = &resp->params.eeprom;
829 pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count);
830 if (le16_to_cpu(eeprom->byte_count) <
831 le16_to_cpu(r.eeprom->byte_count)) {
832 eeprom->byte_count = cpu_to_le16(0);
833 pr_debug("info: EEPROM read length is too big\n");
836 eeprom->offset = r.eeprom->offset;
837 eeprom->byte_count = r.eeprom->byte_count;
838 if (le16_to_cpu(eeprom->byte_count) > 0)
839 memcpy(&eeprom->value, &r.eeprom->value,
840 le16_to_cpu(r.eeprom->byte_count));
850 * This function handles the command response of get IBSS coalescing status.
852 * If the received BSSID is different than the current one, the current BSSID,
853 * beacon interval, ATIM window and ERP information are updated, along with
854 * changing the ad-hoc state accordingly.
856 static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
857 struct host_cmd_ds_command *resp)
859 struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp =
860 &(resp->params.ibss_coalescing);
862 if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET)
865 mwifiex_dbg(priv->adapter, INFO,
866 "info: new BSSID %pM\n", ibss_coal_resp->bssid);
868 /* If rsp has NULL BSSID, Just return..... No Action */
869 if (is_zero_ether_addr(ibss_coal_resp->bssid)) {
870 mwifiex_dbg(priv->adapter, FATAL, "new BSSID is NULL\n");
874 /* If BSSID is diff, modify current BSS parameters */
875 if (!ether_addr_equal(priv->curr_bss_params.bss_descriptor.mac_address, ibss_coal_resp->bssid)) {
877 memcpy(priv->curr_bss_params.bss_descriptor.mac_address,
878 ibss_coal_resp->bssid, ETH_ALEN);
880 /* Beacon Interval */
881 priv->curr_bss_params.bss_descriptor.beacon_period
882 = le16_to_cpu(ibss_coal_resp->beacon_interval);
884 /* ERP Information */
885 priv->curr_bss_params.bss_descriptor.erp_flags =
886 (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect);
888 priv->adhoc_state = ADHOC_COALESCED;
893 static int mwifiex_ret_tdls_oper(struct mwifiex_private *priv,
894 struct host_cmd_ds_command *resp)
896 struct host_cmd_ds_tdls_oper *cmd_tdls_oper = &resp->params.tdls_oper;
897 u16 reason = le16_to_cpu(cmd_tdls_oper->reason);
898 u16 action = le16_to_cpu(cmd_tdls_oper->tdls_action);
899 struct mwifiex_sta_node *node =
900 mwifiex_get_sta_entry(priv, cmd_tdls_oper->peer_mac);
903 case ACT_TDLS_DELETE:
905 if (!node || reason == TDLS_ERR_LINK_NONEXISTENT)
906 mwifiex_dbg(priv->adapter, MSG,
907 "TDLS link delete for %pM failed: reason %d\n",
908 cmd_tdls_oper->peer_mac, reason);
910 mwifiex_dbg(priv->adapter, ERROR,
911 "TDLS link delete for %pM failed: reason %d\n",
912 cmd_tdls_oper->peer_mac, reason);
914 mwifiex_dbg(priv->adapter, MSG,
915 "TDLS link delete for %pM successful\n",
916 cmd_tdls_oper->peer_mac);
919 case ACT_TDLS_CREATE:
921 mwifiex_dbg(priv->adapter, ERROR,
922 "TDLS link creation for %pM failed: reason %d",
923 cmd_tdls_oper->peer_mac, reason);
924 if (node && reason != TDLS_ERR_LINK_EXISTS)
925 node->tdls_status = TDLS_SETUP_FAILURE;
927 mwifiex_dbg(priv->adapter, MSG,
928 "TDLS link creation for %pM successful",
929 cmd_tdls_oper->peer_mac);
932 case ACT_TDLS_CONFIG:
934 mwifiex_dbg(priv->adapter, ERROR,
935 "TDLS link config for %pM failed, reason %d\n",
936 cmd_tdls_oper->peer_mac, reason);
938 node->tdls_status = TDLS_SETUP_FAILURE;
940 mwifiex_dbg(priv->adapter, MSG,
941 "TDLS link config for %pM successful\n",
942 cmd_tdls_oper->peer_mac);
946 mwifiex_dbg(priv->adapter, ERROR,
947 "Unknown TDLS command action response %d", action);
954 * This function handles the command response for subscribe event command.
956 static int mwifiex_ret_subsc_evt(struct mwifiex_private *priv,
957 struct host_cmd_ds_command *resp)
959 struct host_cmd_ds_802_11_subsc_evt *cmd_sub_event =
960 &resp->params.subsc_evt;
962 /* For every subscribe event command (Get/Set/Clear), FW reports the
963 * current set of subscribed events*/
964 mwifiex_dbg(priv->adapter, EVENT,
965 "Bitmap of currently subscribed events: %16x\n",
966 le16_to_cpu(cmd_sub_event->events));
971 static int mwifiex_ret_uap_sta_list(struct mwifiex_private *priv,
972 struct host_cmd_ds_command *resp)
974 struct host_cmd_ds_sta_list *sta_list =
975 &resp->params.sta_list;
976 struct mwifiex_ie_types_sta_info *sta_info = (void *)&sta_list->tlv;
978 struct mwifiex_sta_node *sta_node;
980 for (i = 0; i < sta_list->sta_count; i++) {
981 sta_node = mwifiex_get_sta_entry(priv, sta_info->mac);
982 if (unlikely(!sta_node))
985 sta_node->stats.rssi = sta_info->rssi;
992 /* This function handles the command response of set_cfg_data */
993 static int mwifiex_ret_cfg_data(struct mwifiex_private *priv,
994 struct host_cmd_ds_command *resp)
996 if (resp->result != HostCmd_RESULT_OK) {
997 mwifiex_dbg(priv->adapter, ERROR, "Cal data cmd resp failed\n");
1004 /** This Function handles the command response of sdio rx aggr */
1005 static int mwifiex_ret_sdio_rx_aggr_cfg(struct mwifiex_private *priv,
1006 struct host_cmd_ds_command *resp)
1008 struct mwifiex_adapter *adapter = priv->adapter;
1009 struct host_cmd_sdio_sp_rx_aggr_cfg *cfg =
1010 &resp->params.sdio_rx_aggr_cfg;
1012 adapter->sdio_rx_aggr_enable = cfg->enable;
1013 adapter->sdio_rx_block_size = le16_to_cpu(cfg->block_size);
1018 static int mwifiex_ret_robust_coex(struct mwifiex_private *priv,
1019 struct host_cmd_ds_command *resp,
1022 struct host_cmd_ds_robust_coex *coex = &resp->params.coex;
1023 struct mwifiex_ie_types_robust_coex *coex_tlv;
1024 u16 action = le16_to_cpu(coex->action);
1027 coex_tlv = (struct mwifiex_ie_types_robust_coex
1028 *)((u8 *)coex + sizeof(struct host_cmd_ds_robust_coex));
1029 if (action == HostCmd_ACT_GEN_GET) {
1030 mode = le32_to_cpu(coex_tlv->mode);
1031 if (mode == MWIFIEX_COEX_MODE_TIMESHARE)
1032 *is_timeshare = true;
1034 *is_timeshare = false;
1041 * This function handles the command responses.
1043 * This is a generic function, which calls command specific
1044 * response handlers based on the command ID.
1046 int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
1047 struct host_cmd_ds_command *resp)
1050 struct mwifiex_adapter *adapter = priv->adapter;
1051 void *data_buf = adapter->curr_cmd->data_buf;
1053 /* If the command is not successful, cleanup and return failure */
1054 if (resp->result != HostCmd_RESULT_OK) {
1055 mwifiex_process_cmdresp_error(priv, resp);
1058 /* Command successful, handle response */
1059 switch (cmdresp_no) {
1060 case HostCmd_CMD_GET_HW_SPEC:
1061 ret = mwifiex_ret_get_hw_spec(priv, resp);
1063 case HostCmd_CMD_CFG_DATA:
1064 ret = mwifiex_ret_cfg_data(priv, resp);
1066 case HostCmd_CMD_MAC_CONTROL:
1068 case HostCmd_CMD_802_11_MAC_ADDRESS:
1069 ret = mwifiex_ret_802_11_mac_address(priv, resp);
1071 case HostCmd_CMD_MAC_MULTICAST_ADR:
1072 ret = mwifiex_ret_mac_multicast_adr(priv, resp);
1074 case HostCmd_CMD_TX_RATE_CFG:
1075 ret = mwifiex_ret_tx_rate_cfg(priv, resp);
1077 case HostCmd_CMD_802_11_SCAN:
1078 ret = mwifiex_ret_802_11_scan(priv, resp);
1079 adapter->curr_cmd->wait_q_enabled = false;
1081 case HostCmd_CMD_802_11_SCAN_EXT:
1082 ret = mwifiex_ret_802_11_scan_ext(priv, resp);
1083 adapter->curr_cmd->wait_q_enabled = false;
1085 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
1086 ret = mwifiex_ret_802_11_scan(priv, resp);
1087 mwifiex_dbg(adapter, CMD,
1088 "info: CMD_RESP: BG_SCAN result is ready!\n");
1090 case HostCmd_CMD_TXPWR_CFG:
1091 ret = mwifiex_ret_tx_power_cfg(priv, resp);
1093 case HostCmd_CMD_RF_TX_PWR:
1094 ret = mwifiex_ret_rf_tx_power(priv, resp);
1096 case HostCmd_CMD_RF_ANTENNA:
1097 ret = mwifiex_ret_rf_antenna(priv, resp);
1099 case HostCmd_CMD_802_11_PS_MODE_ENH:
1100 ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf);
1102 case HostCmd_CMD_802_11_HS_CFG_ENH:
1103 ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
1105 case HostCmd_CMD_802_11_ASSOCIATE:
1106 ret = mwifiex_ret_802_11_associate(priv, resp);
1108 case HostCmd_CMD_802_11_DEAUTHENTICATE:
1109 ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
1111 case HostCmd_CMD_802_11_AD_HOC_START:
1112 case HostCmd_CMD_802_11_AD_HOC_JOIN:
1113 ret = mwifiex_ret_802_11_ad_hoc(priv, resp);
1115 case HostCmd_CMD_802_11_AD_HOC_STOP:
1116 ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
1118 case HostCmd_CMD_802_11_GET_LOG:
1119 ret = mwifiex_ret_get_log(priv, resp, data_buf);
1121 case HostCmd_CMD_RSSI_INFO:
1122 ret = mwifiex_ret_802_11_rssi_info(priv, resp);
1124 case HostCmd_CMD_802_11_SNMP_MIB:
1125 ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf);
1127 case HostCmd_CMD_802_11_TX_RATE_QUERY:
1128 ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
1130 case HostCmd_CMD_VERSION_EXT:
1131 ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
1133 case HostCmd_CMD_REMAIN_ON_CHAN:
1134 ret = mwifiex_ret_remain_on_chan(priv, resp, data_buf);
1136 case HostCmd_CMD_11AC_CFG:
1138 case HostCmd_CMD_P2P_MODE_CFG:
1139 ret = mwifiex_ret_p2p_mode_cfg(priv, resp, data_buf);
1141 case HostCmd_CMD_MGMT_FRAME_REG:
1142 case HostCmd_CMD_FUNC_INIT:
1143 case HostCmd_CMD_FUNC_SHUTDOWN:
1145 case HostCmd_CMD_802_11_KEY_MATERIAL:
1146 ret = mwifiex_ret_802_11_key_material(priv, resp);
1148 case HostCmd_CMD_802_11D_DOMAIN_INFO:
1149 ret = mwifiex_ret_802_11d_domain_info(priv, resp);
1151 case HostCmd_CMD_11N_ADDBA_REQ:
1152 ret = mwifiex_ret_11n_addba_req(priv, resp);
1154 case HostCmd_CMD_11N_DELBA:
1155 ret = mwifiex_ret_11n_delba(priv, resp);
1157 case HostCmd_CMD_11N_ADDBA_RSP:
1158 ret = mwifiex_ret_11n_addba_resp(priv, resp);
1160 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
1161 if (0xffff == (u16)le16_to_cpu(resp->params.tx_buf.buff_size)) {
1162 if (adapter->iface_type == MWIFIEX_USB &&
1163 adapter->usb_mc_setup) {
1164 if (adapter->if_ops.multi_port_resync)
1166 multi_port_resync(adapter);
1167 adapter->usb_mc_setup = false;
1168 adapter->tx_lock_flag = false;
1172 adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
1174 adapter->tx_buf_size = (adapter->tx_buf_size
1175 / MWIFIEX_SDIO_BLOCK_SIZE)
1176 * MWIFIEX_SDIO_BLOCK_SIZE;
1177 adapter->curr_tx_buf_size = adapter->tx_buf_size;
1178 mwifiex_dbg(adapter, CMD, "cmd: curr_tx_buf_size=%d\n",
1179 adapter->curr_tx_buf_size);
1181 if (adapter->if_ops.update_mp_end_port)
1182 adapter->if_ops.update_mp_end_port(adapter,
1183 le16_to_cpu(resp->params.tx_buf.mp_end_port));
1185 case HostCmd_CMD_AMSDU_AGGR_CTRL:
1187 case HostCmd_CMD_WMM_GET_STATUS:
1188 ret = mwifiex_ret_wmm_get_status(priv, resp);
1190 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
1191 ret = mwifiex_ret_ibss_coalescing_status(priv, resp);
1193 case HostCmd_CMD_MEM_ACCESS:
1194 ret = mwifiex_ret_mem_access(priv, resp, data_buf);
1196 case HostCmd_CMD_MAC_REG_ACCESS:
1197 case HostCmd_CMD_BBP_REG_ACCESS:
1198 case HostCmd_CMD_RF_REG_ACCESS:
1199 case HostCmd_CMD_PMIC_REG_ACCESS:
1200 case HostCmd_CMD_CAU_REG_ACCESS:
1201 case HostCmd_CMD_802_11_EEPROM_ACCESS:
1202 ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf);
1204 case HostCmd_CMD_SET_BSS_MODE:
1206 case HostCmd_CMD_11N_CFG:
1208 case HostCmd_CMD_PCIE_DESC_DETAILS:
1210 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
1211 ret = mwifiex_ret_subsc_evt(priv, resp);
1213 case HostCmd_CMD_UAP_SYS_CONFIG:
1215 case HOST_CMD_APCMD_STA_LIST:
1216 ret = mwifiex_ret_uap_sta_list(priv, resp);
1218 case HostCmd_CMD_UAP_BSS_START:
1219 adapter->tx_lock_flag = false;
1220 adapter->pps_uapsd_mode = false;
1221 adapter->delay_null_pkt = false;
1222 priv->bss_started = 1;
1224 case HostCmd_CMD_UAP_BSS_STOP:
1225 priv->bss_started = 0;
1227 case HostCmd_CMD_UAP_STA_DEAUTH:
1229 case HOST_CMD_APCMD_SYS_RESET:
1231 case HostCmd_CMD_MEF_CFG:
1233 case HostCmd_CMD_COALESCE_CFG:
1235 case HostCmd_CMD_TDLS_OPER:
1236 ret = mwifiex_ret_tdls_oper(priv, resp);
1237 case HostCmd_CMD_MC_POLICY:
1239 case HostCmd_CMD_CHAN_REPORT_REQUEST:
1241 case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG:
1242 ret = mwifiex_ret_sdio_rx_aggr_cfg(priv, resp);
1244 case HostCmd_CMD_TDLS_CONFIG:
1246 case HostCmd_CMD_ROBUST_COEX:
1247 ret = mwifiex_ret_robust_coex(priv, resp, data_buf);
1250 mwifiex_dbg(adapter, ERROR,
1251 "CMD_RESP: unknown cmd response %#x\n",