blob: e90c34d9c63d550223914e30c4087cd825e644a9 [file] [log] [blame]
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001/*
2 * Marvell Wireless LAN device driver: station command handling
3 *
4 * Copyright (C) 2011, Marvell International Ltd.
5 *
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.
13 *
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.
18 */
19
20#include "decl.h"
21#include "ioctl.h"
22#include "util.h"
23#include "fw.h"
24#include "main.h"
25#include "wmm.h"
26#include "11n.h"
27
28/*
29 * This function prepares command to set/get RSSI information.
30 *
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
36 */
37static int
38mwifiex_cmd_802_11_rssi_info(struct mwifiex_private *priv,
39 struct host_cmd_ds_command *cmd, u16 cmd_action)
40{
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) +
43 S_DS_GEN);
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);
47
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;
56 priv->bcn_nf_avg = 0;
57
58 return 0;
59}
60
61/*
62 * This function prepares command to set MAC control.
63 *
64 * Preparation includes -
65 * - Setting command ID, action and proper size
66 * - Ensuring correct endian-ness
67 */
68static int mwifiex_cmd_mac_control(struct mwifiex_private *priv,
69 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -070070 u16 cmd_action, u16 *action)
Bing Zhao5e6e3a92011-03-21 18:00:50 -070071{
72 struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl;
Bing Zhao5e6e3a92011-03-21 18:00:50 -070073
74 if (cmd_action != HostCmd_ACT_GEN_SET) {
75 dev_err(priv->adapter->dev,
76 "mac_control: only support set cmd\n");
77 return -1;
78 }
79
80 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_CONTROL);
81 cmd->size =
82 cpu_to_le16(sizeof(struct host_cmd_ds_mac_control) + S_DS_GEN);
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -070083 mac_ctrl->action = cpu_to_le16(*action);
Bing Zhao5e6e3a92011-03-21 18:00:50 -070084
85 return 0;
86}
87
88/*
89 * This function prepares command to set/get SNMP MIB.
90 *
91 * Preparation includes -
92 * - Setting command ID, action and proper size
93 * - Setting SNMP MIB OID number and value
94 * (as required)
95 * - Ensuring correct endian-ness
96 *
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
102 */
103static 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,
Amitkumar Karwarf3c8d252012-02-02 20:48:57 -0800106 u16 *ul_temp)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700107{
108 struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700109
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)
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700113 - 1 + S_DS_GEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700114
Amitkumar Karwarf3c8d252012-02-02 20:48:57 -0800115 snmp_mib->oid = cpu_to_le16((u16)cmd_oid);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700116 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);
Amitkumar Karwarf3c8d252012-02-02 20:48:57 -0800119 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));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700125 }
126
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700127 dev_dbg(priv->adapter->dev,
128 "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x,"
129 " Value=0x%x\n",
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700130 cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size),
131 le16_to_cpu(*(__le16 *) snmp_mib->value));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700132 return 0;
133}
134
135/*
136 * This function prepares command to get log.
137 *
138 * Preparation includes -
139 * - Setting command ID and proper size
140 * - Ensuring correct endian-ness
141 */
142static int
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700143mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700144{
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) +
147 S_DS_GEN);
148 return 0;
149}
150
151/*
152 * This function prepares command to set/get Tx data rate configuration.
153 *
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
159 */
160static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv,
161 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700162 u16 cmd_action, u16 *pbitmap_rates)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700163{
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;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700167 u32 i;
168
169 cmd->command = cpu_to_le16(HostCmd_CMD_TX_RATE_CFG);
170
171 rate_cfg->action = cpu_to_le16(cmd_action);
172 rate_cfg->cfg_index = 0;
173
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);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700177 rate_scope->length = cpu_to_le16
178 (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700179 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]);
182 for (i = 0;
183 i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16);
184 i++)
185 rate_scope->ht_mcs_rate_bitmap[i] =
186 cpu_to_le16(pbitmap_rates[2 + i]);
187 } else {
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]);
192 for (i = 0;
193 i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16);
194 i++)
195 rate_scope->ht_mcs_rate_bitmap[i] =
196 cpu_to_le16(priv->bitmap_rates[2 + i]);
197 }
198
199 rate_drop = (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope +
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700200 sizeof(struct mwifiex_rate_scope));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700201 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;
204
205 cmd->size =
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));
209
210 return 0;
211}
212
213/*
214 * This function prepares command to set/get Tx power configuration.
215 *
216 * Preparation includes -
217 * - Setting command ID, action and proper size
218 * - Setting Tx power mode, power group TLV
219 * (as required)
220 * - Ensuring correct endian-ness
221 */
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700222static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700223 u16 cmd_action,
224 struct host_cmd_ds_txpwr_cfg *txp)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700225{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700226 struct mwifiex_types_power_group *pg_tlv;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700227 struct host_cmd_ds_txpwr_cfg *cmd_txp_cfg = &cmd->params.txp_cfg;
228
229 cmd->command = cpu_to_le16(HostCmd_CMD_TXPWR_CFG);
230 cmd->size =
231 cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg));
232 switch (cmd_action) {
233 case HostCmd_ACT_GEN_SET:
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700234 if (txp->mode) {
235 pg_tlv = (struct mwifiex_types_power_group
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700236 *) ((unsigned long) txp +
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700237 sizeof(struct host_cmd_ds_txpwr_cfg));
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700238 memmove(cmd_txp_cfg, txp,
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700239 sizeof(struct host_cmd_ds_txpwr_cfg) +
240 sizeof(struct mwifiex_types_power_group) +
241 pg_tlv->length);
242
243 pg_tlv = (struct mwifiex_types_power_group *) ((u8 *)
244 cmd_txp_cfg +
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) +
248 pg_tlv->length);
249 } else {
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700250 memmove(cmd_txp_cfg, txp, sizeof(*txp));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700251 }
252 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
253 break;
254 case HostCmd_ACT_GEN_GET:
255 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
256 break;
257 }
258
259 return 0;
260}
261
262/*
263 * This function prepares command to set Host Sleep configuration.
264 *
265 * Preparation includes -
266 * - Setting command ID and proper size
267 * - Setting Host Sleep action, conditions, ARP filters
268 * (as required)
269 * - Ensuring correct endian-ness
270 */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700271static int
272mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv,
273 struct host_cmd_ds_command *cmd,
274 u16 cmd_action,
275 struct mwifiex_hs_config_param *hscfg_param)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700276{
277 struct mwifiex_adapter *adapter = priv->adapter;
278 struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg;
279 u16 hs_activate = false;
280
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700281 if (!hscfg_param)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700282 /* New Activate command */
283 hs_activate = true;
284 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH);
285
286 if (!hs_activate &&
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700287 (hscfg_param->conditions != cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) &&
288 ((adapter->arp_filter_size > 0) &&
289 (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700290 dev_dbg(adapter->dev,
291 "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n",
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700292 adapter->arp_filter_size);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700293 memcpy(((u8 *) hs_cfg) +
294 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh),
295 adapter->arp_filter, adapter->arp_filter_size);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700296 cmd->size = cpu_to_le16
297 (adapter->arp_filter_size +
298 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh)
299 + S_DS_GEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700300 } else {
301 cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700302 host_cmd_ds_802_11_hs_cfg_enh));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700303 }
304 if (hs_activate) {
305 hs_cfg->action = cpu_to_le16(HS_ACTIVATE);
306 hs_cfg->params.hs_activate.resp_ctrl = RESP_NEEDED;
307 } else {
308 hs_cfg->action = cpu_to_le16(HS_CONFIGURE);
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700309 hs_cfg->params.hs_config.conditions = hscfg_param->conditions;
310 hs_cfg->params.hs_config.gpio = hscfg_param->gpio;
311 hs_cfg->params.hs_config.gap = hscfg_param->gap;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700312 dev_dbg(adapter->dev,
313 "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n",
314 hs_cfg->params.hs_config.conditions,
315 hs_cfg->params.hs_config.gpio,
316 hs_cfg->params.hs_config.gap);
317 }
318
319 return 0;
320}
321
322/*
323 * This function prepares command to set/get MAC address.
324 *
325 * Preparation includes -
326 * - Setting command ID, action and proper size
327 * - Setting MAC address (for SET only)
328 * - Ensuring correct endian-ness
329 */
330static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv,
331 struct host_cmd_ds_command *cmd,
332 u16 cmd_action)
333{
334 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS);
335 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address) +
336 S_DS_GEN);
337 cmd->result = 0;
338
339 cmd->params.mac_addr.action = cpu_to_le16(cmd_action);
340
341 if (cmd_action == HostCmd_ACT_GEN_SET)
342 memcpy(cmd->params.mac_addr.mac_addr, priv->curr_addr,
343 ETH_ALEN);
344 return 0;
345}
346
347/*
348 * This function prepares command to set MAC multicast address.
349 *
350 * Preparation includes -
351 * - Setting command ID, action and proper size
352 * - Setting MAC multicast address
353 * - Ensuring correct endian-ness
354 */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700355static int
356mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd,
357 u16 cmd_action,
358 struct mwifiex_multicast_list *mcast_list)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700359{
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700360 struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr;
361
362 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) +
363 S_DS_GEN);
364 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR);
365
366 mcast_addr->action = cpu_to_le16(cmd_action);
367 mcast_addr->num_of_adrs =
368 cpu_to_le16((u16) mcast_list->num_multicast_addr);
369 memcpy(mcast_addr->mac_list, mcast_list->mac_list,
370 mcast_list->num_multicast_addr * ETH_ALEN);
371
372 return 0;
373}
374
375/*
376 * This function prepares command to deauthenticate.
377 *
378 * Preparation includes -
379 * - Setting command ID and proper size
380 * - Setting AP MAC address and reason code
381 * - Ensuring correct endian-ness
382 */
383static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv,
384 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700385 u8 *mac)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700386{
387 struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth;
388
389 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE);
390 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate)
391 + S_DS_GEN);
392
393 /* Set AP MAC address */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700394 memcpy(deauth->mac_addr, mac, ETH_ALEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700395
396 dev_dbg(priv->adapter->dev, "cmd: Deauth: %pM\n", deauth->mac_addr);
397
398 deauth->reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING);
399
400 return 0;
401}
402
403/*
404 * This function prepares command to stop Ad-Hoc network.
405 *
406 * Preparation includes -
407 * - Setting command ID and proper size
408 * - Ensuring correct endian-ness
409 */
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700410static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command *cmd)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700411{
412 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP);
413 cmd->size = cpu_to_le16(S_DS_GEN);
414 return 0;
415}
416
417/*
418 * This function sets WEP key(s) to key parameter TLV(s).
419 *
420 * Multi-key parameter TLVs are supported, so we can send multiple
421 * WEP keys in a single buffer.
422 */
423static int
424mwifiex_set_keyparamset_wep(struct mwifiex_private *priv,
425 struct mwifiex_ie_type_key_param_set *key_param_set,
426 u16 *key_param_len)
427{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700428 int cur_key_param_len;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700429 u8 i;
430
431 /* Multi-key_param_set TLV is supported */
432 for (i = 0; i < NUM_WEP_KEYS; i++) {
433 if ((priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP40) ||
434 (priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP104)) {
435 key_param_set->type =
436 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
437/* Key_param_set WEP fixed length */
438#define KEYPARAMSET_WEP_FIXED_LEN 8
439 key_param_set->length = cpu_to_le16((u16)
440 (priv->wep_key[i].
441 key_length +
442 KEYPARAMSET_WEP_FIXED_LEN));
443 key_param_set->key_type_id =
444 cpu_to_le16(KEY_TYPE_ID_WEP);
445 key_param_set->key_info =
Yogesh Ashok Powar6a35a0a2011-04-06 16:46:56 -0700446 cpu_to_le16(KEY_ENABLED | KEY_UNICAST |
447 KEY_MCAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700448 key_param_set->key_len =
449 cpu_to_le16(priv->wep_key[i].key_length);
450 /* Set WEP key index */
451 key_param_set->key[0] = i;
452 /* Set default Tx key flag */
453 if (i ==
454 (priv->
455 wep_key_curr_index & HostCmd_WEP_KEY_INDEX_MASK))
456 key_param_set->key[1] = 1;
457 else
458 key_param_set->key[1] = 0;
459 memmove(&key_param_set->key[2],
460 priv->wep_key[i].key_material,
461 priv->wep_key[i].key_length);
462
463 cur_key_param_len = priv->wep_key[i].key_length +
464 KEYPARAMSET_WEP_FIXED_LEN +
465 sizeof(struct mwifiex_ie_types_header);
466 *key_param_len += (u16) cur_key_param_len;
467 key_param_set =
468 (struct mwifiex_ie_type_key_param_set *)
469 ((u8 *)key_param_set +
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700470 cur_key_param_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700471 } else if (!priv->wep_key[i].key_length) {
472 continue;
473 } else {
474 dev_err(priv->adapter->dev,
475 "key%d Length = %d is incorrect\n",
476 (i + 1), priv->wep_key[i].key_length);
477 return -1;
478 }
479 }
480
481 return 0;
482}
483
484/*
485 * This function prepares command to set/get/reset network key(s).
486 *
487 * Preparation includes -
488 * - Setting command ID, action and proper size
489 * - Setting WEP keys, WAPI keys or WPA keys along with required
490 * encryption (TKIP, AES) (as required)
491 * - Ensuring correct endian-ness
492 */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700493static int
494mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv,
495 struct host_cmd_ds_command *cmd,
496 u16 cmd_action, u32 cmd_oid,
497 struct mwifiex_ds_encrypt_key *enc_key)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700498{
499 struct host_cmd_ds_802_11_key_material *key_material =
500 &cmd->params.key_material;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700501 u16 key_param_len = 0;
502 int ret = 0;
503 const u8 bc_mac[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
504
505 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL);
506 key_material->action = cpu_to_le16(cmd_action);
507
508 if (cmd_action == HostCmd_ACT_GEN_GET) {
509 cmd->size =
510 cpu_to_le16(sizeof(key_material->action) + S_DS_GEN);
511 return ret;
512 }
513
514 if (!enc_key) {
515 memset(&key_material->key_param_set, 0,
516 (NUM_WEP_KEYS *
517 sizeof(struct mwifiex_ie_type_key_param_set)));
518 ret = mwifiex_set_keyparamset_wep(priv,
519 &key_material->key_param_set,
520 &key_param_len);
521 cmd->size = cpu_to_le16(key_param_len +
522 sizeof(key_material->action) + S_DS_GEN);
523 return ret;
524 } else
525 memset(&key_material->key_param_set, 0,
526 sizeof(struct mwifiex_ie_type_key_param_set));
527 if (enc_key->is_wapi_key) {
528 dev_dbg(priv->adapter->dev, "info: Set WAPI Key\n");
529 key_material->key_param_set.key_type_id =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700530 cpu_to_le16(KEY_TYPE_ID_WAPI);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700531 if (cmd_oid == KEY_INFO_ENABLED)
532 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700533 cpu_to_le16(KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700534 else
535 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700536 cpu_to_le16(!KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700537
538 key_material->key_param_set.key[0] = enc_key->key_index;
539 if (!priv->sec_info.wapi_key_on)
540 key_material->key_param_set.key[1] = 1;
541 else
542 /* set 0 when re-key */
543 key_material->key_param_set.key[1] = 0;
544
545 if (0 != memcmp(enc_key->mac_addr, bc_mac, sizeof(bc_mac))) {
546 /* WAPI pairwise key: unicast */
547 key_material->key_param_set.key_info |=
Yogesh Ashok Powar6a35a0a2011-04-06 16:46:56 -0700548 cpu_to_le16(KEY_UNICAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700549 } else { /* WAPI group key: multicast */
550 key_material->key_param_set.key_info |=
Yogesh Ashok Powar6a35a0a2011-04-06 16:46:56 -0700551 cpu_to_le16(KEY_MCAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700552 priv->sec_info.wapi_key_on = true;
553 }
554
555 key_material->key_param_set.type =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700556 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700557 key_material->key_param_set.key_len =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700558 cpu_to_le16(WAPI_KEY_LEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700559 memcpy(&key_material->key_param_set.key[2],
560 enc_key->key_material, enc_key->key_len);
561 memcpy(&key_material->key_param_set.key[2 + enc_key->key_len],
562 enc_key->wapi_rxpn, WAPI_RXPN_LEN);
563 key_material->key_param_set.length =
564 cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN);
565
566 key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) +
567 sizeof(struct mwifiex_ie_types_header);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700568 cmd->size = cpu_to_le16(sizeof(key_material->action)
569 + S_DS_GEN + key_param_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700570 return ret;
571 }
572 if (enc_key->key_len == WLAN_KEY_LEN_CCMP) {
573 dev_dbg(priv->adapter->dev, "cmd: WPA_AES\n");
574 key_material->key_param_set.key_type_id =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700575 cpu_to_le16(KEY_TYPE_ID_AES);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700576 if (cmd_oid == KEY_INFO_ENABLED)
577 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700578 cpu_to_le16(KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700579 else
580 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700581 cpu_to_le16(!KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700582
583 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
584 /* AES pairwise key: unicast */
585 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700586 cpu_to_le16(KEY_UNICAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700587 else /* AES group key: multicast */
588 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700589 cpu_to_le16(KEY_MCAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700590 } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) {
591 dev_dbg(priv->adapter->dev, "cmd: WPA_TKIP\n");
592 key_material->key_param_set.key_type_id =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700593 cpu_to_le16(KEY_TYPE_ID_TKIP);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700594 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700595 cpu_to_le16(KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700596
597 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
598 /* TKIP pairwise key: unicast */
599 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700600 cpu_to_le16(KEY_UNICAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700601 else /* TKIP group key: multicast */
602 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700603 cpu_to_le16(KEY_MCAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700604 }
605
606 if (key_material->key_param_set.key_type_id) {
607 key_material->key_param_set.type =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700608 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700609 key_material->key_param_set.key_len =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700610 cpu_to_le16((u16) enc_key->key_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700611 memcpy(key_material->key_param_set.key, enc_key->key_material,
612 enc_key->key_len);
613 key_material->key_param_set.length =
614 cpu_to_le16((u16) enc_key->key_len +
615 KEYPARAMSET_FIXED_LEN);
616
617 key_param_len = (u16) (enc_key->key_len + KEYPARAMSET_FIXED_LEN)
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700618 + sizeof(struct mwifiex_ie_types_header);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700619
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700620 cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN
621 + key_param_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700622 }
623
624 return ret;
625}
626
627/*
628 * This function prepares command to set/get 11d domain information.
629 *
630 * Preparation includes -
631 * - Setting command ID, action and proper size
632 * - Setting domain information fields (for SET only)
633 * - Ensuring correct endian-ness
634 */
635static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv,
636 struct host_cmd_ds_command *cmd,
637 u16 cmd_action)
638{
639 struct mwifiex_adapter *adapter = priv->adapter;
640 struct host_cmd_ds_802_11d_domain_info *domain_info =
641 &cmd->params.domain_info;
642 struct mwifiex_ietypes_domain_param_set *domain =
643 &domain_info->domain;
644 u8 no_of_triplet = adapter->domain_reg.no_of_triplet;
645
646 dev_dbg(adapter->dev, "info: 11D: no_of_triplet=0x%x\n", no_of_triplet);
647
648 cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO);
649 domain_info->action = cpu_to_le16(cmd_action);
650 if (cmd_action == HostCmd_ACT_GEN_GET) {
651 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
652 return 0;
653 }
654
655 /* Set domain info fields */
656 domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY);
657 memcpy(domain->country_code, adapter->domain_reg.country_code,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700658 sizeof(domain->country_code));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700659
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700660 domain->header.len =
661 cpu_to_le16((no_of_triplet *
662 sizeof(struct ieee80211_country_ie_triplet))
663 + sizeof(domain->country_code));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700664
665 if (no_of_triplet) {
666 memcpy(domain->triplet, adapter->domain_reg.triplet,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700667 no_of_triplet * sizeof(struct
668 ieee80211_country_ie_triplet));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700669
670 cmd->size = cpu_to_le16(sizeof(domain_info->action) +
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700671 le16_to_cpu(domain->header.len) +
672 sizeof(struct mwifiex_ie_types_header)
673 + S_DS_GEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700674 } else {
675 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
676 }
677
678 return 0;
679}
680
681/*
682 * This function prepares command to set/get RF channel.
683 *
684 * Preparation includes -
685 * - Setting command ID, action and proper size
686 * - Setting RF type and current RF channel (for SET only)
687 * - Ensuring correct endian-ness
688 */
689static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv,
690 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700691 u16 cmd_action, u16 *channel)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700692{
693 struct host_cmd_ds_802_11_rf_channel *rf_chan =
694 &cmd->params.rf_channel;
695 uint16_t rf_type = le16_to_cpu(rf_chan->rf_type);
696
697 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_CHANNEL);
698 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rf_channel)
699 + S_DS_GEN);
700
701 if (cmd_action == HostCmd_ACT_GEN_SET) {
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700702 if ((priv->adapter->adhoc_start_band & BAND_A) ||
703 (priv->adapter->adhoc_start_band & BAND_AN))
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700704 rf_chan->rf_type =
705 cpu_to_le16(HostCmd_SCAN_RADIO_TYPE_A);
706
707 rf_type = le16_to_cpu(rf_chan->rf_type);
Amitkumar Karwar21c3ba32011-12-20 23:47:21 -0800708 SET_SECONDARYCHAN(rf_type, priv->adapter->sec_chan_offset);
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700709 rf_chan->current_channel = cpu_to_le16(*channel);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700710 }
711 rf_chan->action = cpu_to_le16(cmd_action);
712 return 0;
713}
714
715/*
716 * This function prepares command to set/get IBSS coalescing status.
717 *
718 * Preparation includes -
719 * - Setting command ID, action and proper size
720 * - Setting status to enable or disable (for SET only)
721 * - Ensuring correct endian-ness
722 */
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700723static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700724 u16 cmd_action, u16 *enable)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700725{
726 struct host_cmd_ds_802_11_ibss_status *ibss_coal =
727 &(cmd->params.ibss_coalescing);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700728
729 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS);
730 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) +
731 S_DS_GEN);
732 cmd->result = 0;
733 ibss_coal->action = cpu_to_le16(cmd_action);
734
735 switch (cmd_action) {
736 case HostCmd_ACT_GEN_SET:
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700737 if (enable)
738 ibss_coal->enable = cpu_to_le16(*enable);
Dan Carpentera5e5aa62011-06-24 16:33:35 +0300739 else
740 ibss_coal->enable = 0;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700741 break;
742
743 /* In other case.. Nothing to do */
744 case HostCmd_ACT_GEN_GET:
745 default:
746 break;
747 }
748
749 return 0;
750}
751
752/*
753 * This function prepares command to set/get register value.
754 *
755 * Preparation includes -
756 * - Setting command ID, action and proper size
757 * - Setting register offset (for both GET and SET) and
758 * register value (for SET only)
759 * - Ensuring correct endian-ness
760 *
761 * The following type of registers can be accessed with this function -
762 * - MAC register
763 * - BBP register
764 * - RF register
765 * - PMIC register
766 * - CAU register
767 * - EEPROM
768 */
769static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd,
770 u16 cmd_action, void *data_buf)
771{
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700772 struct mwifiex_ds_reg_rw *reg_rw = data_buf;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700773
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700774 switch (le16_to_cpu(cmd->command)) {
775 case HostCmd_CMD_MAC_REG_ACCESS:
776 {
777 struct host_cmd_ds_mac_reg_access *mac_reg;
778
779 cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN);
780 mac_reg = (struct host_cmd_ds_mac_reg_access *) &cmd->
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700781 params.mac_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700782 mac_reg->action = cpu_to_le16(cmd_action);
783 mac_reg->offset =
784 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
785 mac_reg->value = reg_rw->value;
786 break;
787 }
788 case HostCmd_CMD_BBP_REG_ACCESS:
789 {
790 struct host_cmd_ds_bbp_reg_access *bbp_reg;
791
792 cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700793 bbp_reg = (struct host_cmd_ds_bbp_reg_access *)
794 &cmd->params.bbp_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700795 bbp_reg->action = cpu_to_le16(cmd_action);
796 bbp_reg->offset =
797 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
798 bbp_reg->value = (u8) le32_to_cpu(reg_rw->value);
799 break;
800 }
801 case HostCmd_CMD_RF_REG_ACCESS:
802 {
803 struct host_cmd_ds_rf_reg_access *rf_reg;
804
805 cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700806 rf_reg = (struct host_cmd_ds_rf_reg_access *)
807 &cmd->params.rf_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700808 rf_reg->action = cpu_to_le16(cmd_action);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700809 rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700810 rf_reg->value = (u8) le32_to_cpu(reg_rw->value);
811 break;
812 }
813 case HostCmd_CMD_PMIC_REG_ACCESS:
814 {
815 struct host_cmd_ds_pmic_reg_access *pmic_reg;
816
817 cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN);
818 pmic_reg = (struct host_cmd_ds_pmic_reg_access *) &cmd->
819 params.pmic_reg;
820 pmic_reg->action = cpu_to_le16(cmd_action);
821 pmic_reg->offset =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700822 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700823 pmic_reg->value = (u8) le32_to_cpu(reg_rw->value);
824 break;
825 }
826 case HostCmd_CMD_CAU_REG_ACCESS:
827 {
828 struct host_cmd_ds_rf_reg_access *cau_reg;
829
830 cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700831 cau_reg = (struct host_cmd_ds_rf_reg_access *)
832 &cmd->params.rf_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700833 cau_reg->action = cpu_to_le16(cmd_action);
834 cau_reg->offset =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700835 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700836 cau_reg->value = (u8) le32_to_cpu(reg_rw->value);
837 break;
838 }
839 case HostCmd_CMD_802_11_EEPROM_ACCESS:
840 {
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700841 struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700842 struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom =
843 (struct host_cmd_ds_802_11_eeprom_access *)
844 &cmd->params.eeprom;
845
846 cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN);
847 cmd_eeprom->action = cpu_to_le16(cmd_action);
848 cmd_eeprom->offset = rd_eeprom->offset;
849 cmd_eeprom->byte_count = rd_eeprom->byte_count;
850 cmd_eeprom->value = 0;
851 break;
852 }
853 default:
854 return -1;
855 }
856
857 return 0;
858}
859
860/*
Amitkumar Karward930fae2011-10-11 17:41:21 -0700861 * This function prepares command to set PCI-Express
862 * host buffer configuration
863 *
864 * Preparation includes -
865 * - Setting command ID, action and proper size
866 * - Setting host buffer configuration
867 * - Ensuring correct endian-ness
868 */
869static int
870mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700871 struct host_cmd_ds_command *cmd, u16 action)
Amitkumar Karward930fae2011-10-11 17:41:21 -0700872{
873 struct host_cmd_ds_pcie_details *host_spec =
874 &cmd->params.pcie_host_spec;
875 struct pcie_service_card *card = priv->adapter->card;
876 phys_addr_t *buf_pa;
877
878 cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS);
879 cmd->size = cpu_to_le16(sizeof(struct
880 host_cmd_ds_pcie_details) + S_DS_GEN);
881 cmd->result = 0;
882
883 memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details));
884
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700885 if (action != HostCmd_ACT_GEN_SET)
886 return 0;
887
888 /* Send the ring base addresses and count to firmware */
889 host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase);
890 host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32);
891 host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD;
892 host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase);
893 host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32);
894 host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD;
895 host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase);
896 host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32);
897 host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD;
898 if (card->sleep_cookie) {
899 buf_pa = MWIFIEX_SKB_PACB(card->sleep_cookie);
900 host_spec->sleep_cookie_addr_lo = (u32) *buf_pa;
901 host_spec->sleep_cookie_addr_hi = (u32) (((u64)*buf_pa) >> 32);
902 dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n",
903 host_spec->sleep_cookie_addr_lo);
Amitkumar Karward930fae2011-10-11 17:41:21 -0700904 }
905
906 return 0;
907}
908
909/*
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -0700910 * This function prepares command for event subscription, configuration
911 * and query. Events can be subscribed or unsubscribed. Current subscribed
912 * events can be queried. Also, current subscribed events are reported in
913 * every FW response.
914 */
915static int
916mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv,
917 struct host_cmd_ds_command *cmd,
918 struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg)
919{
920 struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt;
921 struct mwifiex_ie_types_rssi_threshold *rssi_tlv;
922 u16 event_bitmap;
923 u8 *pos;
924
925 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT);
926 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) +
927 S_DS_GEN);
928
929 subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action);
930 dev_dbg(priv->adapter->dev, "cmd: action: %d\n", subsc_evt_cfg->action);
931
932 /*For query requests, no configuration TLV structures are to be added.*/
933 if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET)
934 return 0;
935
936 subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events);
937
938 event_bitmap = subsc_evt_cfg->events;
939 dev_dbg(priv->adapter->dev, "cmd: event bitmap : %16x\n",
940 event_bitmap);
941
942 if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) ||
943 (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) &&
944 (event_bitmap == 0)) {
945 dev_dbg(priv->adapter->dev, "Error: No event specified "
946 "for bitwise action type\n");
947 return -EINVAL;
948 }
949
950 /*
951 * Append TLV structures for each of the specified events for
952 * subscribing or re-configuring. This is not required for
953 * bitwise unsubscribing request.
954 */
955 if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR)
956 return 0;
957
958 pos = ((u8 *)subsc_evt) +
959 sizeof(struct host_cmd_ds_802_11_subsc_evt);
960
961 if (event_bitmap & BITMASK_BCN_RSSI_LOW) {
962 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
963
964 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW);
965 rssi_tlv->header.len =
966 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
967 sizeof(struct mwifiex_ie_types_header));
968 rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value;
969 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq;
970
971 dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, "
972 "RSSI:-%d dBm, Freq:%d\n",
973 subsc_evt_cfg->bcn_l_rssi_cfg.abs_value,
974 subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq);
975
976 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
977 le16_add_cpu(&cmd->size,
978 sizeof(struct mwifiex_ie_types_rssi_threshold));
979 }
980
981 if (event_bitmap & BITMASK_BCN_RSSI_HIGH) {
982 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
983
984 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH);
985 rssi_tlv->header.len =
986 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
987 sizeof(struct mwifiex_ie_types_header));
988 rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value;
989 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq;
990
991 dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, "
992 "RSSI:-%d dBm, Freq:%d\n",
993 subsc_evt_cfg->bcn_h_rssi_cfg.abs_value,
994 subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq);
995
996 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
997 le16_add_cpu(&cmd->size,
998 sizeof(struct mwifiex_ie_types_rssi_threshold));
999 }
1000
1001 return 0;
1002}
1003
1004/*
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001005 * This function prepares the commands before sending them to the firmware.
1006 *
1007 * This is a generic function which calls specific command preparation
1008 * routines based upon the command number.
1009 */
1010int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1011 u16 cmd_action, u32 cmd_oid,
1012 void *data_buf, void *cmd_buf)
1013{
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -07001014 struct host_cmd_ds_command *cmd_ptr = cmd_buf;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001015 int ret = 0;
1016
1017 /* Prepare command */
1018 switch (cmd_no) {
1019 case HostCmd_CMD_GET_HW_SPEC:
1020 ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr);
1021 break;
1022 case HostCmd_CMD_MAC_CONTROL:
1023 ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action,
1024 data_buf);
1025 break;
1026 case HostCmd_CMD_802_11_MAC_ADDRESS:
1027 ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr,
1028 cmd_action);
1029 break;
1030 case HostCmd_CMD_MAC_MULTICAST_ADR:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001031 ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001032 data_buf);
1033 break;
1034 case HostCmd_CMD_TX_RATE_CFG:
1035 ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action,
1036 data_buf);
1037 break;
1038 case HostCmd_CMD_TXPWR_CFG:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001039 ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001040 data_buf);
1041 break;
1042 case HostCmd_CMD_802_11_PS_MODE_ENH:
1043 ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action,
1044 (uint16_t)cmd_oid, data_buf);
1045 break;
1046 case HostCmd_CMD_802_11_HS_CFG_ENH:
1047 ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action,
1048 (struct mwifiex_hs_config_param *) data_buf);
1049 break;
1050 case HostCmd_CMD_802_11_SCAN:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001051 ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001052 break;
1053 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001054 ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001055 break;
1056 case HostCmd_CMD_802_11_ASSOCIATE:
1057 ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf);
1058 break;
1059 case HostCmd_CMD_802_11_DEAUTHENTICATE:
1060 ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr,
1061 data_buf);
1062 break;
1063 case HostCmd_CMD_802_11_AD_HOC_START:
1064 ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr,
1065 data_buf);
1066 break;
1067 case HostCmd_CMD_802_11_GET_LOG:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001068 ret = mwifiex_cmd_802_11_get_log(cmd_ptr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001069 break;
1070 case HostCmd_CMD_802_11_AD_HOC_JOIN:
1071 ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr,
1072 data_buf);
1073 break;
1074 case HostCmd_CMD_802_11_AD_HOC_STOP:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001075 ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001076 break;
1077 case HostCmd_CMD_RSSI_INFO:
1078 ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action);
1079 break;
1080 case HostCmd_CMD_802_11_SNMP_MIB:
1081 ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action,
1082 cmd_oid, data_buf);
1083 break;
1084 case HostCmd_CMD_802_11_TX_RATE_QUERY:
1085 cmd_ptr->command =
1086 cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY);
1087 cmd_ptr->size =
1088 cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) +
1089 S_DS_GEN);
1090 priv->tx_rate = 0;
1091 ret = 0;
1092 break;
1093 case HostCmd_CMD_VERSION_EXT:
1094 cmd_ptr->command = cpu_to_le16(cmd_no);
1095 cmd_ptr->params.verext.version_str_sel =
1096 (u8) (*((u32 *) data_buf));
1097 memcpy(&cmd_ptr->params, data_buf,
1098 sizeof(struct host_cmd_ds_version_ext));
1099 cmd_ptr->size =
1100 cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) +
1101 S_DS_GEN);
1102 ret = 0;
1103 break;
1104 case HostCmd_CMD_802_11_RF_CHANNEL:
1105 ret = mwifiex_cmd_802_11_rf_channel(priv, cmd_ptr, cmd_action,
1106 data_buf);
1107 break;
1108 case HostCmd_CMD_FUNC_INIT:
1109 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET)
1110 priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY;
1111 cmd_ptr->command = cpu_to_le16(cmd_no);
1112 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1113 break;
1114 case HostCmd_CMD_FUNC_SHUTDOWN:
1115 priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET;
1116 cmd_ptr->command = cpu_to_le16(cmd_no);
1117 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1118 break;
1119 case HostCmd_CMD_11N_ADDBA_REQ:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001120 ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001121 break;
1122 case HostCmd_CMD_11N_DELBA:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001123 ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001124 break;
1125 case HostCmd_CMD_11N_ADDBA_RSP:
1126 ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf);
1127 break;
1128 case HostCmd_CMD_802_11_KEY_MATERIAL:
1129 ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -07001130 cmd_action, cmd_oid,
1131 data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001132 break;
1133 case HostCmd_CMD_802_11D_DOMAIN_INFO:
1134 ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -07001135 cmd_action);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001136 break;
1137 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
1138 ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action,
1139 data_buf);
1140 break;
1141 case HostCmd_CMD_AMSDU_AGGR_CTRL:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001142 ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001143 data_buf);
1144 break;
1145 case HostCmd_CMD_11N_CFG:
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -07001146 ret = mwifiex_cmd_11n_cfg(cmd_ptr, cmd_action, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001147 break;
1148 case HostCmd_CMD_WMM_GET_STATUS:
1149 dev_dbg(priv->adapter->dev,
1150 "cmd: WMM: WMM_GET_STATUS cmd sent\n");
1151 cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS);
1152 cmd_ptr->size =
1153 cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) +
1154 S_DS_GEN);
1155 ret = 0;
1156 break;
1157 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001158 ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action,
1159 data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001160 break;
1161 case HostCmd_CMD_MAC_REG_ACCESS:
1162 case HostCmd_CMD_BBP_REG_ACCESS:
1163 case HostCmd_CMD_RF_REG_ACCESS:
1164 case HostCmd_CMD_PMIC_REG_ACCESS:
1165 case HostCmd_CMD_CAU_REG_ACCESS:
1166 case HostCmd_CMD_802_11_EEPROM_ACCESS:
1167 ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf);
1168 break;
1169 case HostCmd_CMD_SET_BSS_MODE:
1170 cmd_ptr->command = cpu_to_le16(cmd_no);
Bing Zhaoeecd8252011-03-28 17:55:41 -07001171 if (priv->bss_mode == NL80211_IFTYPE_ADHOC)
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001172 cmd_ptr->params.bss_mode.con_type =
1173 CONNECTION_TYPE_ADHOC;
Bing Zhaoeecd8252011-03-28 17:55:41 -07001174 else if (priv->bss_mode == NL80211_IFTYPE_STATION)
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001175 cmd_ptr->params.bss_mode.con_type =
1176 CONNECTION_TYPE_INFRA;
1177 cmd_ptr->size = cpu_to_le16(sizeof(struct
1178 host_cmd_ds_set_bss_mode) + S_DS_GEN);
1179 ret = 0;
1180 break;
Amitkumar Karward930fae2011-10-11 17:41:21 -07001181 case HostCmd_CMD_PCIE_DESC_DETAILS:
1182 ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action);
1183 break;
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -07001184 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
1185 ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf);
1186 break;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001187 default:
1188 dev_err(priv->adapter->dev,
1189 "PREP_CMD: unknown cmd- %#x\n", cmd_no);
1190 ret = -1;
1191 break;
1192 }
1193 return ret;
1194}
1195
1196/*
1197 * This function issues commands to initialize firmware.
1198 *
1199 * This is called after firmware download to bring the card to
1200 * working state.
1201 *
1202 * The following commands are issued sequentially -
Amitkumar Karward930fae2011-10-11 17:41:21 -07001203 * - Set PCI-Express host buffer configuration (PCIE only)
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001204 * - Function init (for first interface only)
1205 * - Read MAC address (for first interface only)
1206 * - Reconfigure Tx buffer size (for first interface only)
1207 * - Enable auto deep sleep (for first interface only)
1208 * - Get Tx rate
1209 * - Get Tx power
1210 * - Set IBSS coalescing status
1211 * - Set AMSDU aggregation control
1212 * - Set 11d control
1213 * - Set MAC control (this must be the last command to initialize firmware)
1214 */
1215int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1216{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -07001217 int ret;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001218 u16 enable = true;
1219 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
1220 struct mwifiex_ds_auto_ds auto_ds;
1221 enum state_11d_t state_11d;
Amitkumar Karwarcd27bc32011-07-08 20:40:30 -07001222 struct mwifiex_ds_11n_tx_cfg tx_cfg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001223
1224 if (first_sta) {
Amitkumar Karward930fae2011-10-11 17:41:21 -07001225 if (priv->adapter->iface_type == MWIFIEX_PCIE) {
1226 ret = mwifiex_send_cmd_async(priv,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -07001227 HostCmd_CMD_PCIE_DESC_DETAILS,
1228 HostCmd_ACT_GEN_SET, 0, NULL);
Amitkumar Karward930fae2011-10-11 17:41:21 -07001229 if (ret)
1230 return -1;
1231 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001232
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001233 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_FUNC_INIT,
1234 HostCmd_ACT_GEN_SET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001235 if (ret)
1236 return -1;
1237 /* Read MAC address from HW */
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001238 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_GET_HW_SPEC,
1239 HostCmd_ACT_GEN_GET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001240 if (ret)
1241 return -1;
1242
1243 /* Reconfigure tx buf size */
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001244 ret = mwifiex_send_cmd_async(priv,
1245 HostCmd_CMD_RECONFIGURE_TX_BUFF,
1246 HostCmd_ACT_GEN_SET, 0,
1247 &priv->adapter->tx_buf_size);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001248 if (ret)
1249 return -1;
1250
1251 /* Enable IEEE PS by default */
1252 priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001253 ret = mwifiex_send_cmd_async(priv,
1254 HostCmd_CMD_802_11_PS_MODE_ENH,
1255 EN_AUTO_PS, BITMAP_STA_PS, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001256 if (ret)
1257 return -1;
1258 }
1259
1260 /* get tx rate */
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001261 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TX_RATE_CFG,
1262 HostCmd_ACT_GEN_GET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001263 if (ret)
1264 return -1;
1265 priv->data_rate = 0;
1266
1267 /* get tx power */
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001268 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TXPWR_CFG,
1269 HostCmd_ACT_GEN_GET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001270 if (ret)
1271 return -1;
1272
1273 /* set ibss coalescing_status */
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001274 ret = mwifiex_send_cmd_async(priv,
1275 HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
1276 HostCmd_ACT_GEN_SET, 0, &enable);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001277 if (ret)
1278 return -1;
1279
1280 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
1281 amsdu_aggr_ctrl.enable = true;
1282 /* Send request to firmware */
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001283 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_AMSDU_AGGR_CTRL,
1284 HostCmd_ACT_GEN_SET, 0,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -07001285 &amsdu_aggr_ctrl);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001286 if (ret)
1287 return -1;
1288 /* MAC Control must be the last command in init_fw */
1289 /* set MAC Control */
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001290 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
1291 HostCmd_ACT_GEN_SET, 0,
1292 &priv->curr_pkt_filter);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001293 if (ret)
1294 return -1;
1295
1296 if (first_sta) {
1297 /* Enable auto deep sleep */
1298 auto_ds.auto_ds = DEEP_SLEEP_ON;
1299 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001300 ret = mwifiex_send_cmd_async(priv,
1301 HostCmd_CMD_802_11_PS_MODE_ENH,
1302 EN_AUTO_PS, BITMAP_AUTO_DS,
1303 &auto_ds);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001304 if (ret)
1305 return -1;
1306 }
1307
1308 /* Send cmd to FW to enable/disable 11D function */
1309 state_11d = ENABLE_11D;
Amitkumar Karwar600f5d92011-04-13 17:27:06 -07001310 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SNMP_MIB,
1311 HostCmd_ACT_GEN_SET, DOT11D_I, &state_11d);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001312 if (ret)
1313 dev_err(priv->adapter->dev, "11D: failed to enable 11D\n");
1314
Amitkumar Karwarcd27bc32011-07-08 20:40:30 -07001315 /* Send cmd to FW to configure 11n specific configuration
1316 * (Short GI, Channel BW, Green field support etc.) for transmit
1317 */
1318 tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG;
1319 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_CFG,
1320 HostCmd_ACT_GEN_SET, 0, &tx_cfg);
1321
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001322 /* set last_init_cmd */
Amitkumar Karwarcd27bc32011-07-08 20:40:30 -07001323 priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001324 ret = -EINPROGRESS;
1325
1326 return ret;
1327}