Commit | Line | Data |
---|---|---|
5e6e3a92 BZ |
1 | /* |
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 | */ | |
37 | static int | |
38 | mwifiex_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 | */ | |
68 | static int mwifiex_cmd_mac_control(struct mwifiex_private *priv, | |
69 | struct host_cmd_ds_command *cmd, | |
a5ffddb7 | 70 | u16 cmd_action, u16 *action) |
5e6e3a92 BZ |
71 | { |
72 | struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl; | |
5e6e3a92 BZ |
73 | |
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); | |
a5ffddb7 | 83 | mac_ctrl->action = cpu_to_le16(*action); |
5e6e3a92 BZ |
84 | |
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 | */ | |
103 | static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, | |
104 | struct host_cmd_ds_command *cmd, | |
105 | u16 cmd_action, u32 cmd_oid, | |
f3c8d259 | 106 | u16 *ul_temp) |
5e6e3a92 BZ |
107 | { |
108 | struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib; | |
5e6e3a92 BZ |
109 | |
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) | |
9c05fd72 | 113 | - 1 + S_DS_GEN); |
5e6e3a92 | 114 | |
f3c8d259 | 115 | snmp_mib->oid = cpu_to_le16((u16)cmd_oid); |
5e6e3a92 BZ |
116 | if (cmd_action == HostCmd_ACT_GEN_GET) { |
117 | snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET); | |
118 | snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE); | |
f3c8d259 AK |
119 | le16_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE); |
120 | } else if (cmd_action == HostCmd_ACT_GEN_SET) { | |
121 | snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET); | |
122 | snmp_mib->buf_size = cpu_to_le16(sizeof(u16)); | |
123 | *((__le16 *) (snmp_mib->value)) = cpu_to_le16(*ul_temp); | |
124 | le16_add_cpu(&cmd->size, sizeof(u16)); | |
5e6e3a92 BZ |
125 | } |
126 | ||
5e6e3a92 BZ |
127 | dev_dbg(priv->adapter->dev, |
128 | "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x," | |
129 | " Value=0x%x\n", | |
9c05fd72 YAP |
130 | cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size), |
131 | le16_to_cpu(*(__le16 *) snmp_mib->value)); | |
5e6e3a92 BZ |
132 | 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 | */ | |
142 | static int | |
572e8f3e | 143 | mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd) |
5e6e3a92 BZ |
144 | { |
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 | */ | |
160 | static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv, | |
161 | struct host_cmd_ds_command *cmd, | |
a5ffddb7 | 162 | u16 cmd_action, u16 *pbitmap_rates) |
5e6e3a92 BZ |
163 | { |
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; | |
5e6e3a92 BZ |
167 | 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); | |
9c05fd72 YAP |
177 | rate_scope->length = cpu_to_le16 |
178 | (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header)); | |
5e6e3a92 BZ |
179 | if (pbitmap_rates != NULL) { |
180 | rate_scope->hr_dsss_rate_bitmap = cpu_to_le16(pbitmap_rates[0]); | |
181 | rate_scope->ofdm_rate_bitmap = cpu_to_le16(pbitmap_rates[1]); | |
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 + | |
9c05fd72 | 200 | sizeof(struct mwifiex_rate_scope)); |
5e6e3a92 BZ |
201 | rate_drop->type = cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL); |
202 | rate_drop->length = cpu_to_le16(sizeof(rate_drop->rate_drop_mode)); | |
203 | rate_drop->rate_drop_mode = 0; | |
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 | */ | |
572e8f3e | 222 | static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd, |
a5ffddb7 AK |
223 | u16 cmd_action, |
224 | struct host_cmd_ds_txpwr_cfg *txp) | |
5e6e3a92 | 225 | { |
270e58e8 | 226 | struct mwifiex_types_power_group *pg_tlv; |
5e6e3a92 BZ |
227 | 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: | |
5e6e3a92 BZ |
234 | if (txp->mode) { |
235 | pg_tlv = (struct mwifiex_types_power_group | |
a5ffddb7 | 236 | *) ((unsigned long) txp + |
5e6e3a92 | 237 | sizeof(struct host_cmd_ds_txpwr_cfg)); |
a5ffddb7 | 238 | memmove(cmd_txp_cfg, txp, |
5e6e3a92 BZ |
239 | 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 { | |
a5ffddb7 | 250 | memmove(cmd_txp_cfg, txp, sizeof(*txp)); |
5e6e3a92 BZ |
251 | } |
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 | */ | |
a5ffddb7 AK |
271 | static int |
272 | mwifiex_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) | |
5e6e3a92 BZ |
276 | { |
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 | ||
a5ffddb7 | 281 | if (!hscfg_param) |
5e6e3a92 BZ |
282 | /* 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 && | |
9c05fd72 YAP |
287 | (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))) { | |
5e6e3a92 BZ |
290 | dev_dbg(adapter->dev, |
291 | "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n", | |
9c05fd72 | 292 | adapter->arp_filter_size); |
5e6e3a92 BZ |
293 | memcpy(((u8 *) hs_cfg) + |
294 | sizeof(struct host_cmd_ds_802_11_hs_cfg_enh), | |
295 | adapter->arp_filter, adapter->arp_filter_size); | |
9c05fd72 YAP |
296 | 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); | |
5e6e3a92 BZ |
300 | } else { |
301 | cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct | |
9c05fd72 | 302 | host_cmd_ds_802_11_hs_cfg_enh)); |
5e6e3a92 BZ |
303 | } |
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); | |
a5ffddb7 AK |
309 | 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; | |
5e6e3a92 BZ |
312 | 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 | */ | |
330 | static 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 | */ | |
a5ffddb7 AK |
355 | static int |
356 | mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd, | |
357 | u16 cmd_action, | |
358 | struct mwifiex_multicast_list *mcast_list) | |
5e6e3a92 | 359 | { |
5e6e3a92 BZ |
360 | 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 | */ | |
383 | static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv, | |
384 | struct host_cmd_ds_command *cmd, | |
a5ffddb7 | 385 | u8 *mac) |
5e6e3a92 BZ |
386 | { |
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 */ | |
a5ffddb7 | 394 | memcpy(deauth->mac_addr, mac, ETH_ALEN); |
5e6e3a92 BZ |
395 | |
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 | */ | |
572e8f3e | 410 | static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command *cmd) |
5e6e3a92 BZ |
411 | { |
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 | */ | |
423 | static int | |
424 | mwifiex_set_keyparamset_wep(struct mwifiex_private *priv, | |
425 | struct mwifiex_ie_type_key_param_set *key_param_set, | |
426 | u16 *key_param_len) | |
427 | { | |
270e58e8 | 428 | int cur_key_param_len; |
5e6e3a92 BZ |
429 | 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 = | |
6a35a0ac YAP |
446 | cpu_to_le16(KEY_ENABLED | KEY_UNICAST | |
447 | KEY_MCAST); | |
5e6e3a92 BZ |
448 | 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 + | |
9c05fd72 | 470 | cur_key_param_len); |
5e6e3a92 BZ |
471 | } 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 | */ | |
a5ffddb7 AK |
493 | static int |
494 | mwifiex_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) | |
5e6e3a92 BZ |
498 | { |
499 | struct host_cmd_ds_802_11_key_material *key_material = | |
500 | &cmd->params.key_material; | |
75edd2c6 AP |
501 | struct host_cmd_tlv_mac_addr *tlv_mac; |
502 | u16 key_param_len = 0, cmd_size; | |
5e6e3a92 BZ |
503 | int ret = 0; |
504 | const u8 bc_mac[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | |
505 | ||
506 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL); | |
507 | key_material->action = cpu_to_le16(cmd_action); | |
508 | ||
509 | if (cmd_action == HostCmd_ACT_GEN_GET) { | |
510 | cmd->size = | |
511 | cpu_to_le16(sizeof(key_material->action) + S_DS_GEN); | |
512 | return ret; | |
513 | } | |
514 | ||
515 | if (!enc_key) { | |
516 | memset(&key_material->key_param_set, 0, | |
517 | (NUM_WEP_KEYS * | |
518 | sizeof(struct mwifiex_ie_type_key_param_set))); | |
519 | ret = mwifiex_set_keyparamset_wep(priv, | |
520 | &key_material->key_param_set, | |
521 | &key_param_len); | |
522 | cmd->size = cpu_to_le16(key_param_len + | |
523 | sizeof(key_material->action) + S_DS_GEN); | |
524 | return ret; | |
525 | } else | |
526 | memset(&key_material->key_param_set, 0, | |
527 | sizeof(struct mwifiex_ie_type_key_param_set)); | |
528 | if (enc_key->is_wapi_key) { | |
529 | dev_dbg(priv->adapter->dev, "info: Set WAPI Key\n"); | |
530 | key_material->key_param_set.key_type_id = | |
9c05fd72 | 531 | cpu_to_le16(KEY_TYPE_ID_WAPI); |
5e6e3a92 BZ |
532 | if (cmd_oid == KEY_INFO_ENABLED) |
533 | key_material->key_param_set.key_info = | |
9c05fd72 | 534 | cpu_to_le16(KEY_ENABLED); |
5e6e3a92 BZ |
535 | else |
536 | key_material->key_param_set.key_info = | |
9c05fd72 | 537 | cpu_to_le16(!KEY_ENABLED); |
5e6e3a92 BZ |
538 | |
539 | key_material->key_param_set.key[0] = enc_key->key_index; | |
540 | if (!priv->sec_info.wapi_key_on) | |
541 | key_material->key_param_set.key[1] = 1; | |
542 | else | |
543 | /* set 0 when re-key */ | |
544 | key_material->key_param_set.key[1] = 0; | |
545 | ||
546 | if (0 != memcmp(enc_key->mac_addr, bc_mac, sizeof(bc_mac))) { | |
547 | /* WAPI pairwise key: unicast */ | |
548 | key_material->key_param_set.key_info |= | |
6a35a0ac | 549 | cpu_to_le16(KEY_UNICAST); |
5e6e3a92 BZ |
550 | } else { /* WAPI group key: multicast */ |
551 | key_material->key_param_set.key_info |= | |
6a35a0ac | 552 | cpu_to_le16(KEY_MCAST); |
5e6e3a92 BZ |
553 | priv->sec_info.wapi_key_on = true; |
554 | } | |
555 | ||
556 | key_material->key_param_set.type = | |
9c05fd72 | 557 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
5e6e3a92 | 558 | key_material->key_param_set.key_len = |
9c05fd72 | 559 | cpu_to_le16(WAPI_KEY_LEN); |
5e6e3a92 BZ |
560 | memcpy(&key_material->key_param_set.key[2], |
561 | enc_key->key_material, enc_key->key_len); | |
562 | memcpy(&key_material->key_param_set.key[2 + enc_key->key_len], | |
563 | enc_key->wapi_rxpn, WAPI_RXPN_LEN); | |
564 | key_material->key_param_set.length = | |
565 | cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN); | |
566 | ||
567 | key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) + | |
568 | sizeof(struct mwifiex_ie_types_header); | |
9c05fd72 YAP |
569 | cmd->size = cpu_to_le16(sizeof(key_material->action) |
570 | + S_DS_GEN + key_param_len); | |
5e6e3a92 BZ |
571 | return ret; |
572 | } | |
573 | if (enc_key->key_len == WLAN_KEY_LEN_CCMP) { | |
574 | dev_dbg(priv->adapter->dev, "cmd: WPA_AES\n"); | |
575 | key_material->key_param_set.key_type_id = | |
9c05fd72 | 576 | cpu_to_le16(KEY_TYPE_ID_AES); |
5e6e3a92 BZ |
577 | if (cmd_oid == KEY_INFO_ENABLED) |
578 | key_material->key_param_set.key_info = | |
9c05fd72 | 579 | cpu_to_le16(KEY_ENABLED); |
5e6e3a92 BZ |
580 | else |
581 | key_material->key_param_set.key_info = | |
9c05fd72 | 582 | cpu_to_le16(!KEY_ENABLED); |
5e6e3a92 BZ |
583 | |
584 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) | |
585 | /* AES pairwise key: unicast */ | |
586 | key_material->key_param_set.key_info |= | |
9c05fd72 | 587 | cpu_to_le16(KEY_UNICAST); |
5e6e3a92 BZ |
588 | else /* AES group key: multicast */ |
589 | key_material->key_param_set.key_info |= | |
9c05fd72 | 590 | cpu_to_le16(KEY_MCAST); |
5e6e3a92 BZ |
591 | } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) { |
592 | dev_dbg(priv->adapter->dev, "cmd: WPA_TKIP\n"); | |
593 | key_material->key_param_set.key_type_id = | |
9c05fd72 | 594 | cpu_to_le16(KEY_TYPE_ID_TKIP); |
5e6e3a92 | 595 | key_material->key_param_set.key_info = |
9c05fd72 | 596 | cpu_to_le16(KEY_ENABLED); |
5e6e3a92 BZ |
597 | |
598 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) | |
599 | /* TKIP pairwise key: unicast */ | |
600 | key_material->key_param_set.key_info |= | |
9c05fd72 | 601 | cpu_to_le16(KEY_UNICAST); |
5e6e3a92 BZ |
602 | else /* TKIP group key: multicast */ |
603 | key_material->key_param_set.key_info |= | |
9c05fd72 | 604 | cpu_to_le16(KEY_MCAST); |
5e6e3a92 BZ |
605 | } |
606 | ||
607 | if (key_material->key_param_set.key_type_id) { | |
608 | key_material->key_param_set.type = | |
9c05fd72 | 609 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
5e6e3a92 | 610 | key_material->key_param_set.key_len = |
9c05fd72 | 611 | cpu_to_le16((u16) enc_key->key_len); |
5e6e3a92 BZ |
612 | memcpy(key_material->key_param_set.key, enc_key->key_material, |
613 | enc_key->key_len); | |
614 | key_material->key_param_set.length = | |
615 | cpu_to_le16((u16) enc_key->key_len + | |
616 | KEYPARAMSET_FIXED_LEN); | |
617 | ||
75edd2c6 | 618 | key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN) |
9c05fd72 | 619 | + sizeof(struct mwifiex_ie_types_header); |
5e6e3a92 | 620 | |
9c05fd72 YAP |
621 | cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN |
622 | + key_param_len); | |
75edd2c6 AP |
623 | |
624 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) { | |
625 | tlv_mac = (void *)((u8 *)&key_material->key_param_set + | |
626 | key_param_len); | |
627 | tlv_mac->tlv.type = cpu_to_le16(TLV_TYPE_STA_MAC_ADDR); | |
628 | tlv_mac->tlv.len = cpu_to_le16(ETH_ALEN); | |
629 | memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN); | |
630 | cmd_size = key_param_len + S_DS_GEN + | |
631 | sizeof(key_material->action) + | |
632 | sizeof(struct host_cmd_tlv_mac_addr); | |
633 | } else { | |
634 | cmd_size = key_param_len + S_DS_GEN + | |
635 | sizeof(key_material->action); | |
636 | } | |
637 | cmd->size = cpu_to_le16(cmd_size); | |
5e6e3a92 BZ |
638 | } |
639 | ||
640 | return ret; | |
641 | } | |
642 | ||
643 | /* | |
644 | * This function prepares command to set/get 11d domain information. | |
645 | * | |
646 | * Preparation includes - | |
647 | * - Setting command ID, action and proper size | |
648 | * - Setting domain information fields (for SET only) | |
649 | * - Ensuring correct endian-ness | |
650 | */ | |
651 | static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv, | |
652 | struct host_cmd_ds_command *cmd, | |
653 | u16 cmd_action) | |
654 | { | |
655 | struct mwifiex_adapter *adapter = priv->adapter; | |
656 | struct host_cmd_ds_802_11d_domain_info *domain_info = | |
657 | &cmd->params.domain_info; | |
658 | struct mwifiex_ietypes_domain_param_set *domain = | |
659 | &domain_info->domain; | |
660 | u8 no_of_triplet = adapter->domain_reg.no_of_triplet; | |
661 | ||
662 | dev_dbg(adapter->dev, "info: 11D: no_of_triplet=0x%x\n", no_of_triplet); | |
663 | ||
664 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO); | |
665 | domain_info->action = cpu_to_le16(cmd_action); | |
666 | if (cmd_action == HostCmd_ACT_GEN_GET) { | |
667 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); | |
668 | return 0; | |
669 | } | |
670 | ||
671 | /* Set domain info fields */ | |
672 | domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY); | |
673 | memcpy(domain->country_code, adapter->domain_reg.country_code, | |
9c05fd72 | 674 | sizeof(domain->country_code)); |
5e6e3a92 | 675 | |
9c05fd72 YAP |
676 | domain->header.len = |
677 | cpu_to_le16((no_of_triplet * | |
678 | sizeof(struct ieee80211_country_ie_triplet)) | |
679 | + sizeof(domain->country_code)); | |
5e6e3a92 BZ |
680 | |
681 | if (no_of_triplet) { | |
682 | memcpy(domain->triplet, adapter->domain_reg.triplet, | |
9c05fd72 YAP |
683 | no_of_triplet * sizeof(struct |
684 | ieee80211_country_ie_triplet)); | |
5e6e3a92 BZ |
685 | |
686 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + | |
9c05fd72 YAP |
687 | le16_to_cpu(domain->header.len) + |
688 | sizeof(struct mwifiex_ie_types_header) | |
689 | + S_DS_GEN); | |
5e6e3a92 BZ |
690 | } else { |
691 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); | |
692 | } | |
693 | ||
694 | return 0; | |
695 | } | |
696 | ||
697 | /* | |
698 | * This function prepares command to set/get RF channel. | |
699 | * | |
700 | * Preparation includes - | |
701 | * - Setting command ID, action and proper size | |
702 | * - Setting RF type and current RF channel (for SET only) | |
703 | * - Ensuring correct endian-ness | |
704 | */ | |
705 | static int mwifiex_cmd_802_11_rf_channel(struct mwifiex_private *priv, | |
706 | struct host_cmd_ds_command *cmd, | |
a5ffddb7 | 707 | u16 cmd_action, u16 *channel) |
5e6e3a92 BZ |
708 | { |
709 | struct host_cmd_ds_802_11_rf_channel *rf_chan = | |
710 | &cmd->params.rf_channel; | |
711 | uint16_t rf_type = le16_to_cpu(rf_chan->rf_type); | |
712 | ||
713 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_RF_CHANNEL); | |
714 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rf_channel) | |
715 | + S_DS_GEN); | |
716 | ||
717 | if (cmd_action == HostCmd_ACT_GEN_SET) { | |
9c05fd72 YAP |
718 | if ((priv->adapter->adhoc_start_band & BAND_A) || |
719 | (priv->adapter->adhoc_start_band & BAND_AN)) | |
5e6e3a92 BZ |
720 | rf_chan->rf_type = |
721 | cpu_to_le16(HostCmd_SCAN_RADIO_TYPE_A); | |
722 | ||
723 | rf_type = le16_to_cpu(rf_chan->rf_type); | |
21c3ba34 | 724 | SET_SECONDARYCHAN(rf_type, priv->adapter->sec_chan_offset); |
a5ffddb7 | 725 | rf_chan->current_channel = cpu_to_le16(*channel); |
5e6e3a92 BZ |
726 | } |
727 | rf_chan->action = cpu_to_le16(cmd_action); | |
728 | return 0; | |
729 | } | |
730 | ||
731 | /* | |
732 | * This function prepares command to set/get IBSS coalescing status. | |
733 | * | |
734 | * Preparation includes - | |
735 | * - Setting command ID, action and proper size | |
736 | * - Setting status to enable or disable (for SET only) | |
737 | * - Ensuring correct endian-ness | |
738 | */ | |
572e8f3e | 739 | static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd, |
a5ffddb7 | 740 | u16 cmd_action, u16 *enable) |
5e6e3a92 BZ |
741 | { |
742 | struct host_cmd_ds_802_11_ibss_status *ibss_coal = | |
743 | &(cmd->params.ibss_coalescing); | |
5e6e3a92 BZ |
744 | |
745 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS); | |
746 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) + | |
747 | S_DS_GEN); | |
748 | cmd->result = 0; | |
749 | ibss_coal->action = cpu_to_le16(cmd_action); | |
750 | ||
751 | switch (cmd_action) { | |
752 | case HostCmd_ACT_GEN_SET: | |
a5ffddb7 AK |
753 | if (enable) |
754 | ibss_coal->enable = cpu_to_le16(*enable); | |
a5e5aa6c DC |
755 | else |
756 | ibss_coal->enable = 0; | |
5e6e3a92 BZ |
757 | break; |
758 | ||
759 | /* In other case.. Nothing to do */ | |
760 | case HostCmd_ACT_GEN_GET: | |
761 | default: | |
762 | break; | |
763 | } | |
764 | ||
765 | return 0; | |
766 | } | |
767 | ||
768 | /* | |
769 | * This function prepares command to set/get register value. | |
770 | * | |
771 | * Preparation includes - | |
772 | * - Setting command ID, action and proper size | |
773 | * - Setting register offset (for both GET and SET) and | |
774 | * register value (for SET only) | |
775 | * - Ensuring correct endian-ness | |
776 | * | |
777 | * The following type of registers can be accessed with this function - | |
778 | * - MAC register | |
779 | * - BBP register | |
780 | * - RF register | |
781 | * - PMIC register | |
782 | * - CAU register | |
783 | * - EEPROM | |
784 | */ | |
785 | static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, | |
786 | u16 cmd_action, void *data_buf) | |
787 | { | |
a5ffddb7 | 788 | struct mwifiex_ds_reg_rw *reg_rw = data_buf; |
5e6e3a92 | 789 | |
5e6e3a92 BZ |
790 | switch (le16_to_cpu(cmd->command)) { |
791 | case HostCmd_CMD_MAC_REG_ACCESS: | |
792 | { | |
793 | struct host_cmd_ds_mac_reg_access *mac_reg; | |
794 | ||
795 | cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN); | |
2c208890 | 796 | mac_reg = &cmd->params.mac_reg; |
5e6e3a92 BZ |
797 | mac_reg->action = cpu_to_le16(cmd_action); |
798 | mac_reg->offset = | |
799 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); | |
800 | mac_reg->value = reg_rw->value; | |
801 | break; | |
802 | } | |
803 | case HostCmd_CMD_BBP_REG_ACCESS: | |
804 | { | |
805 | struct host_cmd_ds_bbp_reg_access *bbp_reg; | |
806 | ||
807 | cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN); | |
2c208890 | 808 | bbp_reg = &cmd->params.bbp_reg; |
5e6e3a92 BZ |
809 | bbp_reg->action = cpu_to_le16(cmd_action); |
810 | bbp_reg->offset = | |
811 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); | |
812 | bbp_reg->value = (u8) le32_to_cpu(reg_rw->value); | |
813 | break; | |
814 | } | |
815 | case HostCmd_CMD_RF_REG_ACCESS: | |
816 | { | |
817 | struct host_cmd_ds_rf_reg_access *rf_reg; | |
818 | ||
819 | cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN); | |
2c208890 | 820 | rf_reg = &cmd->params.rf_reg; |
5e6e3a92 | 821 | rf_reg->action = cpu_to_le16(cmd_action); |
9c05fd72 | 822 | rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
5e6e3a92 BZ |
823 | rf_reg->value = (u8) le32_to_cpu(reg_rw->value); |
824 | break; | |
825 | } | |
826 | case HostCmd_CMD_PMIC_REG_ACCESS: | |
827 | { | |
828 | struct host_cmd_ds_pmic_reg_access *pmic_reg; | |
829 | ||
830 | cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN); | |
2c208890 | 831 | pmic_reg = &cmd->params.pmic_reg; |
5e6e3a92 BZ |
832 | pmic_reg->action = cpu_to_le16(cmd_action); |
833 | pmic_reg->offset = | |
9c05fd72 | 834 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
5e6e3a92 BZ |
835 | pmic_reg->value = (u8) le32_to_cpu(reg_rw->value); |
836 | break; | |
837 | } | |
838 | case HostCmd_CMD_CAU_REG_ACCESS: | |
839 | { | |
840 | struct host_cmd_ds_rf_reg_access *cau_reg; | |
841 | ||
842 | cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN); | |
2c208890 | 843 | cau_reg = &cmd->params.rf_reg; |
5e6e3a92 BZ |
844 | cau_reg->action = cpu_to_le16(cmd_action); |
845 | cau_reg->offset = | |
9c05fd72 | 846 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
5e6e3a92 BZ |
847 | cau_reg->value = (u8) le32_to_cpu(reg_rw->value); |
848 | break; | |
849 | } | |
850 | case HostCmd_CMD_802_11_EEPROM_ACCESS: | |
851 | { | |
a5ffddb7 | 852 | struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf; |
5e6e3a92 | 853 | struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom = |
5e6e3a92 BZ |
854 | &cmd->params.eeprom; |
855 | ||
856 | cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN); | |
857 | cmd_eeprom->action = cpu_to_le16(cmd_action); | |
858 | cmd_eeprom->offset = rd_eeprom->offset; | |
859 | cmd_eeprom->byte_count = rd_eeprom->byte_count; | |
860 | cmd_eeprom->value = 0; | |
861 | break; | |
862 | } | |
863 | default: | |
864 | return -1; | |
865 | } | |
866 | ||
867 | return 0; | |
868 | } | |
869 | ||
d930faee AK |
870 | /* |
871 | * This function prepares command to set PCI-Express | |
872 | * host buffer configuration | |
873 | * | |
874 | * Preparation includes - | |
875 | * - Setting command ID, action and proper size | |
876 | * - Setting host buffer configuration | |
877 | * - Ensuring correct endian-ness | |
878 | */ | |
879 | static int | |
880 | mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv, | |
9c05fd72 | 881 | struct host_cmd_ds_command *cmd, u16 action) |
d930faee AK |
882 | { |
883 | struct host_cmd_ds_pcie_details *host_spec = | |
884 | &cmd->params.pcie_host_spec; | |
885 | struct pcie_service_card *card = priv->adapter->card; | |
886 | phys_addr_t *buf_pa; | |
887 | ||
888 | cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS); | |
889 | cmd->size = cpu_to_le16(sizeof(struct | |
890 | host_cmd_ds_pcie_details) + S_DS_GEN); | |
891 | cmd->result = 0; | |
892 | ||
893 | memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details)); | |
894 | ||
9c05fd72 YAP |
895 | if (action != HostCmd_ACT_GEN_SET) |
896 | return 0; | |
897 | ||
898 | /* Send the ring base addresses and count to firmware */ | |
899 | host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase); | |
900 | host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32); | |
901 | host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD; | |
902 | host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase); | |
903 | host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32); | |
904 | host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD; | |
905 | host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase); | |
906 | host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32); | |
907 | host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD; | |
908 | if (card->sleep_cookie) { | |
909 | buf_pa = MWIFIEX_SKB_PACB(card->sleep_cookie); | |
910 | host_spec->sleep_cookie_addr_lo = (u32) *buf_pa; | |
911 | host_spec->sleep_cookie_addr_hi = (u32) (((u64)*buf_pa) >> 32); | |
912 | dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n", | |
913 | host_spec->sleep_cookie_addr_lo); | |
d930faee AK |
914 | } |
915 | ||
916 | return 0; | |
917 | } | |
918 | ||
fa444bf8 AK |
919 | /* |
920 | * This function prepares command for event subscription, configuration | |
921 | * and query. Events can be subscribed or unsubscribed. Current subscribed | |
922 | * events can be queried. Also, current subscribed events are reported in | |
923 | * every FW response. | |
924 | */ | |
925 | static int | |
926 | mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv, | |
927 | struct host_cmd_ds_command *cmd, | |
928 | struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg) | |
929 | { | |
930 | struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt; | |
931 | struct mwifiex_ie_types_rssi_threshold *rssi_tlv; | |
932 | u16 event_bitmap; | |
933 | u8 *pos; | |
934 | ||
935 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT); | |
936 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) + | |
937 | S_DS_GEN); | |
938 | ||
939 | subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action); | |
940 | dev_dbg(priv->adapter->dev, "cmd: action: %d\n", subsc_evt_cfg->action); | |
941 | ||
942 | /*For query requests, no configuration TLV structures are to be added.*/ | |
943 | if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET) | |
944 | return 0; | |
945 | ||
946 | subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events); | |
947 | ||
948 | event_bitmap = subsc_evt_cfg->events; | |
949 | dev_dbg(priv->adapter->dev, "cmd: event bitmap : %16x\n", | |
950 | event_bitmap); | |
951 | ||
952 | if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) || | |
953 | (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) && | |
954 | (event_bitmap == 0)) { | |
955 | dev_dbg(priv->adapter->dev, "Error: No event specified " | |
956 | "for bitwise action type\n"); | |
957 | return -EINVAL; | |
958 | } | |
959 | ||
960 | /* | |
961 | * Append TLV structures for each of the specified events for | |
962 | * subscribing or re-configuring. This is not required for | |
963 | * bitwise unsubscribing request. | |
964 | */ | |
965 | if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) | |
966 | return 0; | |
967 | ||
968 | pos = ((u8 *)subsc_evt) + | |
969 | sizeof(struct host_cmd_ds_802_11_subsc_evt); | |
970 | ||
971 | if (event_bitmap & BITMASK_BCN_RSSI_LOW) { | |
972 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; | |
973 | ||
974 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW); | |
975 | rssi_tlv->header.len = | |
976 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - | |
977 | sizeof(struct mwifiex_ie_types_header)); | |
978 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value; | |
979 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq; | |
980 | ||
981 | dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, " | |
982 | "RSSI:-%d dBm, Freq:%d\n", | |
983 | subsc_evt_cfg->bcn_l_rssi_cfg.abs_value, | |
984 | subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq); | |
985 | ||
986 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); | |
987 | le16_add_cpu(&cmd->size, | |
988 | sizeof(struct mwifiex_ie_types_rssi_threshold)); | |
989 | } | |
990 | ||
991 | if (event_bitmap & BITMASK_BCN_RSSI_HIGH) { | |
992 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; | |
993 | ||
994 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH); | |
995 | rssi_tlv->header.len = | |
996 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - | |
997 | sizeof(struct mwifiex_ie_types_header)); | |
998 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value; | |
999 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq; | |
1000 | ||
d35ccaa4 | 1001 | dev_dbg(priv->adapter->dev, "Cfg Beacon High Rssi event, " |
fa444bf8 AK |
1002 | "RSSI:-%d dBm, Freq:%d\n", |
1003 | subsc_evt_cfg->bcn_h_rssi_cfg.abs_value, | |
1004 | subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq); | |
1005 | ||
1006 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); | |
1007 | le16_add_cpu(&cmd->size, | |
1008 | sizeof(struct mwifiex_ie_types_rssi_threshold)); | |
1009 | } | |
1010 | ||
1011 | return 0; | |
1012 | } | |
1013 | ||
5e6e3a92 BZ |
1014 | /* |
1015 | * This function prepares the commands before sending them to the firmware. | |
1016 | * | |
1017 | * This is a generic function which calls specific command preparation | |
1018 | * routines based upon the command number. | |
1019 | */ | |
1020 | int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, | |
1021 | u16 cmd_action, u32 cmd_oid, | |
1022 | void *data_buf, void *cmd_buf) | |
1023 | { | |
a5ffddb7 | 1024 | struct host_cmd_ds_command *cmd_ptr = cmd_buf; |
5e6e3a92 BZ |
1025 | int ret = 0; |
1026 | ||
1027 | /* Prepare command */ | |
1028 | switch (cmd_no) { | |
1029 | case HostCmd_CMD_GET_HW_SPEC: | |
1030 | ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr); | |
1031 | break; | |
1032 | case HostCmd_CMD_MAC_CONTROL: | |
1033 | ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action, | |
1034 | data_buf); | |
1035 | break; | |
1036 | case HostCmd_CMD_802_11_MAC_ADDRESS: | |
1037 | ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr, | |
1038 | cmd_action); | |
1039 | break; | |
1040 | case HostCmd_CMD_MAC_MULTICAST_ADR: | |
572e8f3e | 1041 | ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action, |
5e6e3a92 BZ |
1042 | data_buf); |
1043 | break; | |
1044 | case HostCmd_CMD_TX_RATE_CFG: | |
1045 | ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action, | |
1046 | data_buf); | |
1047 | break; | |
1048 | case HostCmd_CMD_TXPWR_CFG: | |
572e8f3e | 1049 | ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action, |
5e6e3a92 BZ |
1050 | data_buf); |
1051 | break; | |
1052 | case HostCmd_CMD_802_11_PS_MODE_ENH: | |
1053 | ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action, | |
1054 | (uint16_t)cmd_oid, data_buf); | |
1055 | break; | |
1056 | case HostCmd_CMD_802_11_HS_CFG_ENH: | |
1057 | ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action, | |
1058 | (struct mwifiex_hs_config_param *) data_buf); | |
1059 | break; | |
1060 | case HostCmd_CMD_802_11_SCAN: | |
572e8f3e | 1061 | ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf); |
5e6e3a92 BZ |
1062 | break; |
1063 | case HostCmd_CMD_802_11_BG_SCAN_QUERY: | |
572e8f3e | 1064 | ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr); |
5e6e3a92 BZ |
1065 | break; |
1066 | case HostCmd_CMD_802_11_ASSOCIATE: | |
1067 | ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf); | |
1068 | break; | |
1069 | case HostCmd_CMD_802_11_DEAUTHENTICATE: | |
1070 | ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr, | |
1071 | data_buf); | |
1072 | break; | |
1073 | case HostCmd_CMD_802_11_AD_HOC_START: | |
1074 | ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr, | |
1075 | data_buf); | |
1076 | break; | |
1077 | case HostCmd_CMD_802_11_GET_LOG: | |
572e8f3e | 1078 | ret = mwifiex_cmd_802_11_get_log(cmd_ptr); |
5e6e3a92 BZ |
1079 | break; |
1080 | case HostCmd_CMD_802_11_AD_HOC_JOIN: | |
1081 | ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr, | |
1082 | data_buf); | |
1083 | break; | |
1084 | case HostCmd_CMD_802_11_AD_HOC_STOP: | |
572e8f3e | 1085 | ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr); |
5e6e3a92 BZ |
1086 | break; |
1087 | case HostCmd_CMD_RSSI_INFO: | |
1088 | ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action); | |
1089 | break; | |
1090 | case HostCmd_CMD_802_11_SNMP_MIB: | |
1091 | ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action, | |
1092 | cmd_oid, data_buf); | |
1093 | break; | |
1094 | case HostCmd_CMD_802_11_TX_RATE_QUERY: | |
1095 | cmd_ptr->command = | |
1096 | cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY); | |
1097 | cmd_ptr->size = | |
1098 | cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) + | |
1099 | S_DS_GEN); | |
1100 | priv->tx_rate = 0; | |
1101 | ret = 0; | |
1102 | break; | |
1103 | case HostCmd_CMD_VERSION_EXT: | |
1104 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
1105 | cmd_ptr->params.verext.version_str_sel = | |
1106 | (u8) (*((u32 *) data_buf)); | |
1107 | memcpy(&cmd_ptr->params, data_buf, | |
1108 | sizeof(struct host_cmd_ds_version_ext)); | |
1109 | cmd_ptr->size = | |
1110 | cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) + | |
1111 | S_DS_GEN); | |
1112 | ret = 0; | |
1113 | break; | |
1114 | case HostCmd_CMD_802_11_RF_CHANNEL: | |
1115 | ret = mwifiex_cmd_802_11_rf_channel(priv, cmd_ptr, cmd_action, | |
1116 | data_buf); | |
1117 | break; | |
1118 | case HostCmd_CMD_FUNC_INIT: | |
1119 | if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET) | |
1120 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY; | |
1121 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
1122 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); | |
1123 | break; | |
1124 | case HostCmd_CMD_FUNC_SHUTDOWN: | |
1125 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET; | |
1126 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
1127 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); | |
1128 | break; | |
1129 | case HostCmd_CMD_11N_ADDBA_REQ: | |
572e8f3e | 1130 | ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf); |
5e6e3a92 BZ |
1131 | break; |
1132 | case HostCmd_CMD_11N_DELBA: | |
572e8f3e | 1133 | ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf); |
5e6e3a92 BZ |
1134 | break; |
1135 | case HostCmd_CMD_11N_ADDBA_RSP: | |
1136 | ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf); | |
1137 | break; | |
1138 | case HostCmd_CMD_802_11_KEY_MATERIAL: | |
1139 | ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr, | |
9c05fd72 YAP |
1140 | cmd_action, cmd_oid, |
1141 | data_buf); | |
5e6e3a92 BZ |
1142 | break; |
1143 | case HostCmd_CMD_802_11D_DOMAIN_INFO: | |
1144 | ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr, | |
9c05fd72 | 1145 | cmd_action); |
5e6e3a92 BZ |
1146 | break; |
1147 | case HostCmd_CMD_RECONFIGURE_TX_BUFF: | |
1148 | ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action, | |
1149 | data_buf); | |
1150 | break; | |
1151 | case HostCmd_CMD_AMSDU_AGGR_CTRL: | |
572e8f3e | 1152 | ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action, |
5e6e3a92 BZ |
1153 | data_buf); |
1154 | break; | |
1155 | case HostCmd_CMD_11N_CFG: | |
9c05fd72 | 1156 | ret = mwifiex_cmd_11n_cfg(cmd_ptr, cmd_action, data_buf); |
5e6e3a92 BZ |
1157 | break; |
1158 | case HostCmd_CMD_WMM_GET_STATUS: | |
1159 | dev_dbg(priv->adapter->dev, | |
1160 | "cmd: WMM: WMM_GET_STATUS cmd sent\n"); | |
1161 | cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS); | |
1162 | cmd_ptr->size = | |
1163 | cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) + | |
1164 | S_DS_GEN); | |
1165 | ret = 0; | |
1166 | break; | |
1167 | case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS: | |
572e8f3e AK |
1168 | ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action, |
1169 | data_buf); | |
5e6e3a92 BZ |
1170 | break; |
1171 | case HostCmd_CMD_MAC_REG_ACCESS: | |
1172 | case HostCmd_CMD_BBP_REG_ACCESS: | |
1173 | case HostCmd_CMD_RF_REG_ACCESS: | |
1174 | case HostCmd_CMD_PMIC_REG_ACCESS: | |
1175 | case HostCmd_CMD_CAU_REG_ACCESS: | |
1176 | case HostCmd_CMD_802_11_EEPROM_ACCESS: | |
1177 | ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf); | |
1178 | break; | |
1179 | case HostCmd_CMD_SET_BSS_MODE: | |
1180 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
eecd8250 | 1181 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) |
5e6e3a92 BZ |
1182 | cmd_ptr->params.bss_mode.con_type = |
1183 | CONNECTION_TYPE_ADHOC; | |
eecd8250 | 1184 | else if (priv->bss_mode == NL80211_IFTYPE_STATION) |
5e6e3a92 BZ |
1185 | cmd_ptr->params.bss_mode.con_type = |
1186 | CONNECTION_TYPE_INFRA; | |
1187 | cmd_ptr->size = cpu_to_le16(sizeof(struct | |
1188 | host_cmd_ds_set_bss_mode) + S_DS_GEN); | |
1189 | ret = 0; | |
1190 | break; | |
d930faee AK |
1191 | case HostCmd_CMD_PCIE_DESC_DETAILS: |
1192 | ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action); | |
1193 | break; | |
fa444bf8 AK |
1194 | case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: |
1195 | ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf); | |
1196 | break; | |
5e6e3a92 BZ |
1197 | default: |
1198 | dev_err(priv->adapter->dev, | |
1199 | "PREP_CMD: unknown cmd- %#x\n", cmd_no); | |
1200 | ret = -1; | |
1201 | break; | |
1202 | } | |
1203 | return ret; | |
1204 | } | |
1205 | ||
1206 | /* | |
1207 | * This function issues commands to initialize firmware. | |
1208 | * | |
1209 | * This is called after firmware download to bring the card to | |
1210 | * working state. | |
1211 | * | |
1212 | * The following commands are issued sequentially - | |
d930faee | 1213 | * - Set PCI-Express host buffer configuration (PCIE only) |
5e6e3a92 BZ |
1214 | * - Function init (for first interface only) |
1215 | * - Read MAC address (for first interface only) | |
1216 | * - Reconfigure Tx buffer size (for first interface only) | |
1217 | * - Enable auto deep sleep (for first interface only) | |
1218 | * - Get Tx rate | |
1219 | * - Get Tx power | |
1220 | * - Set IBSS coalescing status | |
1221 | * - Set AMSDU aggregation control | |
1222 | * - Set 11d control | |
1223 | * - Set MAC control (this must be the last command to initialize firmware) | |
1224 | */ | |
1225 | int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) | |
1226 | { | |
270e58e8 | 1227 | int ret; |
5e6e3a92 BZ |
1228 | u16 enable = true; |
1229 | struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl; | |
1230 | struct mwifiex_ds_auto_ds auto_ds; | |
1231 | enum state_11d_t state_11d; | |
cd27bc3c | 1232 | struct mwifiex_ds_11n_tx_cfg tx_cfg; |
5e6e3a92 BZ |
1233 | |
1234 | if (first_sta) { | |
d930faee AK |
1235 | if (priv->adapter->iface_type == MWIFIEX_PCIE) { |
1236 | ret = mwifiex_send_cmd_async(priv, | |
9c05fd72 YAP |
1237 | HostCmd_CMD_PCIE_DESC_DETAILS, |
1238 | HostCmd_ACT_GEN_SET, 0, NULL); | |
d930faee AK |
1239 | if (ret) |
1240 | return -1; | |
1241 | } | |
5e6e3a92 | 1242 | |
600f5d90 AK |
1243 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_FUNC_INIT, |
1244 | HostCmd_ACT_GEN_SET, 0, NULL); | |
5e6e3a92 BZ |
1245 | if (ret) |
1246 | return -1; | |
1247 | /* Read MAC address from HW */ | |
600f5d90 AK |
1248 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_GET_HW_SPEC, |
1249 | HostCmd_ACT_GEN_GET, 0, NULL); | |
5e6e3a92 BZ |
1250 | if (ret) |
1251 | return -1; | |
1252 | ||
1253 | /* Reconfigure tx buf size */ | |
600f5d90 AK |
1254 | ret = mwifiex_send_cmd_async(priv, |
1255 | HostCmd_CMD_RECONFIGURE_TX_BUFF, | |
1256 | HostCmd_ACT_GEN_SET, 0, | |
1257 | &priv->adapter->tx_buf_size); | |
5e6e3a92 BZ |
1258 | if (ret) |
1259 | return -1; | |
1260 | ||
03785387 AP |
1261 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
1262 | /* Enable IEEE PS by default */ | |
1263 | priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; | |
1264 | ret = mwifiex_send_cmd_async( | |
1265 | priv, HostCmd_CMD_802_11_PS_MODE_ENH, | |
1266 | EN_AUTO_PS, BITMAP_STA_PS, NULL); | |
1267 | if (ret) | |
1268 | return -1; | |
1269 | } | |
5e6e3a92 BZ |
1270 | } |
1271 | ||
1272 | /* get tx rate */ | |
600f5d90 AK |
1273 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TX_RATE_CFG, |
1274 | HostCmd_ACT_GEN_GET, 0, NULL); | |
5e6e3a92 BZ |
1275 | if (ret) |
1276 | return -1; | |
1277 | priv->data_rate = 0; | |
1278 | ||
1279 | /* get tx power */ | |
600f5d90 AK |
1280 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TXPWR_CFG, |
1281 | HostCmd_ACT_GEN_GET, 0, NULL); | |
5e6e3a92 BZ |
1282 | if (ret) |
1283 | return -1; | |
1284 | ||
03785387 AP |
1285 | if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) { |
1286 | /* set ibss coalescing_status */ | |
1287 | ret = mwifiex_send_cmd_async( | |
1288 | priv, HostCmd_CMD_802_11_IBSS_COALESCING_STATUS, | |
1289 | HostCmd_ACT_GEN_SET, 0, &enable); | |
1290 | if (ret) | |
1291 | return -1; | |
1292 | } | |
5e6e3a92 BZ |
1293 | |
1294 | memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl)); | |
1295 | amsdu_aggr_ctrl.enable = true; | |
1296 | /* Send request to firmware */ | |
600f5d90 AK |
1297 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_AMSDU_AGGR_CTRL, |
1298 | HostCmd_ACT_GEN_SET, 0, | |
a5ffddb7 | 1299 | &amsdu_aggr_ctrl); |
5e6e3a92 BZ |
1300 | if (ret) |
1301 | return -1; | |
1302 | /* MAC Control must be the last command in init_fw */ | |
1303 | /* set MAC Control */ | |
600f5d90 AK |
1304 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, |
1305 | HostCmd_ACT_GEN_SET, 0, | |
1306 | &priv->curr_pkt_filter); | |
5e6e3a92 BZ |
1307 | if (ret) |
1308 | return -1; | |
1309 | ||
03785387 AP |
1310 | if (first_sta && priv->adapter->iface_type != MWIFIEX_USB && |
1311 | priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { | |
5e6e3a92 BZ |
1312 | /* Enable auto deep sleep */ |
1313 | auto_ds.auto_ds = DEEP_SLEEP_ON; | |
1314 | auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME; | |
600f5d90 AK |
1315 | ret = mwifiex_send_cmd_async(priv, |
1316 | HostCmd_CMD_802_11_PS_MODE_ENH, | |
1317 | EN_AUTO_PS, BITMAP_AUTO_DS, | |
1318 | &auto_ds); | |
5e6e3a92 BZ |
1319 | if (ret) |
1320 | return -1; | |
1321 | } | |
1322 | ||
03785387 AP |
1323 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
1324 | /* Send cmd to FW to enable/disable 11D function */ | |
1325 | state_11d = ENABLE_11D; | |
1326 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SNMP_MIB, | |
1327 | HostCmd_ACT_GEN_SET, DOT11D_I, | |
1328 | &state_11d); | |
1329 | if (ret) | |
1330 | dev_err(priv->adapter->dev, | |
1331 | "11D: failed to enable 11D\n"); | |
1332 | } | |
5e6e3a92 | 1333 | |
cd27bc3c AK |
1334 | /* Send cmd to FW to configure 11n specific configuration |
1335 | * (Short GI, Channel BW, Green field support etc.) for transmit | |
1336 | */ | |
1337 | tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG; | |
1338 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_CFG, | |
1339 | HostCmd_ACT_GEN_SET, 0, &tx_cfg); | |
1340 | ||
5e6e3a92 | 1341 | /* set last_init_cmd */ |
cd27bc3c | 1342 | priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG; |
5e6e3a92 BZ |
1343 | ret = -EINPROGRESS; |
1344 | ||
1345 | return ret; | |
1346 | } |