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 | ||
caa8984f AK |
262 | /* |
263 | * This function prepares command to get RF Tx power. | |
264 | */ | |
265 | static int mwifiex_cmd_rf_tx_power(struct mwifiex_private *priv, | |
266 | struct host_cmd_ds_command *cmd, | |
267 | u16 cmd_action, void *data_buf) | |
268 | { | |
269 | struct host_cmd_ds_rf_tx_pwr *txp = &cmd->params.txp; | |
270 | ||
271 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_tx_pwr) | |
272 | + S_DS_GEN); | |
273 | cmd->command = cpu_to_le16(HostCmd_CMD_RF_TX_PWR); | |
274 | txp->action = cpu_to_le16(cmd_action); | |
275 | ||
276 | return 0; | |
277 | } | |
278 | ||
8a279d5b AK |
279 | /* |
280 | * This function prepares command to set rf antenna. | |
281 | */ | |
282 | static int mwifiex_cmd_rf_antenna(struct mwifiex_private *priv, | |
283 | struct host_cmd_ds_command *cmd, | |
284 | u16 cmd_action, | |
285 | struct mwifiex_ds_ant_cfg *ant_cfg) | |
286 | { | |
287 | struct host_cmd_ds_rf_ant_mimo *ant_mimo = &cmd->params.ant_mimo; | |
288 | struct host_cmd_ds_rf_ant_siso *ant_siso = &cmd->params.ant_siso; | |
289 | ||
290 | cmd->command = cpu_to_le16(HostCmd_CMD_RF_ANTENNA); | |
291 | ||
292 | if (cmd_action != HostCmd_ACT_GEN_SET) | |
293 | return 0; | |
294 | ||
295 | if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) { | |
296 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_mimo) + | |
297 | S_DS_GEN); | |
298 | ant_mimo->action_tx = cpu_to_le16(HostCmd_ACT_SET_TX); | |
299 | ant_mimo->tx_ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant); | |
300 | ant_mimo->action_rx = cpu_to_le16(HostCmd_ACT_SET_RX); | |
301 | ant_mimo->rx_ant_mode = cpu_to_le16((u16)ant_cfg->rx_ant); | |
302 | } else { | |
303 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_siso) + | |
304 | S_DS_GEN); | |
305 | ant_siso->action = cpu_to_le16(HostCmd_ACT_SET_BOTH); | |
306 | ant_siso->ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant); | |
307 | } | |
308 | ||
309 | return 0; | |
310 | } | |
311 | ||
5e6e3a92 BZ |
312 | /* |
313 | * This function prepares command to set Host Sleep configuration. | |
314 | * | |
315 | * Preparation includes - | |
316 | * - Setting command ID and proper size | |
317 | * - Setting Host Sleep action, conditions, ARP filters | |
318 | * (as required) | |
319 | * - Ensuring correct endian-ness | |
320 | */ | |
a5ffddb7 AK |
321 | static int |
322 | mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv, | |
323 | struct host_cmd_ds_command *cmd, | |
324 | u16 cmd_action, | |
325 | struct mwifiex_hs_config_param *hscfg_param) | |
5e6e3a92 BZ |
326 | { |
327 | struct mwifiex_adapter *adapter = priv->adapter; | |
328 | struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg; | |
329 | u16 hs_activate = false; | |
330 | ||
a5ffddb7 | 331 | if (!hscfg_param) |
5e6e3a92 BZ |
332 | /* New Activate command */ |
333 | hs_activate = true; | |
334 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH); | |
335 | ||
336 | if (!hs_activate && | |
9c05fd72 YAP |
337 | (hscfg_param->conditions != cpu_to_le32(HOST_SLEEP_CFG_CANCEL)) && |
338 | ((adapter->arp_filter_size > 0) && | |
339 | (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) { | |
5e6e3a92 BZ |
340 | dev_dbg(adapter->dev, |
341 | "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n", | |
9c05fd72 | 342 | adapter->arp_filter_size); |
5e6e3a92 BZ |
343 | memcpy(((u8 *) hs_cfg) + |
344 | sizeof(struct host_cmd_ds_802_11_hs_cfg_enh), | |
345 | adapter->arp_filter, adapter->arp_filter_size); | |
9c05fd72 YAP |
346 | cmd->size = cpu_to_le16 |
347 | (adapter->arp_filter_size + | |
348 | sizeof(struct host_cmd_ds_802_11_hs_cfg_enh) | |
349 | + S_DS_GEN); | |
5e6e3a92 BZ |
350 | } else { |
351 | cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct | |
9c05fd72 | 352 | host_cmd_ds_802_11_hs_cfg_enh)); |
5e6e3a92 BZ |
353 | } |
354 | if (hs_activate) { | |
355 | hs_cfg->action = cpu_to_le16(HS_ACTIVATE); | |
356 | hs_cfg->params.hs_activate.resp_ctrl = RESP_NEEDED; | |
357 | } else { | |
358 | hs_cfg->action = cpu_to_le16(HS_CONFIGURE); | |
a5ffddb7 AK |
359 | hs_cfg->params.hs_config.conditions = hscfg_param->conditions; |
360 | hs_cfg->params.hs_config.gpio = hscfg_param->gpio; | |
361 | hs_cfg->params.hs_config.gap = hscfg_param->gap; | |
5e6e3a92 BZ |
362 | dev_dbg(adapter->dev, |
363 | "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n", | |
364 | hs_cfg->params.hs_config.conditions, | |
365 | hs_cfg->params.hs_config.gpio, | |
366 | hs_cfg->params.hs_config.gap); | |
367 | } | |
368 | ||
369 | return 0; | |
370 | } | |
371 | ||
372 | /* | |
373 | * This function prepares command to set/get MAC address. | |
374 | * | |
375 | * Preparation includes - | |
376 | * - Setting command ID, action and proper size | |
377 | * - Setting MAC address (for SET only) | |
378 | * - Ensuring correct endian-ness | |
379 | */ | |
380 | static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv, | |
381 | struct host_cmd_ds_command *cmd, | |
382 | u16 cmd_action) | |
383 | { | |
384 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS); | |
385 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address) + | |
386 | S_DS_GEN); | |
387 | cmd->result = 0; | |
388 | ||
389 | cmd->params.mac_addr.action = cpu_to_le16(cmd_action); | |
390 | ||
391 | if (cmd_action == HostCmd_ACT_GEN_SET) | |
392 | memcpy(cmd->params.mac_addr.mac_addr, priv->curr_addr, | |
393 | ETH_ALEN); | |
394 | return 0; | |
395 | } | |
396 | ||
397 | /* | |
398 | * This function prepares command to set MAC multicast address. | |
399 | * | |
400 | * Preparation includes - | |
401 | * - Setting command ID, action and proper size | |
402 | * - Setting MAC multicast address | |
403 | * - Ensuring correct endian-ness | |
404 | */ | |
a5ffddb7 AK |
405 | static int |
406 | mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd, | |
407 | u16 cmd_action, | |
408 | struct mwifiex_multicast_list *mcast_list) | |
5e6e3a92 | 409 | { |
5e6e3a92 BZ |
410 | struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr; |
411 | ||
412 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) + | |
413 | S_DS_GEN); | |
414 | cmd->command = cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR); | |
415 | ||
416 | mcast_addr->action = cpu_to_le16(cmd_action); | |
417 | mcast_addr->num_of_adrs = | |
418 | cpu_to_le16((u16) mcast_list->num_multicast_addr); | |
419 | memcpy(mcast_addr->mac_list, mcast_list->mac_list, | |
420 | mcast_list->num_multicast_addr * ETH_ALEN); | |
421 | ||
422 | return 0; | |
423 | } | |
424 | ||
425 | /* | |
426 | * This function prepares command to deauthenticate. | |
427 | * | |
428 | * Preparation includes - | |
429 | * - Setting command ID and proper size | |
430 | * - Setting AP MAC address and reason code | |
431 | * - Ensuring correct endian-ness | |
432 | */ | |
433 | static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv, | |
434 | struct host_cmd_ds_command *cmd, | |
a5ffddb7 | 435 | u8 *mac) |
5e6e3a92 BZ |
436 | { |
437 | struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth; | |
438 | ||
439 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE); | |
440 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate) | |
441 | + S_DS_GEN); | |
442 | ||
443 | /* Set AP MAC address */ | |
a5ffddb7 | 444 | memcpy(deauth->mac_addr, mac, ETH_ALEN); |
5e6e3a92 BZ |
445 | |
446 | dev_dbg(priv->adapter->dev, "cmd: Deauth: %pM\n", deauth->mac_addr); | |
447 | ||
448 | deauth->reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING); | |
449 | ||
450 | return 0; | |
451 | } | |
452 | ||
453 | /* | |
454 | * This function prepares command to stop Ad-Hoc network. | |
455 | * | |
456 | * Preparation includes - | |
457 | * - Setting command ID and proper size | |
458 | * - Ensuring correct endian-ness | |
459 | */ | |
572e8f3e | 460 | static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command *cmd) |
5e6e3a92 BZ |
461 | { |
462 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP); | |
463 | cmd->size = cpu_to_le16(S_DS_GEN); | |
464 | return 0; | |
465 | } | |
466 | ||
467 | /* | |
468 | * This function sets WEP key(s) to key parameter TLV(s). | |
469 | * | |
470 | * Multi-key parameter TLVs are supported, so we can send multiple | |
471 | * WEP keys in a single buffer. | |
472 | */ | |
473 | static int | |
474 | mwifiex_set_keyparamset_wep(struct mwifiex_private *priv, | |
475 | struct mwifiex_ie_type_key_param_set *key_param_set, | |
476 | u16 *key_param_len) | |
477 | { | |
270e58e8 | 478 | int cur_key_param_len; |
5e6e3a92 BZ |
479 | u8 i; |
480 | ||
481 | /* Multi-key_param_set TLV is supported */ | |
482 | for (i = 0; i < NUM_WEP_KEYS; i++) { | |
483 | if ((priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP40) || | |
484 | (priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP104)) { | |
485 | key_param_set->type = | |
486 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); | |
487 | /* Key_param_set WEP fixed length */ | |
488 | #define KEYPARAMSET_WEP_FIXED_LEN 8 | |
489 | key_param_set->length = cpu_to_le16((u16) | |
490 | (priv->wep_key[i]. | |
491 | key_length + | |
492 | KEYPARAMSET_WEP_FIXED_LEN)); | |
493 | key_param_set->key_type_id = | |
494 | cpu_to_le16(KEY_TYPE_ID_WEP); | |
495 | key_param_set->key_info = | |
6a35a0ac YAP |
496 | cpu_to_le16(KEY_ENABLED | KEY_UNICAST | |
497 | KEY_MCAST); | |
5e6e3a92 BZ |
498 | key_param_set->key_len = |
499 | cpu_to_le16(priv->wep_key[i].key_length); | |
500 | /* Set WEP key index */ | |
501 | key_param_set->key[0] = i; | |
502 | /* Set default Tx key flag */ | |
503 | if (i == | |
504 | (priv-> | |
505 | wep_key_curr_index & HostCmd_WEP_KEY_INDEX_MASK)) | |
506 | key_param_set->key[1] = 1; | |
507 | else | |
508 | key_param_set->key[1] = 0; | |
509 | memmove(&key_param_set->key[2], | |
510 | priv->wep_key[i].key_material, | |
511 | priv->wep_key[i].key_length); | |
512 | ||
513 | cur_key_param_len = priv->wep_key[i].key_length + | |
514 | KEYPARAMSET_WEP_FIXED_LEN + | |
515 | sizeof(struct mwifiex_ie_types_header); | |
516 | *key_param_len += (u16) cur_key_param_len; | |
517 | key_param_set = | |
518 | (struct mwifiex_ie_type_key_param_set *) | |
519 | ((u8 *)key_param_set + | |
9c05fd72 | 520 | cur_key_param_len); |
5e6e3a92 BZ |
521 | } else if (!priv->wep_key[i].key_length) { |
522 | continue; | |
523 | } else { | |
524 | dev_err(priv->adapter->dev, | |
525 | "key%d Length = %d is incorrect\n", | |
526 | (i + 1), priv->wep_key[i].key_length); | |
527 | return -1; | |
528 | } | |
529 | } | |
530 | ||
531 | return 0; | |
532 | } | |
533 | ||
534 | /* | |
535 | * This function prepares command to set/get/reset network key(s). | |
536 | * | |
537 | * Preparation includes - | |
538 | * - Setting command ID, action and proper size | |
539 | * - Setting WEP keys, WAPI keys or WPA keys along with required | |
540 | * encryption (TKIP, AES) (as required) | |
541 | * - Ensuring correct endian-ness | |
542 | */ | |
a5ffddb7 AK |
543 | static int |
544 | mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv, | |
545 | struct host_cmd_ds_command *cmd, | |
546 | u16 cmd_action, u32 cmd_oid, | |
547 | struct mwifiex_ds_encrypt_key *enc_key) | |
5e6e3a92 BZ |
548 | { |
549 | struct host_cmd_ds_802_11_key_material *key_material = | |
550 | &cmd->params.key_material; | |
75edd2c6 AP |
551 | struct host_cmd_tlv_mac_addr *tlv_mac; |
552 | u16 key_param_len = 0, cmd_size; | |
5e6e3a92 BZ |
553 | int ret = 0; |
554 | const u8 bc_mac[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | |
555 | ||
556 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_KEY_MATERIAL); | |
557 | key_material->action = cpu_to_le16(cmd_action); | |
558 | ||
559 | if (cmd_action == HostCmd_ACT_GEN_GET) { | |
560 | cmd->size = | |
561 | cpu_to_le16(sizeof(key_material->action) + S_DS_GEN); | |
562 | return ret; | |
563 | } | |
564 | ||
565 | if (!enc_key) { | |
566 | memset(&key_material->key_param_set, 0, | |
567 | (NUM_WEP_KEYS * | |
568 | sizeof(struct mwifiex_ie_type_key_param_set))); | |
569 | ret = mwifiex_set_keyparamset_wep(priv, | |
570 | &key_material->key_param_set, | |
571 | &key_param_len); | |
572 | cmd->size = cpu_to_le16(key_param_len + | |
573 | sizeof(key_material->action) + S_DS_GEN); | |
574 | return ret; | |
575 | } else | |
576 | memset(&key_material->key_param_set, 0, | |
577 | sizeof(struct mwifiex_ie_type_key_param_set)); | |
578 | if (enc_key->is_wapi_key) { | |
579 | dev_dbg(priv->adapter->dev, "info: Set WAPI Key\n"); | |
580 | key_material->key_param_set.key_type_id = | |
9c05fd72 | 581 | cpu_to_le16(KEY_TYPE_ID_WAPI); |
5e6e3a92 BZ |
582 | if (cmd_oid == KEY_INFO_ENABLED) |
583 | key_material->key_param_set.key_info = | |
9c05fd72 | 584 | cpu_to_le16(KEY_ENABLED); |
5e6e3a92 BZ |
585 | else |
586 | key_material->key_param_set.key_info = | |
9c05fd72 | 587 | cpu_to_le16(!KEY_ENABLED); |
5e6e3a92 BZ |
588 | |
589 | key_material->key_param_set.key[0] = enc_key->key_index; | |
590 | if (!priv->sec_info.wapi_key_on) | |
591 | key_material->key_param_set.key[1] = 1; | |
592 | else | |
593 | /* set 0 when re-key */ | |
594 | key_material->key_param_set.key[1] = 0; | |
595 | ||
596 | if (0 != memcmp(enc_key->mac_addr, bc_mac, sizeof(bc_mac))) { | |
597 | /* WAPI pairwise key: unicast */ | |
598 | key_material->key_param_set.key_info |= | |
6a35a0ac | 599 | cpu_to_le16(KEY_UNICAST); |
5e6e3a92 BZ |
600 | } else { /* WAPI group key: multicast */ |
601 | key_material->key_param_set.key_info |= | |
6a35a0ac | 602 | cpu_to_le16(KEY_MCAST); |
5e6e3a92 BZ |
603 | priv->sec_info.wapi_key_on = true; |
604 | } | |
605 | ||
606 | key_material->key_param_set.type = | |
9c05fd72 | 607 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
5e6e3a92 | 608 | key_material->key_param_set.key_len = |
9c05fd72 | 609 | cpu_to_le16(WAPI_KEY_LEN); |
5e6e3a92 BZ |
610 | memcpy(&key_material->key_param_set.key[2], |
611 | enc_key->key_material, enc_key->key_len); | |
612 | memcpy(&key_material->key_param_set.key[2 + enc_key->key_len], | |
9d7aba63 | 613 | enc_key->pn, PN_LEN); |
5e6e3a92 BZ |
614 | key_material->key_param_set.length = |
615 | cpu_to_le16(WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN); | |
616 | ||
617 | key_param_len = (WAPI_KEY_LEN + KEYPARAMSET_FIXED_LEN) + | |
618 | sizeof(struct mwifiex_ie_types_header); | |
9c05fd72 YAP |
619 | cmd->size = cpu_to_le16(sizeof(key_material->action) |
620 | + S_DS_GEN + key_param_len); | |
5e6e3a92 BZ |
621 | return ret; |
622 | } | |
623 | if (enc_key->key_len == WLAN_KEY_LEN_CCMP) { | |
b877f4cf YL |
624 | if (enc_key->is_igtk_key) { |
625 | dev_dbg(priv->adapter->dev, "cmd: CMAC_AES\n"); | |
626 | key_material->key_param_set.key_type_id = | |
627 | cpu_to_le16(KEY_TYPE_ID_AES_CMAC); | |
628 | if (cmd_oid == KEY_INFO_ENABLED) | |
629 | key_material->key_param_set.key_info = | |
630 | cpu_to_le16(KEY_ENABLED); | |
631 | else | |
632 | key_material->key_param_set.key_info = | |
633 | cpu_to_le16(!KEY_ENABLED); | |
634 | ||
635 | key_material->key_param_set.key_info |= | |
636 | cpu_to_le16(KEY_IGTK); | |
637 | } else { | |
638 | dev_dbg(priv->adapter->dev, "cmd: WPA_AES\n"); | |
639 | key_material->key_param_set.key_type_id = | |
9c05fd72 | 640 | cpu_to_le16(KEY_TYPE_ID_AES); |
b877f4cf YL |
641 | if (cmd_oid == KEY_INFO_ENABLED) |
642 | key_material->key_param_set.key_info = | |
9c05fd72 | 643 | cpu_to_le16(KEY_ENABLED); |
b877f4cf YL |
644 | else |
645 | key_material->key_param_set.key_info = | |
9c05fd72 | 646 | cpu_to_le16(!KEY_ENABLED); |
5e6e3a92 | 647 | |
b877f4cf | 648 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) |
5e6e3a92 | 649 | /* AES pairwise key: unicast */ |
b877f4cf | 650 | key_material->key_param_set.key_info |= |
9c05fd72 | 651 | cpu_to_le16(KEY_UNICAST); |
b877f4cf YL |
652 | else /* AES group key: multicast */ |
653 | key_material->key_param_set.key_info |= | |
9c05fd72 | 654 | cpu_to_le16(KEY_MCAST); |
b877f4cf | 655 | } |
5e6e3a92 BZ |
656 | } else if (enc_key->key_len == WLAN_KEY_LEN_TKIP) { |
657 | dev_dbg(priv->adapter->dev, "cmd: WPA_TKIP\n"); | |
658 | key_material->key_param_set.key_type_id = | |
9c05fd72 | 659 | cpu_to_le16(KEY_TYPE_ID_TKIP); |
5e6e3a92 | 660 | key_material->key_param_set.key_info = |
9c05fd72 | 661 | cpu_to_le16(KEY_ENABLED); |
5e6e3a92 BZ |
662 | |
663 | if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST) | |
664 | /* TKIP pairwise key: unicast */ | |
665 | key_material->key_param_set.key_info |= | |
9c05fd72 | 666 | cpu_to_le16(KEY_UNICAST); |
5e6e3a92 BZ |
667 | else /* TKIP group key: multicast */ |
668 | key_material->key_param_set.key_info |= | |
9c05fd72 | 669 | cpu_to_le16(KEY_MCAST); |
5e6e3a92 BZ |
670 | } |
671 | ||
672 | if (key_material->key_param_set.key_type_id) { | |
673 | key_material->key_param_set.type = | |
9c05fd72 | 674 | cpu_to_le16(TLV_TYPE_KEY_MATERIAL); |
5e6e3a92 | 675 | key_material->key_param_set.key_len = |
9c05fd72 | 676 | cpu_to_le16((u16) enc_key->key_len); |
5e6e3a92 BZ |
677 | memcpy(key_material->key_param_set.key, enc_key->key_material, |
678 | enc_key->key_len); | |
679 | key_material->key_param_set.length = | |
680 | cpu_to_le16((u16) enc_key->key_len + | |
681 | KEYPARAMSET_FIXED_LEN); | |
682 | ||
75edd2c6 | 683 | key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN) |
9c05fd72 | 684 | + sizeof(struct mwifiex_ie_types_header); |
5e6e3a92 | 685 | |
b877f4cf YL |
686 | if (le16_to_cpu(key_material->key_param_set.key_type_id) == |
687 | KEY_TYPE_ID_AES_CMAC) { | |
688 | struct mwifiex_cmac_param *param = | |
689 | (void *)key_material->key_param_set.key; | |
690 | ||
691 | memcpy(param->ipn, enc_key->pn, IGTK_PN_LEN); | |
692 | memcpy(param->key, enc_key->key_material, | |
693 | enc_key->key_len); | |
694 | ||
695 | key_param_len = sizeof(struct mwifiex_cmac_param); | |
696 | key_material->key_param_set.key_len = | |
697 | cpu_to_le16(key_param_len); | |
698 | key_param_len += KEYPARAMSET_FIXED_LEN; | |
699 | key_material->key_param_set.length = | |
700 | cpu_to_le16(key_param_len); | |
701 | key_param_len += sizeof(struct mwifiex_ie_types_header); | |
702 | } | |
703 | ||
9c05fd72 YAP |
704 | cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN |
705 | + key_param_len); | |
75edd2c6 AP |
706 | |
707 | if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) { | |
708 | tlv_mac = (void *)((u8 *)&key_material->key_param_set + | |
709 | key_param_len); | |
710 | tlv_mac->tlv.type = cpu_to_le16(TLV_TYPE_STA_MAC_ADDR); | |
711 | tlv_mac->tlv.len = cpu_to_le16(ETH_ALEN); | |
712 | memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN); | |
713 | cmd_size = key_param_len + S_DS_GEN + | |
714 | sizeof(key_material->action) + | |
715 | sizeof(struct host_cmd_tlv_mac_addr); | |
716 | } else { | |
717 | cmd_size = key_param_len + S_DS_GEN + | |
718 | sizeof(key_material->action); | |
719 | } | |
720 | cmd->size = cpu_to_le16(cmd_size); | |
5e6e3a92 BZ |
721 | } |
722 | ||
723 | return ret; | |
724 | } | |
725 | ||
726 | /* | |
727 | * This function prepares command to set/get 11d domain information. | |
728 | * | |
729 | * Preparation includes - | |
730 | * - Setting command ID, action and proper size | |
731 | * - Setting domain information fields (for SET only) | |
732 | * - Ensuring correct endian-ness | |
733 | */ | |
734 | static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv, | |
735 | struct host_cmd_ds_command *cmd, | |
736 | u16 cmd_action) | |
737 | { | |
738 | struct mwifiex_adapter *adapter = priv->adapter; | |
739 | struct host_cmd_ds_802_11d_domain_info *domain_info = | |
740 | &cmd->params.domain_info; | |
741 | struct mwifiex_ietypes_domain_param_set *domain = | |
742 | &domain_info->domain; | |
743 | u8 no_of_triplet = adapter->domain_reg.no_of_triplet; | |
744 | ||
745 | dev_dbg(adapter->dev, "info: 11D: no_of_triplet=0x%x\n", no_of_triplet); | |
746 | ||
747 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO); | |
748 | domain_info->action = cpu_to_le16(cmd_action); | |
749 | if (cmd_action == HostCmd_ACT_GEN_GET) { | |
750 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); | |
751 | return 0; | |
752 | } | |
753 | ||
754 | /* Set domain info fields */ | |
755 | domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY); | |
756 | memcpy(domain->country_code, adapter->domain_reg.country_code, | |
9c05fd72 | 757 | sizeof(domain->country_code)); |
5e6e3a92 | 758 | |
9c05fd72 YAP |
759 | domain->header.len = |
760 | cpu_to_le16((no_of_triplet * | |
761 | sizeof(struct ieee80211_country_ie_triplet)) | |
762 | + sizeof(domain->country_code)); | |
5e6e3a92 BZ |
763 | |
764 | if (no_of_triplet) { | |
765 | memcpy(domain->triplet, adapter->domain_reg.triplet, | |
9c05fd72 YAP |
766 | no_of_triplet * sizeof(struct |
767 | ieee80211_country_ie_triplet)); | |
5e6e3a92 BZ |
768 | |
769 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + | |
9c05fd72 YAP |
770 | le16_to_cpu(domain->header.len) + |
771 | sizeof(struct mwifiex_ie_types_header) | |
772 | + S_DS_GEN); | |
5e6e3a92 BZ |
773 | } else { |
774 | cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN); | |
775 | } | |
776 | ||
777 | return 0; | |
778 | } | |
779 | ||
5e6e3a92 BZ |
780 | /* |
781 | * This function prepares command to set/get IBSS coalescing status. | |
782 | * | |
783 | * Preparation includes - | |
784 | * - Setting command ID, action and proper size | |
785 | * - Setting status to enable or disable (for SET only) | |
786 | * - Ensuring correct endian-ness | |
787 | */ | |
572e8f3e | 788 | static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd, |
a5ffddb7 | 789 | u16 cmd_action, u16 *enable) |
5e6e3a92 BZ |
790 | { |
791 | struct host_cmd_ds_802_11_ibss_status *ibss_coal = | |
792 | &(cmd->params.ibss_coalescing); | |
5e6e3a92 BZ |
793 | |
794 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS); | |
795 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) + | |
796 | S_DS_GEN); | |
797 | cmd->result = 0; | |
798 | ibss_coal->action = cpu_to_le16(cmd_action); | |
799 | ||
800 | switch (cmd_action) { | |
801 | case HostCmd_ACT_GEN_SET: | |
a5ffddb7 AK |
802 | if (enable) |
803 | ibss_coal->enable = cpu_to_le16(*enable); | |
a5e5aa6c DC |
804 | else |
805 | ibss_coal->enable = 0; | |
5e6e3a92 BZ |
806 | break; |
807 | ||
808 | /* In other case.. Nothing to do */ | |
809 | case HostCmd_ACT_GEN_GET: | |
810 | default: | |
811 | break; | |
812 | } | |
813 | ||
814 | return 0; | |
815 | } | |
816 | ||
817 | /* | |
818 | * This function prepares command to set/get register value. | |
819 | * | |
820 | * Preparation includes - | |
821 | * - Setting command ID, action and proper size | |
822 | * - Setting register offset (for both GET and SET) and | |
823 | * register value (for SET only) | |
824 | * - Ensuring correct endian-ness | |
825 | * | |
826 | * The following type of registers can be accessed with this function - | |
827 | * - MAC register | |
828 | * - BBP register | |
829 | * - RF register | |
830 | * - PMIC register | |
831 | * - CAU register | |
832 | * - EEPROM | |
833 | */ | |
834 | static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd, | |
835 | u16 cmd_action, void *data_buf) | |
836 | { | |
a5ffddb7 | 837 | struct mwifiex_ds_reg_rw *reg_rw = data_buf; |
5e6e3a92 | 838 | |
5e6e3a92 BZ |
839 | switch (le16_to_cpu(cmd->command)) { |
840 | case HostCmd_CMD_MAC_REG_ACCESS: | |
841 | { | |
842 | struct host_cmd_ds_mac_reg_access *mac_reg; | |
843 | ||
844 | cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN); | |
2c208890 | 845 | mac_reg = &cmd->params.mac_reg; |
5e6e3a92 BZ |
846 | mac_reg->action = cpu_to_le16(cmd_action); |
847 | mac_reg->offset = | |
848 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); | |
849 | mac_reg->value = reg_rw->value; | |
850 | break; | |
851 | } | |
852 | case HostCmd_CMD_BBP_REG_ACCESS: | |
853 | { | |
854 | struct host_cmd_ds_bbp_reg_access *bbp_reg; | |
855 | ||
856 | cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN); | |
2c208890 | 857 | bbp_reg = &cmd->params.bbp_reg; |
5e6e3a92 BZ |
858 | bbp_reg->action = cpu_to_le16(cmd_action); |
859 | bbp_reg->offset = | |
860 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); | |
861 | bbp_reg->value = (u8) le32_to_cpu(reg_rw->value); | |
862 | break; | |
863 | } | |
864 | case HostCmd_CMD_RF_REG_ACCESS: | |
865 | { | |
866 | struct host_cmd_ds_rf_reg_access *rf_reg; | |
867 | ||
868 | cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN); | |
2c208890 | 869 | rf_reg = &cmd->params.rf_reg; |
5e6e3a92 | 870 | rf_reg->action = cpu_to_le16(cmd_action); |
9c05fd72 | 871 | rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
5e6e3a92 BZ |
872 | rf_reg->value = (u8) le32_to_cpu(reg_rw->value); |
873 | break; | |
874 | } | |
875 | case HostCmd_CMD_PMIC_REG_ACCESS: | |
876 | { | |
877 | struct host_cmd_ds_pmic_reg_access *pmic_reg; | |
878 | ||
879 | cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN); | |
2c208890 | 880 | pmic_reg = &cmd->params.pmic_reg; |
5e6e3a92 BZ |
881 | pmic_reg->action = cpu_to_le16(cmd_action); |
882 | pmic_reg->offset = | |
9c05fd72 | 883 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
5e6e3a92 BZ |
884 | pmic_reg->value = (u8) le32_to_cpu(reg_rw->value); |
885 | break; | |
886 | } | |
887 | case HostCmd_CMD_CAU_REG_ACCESS: | |
888 | { | |
889 | struct host_cmd_ds_rf_reg_access *cau_reg; | |
890 | ||
891 | cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN); | |
2c208890 | 892 | cau_reg = &cmd->params.rf_reg; |
5e6e3a92 BZ |
893 | cau_reg->action = cpu_to_le16(cmd_action); |
894 | cau_reg->offset = | |
9c05fd72 | 895 | cpu_to_le16((u16) le32_to_cpu(reg_rw->offset)); |
5e6e3a92 BZ |
896 | cau_reg->value = (u8) le32_to_cpu(reg_rw->value); |
897 | break; | |
898 | } | |
899 | case HostCmd_CMD_802_11_EEPROM_ACCESS: | |
900 | { | |
a5ffddb7 | 901 | struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf; |
5e6e3a92 | 902 | struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom = |
5e6e3a92 BZ |
903 | &cmd->params.eeprom; |
904 | ||
905 | cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN); | |
906 | cmd_eeprom->action = cpu_to_le16(cmd_action); | |
907 | cmd_eeprom->offset = rd_eeprom->offset; | |
908 | cmd_eeprom->byte_count = rd_eeprom->byte_count; | |
909 | cmd_eeprom->value = 0; | |
910 | break; | |
911 | } | |
912 | default: | |
913 | return -1; | |
914 | } | |
915 | ||
916 | return 0; | |
917 | } | |
918 | ||
d930faee AK |
919 | /* |
920 | * This function prepares command to set PCI-Express | |
921 | * host buffer configuration | |
922 | * | |
923 | * Preparation includes - | |
924 | * - Setting command ID, action and proper size | |
925 | * - Setting host buffer configuration | |
926 | * - Ensuring correct endian-ness | |
927 | */ | |
928 | static int | |
929 | mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv, | |
9c05fd72 | 930 | struct host_cmd_ds_command *cmd, u16 action) |
d930faee AK |
931 | { |
932 | struct host_cmd_ds_pcie_details *host_spec = | |
933 | &cmd->params.pcie_host_spec; | |
934 | struct pcie_service_card *card = priv->adapter->card; | |
935 | phys_addr_t *buf_pa; | |
936 | ||
937 | cmd->command = cpu_to_le16(HostCmd_CMD_PCIE_DESC_DETAILS); | |
938 | cmd->size = cpu_to_le16(sizeof(struct | |
939 | host_cmd_ds_pcie_details) + S_DS_GEN); | |
940 | cmd->result = 0; | |
941 | ||
942 | memset(host_spec, 0, sizeof(struct host_cmd_ds_pcie_details)); | |
943 | ||
9c05fd72 YAP |
944 | if (action != HostCmd_ACT_GEN_SET) |
945 | return 0; | |
946 | ||
947 | /* Send the ring base addresses and count to firmware */ | |
948 | host_spec->txbd_addr_lo = (u32)(card->txbd_ring_pbase); | |
949 | host_spec->txbd_addr_hi = (u32)(((u64)card->txbd_ring_pbase)>>32); | |
950 | host_spec->txbd_count = MWIFIEX_MAX_TXRX_BD; | |
951 | host_spec->rxbd_addr_lo = (u32)(card->rxbd_ring_pbase); | |
952 | host_spec->rxbd_addr_hi = (u32)(((u64)card->rxbd_ring_pbase)>>32); | |
953 | host_spec->rxbd_count = MWIFIEX_MAX_TXRX_BD; | |
954 | host_spec->evtbd_addr_lo = (u32)(card->evtbd_ring_pbase); | |
955 | host_spec->evtbd_addr_hi = (u32)(((u64)card->evtbd_ring_pbase)>>32); | |
956 | host_spec->evtbd_count = MWIFIEX_MAX_EVT_BD; | |
957 | if (card->sleep_cookie) { | |
958 | buf_pa = MWIFIEX_SKB_PACB(card->sleep_cookie); | |
959 | host_spec->sleep_cookie_addr_lo = (u32) *buf_pa; | |
960 | host_spec->sleep_cookie_addr_hi = (u32) (((u64)*buf_pa) >> 32); | |
961 | dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n", | |
962 | host_spec->sleep_cookie_addr_lo); | |
d930faee AK |
963 | } |
964 | ||
965 | return 0; | |
966 | } | |
967 | ||
fa444bf8 AK |
968 | /* |
969 | * This function prepares command for event subscription, configuration | |
970 | * and query. Events can be subscribed or unsubscribed. Current subscribed | |
971 | * events can be queried. Also, current subscribed events are reported in | |
972 | * every FW response. | |
973 | */ | |
974 | static int | |
975 | mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv, | |
976 | struct host_cmd_ds_command *cmd, | |
977 | struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg) | |
978 | { | |
979 | struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt; | |
980 | struct mwifiex_ie_types_rssi_threshold *rssi_tlv; | |
981 | u16 event_bitmap; | |
982 | u8 *pos; | |
983 | ||
984 | cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT); | |
985 | cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) + | |
986 | S_DS_GEN); | |
987 | ||
988 | subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action); | |
989 | dev_dbg(priv->adapter->dev, "cmd: action: %d\n", subsc_evt_cfg->action); | |
990 | ||
991 | /*For query requests, no configuration TLV structures are to be added.*/ | |
992 | if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET) | |
993 | return 0; | |
994 | ||
995 | subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events); | |
996 | ||
997 | event_bitmap = subsc_evt_cfg->events; | |
998 | dev_dbg(priv->adapter->dev, "cmd: event bitmap : %16x\n", | |
999 | event_bitmap); | |
1000 | ||
1001 | if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) || | |
1002 | (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) && | |
1003 | (event_bitmap == 0)) { | |
1004 | dev_dbg(priv->adapter->dev, "Error: No event specified " | |
1005 | "for bitwise action type\n"); | |
1006 | return -EINVAL; | |
1007 | } | |
1008 | ||
1009 | /* | |
1010 | * Append TLV structures for each of the specified events for | |
1011 | * subscribing or re-configuring. This is not required for | |
1012 | * bitwise unsubscribing request. | |
1013 | */ | |
1014 | if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) | |
1015 | return 0; | |
1016 | ||
1017 | pos = ((u8 *)subsc_evt) + | |
1018 | sizeof(struct host_cmd_ds_802_11_subsc_evt); | |
1019 | ||
1020 | if (event_bitmap & BITMASK_BCN_RSSI_LOW) { | |
1021 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; | |
1022 | ||
1023 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW); | |
1024 | rssi_tlv->header.len = | |
1025 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - | |
1026 | sizeof(struct mwifiex_ie_types_header)); | |
1027 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value; | |
1028 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq; | |
1029 | ||
1030 | dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, " | |
1031 | "RSSI:-%d dBm, Freq:%d\n", | |
1032 | subsc_evt_cfg->bcn_l_rssi_cfg.abs_value, | |
1033 | subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq); | |
1034 | ||
1035 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); | |
1036 | le16_add_cpu(&cmd->size, | |
1037 | sizeof(struct mwifiex_ie_types_rssi_threshold)); | |
1038 | } | |
1039 | ||
1040 | if (event_bitmap & BITMASK_BCN_RSSI_HIGH) { | |
1041 | rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos; | |
1042 | ||
1043 | rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH); | |
1044 | rssi_tlv->header.len = | |
1045 | cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) - | |
1046 | sizeof(struct mwifiex_ie_types_header)); | |
1047 | rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value; | |
1048 | rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq; | |
1049 | ||
d35ccaa4 | 1050 | dev_dbg(priv->adapter->dev, "Cfg Beacon High Rssi event, " |
fa444bf8 AK |
1051 | "RSSI:-%d dBm, Freq:%d\n", |
1052 | subsc_evt_cfg->bcn_h_rssi_cfg.abs_value, | |
1053 | subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq); | |
1054 | ||
1055 | pos += sizeof(struct mwifiex_ie_types_rssi_threshold); | |
1056 | le16_add_cpu(&cmd->size, | |
1057 | sizeof(struct mwifiex_ie_types_rssi_threshold)); | |
1058 | } | |
1059 | ||
1060 | return 0; | |
1061 | } | |
1062 | ||
5e6e3a92 BZ |
1063 | /* |
1064 | * This function prepares the commands before sending them to the firmware. | |
1065 | * | |
1066 | * This is a generic function which calls specific command preparation | |
1067 | * routines based upon the command number. | |
1068 | */ | |
1069 | int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no, | |
1070 | u16 cmd_action, u32 cmd_oid, | |
1071 | void *data_buf, void *cmd_buf) | |
1072 | { | |
a5ffddb7 | 1073 | struct host_cmd_ds_command *cmd_ptr = cmd_buf; |
5e6e3a92 BZ |
1074 | int ret = 0; |
1075 | ||
1076 | /* Prepare command */ | |
1077 | switch (cmd_no) { | |
1078 | case HostCmd_CMD_GET_HW_SPEC: | |
1079 | ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr); | |
1080 | break; | |
1081 | case HostCmd_CMD_MAC_CONTROL: | |
1082 | ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action, | |
1083 | data_buf); | |
1084 | break; | |
1085 | case HostCmd_CMD_802_11_MAC_ADDRESS: | |
1086 | ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr, | |
1087 | cmd_action); | |
1088 | break; | |
1089 | case HostCmd_CMD_MAC_MULTICAST_ADR: | |
572e8f3e | 1090 | ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action, |
5e6e3a92 BZ |
1091 | data_buf); |
1092 | break; | |
1093 | case HostCmd_CMD_TX_RATE_CFG: | |
1094 | ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action, | |
1095 | data_buf); | |
1096 | break; | |
1097 | case HostCmd_CMD_TXPWR_CFG: | |
572e8f3e | 1098 | ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action, |
5e6e3a92 BZ |
1099 | data_buf); |
1100 | break; | |
caa8984f AK |
1101 | case HostCmd_CMD_RF_TX_PWR: |
1102 | ret = mwifiex_cmd_rf_tx_power(priv, cmd_ptr, cmd_action, | |
1103 | data_buf); | |
1104 | break; | |
8a279d5b AK |
1105 | case HostCmd_CMD_RF_ANTENNA: |
1106 | ret = mwifiex_cmd_rf_antenna(priv, cmd_ptr, cmd_action, | |
1107 | data_buf); | |
1108 | break; | |
5e6e3a92 BZ |
1109 | case HostCmd_CMD_802_11_PS_MODE_ENH: |
1110 | ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action, | |
1111 | (uint16_t)cmd_oid, data_buf); | |
1112 | break; | |
1113 | case HostCmd_CMD_802_11_HS_CFG_ENH: | |
1114 | ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action, | |
1115 | (struct mwifiex_hs_config_param *) data_buf); | |
1116 | break; | |
1117 | case HostCmd_CMD_802_11_SCAN: | |
572e8f3e | 1118 | ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf); |
5e6e3a92 BZ |
1119 | break; |
1120 | case HostCmd_CMD_802_11_BG_SCAN_QUERY: | |
572e8f3e | 1121 | ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr); |
5e6e3a92 BZ |
1122 | break; |
1123 | case HostCmd_CMD_802_11_ASSOCIATE: | |
1124 | ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf); | |
1125 | break; | |
1126 | case HostCmd_CMD_802_11_DEAUTHENTICATE: | |
1127 | ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr, | |
1128 | data_buf); | |
1129 | break; | |
1130 | case HostCmd_CMD_802_11_AD_HOC_START: | |
1131 | ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr, | |
1132 | data_buf); | |
1133 | break; | |
1134 | case HostCmd_CMD_802_11_GET_LOG: | |
572e8f3e | 1135 | ret = mwifiex_cmd_802_11_get_log(cmd_ptr); |
5e6e3a92 BZ |
1136 | break; |
1137 | case HostCmd_CMD_802_11_AD_HOC_JOIN: | |
1138 | ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr, | |
1139 | data_buf); | |
1140 | break; | |
1141 | case HostCmd_CMD_802_11_AD_HOC_STOP: | |
572e8f3e | 1142 | ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr); |
5e6e3a92 BZ |
1143 | break; |
1144 | case HostCmd_CMD_RSSI_INFO: | |
1145 | ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action); | |
1146 | break; | |
1147 | case HostCmd_CMD_802_11_SNMP_MIB: | |
1148 | ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action, | |
1149 | cmd_oid, data_buf); | |
1150 | break; | |
1151 | case HostCmd_CMD_802_11_TX_RATE_QUERY: | |
1152 | cmd_ptr->command = | |
1153 | cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY); | |
1154 | cmd_ptr->size = | |
1155 | cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) + | |
1156 | S_DS_GEN); | |
1157 | priv->tx_rate = 0; | |
1158 | ret = 0; | |
1159 | break; | |
1160 | case HostCmd_CMD_VERSION_EXT: | |
1161 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
1162 | cmd_ptr->params.verext.version_str_sel = | |
1163 | (u8) (*((u32 *) data_buf)); | |
1164 | memcpy(&cmd_ptr->params, data_buf, | |
1165 | sizeof(struct host_cmd_ds_version_ext)); | |
1166 | cmd_ptr->size = | |
1167 | cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) + | |
1168 | S_DS_GEN); | |
1169 | ret = 0; | |
1170 | break; | |
5e6e3a92 BZ |
1171 | case HostCmd_CMD_FUNC_INIT: |
1172 | if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET) | |
1173 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY; | |
1174 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
1175 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); | |
1176 | break; | |
1177 | case HostCmd_CMD_FUNC_SHUTDOWN: | |
1178 | priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET; | |
1179 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
1180 | cmd_ptr->size = cpu_to_le16(S_DS_GEN); | |
1181 | break; | |
1182 | case HostCmd_CMD_11N_ADDBA_REQ: | |
572e8f3e | 1183 | ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf); |
5e6e3a92 BZ |
1184 | break; |
1185 | case HostCmd_CMD_11N_DELBA: | |
572e8f3e | 1186 | ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf); |
5e6e3a92 BZ |
1187 | break; |
1188 | case HostCmd_CMD_11N_ADDBA_RSP: | |
1189 | ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf); | |
1190 | break; | |
1191 | case HostCmd_CMD_802_11_KEY_MATERIAL: | |
1192 | ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr, | |
9c05fd72 YAP |
1193 | cmd_action, cmd_oid, |
1194 | data_buf); | |
5e6e3a92 BZ |
1195 | break; |
1196 | case HostCmd_CMD_802_11D_DOMAIN_INFO: | |
1197 | ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr, | |
9c05fd72 | 1198 | cmd_action); |
5e6e3a92 BZ |
1199 | break; |
1200 | case HostCmd_CMD_RECONFIGURE_TX_BUFF: | |
1201 | ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action, | |
1202 | data_buf); | |
1203 | break; | |
1204 | case HostCmd_CMD_AMSDU_AGGR_CTRL: | |
572e8f3e | 1205 | ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action, |
5e6e3a92 BZ |
1206 | data_buf); |
1207 | break; | |
1208 | case HostCmd_CMD_11N_CFG: | |
9c05fd72 | 1209 | ret = mwifiex_cmd_11n_cfg(cmd_ptr, cmd_action, data_buf); |
5e6e3a92 BZ |
1210 | break; |
1211 | case HostCmd_CMD_WMM_GET_STATUS: | |
1212 | dev_dbg(priv->adapter->dev, | |
1213 | "cmd: WMM: WMM_GET_STATUS cmd sent\n"); | |
1214 | cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS); | |
1215 | cmd_ptr->size = | |
1216 | cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) + | |
1217 | S_DS_GEN); | |
1218 | ret = 0; | |
1219 | break; | |
1220 | case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS: | |
572e8f3e AK |
1221 | ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action, |
1222 | data_buf); | |
5e6e3a92 BZ |
1223 | break; |
1224 | case HostCmd_CMD_MAC_REG_ACCESS: | |
1225 | case HostCmd_CMD_BBP_REG_ACCESS: | |
1226 | case HostCmd_CMD_RF_REG_ACCESS: | |
1227 | case HostCmd_CMD_PMIC_REG_ACCESS: | |
1228 | case HostCmd_CMD_CAU_REG_ACCESS: | |
1229 | case HostCmd_CMD_802_11_EEPROM_ACCESS: | |
1230 | ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf); | |
1231 | break; | |
1232 | case HostCmd_CMD_SET_BSS_MODE: | |
1233 | cmd_ptr->command = cpu_to_le16(cmd_no); | |
eecd8250 | 1234 | if (priv->bss_mode == NL80211_IFTYPE_ADHOC) |
5e6e3a92 BZ |
1235 | cmd_ptr->params.bss_mode.con_type = |
1236 | CONNECTION_TYPE_ADHOC; | |
eecd8250 | 1237 | else if (priv->bss_mode == NL80211_IFTYPE_STATION) |
5e6e3a92 BZ |
1238 | cmd_ptr->params.bss_mode.con_type = |
1239 | CONNECTION_TYPE_INFRA; | |
1240 | cmd_ptr->size = cpu_to_le16(sizeof(struct | |
1241 | host_cmd_ds_set_bss_mode) + S_DS_GEN); | |
1242 | ret = 0; | |
1243 | break; | |
d930faee AK |
1244 | case HostCmd_CMD_PCIE_DESC_DETAILS: |
1245 | ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action); | |
1246 | break; | |
fa444bf8 AK |
1247 | case HostCmd_CMD_802_11_SUBSCRIBE_EVENT: |
1248 | ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf); | |
1249 | break; | |
5e6e3a92 BZ |
1250 | default: |
1251 | dev_err(priv->adapter->dev, | |
1252 | "PREP_CMD: unknown cmd- %#x\n", cmd_no); | |
1253 | ret = -1; | |
1254 | break; | |
1255 | } | |
1256 | return ret; | |
1257 | } | |
1258 | ||
1259 | /* | |
1260 | * This function issues commands to initialize firmware. | |
1261 | * | |
1262 | * This is called after firmware download to bring the card to | |
1263 | * working state. | |
1264 | * | |
1265 | * The following commands are issued sequentially - | |
d930faee | 1266 | * - Set PCI-Express host buffer configuration (PCIE only) |
5e6e3a92 BZ |
1267 | * - Function init (for first interface only) |
1268 | * - Read MAC address (for first interface only) | |
1269 | * - Reconfigure Tx buffer size (for first interface only) | |
1270 | * - Enable auto deep sleep (for first interface only) | |
1271 | * - Get Tx rate | |
1272 | * - Get Tx power | |
1273 | * - Set IBSS coalescing status | |
1274 | * - Set AMSDU aggregation control | |
1275 | * - Set 11d control | |
1276 | * - Set MAC control (this must be the last command to initialize firmware) | |
1277 | */ | |
1278 | int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta) | |
1279 | { | |
270e58e8 | 1280 | int ret; |
5e6e3a92 BZ |
1281 | u16 enable = true; |
1282 | struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl; | |
1283 | struct mwifiex_ds_auto_ds auto_ds; | |
1284 | enum state_11d_t state_11d; | |
cd27bc3c | 1285 | struct mwifiex_ds_11n_tx_cfg tx_cfg; |
5e6e3a92 BZ |
1286 | |
1287 | if (first_sta) { | |
d930faee AK |
1288 | if (priv->adapter->iface_type == MWIFIEX_PCIE) { |
1289 | ret = mwifiex_send_cmd_async(priv, | |
9c05fd72 YAP |
1290 | HostCmd_CMD_PCIE_DESC_DETAILS, |
1291 | HostCmd_ACT_GEN_SET, 0, NULL); | |
d930faee AK |
1292 | if (ret) |
1293 | return -1; | |
1294 | } | |
5e6e3a92 | 1295 | |
600f5d90 AK |
1296 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_FUNC_INIT, |
1297 | HostCmd_ACT_GEN_SET, 0, NULL); | |
5e6e3a92 BZ |
1298 | if (ret) |
1299 | return -1; | |
1300 | /* Read MAC address from HW */ | |
600f5d90 AK |
1301 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_GET_HW_SPEC, |
1302 | HostCmd_ACT_GEN_GET, 0, NULL); | |
5e6e3a92 BZ |
1303 | if (ret) |
1304 | return -1; | |
1305 | ||
1306 | /* Reconfigure tx buf size */ | |
600f5d90 AK |
1307 | ret = mwifiex_send_cmd_async(priv, |
1308 | HostCmd_CMD_RECONFIGURE_TX_BUFF, | |
1309 | HostCmd_ACT_GEN_SET, 0, | |
1310 | &priv->adapter->tx_buf_size); | |
5e6e3a92 BZ |
1311 | if (ret) |
1312 | return -1; | |
1313 | ||
03785387 AP |
1314 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
1315 | /* Enable IEEE PS by default */ | |
1316 | priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; | |
1317 | ret = mwifiex_send_cmd_async( | |
1318 | priv, HostCmd_CMD_802_11_PS_MODE_ENH, | |
1319 | EN_AUTO_PS, BITMAP_STA_PS, NULL); | |
1320 | if (ret) | |
1321 | return -1; | |
1322 | } | |
5e6e3a92 BZ |
1323 | } |
1324 | ||
1325 | /* get tx rate */ | |
600f5d90 AK |
1326 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_TX_RATE_CFG, |
1327 | HostCmd_ACT_GEN_GET, 0, NULL); | |
5e6e3a92 BZ |
1328 | if (ret) |
1329 | return -1; | |
1330 | priv->data_rate = 0; | |
1331 | ||
1332 | /* get tx power */ | |
caa8984f | 1333 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_RF_TX_PWR, |
600f5d90 | 1334 | HostCmd_ACT_GEN_GET, 0, NULL); |
5e6e3a92 BZ |
1335 | if (ret) |
1336 | return -1; | |
1337 | ||
03785387 AP |
1338 | if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) { |
1339 | /* set ibss coalescing_status */ | |
1340 | ret = mwifiex_send_cmd_async( | |
1341 | priv, HostCmd_CMD_802_11_IBSS_COALESCING_STATUS, | |
1342 | HostCmd_ACT_GEN_SET, 0, &enable); | |
1343 | if (ret) | |
1344 | return -1; | |
1345 | } | |
5e6e3a92 BZ |
1346 | |
1347 | memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl)); | |
1348 | amsdu_aggr_ctrl.enable = true; | |
1349 | /* Send request to firmware */ | |
600f5d90 AK |
1350 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_AMSDU_AGGR_CTRL, |
1351 | HostCmd_ACT_GEN_SET, 0, | |
a5ffddb7 | 1352 | &amsdu_aggr_ctrl); |
5e6e3a92 BZ |
1353 | if (ret) |
1354 | return -1; | |
1355 | /* MAC Control must be the last command in init_fw */ | |
1356 | /* set MAC Control */ | |
600f5d90 AK |
1357 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL, |
1358 | HostCmd_ACT_GEN_SET, 0, | |
1359 | &priv->curr_pkt_filter); | |
5e6e3a92 BZ |
1360 | if (ret) |
1361 | return -1; | |
1362 | ||
03785387 AP |
1363 | if (first_sta && priv->adapter->iface_type != MWIFIEX_USB && |
1364 | priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { | |
5e6e3a92 BZ |
1365 | /* Enable auto deep sleep */ |
1366 | auto_ds.auto_ds = DEEP_SLEEP_ON; | |
1367 | auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME; | |
600f5d90 AK |
1368 | ret = mwifiex_send_cmd_async(priv, |
1369 | HostCmd_CMD_802_11_PS_MODE_ENH, | |
1370 | EN_AUTO_PS, BITMAP_AUTO_DS, | |
1371 | &auto_ds); | |
5e6e3a92 BZ |
1372 | if (ret) |
1373 | return -1; | |
1374 | } | |
1375 | ||
03785387 AP |
1376 | if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) { |
1377 | /* Send cmd to FW to enable/disable 11D function */ | |
1378 | state_11d = ENABLE_11D; | |
1379 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SNMP_MIB, | |
1380 | HostCmd_ACT_GEN_SET, DOT11D_I, | |
1381 | &state_11d); | |
1382 | if (ret) | |
1383 | dev_err(priv->adapter->dev, | |
1384 | "11D: failed to enable 11D\n"); | |
1385 | } | |
5e6e3a92 | 1386 | |
cd27bc3c AK |
1387 | /* Send cmd to FW to configure 11n specific configuration |
1388 | * (Short GI, Channel BW, Green field support etc.) for transmit | |
1389 | */ | |
1390 | tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG; | |
1391 | ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_11N_CFG, | |
1392 | HostCmd_ACT_GEN_SET, 0, &tx_cfg); | |
1393 | ||
5e6e3a92 | 1394 | /* set last_init_cmd */ |
cd27bc3c | 1395 | priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG; |
5e6e3a92 BZ |
1396 | ret = -EINPROGRESS; |
1397 | ||
1398 | return ret; | |
1399 | } |