2 * Marvell Wireless LAN device driver: station command 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.
29 * This function prepares command to set/get RSSI information.
31 * Preparation includes -
32 * - Setting command ID, action and proper size
33 * - Setting data/beacon average factors
34 * - Resetting SNR/NF/RSSI values in private structure
35 * - Ensuring correct endian-ness
38 mwifiex_cmd_802_11_rssi_info(struct mwifiex_private *priv,
39 struct host_cmd_ds_command *cmd, u16 cmd_action)
41 cmd->command = cpu_to_le16(HostCmd_CMD_RSSI_INFO);
42 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rssi_info) +
44 cmd->params.rssi_info.action = cpu_to_le16(cmd_action);
45 cmd->params.rssi_info.ndata = cpu_to_le16(priv->data_avg_factor);
46 cmd->params.rssi_info.nbcn = cpu_to_le16(priv->bcn_avg_factor);
48 /* Reset SNR/NF/RSSI values in private structure */
49 priv->data_rssi_last = 0;
50 priv->data_nf_last = 0;
51 priv->data_rssi_avg = 0;
52 priv->data_nf_avg = 0;
53 priv->bcn_rssi_last = 0;
54 priv->bcn_nf_last = 0;
55 priv->bcn_rssi_avg = 0;
62 * This function prepares command to set MAC control.
64 * Preparation includes -
65 * - Setting command ID, action and proper size
66 * - Ensuring correct endian-ness
68 static int mwifiex_cmd_mac_control(struct mwifiex_private *priv,
69 struct host_cmd_ds_command *cmd,
70 u16 cmd_action, u16 *action)
72 struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl;
74 if (cmd_action != HostCmd_ACT_GEN_SET) {
75 dev_err(priv->adapter->dev,
76 "mac_control: only support set cmd\n");
80 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_CONTROL);
82 cpu_to_le16(sizeof(struct host_cmd_ds_mac_control) + S_DS_GEN);
83 mac_ctrl->action = cpu_to_le16(*action);
89 * This function prepares command to set/get SNMP MIB.
91 * Preparation includes -
92 * - Setting command ID, action and proper size
93 * - Setting SNMP MIB OID number and value
95 * - Ensuring correct endian-ness
97 * The following SNMP MIB OIDs are supported -
98 * - FRAG_THRESH_I : Fragmentation threshold
99 * - RTS_THRESH_I : RTS threshold
100 * - SHORT_RETRY_LIM_I : Short retry limit
101 * - DOT11D_I : 11d support
103 static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv,
104 struct host_cmd_ds_command *cmd,
105 u16 cmd_action, u32 cmd_oid,
108 struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib;
110 dev_dbg(priv->adapter->dev, "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid);
111 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB);
112 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib)
115 snmp_mib->oid = cpu_to_le16((u16)cmd_oid);
116 if (cmd_action == HostCmd_ACT_GEN_GET) {
117 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET);
118 snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE);
119 le16_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE);
120 } else if (cmd_action == HostCmd_ACT_GEN_SET) {
121 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
122 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
123 *((__le16 *) (snmp_mib->value)) = cpu_to_le16(*ul_temp);
124 le16_add_cpu(&cmd->size, sizeof(u16));
127 dev_dbg(priv->adapter->dev,
128 "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x,"
130 cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size),
131 le16_to_cpu(*(__le16 *) snmp_mib->value));
136 * This function prepares command to get log.
138 * Preparation includes -
139 * - Setting command ID and proper size
140 * - Ensuring correct endian-ness
143 mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd)
145 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_GET_LOG);
146 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_get_log) +
152 * This function prepares command to set/get Tx data rate configuration.
154 * Preparation includes -
155 * - Setting command ID, action and proper size
156 * - Setting configuration index, rate scope and rate drop pattern
157 * parameters (as required)
158 * - Ensuring correct endian-ness
160 static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv,
161 struct host_cmd_ds_command *cmd,
162 u16 cmd_action, u16 *pbitmap_rates)
164 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &cmd->params.tx_rate_cfg;
165 struct mwifiex_rate_scope *rate_scope;
166 struct mwifiex_rate_drop_pattern *rate_drop;
169 cmd->command = cpu_to_le16(HostCmd_CMD_TX_RATE_CFG);
171 rate_cfg->action = cpu_to_le16(cmd_action);
172 rate_cfg->cfg_index = 0;
174 rate_scope = (struct mwifiex_rate_scope *) ((u8 *) rate_cfg +
175 sizeof(struct host_cmd_ds_tx_rate_cfg));
176 rate_scope->type = cpu_to_le16(TLV_TYPE_RATE_SCOPE);
177 rate_scope->length = cpu_to_le16
178 (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header));
179 if (pbitmap_rates != NULL) {
180 rate_scope->hr_dsss_rate_bitmap = cpu_to_le16(pbitmap_rates[0]);
181 rate_scope->ofdm_rate_bitmap = cpu_to_le16(pbitmap_rates[1]);
183 i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16);
185 rate_scope->ht_mcs_rate_bitmap[i] =
186 cpu_to_le16(pbitmap_rates[2 + i]);
188 rate_scope->hr_dsss_rate_bitmap =
189 cpu_to_le16(priv->bitmap_rates[0]);
190 rate_scope->ofdm_rate_bitmap =
191 cpu_to_le16(priv->bitmap_rates[1]);
193 i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16);
195 rate_scope->ht_mcs_rate_bitmap[i] =
196 cpu_to_le16(priv->bitmap_rates[2 + i]);
199 rate_drop = (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope +
200 sizeof(struct mwifiex_rate_scope));
201 rate_drop->type = cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL);
202 rate_drop->length = cpu_to_le16(sizeof(rate_drop->rate_drop_mode));
203 rate_drop->rate_drop_mode = 0;
206 cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_tx_rate_cfg) +
207 sizeof(struct mwifiex_rate_scope) +
208 sizeof(struct mwifiex_rate_drop_pattern));
214 * This function prepares command to set/get Tx power configuration.
216 * Preparation includes -
217 * - Setting command ID, action and proper size
218 * - Setting Tx power mode, power group TLV
220 * - Ensuring correct endian-ness
222 static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd,
224 struct host_cmd_ds_txpwr_cfg *txp)
226 struct mwifiex_types_power_group *pg_tlv;
227 struct host_cmd_ds_txpwr_cfg *cmd_txp_cfg = &cmd->params.txp_cfg;
229 cmd->command = cpu_to_le16(HostCmd_CMD_TXPWR_CFG);
231 cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg));
232 switch (cmd_action) {
233 case HostCmd_ACT_GEN_SET:
235 pg_tlv = (struct mwifiex_types_power_group
236 *) ((unsigned long) txp +
237 sizeof(struct host_cmd_ds_txpwr_cfg));
238 memmove(cmd_txp_cfg, txp,
239 sizeof(struct host_cmd_ds_txpwr_cfg) +
240 sizeof(struct mwifiex_types_power_group) +
243 pg_tlv = (struct mwifiex_types_power_group *) ((u8 *)
245 sizeof(struct host_cmd_ds_txpwr_cfg));
246 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) +
247 sizeof(struct mwifiex_types_power_group) +
250 memmove(cmd_txp_cfg, txp, sizeof(*txp));
252 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
254 case HostCmd_ACT_GEN_GET:
255 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
263 * This function prepares command to get RF Tx power.
265 static int mwifiex_cmd_rf_tx_power(struct mwifiex_private *priv,
266 struct host_cmd_ds_command *cmd,
267 u16 cmd_action, void *data_buf)
269 struct host_cmd_ds_rf_tx_pwr *txp = &cmd->params.txp;
271 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_tx_pwr)
273 cmd->command = cpu_to_le16(HostCmd_CMD_RF_TX_PWR);
274 txp->action = cpu_to_le16(cmd_action);
280 * This function prepares command to set rf antenna.
282 static int mwifiex_cmd_rf_antenna(struct mwifiex_private *priv,
283 struct host_cmd_ds_command *cmd,
285 struct mwifiex_ds_ant_cfg *ant_cfg)
287 struct host_cmd_ds_rf_ant_mimo *ant_mimo = &cmd->params.ant_mimo;
288 struct host_cmd_ds_rf_ant_siso *ant_siso = &cmd->params.ant_siso;
290 cmd->command = cpu_to_le16(HostCmd_CMD_RF_ANTENNA);
292 if (cmd_action != HostCmd_ACT_GEN_SET)
295 if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) {
296 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_mimo) +
298 ant_mimo->action_tx = cpu_to_le16(HostCmd_ACT_SET_TX);
299 ant_mimo->tx_ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant);
300 ant_mimo->action_rx = cpu_to_le16(HostCmd_ACT_SET_RX);
301 ant_mimo->rx_ant_mode = cpu_to_le16((u16)ant_cfg->rx_ant);
303 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_siso) +
305 ant_siso->action = cpu_to_le16(HostCmd_ACT_SET_BOTH);
306 ant_siso->ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant);
313 * This function prepares command to set Host Sleep configuration.
315 * Preparation includes -
316 * - Setting command ID and proper size
317 * - Setting Host Sleep action, conditions, ARP filters
319 * - Ensuring correct endian-ness
322 mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv,
323 struct host_cmd_ds_command *cmd,
325 struct mwifiex_hs_config_param *hscfg_param)
327 struct mwifiex_adapter *adapter = priv->adapter;
328 struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg;
329 u16 hs_activate = false;
332 /* New Activate command */
334 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH);
337 (hscfg_param->conditions != cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) &&
338 ((adapter->arp_filter_size > 0) &&
339 (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) {
340 dev_dbg(adapter->dev,
341 "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n",
342 adapter->arp_filter_size);
343 memcpy(((u8 *) hs_cfg) +
344 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh),
345 adapter->arp_filter, adapter->arp_filter_size);
346 cmd->size = cpu_to_le16
347 (adapter->arp_filter_size +
348 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh)
351 cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct
352 host_cmd_ds_802_11_hs_cfg_enh));
355 hs_cfg->action = cpu_to_le16(HS_ACTIVATE);
356 hs_cfg->params.hs_activate.resp_ctrl = RESP_NEEDED;
358 hs_cfg->action = cpu_to_le16(HS_CONFIGURE);
359 hs_cfg->params.hs_config.conditions = hscfg_param->conditions;
360 hs_cfg->params.hs_config.gpio = hscfg_param->gpio;
361 hs_cfg->params.hs_config.gap = hscfg_param->gap;
362 dev_dbg(adapter->dev,
363 "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n",
364 hs_cfg->params.hs_config.conditions,
365 hs_cfg->params.hs_config.gpio,
366 hs_cfg->params.hs_config.gap);
373 * This function prepares command to set/get MAC address.
375 * Preparation includes -
376 * - Setting command ID, action and proper size
377 * - Setting MAC address (for SET only)
378 * - Ensuring correct endian-ness
380 static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv,
381 struct host_cmd_ds_command *cmd,
384 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS);
385 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address) +
389 cmd->params.mac_addr.action = cpu_to_le16(cmd_action);
391 if (cmd_action == HostCmd_ACT_GEN_SET)
392 memcpy(cmd->params.mac_addr.mac_addr, priv->curr_addr,
398 * This function prepares command to set MAC multicast address.
400 * Preparation includes -
401 * - Setting command ID, action and proper size
402 * - Setting MAC multicast address
403 * - Ensuring correct endian-ness
406 mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd,
408 struct mwifiex_multicast_list *mcast_list)
410 struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr;
412 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) +
414 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR);
416 mcast_addr->action = cpu_to_le16(cmd_action);
417 mcast_addr->num_of_adrs =
418 cpu_to_le16((u16) mcast_list->num_multicast_addr);
419 memcpy(mcast_addr->mac_list, mcast_list->mac_list,
420 mcast_list->num_multicast_addr * ETH_ALEN);
426 * This function prepares command to deauthenticate.
428 * Preparation includes -
429 * - Setting command ID and proper size
430 * - Setting AP MAC address and reason code
431 * - Ensuring correct endian-ness
433 static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv,
434 struct host_cmd_ds_command *cmd,
437 struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth;
439 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE);
440 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate)
443 /* Set AP MAC address */
444 memcpy(deauth->mac_addr, mac, ETH_ALEN);
446 dev_dbg(priv->adapter->dev, "cmd: Deauth: %pM\n", deauth->mac_addr);
448 deauth->reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING);
454 * This function prepares command to stop Ad-Hoc network.
456 * Preparation includes -
457 * - Setting command ID and proper size
458 * - Ensuring correct endian-ness
460 static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command *cmd)
462 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP);
463 cmd->size = cpu_to_le16(S_DS_GEN);
468 * This function sets WEP key(s) to key parameter TLV(s).
470 * Multi-key parameter TLVs are supported, so we can send multiple
471 * WEP keys in a single buffer.
474 mwifiex_set_keyparamset_wep(struct mwifiex_private *priv,
475 struct mwifiex_ie_type_key_param_set *key_param_set,
478 int cur_key_param_len;
481 /* Multi-key_param_set TLV is supported */
482 for (i = 0; i < NUM_WEP_KEYS; i++) {
483 if ((priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP40) ||
484 (priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP104)) {
485 key_param_set->type =
486 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
487 /* Key_param_set WEP fixed length */
488 #define KEYPARAMSET_WEP_FIXED_LEN 8
489 key_param_set->length = cpu_to_le16((u16)
492 KEYPARAMSET_WEP_FIXED_LEN));
493 key_param_set->key_type_id =
494 cpu_to_le16(KEY_TYPE_ID_WEP);
495 key_param_set->key_info =
496 cpu_to_le16(KEY_ENABLED | KEY_UNICAST |
498 key_param_set->key_len =
499 cpu_to_le16(priv->wep_key[i].key_length);
500 /* Set WEP key index */
501 key_param_set->key[0] = i;
502 /* Set default Tx key flag */
505 wep_key_curr_index & HostCmd_WEP_KEY_INDEX_MASK))
506 key_param_set->key[1] = 1;
508 key_param_set->key[1] = 0;
509 memmove(&key_param_set->key[2],
510 priv->wep_key[i].key_material,
511 priv->wep_key[i].key_length);
513 cur_key_param_len = priv->wep_key[i].key_length +
514 KEYPARAMSET_WEP_FIXED_LEN +
515 sizeof(struct mwifiex_ie_types_header);
516 *key_param_len += (u16) cur_key_param_len;
518 (struct mwifiex_ie_type_key_param_set *)
519 ((u8 *)key_param_set +
521 } else if (!priv->wep_key[i].key_length) {
524 dev_err(priv->adapter->dev,
525 "key%d Length = %d is incorrect\n",
526 (i + 1), priv->wep_key[i].key_length);
535 * This function prepares command to set/get/reset network key(s).
537 * Preparation includes -
538 * - Setting command ID, action and proper size
539 * - Setting WEP keys, WAPI keys or WPA keys along with required
540 * encryption (TKIP, AES) (as required)
541 * - Ensuring correct endian-ness
544 mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv,
545 struct host_cmd_ds_command *cmd,
546 u16 cmd_action, u32 cmd_oid,
547 struct mwifiex_ds_encrypt_key *enc_key)
549 struct host_cmd_ds_802_11_key_material *key_material =
550 &cmd->params.key_material;
551 struct host_cmd_tlv_mac_addr *tlv_mac;
552 u16 key_param_len = 0, cmd_size;
555 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL);
556 key_material->action = cpu_to_le16(cmd_action);
558 if (cmd_action == HostCmd_ACT_GEN_GET) {
560 cpu_to_le16(sizeof(key_material->action) + S_DS_GEN);
565 memset(&key_material->key_param_set, 0,
567 sizeof(struct mwifiex_ie_type_key_param_set)));
568 ret = mwifiex_set_keyparamset_wep(priv,
569 &key_material->key_param_set,
571 cmd->size = cpu_to_le16(key_param_len +
572 sizeof(key_material->action) + S_DS_GEN);
575 memset(&key_material->key_param_set, 0,
576 sizeof(struct mwifiex_ie_type_key_param_set));
577 if (enc_key->is_wapi_key) {
578 dev_dbg(priv->adapter->dev, "info: Set WAPI Key\n");
579 key_material->key_param_set.key_type_id =
580 cpu_to_le16(KEY_TYPE_ID_WAPI);
581 if (cmd_oid == KEY_INFO_ENABLED)
582 key_material->key_param_set.key_info =
583 cpu_to_le16(KEY_ENABLED);
585 key_material->key_param_set.key_info =
586 cpu_to_le16(!KEY_ENABLED);
588 key_material->key_param_set.key[0] = enc_key->key_index;
589 if (!priv->sec_info.wapi_key_on)
590 key_material->key_param_set.key[1] = 1;
592 /* set 0 when re-key */
593 key_material->key_param_set.key[1] = 0;
595 if (!is_broadcast_ether_addr(enc_key->mac_addr)) {
596 /* WAPI pairwise key: unicast */
597 key_material->key_param_set.key_info |=
598 cpu_to_le16(KEY_UNICAST);
599 } else { /* WAPI group key: multicast */
600 key_material->key_param_set.key_info |=
601 cpu_to_le16(KEY_MCAST);
602 priv->sec_info.wapi_key_on = true;
605 key_material->key_param_set.type =
606 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
607 key_material->key_param_set.key_len =
608 cpu_to_le16(WAPI_KEY_LEN);
609 memcpy(&key_material->key_param_set.key[2],
610 enc_key->key_material, enc_key->key_len);
611 memcpy(&key_material->key_param_set.key[2 + enc_key->key_len],
612 enc_key->pn, PN_LEN);
613 key_material->key_param_set.length =
614 cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN);
616 key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) +
617 sizeof(struct mwifiex_ie_types_header);
618 cmd->size = cpu_to_le16(sizeof(key_material->action)
619 + S_DS_GEN + key_param_len);
622 if (enc_key->key_len == WLAN_KEY_LEN_CCMP) {
623 if (enc_key->is_igtk_key) {
624 dev_dbg(priv->adapter->dev, "cmd: CMAC_AES\n");
625 key_material->key_param_set.key_type_id =
626 cpu_to_le16(KEY_TYPE_ID_AES_CMAC);
627 if (cmd_oid == KEY_INFO_ENABLED)
628 key_material->key_param_set.key_info =
629 cpu_to_le16(KEY_ENABLED);
631 key_material->key_param_set.key_info =
632 cpu_to_le16(!KEY_ENABLED);
634 key_material->key_param_set.key_info |=
635 cpu_to_le16(KEY_IGTK);
637 dev_dbg(priv->adapter->dev, "cmd: WPA_AES\n");
638 key_material->key_param_set.key_type_id =
639 cpu_to_le16(KEY_TYPE_ID_AES);
640 if (cmd_oid == KEY_INFO_ENABLED)
641 key_material->key_param_set.key_info =
642 cpu_to_le16(KEY_ENABLED);
644 key_material->key_param_set.key_info =
645 cpu_to_le16(!KEY_ENABLED);
647 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
648 /* AES pairwise key: unicast */
649 key_material->key_param_set.key_info |=
650 cpu_to_le16(KEY_UNICAST);
651 else /* AES group key: multicast */
652 key_material->key_param_set.key_info |=
653 cpu_to_le16(KEY_MCAST);
655 } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) {
656 dev_dbg(priv->adapter->dev, "cmd: WPA_TKIP\n");
657 key_material->key_param_set.key_type_id =
658 cpu_to_le16(KEY_TYPE_ID_TKIP);
659 key_material->key_param_set.key_info =
660 cpu_to_le16(KEY_ENABLED);
662 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
663 /* TKIP pairwise key: unicast */
664 key_material->key_param_set.key_info |=
665 cpu_to_le16(KEY_UNICAST);
666 else /* TKIP group key: multicast */
667 key_material->key_param_set.key_info |=
668 cpu_to_le16(KEY_MCAST);
671 if (key_material->key_param_set.key_type_id) {
672 key_material->key_param_set.type =
673 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
674 key_material->key_param_set.key_len =
675 cpu_to_le16((u16) enc_key->key_len);
676 memcpy(key_material->key_param_set.key, enc_key->key_material,
678 key_material->key_param_set.length =
679 cpu_to_le16((u16) enc_key->key_len +
680 KEYPARAMSET_FIXED_LEN);
682 key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN)
683 + sizeof(struct mwifiex_ie_types_header);
685 if (le16_to_cpu(key_material->key_param_set.key_type_id) ==
686 KEY_TYPE_ID_AES_CMAC) {
687 struct mwifiex_cmac_param *param =
688 (void *)key_material->key_param_set.key;
690 memcpy(param->ipn, enc_key->pn, IGTK_PN_LEN);
691 memcpy(param->key, enc_key->key_material,
692 WLAN_KEY_LEN_AES_CMAC);
694 key_param_len = sizeof(struct mwifiex_cmac_param);
695 key_material->key_param_set.key_len =
696 cpu_to_le16(key_param_len);
697 key_param_len += KEYPARAMSET_FIXED_LEN;
698 key_material->key_param_set.length =
699 cpu_to_le16(key_param_len);
700 key_param_len += sizeof(struct mwifiex_ie_types_header);
703 cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN
706 if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) {
707 tlv_mac = (void *)((u8 *)&key_material->key_param_set +
709 tlv_mac->tlv.type = cpu_to_le16(TLV_TYPE_STA_MAC_ADDR);
710 tlv_mac->tlv.len = cpu_to_le16(ETH_ALEN);
711 memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN);
712 cmd_size = key_param_len + S_DS_GEN +
713 sizeof(key_material->action) +
714 sizeof(struct host_cmd_tlv_mac_addr);
716 cmd_size = key_param_len + S_DS_GEN +
717 sizeof(key_material->action);
719 cmd->size = cpu_to_le16(cmd_size);
726 * This function prepares command to set/get 11d domain information.
728 * Preparation includes -
729 * - Setting command ID, action and proper size
730 * - Setting domain information fields (for SET only)
731 * - Ensuring correct endian-ness
733 static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv,
734 struct host_cmd_ds_command *cmd,
737 struct mwifiex_adapter *adapter = priv->adapter;
738 struct host_cmd_ds_802_11d_domain_info *domain_info =
739 &cmd->params.domain_info;
740 struct mwifiex_ietypes_domain_param_set *domain =
741 &domain_info->domain;
742 u8 no_of_triplet = adapter->domain_reg.no_of_triplet;
744 dev_dbg(adapter->dev, "info: 11D: no_of_triplet=0x%x\n", no_of_triplet);
746 cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO);
747 domain_info->action = cpu_to_le16(cmd_action);
748 if (cmd_action == HostCmd_ACT_GEN_GET) {
749 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
753 /* Set domain info fields */
754 domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY);
755 memcpy(domain->country_code, adapter->domain_reg.country_code,
756 sizeof(domain->country_code));
759 cpu_to_le16((no_of_triplet *
760 sizeof(struct ieee80211_country_ie_triplet))
761 + sizeof(domain->country_code));
764 memcpy(domain->triplet, adapter->domain_reg.triplet,
765 no_of_triplet * sizeof(struct
766 ieee80211_country_ie_triplet));
768 cmd->size = cpu_to_le16(sizeof(domain_info->action) +
769 le16_to_cpu(domain->header.len) +
770 sizeof(struct mwifiex_ie_types_header)
773 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
780 * This function prepares command to set/get IBSS coalescing status.
782 * Preparation includes -
783 * - Setting command ID, action and proper size
784 * - Setting status to enable or disable (for SET only)
785 * - Ensuring correct endian-ness
787 static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd,
788 u16 cmd_action, u16 *enable)
790 struct host_cmd_ds_802_11_ibss_status *ibss_coal =
791 &(cmd->params.ibss_coalescing);
793 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS);
794 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) +
797 ibss_coal->action = cpu_to_le16(cmd_action);
799 switch (cmd_action) {
800 case HostCmd_ACT_GEN_SET:
802 ibss_coal->enable = cpu_to_le16(*enable);
804 ibss_coal->enable = 0;
807 /* In other case.. Nothing to do */
808 case HostCmd_ACT_GEN_GET:
817 * This function prepares command to set/get register value.
819 * Preparation includes -
820 * - Setting command ID, action and proper size
821 * - Setting register offset (for both GET and SET) and
822 * register value (for SET only)
823 * - Ensuring correct endian-ness
825 * The following type of registers can be accessed with this function -
833 static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd,
834 u16 cmd_action, void *data_buf)
836 struct mwifiex_ds_reg_rw *reg_rw = data_buf;
838 switch (le16_to_cpu(cmd->command)) {
839 case HostCmd_CMD_MAC_REG_ACCESS:
841 struct host_cmd_ds_mac_reg_access *mac_reg;
843 cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN);
844 mac_reg = &cmd->params.mac_reg;
845 mac_reg->action = cpu_to_le16(cmd_action);
847 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
848 mac_reg->value = reg_rw->value;
851 case HostCmd_CMD_BBP_REG_ACCESS:
853 struct host_cmd_ds_bbp_reg_access *bbp_reg;
855 cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN);
856 bbp_reg = &cmd->params.bbp_reg;
857 bbp_reg->action = cpu_to_le16(cmd_action);
859 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
860 bbp_reg->value = (u8) le32_to_cpu(reg_rw->value);
863 case HostCmd_CMD_RF_REG_ACCESS:
865 struct host_cmd_ds_rf_reg_access *rf_reg;
867 cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN);
868 rf_reg = &cmd->params.rf_reg;
869 rf_reg->action = cpu_to_le16(cmd_action);
870 rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
871 rf_reg->value = (u8) le32_to_cpu(reg_rw->value);
874 case HostCmd_CMD_PMIC_REG_ACCESS:
876 struct host_cmd_ds_pmic_reg_access *pmic_reg;
878 cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN);
879 pmic_reg = &cmd->params.pmic_reg;
880 pmic_reg->action = cpu_to_le16(cmd_action);
882 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
883 pmic_reg->value = (u8) le32_to_cpu(reg_rw->value);
886 case HostCmd_CMD_CAU_REG_ACCESS:
888 struct host_cmd_ds_rf_reg_access *cau_reg;
890 cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN);
891 cau_reg = &cmd->params.rf_reg;
892 cau_reg->action = cpu_to_le16(cmd_action);
894 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
895 cau_reg->value = (u8) le32_to_cpu(reg_rw->value);
898 case HostCmd_CMD_802_11_EEPROM_ACCESS:
900 struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf;
901 struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom =
904 cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN);
905 cmd_eeprom->action = cpu_to_le16(cmd_action);
906 cmd_eeprom->offset = rd_eeprom->offset;
907 cmd_eeprom->byte_count = rd_eeprom->byte_count;
908 cmd_eeprom->value = 0;
919 * This function prepares command to set PCI-Express
920 * host buffer configuration
922 * Preparation includes -
923 * - Setting command ID, action and proper size
924 * - Setting host buffer configuration
925 * - Ensuring correct endian-ness
928 mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv,
929 struct host_cmd_ds_command *cmd, u16 action)
931 struct host_cmd_ds_pcie_details *host_spec =
932 &cmd->params.pcie_host_spec;
933 struct pcie_service_card *card = priv->adapter->card;
935 cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS);
936 cmd->size = cpu_to_le16(sizeof(struct
937 host_cmd_ds_pcie_details) + S_DS_GEN);
940 memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details));
942 if (action != HostCmd_ACT_GEN_SET)
945 /* Send the ring base addresses and count to firmware */
946 host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase);
947 host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32);
948 host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD;
949 host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase);
950 host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32);
951 host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD;
952 host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase);
953 host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32);
954 host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD;
955 if (card->sleep_cookie_vbase) {
956 host_spec->sleep_cookie_addr_lo =
957 (u32)(card->sleep_cookie_pbase);
958 host_spec->sleep_cookie_addr_hi =
959 (u32)(((u64)(card->sleep_cookie_pbase)) >> 32);
960 dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n",
961 host_spec->sleep_cookie_addr_lo);
968 * This function prepares command for event subscription, configuration
969 * and query. Events can be subscribed or unsubscribed. Current subscribed
970 * events can be queried. Also, current subscribed events are reported in
974 mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv,
975 struct host_cmd_ds_command *cmd,
976 struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg)
978 struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt;
979 struct mwifiex_ie_types_rssi_threshold *rssi_tlv;
983 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT);
984 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) +
987 subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action);
988 dev_dbg(priv->adapter->dev, "cmd: action: %d\n", subsc_evt_cfg->action);
990 /*For query requests, no configuration TLV structures are to be added.*/
991 if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET)
994 subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events);
996 event_bitmap = subsc_evt_cfg->events;
997 dev_dbg(priv->adapter->dev, "cmd: event bitmap : %16x\n",
1000 if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) ||
1001 (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) &&
1002 (event_bitmap == 0)) {
1003 dev_dbg(priv->adapter->dev, "Error: No event specified "
1004 "for bitwise action type\n");
1009 * Append TLV structures for each of the specified events for
1010 * subscribing or re-configuring. This is not required for
1011 * bitwise unsubscribing request.
1013 if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR)
1016 pos = ((u8 *)subsc_evt) +
1017 sizeof(struct host_cmd_ds_802_11_subsc_evt);
1019 if (event_bitmap & BITMASK_BCN_RSSI_LOW) {
1020 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
1022 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW);
1023 rssi_tlv->header.len =
1024 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
1025 sizeof(struct mwifiex_ie_types_header));
1026 rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value;
1027 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq;
1029 dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, "
1030 "RSSI:-%d dBm, Freq:%d\n",
1031 subsc_evt_cfg->bcn_l_rssi_cfg.abs_value,
1032 subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq);
1034 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1035 le16_add_cpu(&cmd->size,
1036 sizeof(struct mwifiex_ie_types_rssi_threshold));
1039 if (event_bitmap & BITMASK_BCN_RSSI_HIGH) {
1040 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
1042 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH);
1043 rssi_tlv->header.len =
1044 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
1045 sizeof(struct mwifiex_ie_types_header));
1046 rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value;
1047 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq;
1049 dev_dbg(priv->adapter->dev, "Cfg Beacon High Rssi event, "
1050 "RSSI:-%d dBm, Freq:%d\n",
1051 subsc_evt_cfg->bcn_h_rssi_cfg.abs_value,
1052 subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq);
1054 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1055 le16_add_cpu(&cmd->size,
1056 sizeof(struct mwifiex_ie_types_rssi_threshold));
1063 * This function prepares the commands before sending them to the firmware.
1065 * This is a generic function which calls specific command preparation
1066 * routines based upon the command number.
1068 int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1069 u16 cmd_action, u32 cmd_oid,
1070 void *data_buf, void *cmd_buf)
1072 struct host_cmd_ds_command *cmd_ptr = cmd_buf;
1075 /* Prepare command */
1077 case HostCmd_CMD_GET_HW_SPEC:
1078 ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr);
1080 case HostCmd_CMD_MAC_CONTROL:
1081 ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action,
1084 case HostCmd_CMD_802_11_MAC_ADDRESS:
1085 ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr,
1088 case HostCmd_CMD_MAC_MULTICAST_ADR:
1089 ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action,
1092 case HostCmd_CMD_TX_RATE_CFG:
1093 ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action,
1096 case HostCmd_CMD_TXPWR_CFG:
1097 ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action,
1100 case HostCmd_CMD_RF_TX_PWR:
1101 ret = mwifiex_cmd_rf_tx_power(priv, cmd_ptr, cmd_action,
1104 case HostCmd_CMD_RF_ANTENNA:
1105 ret = mwifiex_cmd_rf_antenna(priv, cmd_ptr, cmd_action,
1108 case HostCmd_CMD_802_11_PS_MODE_ENH:
1109 ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action,
1110 (uint16_t)cmd_oid, data_buf);
1112 case HostCmd_CMD_802_11_HS_CFG_ENH:
1113 ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action,
1114 (struct mwifiex_hs_config_param *) data_buf);
1116 case HostCmd_CMD_802_11_SCAN:
1117 ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf);
1119 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
1120 ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr);
1122 case HostCmd_CMD_802_11_ASSOCIATE:
1123 ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf);
1125 case HostCmd_CMD_802_11_DEAUTHENTICATE:
1126 ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr,
1129 case HostCmd_CMD_802_11_AD_HOC_START:
1130 ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr,
1133 case HostCmd_CMD_802_11_GET_LOG:
1134 ret = mwifiex_cmd_802_11_get_log(cmd_ptr);
1136 case HostCmd_CMD_802_11_AD_HOC_JOIN:
1137 ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr,
1140 case HostCmd_CMD_802_11_AD_HOC_STOP:
1141 ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr);
1143 case HostCmd_CMD_RSSI_INFO:
1144 ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action);
1146 case HostCmd_CMD_802_11_SNMP_MIB:
1147 ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action,
1150 case HostCmd_CMD_802_11_TX_RATE_QUERY:
1152 cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY);
1154 cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) +
1159 case HostCmd_CMD_VERSION_EXT:
1160 cmd_ptr->command = cpu_to_le16(cmd_no);
1161 cmd_ptr->params.verext.version_str_sel =
1162 (u8) (*((u32 *) data_buf));
1163 memcpy(&cmd_ptr->params, data_buf,
1164 sizeof(struct host_cmd_ds_version_ext));
1166 cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) +
1170 case HostCmd_CMD_MGMT_FRAME_REG:
1171 cmd_ptr->command = cpu_to_le16(cmd_no);
1172 cmd_ptr->params.reg_mask.action = cpu_to_le16(cmd_action);
1173 cmd_ptr->params.reg_mask.mask = cpu_to_le32(*(u32 *)data_buf);
1175 cpu_to_le16(sizeof(struct host_cmd_ds_mgmt_frame_reg) +
1179 case HostCmd_CMD_REMAIN_ON_CHAN:
1180 cmd_ptr->command = cpu_to_le16(cmd_no);
1181 memcpy(&cmd_ptr->params, data_buf,
1182 sizeof(struct host_cmd_ds_remain_on_chan));
1184 cpu_to_le16(sizeof(struct host_cmd_ds_remain_on_chan) +
1187 case HostCmd_CMD_P2P_MODE_CFG:
1188 cmd_ptr->command = cpu_to_le16(cmd_no);
1189 cmd_ptr->params.mode_cfg.action = cpu_to_le16(cmd_action);
1190 cmd_ptr->params.mode_cfg.mode = cpu_to_le16(*(u16 *)data_buf);
1192 cpu_to_le16(sizeof(struct host_cmd_ds_p2p_mode_cfg) +
1195 case HostCmd_CMD_FUNC_INIT:
1196 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET)
1197 priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY;
1198 cmd_ptr->command = cpu_to_le16(cmd_no);
1199 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1201 case HostCmd_CMD_FUNC_SHUTDOWN:
1202 priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET;
1203 cmd_ptr->command = cpu_to_le16(cmd_no);
1204 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1206 case HostCmd_CMD_11N_ADDBA_REQ:
1207 ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf);
1209 case HostCmd_CMD_11N_DELBA:
1210 ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf);
1212 case HostCmd_CMD_11N_ADDBA_RSP:
1213 ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf);
1215 case HostCmd_CMD_802_11_KEY_MATERIAL:
1216 ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr,
1217 cmd_action, cmd_oid,
1220 case HostCmd_CMD_802_11D_DOMAIN_INFO:
1221 ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr,
1224 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
1225 ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action,
1228 case HostCmd_CMD_AMSDU_AGGR_CTRL:
1229 ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action,
1232 case HostCmd_CMD_11N_CFG:
1233 ret = mwifiex_cmd_11n_cfg(priv, cmd_ptr, cmd_action, data_buf);
1235 case HostCmd_CMD_WMM_GET_STATUS:
1236 dev_dbg(priv->adapter->dev,
1237 "cmd: WMM: WMM_GET_STATUS cmd sent\n");
1238 cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS);
1240 cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) +
1244 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
1245 ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action,
1248 case HostCmd_CMD_MAC_REG_ACCESS:
1249 case HostCmd_CMD_BBP_REG_ACCESS:
1250 case HostCmd_CMD_RF_REG_ACCESS:
1251 case HostCmd_CMD_PMIC_REG_ACCESS:
1252 case HostCmd_CMD_CAU_REG_ACCESS:
1253 case HostCmd_CMD_802_11_EEPROM_ACCESS:
1254 ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf);
1256 case HostCmd_CMD_SET_BSS_MODE:
1257 cmd_ptr->command = cpu_to_le16(cmd_no);
1258 if (priv->bss_mode == NL80211_IFTYPE_ADHOC)
1259 cmd_ptr->params.bss_mode.con_type =
1260 CONNECTION_TYPE_ADHOC;
1261 else if (priv->bss_mode == NL80211_IFTYPE_STATION)
1262 cmd_ptr->params.bss_mode.con_type =
1263 CONNECTION_TYPE_INFRA;
1264 else if (priv->bss_mode == NL80211_IFTYPE_AP)
1265 cmd_ptr->params.bss_mode.con_type = CONNECTION_TYPE_AP;
1266 cmd_ptr->size = cpu_to_le16(sizeof(struct
1267 host_cmd_ds_set_bss_mode) + S_DS_GEN);
1270 case HostCmd_CMD_PCIE_DESC_DETAILS:
1271 ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action);
1273 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
1274 ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf);
1277 dev_err(priv->adapter->dev,
1278 "PREP_CMD: unknown cmd- %#x\n", cmd_no);
1286 * This function issues commands to initialize firmware.
1288 * This is called after firmware download to bring the card to
1291 * The following commands are issued sequentially -
1292 * - Set PCI-Express host buffer configuration (PCIE only)
1293 * - Function init (for first interface only)
1294 * - Read MAC address (for first interface only)
1295 * - Reconfigure Tx buffer size (for first interface only)
1296 * - Enable auto deep sleep (for first interface only)
1299 * - Set IBSS coalescing status
1300 * - Set AMSDU aggregation control
1302 * - Set MAC control (this must be the last command to initialize firmware)
1304 int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1308 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
1309 struct mwifiex_ds_auto_ds auto_ds;
1310 enum state_11d_t state_11d;
1311 struct mwifiex_ds_11n_tx_cfg tx_cfg;
1314 if (priv->adapter->iface_type == MWIFIEX_PCIE) {
1315 ret = mwifiex_send_cmd_sync(priv,
1316 HostCmd_CMD_PCIE_DESC_DETAILS,
1317 HostCmd_ACT_GEN_SET, 0, NULL);
1322 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_FUNC_INIT,
1323 HostCmd_ACT_GEN_SET, 0, NULL);
1326 /* Read MAC address from HW */
1327 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_GET_HW_SPEC,
1328 HostCmd_ACT_GEN_GET, 0, NULL);
1332 /* Reconfigure tx buf size */
1333 ret = mwifiex_send_cmd_sync(priv,
1334 HostCmd_CMD_RECONFIGURE_TX_BUFF,
1335 HostCmd_ACT_GEN_SET, 0,
1336 &priv->adapter->tx_buf_size);
1340 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1341 /* Enable IEEE PS by default */
1342 priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1343 ret = mwifiex_send_cmd_sync(
1344 priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1345 EN_AUTO_PS, BITMAP_STA_PS, NULL);
1352 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
1353 HostCmd_ACT_GEN_GET, 0, NULL);
1356 priv->data_rate = 0;
1359 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_RF_TX_PWR,
1360 HostCmd_ACT_GEN_GET, 0, NULL);
1364 if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
1365 /* set ibss coalescing_status */
1366 ret = mwifiex_send_cmd_sync(
1367 priv, HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
1368 HostCmd_ACT_GEN_SET, 0, &enable);
1373 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
1374 amsdu_aggr_ctrl.enable = true;
1375 /* Send request to firmware */
1376 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_AMSDU_AGGR_CTRL,
1377 HostCmd_ACT_GEN_SET, 0,
1381 /* MAC Control must be the last command in init_fw */
1382 /* set MAC Control */
1383 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1384 HostCmd_ACT_GEN_SET, 0,
1385 &priv->curr_pkt_filter);
1389 if (first_sta && priv->adapter->iface_type != MWIFIEX_USB &&
1390 priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1391 /* Enable auto deep sleep */
1392 auto_ds.auto_ds = DEEP_SLEEP_ON;
1393 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
1394 ret = mwifiex_send_cmd_sync(priv,
1395 HostCmd_CMD_802_11_PS_MODE_ENH,
1396 EN_AUTO_PS, BITMAP_AUTO_DS,
1402 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1403 /* Send cmd to FW to enable/disable 11D function */
1404 state_11d = ENABLE_11D;
1405 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
1406 HostCmd_ACT_GEN_SET, DOT11D_I,
1409 dev_err(priv->adapter->dev,
1410 "11D: failed to enable 11D\n");
1413 /* set last_init_cmd before sending the command */
1414 priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG;
1416 /* Send cmd to FW to configure 11n specific configuration
1417 * (Short GI, Channel BW, Green field support etc.) for transmit
1419 tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG;
1420 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_11N_CFG,
1421 HostCmd_ACT_GEN_SET, 0, &tx_cfg);