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;
554 const u8 bc_mac[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
556 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL);
557 key_material->action = cpu_to_le16(cmd_action);
559 if (cmd_action == HostCmd_ACT_GEN_GET) {
561 cpu_to_le16(sizeof(key_material->action) + S_DS_GEN);
566 memset(&key_material->key_param_set, 0,
568 sizeof(struct mwifiex_ie_type_key_param_set)));
569 ret = mwifiex_set_keyparamset_wep(priv,
570 &key_material->key_param_set,
572 cmd->size = cpu_to_le16(key_param_len +
573 sizeof(key_material->action) + S_DS_GEN);
576 memset(&key_material->key_param_set, 0,
577 sizeof(struct mwifiex_ie_type_key_param_set));
578 if (enc_key->is_wapi_key) {
579 dev_dbg(priv->adapter->dev, "info: Set WAPI Key\n");
580 key_material->key_param_set.key_type_id =
581 cpu_to_le16(KEY_TYPE_ID_WAPI);
582 if (cmd_oid == KEY_INFO_ENABLED)
583 key_material->key_param_set.key_info =
584 cpu_to_le16(KEY_ENABLED);
586 key_material->key_param_set.key_info =
587 cpu_to_le16(!KEY_ENABLED);
589 key_material->key_param_set.key[0] = enc_key->key_index;
590 if (!priv->sec_info.wapi_key_on)
591 key_material->key_param_set.key[1] = 1;
593 /* set 0 when re-key */
594 key_material->key_param_set.key[1] = 0;
596 if (0 != memcmp(enc_key->mac_addr, bc_mac, sizeof(bc_mac))) {
597 /* WAPI pairwise key: unicast */
598 key_material->key_param_set.key_info |=
599 cpu_to_le16(KEY_UNICAST);
600 } else { /* WAPI group key: multicast */
601 key_material->key_param_set.key_info |=
602 cpu_to_le16(KEY_MCAST);
603 priv->sec_info.wapi_key_on = true;
606 key_material->key_param_set.type =
607 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
608 key_material->key_param_set.key_len =
609 cpu_to_le16(WAPI_KEY_LEN);
610 memcpy(&key_material->key_param_set.key[2],
611 enc_key->key_material, enc_key->key_len);
612 memcpy(&key_material->key_param_set.key[2 + enc_key->key_len],
613 enc_key->wapi_rxpn, WAPI_RXPN_LEN);
614 key_material->key_param_set.length =
615 cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN);
617 key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) +
618 sizeof(struct mwifiex_ie_types_header);
619 cmd->size = cpu_to_le16(sizeof(key_material->action)
620 + S_DS_GEN + key_param_len);
623 if (enc_key->key_len == WLAN_KEY_LEN_CCMP) {
624 dev_dbg(priv->adapter->dev, "cmd: WPA_AES\n");
625 key_material->key_param_set.key_type_id =
626 cpu_to_le16(KEY_TYPE_ID_AES);
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 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
635 /* AES pairwise key: unicast */
636 key_material->key_param_set.key_info |=
637 cpu_to_le16(KEY_UNICAST);
638 else /* AES group key: multicast */
639 key_material->key_param_set.key_info |=
640 cpu_to_le16(KEY_MCAST);
641 } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) {
642 dev_dbg(priv->adapter->dev, "cmd: WPA_TKIP\n");
643 key_material->key_param_set.key_type_id =
644 cpu_to_le16(KEY_TYPE_ID_TKIP);
645 key_material->key_param_set.key_info =
646 cpu_to_le16(KEY_ENABLED);
648 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
649 /* TKIP pairwise key: unicast */
650 key_material->key_param_set.key_info |=
651 cpu_to_le16(KEY_UNICAST);
652 else /* TKIP group key: multicast */
653 key_material->key_param_set.key_info |=
654 cpu_to_le16(KEY_MCAST);
657 if (key_material->key_param_set.key_type_id) {
658 key_material->key_param_set.type =
659 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
660 key_material->key_param_set.key_len =
661 cpu_to_le16((u16) enc_key->key_len);
662 memcpy(key_material->key_param_set.key, enc_key->key_material,
664 key_material->key_param_set.length =
665 cpu_to_le16((u16) enc_key->key_len +
666 KEYPARAMSET_FIXED_LEN);
668 key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN)
669 + sizeof(struct mwifiex_ie_types_header);
671 cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN
674 if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) {
675 tlv_mac = (void *)((u8 *)&key_material->key_param_set +
677 tlv_mac->tlv.type = cpu_to_le16(TLV_TYPE_STA_MAC_ADDR);
678 tlv_mac->tlv.len = cpu_to_le16(ETH_ALEN);
679 memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN);
680 cmd_size = key_param_len + S_DS_GEN +
681 sizeof(key_material->action) +
682 sizeof(struct host_cmd_tlv_mac_addr);
684 cmd_size = key_param_len + S_DS_GEN +
685 sizeof(key_material->action);
687 cmd->size = cpu_to_le16(cmd_size);
694 * This function prepares command to set/get 11d domain information.
696 * Preparation includes -
697 * - Setting command ID, action and proper size
698 * - Setting domain information fields (for SET only)
699 * - Ensuring correct endian-ness
701 static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv,
702 struct host_cmd_ds_command *cmd,
705 struct mwifiex_adapter *adapter = priv->adapter;
706 struct host_cmd_ds_802_11d_domain_info *domain_info =
707 &cmd->params.domain_info;
708 struct mwifiex_ietypes_domain_param_set *domain =
709 &domain_info->domain;
710 u8 no_of_triplet = adapter->domain_reg.no_of_triplet;
712 dev_dbg(adapter->dev, "info: 11D: no_of_triplet=0x%x\n", no_of_triplet);
714 cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO);
715 domain_info->action = cpu_to_le16(cmd_action);
716 if (cmd_action == HostCmd_ACT_GEN_GET) {
717 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
721 /* Set domain info fields */
722 domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY);
723 memcpy(domain->country_code, adapter->domain_reg.country_code,
724 sizeof(domain->country_code));
727 cpu_to_le16((no_of_triplet *
728 sizeof(struct ieee80211_country_ie_triplet))
729 + sizeof(domain->country_code));
732 memcpy(domain->triplet, adapter->domain_reg.triplet,
733 no_of_triplet * sizeof(struct
734 ieee80211_country_ie_triplet));
736 cmd->size = cpu_to_le16(sizeof(domain_info->action) +
737 le16_to_cpu(domain->header.len) +
738 sizeof(struct mwifiex_ie_types_header)
741 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
748 * This function prepares command to set/get IBSS coalescing status.
750 * Preparation includes -
751 * - Setting command ID, action and proper size
752 * - Setting status to enable or disable (for SET only)
753 * - Ensuring correct endian-ness
755 static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd,
756 u16 cmd_action, u16 *enable)
758 struct host_cmd_ds_802_11_ibss_status *ibss_coal =
759 &(cmd->params.ibss_coalescing);
761 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS);
762 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) +
765 ibss_coal->action = cpu_to_le16(cmd_action);
767 switch (cmd_action) {
768 case HostCmd_ACT_GEN_SET:
770 ibss_coal->enable = cpu_to_le16(*enable);
772 ibss_coal->enable = 0;
775 /* In other case.. Nothing to do */
776 case HostCmd_ACT_GEN_GET:
785 * This function prepares command to set/get register value.
787 * Preparation includes -
788 * - Setting command ID, action and proper size
789 * - Setting register offset (for both GET and SET) and
790 * register value (for SET only)
791 * - Ensuring correct endian-ness
793 * The following type of registers can be accessed with this function -
801 static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd,
802 u16 cmd_action, void *data_buf)
804 struct mwifiex_ds_reg_rw *reg_rw = data_buf;
806 switch (le16_to_cpu(cmd->command)) {
807 case HostCmd_CMD_MAC_REG_ACCESS:
809 struct host_cmd_ds_mac_reg_access *mac_reg;
811 cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN);
812 mac_reg = &cmd->params.mac_reg;
813 mac_reg->action = cpu_to_le16(cmd_action);
815 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
816 mac_reg->value = reg_rw->value;
819 case HostCmd_CMD_BBP_REG_ACCESS:
821 struct host_cmd_ds_bbp_reg_access *bbp_reg;
823 cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN);
824 bbp_reg = &cmd->params.bbp_reg;
825 bbp_reg->action = cpu_to_le16(cmd_action);
827 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
828 bbp_reg->value = (u8) le32_to_cpu(reg_rw->value);
831 case HostCmd_CMD_RF_REG_ACCESS:
833 struct host_cmd_ds_rf_reg_access *rf_reg;
835 cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN);
836 rf_reg = &cmd->params.rf_reg;
837 rf_reg->action = cpu_to_le16(cmd_action);
838 rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
839 rf_reg->value = (u8) le32_to_cpu(reg_rw->value);
842 case HostCmd_CMD_PMIC_REG_ACCESS:
844 struct host_cmd_ds_pmic_reg_access *pmic_reg;
846 cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN);
847 pmic_reg = &cmd->params.pmic_reg;
848 pmic_reg->action = cpu_to_le16(cmd_action);
850 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
851 pmic_reg->value = (u8) le32_to_cpu(reg_rw->value);
854 case HostCmd_CMD_CAU_REG_ACCESS:
856 struct host_cmd_ds_rf_reg_access *cau_reg;
858 cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN);
859 cau_reg = &cmd->params.rf_reg;
860 cau_reg->action = cpu_to_le16(cmd_action);
862 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
863 cau_reg->value = (u8) le32_to_cpu(reg_rw->value);
866 case HostCmd_CMD_802_11_EEPROM_ACCESS:
868 struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf;
869 struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom =
872 cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN);
873 cmd_eeprom->action = cpu_to_le16(cmd_action);
874 cmd_eeprom->offset = rd_eeprom->offset;
875 cmd_eeprom->byte_count = rd_eeprom->byte_count;
876 cmd_eeprom->value = 0;
887 * This function prepares command to set PCI-Express
888 * host buffer configuration
890 * Preparation includes -
891 * - Setting command ID, action and proper size
892 * - Setting host buffer configuration
893 * - Ensuring correct endian-ness
896 mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv,
897 struct host_cmd_ds_command *cmd, u16 action)
899 struct host_cmd_ds_pcie_details *host_spec =
900 &cmd->params.pcie_host_spec;
901 struct pcie_service_card *card = priv->adapter->card;
904 cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS);
905 cmd->size = cpu_to_le16(sizeof(struct
906 host_cmd_ds_pcie_details) + S_DS_GEN);
909 memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details));
911 if (action != HostCmd_ACT_GEN_SET)
914 /* Send the ring base addresses and count to firmware */
915 host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase);
916 host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32);
917 host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD;
918 host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase);
919 host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32);
920 host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD;
921 host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase);
922 host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32);
923 host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD;
924 if (card->sleep_cookie) {
925 buf_pa = MWIFIEX_SKB_PACB(card->sleep_cookie);
926 host_spec->sleep_cookie_addr_lo = (u32) *buf_pa;
927 host_spec->sleep_cookie_addr_hi = (u32) (((u64)*buf_pa) >> 32);
928 dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n",
929 host_spec->sleep_cookie_addr_lo);
936 * This function prepares command for event subscription, configuration
937 * and query. Events can be subscribed or unsubscribed. Current subscribed
938 * events can be queried. Also, current subscribed events are reported in
942 mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv,
943 struct host_cmd_ds_command *cmd,
944 struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg)
946 struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt;
947 struct mwifiex_ie_types_rssi_threshold *rssi_tlv;
951 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT);
952 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) +
955 subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action);
956 dev_dbg(priv->adapter->dev, "cmd: action: %d\n", subsc_evt_cfg->action);
958 /*For query requests, no configuration TLV structures are to be added.*/
959 if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET)
962 subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events);
964 event_bitmap = subsc_evt_cfg->events;
965 dev_dbg(priv->adapter->dev, "cmd: event bitmap : %16x\n",
968 if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) ||
969 (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) &&
970 (event_bitmap == 0)) {
971 dev_dbg(priv->adapter->dev, "Error: No event specified "
972 "for bitwise action type\n");
977 * Append TLV structures for each of the specified events for
978 * subscribing or re-configuring. This is not required for
979 * bitwise unsubscribing request.
981 if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR)
984 pos = ((u8 *)subsc_evt) +
985 sizeof(struct host_cmd_ds_802_11_subsc_evt);
987 if (event_bitmap & BITMASK_BCN_RSSI_LOW) {
988 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
990 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW);
991 rssi_tlv->header.len =
992 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
993 sizeof(struct mwifiex_ie_types_header));
994 rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value;
995 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq;
997 dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, "
998 "RSSI:-%d dBm, Freq:%d\n",
999 subsc_evt_cfg->bcn_l_rssi_cfg.abs_value,
1000 subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq);
1002 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1003 le16_add_cpu(&cmd->size,
1004 sizeof(struct mwifiex_ie_types_rssi_threshold));
1007 if (event_bitmap & BITMASK_BCN_RSSI_HIGH) {
1008 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
1010 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH);
1011 rssi_tlv->header.len =
1012 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
1013 sizeof(struct mwifiex_ie_types_header));
1014 rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value;
1015 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq;
1017 dev_dbg(priv->adapter->dev, "Cfg Beacon High Rssi event, "
1018 "RSSI:-%d dBm, Freq:%d\n",
1019 subsc_evt_cfg->bcn_h_rssi_cfg.abs_value,
1020 subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq);
1022 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1023 le16_add_cpu(&cmd->size,
1024 sizeof(struct mwifiex_ie_types_rssi_threshold));
1031 * This function prepares the commands before sending them to the firmware.
1033 * This is a generic function which calls specific command preparation
1034 * routines based upon the command number.
1036 int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1037 u16 cmd_action, u32 cmd_oid,
1038 void *data_buf, void *cmd_buf)
1040 struct host_cmd_ds_command *cmd_ptr = cmd_buf;
1043 /* Prepare command */
1045 case HostCmd_CMD_GET_HW_SPEC:
1046 ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr);
1048 case HostCmd_CMD_MAC_CONTROL:
1049 ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action,
1052 case HostCmd_CMD_802_11_MAC_ADDRESS:
1053 ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr,
1056 case HostCmd_CMD_MAC_MULTICAST_ADR:
1057 ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action,
1060 case HostCmd_CMD_TX_RATE_CFG:
1061 ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action,
1064 case HostCmd_CMD_TXPWR_CFG:
1065 ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action,
1068 case HostCmd_CMD_RF_TX_PWR:
1069 ret = mwifiex_cmd_rf_tx_power(priv, cmd_ptr, cmd_action,
1072 case HostCmd_CMD_RF_ANTENNA:
1073 ret = mwifiex_cmd_rf_antenna(priv, cmd_ptr, cmd_action,
1076 case HostCmd_CMD_802_11_PS_MODE_ENH:
1077 ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action,
1078 (uint16_t)cmd_oid, data_buf);
1080 case HostCmd_CMD_802_11_HS_CFG_ENH:
1081 ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action,
1082 (struct mwifiex_hs_config_param *) data_buf);
1084 case HostCmd_CMD_802_11_SCAN:
1085 ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf);
1087 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
1088 ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr);
1090 case HostCmd_CMD_802_11_ASSOCIATE:
1091 ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf);
1093 case HostCmd_CMD_802_11_DEAUTHENTICATE:
1094 ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr,
1097 case HostCmd_CMD_802_11_AD_HOC_START:
1098 ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr,
1101 case HostCmd_CMD_802_11_GET_LOG:
1102 ret = mwifiex_cmd_802_11_get_log(cmd_ptr);
1104 case HostCmd_CMD_802_11_AD_HOC_JOIN:
1105 ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr,
1108 case HostCmd_CMD_802_11_AD_HOC_STOP:
1109 ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr);
1111 case HostCmd_CMD_RSSI_INFO:
1112 ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action);
1114 case HostCmd_CMD_802_11_SNMP_MIB:
1115 ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action,
1118 case HostCmd_CMD_802_11_TX_RATE_QUERY:
1120 cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY);
1122 cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) +
1127 case HostCmd_CMD_VERSION_EXT:
1128 cmd_ptr->command = cpu_to_le16(cmd_no);
1129 cmd_ptr->params.verext.version_str_sel =
1130 (u8) (*((u32 *) data_buf));
1131 memcpy(&cmd_ptr->params, data_buf,
1132 sizeof(struct host_cmd_ds_version_ext));
1134 cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) +
1138 case HostCmd_CMD_FUNC_INIT:
1139 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET)
1140 priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY;
1141 cmd_ptr->command = cpu_to_le16(cmd_no);
1142 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1144 case HostCmd_CMD_FUNC_SHUTDOWN:
1145 priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET;
1146 cmd_ptr->command = cpu_to_le16(cmd_no);
1147 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1149 case HostCmd_CMD_11N_ADDBA_REQ:
1150 ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf);
1152 case HostCmd_CMD_11N_DELBA:
1153 ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf);
1155 case HostCmd_CMD_11N_ADDBA_RSP:
1156 ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf);
1158 case HostCmd_CMD_802_11_KEY_MATERIAL:
1159 ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr,
1160 cmd_action, cmd_oid,
1163 case HostCmd_CMD_802_11D_DOMAIN_INFO:
1164 ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr,
1167 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
1168 ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action,
1171 case HostCmd_CMD_AMSDU_AGGR_CTRL:
1172 ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action,
1175 case HostCmd_CMD_11N_CFG:
1176 ret = mwifiex_cmd_11n_cfg(cmd_ptr, cmd_action, data_buf);
1178 case HostCmd_CMD_WMM_GET_STATUS:
1179 dev_dbg(priv->adapter->dev,
1180 "cmd: WMM: WMM_GET_STATUS cmd sent\n");
1181 cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS);
1183 cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) +
1187 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
1188 ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action,
1191 case HostCmd_CMD_MAC_REG_ACCESS:
1192 case HostCmd_CMD_BBP_REG_ACCESS:
1193 case HostCmd_CMD_RF_REG_ACCESS:
1194 case HostCmd_CMD_PMIC_REG_ACCESS:
1195 case HostCmd_CMD_CAU_REG_ACCESS:
1196 case HostCmd_CMD_802_11_EEPROM_ACCESS:
1197 ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf);
1199 case HostCmd_CMD_SET_BSS_MODE:
1200 cmd_ptr->command = cpu_to_le16(cmd_no);
1201 if (priv->bss_mode == NL80211_IFTYPE_ADHOC)
1202 cmd_ptr->params.bss_mode.con_type =
1203 CONNECTION_TYPE_ADHOC;
1204 else if (priv->bss_mode == NL80211_IFTYPE_STATION)
1205 cmd_ptr->params.bss_mode.con_type =
1206 CONNECTION_TYPE_INFRA;
1207 cmd_ptr->size = cpu_to_le16(sizeof(struct
1208 host_cmd_ds_set_bss_mode) + S_DS_GEN);
1211 case HostCmd_CMD_PCIE_DESC_DETAILS:
1212 ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action);
1214 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
1215 ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf);
1218 dev_err(priv->adapter->dev,
1219 "PREP_CMD: unknown cmd- %#x\n", cmd_no);
1227 * This function issues commands to initialize firmware.
1229 * This is called after firmware download to bring the card to
1232 * The following commands are issued sequentially -
1233 * - Set PCI-Express host buffer configuration (PCIE only)
1234 * - Function init (for first interface only)
1235 * - Read MAC address (for first interface only)
1236 * - Reconfigure Tx buffer size (for first interface only)
1237 * - Enable auto deep sleep (for first interface only)
1240 * - Set IBSS coalescing status
1241 * - Set AMSDU aggregation control
1243 * - Set MAC control (this must be the last command to initialize firmware)
1245 int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1249 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
1250 struct mwifiex_ds_auto_ds auto_ds;
1251 enum state_11d_t state_11d;
1252 struct mwifiex_ds_11n_tx_cfg tx_cfg;
1255 if (priv->adapter->iface_type == MWIFIEX_PCIE) {
1256 ret = mwifiex_send_cmd_async(priv,
1257 HostCmd_CMD_PCIE_DESC_DETAILS,
1258 HostCmd_ACT_GEN_SET, 0, NULL);
1263 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_FUNC_INIT,
1264 HostCmd_ACT_GEN_SET, 0, NULL);
1267 /* Read MAC address from HW */
1268 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_GET_HW_SPEC,
1269 HostCmd_ACT_GEN_GET, 0, NULL);
1273 /* Reconfigure tx buf size */
1274 ret = mwifiex_send_cmd_async(priv,
1275 HostCmd_CMD_RECONFIGURE_TX_BUFF,
1276 HostCmd_ACT_GEN_SET, 0,
1277 &priv->adapter->tx_buf_size);
1281 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1282 /* Enable IEEE PS by default */
1283 priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1284 ret = mwifiex_send_cmd_async(
1285 priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1286 EN_AUTO_PS, BITMAP_STA_PS, NULL);
1293 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TX_RATE_CFG,
1294 HostCmd_ACT_GEN_GET, 0, NULL);
1297 priv->data_rate = 0;
1300 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_RF_TX_PWR,
1301 HostCmd_ACT_GEN_GET, 0, NULL);
1305 if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
1306 /* set ibss coalescing_status */
1307 ret = mwifiex_send_cmd_async(
1308 priv, HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
1309 HostCmd_ACT_GEN_SET, 0, &enable);
1314 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
1315 amsdu_aggr_ctrl.enable = true;
1316 /* Send request to firmware */
1317 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_AMSDU_AGGR_CTRL,
1318 HostCmd_ACT_GEN_SET, 0,
1322 /* MAC Control must be the last command in init_fw */
1323 /* set MAC Control */
1324 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
1325 HostCmd_ACT_GEN_SET, 0,
1326 &priv->curr_pkt_filter);
1330 if (first_sta && priv->adapter->iface_type != MWIFIEX_USB &&
1331 priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1332 /* Enable auto deep sleep */
1333 auto_ds.auto_ds = DEEP_SLEEP_ON;
1334 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
1335 ret = mwifiex_send_cmd_async(priv,
1336 HostCmd_CMD_802_11_PS_MODE_ENH,
1337 EN_AUTO_PS, BITMAP_AUTO_DS,
1343 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1344 /* Send cmd to FW to enable/disable 11D function */
1345 state_11d = ENABLE_11D;
1346 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SNMP_MIB,
1347 HostCmd_ACT_GEN_SET, DOT11D_I,
1350 dev_err(priv->adapter->dev,
1351 "11D: failed to enable 11D\n");
1354 /* Send cmd to FW to configure 11n specific configuration
1355 * (Short GI, Channel BW, Green field support etc.) for transmit
1357 tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG;
1358 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_CFG,
1359 HostCmd_ACT_GEN_SET, 0, &tx_cfg);
1361 /* set last_init_cmd */
1362 priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG;