blob: 4559f84e64b56840c8c6fd177c374ad89484bb9d [file] [log] [blame]
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001/*
2 * Marvell Wireless LAN device driver: station command handling
3 *
4 * Copyright (C) 2011, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
18 */
19
20#include "decl.h"
21#include "ioctl.h"
22#include "util.h"
23#include "fw.h"
24#include "main.h"
25#include "wmm.h"
26#include "11n.h"
Yogesh Ashok Powar83c78da2013-03-18 20:06:03 -070027#include "11ac.h"
Bing Zhao5e6e3a92011-03-21 18:00:50 -070028
29/*
30 * This function prepares command to set/get RSSI information.
31 *
32 * Preparation includes -
33 * - Setting command ID, action and proper size
34 * - Setting data/beacon average factors
35 * - Resetting SNR/NF/RSSI values in private structure
36 * - Ensuring correct endian-ness
37 */
38static int
39mwifiex_cmd_802_11_rssi_info(struct mwifiex_private *priv,
40 struct host_cmd_ds_command *cmd, u16 cmd_action)
41{
42 cmd->command = cpu_to_le16(HostCmd_CMD_RSSI_INFO);
43 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_rssi_info) +
44 S_DS_GEN);
45 cmd->params.rssi_info.action = cpu_to_le16(cmd_action);
46 cmd->params.rssi_info.ndata = cpu_to_le16(priv->data_avg_factor);
47 cmd->params.rssi_info.nbcn = cpu_to_le16(priv->bcn_avg_factor);
48
49 /* Reset SNR/NF/RSSI values in private structure */
50 priv->data_rssi_last = 0;
51 priv->data_nf_last = 0;
52 priv->data_rssi_avg = 0;
53 priv->data_nf_avg = 0;
54 priv->bcn_rssi_last = 0;
55 priv->bcn_nf_last = 0;
56 priv->bcn_rssi_avg = 0;
57 priv->bcn_nf_avg = 0;
58
59 return 0;
60}
61
62/*
63 * This function prepares command to set MAC control.
64 *
65 * Preparation includes -
66 * - Setting command ID, action and proper size
67 * - Ensuring correct endian-ness
68 */
69static int mwifiex_cmd_mac_control(struct mwifiex_private *priv,
70 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -070071 u16 cmd_action, u16 *action)
Bing Zhao5e6e3a92011-03-21 18:00:50 -070072{
73 struct host_cmd_ds_mac_control *mac_ctrl = &cmd->params.mac_ctrl;
Bing Zhao5e6e3a92011-03-21 18:00:50 -070074
75 if (cmd_action != HostCmd_ACT_GEN_SET) {
76 dev_err(priv->adapter->dev,
77 "mac_control: only support set cmd\n");
78 return -1;
79 }
80
81 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_CONTROL);
82 cmd->size =
83 cpu_to_le16(sizeof(struct host_cmd_ds_mac_control) + S_DS_GEN);
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -070084 mac_ctrl->action = cpu_to_le16(*action);
Bing Zhao5e6e3a92011-03-21 18:00:50 -070085
86 return 0;
87}
88
89/*
90 * This function prepares command to set/get SNMP MIB.
91 *
92 * Preparation includes -
93 * - Setting command ID, action and proper size
94 * - Setting SNMP MIB OID number and value
95 * (as required)
96 * - Ensuring correct endian-ness
97 *
98 * The following SNMP MIB OIDs are supported -
99 * - FRAG_THRESH_I : Fragmentation threshold
100 * - RTS_THRESH_I : RTS threshold
101 * - SHORT_RETRY_LIM_I : Short retry limit
102 * - DOT11D_I : 11d support
103 */
104static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv,
105 struct host_cmd_ds_command *cmd,
106 u16 cmd_action, u32 cmd_oid,
Amitkumar Karwarf3c8d252012-02-02 20:48:57 -0800107 u16 *ul_temp)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700108{
109 struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700110
111 dev_dbg(priv->adapter->dev, "cmd: SNMP_CMD: cmd_oid = 0x%x\n", cmd_oid);
112 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SNMP_MIB);
113 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib)
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700114 - 1 + S_DS_GEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700115
Amitkumar Karwarf3c8d252012-02-02 20:48:57 -0800116 snmp_mib->oid = cpu_to_le16((u16)cmd_oid);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700117 if (cmd_action == HostCmd_ACT_GEN_GET) {
118 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET);
119 snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE);
Amitkumar Karwarf3c8d252012-02-02 20:48:57 -0800120 le16_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE);
121 } else if (cmd_action == HostCmd_ACT_GEN_SET) {
122 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
123 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
124 *((__le16 *) (snmp_mib->value)) = cpu_to_le16(*ul_temp);
125 le16_add_cpu(&cmd->size, sizeof(u16));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700126 }
127
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700128 dev_dbg(priv->adapter->dev,
129 "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x,"
130 " Value=0x%x\n",
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700131 cmd_action, cmd_oid, le16_to_cpu(snmp_mib->buf_size),
132 le16_to_cpu(*(__le16 *) snmp_mib->value));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700133 return 0;
134}
135
136/*
137 * This function prepares command to get log.
138 *
139 * Preparation includes -
140 * - Setting command ID and proper size
141 * - Ensuring correct endian-ness
142 */
143static int
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700144mwifiex_cmd_802_11_get_log(struct host_cmd_ds_command *cmd)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700145{
146 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_GET_LOG);
147 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_get_log) +
148 S_DS_GEN);
149 return 0;
150}
151
152/*
153 * This function prepares command to set/get Tx data rate configuration.
154 *
155 * Preparation includes -
156 * - Setting command ID, action and proper size
157 * - Setting configuration index, rate scope and rate drop pattern
158 * parameters (as required)
159 * - Ensuring correct endian-ness
160 */
161static int mwifiex_cmd_tx_rate_cfg(struct mwifiex_private *priv,
162 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700163 u16 cmd_action, u16 *pbitmap_rates)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700164{
165 struct host_cmd_ds_tx_rate_cfg *rate_cfg = &cmd->params.tx_rate_cfg;
166 struct mwifiex_rate_scope *rate_scope;
167 struct mwifiex_rate_drop_pattern *rate_drop;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700168 u32 i;
169
170 cmd->command = cpu_to_le16(HostCmd_CMD_TX_RATE_CFG);
171
172 rate_cfg->action = cpu_to_le16(cmd_action);
173 rate_cfg->cfg_index = 0;
174
175 rate_scope = (struct mwifiex_rate_scope *) ((u8 *) rate_cfg +
176 sizeof(struct host_cmd_ds_tx_rate_cfg));
177 rate_scope->type = cpu_to_le16(TLV_TYPE_RATE_SCOPE);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700178 rate_scope->length = cpu_to_le16
179 (sizeof(*rate_scope) - sizeof(struct mwifiex_ie_types_header));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700180 if (pbitmap_rates != NULL) {
181 rate_scope->hr_dsss_rate_bitmap = cpu_to_le16(pbitmap_rates[0]);
182 rate_scope->ofdm_rate_bitmap = cpu_to_le16(pbitmap_rates[1]);
183 for (i = 0;
184 i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16);
185 i++)
186 rate_scope->ht_mcs_rate_bitmap[i] =
187 cpu_to_le16(pbitmap_rates[2 + i]);
188 } else {
189 rate_scope->hr_dsss_rate_bitmap =
190 cpu_to_le16(priv->bitmap_rates[0]);
191 rate_scope->ofdm_rate_bitmap =
192 cpu_to_le16(priv->bitmap_rates[1]);
193 for (i = 0;
194 i < sizeof(rate_scope->ht_mcs_rate_bitmap) / sizeof(u16);
195 i++)
196 rate_scope->ht_mcs_rate_bitmap[i] =
197 cpu_to_le16(priv->bitmap_rates[2 + i]);
198 }
199
200 rate_drop = (struct mwifiex_rate_drop_pattern *) ((u8 *) rate_scope +
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700201 sizeof(struct mwifiex_rate_scope));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700202 rate_drop->type = cpu_to_le16(TLV_TYPE_RATE_DROP_CONTROL);
203 rate_drop->length = cpu_to_le16(sizeof(rate_drop->rate_drop_mode));
204 rate_drop->rate_drop_mode = 0;
205
206 cmd->size =
207 cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_tx_rate_cfg) +
208 sizeof(struct mwifiex_rate_scope) +
209 sizeof(struct mwifiex_rate_drop_pattern));
210
211 return 0;
212}
213
214/*
215 * This function prepares command to set/get Tx power configuration.
216 *
217 * Preparation includes -
218 * - Setting command ID, action and proper size
219 * - Setting Tx power mode, power group TLV
220 * (as required)
221 * - Ensuring correct endian-ness
222 */
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700223static int mwifiex_cmd_tx_power_cfg(struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700224 u16 cmd_action,
225 struct host_cmd_ds_txpwr_cfg *txp)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700226{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700227 struct mwifiex_types_power_group *pg_tlv;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700228 struct host_cmd_ds_txpwr_cfg *cmd_txp_cfg = &cmd->params.txp_cfg;
229
230 cmd->command = cpu_to_le16(HostCmd_CMD_TXPWR_CFG);
231 cmd->size =
232 cpu_to_le16(S_DS_GEN + sizeof(struct host_cmd_ds_txpwr_cfg));
233 switch (cmd_action) {
234 case HostCmd_ACT_GEN_SET:
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700235 if (txp->mode) {
236 pg_tlv = (struct mwifiex_types_power_group
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700237 *) ((unsigned long) txp +
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700238 sizeof(struct host_cmd_ds_txpwr_cfg));
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700239 memmove(cmd_txp_cfg, txp,
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700240 sizeof(struct host_cmd_ds_txpwr_cfg) +
241 sizeof(struct mwifiex_types_power_group) +
Amitkumar Karwar930fd352013-10-22 15:24:43 -0700242 le16_to_cpu(pg_tlv->length));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700243
244 pg_tlv = (struct mwifiex_types_power_group *) ((u8 *)
245 cmd_txp_cfg +
246 sizeof(struct host_cmd_ds_txpwr_cfg));
247 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) +
248 sizeof(struct mwifiex_types_power_group) +
Amitkumar Karwar930fd352013-10-22 15:24:43 -0700249 le16_to_cpu(pg_tlv->length));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700250 } else {
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700251 memmove(cmd_txp_cfg, txp, sizeof(*txp));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700252 }
253 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
254 break;
255 case HostCmd_ACT_GEN_GET:
256 cmd_txp_cfg->action = cpu_to_le16(cmd_action);
257 break;
258 }
259
260 return 0;
261}
262
263/*
Amitkumar Karwarcaa89842012-06-27 19:57:57 -0700264 * This function prepares command to get RF Tx power.
265 */
266static int mwifiex_cmd_rf_tx_power(struct mwifiex_private *priv,
267 struct host_cmd_ds_command *cmd,
268 u16 cmd_action, void *data_buf)
269{
270 struct host_cmd_ds_rf_tx_pwr *txp = &cmd->params.txp;
271
272 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_tx_pwr)
273 + S_DS_GEN);
274 cmd->command = cpu_to_le16(HostCmd_CMD_RF_TX_PWR);
275 txp->action = cpu_to_le16(cmd_action);
276
277 return 0;
278}
279
280/*
Amitkumar Karwar8a279d52012-07-02 19:32:33 -0700281 * This function prepares command to set rf antenna.
282 */
283static int mwifiex_cmd_rf_antenna(struct mwifiex_private *priv,
284 struct host_cmd_ds_command *cmd,
285 u16 cmd_action,
286 struct mwifiex_ds_ant_cfg *ant_cfg)
287{
288 struct host_cmd_ds_rf_ant_mimo *ant_mimo = &cmd->params.ant_mimo;
289 struct host_cmd_ds_rf_ant_siso *ant_siso = &cmd->params.ant_siso;
290
291 cmd->command = cpu_to_le16(HostCmd_CMD_RF_ANTENNA);
292
293 if (cmd_action != HostCmd_ACT_GEN_SET)
294 return 0;
295
296 if (priv->adapter->hw_dev_mcs_support == HT_STREAM_2X2) {
297 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_mimo) +
298 S_DS_GEN);
299 ant_mimo->action_tx = cpu_to_le16(HostCmd_ACT_SET_TX);
300 ant_mimo->tx_ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant);
301 ant_mimo->action_rx = cpu_to_le16(HostCmd_ACT_SET_RX);
302 ant_mimo->rx_ant_mode = cpu_to_le16((u16)ant_cfg->rx_ant);
303 } else {
304 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_rf_ant_siso) +
305 S_DS_GEN);
306 ant_siso->action = cpu_to_le16(HostCmd_ACT_SET_BOTH);
307 ant_siso->ant_mode = cpu_to_le16((u16)ant_cfg->tx_ant);
308 }
309
310 return 0;
311}
312
313/*
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700314 * This function prepares command to set Host Sleep configuration.
315 *
316 * Preparation includes -
317 * - Setting command ID and proper size
318 * - Setting Host Sleep action, conditions, ARP filters
319 * (as required)
320 * - Ensuring correct endian-ness
321 */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700322static int
323mwifiex_cmd_802_11_hs_cfg(struct mwifiex_private *priv,
324 struct host_cmd_ds_command *cmd,
325 u16 cmd_action,
326 struct mwifiex_hs_config_param *hscfg_param)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700327{
328 struct mwifiex_adapter *adapter = priv->adapter;
329 struct host_cmd_ds_802_11_hs_cfg_enh *hs_cfg = &cmd->params.opt_hs_cfg;
Peter Senna Tschudinc8561972013-09-22 00:27:43 +0200330 bool hs_activate = false;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700331
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700332 if (!hscfg_param)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700333 /* New Activate command */
334 hs_activate = true;
335 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_HS_CFG_ENH);
336
337 if (!hs_activate &&
Amitkumar Karwarcc0b5a62013-03-04 16:27:57 -0800338 (hscfg_param->conditions != cpu_to_le32(HS_CFG_CANCEL)) &&
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700339 ((adapter->arp_filter_size > 0) &&
340 (adapter->arp_filter_size <= ARP_FILTER_MAX_BUF_SIZE))) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700341 dev_dbg(adapter->dev,
342 "cmd: Attach %d bytes ArpFilter to HSCfg cmd\n",
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700343 adapter->arp_filter_size);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700344 memcpy(((u8 *) hs_cfg) +
345 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh),
346 adapter->arp_filter, adapter->arp_filter_size);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700347 cmd->size = cpu_to_le16
348 (adapter->arp_filter_size +
349 sizeof(struct host_cmd_ds_802_11_hs_cfg_enh)
350 + S_DS_GEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700351 } else {
352 cmd->size = cpu_to_le16(S_DS_GEN + sizeof(struct
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700353 host_cmd_ds_802_11_hs_cfg_enh));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700354 }
355 if (hs_activate) {
356 hs_cfg->action = cpu_to_le16(HS_ACTIVATE);
Ujjal Roy4348d082013-12-02 23:17:48 -0800357 hs_cfg->params.hs_activate.resp_ctrl = cpu_to_le16(RESP_NEEDED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700358 } else {
359 hs_cfg->action = cpu_to_le16(HS_CONFIGURE);
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700360 hs_cfg->params.hs_config.conditions = hscfg_param->conditions;
361 hs_cfg->params.hs_config.gpio = hscfg_param->gpio;
362 hs_cfg->params.hs_config.gap = hscfg_param->gap;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700363 dev_dbg(adapter->dev,
364 "cmd: HS_CFG_CMD: condition:0x%x gpio:0x%x gap:0x%x\n",
365 hs_cfg->params.hs_config.conditions,
366 hs_cfg->params.hs_config.gpio,
367 hs_cfg->params.hs_config.gap);
368 }
369
370 return 0;
371}
372
373/*
374 * This function prepares command to set/get MAC address.
375 *
376 * Preparation includes -
377 * - Setting command ID, action and proper size
378 * - Setting MAC address (for SET only)
379 * - Ensuring correct endian-ness
380 */
381static int mwifiex_cmd_802_11_mac_address(struct mwifiex_private *priv,
382 struct host_cmd_ds_command *cmd,
383 u16 cmd_action)
384{
385 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_MAC_ADDRESS);
386 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_mac_address) +
387 S_DS_GEN);
388 cmd->result = 0;
389
390 cmd->params.mac_addr.action = cpu_to_le16(cmd_action);
391
392 if (cmd_action == HostCmd_ACT_GEN_SET)
393 memcpy(cmd->params.mac_addr.mac_addr, priv->curr_addr,
394 ETH_ALEN);
395 return 0;
396}
397
398/*
399 * This function prepares command to set MAC multicast address.
400 *
401 * Preparation includes -
402 * - Setting command ID, action and proper size
403 * - Setting MAC multicast address
404 * - Ensuring correct endian-ness
405 */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700406static int
407mwifiex_cmd_mac_multicast_adr(struct host_cmd_ds_command *cmd,
408 u16 cmd_action,
409 struct mwifiex_multicast_list *mcast_list)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700410{
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700411 struct host_cmd_ds_mac_multicast_adr *mcast_addr = &cmd->params.mc_addr;
412
413 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_mac_multicast_adr) +
414 S_DS_GEN);
415 cmd->command = cpu_to_le16(HostCmd_CMD_MAC_MULTICAST_ADR);
416
417 mcast_addr->action = cpu_to_le16(cmd_action);
418 mcast_addr->num_of_adrs =
419 cpu_to_le16((u16) mcast_list->num_multicast_addr);
420 memcpy(mcast_addr->mac_list, mcast_list->mac_list,
421 mcast_list->num_multicast_addr * ETH_ALEN);
422
423 return 0;
424}
425
426/*
427 * This function prepares command to deauthenticate.
428 *
429 * Preparation includes -
430 * - Setting command ID and proper size
431 * - Setting AP MAC address and reason code
432 * - Ensuring correct endian-ness
433 */
434static int mwifiex_cmd_802_11_deauthenticate(struct mwifiex_private *priv,
435 struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700436 u8 *mac)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700437{
438 struct host_cmd_ds_802_11_deauthenticate *deauth = &cmd->params.deauth;
439
440 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_DEAUTHENTICATE);
441 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_deauthenticate)
442 + S_DS_GEN);
443
444 /* Set AP MAC address */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700445 memcpy(deauth->mac_addr, mac, ETH_ALEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700446
447 dev_dbg(priv->adapter->dev, "cmd: Deauth: %pM\n", deauth->mac_addr);
448
449 deauth->reason_code = cpu_to_le16(WLAN_REASON_DEAUTH_LEAVING);
450
451 return 0;
452}
453
454/*
455 * This function prepares command to stop Ad-Hoc network.
456 *
457 * Preparation includes -
458 * - Setting command ID and proper size
459 * - Ensuring correct endian-ness
460 */
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700461static int mwifiex_cmd_802_11_ad_hoc_stop(struct host_cmd_ds_command *cmd)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700462{
463 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_AD_HOC_STOP);
464 cmd->size = cpu_to_le16(S_DS_GEN);
465 return 0;
466}
467
468/*
469 * This function sets WEP key(s) to key parameter TLV(s).
470 *
471 * Multi-key parameter TLVs are supported, so we can send multiple
472 * WEP keys in a single buffer.
473 */
474static int
475mwifiex_set_keyparamset_wep(struct mwifiex_private *priv,
476 struct mwifiex_ie_type_key_param_set *key_param_set,
477 u16 *key_param_len)
478{
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -0700479 int cur_key_param_len;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700480 u8 i;
481
482 /* Multi-key_param_set TLV is supported */
483 for (i = 0; i < NUM_WEP_KEYS; i++) {
484 if ((priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP40) ||
485 (priv->wep_key[i].key_length == WLAN_KEY_LEN_WEP104)) {
486 key_param_set->type =
487 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
488/* Key_param_set WEP fixed length */
489#define KEYPARAMSET_WEP_FIXED_LEN 8
490 key_param_set->length = cpu_to_le16((u16)
491 (priv->wep_key[i].
492 key_length +
493 KEYPARAMSET_WEP_FIXED_LEN));
494 key_param_set->key_type_id =
495 cpu_to_le16(KEY_TYPE_ID_WEP);
496 key_param_set->key_info =
Yogesh Ashok Powar6a35a0a2011-04-06 16:46:56 -0700497 cpu_to_le16(KEY_ENABLED | KEY_UNICAST |
498 KEY_MCAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700499 key_param_set->key_len =
500 cpu_to_le16(priv->wep_key[i].key_length);
501 /* Set WEP key index */
502 key_param_set->key[0] = i;
503 /* Set default Tx key flag */
504 if (i ==
505 (priv->
506 wep_key_curr_index & HostCmd_WEP_KEY_INDEX_MASK))
507 key_param_set->key[1] = 1;
508 else
509 key_param_set->key[1] = 0;
510 memmove(&key_param_set->key[2],
511 priv->wep_key[i].key_material,
512 priv->wep_key[i].key_length);
513
514 cur_key_param_len = priv->wep_key[i].key_length +
515 KEYPARAMSET_WEP_FIXED_LEN +
516 sizeof(struct mwifiex_ie_types_header);
517 *key_param_len += (u16) cur_key_param_len;
518 key_param_set =
519 (struct mwifiex_ie_type_key_param_set *)
520 ((u8 *)key_param_set +
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700521 cur_key_param_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700522 } else if (!priv->wep_key[i].key_length) {
523 continue;
524 } else {
525 dev_err(priv->adapter->dev,
526 "key%d Length = %d is incorrect\n",
527 (i + 1), priv->wep_key[i].key_length);
528 return -1;
529 }
530 }
531
532 return 0;
533}
534
535/*
536 * This function prepares command to set/get/reset network key(s).
537 *
538 * Preparation includes -
539 * - Setting command ID, action and proper size
540 * - Setting WEP keys, WAPI keys or WPA keys along with required
541 * encryption (TKIP, AES) (as required)
542 * - Ensuring correct endian-ness
543 */
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700544static int
545mwifiex_cmd_802_11_key_material(struct mwifiex_private *priv,
546 struct host_cmd_ds_command *cmd,
547 u16 cmd_action, u32 cmd_oid,
548 struct mwifiex_ds_encrypt_key *enc_key)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700549{
550 struct host_cmd_ds_802_11_key_material *key_material =
551 &cmd->params.key_material;
Avinash Patil75edd2c2012-05-08 18:30:18 -0700552 struct host_cmd_tlv_mac_addr *tlv_mac;
553 u16 key_param_len = 0, cmd_size;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700554 int ret = 0;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700555
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 =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700581 cpu_to_le16(KEY_TYPE_ID_WAPI);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700582 if (cmd_oid == KEY_INFO_ENABLED)
583 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700584 cpu_to_le16(KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700585 else
586 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700587 cpu_to_le16(!KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700588
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
Wei Yongjuna71bf902012-08-24 13:25:30 +0800596 if (!is_broadcast_ether_addr(enc_key->mac_addr)) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700597 /* WAPI pairwise key: unicast */
598 key_material->key_param_set.key_info |=
Yogesh Ashok Powar6a35a0a2011-04-06 16:46:56 -0700599 cpu_to_le16(KEY_UNICAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700600 } else { /* WAPI group key: multicast */
601 key_material->key_param_set.key_info |=
Yogesh Ashok Powar6a35a0a2011-04-06 16:46:56 -0700602 cpu_to_le16(KEY_MCAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700603 priv->sec_info.wapi_key_on = true;
604 }
605
606 key_material->key_param_set.type =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700607 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700608 key_material->key_param_set.key_len =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700609 cpu_to_le16(WAPI_KEY_LEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700610 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],
Ying Luo9d7aba62012-08-03 18:06:12 -0700613 enc_key->pn, PN_LEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700614 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);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700619 cmd->size = cpu_to_le16(sizeof(key_material->action)
620 + S_DS_GEN + key_param_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700621 return ret;
622 }
623 if (enc_key->key_len == WLAN_KEY_LEN_CCMP) {
Ying Luob877f4c2012-08-03 18:06:14 -0700624 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 =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700630 cpu_to_le16(KEY_ENABLED);
Ying Luob877f4c2012-08-03 18:06:14 -0700631 else
632 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700633 cpu_to_le16(!KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700634
Ying Luob877f4c2012-08-03 18:06:14 -0700635 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 =
640 cpu_to_le16(KEY_TYPE_ID_AES);
641 if (cmd_oid == KEY_INFO_ENABLED)
642 key_material->key_param_set.key_info =
643 cpu_to_le16(KEY_ENABLED);
644 else
645 key_material->key_param_set.key_info =
646 cpu_to_le16(!KEY_ENABLED);
647
648 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700649 /* AES pairwise key: unicast */
Ying Luob877f4c2012-08-03 18:06:14 -0700650 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700651 cpu_to_le16(KEY_UNICAST);
Ying Luob877f4c2012-08-03 18:06:14 -0700652 else /* AES group key: multicast */
653 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700654 cpu_to_le16(KEY_MCAST);
Ying Luob877f4c2012-08-03 18:06:14 -0700655 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700656 } 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 =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700659 cpu_to_le16(KEY_TYPE_ID_TKIP);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700660 key_material->key_param_set.key_info =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700661 cpu_to_le16(KEY_ENABLED);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700662
663 if (enc_key->key_index & MWIFIEX_KEY_INDEX_UNICAST)
664 /* TKIP pairwise key: unicast */
665 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700666 cpu_to_le16(KEY_UNICAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700667 else /* TKIP group key: multicast */
668 key_material->key_param_set.key_info |=
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700669 cpu_to_le16(KEY_MCAST);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700670 }
671
672 if (key_material->key_param_set.key_type_id) {
673 key_material->key_param_set.type =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700674 cpu_to_le16(TLV_TYPE_KEY_MATERIAL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700675 key_material->key_param_set.key_len =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700676 cpu_to_le16((u16) enc_key->key_len);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700677 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
Avinash Patil75edd2c2012-05-08 18:30:18 -0700683 key_param_len = (u16)(enc_key->key_len + KEYPARAMSET_FIXED_LEN)
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700684 + sizeof(struct mwifiex_ie_types_header);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700685
Ying Luob877f4c2012-08-03 18:06:14 -0700686 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,
Bing Zhao641c8692012-08-08 19:01:52 -0700693 WLAN_KEY_LEN_AES_CMAC);
Ying Luob877f4c2012-08-03 18:06:14 -0700694
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
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700704 cmd->size = cpu_to_le16(sizeof(key_material->action) + S_DS_GEN
705 + key_param_len);
Avinash Patil75edd2c2012-05-08 18:30:18 -0700706
707 if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) {
708 tlv_mac = (void *)((u8 *)&key_material->key_param_set +
709 key_param_len);
Amitkumar Karwar6b21a692013-07-22 19:17:57 -0700710 tlv_mac->header.type =
711 cpu_to_le16(TLV_TYPE_STA_MAC_ADDR);
712 tlv_mac->header.len = cpu_to_le16(ETH_ALEN);
Avinash Patil75edd2c2012-05-08 18:30:18 -0700713 memcpy(tlv_mac->mac_addr, enc_key->mac_addr, ETH_ALEN);
714 cmd_size = key_param_len + S_DS_GEN +
715 sizeof(key_material->action) +
716 sizeof(struct host_cmd_tlv_mac_addr);
717 } else {
718 cmd_size = key_param_len + S_DS_GEN +
719 sizeof(key_material->action);
720 }
721 cmd->size = cpu_to_le16(cmd_size);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700722 }
723
724 return ret;
725}
726
727/*
728 * This function prepares command to set/get 11d domain information.
729 *
730 * Preparation includes -
731 * - Setting command ID, action and proper size
732 * - Setting domain information fields (for SET only)
733 * - Ensuring correct endian-ness
734 */
735static int mwifiex_cmd_802_11d_domain_info(struct mwifiex_private *priv,
736 struct host_cmd_ds_command *cmd,
737 u16 cmd_action)
738{
739 struct mwifiex_adapter *adapter = priv->adapter;
740 struct host_cmd_ds_802_11d_domain_info *domain_info =
741 &cmd->params.domain_info;
742 struct mwifiex_ietypes_domain_param_set *domain =
743 &domain_info->domain;
744 u8 no_of_triplet = adapter->domain_reg.no_of_triplet;
745
746 dev_dbg(adapter->dev, "info: 11D: no_of_triplet=0x%x\n", no_of_triplet);
747
748 cmd->command = cpu_to_le16(HostCmd_CMD_802_11D_DOMAIN_INFO);
749 domain_info->action = cpu_to_le16(cmd_action);
750 if (cmd_action == HostCmd_ACT_GEN_GET) {
751 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
752 return 0;
753 }
754
755 /* Set domain info fields */
756 domain->header.type = cpu_to_le16(WLAN_EID_COUNTRY);
757 memcpy(domain->country_code, adapter->domain_reg.country_code,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700758 sizeof(domain->country_code));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700759
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700760 domain->header.len =
761 cpu_to_le16((no_of_triplet *
762 sizeof(struct ieee80211_country_ie_triplet))
763 + sizeof(domain->country_code));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700764
765 if (no_of_triplet) {
766 memcpy(domain->triplet, adapter->domain_reg.triplet,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700767 no_of_triplet * sizeof(struct
768 ieee80211_country_ie_triplet));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700769
770 cmd->size = cpu_to_le16(sizeof(domain_info->action) +
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700771 le16_to_cpu(domain->header.len) +
772 sizeof(struct mwifiex_ie_types_header)
773 + S_DS_GEN);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700774 } else {
775 cmd->size = cpu_to_le16(sizeof(domain_info->action) + S_DS_GEN);
776 }
777
778 return 0;
779}
780
781/*
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700782 * This function prepares command to set/get IBSS coalescing status.
783 *
784 * Preparation includes -
785 * - Setting command ID, action and proper size
786 * - Setting status to enable or disable (for SET only)
787 * - Ensuring correct endian-ness
788 */
Amitkumar Karwar572e8f32011-04-13 17:27:08 -0700789static int mwifiex_cmd_ibss_coalescing_status(struct host_cmd_ds_command *cmd,
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700790 u16 cmd_action, u16 *enable)
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700791{
792 struct host_cmd_ds_802_11_ibss_status *ibss_coal =
793 &(cmd->params.ibss_coalescing);
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700794
795 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_IBSS_COALESCING_STATUS);
796 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_ibss_status) +
797 S_DS_GEN);
798 cmd->result = 0;
799 ibss_coal->action = cpu_to_le16(cmd_action);
800
801 switch (cmd_action) {
802 case HostCmd_ACT_GEN_SET:
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700803 if (enable)
804 ibss_coal->enable = cpu_to_le16(*enable);
Dan Carpentera5e5aa62011-06-24 16:33:35 +0300805 else
806 ibss_coal->enable = 0;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700807 break;
808
809 /* In other case.. Nothing to do */
810 case HostCmd_ACT_GEN_GET:
811 default:
812 break;
813 }
814
815 return 0;
816}
817
818/*
819 * This function prepares command to set/get register value.
820 *
821 * Preparation includes -
822 * - Setting command ID, action and proper size
823 * - Setting register offset (for both GET and SET) and
824 * register value (for SET only)
825 * - Ensuring correct endian-ness
826 *
827 * The following type of registers can be accessed with this function -
828 * - MAC register
829 * - BBP register
830 * - RF register
831 * - PMIC register
832 * - CAU register
833 * - EEPROM
834 */
835static int mwifiex_cmd_reg_access(struct host_cmd_ds_command *cmd,
836 u16 cmd_action, void *data_buf)
837{
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700838 struct mwifiex_ds_reg_rw *reg_rw = data_buf;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700839
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700840 switch (le16_to_cpu(cmd->command)) {
841 case HostCmd_CMD_MAC_REG_ACCESS:
842 {
843 struct host_cmd_ds_mac_reg_access *mac_reg;
844
845 cmd->size = cpu_to_le16(sizeof(*mac_reg) + S_DS_GEN);
Joe Perches2c208892012-06-04 12:44:17 +0000846 mac_reg = &cmd->params.mac_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700847 mac_reg->action = cpu_to_le16(cmd_action);
848 mac_reg->offset =
849 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
850 mac_reg->value = reg_rw->value;
851 break;
852 }
853 case HostCmd_CMD_BBP_REG_ACCESS:
854 {
855 struct host_cmd_ds_bbp_reg_access *bbp_reg;
856
857 cmd->size = cpu_to_le16(sizeof(*bbp_reg) + S_DS_GEN);
Joe Perches2c208892012-06-04 12:44:17 +0000858 bbp_reg = &cmd->params.bbp_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700859 bbp_reg->action = cpu_to_le16(cmd_action);
860 bbp_reg->offset =
861 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
862 bbp_reg->value = (u8) le32_to_cpu(reg_rw->value);
863 break;
864 }
865 case HostCmd_CMD_RF_REG_ACCESS:
866 {
867 struct host_cmd_ds_rf_reg_access *rf_reg;
868
869 cmd->size = cpu_to_le16(sizeof(*rf_reg) + S_DS_GEN);
Joe Perches2c208892012-06-04 12:44:17 +0000870 rf_reg = &cmd->params.rf_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700871 rf_reg->action = cpu_to_le16(cmd_action);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700872 rf_reg->offset = cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700873 rf_reg->value = (u8) le32_to_cpu(reg_rw->value);
874 break;
875 }
876 case HostCmd_CMD_PMIC_REG_ACCESS:
877 {
878 struct host_cmd_ds_pmic_reg_access *pmic_reg;
879
880 cmd->size = cpu_to_le16(sizeof(*pmic_reg) + S_DS_GEN);
Joe Perches2c208892012-06-04 12:44:17 +0000881 pmic_reg = &cmd->params.pmic_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700882 pmic_reg->action = cpu_to_le16(cmd_action);
883 pmic_reg->offset =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700884 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700885 pmic_reg->value = (u8) le32_to_cpu(reg_rw->value);
886 break;
887 }
888 case HostCmd_CMD_CAU_REG_ACCESS:
889 {
890 struct host_cmd_ds_rf_reg_access *cau_reg;
891
892 cmd->size = cpu_to_le16(sizeof(*cau_reg) + S_DS_GEN);
Joe Perches2c208892012-06-04 12:44:17 +0000893 cau_reg = &cmd->params.rf_reg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700894 cau_reg->action = cpu_to_le16(cmd_action);
895 cau_reg->offset =
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700896 cpu_to_le16((u16) le32_to_cpu(reg_rw->offset));
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700897 cau_reg->value = (u8) le32_to_cpu(reg_rw->value);
898 break;
899 }
900 case HostCmd_CMD_802_11_EEPROM_ACCESS:
901 {
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -0700902 struct mwifiex_ds_read_eeprom *rd_eeprom = data_buf;
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700903 struct host_cmd_ds_802_11_eeprom_access *cmd_eeprom =
Bing Zhao5e6e3a92011-03-21 18:00:50 -0700904 &cmd->params.eeprom;
905
906 cmd->size = cpu_to_le16(sizeof(*cmd_eeprom) + S_DS_GEN);
907 cmd_eeprom->action = cpu_to_le16(cmd_action);
908 cmd_eeprom->offset = rd_eeprom->offset;
909 cmd_eeprom->byte_count = rd_eeprom->byte_count;
910 cmd_eeprom->value = 0;
911 break;
912 }
913 default:
914 return -1;
915 }
916
917 return 0;
918}
919
920/*
Amitkumar Karward930fae2011-10-11 17:41:21 -0700921 * This function prepares command to set PCI-Express
922 * host buffer configuration
923 *
924 * Preparation includes -
925 * - Setting command ID, action and proper size
926 * - Setting host buffer configuration
927 * - Ensuring correct endian-ness
928 */
929static int
930mwifiex_cmd_pcie_host_spec(struct mwifiex_private *priv,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700931 struct host_cmd_ds_command *cmd, u16 action)
Amitkumar Karward930fae2011-10-11 17:41:21 -0700932{
933 struct host_cmd_ds_pcie_details *host_spec =
934 &cmd->params.pcie_host_spec;
935 struct pcie_service_card *card = priv->adapter->card;
Amitkumar Karward930fae2011-10-11 17:41:21 -0700936
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
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700944 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;
Avinash Patilfc331462013-01-03 21:21:30 -0800957 if (card->sleep_cookie_vbase) {
958 host_spec->sleep_cookie_addr_lo =
959 (u32)(card->sleep_cookie_pbase);
960 host_spec->sleep_cookie_addr_hi =
961 (u32)(((u64)(card->sleep_cookie_pbase)) >> 32);
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -0700962 dev_dbg(priv->adapter->dev, "sleep_cook_lo phy addr: 0x%x\n",
963 host_spec->sleep_cookie_addr_lo);
Amitkumar Karward930fae2011-10-11 17:41:21 -0700964 }
965
966 return 0;
967}
968
969/*
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -0700970 * This function prepares command for event subscription, configuration
971 * and query. Events can be subscribed or unsubscribed. Current subscribed
972 * events can be queried. Also, current subscribed events are reported in
973 * every FW response.
974 */
975static int
976mwifiex_cmd_802_11_subsc_evt(struct mwifiex_private *priv,
977 struct host_cmd_ds_command *cmd,
978 struct mwifiex_ds_misc_subsc_evt *subsc_evt_cfg)
979{
980 struct host_cmd_ds_802_11_subsc_evt *subsc_evt = &cmd->params.subsc_evt;
981 struct mwifiex_ie_types_rssi_threshold *rssi_tlv;
982 u16 event_bitmap;
983 u8 *pos;
984
985 cmd->command = cpu_to_le16(HostCmd_CMD_802_11_SUBSCRIBE_EVENT);
986 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_subsc_evt) +
987 S_DS_GEN);
988
989 subsc_evt->action = cpu_to_le16(subsc_evt_cfg->action);
990 dev_dbg(priv->adapter->dev, "cmd: action: %d\n", subsc_evt_cfg->action);
991
992 /*For query requests, no configuration TLV structures are to be added.*/
993 if (subsc_evt_cfg->action == HostCmd_ACT_GEN_GET)
994 return 0;
995
996 subsc_evt->events = cpu_to_le16(subsc_evt_cfg->events);
997
998 event_bitmap = subsc_evt_cfg->events;
999 dev_dbg(priv->adapter->dev, "cmd: event bitmap : %16x\n",
1000 event_bitmap);
1001
1002 if (((subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR) ||
1003 (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_SET)) &&
1004 (event_bitmap == 0)) {
1005 dev_dbg(priv->adapter->dev, "Error: No event specified "
1006 "for bitwise action type\n");
1007 return -EINVAL;
1008 }
1009
1010 /*
1011 * Append TLV structures for each of the specified events for
1012 * subscribing or re-configuring. This is not required for
1013 * bitwise unsubscribing request.
1014 */
1015 if (subsc_evt_cfg->action == HostCmd_ACT_BITWISE_CLR)
1016 return 0;
1017
1018 pos = ((u8 *)subsc_evt) +
1019 sizeof(struct host_cmd_ds_802_11_subsc_evt);
1020
1021 if (event_bitmap & BITMASK_BCN_RSSI_LOW) {
1022 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
1023
1024 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_LOW);
1025 rssi_tlv->header.len =
1026 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
1027 sizeof(struct mwifiex_ie_types_header));
1028 rssi_tlv->abs_value = subsc_evt_cfg->bcn_l_rssi_cfg.abs_value;
1029 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq;
1030
1031 dev_dbg(priv->adapter->dev, "Cfg Beacon Low Rssi event, "
1032 "RSSI:-%d dBm, Freq:%d\n",
1033 subsc_evt_cfg->bcn_l_rssi_cfg.abs_value,
1034 subsc_evt_cfg->bcn_l_rssi_cfg.evt_freq);
1035
1036 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1037 le16_add_cpu(&cmd->size,
1038 sizeof(struct mwifiex_ie_types_rssi_threshold));
1039 }
1040
1041 if (event_bitmap & BITMASK_BCN_RSSI_HIGH) {
1042 rssi_tlv = (struct mwifiex_ie_types_rssi_threshold *) pos;
1043
1044 rssi_tlv->header.type = cpu_to_le16(TLV_TYPE_RSSI_HIGH);
1045 rssi_tlv->header.len =
1046 cpu_to_le16(sizeof(struct mwifiex_ie_types_rssi_threshold) -
1047 sizeof(struct mwifiex_ie_types_header));
1048 rssi_tlv->abs_value = subsc_evt_cfg->bcn_h_rssi_cfg.abs_value;
1049 rssi_tlv->evt_freq = subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq;
1050
Bing Zhaod35ccaa2012-04-09 20:06:53 -07001051 dev_dbg(priv->adapter->dev, "Cfg Beacon High Rssi event, "
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -07001052 "RSSI:-%d dBm, Freq:%d\n",
1053 subsc_evt_cfg->bcn_h_rssi_cfg.abs_value,
1054 subsc_evt_cfg->bcn_h_rssi_cfg.evt_freq);
1055
1056 pos += sizeof(struct mwifiex_ie_types_rssi_threshold);
1057 le16_add_cpu(&cmd->size,
1058 sizeof(struct mwifiex_ie_types_rssi_threshold));
1059 }
1060
1061 return 0;
1062}
1063
Amitkumar Karwar7da060c2013-03-04 16:27:59 -08001064static int
1065mwifiex_cmd_append_rpn_expression(struct mwifiex_private *priv,
1066 struct mwifiex_mef_entry *mef_entry,
1067 u8 **buffer)
1068{
1069 struct mwifiex_mef_filter *filter = mef_entry->filter;
1070 int i, byte_len;
1071 u8 *stack_ptr = *buffer;
1072
Amitkumar Karwar3f4e8542013-08-05 18:51:57 -07001073 for (i = 0; i < MWIFIEX_MEF_MAX_FILTERS; i++) {
Amitkumar Karwar7da060c2013-03-04 16:27:59 -08001074 filter = &mef_entry->filter[i];
1075 if (!filter->filt_type)
1076 break;
1077 *(__le32 *)stack_ptr = cpu_to_le32((u32)filter->repeat);
1078 stack_ptr += 4;
1079 *stack_ptr = TYPE_DNUM;
1080 stack_ptr += 1;
1081
Amitkumar Karwar3f4e8542013-08-05 18:51:57 -07001082 byte_len = filter->byte_seq[MWIFIEX_MEF_MAX_BYTESEQ];
Amitkumar Karwar7da060c2013-03-04 16:27:59 -08001083 memcpy(stack_ptr, filter->byte_seq, byte_len);
1084 stack_ptr += byte_len;
1085 *stack_ptr = byte_len;
1086 stack_ptr += 1;
1087 *stack_ptr = TYPE_BYTESEQ;
1088 stack_ptr += 1;
1089
1090 *(__le32 *)stack_ptr = cpu_to_le32((u32)filter->offset);
1091 stack_ptr += 4;
1092 *stack_ptr = TYPE_DNUM;
1093 stack_ptr += 1;
1094
1095 *stack_ptr = filter->filt_type;
1096 stack_ptr += 1;
1097
1098 if (filter->filt_action) {
1099 *stack_ptr = filter->filt_action;
1100 stack_ptr += 1;
1101 }
1102
1103 if (stack_ptr - *buffer > STACK_NBYTES)
1104 return -1;
1105 }
1106
1107 *buffer = stack_ptr;
1108 return 0;
1109}
1110
1111static int
1112mwifiex_cmd_mef_cfg(struct mwifiex_private *priv,
1113 struct host_cmd_ds_command *cmd,
1114 struct mwifiex_ds_mef_cfg *mef)
1115{
1116 struct host_cmd_ds_mef_cfg *mef_cfg = &cmd->params.mef_cfg;
1117 u8 *pos = (u8 *)mef_cfg;
1118
1119 cmd->command = cpu_to_le16(HostCmd_CMD_MEF_CFG);
1120
1121 mef_cfg->criteria = cpu_to_le32(mef->criteria);
1122 mef_cfg->num_entries = cpu_to_le16(mef->num_entries);
1123 pos += sizeof(*mef_cfg);
1124 mef_cfg->mef_entry->mode = mef->mef_entry->mode;
1125 mef_cfg->mef_entry->action = mef->mef_entry->action;
1126 pos += sizeof(*(mef_cfg->mef_entry));
1127
1128 if (mwifiex_cmd_append_rpn_expression(priv, mef->mef_entry, &pos))
1129 return -1;
1130
1131 mef_cfg->mef_entry->exprsize =
1132 cpu_to_le16(pos - mef_cfg->mef_entry->expr);
1133 cmd->size = cpu_to_le16((u16) (pos - (u8 *)mef_cfg) + S_DS_GEN);
1134
1135 return 0;
1136}
1137
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001138/* This function parse cal data from ASCII to hex */
1139static u32 mwifiex_parse_cal_cfg(u8 *src, size_t len, u8 *dst)
1140{
1141 u8 *s = src, *d = dst;
1142
1143 while (s - src < len) {
1144 if (*s && (isspace(*s) || *s == '\t')) {
1145 s++;
1146 continue;
1147 }
1148 if (isxdigit(*s)) {
1149 *d++ = simple_strtol(s, NULL, 16);
1150 s += 2;
1151 } else {
1152 s++;
1153 }
1154 }
1155
1156 return d - dst;
1157}
1158
Bing Zhao82efa162013-12-13 18:33:02 -08001159int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
1160 struct device_node *node, const char *prefix)
Bing Zhao699b0272013-12-13 18:33:01 -08001161{
1162#ifdef CONFIG_OF
1163 struct property *prop;
1164 size_t len = strlen(prefix);
1165 int ret;
1166
1167 /* look for all matching property names */
1168 for_each_property_of_node(node, prop) {
1169 if (len > strlen(prop->name) ||
1170 strncmp(prop->name, prefix, len))
1171 continue;
1172
Bing Zhao63791cc2014-01-08 15:45:56 -08001173 /* property header is 6 bytes, data must fit in cmd buffer */
1174 if (prop && prop->value && prop->length > 6 &&
1175 prop->length <= MWIFIEX_SIZE_OF_CMD_BUFFER - S_DS_GEN) {
Bing Zhao699b0272013-12-13 18:33:01 -08001176 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_CFG_DATA,
1177 HostCmd_ACT_GEN_SET, 0,
1178 prop);
1179 if (ret)
1180 return ret;
1181 }
1182 }
1183#endif
1184 return 0;
1185}
1186
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001187/* This function prepares command of set_cfg_data. */
1188static int mwifiex_cmd_cfg_data(struct mwifiex_private *priv,
Bing Zhao699b0272013-12-13 18:33:01 -08001189 struct host_cmd_ds_command *cmd, void *data_buf)
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001190{
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001191 struct mwifiex_adapter *adapter = priv->adapter;
Bing Zhao699b0272013-12-13 18:33:01 -08001192 struct property *prop = data_buf;
Bing Zhaod39fbc82013-12-13 18:33:00 -08001193 u32 len;
1194 u8 *data = (u8 *)cmd + S_DS_GEN;
Bing Zhao699b0272013-12-13 18:33:01 -08001195 int ret;
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001196
Bing Zhao699b0272013-12-13 18:33:01 -08001197 if (prop) {
1198 len = prop->length;
1199 ret = of_property_read_u8_array(adapter->dt_node, prop->name,
1200 data, len);
1201 if (ret)
1202 return ret;
1203 dev_dbg(adapter->dev,
1204 "download cfg_data from device tree: %s\n", prop->name);
1205 } else if (adapter->cal_data->data && adapter->cal_data->size > 0) {
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001206 len = mwifiex_parse_cal_cfg((u8 *)adapter->cal_data->data,
Bing Zhaod39fbc82013-12-13 18:33:00 -08001207 adapter->cal_data->size, data);
Bing Zhao699b0272013-12-13 18:33:01 -08001208 dev_dbg(adapter->dev, "download cfg_data from config file\n");
1209 } else {
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001210 return -1;
Bing Zhao699b0272013-12-13 18:33:01 -08001211 }
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001212
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001213 cmd->command = cpu_to_le16(HostCmd_CMD_CFG_DATA);
Bing Zhaod39fbc82013-12-13 18:33:00 -08001214 cmd->size = cpu_to_le16(S_DS_GEN + len);
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001215
1216 return 0;
1217}
1218
Amitkumar Karwar562fc5b2013-08-05 18:52:00 -07001219static int
1220mwifiex_cmd_coalesce_cfg(struct mwifiex_private *priv,
1221 struct host_cmd_ds_command *cmd,
1222 u16 cmd_action, void *data_buf)
1223{
1224 struct host_cmd_ds_coalesce_cfg *coalesce_cfg =
1225 &cmd->params.coalesce_cfg;
1226 struct mwifiex_ds_coalesce_cfg *cfg = data_buf;
1227 struct coalesce_filt_field_param *param;
1228 u16 cnt, idx, length;
1229 struct coalesce_receive_filt_rule *rule;
1230
1231 cmd->command = cpu_to_le16(HostCmd_CMD_COALESCE_CFG);
1232 cmd->size = cpu_to_le16(S_DS_GEN);
1233
1234 coalesce_cfg->action = cpu_to_le16(cmd_action);
1235 coalesce_cfg->num_of_rules = cpu_to_le16(cfg->num_of_rules);
1236 rule = coalesce_cfg->rule;
1237
1238 for (cnt = 0; cnt < cfg->num_of_rules; cnt++) {
1239 rule->header.type = cpu_to_le16(TLV_TYPE_COALESCE_RULE);
1240 rule->max_coalescing_delay =
1241 cpu_to_le16(cfg->rule[cnt].max_coalescing_delay);
1242 rule->pkt_type = cfg->rule[cnt].pkt_type;
1243 rule->num_of_fields = cfg->rule[cnt].num_of_fields;
1244
1245 length = 0;
1246
1247 param = rule->params;
1248 for (idx = 0; idx < cfg->rule[cnt].num_of_fields; idx++) {
1249 param->operation = cfg->rule[cnt].params[idx].operation;
1250 param->operand_len =
1251 cfg->rule[cnt].params[idx].operand_len;
1252 param->offset =
1253 cpu_to_le16(cfg->rule[cnt].params[idx].offset);
1254 memcpy(param->operand_byte_stream,
1255 cfg->rule[cnt].params[idx].operand_byte_stream,
1256 param->operand_len);
1257
1258 length += sizeof(struct coalesce_filt_field_param);
1259
1260 param++;
1261 }
1262
1263 /* Total rule length is sizeof max_coalescing_delay(u16),
1264 * num_of_fields(u8), pkt_type(u8) and total length of the all
1265 * params
1266 */
1267 rule->header.len = cpu_to_le16(length + sizeof(u16) +
1268 sizeof(u8) + sizeof(u8));
1269
1270 /* Add the rule length to the command size*/
1271 le16_add_cpu(&cmd->size, le16_to_cpu(rule->header.len) +
1272 sizeof(struct mwifiex_ie_types_header));
1273
1274 rule = (void *)((u8 *)rule->params + length);
1275 }
1276
1277 /* Add sizeof action, num_of_rules to total command length */
1278 le16_add_cpu(&cmd->size, sizeof(u16) + sizeof(u16));
1279
1280 return 0;
1281}
1282
Avinash Patil429d90d2014-02-07 16:27:34 -08001283static int
1284mwifiex_cmd_tdls_oper(struct mwifiex_private *priv,
1285 struct host_cmd_ds_command *cmd,
1286 void *data_buf)
1287{
1288 struct host_cmd_ds_tdls_oper *tdls_oper = &cmd->params.tdls_oper;
1289 struct mwifiex_ds_tdls_oper *oper = data_buf;
1290 struct mwifiex_sta_node *sta_ptr;
1291
1292 cmd->command = cpu_to_le16(HostCmd_CMD_TDLS_OPER);
1293 cmd->size = cpu_to_le16(S_DS_GEN);
1294
1295 tdls_oper->reason = 0;
1296 memcpy(tdls_oper->peer_mac, oper->peer_mac, ETH_ALEN);
1297 sta_ptr = mwifiex_get_sta_entry(priv, oper->peer_mac);
1298
1299 switch (oper->tdls_action) {
1300 case MWIFIEX_TDLS_DISABLE_LINK:
1301 tdls_oper->tdls_action = cpu_to_le16(ACT_TDLS_DELETE);
1302 break;
1303 default:
1304 dev_err(priv->adapter->dev, "Unknown TDLS operation\n");
1305 return -ENOTSUPP;
1306 }
1307
1308 le16_add_cpu(&cmd->size, sizeof(struct host_cmd_ds_tdls_oper));
1309
1310 return 0;
1311}
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -07001312/*
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001313 * This function prepares the commands before sending them to the firmware.
1314 *
1315 * This is a generic function which calls specific command preparation
1316 * routines based upon the command number.
1317 */
1318int mwifiex_sta_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1319 u16 cmd_action, u32 cmd_oid,
1320 void *data_buf, void *cmd_buf)
1321{
Amitkumar Karwara5ffddb2011-06-20 15:21:48 -07001322 struct host_cmd_ds_command *cmd_ptr = cmd_buf;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001323 int ret = 0;
1324
1325 /* Prepare command */
1326 switch (cmd_no) {
1327 case HostCmd_CMD_GET_HW_SPEC:
1328 ret = mwifiex_cmd_get_hw_spec(priv, cmd_ptr);
1329 break;
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001330 case HostCmd_CMD_CFG_DATA:
Bing Zhao699b0272013-12-13 18:33:01 -08001331 ret = mwifiex_cmd_cfg_data(priv, cmd_ptr, data_buf);
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001332 break;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001333 case HostCmd_CMD_MAC_CONTROL:
1334 ret = mwifiex_cmd_mac_control(priv, cmd_ptr, cmd_action,
1335 data_buf);
1336 break;
1337 case HostCmd_CMD_802_11_MAC_ADDRESS:
1338 ret = mwifiex_cmd_802_11_mac_address(priv, cmd_ptr,
1339 cmd_action);
1340 break;
1341 case HostCmd_CMD_MAC_MULTICAST_ADR:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001342 ret = mwifiex_cmd_mac_multicast_adr(cmd_ptr, cmd_action,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001343 data_buf);
1344 break;
1345 case HostCmd_CMD_TX_RATE_CFG:
1346 ret = mwifiex_cmd_tx_rate_cfg(priv, cmd_ptr, cmd_action,
1347 data_buf);
1348 break;
1349 case HostCmd_CMD_TXPWR_CFG:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001350 ret = mwifiex_cmd_tx_power_cfg(cmd_ptr, cmd_action,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001351 data_buf);
1352 break;
Amitkumar Karwarcaa89842012-06-27 19:57:57 -07001353 case HostCmd_CMD_RF_TX_PWR:
1354 ret = mwifiex_cmd_rf_tx_power(priv, cmd_ptr, cmd_action,
1355 data_buf);
1356 break;
Amitkumar Karwar8a279d52012-07-02 19:32:33 -07001357 case HostCmd_CMD_RF_ANTENNA:
1358 ret = mwifiex_cmd_rf_antenna(priv, cmd_ptr, cmd_action,
1359 data_buf);
1360 break;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001361 case HostCmd_CMD_802_11_PS_MODE_ENH:
1362 ret = mwifiex_cmd_enh_power_mode(priv, cmd_ptr, cmd_action,
1363 (uint16_t)cmd_oid, data_buf);
1364 break;
1365 case HostCmd_CMD_802_11_HS_CFG_ENH:
1366 ret = mwifiex_cmd_802_11_hs_cfg(priv, cmd_ptr, cmd_action,
1367 (struct mwifiex_hs_config_param *) data_buf);
1368 break;
1369 case HostCmd_CMD_802_11_SCAN:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001370 ret = mwifiex_cmd_802_11_scan(cmd_ptr, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001371 break;
1372 case HostCmd_CMD_802_11_BG_SCAN_QUERY:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001373 ret = mwifiex_cmd_802_11_bg_scan_query(cmd_ptr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001374 break;
1375 case HostCmd_CMD_802_11_ASSOCIATE:
1376 ret = mwifiex_cmd_802_11_associate(priv, cmd_ptr, data_buf);
1377 break;
1378 case HostCmd_CMD_802_11_DEAUTHENTICATE:
1379 ret = mwifiex_cmd_802_11_deauthenticate(priv, cmd_ptr,
1380 data_buf);
1381 break;
1382 case HostCmd_CMD_802_11_AD_HOC_START:
1383 ret = mwifiex_cmd_802_11_ad_hoc_start(priv, cmd_ptr,
1384 data_buf);
1385 break;
1386 case HostCmd_CMD_802_11_GET_LOG:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001387 ret = mwifiex_cmd_802_11_get_log(cmd_ptr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001388 break;
1389 case HostCmd_CMD_802_11_AD_HOC_JOIN:
1390 ret = mwifiex_cmd_802_11_ad_hoc_join(priv, cmd_ptr,
1391 data_buf);
1392 break;
1393 case HostCmd_CMD_802_11_AD_HOC_STOP:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001394 ret = mwifiex_cmd_802_11_ad_hoc_stop(cmd_ptr);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001395 break;
1396 case HostCmd_CMD_RSSI_INFO:
1397 ret = mwifiex_cmd_802_11_rssi_info(priv, cmd_ptr, cmd_action);
1398 break;
1399 case HostCmd_CMD_802_11_SNMP_MIB:
1400 ret = mwifiex_cmd_802_11_snmp_mib(priv, cmd_ptr, cmd_action,
1401 cmd_oid, data_buf);
1402 break;
1403 case HostCmd_CMD_802_11_TX_RATE_QUERY:
1404 cmd_ptr->command =
1405 cpu_to_le16(HostCmd_CMD_802_11_TX_RATE_QUERY);
1406 cmd_ptr->size =
1407 cpu_to_le16(sizeof(struct host_cmd_ds_tx_rate_query) +
1408 S_DS_GEN);
1409 priv->tx_rate = 0;
1410 ret = 0;
1411 break;
1412 case HostCmd_CMD_VERSION_EXT:
1413 cmd_ptr->command = cpu_to_le16(cmd_no);
1414 cmd_ptr->params.verext.version_str_sel =
1415 (u8) (*((u32 *) data_buf));
1416 memcpy(&cmd_ptr->params, data_buf,
1417 sizeof(struct host_cmd_ds_version_ext));
1418 cmd_ptr->size =
1419 cpu_to_le16(sizeof(struct host_cmd_ds_version_ext) +
1420 S_DS_GEN);
1421 ret = 0;
1422 break;
Stone Piao3cec6872012-09-25 20:23:34 -07001423 case HostCmd_CMD_MGMT_FRAME_REG:
1424 cmd_ptr->command = cpu_to_le16(cmd_no);
1425 cmd_ptr->params.reg_mask.action = cpu_to_le16(cmd_action);
1426 cmd_ptr->params.reg_mask.mask = cpu_to_le32(*(u32 *)data_buf);
1427 cmd_ptr->size =
1428 cpu_to_le16(sizeof(struct host_cmd_ds_mgmt_frame_reg) +
1429 S_DS_GEN);
1430 ret = 0;
1431 break;
Stone Piao7feb4c42012-09-25 20:23:36 -07001432 case HostCmd_CMD_REMAIN_ON_CHAN:
1433 cmd_ptr->command = cpu_to_le16(cmd_no);
1434 memcpy(&cmd_ptr->params, data_buf,
1435 sizeof(struct host_cmd_ds_remain_on_chan));
1436 cmd_ptr->size =
1437 cpu_to_le16(sizeof(struct host_cmd_ds_remain_on_chan) +
1438 S_DS_GEN);
1439 break;
Yogesh Ashok Powar83c78da2013-03-18 20:06:03 -07001440 case HostCmd_CMD_11AC_CFG:
1441 ret = mwifiex_cmd_11ac_cfg(priv, cmd_ptr, cmd_action, data_buf);
1442 break;
Stone Piaoe1a2b7a2012-09-25 20:23:41 -07001443 case HostCmd_CMD_P2P_MODE_CFG:
1444 cmd_ptr->command = cpu_to_le16(cmd_no);
1445 cmd_ptr->params.mode_cfg.action = cpu_to_le16(cmd_action);
1446 cmd_ptr->params.mode_cfg.mode = cpu_to_le16(*(u16 *)data_buf);
1447 cmd_ptr->size =
1448 cpu_to_le16(sizeof(struct host_cmd_ds_p2p_mode_cfg) +
1449 S_DS_GEN);
1450 break;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001451 case HostCmd_CMD_FUNC_INIT:
1452 if (priv->adapter->hw_status == MWIFIEX_HW_STATUS_RESET)
1453 priv->adapter->hw_status = MWIFIEX_HW_STATUS_READY;
1454 cmd_ptr->command = cpu_to_le16(cmd_no);
1455 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1456 break;
1457 case HostCmd_CMD_FUNC_SHUTDOWN:
1458 priv->adapter->hw_status = MWIFIEX_HW_STATUS_RESET;
1459 cmd_ptr->command = cpu_to_le16(cmd_no);
1460 cmd_ptr->size = cpu_to_le16(S_DS_GEN);
1461 break;
1462 case HostCmd_CMD_11N_ADDBA_REQ:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001463 ret = mwifiex_cmd_11n_addba_req(cmd_ptr, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001464 break;
1465 case HostCmd_CMD_11N_DELBA:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001466 ret = mwifiex_cmd_11n_delba(cmd_ptr, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001467 break;
1468 case HostCmd_CMD_11N_ADDBA_RSP:
1469 ret = mwifiex_cmd_11n_addba_rsp_gen(priv, cmd_ptr, data_buf);
1470 break;
1471 case HostCmd_CMD_802_11_KEY_MATERIAL:
1472 ret = mwifiex_cmd_802_11_key_material(priv, cmd_ptr,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -07001473 cmd_action, cmd_oid,
1474 data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001475 break;
1476 case HostCmd_CMD_802_11D_DOMAIN_INFO:
1477 ret = mwifiex_cmd_802_11d_domain_info(priv, cmd_ptr,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -07001478 cmd_action);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001479 break;
1480 case HostCmd_CMD_RECONFIGURE_TX_BUFF:
1481 ret = mwifiex_cmd_recfg_tx_buf(priv, cmd_ptr, cmd_action,
1482 data_buf);
1483 break;
1484 case HostCmd_CMD_AMSDU_AGGR_CTRL:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001485 ret = mwifiex_cmd_amsdu_aggr_ctrl(cmd_ptr, cmd_action,
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001486 data_buf);
1487 break;
1488 case HostCmd_CMD_11N_CFG:
Yogesh Ashok Powara5f39052013-02-15 21:44:30 -08001489 ret = mwifiex_cmd_11n_cfg(priv, cmd_ptr, cmd_action, data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001490 break;
1491 case HostCmd_CMD_WMM_GET_STATUS:
1492 dev_dbg(priv->adapter->dev,
1493 "cmd: WMM: WMM_GET_STATUS cmd sent\n");
1494 cmd_ptr->command = cpu_to_le16(HostCmd_CMD_WMM_GET_STATUS);
1495 cmd_ptr->size =
1496 cpu_to_le16(sizeof(struct host_cmd_ds_wmm_get_status) +
1497 S_DS_GEN);
1498 ret = 0;
1499 break;
1500 case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
Amitkumar Karwar572e8f32011-04-13 17:27:08 -07001501 ret = mwifiex_cmd_ibss_coalescing_status(cmd_ptr, cmd_action,
1502 data_buf);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001503 break;
Amitkumar Karwar21f58d202014-02-11 18:39:56 -08001504 case HostCmd_CMD_802_11_SCAN_EXT:
1505 ret = mwifiex_cmd_802_11_scan_ext(priv, cmd_ptr, data_buf);
1506 break;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001507 case HostCmd_CMD_MAC_REG_ACCESS:
1508 case HostCmd_CMD_BBP_REG_ACCESS:
1509 case HostCmd_CMD_RF_REG_ACCESS:
1510 case HostCmd_CMD_PMIC_REG_ACCESS:
1511 case HostCmd_CMD_CAU_REG_ACCESS:
1512 case HostCmd_CMD_802_11_EEPROM_ACCESS:
1513 ret = mwifiex_cmd_reg_access(cmd_ptr, cmd_action, data_buf);
1514 break;
1515 case HostCmd_CMD_SET_BSS_MODE:
1516 cmd_ptr->command = cpu_to_le16(cmd_no);
Bing Zhaoeecd8252011-03-28 17:55:41 -07001517 if (priv->bss_mode == NL80211_IFTYPE_ADHOC)
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001518 cmd_ptr->params.bss_mode.con_type =
1519 CONNECTION_TYPE_ADHOC;
Bing Zhaoeecd8252011-03-28 17:55:41 -07001520 else if (priv->bss_mode == NL80211_IFTYPE_STATION)
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001521 cmd_ptr->params.bss_mode.con_type =
1522 CONNECTION_TYPE_INFRA;
Stone Piao9197ab92012-09-25 20:23:42 -07001523 else if (priv->bss_mode == NL80211_IFTYPE_AP)
1524 cmd_ptr->params.bss_mode.con_type = CONNECTION_TYPE_AP;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001525 cmd_ptr->size = cpu_to_le16(sizeof(struct
1526 host_cmd_ds_set_bss_mode) + S_DS_GEN);
1527 ret = 0;
1528 break;
Amitkumar Karward930fae2011-10-11 17:41:21 -07001529 case HostCmd_CMD_PCIE_DESC_DETAILS:
1530 ret = mwifiex_cmd_pcie_host_spec(priv, cmd_ptr, cmd_action);
1531 break;
Amitkumar Karwarfa444bf2012-03-15 20:51:51 -07001532 case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
1533 ret = mwifiex_cmd_802_11_subsc_evt(priv, cmd_ptr, data_buf);
1534 break;
Amitkumar Karwar7da060c2013-03-04 16:27:59 -08001535 case HostCmd_CMD_MEF_CFG:
1536 ret = mwifiex_cmd_mef_cfg(priv, cmd_ptr, data_buf);
1537 break;
Amitkumar Karwar562fc5b2013-08-05 18:52:00 -07001538 case HostCmd_CMD_COALESCE_CFG:
1539 ret = mwifiex_cmd_coalesce_cfg(priv, cmd_ptr, cmd_action,
1540 data_buf);
1541 break;
Avinash Patil429d90d2014-02-07 16:27:34 -08001542 case HostCmd_CMD_TDLS_OPER:
1543 ret = mwifiex_cmd_tdls_oper(priv, cmd_ptr, data_buf);
1544 break;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001545 default:
1546 dev_err(priv->adapter->dev,
1547 "PREP_CMD: unknown cmd- %#x\n", cmd_no);
1548 ret = -1;
1549 break;
1550 }
1551 return ret;
1552}
1553
1554/*
1555 * This function issues commands to initialize firmware.
1556 *
1557 * This is called after firmware download to bring the card to
1558 * working state.
1559 *
1560 * The following commands are issued sequentially -
Amitkumar Karward930fae2011-10-11 17:41:21 -07001561 * - Set PCI-Express host buffer configuration (PCIE only)
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001562 * - Function init (for first interface only)
1563 * - Read MAC address (for first interface only)
1564 * - Reconfigure Tx buffer size (for first interface only)
1565 * - Enable auto deep sleep (for first interface only)
1566 * - Get Tx rate
1567 * - Get Tx power
1568 * - Set IBSS coalescing status
1569 * - Set AMSDU aggregation control
1570 * - Set 11d control
1571 * - Set MAC control (this must be the last command to initialize firmware)
1572 */
1573int mwifiex_sta_init_cmd(struct mwifiex_private *priv, u8 first_sta)
1574{
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001575 struct mwifiex_adapter *adapter = priv->adapter;
Yogesh Ashok Powar270e58e2011-05-03 20:11:46 -07001576 int ret;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001577 u16 enable = true;
1578 struct mwifiex_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
1579 struct mwifiex_ds_auto_ds auto_ds;
1580 enum state_11d_t state_11d;
Amitkumar Karwarcd27bc32011-07-08 20:40:30 -07001581 struct mwifiex_ds_11n_tx_cfg tx_cfg;
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001582
1583 if (first_sta) {
Amitkumar Karward930fae2011-10-11 17:41:21 -07001584 if (priv->adapter->iface_type == MWIFIEX_PCIE) {
Stone Piao7bff9c92012-09-25 20:23:39 -07001585 ret = mwifiex_send_cmd_sync(priv,
Yogesh Ashok Powar9c05fd72012-03-13 19:22:40 -07001586 HostCmd_CMD_PCIE_DESC_DETAILS,
1587 HostCmd_ACT_GEN_SET, 0, NULL);
Amitkumar Karward930fae2011-10-11 17:41:21 -07001588 if (ret)
1589 return -1;
1590 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001591
Stone Piao7bff9c92012-09-25 20:23:39 -07001592 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_FUNC_INIT,
1593 HostCmd_ACT_GEN_SET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001594 if (ret)
1595 return -1;
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001596
Bing Zhao699b0272013-12-13 18:33:01 -08001597 /* Download calibration data to firmware.
1598 * The cal-data can be read from device tree and/or
1599 * a configuration file and downloaded to firmware.
1600 */
1601 adapter->dt_node =
1602 of_find_node_by_name(NULL, "marvell_cfgdata");
1603 if (adapter->dt_node) {
1604 ret = mwifiex_dnld_dt_cfgdata(priv, adapter->dt_node,
1605 "marvell,caldata");
1606 if (ret)
1607 return -1;
1608 }
1609
Amitkumar Karwar388ec382013-05-17 17:50:25 -07001610 if (adapter->cal_data) {
1611 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_CFG_DATA,
1612 HostCmd_ACT_GEN_SET, 0, NULL);
1613 if (ret)
1614 return -1;
1615 }
1616
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001617 /* Read MAC address from HW */
Stone Piao7bff9c92012-09-25 20:23:39 -07001618 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_GET_HW_SPEC,
1619 HostCmd_ACT_GEN_GET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001620 if (ret)
1621 return -1;
1622
1623 /* Reconfigure tx buf size */
Stone Piao7bff9c92012-09-25 20:23:39 -07001624 ret = mwifiex_send_cmd_sync(priv,
1625 HostCmd_CMD_RECONFIGURE_TX_BUFF,
1626 HostCmd_ACT_GEN_SET, 0,
1627 &priv->adapter->tx_buf_size);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001628 if (ret)
1629 return -1;
1630
Avinash Patil03785382012-05-08 18:30:14 -07001631 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1632 /* Enable IEEE PS by default */
1633 priv->adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
Stone Piao7bff9c92012-09-25 20:23:39 -07001634 ret = mwifiex_send_cmd_sync(
Avinash Patil03785382012-05-08 18:30:14 -07001635 priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1636 EN_AUTO_PS, BITMAP_STA_PS, NULL);
1637 if (ret)
1638 return -1;
1639 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001640 }
1641
1642 /* get tx rate */
Stone Piao7bff9c92012-09-25 20:23:39 -07001643 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
1644 HostCmd_ACT_GEN_GET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001645 if (ret)
1646 return -1;
1647 priv->data_rate = 0;
1648
1649 /* get tx power */
Stone Piao7bff9c92012-09-25 20:23:39 -07001650 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_RF_TX_PWR,
1651 HostCmd_ACT_GEN_GET, 0, NULL);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001652 if (ret)
1653 return -1;
1654
Avinash Patil03785382012-05-08 18:30:14 -07001655 if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
1656 /* set ibss coalescing_status */
Stone Piao7bff9c92012-09-25 20:23:39 -07001657 ret = mwifiex_send_cmd_sync(
Avinash Patil03785382012-05-08 18:30:14 -07001658 priv, HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
1659 HostCmd_ACT_GEN_SET, 0, &enable);
1660 if (ret)
1661 return -1;
1662 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001663
1664 memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
1665 amsdu_aggr_ctrl.enable = true;
1666 /* Send request to firmware */
Stone Piao7bff9c92012-09-25 20:23:39 -07001667 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_AMSDU_AGGR_CTRL,
1668 HostCmd_ACT_GEN_SET, 0,
1669 &amsdu_aggr_ctrl);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001670 if (ret)
1671 return -1;
1672 /* MAC Control must be the last command in init_fw */
1673 /* set MAC Control */
Stone Piao7bff9c92012-09-25 20:23:39 -07001674 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1675 HostCmd_ACT_GEN_SET, 0,
1676 &priv->curr_pkt_filter);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001677 if (ret)
1678 return -1;
1679
Avinash Patil03785382012-05-08 18:30:14 -07001680 if (first_sta && priv->adapter->iface_type != MWIFIEX_USB &&
1681 priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001682 /* Enable auto deep sleep */
1683 auto_ds.auto_ds = DEEP_SLEEP_ON;
1684 auto_ds.idle_time = DEEP_SLEEP_IDLE_TIME;
Stone Piao7bff9c92012-09-25 20:23:39 -07001685 ret = mwifiex_send_cmd_sync(priv,
1686 HostCmd_CMD_802_11_PS_MODE_ENH,
1687 EN_AUTO_PS, BITMAP_AUTO_DS,
1688 &auto_ds);
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001689 if (ret)
1690 return -1;
1691 }
1692
Avinash Patil03785382012-05-08 18:30:14 -07001693 if (priv->bss_type != MWIFIEX_BSS_TYPE_UAP) {
1694 /* Send cmd to FW to enable/disable 11D function */
1695 state_11d = ENABLE_11D;
Stone Piao7bff9c92012-09-25 20:23:39 -07001696 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
1697 HostCmd_ACT_GEN_SET, DOT11D_I,
1698 &state_11d);
Avinash Patil03785382012-05-08 18:30:14 -07001699 if (ret)
1700 dev_err(priv->adapter->dev,
1701 "11D: failed to enable 11D\n");
1702 }
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001703
Stone Piao7bff9c92012-09-25 20:23:39 -07001704 /* set last_init_cmd before sending the command */
1705 priv->adapter->last_init_cmd = HostCmd_CMD_11N_CFG;
1706
Amitkumar Karwarcd27bc32011-07-08 20:40:30 -07001707 /* Send cmd to FW to configure 11n specific configuration
1708 * (Short GI, Channel BW, Green field support etc.) for transmit
1709 */
1710 tx_cfg.tx_htcap = MWIFIEX_FW_DEF_HTTXCFG;
Stone Piao7bff9c92012-09-25 20:23:39 -07001711 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_11N_CFG,
1712 HostCmd_ACT_GEN_SET, 0, &tx_cfg);
Amitkumar Karwarcd27bc32011-07-08 20:40:30 -07001713
Bing Zhao5e6e3a92011-03-21 18:00:50 -07001714 ret = -EINPROGRESS;
1715
1716 return ret;
1717}