2 * Marvell Wireless LAN device driver: station command 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.
29 static bool disable_auto_ds
;
30 module_param(disable_auto_ds
, bool, 0);
31 MODULE_PARM_DESC(disable_auto_ds
,
32 "deepsleep enabled=0(default), deepsleep disabled=1");
34 * This function prepares command to set/get RSSI information.
36 * Preparation includes -
37 * - Setting command ID, action and proper size
38 * - Setting data/beacon average factors
39 * - Resetting SNR/NF/RSSI values in private structure
40 * - Ensuring correct endian-ness
43 mwifiex_cmd_802_11_rssi_info(struct mwifiex_private
*priv
,
44 struct host_cmd_ds_command
*cmd
, u16 cmd_action
)
46 cmd
->command
= cpu_to_le16(HostCmd_CMD_RSSI_INFO
);
47 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rssi_info
) +
49 cmd
->params
.rssi_info
.action
= cpu_to_le16(cmd_action
);
50 cmd
->params
.rssi_info
.ndata
= cpu_to_le16(priv
->data_avg_factor
);
51 cmd
->params
.rssi_info
.nbcn
= cpu_to_le16(priv
->bcn_avg_factor
);
53 /* Reset SNR/NF/RSSI values in private structure */
54 priv
->data_rssi_last
= 0;
55 priv
->data_nf_last
= 0;
56 priv
->data_rssi_avg
= 0;
57 priv
->data_nf_avg
= 0;
58 priv
->bcn_rssi_last
= 0;
59 priv
->bcn_nf_last
= 0;
60 priv
->bcn_rssi_avg
= 0;
67 * This function prepares command to set MAC control.
69 * Preparation includes -
70 * - Setting command ID, action and proper size
71 * - Ensuring correct endian-ness
73 static int mwifiex_cmd_mac_control(struct mwifiex_private
*priv
,
74 struct host_cmd_ds_command
*cmd
,
75 u16 cmd_action
, u16
*action
)
77 struct host_cmd_ds_mac_control
*mac_ctrl
= &cmd
->params
.mac_ctrl
;
79 if (cmd_action
!= HostCmd_ACT_GEN_SET
) {
80 mwifiex_dbg(priv
->adapter
, ERROR
,
81 "mac_control: only support set cmd\n");
85 cmd
->command
= cpu_to_le16(HostCmd_CMD_MAC_CONTROL
);
87 cpu_to_le16(sizeof(struct host_cmd_ds_mac_control
) + S_DS_GEN
);
88 mac_ctrl
->action
= cpu_to_le16(*action
);
94 * This function prepares command to set/get SNMP MIB.
96 * Preparation includes -
97 * - Setting command ID, action and proper size
98 * - Setting SNMP MIB OID number and value
100 * - Ensuring correct endian-ness
102 * The following SNMP MIB OIDs are supported -
103 * - FRAG_THRESH_I : Fragmentation threshold
104 * - RTS_THRESH_I : RTS threshold
105 * - SHORT_RETRY_LIM_I : Short retry limit
106 * - DOT11D_I : 11d support
108 static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private
*priv
,
109 struct host_cmd_ds_command
*cmd
,
110 u16 cmd_action
, u32 cmd_oid
,
113 struct host_cmd_ds_802_11_snmp_mib
*snmp_mib
= &cmd
->params
.smib
;
115 mwifiex_dbg(priv
->adapter
, CMD
,
116 "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid
);
117 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB
);
118 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib
)
121 snmp_mib
->oid
= cpu_to_le16((u16
)cmd_oid
);
122 if (cmd_action
== HostCmd_ACT_GEN_GET
) {
123 snmp_mib
->query_type
= cpu_to_le16(HostCmd_ACT_GEN_GET
);
124 snmp_mib
->buf_size
= cpu_to_le16(MAX_SNMP_BUF_SIZE
);
125 le16_add_cpu(&cmd
->size
, MAX_SNMP_BUF_SIZE
);
126 } else if (cmd_action
== HostCmd_ACT_GEN_SET
) {
127 snmp_mib
->query_type
= cpu_to_le16(HostCmd_ACT_GEN_SET
);
128 snmp_mib
->buf_size
= cpu_to_le16(sizeof(u16
));
129 *((__le16
*) (snmp_mib
->value
)) = cpu_to_le16(*ul_temp
);
130 le16_add_cpu(&cmd
->size
, sizeof(u16
));
133 mwifiex_dbg(priv
->adapter
, CMD
,
134 "cmd: SNMP_CMD: Action=0x%x, OID=0x%x,\t"
135 "OIDSize=0x%x, Value=0x%x\n",
136 cmd_action
, cmd_oid
, le16_to_cpu(snmp_mib
->buf_size
),
137 le16_to_cpu(*(__le16
*)snmp_mib
->value
));
142 * This function prepares command to get log.
144 * Preparation includes -
145 * - Setting command ID and proper size
146 * - Ensuring correct endian-ness
149 mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command
*cmd
)
151 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_GET_LOG
);
152 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_802_11_get_log
) +
158 * This function prepares command to set/get Tx data rate configuration.
160 * Preparation includes -
161 * - Setting command ID, action and proper size
162 * - Setting configuration index, rate scope and rate drop pattern
163 * parameters (as required)
164 * - Ensuring correct endian-ness
166 static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private
*priv
,
167 struct host_cmd_ds_command
*cmd
,
168 u16 cmd_action
, u16
*pbitmap_rates
)
170 struct host_cmd_ds_tx_rate_cfg
*rate_cfg
= &cmd
->params
.tx_rate_cfg
;
171 struct mwifiex_rate_scope
*rate_scope
;
172 struct mwifiex_rate_drop_pattern
*rate_drop
;
175 cmd
->command
= cpu_to_le16(HostCmd_CMD_TX_RATE_CFG
);
177 rate_cfg
->action
= cpu_to_le16(cmd_action
);
178 rate_cfg
->cfg_index
= 0;
180 rate_scope
= (struct mwifiex_rate_scope
*) ((u8
*) rate_cfg
+
181 sizeof(struct host_cmd_ds_tx_rate_cfg
));
182 rate_scope
->type
= cpu_to_le16(TLV_TYPE_RATE_SCOPE
);
183 rate_scope
->length
= cpu_to_le16
184 (sizeof(*rate_scope
) - sizeof(struct mwifiex_ie_types_header
));
185 if (pbitmap_rates
!= NULL
) {
186 rate_scope
->hr_dsss_rate_bitmap
= cpu_to_le16(pbitmap_rates
[0]);
187 rate_scope
->ofdm_rate_bitmap
= cpu_to_le16(pbitmap_rates
[1]);
189 i
< sizeof(rate_scope
->ht_mcs_rate_bitmap
) / sizeof(u16
);
191 rate_scope
->ht_mcs_rate_bitmap
[i
] =
192 cpu_to_le16(pbitmap_rates
[2 + i
]);
193 if (priv
->adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
195 i
< ARRAY_SIZE(rate_scope
->vht_mcs_rate_bitmap
);
197 rate_scope
->vht_mcs_rate_bitmap
[i
] =
198 cpu_to_le16(pbitmap_rates
[10 + i
]);
201 rate_scope
->hr_dsss_rate_bitmap
=
202 cpu_to_le16(priv
->bitmap_rates
[0]);
203 rate_scope
->ofdm_rate_bitmap
=
204 cpu_to_le16(priv
->bitmap_rates
[1]);
206 i
< sizeof(rate_scope
->ht_mcs_rate_bitmap
) / sizeof(u16
);
208 rate_scope
->ht_mcs_rate_bitmap
[i
] =
209 cpu_to_le16(priv
->bitmap_rates
[2 + i
]);
210 if (priv
->adapter
->fw_api_ver
== MWIFIEX_FW_V15
) {
212 i
< ARRAY_SIZE(rate_scope
->vht_mcs_rate_bitmap
);
214 rate_scope
->vht_mcs_rate_bitmap
[i
] =
215 cpu_to_le16(priv
->bitmap_rates
[10 + i
]);
219 rate_drop
= (struct mwifiex_rate_drop_pattern
*) ((u8
*) rate_scope
+
220 sizeof(struct mwifiex_rate_scope
));
221 rate_drop
->type
= cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL
);
222 rate_drop
->length
= cpu_to_le16(sizeof(rate_drop
->rate_drop_mode
));
223 rate_drop
->rate_drop_mode
= 0;
226 cpu_to_le16(S_DS_GEN
+ sizeof(struct host_cmd_ds_tx_rate_cfg
) +
227 sizeof(struct mwifiex_rate_scope
) +
228 sizeof(struct mwifiex_rate_drop_pattern
));
234 * This function prepares command to set/get Tx power configuration.
236 * Preparation includes -
237 * - Setting command ID, action and proper size
238 * - Setting Tx power mode, power group TLV
240 * - Ensuring correct endian-ness
242 static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command
*cmd
,
244 struct host_cmd_ds_txpwr_cfg
*txp
)
246 struct mwifiex_types_power_group
*pg_tlv
;
247 struct host_cmd_ds_txpwr_cfg
*cmd_txp_cfg
= &cmd
->params
.txp_cfg
;
249 cmd
->command
= cpu_to_le16(HostCmd_CMD_TXPWR_CFG
);
251 cpu_to_le16(S_DS_GEN
+ sizeof(struct host_cmd_ds_txpwr_cfg
));
252 switch (cmd_action
) {
253 case HostCmd_ACT_GEN_SET
:
255 pg_tlv
= (struct mwifiex_types_power_group
256 *) ((unsigned long) txp
+
257 sizeof(struct host_cmd_ds_txpwr_cfg
));
258 memmove(cmd_txp_cfg
, txp
,
259 sizeof(struct host_cmd_ds_txpwr_cfg
) +
260 sizeof(struct mwifiex_types_power_group
) +
261 le16_to_cpu(pg_tlv
->length
));
263 pg_tlv
= (struct mwifiex_types_power_group
*) ((u8
*)
265 sizeof(struct host_cmd_ds_txpwr_cfg
));
266 cmd
->size
= cpu_to_le16(le16_to_cpu(cmd
->size
) +
267 sizeof(struct mwifiex_types_power_group
) +
268 le16_to_cpu(pg_tlv
->length
));
270 memmove(cmd_txp_cfg
, txp
, sizeof(*txp
));
272 cmd_txp_cfg
->action
= cpu_to_le16(cmd_action
);
274 case HostCmd_ACT_GEN_GET
:
275 cmd_txp_cfg
->action
= cpu_to_le16(cmd_action
);
283 * This function prepares command to get RF Tx power.
285 static int mwifiex_cmd_rf_tx_power(struct mwifiex_private
*priv
,
286 struct host_cmd_ds_command
*cmd
,
287 u16 cmd_action
, void *data_buf
)
289 struct host_cmd_ds_rf_tx_pwr
*txp
= &cmd
->params
.txp
;
291 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_rf_tx_pwr
)
293 cmd
->command
= cpu_to_le16(HostCmd_CMD_RF_TX_PWR
);
294 txp
->action
= cpu_to_le16(cmd_action
);
300 * This function prepares command to set rf antenna.
302 static int mwifiex_cmd_rf_antenna(struct mwifiex_private
*priv
,
303 struct host_cmd_ds_command
*cmd
,
305 struct mwifiex_ds_ant_cfg
*ant_cfg
)
307 struct host_cmd_ds_rf_ant_mimo
*ant_mimo
= &cmd
->params
.ant_mimo
;
308 struct host_cmd_ds_rf_ant_siso
*ant_siso
= &cmd
->params
.ant_siso
;
310 cmd
->command
= cpu_to_le16(HostCmd_CMD_RF_ANTENNA
);
312 if (cmd_action
!= HostCmd_ACT_GEN_SET
)
315 if (priv
->adapter
->hw_dev_mcs_support
== HT_STREAM_2X2
) {
316 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_mimo
) +
318 ant_mimo
->action_tx
= cpu_to_le16(HostCmd_ACT_SET_TX
);
319 ant_mimo
->tx_ant_mode
= cpu_to_le16((u16
)ant_cfg
->tx_ant
);
320 ant_mimo
->action_rx
= cpu_to_le16(HostCmd_ACT_SET_RX
);
321 ant_mimo
->rx_ant_mode
= cpu_to_le16((u16
)ant_cfg
->rx_ant
);
323 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_siso
) +
325 ant_siso
->action
= cpu_to_le16(HostCmd_ACT_SET_BOTH
);
326 ant_siso
->ant_mode
= cpu_to_le16((u16
)ant_cfg
->tx_ant
);
333 * This function prepares command to set Host Sleep configuration.
335 * Preparation includes -
336 * - Setting command ID and proper size
337 * - Setting Host Sleep action, conditions, ARP filters
339 * - Ensuring correct endian-ness
342 mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private
*priv
,
343 struct host_cmd_ds_command
*cmd
,
345 struct mwifiex_hs_config_param
*hscfg_param
)
347 struct mwifiex_adapter
*adapter
= priv
->adapter
;
348 struct host_cmd_ds_802_11_hs_cfg_enh
*hs_cfg
= &cmd
->params
.opt_hs_cfg
;
349 bool hs_activate
= false;
352 /* New Activate command */
354 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH
);
357 (hscfg_param
->conditions
!= cpu_to_le32(HS_CFG_CANCEL
)) &&
358 ((adapter
->arp_filter_size
> 0) &&
359 (adapter
->arp_filter_size
<= ARP_FILTER_MAX_BUF_SIZE
))) {
360 mwifiex_dbg(adapter
, CMD
,
361 "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n",
362 adapter
->arp_filter_size
);
363 memcpy(((u8
*) hs_cfg
) +
364 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh
),
365 adapter
->arp_filter
, adapter
->arp_filter_size
);
366 cmd
->size
= cpu_to_le16
367 (adapter
->arp_filter_size
+
368 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh
)
371 cmd
->size
= cpu_to_le16(S_DS_GEN
+ sizeof(struct
372 host_cmd_ds_802_11_hs_cfg_enh
));
375 hs_cfg
->action
= cpu_to_le16(HS_ACTIVATE
);
376 hs_cfg
->params
.hs_activate
.resp_ctrl
= cpu_to_le16(RESP_NEEDED
);
378 hs_cfg
->action
= cpu_to_le16(HS_CONFIGURE
);
379 hs_cfg
->params
.hs_config
.conditions
= hscfg_param
->conditions
;
380 hs_cfg
->params
.hs_config
.gpio
= hscfg_param
->gpio
;
381 hs_cfg
->params
.hs_config
.gap
= hscfg_param
->gap
;
382 mwifiex_dbg(adapter
, CMD
,
383 "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n",
384 hs_cfg
->params
.hs_config
.conditions
,
385 hs_cfg
->params
.hs_config
.gpio
,
386 hs_cfg
->params
.hs_config
.gap
);
393 * This function prepares command to set/get MAC address.
395 * Preparation includes -
396 * - Setting command ID, action and proper size
397 * - Setting MAC address (for SET only)
398 * - Ensuring correct endian-ness
400 static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private
*priv
,
401 struct host_cmd_ds_command
*cmd
,
404 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS
);
405 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address
) +
409 cmd
->params
.mac_addr
.action
= cpu_to_le16(cmd_action
);
411 if (cmd_action
== HostCmd_ACT_GEN_SET
)
412 memcpy(cmd
->params
.mac_addr
.mac_addr
, priv
->curr_addr
,
418 * This function prepares command to set MAC multicast address.
420 * Preparation includes -
421 * - Setting command ID, action and proper size
422 * - Setting MAC multicast address
423 * - Ensuring correct endian-ness
426 mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command
*cmd
,
428 struct mwifiex_multicast_list
*mcast_list
)
430 struct host_cmd_ds_mac_multicast_adr
*mcast_addr
= &cmd
->params
.mc_addr
;
432 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr
) +
434 cmd
->command
= cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR
);
436 mcast_addr
->action
= cpu_to_le16(cmd_action
);
437 mcast_addr
->num_of_adrs
=
438 cpu_to_le16((u16
) mcast_list
->num_multicast_addr
);
439 memcpy(mcast_addr
->mac_list
, mcast_list
->mac_list
,
440 mcast_list
->num_multicast_addr
* ETH_ALEN
);
446 * This function prepares command to deauthenticate.
448 * Preparation includes -
449 * - Setting command ID and proper size
450 * - Setting AP MAC address and reason code
451 * - Ensuring correct endian-ness
453 static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private
*priv
,
454 struct host_cmd_ds_command
*cmd
,
457 struct host_cmd_ds_802_11_deauthenticate
*deauth
= &cmd
->params
.deauth
;
459 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE
);
460 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate
)
463 /* Set AP MAC address */
464 memcpy(deauth
->mac_addr
, mac
, ETH_ALEN
);
466 mwifiex_dbg(priv
->adapter
, CMD
, "cmd: Deauth: %pM\n", deauth
->mac_addr
);
468 deauth
->reason_code
= cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING
);
474 * This function prepares command to stop Ad-Hoc network.
476 * Preparation includes -
477 * - Setting command ID and proper size
478 * - Ensuring correct endian-ness
480 static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command
*cmd
)
482 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP
);
483 cmd
->size
= cpu_to_le16(S_DS_GEN
);
488 * This function sets WEP key(s) to key parameter TLV(s).
490 * Multi-key parameter TLVs are supported, so we can send multiple
491 * WEP keys in a single buffer.
494 mwifiex_set_keyparamset_wep(struct mwifiex_private
*priv
,
495 struct mwifiex_ie_type_key_param_set
*key_param_set
,
498 int cur_key_param_len
;
501 /* Multi-key_param_set TLV is supported */
502 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
503 if ((priv
->wep_key
[i
].key_length
== WLAN_KEY_LEN_WEP40
) ||
504 (priv
->wep_key
[i
].key_length
== WLAN_KEY_LEN_WEP104
)) {
505 key_param_set
->type
=
506 cpu_to_le16(TLV_TYPE_KEY_MATERIAL
);
507 /* Key_param_set WEP fixed length */
508 #define KEYPARAMSET_WEP_FIXED_LEN 8
509 key_param_set
->length
= cpu_to_le16((u16
)
512 KEYPARAMSET_WEP_FIXED_LEN
));
513 key_param_set
->key_type_id
=
514 cpu_to_le16(KEY_TYPE_ID_WEP
);
515 key_param_set
->key_info
=
516 cpu_to_le16(KEY_ENABLED
| KEY_UNICAST
|
518 key_param_set
->key_len
=
519 cpu_to_le16(priv
->wep_key
[i
].key_length
);
520 /* Set WEP key index */
521 key_param_set
->key
[0] = i
;
522 /* Set default Tx key flag */
525 wep_key_curr_index
& HostCmd_WEP_KEY_INDEX_MASK
))
526 key_param_set
->key
[1] = 1;
528 key_param_set
->key
[1] = 0;
529 memmove(&key_param_set
->key
[2],
530 priv
->wep_key
[i
].key_material
,
531 priv
->wep_key
[i
].key_length
);
533 cur_key_param_len
= priv
->wep_key
[i
].key_length
+
534 KEYPARAMSET_WEP_FIXED_LEN
+
535 sizeof(struct mwifiex_ie_types_header
);
536 *key_param_len
+= (u16
) cur_key_param_len
;
538 (struct mwifiex_ie_type_key_param_set
*)
539 ((u8
*)key_param_set
+
541 } else if (!priv
->wep_key
[i
].key_length
) {
544 mwifiex_dbg(priv
->adapter
, ERROR
,
545 "key%d Length = %d is incorrect\n",
546 (i
+ 1), priv
->wep_key
[i
].key_length
);
554 /* This function populates key material v2 command
555 * to set network key for AES & CMAC AES.
557 static int mwifiex_set_aes_key_v2(struct mwifiex_private
*priv
,
558 struct host_cmd_ds_command
*cmd
,
559 struct mwifiex_ds_encrypt_key
*enc_key
,
560 struct host_cmd_ds_802_11_key_material_v2
*km
)
562 struct mwifiex_adapter
*adapter
= priv
->adapter
;
563 u16 size
, len
= KEY_PARAMS_FIXED_LEN
;
565 if (enc_key
->is_igtk_key
) {
566 mwifiex_dbg(adapter
, INFO
,
567 "%s: Set CMAC AES Key\n", __func__
);
568 if (enc_key
->is_rx_seq_valid
)
569 memcpy(km
->key_param_set
.key_params
.cmac_aes
.ipn
,
570 enc_key
->pn
, enc_key
->pn_len
);
571 km
->key_param_set
.key_info
&= cpu_to_le16(~KEY_MCAST
);
572 km
->key_param_set
.key_info
|= cpu_to_le16(KEY_IGTK
);
573 km
->key_param_set
.key_type
= KEY_TYPE_ID_AES_CMAC
;
574 km
->key_param_set
.key_params
.cmac_aes
.key_len
=
575 cpu_to_le16(enc_key
->key_len
);
576 memcpy(km
->key_param_set
.key_params
.cmac_aes
.key
,
577 enc_key
->key_material
, enc_key
->key_len
);
578 len
+= sizeof(struct mwifiex_cmac_aes_param
);
580 mwifiex_dbg(adapter
, INFO
,
581 "%s: Set AES Key\n", __func__
);
582 if (enc_key
->is_rx_seq_valid
)
583 memcpy(km
->key_param_set
.key_params
.aes
.pn
,
584 enc_key
->pn
, enc_key
->pn_len
);
585 km
->key_param_set
.key_type
= KEY_TYPE_ID_AES
;
586 km
->key_param_set
.key_params
.aes
.key_len
=
587 cpu_to_le16(enc_key
->key_len
);
588 memcpy(km
->key_param_set
.key_params
.aes
.key
,
589 enc_key
->key_material
, enc_key
->key_len
);
590 len
+= sizeof(struct mwifiex_aes_param
);
593 km
->key_param_set
.len
= cpu_to_le16(len
);
594 size
= len
+ sizeof(struct mwifiex_ie_types_header
) +
595 sizeof(km
->action
) + S_DS_GEN
;
596 cmd
->size
= cpu_to_le16(size
);
601 /* This function prepares command to set/get/reset network key(s).
602 * This function prepares key material command for V2 format.
603 * Preparation includes -
604 * - Setting command ID, action and proper size
605 * - Setting WEP keys, WAPI keys or WPA keys along with required
606 * encryption (TKIP, AES) (as required)
607 * - Ensuring correct endian-ness
610 mwifiex_cmd_802_11_key_material_v2(struct mwifiex_private
*priv
,
611 struct host_cmd_ds_command
*cmd
,
612 u16 cmd_action
, u32 cmd_oid
,
613 struct mwifiex_ds_encrypt_key
*enc_key
)
615 struct mwifiex_adapter
*adapter
= priv
->adapter
;
616 u8
*mac
= enc_key
->mac_addr
;
617 u16 key_info
, len
= KEY_PARAMS_FIXED_LEN
;
618 struct host_cmd_ds_802_11_key_material_v2
*km
=
619 &cmd
->params
.key_material_v2
;
621 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL
);
622 km
->action
= cpu_to_le16(cmd_action
);
624 if (cmd_action
== HostCmd_ACT_GEN_GET
) {
625 mwifiex_dbg(adapter
, INFO
, "%s: Get key\n", __func__
);
626 km
->key_param_set
.key_idx
=
627 enc_key
->key_index
& KEY_INDEX_MASK
;
628 km
->key_param_set
.type
= cpu_to_le16(TLV_TYPE_KEY_PARAM_V2
);
629 km
->key_param_set
.len
= cpu_to_le16(KEY_PARAMS_FIXED_LEN
);
630 memcpy(km
->key_param_set
.mac_addr
, mac
, ETH_ALEN
);
632 if (enc_key
->key_index
& MWIFIEX_KEY_INDEX_UNICAST
)
633 key_info
= KEY_UNICAST
;
635 key_info
= KEY_MCAST
;
637 if (enc_key
->is_igtk_key
)
638 key_info
|= KEY_IGTK
;
640 km
->key_param_set
.key_info
= cpu_to_le16(key_info
);
642 cmd
->size
= cpu_to_le16(sizeof(struct mwifiex_ie_types_header
) +
643 S_DS_GEN
+ KEY_PARAMS_FIXED_LEN
+
648 memset(&km
->key_param_set
, 0,
649 sizeof(struct mwifiex_ie_type_key_param_set_v2
));
651 if (enc_key
->key_disable
) {
652 mwifiex_dbg(adapter
, INFO
, "%s: Remove key\n", __func__
);
653 km
->action
= cpu_to_le16(HostCmd_ACT_GEN_REMOVE
);
654 km
->key_param_set
.type
= cpu_to_le16(TLV_TYPE_KEY_PARAM_V2
);
655 km
->key_param_set
.len
= cpu_to_le16(KEY_PARAMS_FIXED_LEN
);
656 km
->key_param_set
.key_idx
= enc_key
->key_index
& KEY_INDEX_MASK
;
657 key_info
= KEY_MCAST
| KEY_UNICAST
;
658 km
->key_param_set
.key_info
= cpu_to_le16(key_info
);
659 memcpy(km
->key_param_set
.mac_addr
, mac
, ETH_ALEN
);
660 cmd
->size
= cpu_to_le16(sizeof(struct mwifiex_ie_types_header
) +
661 S_DS_GEN
+ KEY_PARAMS_FIXED_LEN
+
666 km
->action
= cpu_to_le16(HostCmd_ACT_GEN_SET
);
667 km
->key_param_set
.key_idx
= enc_key
->key_index
& KEY_INDEX_MASK
;
668 km
->key_param_set
.type
= cpu_to_le16(TLV_TYPE_KEY_PARAM_V2
);
669 key_info
= KEY_ENABLED
;
670 memcpy(km
->key_param_set
.mac_addr
, mac
, ETH_ALEN
);
672 if (enc_key
->key_len
<= WLAN_KEY_LEN_WEP104
) {
673 mwifiex_dbg(adapter
, INFO
, "%s: Set WEP Key\n", __func__
);
674 len
+= sizeof(struct mwifiex_wep_param
);
675 km
->key_param_set
.len
= cpu_to_le16(len
);
676 km
->key_param_set
.key_type
= KEY_TYPE_ID_WEP
;
678 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
679 key_info
|= KEY_MCAST
| KEY_UNICAST
;
681 if (enc_key
->is_current_wep_key
) {
682 key_info
|= KEY_MCAST
| KEY_UNICAST
;
683 if (km
->key_param_set
.key_idx
==
684 (priv
->wep_key_curr_index
& KEY_INDEX_MASK
))
685 key_info
|= KEY_DEFAULT
;
688 if (is_broadcast_ether_addr(mac
))
689 key_info
|= KEY_MCAST
;
691 key_info
|= KEY_UNICAST
|
694 key_info
|= KEY_MCAST
;
698 km
->key_param_set
.key_info
= cpu_to_le16(key_info
);
700 km
->key_param_set
.key_params
.wep
.key_len
=
701 cpu_to_le16(enc_key
->key_len
);
702 memcpy(km
->key_param_set
.key_params
.wep
.key
,
703 enc_key
->key_material
, enc_key
->key_len
);
705 cmd
->size
= cpu_to_le16(sizeof(struct mwifiex_ie_types_header
) +
706 len
+ sizeof(km
->action
) + S_DS_GEN
);
710 if (is_broadcast_ether_addr(mac
))
711 key_info
|= KEY_MCAST
| KEY_RX_KEY
;
713 key_info
|= KEY_UNICAST
| KEY_TX_KEY
| KEY_RX_KEY
;
715 if (enc_key
->is_wapi_key
) {
716 mwifiex_dbg(adapter
, INFO
, "%s: Set WAPI Key\n", __func__
);
717 km
->key_param_set
.key_type
= KEY_TYPE_ID_WAPI
;
718 memcpy(km
->key_param_set
.key_params
.wapi
.pn
, enc_key
->pn
,
720 km
->key_param_set
.key_params
.wapi
.key_len
=
721 cpu_to_le16(enc_key
->key_len
);
722 memcpy(km
->key_param_set
.key_params
.wapi
.key
,
723 enc_key
->key_material
, enc_key
->key_len
);
724 if (is_broadcast_ether_addr(mac
))
725 priv
->sec_info
.wapi_key_on
= true;
727 if (!priv
->sec_info
.wapi_key_on
)
728 key_info
|= KEY_DEFAULT
;
729 km
->key_param_set
.key_info
= cpu_to_le16(key_info
);
731 len
+= sizeof(struct mwifiex_wapi_param
);
732 km
->key_param_set
.len
= cpu_to_le16(len
);
733 cmd
->size
= cpu_to_le16(sizeof(struct mwifiex_ie_types_header
) +
734 len
+ sizeof(km
->action
) + S_DS_GEN
);
738 if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
) {
739 key_info
|= KEY_DEFAULT
;
740 /* Enable unicast bit for WPA-NONE/ADHOC_AES */
741 if (!priv
->sec_info
.wpa2_enabled
&&
742 !is_broadcast_ether_addr(mac
))
743 key_info
|= KEY_UNICAST
;
745 /* Enable default key for WPA/WPA2 */
746 if (!priv
->wpa_is_gtk_set
)
747 key_info
|= KEY_DEFAULT
;
750 km
->key_param_set
.key_info
= cpu_to_le16(key_info
);
752 if (enc_key
->key_len
== WLAN_KEY_LEN_CCMP
)
753 return mwifiex_set_aes_key_v2(priv
, cmd
, enc_key
, km
);
755 if (enc_key
->key_len
== WLAN_KEY_LEN_TKIP
) {
756 mwifiex_dbg(adapter
, INFO
,
757 "%s: Set TKIP Key\n", __func__
);
758 if (enc_key
->is_rx_seq_valid
)
759 memcpy(km
->key_param_set
.key_params
.tkip
.pn
,
760 enc_key
->pn
, enc_key
->pn_len
);
761 km
->key_param_set
.key_type
= KEY_TYPE_ID_TKIP
;
762 km
->key_param_set
.key_params
.tkip
.key_len
=
763 cpu_to_le16(enc_key
->key_len
);
764 memcpy(km
->key_param_set
.key_params
.tkip
.key
,
765 enc_key
->key_material
, enc_key
->key_len
);
767 len
+= sizeof(struct mwifiex_tkip_param
);
768 km
->key_param_set
.len
= cpu_to_le16(len
);
769 cmd
->size
= cpu_to_le16(sizeof(struct mwifiex_ie_types_header
) +
770 len
+ sizeof(km
->action
) + S_DS_GEN
);
777 * This function prepares command to set/get/reset network key(s).
778 * This function prepares key material command for V1 format.
780 * Preparation includes -
781 * - Setting command ID, action and proper size
782 * - Setting WEP keys, WAPI keys or WPA keys along with required
783 * encryption (TKIP, AES) (as required)
784 * - Ensuring correct endian-ness
787 mwifiex_cmd_802_11_key_material_v1(struct mwifiex_private
*priv
,
788 struct host_cmd_ds_command
*cmd
,
789 u16 cmd_action
, u32 cmd_oid
,
790 struct mwifiex_ds_encrypt_key
*enc_key
)
792 struct host_cmd_ds_802_11_key_material
*key_material
=
793 &cmd
->params
.key_material
;
794 struct host_cmd_tlv_mac_addr
*tlv_mac
;
795 u16 key_param_len
= 0, cmd_size
;
798 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL
);
799 key_material
->action
= cpu_to_le16(cmd_action
);
801 if (cmd_action
== HostCmd_ACT_GEN_GET
) {
803 cpu_to_le16(sizeof(key_material
->action
) + S_DS_GEN
);
808 memset(&key_material
->key_param_set
, 0,
810 sizeof(struct mwifiex_ie_type_key_param_set
)));
811 ret
= mwifiex_set_keyparamset_wep(priv
,
812 &key_material
->key_param_set
,
814 cmd
->size
= cpu_to_le16(key_param_len
+
815 sizeof(key_material
->action
) + S_DS_GEN
);
818 memset(&key_material
->key_param_set
, 0,
819 sizeof(struct mwifiex_ie_type_key_param_set
));
820 if (enc_key
->is_wapi_key
) {
821 mwifiex_dbg(priv
->adapter
, INFO
, "info: Set WAPI Key\n");
822 key_material
->key_param_set
.key_type_id
=
823 cpu_to_le16(KEY_TYPE_ID_WAPI
);
824 if (cmd_oid
== KEY_INFO_ENABLED
)
825 key_material
->key_param_set
.key_info
=
826 cpu_to_le16(KEY_ENABLED
);
828 key_material
->key_param_set
.key_info
=
829 cpu_to_le16(!KEY_ENABLED
);
831 key_material
->key_param_set
.key
[0] = enc_key
->key_index
;
832 if (!priv
->sec_info
.wapi_key_on
)
833 key_material
->key_param_set
.key
[1] = 1;
835 /* set 0 when re-key */
836 key_material
->key_param_set
.key
[1] = 0;
838 if (!is_broadcast_ether_addr(enc_key
->mac_addr
)) {
839 /* WAPI pairwise key: unicast */
840 key_material
->key_param_set
.key_info
|=
841 cpu_to_le16(KEY_UNICAST
);
842 } else { /* WAPI group key: multicast */
843 key_material
->key_param_set
.key_info
|=
844 cpu_to_le16(KEY_MCAST
);
845 priv
->sec_info
.wapi_key_on
= true;
848 key_material
->key_param_set
.type
=
849 cpu_to_le16(TLV_TYPE_KEY_MATERIAL
);
850 key_material
->key_param_set
.key_len
=
851 cpu_to_le16(WAPI_KEY_LEN
);
852 memcpy(&key_material
->key_param_set
.key
[2],
853 enc_key
->key_material
, enc_key
->key_len
);
854 memcpy(&key_material
->key_param_set
.key
[2 + enc_key
->key_len
],
855 enc_key
->pn
, PN_LEN
);
856 key_material
->key_param_set
.length
=
857 cpu_to_le16(WAPI_KEY_LEN
+ KEYPARAMSET_FIXED_LEN
);
859 key_param_len
= (WAPI_KEY_LEN
+ KEYPARAMSET_FIXED_LEN
) +
860 sizeof(struct mwifiex_ie_types_header
);
861 cmd
->size
= cpu_to_le16(sizeof(key_material
->action
)
862 + S_DS_GEN
+ key_param_len
);
865 if (enc_key
->key_len
== WLAN_KEY_LEN_CCMP
) {
866 if (enc_key
->is_igtk_key
) {
867 mwifiex_dbg(priv
->adapter
, CMD
, "cmd: CMAC_AES\n");
868 key_material
->key_param_set
.key_type_id
=
869 cpu_to_le16(KEY_TYPE_ID_AES_CMAC
);
870 if (cmd_oid
== KEY_INFO_ENABLED
)
871 key_material
->key_param_set
.key_info
=
872 cpu_to_le16(KEY_ENABLED
);
874 key_material
->key_param_set
.key_info
=
875 cpu_to_le16(!KEY_ENABLED
);
877 key_material
->key_param_set
.key_info
|=
878 cpu_to_le16(KEY_IGTK
);
880 mwifiex_dbg(priv
->adapter
, CMD
, "cmd: WPA_AES\n");
881 key_material
->key_param_set
.key_type_id
=
882 cpu_to_le16(KEY_TYPE_ID_AES
);
883 if (cmd_oid
== KEY_INFO_ENABLED
)
884 key_material
->key_param_set
.key_info
=
885 cpu_to_le16(KEY_ENABLED
);
887 key_material
->key_param_set
.key_info
=
888 cpu_to_le16(!KEY_ENABLED
);
890 if (enc_key
->key_index
& MWIFIEX_KEY_INDEX_UNICAST
)
891 /* AES pairwise key: unicast */
892 key_material
->key_param_set
.key_info
|=
893 cpu_to_le16(KEY_UNICAST
);
894 else /* AES group key: multicast */
895 key_material
->key_param_set
.key_info
|=
896 cpu_to_le16(KEY_MCAST
);
898 } else if (enc_key
->key_len
== WLAN_KEY_LEN_TKIP
) {
899 mwifiex_dbg(priv
->adapter
, CMD
, "cmd: WPA_TKIP\n");
900 key_material
->key_param_set
.key_type_id
=
901 cpu_to_le16(KEY_TYPE_ID_TKIP
);
902 key_material
->key_param_set
.key_info
=
903 cpu_to_le16(KEY_ENABLED
);
905 if (enc_key
->key_index
& MWIFIEX_KEY_INDEX_UNICAST
)
906 /* TKIP pairwise key: unicast */
907 key_material
->key_param_set
.key_info
|=
908 cpu_to_le16(KEY_UNICAST
);
909 else /* TKIP group key: multicast */
910 key_material
->key_param_set
.key_info
|=
911 cpu_to_le16(KEY_MCAST
);
914 if (key_material
->key_param_set
.key_type_id
) {
915 key_material
->key_param_set
.type
=
916 cpu_to_le16(TLV_TYPE_KEY_MATERIAL
);
917 key_material
->key_param_set
.key_len
=
918 cpu_to_le16((u16
) enc_key
->key_len
);
919 memcpy(key_material
->key_param_set
.key
, enc_key
->key_material
,
921 key_material
->key_param_set
.length
=
922 cpu_to_le16((u16
) enc_key
->key_len
+
923 KEYPARAMSET_FIXED_LEN
);
925 key_param_len
= (u16
)(enc_key
->key_len
+ KEYPARAMSET_FIXED_LEN
)
926 + sizeof(struct mwifiex_ie_types_header
);
928 if (le16_to_cpu(key_material
->key_param_set
.key_type_id
) ==
929 KEY_TYPE_ID_AES_CMAC
) {
930 struct mwifiex_cmac_param
*param
=
931 (void *)key_material
->key_param_set
.key
;
933 memcpy(param
->ipn
, enc_key
->pn
, IGTK_PN_LEN
);
934 memcpy(param
->key
, enc_key
->key_material
,
935 WLAN_KEY_LEN_AES_CMAC
);
937 key_param_len
= sizeof(struct mwifiex_cmac_param
);
938 key_material
->key_param_set
.key_len
=
939 cpu_to_le16(key_param_len
);
940 key_param_len
+= KEYPARAMSET_FIXED_LEN
;
941 key_material
->key_param_set
.length
=
942 cpu_to_le16(key_param_len
);
943 key_param_len
+= sizeof(struct mwifiex_ie_types_header
);
946 cmd
->size
= cpu_to_le16(sizeof(key_material
->action
) + S_DS_GEN
949 if (GET_BSS_ROLE(priv
) == MWIFIEX_BSS_ROLE_UAP
) {
950 tlv_mac
= (void *)((u8
*)&key_material
->key_param_set
+
952 tlv_mac
->header
.type
=
953 cpu_to_le16(TLV_TYPE_STA_MAC_ADDR
);
954 tlv_mac
->header
.len
= cpu_to_le16(ETH_ALEN
);
955 memcpy(tlv_mac
->mac_addr
, enc_key
->mac_addr
, ETH_ALEN
);
956 cmd_size
= key_param_len
+ S_DS_GEN
+
957 sizeof(key_material
->action
) +
958 sizeof(struct host_cmd_tlv_mac_addr
);
960 cmd_size
= key_param_len
+ S_DS_GEN
+
961 sizeof(key_material
->action
);
963 cmd
->size
= cpu_to_le16(cmd_size
);
969 /* Wrapper function for setting network key depending upon FW KEY API version */
971 mwifiex_cmd_802_11_key_material(struct mwifiex_private
*priv
,
972 struct host_cmd_ds_command
*cmd
,
973 u16 cmd_action
, u32 cmd_oid
,
974 struct mwifiex_ds_encrypt_key
*enc_key
)
976 if (priv
->adapter
->key_api_major_ver
== KEY_API_VER_MAJOR_V2
)
977 return mwifiex_cmd_802_11_key_material_v2(priv
, cmd
,
982 return mwifiex_cmd_802_11_key_material_v1(priv
, cmd
,
988 * This function prepares command to set/get 11d domain information.
990 * Preparation includes -
991 * - Setting command ID, action and proper size
992 * - Setting domain information fields (for SET only)
993 * - Ensuring correct endian-ness
995 static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private
*priv
,
996 struct host_cmd_ds_command
*cmd
,
999 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1000 struct host_cmd_ds_802_11d_domain_info
*domain_info
=
1001 &cmd
->params
.domain_info
;
1002 struct mwifiex_ietypes_domain_param_set
*domain
=
1003 &domain_info
->domain
;
1004 u8 no_of_triplet
= adapter
->domain_reg
.no_of_triplet
;
1006 mwifiex_dbg(adapter
, INFO
,
1007 "info: 11D: no_of_triplet=0x%x\n", no_of_triplet
);
1009 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO
);
1010 domain_info
->action
= cpu_to_le16(cmd_action
);
1011 if (cmd_action
== HostCmd_ACT_GEN_GET
) {
1012 cmd
->size
= cpu_to_le16(sizeof(domain_info
->action
) + S_DS_GEN
);
1016 /* Set domain info fields */
1017 domain
->header
.type
= cpu_to_le16(WLAN_EID_COUNTRY
);
1018 memcpy(domain
->country_code
, adapter
->domain_reg
.country_code
,
1019 sizeof(domain
->country_code
));
1021 domain
->header
.len
=
1022 cpu_to_le16((no_of_triplet
*
1023 sizeof(struct ieee80211_country_ie_triplet
))
1024 + sizeof(domain
->country_code
));
1026 if (no_of_triplet
) {
1027 memcpy(domain
->triplet
, adapter
->domain_reg
.triplet
,
1028 no_of_triplet
* sizeof(struct
1029 ieee80211_country_ie_triplet
));
1031 cmd
->size
= cpu_to_le16(sizeof(domain_info
->action
) +
1032 le16_to_cpu(domain
->header
.len
) +
1033 sizeof(struct mwifiex_ie_types_header
)
1036 cmd
->size
= cpu_to_le16(sizeof(domain_info
->action
) + S_DS_GEN
);
1043 * This function prepares command to set/get IBSS coalescing status.
1045 * Preparation includes -
1046 * - Setting command ID, action and proper size
1047 * - Setting status to enable or disable (for SET only)
1048 * - Ensuring correct endian-ness
1050 static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command
*cmd
,
1051 u16 cmd_action
, u16
*enable
)
1053 struct host_cmd_ds_802_11_ibss_status
*ibss_coal
=
1054 &(cmd
->params
.ibss_coalescing
);
1056 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS
);
1057 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status
) +
1060 ibss_coal
->action
= cpu_to_le16(cmd_action
);
1062 switch (cmd_action
) {
1063 case HostCmd_ACT_GEN_SET
:
1065 ibss_coal
->enable
= cpu_to_le16(*enable
);
1067 ibss_coal
->enable
= 0;
1070 /* In other case.. Nothing to do */
1071 case HostCmd_ACT_GEN_GET
:
1079 /* This function prepares command buffer to get/set memory location value.
1082 mwifiex_cmd_mem_access(struct host_cmd_ds_command
*cmd
, u16 cmd_action
,
1085 struct mwifiex_ds_mem_rw
*mem_rw
= (void *)pdata_buf
;
1086 struct host_cmd_ds_mem_access
*mem_access
= (void *)&cmd
->params
.mem
;
1088 cmd
->command
= cpu_to_le16(HostCmd_CMD_MEM_ACCESS
);
1089 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_mem_access
) +
1092 mem_access
->action
= cpu_to_le16(cmd_action
);
1093 mem_access
->addr
= cpu_to_le32(mem_rw
->addr
);
1094 mem_access
->value
= cpu_to_le32(mem_rw
->value
);
1100 * This function prepares command to set/get register value.
1102 * Preparation includes -
1103 * - Setting command ID, action and proper size
1104 * - Setting register offset (for both GET and SET) and
1105 * register value (for SET only)
1106 * - Ensuring correct endian-ness
1108 * The following type of registers can be accessed with this function -
1116 static int mwifiex_cmd_reg_access(struct host_cmd_ds_command
*cmd
,
1117 u16 cmd_action
, void *data_buf
)
1119 struct mwifiex_ds_reg_rw
*reg_rw
= data_buf
;
1121 switch (le16_to_cpu(cmd
->command
)) {
1122 case HostCmd_CMD_MAC_REG_ACCESS
:
1124 struct host_cmd_ds_mac_reg_access
*mac_reg
;
1126 cmd
->size
= cpu_to_le16(sizeof(*mac_reg
) + S_DS_GEN
);
1127 mac_reg
= &cmd
->params
.mac_reg
;
1128 mac_reg
->action
= cpu_to_le16(cmd_action
);
1130 cpu_to_le16((u16
) le32_to_cpu(reg_rw
->offset
));
1131 mac_reg
->value
= reg_rw
->value
;
1134 case HostCmd_CMD_BBP_REG_ACCESS
:
1136 struct host_cmd_ds_bbp_reg_access
*bbp_reg
;
1138 cmd
->size
= cpu_to_le16(sizeof(*bbp_reg
) + S_DS_GEN
);
1139 bbp_reg
= &cmd
->params
.bbp_reg
;
1140 bbp_reg
->action
= cpu_to_le16(cmd_action
);
1142 cpu_to_le16((u16
) le32_to_cpu(reg_rw
->offset
));
1143 bbp_reg
->value
= (u8
) le32_to_cpu(reg_rw
->value
);
1146 case HostCmd_CMD_RF_REG_ACCESS
:
1148 struct host_cmd_ds_rf_reg_access
*rf_reg
;
1150 cmd
->size
= cpu_to_le16(sizeof(*rf_reg
) + S_DS_GEN
);
1151 rf_reg
= &cmd
->params
.rf_reg
;
1152 rf_reg
->action
= cpu_to_le16(cmd_action
);
1153 rf_reg
->offset
= cpu_to_le16((u16
) le32_to_cpu(reg_rw
->offset
));
1154 rf_reg
->value
= (u8
) le32_to_cpu(reg_rw
->value
);
1157 case HostCmd_CMD_PMIC_REG_ACCESS
:
1159 struct host_cmd_ds_pmic_reg_access
*pmic_reg
;
1161 cmd
->size
= cpu_to_le16(sizeof(*pmic_reg
) + S_DS_GEN
);
1162 pmic_reg
= &cmd
->params
.pmic_reg
;
1163 pmic_reg
->action
= cpu_to_le16(cmd_action
);
1165 cpu_to_le16((u16
) le32_to_cpu(reg_rw
->offset
));
1166 pmic_reg
->value
= (u8
) le32_to_cpu(reg_rw
->value
);
1169 case HostCmd_CMD_CAU_REG_ACCESS
:
1171 struct host_cmd_ds_rf_reg_access
*cau_reg
;
1173 cmd
->size
= cpu_to_le16(sizeof(*cau_reg
) + S_DS_GEN
);
1174 cau_reg
= &cmd
->params
.rf_reg
;
1175 cau_reg
->action
= cpu_to_le16(cmd_action
);
1177 cpu_to_le16((u16
) le32_to_cpu(reg_rw
->offset
));
1178 cau_reg
->value
= (u8
) le32_to_cpu(reg_rw
->value
);
1181 case HostCmd_CMD_802_11_EEPROM_ACCESS
:
1183 struct mwifiex_ds_read_eeprom
*rd_eeprom
= data_buf
;
1184 struct host_cmd_ds_802_11_eeprom_access
*cmd_eeprom
=
1185 &cmd
->params
.eeprom
;
1187 cmd
->size
= cpu_to_le16(sizeof(*cmd_eeprom
) + S_DS_GEN
);
1188 cmd_eeprom
->action
= cpu_to_le16(cmd_action
);
1189 cmd_eeprom
->offset
= rd_eeprom
->offset
;
1190 cmd_eeprom
->byte_count
= rd_eeprom
->byte_count
;
1191 cmd_eeprom
->value
= 0;
1202 * This function prepares command to set PCI-Express
1203 * host buffer configuration
1205 * Preparation includes -
1206 * - Setting command ID, action and proper size
1207 * - Setting host buffer configuration
1208 * - Ensuring correct endian-ness
1211 mwifiex_cmd_pcie_host_spec(struct mwifiex_private
*priv
,
1212 struct host_cmd_ds_command
*cmd
, u16 action
)
1214 struct host_cmd_ds_pcie_details
*host_spec
=
1215 &cmd
->params
.pcie_host_spec
;
1216 struct pcie_service_card
*card
= priv
->adapter
->card
;
1218 cmd
->command
= cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS
);
1219 cmd
->size
= cpu_to_le16(sizeof(struct
1220 host_cmd_ds_pcie_details
) + S_DS_GEN
);
1223 memset(host_spec
, 0, sizeof(struct host_cmd_ds_pcie_details
));
1225 if (action
!= HostCmd_ACT_GEN_SET
)
1228 /* Send the ring base addresses and count to firmware */
1229 host_spec
->txbd_addr_lo
= (u32
)(card
->txbd_ring_pbase
);
1230 host_spec
->txbd_addr_hi
= (u32
)(((u64
)card
->txbd_ring_pbase
)>>32);
1231 host_spec
->txbd_count
= MWIFIEX_MAX_TXRX_BD
;
1232 host_spec
->rxbd_addr_lo
= (u32
)(card
->rxbd_ring_pbase
);
1233 host_spec
->rxbd_addr_hi
= (u32
)(((u64
)card
->rxbd_ring_pbase
)>>32);
1234 host_spec
->rxbd_count
= MWIFIEX_MAX_TXRX_BD
;
1235 host_spec
->evtbd_addr_lo
= (u32
)(card
->evtbd_ring_pbase
);
1236 host_spec
->evtbd_addr_hi
= (u32
)(((u64
)card
->evtbd_ring_pbase
)>>32);
1237 host_spec
->evtbd_count
= MWIFIEX_MAX_EVT_BD
;
1238 if (card
->sleep_cookie_vbase
) {
1239 host_spec
->sleep_cookie_addr_lo
=
1240 (u32
)(card
->sleep_cookie_pbase
);
1241 host_spec
->sleep_cookie_addr_hi
=
1242 (u32
)(((u64
)(card
->sleep_cookie_pbase
)) >> 32);
1243 mwifiex_dbg(priv
->adapter
, INFO
,
1244 "sleep_cook_lo phy addr: 0x%x\n",
1245 host_spec
->sleep_cookie_addr_lo
);
1252 * This function prepares command for event subscription, configuration
1253 * and query. Events can be subscribed or unsubscribed. Current subscribed
1254 * events can be queried. Also, current subscribed events are reported in
1255 * every FW response.
1258 mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private
*priv
,
1259 struct host_cmd_ds_command
*cmd
,
1260 struct mwifiex_ds_misc_subsc_evt
*subsc_evt_cfg
)
1262 struct host_cmd_ds_802_11_subsc_evt
*subsc_evt
= &cmd
->params
.subsc_evt
;
1263 struct mwifiex_ie_types_rssi_threshold
*rssi_tlv
;
1267 cmd
->command
= cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT
);
1268 cmd
->size
= cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt
) +
1271 subsc_evt
->action
= cpu_to_le16(subsc_evt_cfg
->action
);
1272 mwifiex_dbg(priv
->adapter
, CMD
,
1273 "cmd: action: %d\n", subsc_evt_cfg
->action
);
1275 /*For query requests, no configuration TLV structures are to be added.*/
1276 if (subsc_evt_cfg
->action
== HostCmd_ACT_GEN_GET
)
1279 subsc_evt
->events
= cpu_to_le16(subsc_evt_cfg
->events
);
1281 event_bitmap
= subsc_evt_cfg
->events
;
1282 mwifiex_dbg(priv
->adapter
, CMD
, "cmd: event bitmap : %16x\n",
1285 if (((subsc_evt_cfg
->action
== HostCmd_ACT_BITWISE_CLR
) ||
1286 (subsc_evt_cfg
->action
== HostCmd_ACT_BITWISE_SET
)) &&
1287 (event_bitmap
== 0)) {
1288 mwifiex_dbg(priv
->adapter
, ERROR
,
1289 "Error: No event specified\t"
1290 "for bitwise action type\n");
1295 * Append TLV structures for each of the specified events for
1296 * subscribing or re-configuring. This is not required for
1297 * bitwise unsubscribing request.
1299 if (subsc_evt_cfg
->action
== HostCmd_ACT_BITWISE_CLR
)
1302 pos
= ((u8
*)subsc_evt
) +
1303 sizeof(struct host_cmd_ds_802_11_subsc_evt
);
1305 if (event_bitmap
& BITMASK_BCN_RSSI_LOW
) {
1306 rssi_tlv
= (struct mwifiex_ie_types_rssi_threshold
*) pos
;
1308 rssi_tlv
->header
.type
= cpu_to_le16(TLV_TYPE_RSSI_LOW
);
1309 rssi_tlv
->header
.len
=
1310 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold
) -
1311 sizeof(struct mwifiex_ie_types_header
));
1312 rssi_tlv
->abs_value
= subsc_evt_cfg
->bcn_l_rssi_cfg
.abs_value
;
1313 rssi_tlv
->evt_freq
= subsc_evt_cfg
->bcn_l_rssi_cfg
.evt_freq
;
1315 mwifiex_dbg(priv
->adapter
, EVENT
,
1316 "Cfg Beacon Low Rssi event,\t"
1317 "RSSI:-%d dBm, Freq:%d\n",
1318 subsc_evt_cfg
->bcn_l_rssi_cfg
.abs_value
,
1319 subsc_evt_cfg
->bcn_l_rssi_cfg
.evt_freq
);
1321 pos
+= sizeof(struct mwifiex_ie_types_rssi_threshold
);
1322 le16_add_cpu(&cmd
->size
,
1323 sizeof(struct mwifiex_ie_types_rssi_threshold
));
1326 if (event_bitmap
& BITMASK_BCN_RSSI_HIGH
) {
1327 rssi_tlv
= (struct mwifiex_ie_types_rssi_threshold
*) pos
;
1329 rssi_tlv
->header
.type
= cpu_to_le16(TLV_TYPE_RSSI_HIGH
);
1330 rssi_tlv
->header
.len
=
1331 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold
) -
1332 sizeof(struct mwifiex_ie_types_header
));
1333 rssi_tlv
->abs_value
= subsc_evt_cfg
->bcn_h_rssi_cfg
.abs_value
;
1334 rssi_tlv
->evt_freq
= subsc_evt_cfg
->bcn_h_rssi_cfg
.evt_freq
;
1336 mwifiex_dbg(priv
->adapter
, EVENT
,
1337 "Cfg Beacon High Rssi event,\t"
1338 "RSSI:-%d dBm, Freq:%d\n",
1339 subsc_evt_cfg
->bcn_h_rssi_cfg
.abs_value
,
1340 subsc_evt_cfg
->bcn_h_rssi_cfg
.evt_freq
);
1342 pos
+= sizeof(struct mwifiex_ie_types_rssi_threshold
);
1343 le16_add_cpu(&cmd
->size
,
1344 sizeof(struct mwifiex_ie_types_rssi_threshold
));
1351 mwifiex_cmd_append_rpn_expression(struct mwifiex_private
*priv
,
1352 struct mwifiex_mef_entry
*mef_entry
,
1355 struct mwifiex_mef_filter
*filter
= mef_entry
->filter
;
1357 u8
*stack_ptr
= *buffer
;
1359 for (i
= 0; i
< MWIFIEX_MEF_MAX_FILTERS
; i
++) {
1360 filter
= &mef_entry
->filter
[i
];
1361 if (!filter
->filt_type
)
1363 *(__le32
*)stack_ptr
= cpu_to_le32((u32
)filter
->repeat
);
1365 *stack_ptr
= TYPE_DNUM
;
1368 byte_len
= filter
->byte_seq
[MWIFIEX_MEF_MAX_BYTESEQ
];
1369 memcpy(stack_ptr
, filter
->byte_seq
, byte_len
);
1370 stack_ptr
+= byte_len
;
1371 *stack_ptr
= byte_len
;
1373 *stack_ptr
= TYPE_BYTESEQ
;
1376 *(__le32
*)stack_ptr
= cpu_to_le32((u32
)filter
->offset
);
1378 *stack_ptr
= TYPE_DNUM
;
1381 *stack_ptr
= filter
->filt_type
;
1384 if (filter
->filt_action
) {
1385 *stack_ptr
= filter
->filt_action
;
1389 if (stack_ptr
- *buffer
> STACK_NBYTES
)
1393 *buffer
= stack_ptr
;
1398 mwifiex_cmd_mef_cfg(struct mwifiex_private
*priv
,
1399 struct host_cmd_ds_command
*cmd
,
1400 struct mwifiex_ds_mef_cfg
*mef
)
1402 struct host_cmd_ds_mef_cfg
*mef_cfg
= &cmd
->params
.mef_cfg
;
1403 struct mwifiex_fw_mef_entry
*mef_entry
= NULL
;
1404 u8
*pos
= (u8
*)mef_cfg
;
1407 cmd
->command
= cpu_to_le16(HostCmd_CMD_MEF_CFG
);
1409 mef_cfg
->criteria
= cpu_to_le32(mef
->criteria
);
1410 mef_cfg
->num_entries
= cpu_to_le16(mef
->num_entries
);
1411 pos
+= sizeof(*mef_cfg
);
1413 for (i
= 0; i
< mef
->num_entries
; i
++) {
1414 mef_entry
= (struct mwifiex_fw_mef_entry
*)pos
;
1415 mef_entry
->mode
= mef
->mef_entry
[i
].mode
;
1416 mef_entry
->action
= mef
->mef_entry
[i
].action
;
1417 pos
+= sizeof(*mef_cfg
->mef_entry
);
1419 if (mwifiex_cmd_append_rpn_expression(priv
,
1420 &mef
->mef_entry
[i
], &pos
))
1423 mef_entry
->exprsize
=
1424 cpu_to_le16(pos
- mef_entry
->expr
);
1426 cmd
->size
= cpu_to_le16((u16
) (pos
- (u8
*)mef_cfg
) + S_DS_GEN
);
1431 /* This function parse cal data from ASCII to hex */
1432 static u32
mwifiex_parse_cal_cfg(u8
*src
, size_t len
, u8
*dst
)
1434 u8
*s
= src
, *d
= dst
;
1436 while (s
- src
< len
) {
1437 if (*s
&& (isspace(*s
) || *s
== '\t')) {
1442 *d
++ = simple_strtol(s
, NULL
, 16);
1452 int mwifiex_dnld_dt_cfgdata(struct mwifiex_private
*priv
,
1453 struct device_node
*node
, const char *prefix
)
1456 struct property
*prop
;
1457 size_t len
= strlen(prefix
);
1460 /* look for all matching property names */
1461 for_each_property_of_node(node
, prop
) {
1462 if (len
> strlen(prop
->name
) ||
1463 strncmp(prop
->name
, prefix
, len
))
1466 /* property header is 6 bytes, data must fit in cmd buffer */
1467 if (prop
&& prop
->value
&& prop
->length
> 6 &&
1468 prop
->length
<= MWIFIEX_SIZE_OF_CMD_BUFFER
- S_DS_GEN
) {
1469 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_CFG_DATA
,
1470 HostCmd_ACT_GEN_SET
, 0,
1480 /* This function prepares command of set_cfg_data. */
1481 static int mwifiex_cmd_cfg_data(struct mwifiex_private
*priv
,
1482 struct host_cmd_ds_command
*cmd
, void *data_buf
)
1484 struct mwifiex_adapter
*adapter
= priv
->adapter
;
1485 struct property
*prop
= data_buf
;
1487 u8
*data
= (u8
*)cmd
+ S_DS_GEN
;
1492 ret
= of_property_read_u8_array(adapter
->dt_node
, prop
->name
,
1496 mwifiex_dbg(adapter
, INFO
,
1497 "download cfg_data from device tree: %s\n",
1499 } else if (adapter
->cal_data
->data
&& adapter
->cal_data
->size
> 0) {
1500 len
= mwifiex_parse_cal_cfg((u8
*)adapter
->cal_data
->data
,
1501 adapter
->cal_data
->size
, data
);
1502 mwifiex_dbg(adapter
, INFO
,
1503 "download cfg_data from config file\n");
1508 cmd
->command
= cpu_to_le16(HostCmd_CMD_CFG_DATA
);
1509 cmd
->size
= cpu_to_le16(S_DS_GEN
+ len
);
1515 mwifiex_cmd_coalesce_cfg(struct mwifiex_private
*priv
,
1516 struct host_cmd_ds_command
*cmd
,
1517 u16 cmd_action
, void *data_buf
)
1519 struct host_cmd_ds_coalesce_cfg
*coalesce_cfg
=
1520 &cmd
->params
.coalesce_cfg
;
1521 struct mwifiex_ds_coalesce_cfg
*cfg
= data_buf
;
1522 struct coalesce_filt_field_param
*param
;
1523 u16 cnt
, idx
, length
;
1524 struct coalesce_receive_filt_rule
*rule
;
1526 cmd
->command
= cpu_to_le16(HostCmd_CMD_COALESCE_CFG
);
1527 cmd
->size
= cpu_to_le16(S_DS_GEN
);
1529 coalesce_cfg
->action
= cpu_to_le16(cmd_action
);
1530 coalesce_cfg
->num_of_rules
= cpu_to_le16(cfg
->num_of_rules
);
1531 rule
= coalesce_cfg
->rule
;
1533 for (cnt
= 0; cnt
< cfg
->num_of_rules
; cnt
++) {
1534 rule
->header
.type
= cpu_to_le16(TLV_TYPE_COALESCE_RULE
);
1535 rule
->max_coalescing_delay
=
1536 cpu_to_le16(cfg
->rule
[cnt
].max_coalescing_delay
);
1537 rule
->pkt_type
= cfg
->rule
[cnt
].pkt_type
;
1538 rule
->num_of_fields
= cfg
->rule
[cnt
].num_of_fields
;
1542 param
= rule
->params
;
1543 for (idx
= 0; idx
< cfg
->rule
[cnt
].num_of_fields
; idx
++) {
1544 param
->operation
= cfg
->rule
[cnt
].params
[idx
].operation
;
1545 param
->operand_len
=
1546 cfg
->rule
[cnt
].params
[idx
].operand_len
;
1548 cpu_to_le16(cfg
->rule
[cnt
].params
[idx
].offset
);
1549 memcpy(param
->operand_byte_stream
,
1550 cfg
->rule
[cnt
].params
[idx
].operand_byte_stream
,
1551 param
->operand_len
);
1553 length
+= sizeof(struct coalesce_filt_field_param
);
1558 /* Total rule length is sizeof max_coalescing_delay(u16),
1559 * num_of_fields(u8), pkt_type(u8) and total length of the all
1562 rule
->header
.len
= cpu_to_le16(length
+ sizeof(u16
) +
1563 sizeof(u8
) + sizeof(u8
));
1565 /* Add the rule length to the command size*/
1566 le16_add_cpu(&cmd
->size
, le16_to_cpu(rule
->header
.len
) +
1567 sizeof(struct mwifiex_ie_types_header
));
1569 rule
= (void *)((u8
*)rule
->params
+ length
);
1572 /* Add sizeof action, num_of_rules to total command length */
1573 le16_add_cpu(&cmd
->size
, sizeof(u16
) + sizeof(u16
));
1579 mwifiex_cmd_tdls_config(struct mwifiex_private
*priv
,
1580 struct host_cmd_ds_command
*cmd
,
1581 u16 cmd_action
, void *data_buf
)
1583 struct host_cmd_ds_tdls_config
*tdls_config
= &cmd
->params
.tdls_config
;
1584 struct mwifiex_tdls_init_cs_params
*config
;
1585 struct mwifiex_tdls_config
*init_config
;
1588 cmd
->command
= cpu_to_le16(HostCmd_CMD_TDLS_CONFIG
);
1589 cmd
->size
= cpu_to_le16(S_DS_GEN
);
1590 tdls_config
->tdls_action
= cpu_to_le16(cmd_action
);
1591 le16_add_cpu(&cmd
->size
, sizeof(tdls_config
->tdls_action
));
1593 switch (cmd_action
) {
1594 case ACT_TDLS_CS_ENABLE_CONFIG
:
1595 init_config
= data_buf
;
1596 len
= sizeof(*init_config
);
1597 memcpy(tdls_config
->tdls_data
, init_config
, len
);
1599 case ACT_TDLS_CS_INIT
:
1601 len
= sizeof(*config
);
1602 memcpy(tdls_config
->tdls_data
, config
, len
);
1604 case ACT_TDLS_CS_STOP
:
1605 len
= sizeof(struct mwifiex_tdls_stop_cs_params
);
1606 memcpy(tdls_config
->tdls_data
, data_buf
, len
);
1608 case ACT_TDLS_CS_PARAMS
:
1609 len
= sizeof(struct mwifiex_tdls_config_cs_params
);
1610 memcpy(tdls_config
->tdls_data
, data_buf
, len
);
1613 mwifiex_dbg(priv
->adapter
, ERROR
,
1614 "Unknown TDLS configuration\n");
1618 le16_add_cpu(&cmd
->size
, len
);
1623 mwifiex_cmd_tdls_oper(struct mwifiex_private
*priv
,
1624 struct host_cmd_ds_command
*cmd
,
1627 struct host_cmd_ds_tdls_oper
*tdls_oper
= &cmd
->params
.tdls_oper
;
1628 struct mwifiex_ds_tdls_oper
*oper
= data_buf
;
1629 struct mwifiex_sta_node
*sta_ptr
;
1630 struct host_cmd_tlv_rates
*tlv_rates
;
1631 struct mwifiex_ie_types_htcap
*ht_capab
;
1632 struct mwifiex_ie_types_qos_info
*wmm_qos_info
;
1633 struct mwifiex_ie_types_extcap
*extcap
;
1634 struct mwifiex_ie_types_vhtcap
*vht_capab
;
1635 struct mwifiex_ie_types_aid
*aid
;
1636 struct mwifiex_ie_types_tdls_idle_timeout
*timeout
;
1639 struct station_parameters
*params
= priv
->sta_params
;
1641 cmd
->command
= cpu_to_le16(HostCmd_CMD_TDLS_OPER
);
1642 cmd
->size
= cpu_to_le16(S_DS_GEN
);
1643 le16_add_cpu(&cmd
->size
, sizeof(struct host_cmd_ds_tdls_oper
));
1645 tdls_oper
->reason
= 0;
1646 memcpy(tdls_oper
->peer_mac
, oper
->peer_mac
, ETH_ALEN
);
1647 sta_ptr
= mwifiex_get_sta_entry(priv
, oper
->peer_mac
);
1649 pos
= (u8
*)tdls_oper
+ sizeof(struct host_cmd_ds_tdls_oper
);
1651 switch (oper
->tdls_action
) {
1652 case MWIFIEX_TDLS_DISABLE_LINK
:
1653 tdls_oper
->tdls_action
= cpu_to_le16(ACT_TDLS_DELETE
);
1655 case MWIFIEX_TDLS_CREATE_LINK
:
1656 tdls_oper
->tdls_action
= cpu_to_le16(ACT_TDLS_CREATE
);
1658 case MWIFIEX_TDLS_CONFIG_LINK
:
1659 tdls_oper
->tdls_action
= cpu_to_le16(ACT_TDLS_CONFIG
);
1662 mwifiex_dbg(priv
->adapter
, ERROR
,
1663 "TDLS config params not available for %pM\n",
1668 *(__le16
*)pos
= cpu_to_le16(params
->capability
);
1669 config_len
+= sizeof(params
->capability
);
1671 qos_info
= params
->uapsd_queues
| (params
->max_sp
<< 5);
1672 wmm_qos_info
= (struct mwifiex_ie_types_qos_info
*)(pos
+
1674 wmm_qos_info
->header
.type
= cpu_to_le16(WLAN_EID_QOS_CAPA
);
1675 wmm_qos_info
->header
.len
= cpu_to_le16(sizeof(qos_info
));
1676 wmm_qos_info
->qos_info
= qos_info
;
1677 config_len
+= sizeof(struct mwifiex_ie_types_qos_info
);
1679 if (params
->ht_capa
) {
1680 ht_capab
= (struct mwifiex_ie_types_htcap
*)(pos
+
1682 ht_capab
->header
.type
=
1683 cpu_to_le16(WLAN_EID_HT_CAPABILITY
);
1684 ht_capab
->header
.len
=
1685 cpu_to_le16(sizeof(struct ieee80211_ht_cap
));
1686 memcpy(&ht_capab
->ht_cap
, params
->ht_capa
,
1687 sizeof(struct ieee80211_ht_cap
));
1688 config_len
+= sizeof(struct mwifiex_ie_types_htcap
);
1691 if (params
->supported_rates
&& params
->supported_rates_len
) {
1692 tlv_rates
= (struct host_cmd_tlv_rates
*)(pos
+
1694 tlv_rates
->header
.type
=
1695 cpu_to_le16(WLAN_EID_SUPP_RATES
);
1696 tlv_rates
->header
.len
=
1697 cpu_to_le16(params
->supported_rates_len
);
1698 memcpy(tlv_rates
->rates
, params
->supported_rates
,
1699 params
->supported_rates_len
);
1700 config_len
+= sizeof(struct host_cmd_tlv_rates
) +
1701 params
->supported_rates_len
;
1704 if (params
->ext_capab
&& params
->ext_capab_len
) {
1705 extcap
= (struct mwifiex_ie_types_extcap
*)(pos
+
1707 extcap
->header
.type
=
1708 cpu_to_le16(WLAN_EID_EXT_CAPABILITY
);
1709 extcap
->header
.len
= cpu_to_le16(params
->ext_capab_len
);
1710 memcpy(extcap
->ext_capab
, params
->ext_capab
,
1711 params
->ext_capab_len
);
1712 config_len
+= sizeof(struct mwifiex_ie_types_extcap
) +
1713 params
->ext_capab_len
;
1715 if (params
->vht_capa
) {
1716 vht_capab
= (struct mwifiex_ie_types_vhtcap
*)(pos
+
1718 vht_capab
->header
.type
=
1719 cpu_to_le16(WLAN_EID_VHT_CAPABILITY
);
1720 vht_capab
->header
.len
=
1721 cpu_to_le16(sizeof(struct ieee80211_vht_cap
));
1722 memcpy(&vht_capab
->vht_cap
, params
->vht_capa
,
1723 sizeof(struct ieee80211_vht_cap
));
1724 config_len
+= sizeof(struct mwifiex_ie_types_vhtcap
);
1727 aid
= (struct mwifiex_ie_types_aid
*)(pos
+ config_len
);
1728 aid
->header
.type
= cpu_to_le16(WLAN_EID_AID
);
1729 aid
->header
.len
= cpu_to_le16(sizeof(params
->aid
));
1730 aid
->aid
= cpu_to_le16(params
->aid
);
1731 config_len
+= sizeof(struct mwifiex_ie_types_aid
);
1734 timeout
= (void *)(pos
+ config_len
);
1735 timeout
->header
.type
= cpu_to_le16(TLV_TYPE_TDLS_IDLE_TIMEOUT
);
1736 timeout
->header
.len
= cpu_to_le16(sizeof(timeout
->value
));
1737 timeout
->value
= cpu_to_le16(MWIFIEX_TDLS_IDLE_TIMEOUT_IN_SEC
);
1738 config_len
+= sizeof(struct mwifiex_ie_types_tdls_idle_timeout
);
1742 mwifiex_dbg(priv
->adapter
, ERROR
, "Unknown TDLS operation\n");
1746 le16_add_cpu(&cmd
->size
, config_len
);
1751 /* This function prepares command of sdio rx aggr info. */
1752 static int mwifiex_cmd_sdio_rx_aggr_cfg(struct host_cmd_ds_command
*cmd
,
1753 u16 cmd_action
, void *data_buf
)
1755 struct host_cmd_sdio_sp_rx_aggr_cfg
*cfg
=
1756 &cmd
->params
.sdio_rx_aggr_cfg
;
1758 cmd
->command
= cpu_to_le16(HostCmd_CMD_SDIO_SP_RX_AGGR_CFG
);
1760 cpu_to_le16(sizeof(struct host_cmd_sdio_sp_rx_aggr_cfg
) +
1762 cfg
->action
= cmd_action
;
1763 if (cmd_action
== HostCmd_ACT_GEN_SET
)
1764 cfg
->enable
= *(u8
*)data_buf
;
1770 * This function prepares the commands before sending them to the firmware.
1772 * This is a generic function which calls specific command preparation
1773 * routines based upon the command number.
1775 int mwifiex_sta_prepare_cmd(struct mwifiex_private
*priv
, uint16_t cmd_no
,
1776 u16 cmd_action
, u32 cmd_oid
,
1777 void *data_buf
, void *cmd_buf
)
1779 struct host_cmd_ds_command
*cmd_ptr
= cmd_buf
;
1782 /* Prepare command */
1784 case HostCmd_CMD_GET_HW_SPEC
:
1785 ret
= mwifiex_cmd_get_hw_spec(priv
, cmd_ptr
);
1787 case HostCmd_CMD_CFG_DATA
:
1788 ret
= mwifiex_cmd_cfg_data(priv
, cmd_ptr
, data_buf
);
1790 case HostCmd_CMD_MAC_CONTROL
:
1791 ret
= mwifiex_cmd_mac_control(priv
, cmd_ptr
, cmd_action
,
1794 case HostCmd_CMD_802_11_MAC_ADDRESS
:
1795 ret
= mwifiex_cmd_802_11_mac_address(priv
, cmd_ptr
,
1798 case HostCmd_CMD_MAC_MULTICAST_ADR
:
1799 ret
= mwifiex_cmd_mac_multicast_adr(cmd_ptr
, cmd_action
,
1802 case HostCmd_CMD_TX_RATE_CFG
:
1803 ret
= mwifiex_cmd_tx_rate_cfg(priv
, cmd_ptr
, cmd_action
,
1806 case HostCmd_CMD_TXPWR_CFG
:
1807 ret
= mwifiex_cmd_tx_power_cfg(cmd_ptr
, cmd_action
,
1810 case HostCmd_CMD_RF_TX_PWR
:
1811 ret
= mwifiex_cmd_rf_tx_power(priv
, cmd_ptr
, cmd_action
,
1814 case HostCmd_CMD_RF_ANTENNA
:
1815 ret
= mwifiex_cmd_rf_antenna(priv
, cmd_ptr
, cmd_action
,
1818 case HostCmd_CMD_802_11_PS_MODE_ENH
:
1819 ret
= mwifiex_cmd_enh_power_mode(priv
, cmd_ptr
, cmd_action
,
1820 (uint16_t)cmd_oid
, data_buf
);
1822 case HostCmd_CMD_802_11_HS_CFG_ENH
:
1823 ret
= mwifiex_cmd_802_11_hs_cfg(priv
, cmd_ptr
, cmd_action
,
1824 (struct mwifiex_hs_config_param
*) data_buf
);
1826 case HostCmd_CMD_802_11_SCAN
:
1827 ret
= mwifiex_cmd_802_11_scan(cmd_ptr
, data_buf
);
1829 case HostCmd_CMD_802_11_BG_SCAN_QUERY
:
1830 ret
= mwifiex_cmd_802_11_bg_scan_query(cmd_ptr
);
1832 case HostCmd_CMD_802_11_ASSOCIATE
:
1833 ret
= mwifiex_cmd_802_11_associate(priv
, cmd_ptr
, data_buf
);
1835 case HostCmd_CMD_802_11_DEAUTHENTICATE
:
1836 ret
= mwifiex_cmd_802_11_deauthenticate(priv
, cmd_ptr
,
1839 case HostCmd_CMD_802_11_AD_HOC_START
:
1840 ret
= mwifiex_cmd_802_11_ad_hoc_start(priv
, cmd_ptr
,
1843 case HostCmd_CMD_802_11_GET_LOG
:
1844 ret
= mwifiex_cmd_802_11_get_log(cmd_ptr
);
1846 case HostCmd_CMD_802_11_AD_HOC_JOIN
:
1847 ret
= mwifiex_cmd_802_11_ad_hoc_join(priv
, cmd_ptr
,
1850 case HostCmd_CMD_802_11_AD_HOC_STOP
:
1851 ret
= mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr
);
1853 case HostCmd_CMD_RSSI_INFO
:
1854 ret
= mwifiex_cmd_802_11_rssi_info(priv
, cmd_ptr
, cmd_action
);
1856 case HostCmd_CMD_802_11_SNMP_MIB
:
1857 ret
= mwifiex_cmd_802_11_snmp_mib(priv
, cmd_ptr
, cmd_action
,
1860 case HostCmd_CMD_802_11_TX_RATE_QUERY
:
1862 cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY
);
1864 cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query
) +
1869 case HostCmd_CMD_VERSION_EXT
:
1870 cmd_ptr
->command
= cpu_to_le16(cmd_no
);
1871 cmd_ptr
->params
.verext
.version_str_sel
=
1872 (u8
) (*((u32
*) data_buf
));
1873 memcpy(&cmd_ptr
->params
, data_buf
,
1874 sizeof(struct host_cmd_ds_version_ext
));
1876 cpu_to_le16(sizeof(struct host_cmd_ds_version_ext
) +
1880 case HostCmd_CMD_MGMT_FRAME_REG
:
1881 cmd_ptr
->command
= cpu_to_le16(cmd_no
);
1882 cmd_ptr
->params
.reg_mask
.action
= cpu_to_le16(cmd_action
);
1883 cmd_ptr
->params
.reg_mask
.mask
= cpu_to_le32(*(u32
*)data_buf
);
1885 cpu_to_le16(sizeof(struct host_cmd_ds_mgmt_frame_reg
) +
1889 case HostCmd_CMD_REMAIN_ON_CHAN
:
1890 cmd_ptr
->command
= cpu_to_le16(cmd_no
);
1891 memcpy(&cmd_ptr
->params
, data_buf
,
1892 sizeof(struct host_cmd_ds_remain_on_chan
));
1894 cpu_to_le16(sizeof(struct host_cmd_ds_remain_on_chan
) +
1897 case HostCmd_CMD_11AC_CFG
:
1898 ret
= mwifiex_cmd_11ac_cfg(priv
, cmd_ptr
, cmd_action
, data_buf
);
1900 case HostCmd_CMD_P2P_MODE_CFG
:
1901 cmd_ptr
->command
= cpu_to_le16(cmd_no
);
1902 cmd_ptr
->params
.mode_cfg
.action
= cpu_to_le16(cmd_action
);
1903 cmd_ptr
->params
.mode_cfg
.mode
= cpu_to_le16(*(u16
*)data_buf
);
1905 cpu_to_le16(sizeof(struct host_cmd_ds_p2p_mode_cfg
) +
1908 case HostCmd_CMD_FUNC_INIT
:
1909 if (priv
->adapter
->hw_status
== MWIFIEX_HW_STATUS_RESET
)
1910 priv
->adapter
->hw_status
= MWIFIEX_HW_STATUS_READY
;
1911 cmd_ptr
->command
= cpu_to_le16(cmd_no
);
1912 cmd_ptr
->size
= cpu_to_le16(S_DS_GEN
);
1914 case HostCmd_CMD_FUNC_SHUTDOWN
:
1915 priv
->adapter
->hw_status
= MWIFIEX_HW_STATUS_RESET
;
1916 cmd_ptr
->command
= cpu_to_le16(cmd_no
);
1917 cmd_ptr
->size
= cpu_to_le16(S_DS_GEN
);
1919 case HostCmd_CMD_11N_ADDBA_REQ
:
1920 ret
= mwifiex_cmd_11n_addba_req(cmd_ptr
, data_buf
);
1922 case HostCmd_CMD_11N_DELBA
:
1923 ret
= mwifiex_cmd_11n_delba(cmd_ptr
, data_buf
);
1925 case HostCmd_CMD_11N_ADDBA_RSP
:
1926 ret
= mwifiex_cmd_11n_addba_rsp_gen(priv
, cmd_ptr
, data_buf
);
1928 case HostCmd_CMD_802_11_KEY_MATERIAL
:
1929 ret
= mwifiex_cmd_802_11_key_material(priv
, cmd_ptr
,
1930 cmd_action
, cmd_oid
,
1933 case HostCmd_CMD_802_11D_DOMAIN_INFO
:
1934 ret
= mwifiex_cmd_802_11d_domain_info(priv
, cmd_ptr
,
1937 case HostCmd_CMD_RECONFIGURE_TX_BUFF
:
1938 ret
= mwifiex_cmd_recfg_tx_buf(priv
, cmd_ptr
, cmd_action
,
1941 case HostCmd_CMD_AMSDU_AGGR_CTRL
:
1942 ret
= mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr
, cmd_action
,
1945 case HostCmd_CMD_11N_CFG
:
1946 ret
= mwifiex_cmd_11n_cfg(priv
, cmd_ptr
, cmd_action
, data_buf
);
1948 case HostCmd_CMD_WMM_GET_STATUS
:
1949 mwifiex_dbg(priv
->adapter
, CMD
,
1950 "cmd: WMM: WMM_GET_STATUS cmd sent\n");
1951 cmd_ptr
->command
= cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS
);
1953 cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status
) +
1957 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS
:
1958 ret
= mwifiex_cmd_ibss_coalescing_status(cmd_ptr
, cmd_action
,
1961 case HostCmd_CMD_802_11_SCAN_EXT
:
1962 ret
= mwifiex_cmd_802_11_scan_ext(priv
, cmd_ptr
, data_buf
);
1964 case HostCmd_CMD_MEM_ACCESS
:
1965 ret
= mwifiex_cmd_mem_access(cmd_ptr
, cmd_action
, data_buf
);
1967 case HostCmd_CMD_MAC_REG_ACCESS
:
1968 case HostCmd_CMD_BBP_REG_ACCESS
:
1969 case HostCmd_CMD_RF_REG_ACCESS
:
1970 case HostCmd_CMD_PMIC_REG_ACCESS
:
1971 case HostCmd_CMD_CAU_REG_ACCESS
:
1972 case HostCmd_CMD_802_11_EEPROM_ACCESS
:
1973 ret
= mwifiex_cmd_reg_access(cmd_ptr
, cmd_action
, data_buf
);
1975 case HostCmd_CMD_SET_BSS_MODE
:
1976 cmd_ptr
->command
= cpu_to_le16(cmd_no
);
1977 if (priv
->bss_mode
== NL80211_IFTYPE_ADHOC
)
1978 cmd_ptr
->params
.bss_mode
.con_type
=
1979 CONNECTION_TYPE_ADHOC
;
1980 else if (priv
->bss_mode
== NL80211_IFTYPE_STATION
)
1981 cmd_ptr
->params
.bss_mode
.con_type
=
1982 CONNECTION_TYPE_INFRA
;
1983 else if (priv
->bss_mode
== NL80211_IFTYPE_AP
)
1984 cmd_ptr
->params
.bss_mode
.con_type
= CONNECTION_TYPE_AP
;
1985 cmd_ptr
->size
= cpu_to_le16(sizeof(struct
1986 host_cmd_ds_set_bss_mode
) + S_DS_GEN
);
1989 case HostCmd_CMD_PCIE_DESC_DETAILS
:
1990 ret
= mwifiex_cmd_pcie_host_spec(priv
, cmd_ptr
, cmd_action
);
1992 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT
:
1993 ret
= mwifiex_cmd_802_11_subsc_evt(priv
, cmd_ptr
, data_buf
);
1995 case HostCmd_CMD_MEF_CFG
:
1996 ret
= mwifiex_cmd_mef_cfg(priv
, cmd_ptr
, data_buf
);
1998 case HostCmd_CMD_COALESCE_CFG
:
1999 ret
= mwifiex_cmd_coalesce_cfg(priv
, cmd_ptr
, cmd_action
,
2002 case HostCmd_CMD_TDLS_OPER
:
2003 ret
= mwifiex_cmd_tdls_oper(priv
, cmd_ptr
, data_buf
);
2005 case HostCmd_CMD_TDLS_CONFIG
:
2006 ret
= mwifiex_cmd_tdls_config(priv
, cmd_ptr
, cmd_action
,
2009 case HostCmd_CMD_CHAN_REPORT_REQUEST
:
2010 ret
= mwifiex_cmd_issue_chan_report_request(priv
, cmd_ptr
,
2013 case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG
:
2014 ret
= mwifiex_cmd_sdio_rx_aggr_cfg(cmd_ptr
, cmd_action
,
2018 mwifiex_dbg(priv
->adapter
, ERROR
,
2019 "PREP_CMD: unknown cmd- %#x\n", cmd_no
);
2027 * This function issues commands to initialize firmware.
2029 * This is called after firmware download to bring the card to
2031 * Function is also called during reinitialization of virtual
2034 * The following commands are issued sequentially -
2035 * - Set PCI-Express host buffer configuration (PCIE only)
2036 * - Function init (for first interface only)
2037 * - Read MAC address (for first interface only)
2038 * - Reconfigure Tx buffer size (for first interface only)
2039 * - Enable auto deep sleep (for first interface only)
2042 * - Set IBSS coalescing status
2043 * - Set AMSDU aggregation control
2045 * - Set MAC control (this must be the last command to initialize firmware)
2047 int mwifiex_sta_init_cmd(struct mwifiex_private
*priv
, u8 first_sta
, bool init
)
2049 struct mwifiex_adapter
*adapter
= priv
->adapter
;
2052 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl
;
2053 struct mwifiex_ds_auto_ds auto_ds
;
2054 enum state_11d_t state_11d
;
2055 struct mwifiex_ds_11n_tx_cfg tx_cfg
;
2056 u8 sdio_sp_rx_aggr_enable
;
2059 if (priv
->adapter
->iface_type
== MWIFIEX_PCIE
) {
2060 ret
= mwifiex_send_cmd(priv
,
2061 HostCmd_CMD_PCIE_DESC_DETAILS
,
2062 HostCmd_ACT_GEN_SET
, 0, NULL
,
2068 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_FUNC_INIT
,
2069 HostCmd_ACT_GEN_SET
, 0, NULL
, true);
2073 /* Download calibration data to firmware.
2074 * The cal-data can be read from device tree and/or
2075 * a configuration file and downloaded to firmware.
2078 of_find_node_by_name(NULL
, "marvell_cfgdata");
2079 if (adapter
->dt_node
) {
2080 ret
= mwifiex_dnld_dt_cfgdata(priv
, adapter
->dt_node
,
2086 if (adapter
->cal_data
) {
2087 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_CFG_DATA
,
2088 HostCmd_ACT_GEN_SET
, 0, NULL
,
2094 /* Read MAC address from HW */
2095 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_GET_HW_SPEC
,
2096 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
2100 /** Set SDIO Single Port RX Aggr Info */
2101 if (priv
->adapter
->iface_type
== MWIFIEX_SDIO
&&
2102 ISSUPP_SDIO_SPA_ENABLED(priv
->adapter
->fw_cap_info
)) {
2103 sdio_sp_rx_aggr_enable
= true;
2104 ret
= mwifiex_send_cmd(priv
,
2105 HostCmd_CMD_SDIO_SP_RX_AGGR_CFG
,
2106 HostCmd_ACT_GEN_SET
, 0,
2107 &sdio_sp_rx_aggr_enable
,
2110 mwifiex_dbg(priv
->adapter
, ERROR
,
2111 "error while enabling SP aggregation..disable it");
2112 adapter
->sdio_rx_aggr_enable
= false;
2116 /* Reconfigure tx buf size */
2117 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_RECONFIGURE_TX_BUFF
,
2118 HostCmd_ACT_GEN_SET
, 0,
2119 &priv
->adapter
->tx_buf_size
, true);
2123 if (priv
->bss_type
!= MWIFIEX_BSS_TYPE_UAP
) {
2124 /* Enable IEEE PS by default */
2125 priv
->adapter
->ps_mode
= MWIFIEX_802_11_POWER_MODE_PSP
;
2126 ret
= mwifiex_send_cmd(priv
,
2127 HostCmd_CMD_802_11_PS_MODE_ENH
,
2128 EN_AUTO_PS
, BITMAP_STA_PS
, NULL
,
2136 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_TX_RATE_CFG
,
2137 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
2140 priv
->data_rate
= 0;
2143 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_RF_TX_PWR
,
2144 HostCmd_ACT_GEN_GET
, 0, NULL
, true);
2148 if (priv
->bss_type
== MWIFIEX_BSS_TYPE_STA
) {
2149 /* set ibss coalescing_status */
2150 ret
= mwifiex_send_cmd(
2152 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS
,
2153 HostCmd_ACT_GEN_SET
, 0, &enable
, true);
2158 memset(&amsdu_aggr_ctrl
, 0, sizeof(amsdu_aggr_ctrl
));
2159 amsdu_aggr_ctrl
.enable
= true;
2160 /* Send request to firmware */
2161 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_AMSDU_AGGR_CTRL
,
2162 HostCmd_ACT_GEN_SET
, 0,
2163 &amsdu_aggr_ctrl
, true);
2166 /* MAC Control must be the last command in init_fw */
2167 /* set MAC Control */
2168 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_MAC_CONTROL
,
2169 HostCmd_ACT_GEN_SET
, 0,
2170 &priv
->curr_pkt_filter
, true);
2174 if (!disable_auto_ds
&&
2175 first_sta
&& priv
->adapter
->iface_type
!= MWIFIEX_USB
&&
2176 priv
->bss_type
!= MWIFIEX_BSS_TYPE_UAP
) {
2177 /* Enable auto deep sleep */
2178 auto_ds
.auto_ds
= DEEP_SLEEP_ON
;
2179 auto_ds
.idle_time
= DEEP_SLEEP_IDLE_TIME
;
2180 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_PS_MODE_ENH
,
2181 EN_AUTO_PS
, BITMAP_AUTO_DS
,
2187 if (priv
->bss_type
!= MWIFIEX_BSS_TYPE_UAP
) {
2188 /* Send cmd to FW to enable/disable 11D function */
2189 state_11d
= ENABLE_11D
;
2190 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_802_11_SNMP_MIB
,
2191 HostCmd_ACT_GEN_SET
, DOT11D_I
,
2194 mwifiex_dbg(priv
->adapter
, ERROR
,
2195 "11D: failed to enable 11D\n");
2198 /* Send cmd to FW to configure 11n specific configuration
2199 * (Short GI, Channel BW, Green field support etc.) for transmit
2201 tx_cfg
.tx_htcap
= MWIFIEX_FW_DEF_HTTXCFG
;
2202 ret
= mwifiex_send_cmd(priv
, HostCmd_CMD_11N_CFG
,
2203 HostCmd_ACT_GEN_SET
, 0, &tx_cfg
, true);
2206 /* set last_init_cmd before sending the command */
2207 priv
->adapter
->last_init_cmd
= HostCmd_CMD_11N_CFG
;