1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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#include "cfg80211.h"
28
29static int disconnect_on_suspend;
30module_param(disconnect_on_suspend, int, 0644);
31
32
33
34
35
36
37
38
39int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
40 struct net_device *dev)
41{
42 int i = 0;
43 struct netdev_hw_addr *ha;
44
45 netdev_for_each_mc_addr(ha, dev)
46 memcpy(&mlist->mac_list[i++], ha->addr, ETH_ALEN);
47
48 return i;
49}
50
51
52
53
54
55
56
57int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
58 struct cmd_ctrl_node *cmd_queued)
59{
60 int status;
61
62
63 status = wait_event_interruptible_timeout(adapter->cmd_wait_q.wait,
64 *(cmd_queued->condition),
65 (12 * HZ));
66 if (status <= 0) {
67 if (status == 0)
68 status = -ETIMEDOUT;
69 mwifiex_dbg(adapter, ERROR, "cmd_wait_q terminated: %d\n",
70 status);
71 mwifiex_cancel_all_pending_cmd(adapter);
72 return status;
73 }
74
75 status = adapter->cmd_wait_q.status;
76 adapter->cmd_wait_q.status = 0;
77
78 return status;
79}
80
81
82
83
84
85
86
87
88int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
89 struct mwifiex_multicast_list *mcast_list)
90{
91 int ret = 0;
92 u16 old_pkt_filter;
93
94 old_pkt_filter = priv->curr_pkt_filter;
95
96 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
97 mwifiex_dbg(priv->adapter, INFO,
98 "info: Enable Promiscuous mode\n");
99 priv->curr_pkt_filter |= HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
100 priv->curr_pkt_filter &=
101 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
102 } else {
103
104 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_PROMISCUOUS_ENABLE;
105 if (mcast_list->mode == MWIFIEX_ALL_MULTI_MODE) {
106 mwifiex_dbg(priv->adapter, INFO,
107 "info: Enabling All Multicast!\n");
108 priv->curr_pkt_filter |=
109 HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
110 } else {
111 priv->curr_pkt_filter &=
112 ~HostCmd_ACT_MAC_ALL_MULTICAST_ENABLE;
113 mwifiex_dbg(priv->adapter, INFO,
114 "info: Set multicast list=%d\n",
115 mcast_list->num_multicast_addr);
116
117 ret = mwifiex_send_cmd(priv,
118 HostCmd_CMD_MAC_MULTICAST_ADR,
119 HostCmd_ACT_GEN_SET, 0,
120 mcast_list, false);
121 }
122 }
123 mwifiex_dbg(priv->adapter, INFO,
124 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
125 old_pkt_filter, priv->curr_pkt_filter);
126 if (old_pkt_filter != priv->curr_pkt_filter) {
127 ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
128 HostCmd_ACT_GEN_SET,
129 0, &priv->curr_pkt_filter, false);
130 }
131
132 return ret;
133}
134
135
136
137
138
139
140
141int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
142 struct cfg80211_bss *bss,
143 struct mwifiex_bssdescriptor *bss_desc)
144{
145 u8 *beacon_ie;
146 size_t beacon_ie_len;
147 struct mwifiex_bss_priv *bss_priv = (void *)bss->priv;
148 const struct cfg80211_bss_ies *ies;
149 int ret;
150
151 rcu_read_lock();
152 ies = rcu_dereference(bss->ies);
153 beacon_ie = kmemdup(ies->data, ies->len, GFP_ATOMIC);
154 beacon_ie_len = ies->len;
155 bss_desc->timestamp = ies->tsf;
156 rcu_read_unlock();
157
158 if (!beacon_ie) {
159 mwifiex_dbg(priv->adapter, ERROR,
160 " failed to alloc beacon_ie\n");
161 return -ENOMEM;
162 }
163
164 memcpy(bss_desc->mac_address, bss->bssid, ETH_ALEN);
165 bss_desc->rssi = bss->signal;
166
167 bss_desc->beacon_buf = beacon_ie;
168 bss_desc->beacon_buf_size = beacon_ie_len;
169 bss_desc->beacon_period = bss->beacon_interval;
170 bss_desc->cap_info_bitmap = bss->capability;
171 bss_desc->bss_band = bss_priv->band;
172 bss_desc->fw_tsf = bss_priv->fw_tsf;
173 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_PRIVACY) {
174 mwifiex_dbg(priv->adapter, INFO,
175 "info: InterpretIE: AP WEP enabled\n");
176 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_8021X_WEP;
177 } else {
178 bss_desc->privacy = MWIFIEX_802_11_PRIV_FILTER_ACCEPT_ALL;
179 }
180 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_IBSS)
181 bss_desc->bss_mode = NL80211_IFTYPE_ADHOC;
182 else
183 bss_desc->bss_mode = NL80211_IFTYPE_STATION;
184
185
186
187
188 bss_desc->disable_11ac = true;
189
190 if (bss_desc->cap_info_bitmap & WLAN_CAPABILITY_SPECTRUM_MGMT)
191 bss_desc->sensed_11h = true;
192
193 ret = mwifiex_update_bss_desc_with_ie(priv->adapter, bss_desc);
194 if (ret)
195 return ret;
196
197
198 if (bss_desc->bcn_ht_oper && bss_desc->bcn_ht_cap) {
199 u8 ht_param = bss_desc->bcn_ht_oper->ht_param;
200 u8 radio = mwifiex_band_to_radio_type(bss_desc->bss_band);
201 struct ieee80211_supported_band *sband =
202 priv->wdev.wiphy->bands[radio];
203 int freq = ieee80211_channel_to_frequency(bss_desc->channel,
204 radio);
205 struct ieee80211_channel *chan =
206 ieee80211_get_channel(priv->adapter->wiphy, freq);
207
208 switch (ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
209 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
210 if (chan->flags & IEEE80211_CHAN_NO_HT40PLUS) {
211 sband->ht_cap.cap &=
212 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
213 sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
214 } else {
215 sband->ht_cap.cap |=
216 IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
217 IEEE80211_HT_CAP_SGI_40;
218 }
219 break;
220 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
221 if (chan->flags & IEEE80211_CHAN_NO_HT40MINUS) {
222 sband->ht_cap.cap &=
223 ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
224 sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
225 } else {
226 sband->ht_cap.cap |=
227 IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
228 IEEE80211_HT_CAP_SGI_40;
229 }
230 break;
231 }
232 }
233
234 return 0;
235}
236
237void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv)
238{
239 if (priv->adapter->dt_node) {
240 char txpwr[] = {"marvell,00_txpwrlimit"};
241
242 memcpy(&txpwr[8], priv->adapter->country_code, 2);
243 mwifiex_dnld_dt_cfgdata(priv, priv->adapter->dt_node, txpwr);
244 }
245}
246
247static int mwifiex_process_country_ie(struct mwifiex_private *priv,
248 struct cfg80211_bss *bss)
249{
250 const u8 *country_ie;
251 u8 country_ie_len;
252 struct mwifiex_802_11d_domain_reg *domain_info =
253 &priv->adapter->domain_reg;
254
255 rcu_read_lock();
256 country_ie = ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY);
257 if (!country_ie) {
258 rcu_read_unlock();
259 return 0;
260 }
261
262 country_ie_len = country_ie[1];
263 if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) {
264 rcu_read_unlock();
265 return 0;
266 }
267
268 if (!strncmp(priv->adapter->country_code, &country_ie[2], 2)) {
269 rcu_read_unlock();
270 mwifiex_dbg(priv->adapter, INFO,
271 "11D: skip setting domain info in FW\n");
272 return 0;
273 }
274 memcpy(priv->adapter->country_code, &country_ie[2], 2);
275
276 domain_info->country_code[0] = country_ie[2];
277 domain_info->country_code[1] = country_ie[3];
278 domain_info->country_code[2] = ' ';
279
280 country_ie_len -= IEEE80211_COUNTRY_STRING_LEN;
281
282 domain_info->no_of_triplet =
283 country_ie_len / sizeof(struct ieee80211_country_ie_triplet);
284
285 memcpy((u8 *)domain_info->triplet,
286 &country_ie[2] + IEEE80211_COUNTRY_STRING_LEN, country_ie_len);
287
288 rcu_read_unlock();
289
290 if (mwifiex_send_cmd(priv, HostCmd_CMD_802_11D_DOMAIN_INFO,
291 HostCmd_ACT_GEN_SET, 0, NULL, false)) {
292 mwifiex_dbg(priv->adapter, ERROR,
293 "11D: setting domain info in FW fail\n");
294 return -1;
295 }
296
297 mwifiex_dnld_txpwr_table(priv);
298
299 return 0;
300}
301
302
303
304
305
306
307int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
308 struct cfg80211_ssid *req_ssid)
309{
310 int ret;
311 struct mwifiex_adapter *adapter = priv->adapter;
312 struct mwifiex_bssdescriptor *bss_desc = NULL;
313
314 priv->scan_block = false;
315
316 if (bss) {
317 if (adapter->region_code == 0x00)
318 mwifiex_process_country_ie(priv, bss);
319
320
321 bss_desc = kzalloc(sizeof(struct mwifiex_bssdescriptor),
322 GFP_KERNEL);
323 if (!bss_desc)
324 return -ENOMEM;
325
326 ret = mwifiex_fill_new_bss_desc(priv, bss, bss_desc);
327 if (ret)
328 goto done;
329 }
330
331 if (priv->bss_mode == NL80211_IFTYPE_STATION ||
332 priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) {
333 u8 config_bands;
334
335 if (!bss_desc)
336 return -1;
337
338 if (mwifiex_band_to_radio_type(bss_desc->bss_band) ==
339 HostCmd_SCAN_RADIO_TYPE_BG) {
340 config_bands = BAND_B | BAND_G | BAND_GN;
341 } else {
342 config_bands = BAND_A | BAND_AN;
343 if (adapter->fw_bands & BAND_AAC)
344 config_bands |= BAND_AAC;
345 }
346
347 if (!((config_bands | adapter->fw_bands) & ~adapter->fw_bands))
348 adapter->config_bands = config_bands;
349
350 ret = mwifiex_check_network_compatibility(priv, bss_desc);
351 if (ret)
352 goto done;
353
354 if (mwifiex_11h_get_csa_closed_channel(priv) ==
355 (u8)bss_desc->channel) {
356 mwifiex_dbg(adapter, ERROR,
357 "Attempt to reconnect on csa closed chan(%d)\n",
358 bss_desc->channel);
359 ret = -1;
360 goto done;
361 }
362
363 mwifiex_dbg(adapter, INFO,
364 "info: SSID found in scan list ...\t"
365 "associating...\n");
366
367 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
368 if (netif_carrier_ok(priv->netdev))
369 netif_carrier_off(priv->netdev);
370
371
372
373 priv->assoc_rsp_size = 0;
374 ret = mwifiex_associate(priv, bss_desc);
375
376
377
378 if (ret == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG &&
379 priv->sec_info.is_authtype_auto &&
380 priv->sec_info.wep_enabled) {
381 priv->sec_info.authentication_mode =
382 NL80211_AUTHTYPE_SHARED_KEY;
383 ret = mwifiex_associate(priv, bss_desc);
384 }
385
386 if (bss)
387 cfg80211_put_bss(priv->adapter->wiphy, bss);
388 } else {
389
390
391 if (bss_desc && bss_desc->ssid.ssid_len &&
392 (!mwifiex_ssid_cmp(&priv->curr_bss_params.bss_descriptor.
393 ssid, &bss_desc->ssid))) {
394 ret = 0;
395 goto done;
396 }
397
398 priv->adhoc_is_link_sensed = false;
399
400 ret = mwifiex_check_network_compatibility(priv, bss_desc);
401
402 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
403 if (netif_carrier_ok(priv->netdev))
404 netif_carrier_off(priv->netdev);
405
406 if (!ret) {
407 mwifiex_dbg(adapter, INFO,
408 "info: network found in scan\t"
409 " list. Joining...\n");
410 ret = mwifiex_adhoc_join(priv, bss_desc);
411 if (bss)
412 cfg80211_put_bss(priv->adapter->wiphy, bss);
413 } else {
414 mwifiex_dbg(adapter, INFO,
415 "info: Network not found in\t"
416 "the list, creating adhoc with ssid = %s\n",
417 req_ssid->ssid);
418 ret = mwifiex_adhoc_start(priv, req_ssid);
419 }
420 }
421
422done:
423
424
425
426 if (bss_desc)
427 kfree(bss_desc->beacon_buf);
428 kfree(bss_desc);
429
430 if (ret < 0)
431 priv->attempted_bss_desc = NULL;
432
433 return ret;
434}
435
436
437
438
439
440
441
442int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
443 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
444
445{
446 struct mwifiex_adapter *adapter = priv->adapter;
447 int status = 0;
448 u32 prev_cond = 0;
449
450 if (!hs_cfg)
451 return -ENOMEM;
452
453 switch (action) {
454 case HostCmd_ACT_GEN_SET:
455 if (adapter->pps_uapsd_mode) {
456 mwifiex_dbg(adapter, INFO,
457 "info: Host Sleep IOCTL\t"
458 "is blocked in UAPSD/PPS mode\n");
459 status = -1;
460 break;
461 }
462 if (hs_cfg->is_invoke_hostcmd) {
463 if (hs_cfg->conditions == HS_CFG_CANCEL) {
464 if (!adapter->is_hs_configured)
465
466 break;
467
468 prev_cond = le32_to_cpu(adapter->hs_cfg
469 .conditions);
470 adapter->hs_cfg.conditions =
471 cpu_to_le32(hs_cfg->conditions);
472 } else if (hs_cfg->conditions) {
473 adapter->hs_cfg.conditions =
474 cpu_to_le32(hs_cfg->conditions);
475 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
476 if (hs_cfg->gap)
477 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
478 } else if (adapter->hs_cfg.conditions ==
479 cpu_to_le32(HS_CFG_CANCEL)) {
480
481
482 status = -1;
483 break;
484 }
485
486 status = mwifiex_send_cmd(priv,
487 HostCmd_CMD_802_11_HS_CFG_ENH,
488 HostCmd_ACT_GEN_SET, 0,
489 &adapter->hs_cfg,
490 cmd_type == MWIFIEX_SYNC_CMD);
491
492 if (hs_cfg->conditions == HS_CFG_CANCEL)
493
494 adapter->hs_cfg.conditions =
495 cpu_to_le32(prev_cond);
496 } else {
497 adapter->hs_cfg.conditions =
498 cpu_to_le32(hs_cfg->conditions);
499 adapter->hs_cfg.gpio = (u8)hs_cfg->gpio;
500 adapter->hs_cfg.gap = (u8)hs_cfg->gap;
501 }
502 break;
503 case HostCmd_ACT_GEN_GET:
504 hs_cfg->conditions = le32_to_cpu(adapter->hs_cfg.conditions);
505 hs_cfg->gpio = adapter->hs_cfg.gpio;
506 hs_cfg->gap = adapter->hs_cfg.gap;
507 break;
508 default:
509 status = -1;
510 break;
511 }
512
513 return status;
514}
515
516
517
518
519
520
521
522int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
523{
524 struct mwifiex_ds_hs_cfg hscfg;
525
526 hscfg.conditions = HS_CFG_CANCEL;
527 hscfg.is_invoke_hostcmd = true;
528
529 return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
530 cmd_type, &hscfg);
531}
532EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
533
534
535
536
537
538
539
540int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
541{
542 struct mwifiex_ds_hs_cfg hscfg;
543 struct mwifiex_private *priv;
544 int i;
545
546 if (disconnect_on_suspend) {
547 for (i = 0; i < adapter->priv_num; i++) {
548 priv = adapter->priv[i];
549 if (priv)
550 mwifiex_deauthenticate(priv, NULL);
551 }
552 }
553
554 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA);
555
556 if (priv && priv->sched_scanning) {
557#ifdef CONFIG_PM
558 if (priv->wdev.wiphy->wowlan_config &&
559 !priv->wdev.wiphy->wowlan_config->nd_config) {
560#endif
561 mwifiex_dbg(adapter, CMD, "aborting bgscan!\n");
562 mwifiex_stop_bg_scan(priv);
563 cfg80211_sched_scan_stopped(priv->wdev.wiphy, 0);
564#ifdef CONFIG_PM
565 }
566#endif
567 }
568
569 if (adapter->hs_activated) {
570 mwifiex_dbg(adapter, CMD,
571 "cmd: HS Already activated\n");
572 return true;
573 }
574
575 adapter->hs_activate_wait_q_woken = false;
576
577 memset(&hscfg, 0, sizeof(hscfg));
578 hscfg.is_invoke_hostcmd = true;
579
580 adapter->hs_enabling = true;
581 mwifiex_cancel_all_pending_cmd(adapter);
582
583 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
584 MWIFIEX_BSS_ROLE_STA),
585 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
586 &hscfg)) {
587 mwifiex_dbg(adapter, ERROR,
588 "IOCTL request HS enable failed\n");
589 return false;
590 }
591
592 if (wait_event_interruptible_timeout(adapter->hs_activate_wait_q,
593 adapter->hs_activate_wait_q_woken,
594 (10 * HZ)) <= 0) {
595 mwifiex_dbg(adapter, ERROR,
596 "hs_activate_wait_q terminated\n");
597 return false;
598 }
599
600 return true;
601}
602EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
603
604
605
606
607
608
609
610int mwifiex_get_bss_info(struct mwifiex_private *priv,
611 struct mwifiex_bss_info *info)
612{
613 struct mwifiex_adapter *adapter = priv->adapter;
614 struct mwifiex_bssdescriptor *bss_desc;
615
616 if (!info)
617 return -1;
618
619 bss_desc = &priv->curr_bss_params.bss_descriptor;
620
621 info->bss_mode = priv->bss_mode;
622
623 memcpy(&info->ssid, &bss_desc->ssid, sizeof(struct cfg80211_ssid));
624
625 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
626
627 info->bss_chan = bss_desc->channel;
628
629 memcpy(info->country_code, adapter->country_code,
630 IEEE80211_COUNTRY_STRING_LEN);
631
632 info->media_connected = priv->media_connected;
633
634 info->max_power_level = priv->max_tx_power_level;
635 info->min_power_level = priv->min_tx_power_level;
636
637 info->adhoc_state = priv->adhoc_state;
638
639 info->bcn_nf_last = priv->bcn_nf_last;
640
641 if (priv->sec_info.wep_enabled)
642 info->wep_status = true;
643 else
644 info->wep_status = false;
645
646 info->is_hs_configured = adapter->is_hs_configured;
647 info->is_deep_sleep = adapter->is_deep_sleep;
648
649 return 0;
650}
651
652
653
654
655int mwifiex_disable_auto_ds(struct mwifiex_private *priv)
656{
657 struct mwifiex_ds_auto_ds auto_ds = {
658 .auto_ds = DEEP_SLEEP_OFF,
659 };
660
661 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
662 DIS_AUTO_PS, BITMAP_AUTO_DS, &auto_ds, true);
663}
664EXPORT_SYMBOL_GPL(mwifiex_disable_auto_ds);
665
666
667
668
669
670
671
672int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate)
673{
674 int ret;
675
676 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
677 HostCmd_ACT_GEN_GET, 0, NULL, true);
678
679 if (!ret) {
680 if (priv->is_data_rate_auto)
681 *rate = mwifiex_index_to_data_rate(priv, priv->tx_rate,
682 priv->tx_htinfo);
683 else
684 *rate = priv->data_rate;
685 }
686
687 return ret;
688}
689
690
691
692
693
694
695
696
697
698
699
700
701
702int mwifiex_set_tx_power(struct mwifiex_private *priv,
703 struct mwifiex_power_cfg *power_cfg)
704{
705 int ret;
706 struct host_cmd_ds_txpwr_cfg *txp_cfg;
707 struct mwifiex_types_power_group *pg_tlv;
708 struct mwifiex_power_group *pg;
709 u8 *buf;
710 u16 dbm = 0;
711
712 if (!power_cfg->is_power_auto) {
713 dbm = (u16) power_cfg->power_level;
714 if ((dbm < priv->min_tx_power_level) ||
715 (dbm > priv->max_tx_power_level)) {
716 mwifiex_dbg(priv->adapter, ERROR,
717 "txpower value %d dBm\t"
718 "is out of range (%d dBm-%d dBm)\n",
719 dbm, priv->min_tx_power_level,
720 priv->max_tx_power_level);
721 return -1;
722 }
723 }
724 buf = kzalloc(MWIFIEX_SIZE_OF_CMD_BUFFER, GFP_KERNEL);
725 if (!buf)
726 return -ENOMEM;
727
728 txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
729 txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
730 if (!power_cfg->is_power_auto) {
731 txp_cfg->mode = cpu_to_le32(1);
732 pg_tlv = (struct mwifiex_types_power_group *)
733 (buf + sizeof(struct host_cmd_ds_txpwr_cfg));
734 pg_tlv->type = cpu_to_le16(TLV_TYPE_POWER_GROUP);
735 pg_tlv->length =
736 cpu_to_le16(4 * sizeof(struct mwifiex_power_group));
737 pg = (struct mwifiex_power_group *)
738 (buf + sizeof(struct host_cmd_ds_txpwr_cfg)
739 + sizeof(struct mwifiex_types_power_group));
740
741 pg->first_rate_code = 0x00;
742 pg->last_rate_code = 0x03;
743 pg->modulation_class = MOD_CLASS_HR_DSSS;
744 pg->power_step = 0;
745 pg->power_min = (s8) dbm;
746 pg->power_max = (s8) dbm;
747 pg++;
748
749 pg->first_rate_code = 0x00;
750 pg->last_rate_code = 0x07;
751 pg->modulation_class = MOD_CLASS_OFDM;
752 pg->power_step = 0;
753 pg->power_min = (s8) dbm;
754 pg->power_max = (s8) dbm;
755 pg++;
756
757 pg->first_rate_code = 0x00;
758 pg->last_rate_code = 0x20;
759 pg->modulation_class = MOD_CLASS_HT;
760 pg->power_step = 0;
761 pg->power_min = (s8) dbm;
762 pg->power_max = (s8) dbm;
763 pg->ht_bandwidth = HT_BW_20;
764 pg++;
765
766 pg->first_rate_code = 0x00;
767 pg->last_rate_code = 0x20;
768 pg->modulation_class = MOD_CLASS_HT;
769 pg->power_step = 0;
770 pg->power_min = (s8) dbm;
771 pg->power_max = (s8) dbm;
772 pg->ht_bandwidth = HT_BW_40;
773 }
774 ret = mwifiex_send_cmd(priv, HostCmd_CMD_TXPWR_CFG,
775 HostCmd_ACT_GEN_SET, 0, buf, true);
776
777 kfree(buf);
778 return ret;
779}
780
781
782
783
784
785
786
787int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
788{
789 int ret;
790 struct mwifiex_adapter *adapter = priv->adapter;
791 u16 sub_cmd;
792
793 if (*ps_mode)
794 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
795 else
796 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
797 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
798 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
799 sub_cmd, BITMAP_STA_PS, NULL, true);
800 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
801 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
802 GET_PS, 0, NULL, false);
803
804 return ret;
805}
806
807
808
809
810
811
812
813
814static int mwifiex_set_wpa_ie(struct mwifiex_private *priv,
815 u8 *ie_data_ptr, u16 ie_len)
816{
817 if (ie_len) {
818 if (ie_len > sizeof(priv->wpa_ie)) {
819 mwifiex_dbg(priv->adapter, ERROR,
820 "failed to copy WPA IE, too big\n");
821 return -1;
822 }
823 memcpy(priv->wpa_ie, ie_data_ptr, ie_len);
824 priv->wpa_ie_len = ie_len;
825 mwifiex_dbg(priv->adapter, CMD,
826 "cmd: Set Wpa_ie_len=%d IE=%#x\n",
827 priv->wpa_ie_len, priv->wpa_ie[0]);
828
829 if (priv->wpa_ie[0] == WLAN_EID_VENDOR_SPECIFIC) {
830 priv->sec_info.wpa_enabled = true;
831 } else if (priv->wpa_ie[0] == WLAN_EID_RSN) {
832 priv->sec_info.wpa2_enabled = true;
833 } else {
834 priv->sec_info.wpa_enabled = false;
835 priv->sec_info.wpa2_enabled = false;
836 }
837 } else {
838 memset(priv->wpa_ie, 0, sizeof(priv->wpa_ie));
839 priv->wpa_ie_len = 0;
840 mwifiex_dbg(priv->adapter, INFO,
841 "info: reset wpa_ie_len=%d IE=%#x\n",
842 priv->wpa_ie_len, priv->wpa_ie[0]);
843 priv->sec_info.wpa_enabled = false;
844 priv->sec_info.wpa2_enabled = false;
845 }
846
847 return 0;
848}
849
850
851
852
853
854
855
856
857static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
858 u8 *ie_data_ptr, u16 ie_len)
859{
860 if (ie_len) {
861 if (ie_len > sizeof(priv->wapi_ie)) {
862 mwifiex_dbg(priv->adapter, ERROR,
863 "info: failed to copy WAPI IE, too big\n");
864 return -1;
865 }
866 memcpy(priv->wapi_ie, ie_data_ptr, ie_len);
867 priv->wapi_ie_len = ie_len;
868 mwifiex_dbg(priv->adapter, CMD,
869 "cmd: Set wapi_ie_len=%d IE=%#x\n",
870 priv->wapi_ie_len, priv->wapi_ie[0]);
871
872 if (priv->wapi_ie[0] == WLAN_EID_BSS_AC_ACCESS_DELAY)
873 priv->sec_info.wapi_enabled = true;
874 } else {
875 memset(priv->wapi_ie, 0, sizeof(priv->wapi_ie));
876 priv->wapi_ie_len = ie_len;
877 mwifiex_dbg(priv->adapter, INFO,
878 "info: Reset wapi_ie_len=%d IE=%#x\n",
879 priv->wapi_ie_len, priv->wapi_ie[0]);
880 priv->sec_info.wapi_enabled = false;
881 }
882 return 0;
883}
884
885
886
887
888
889
890
891
892static int mwifiex_set_wps_ie(struct mwifiex_private *priv,
893 u8 *ie_data_ptr, u16 ie_len)
894{
895 if (ie_len) {
896 if (ie_len > MWIFIEX_MAX_VSIE_LEN) {
897 mwifiex_dbg(priv->adapter, ERROR,
898 "info: failed to copy WPS IE, too big\n");
899 return -1;
900 }
901
902 priv->wps_ie = kzalloc(MWIFIEX_MAX_VSIE_LEN, GFP_KERNEL);
903 if (!priv->wps_ie)
904 return -ENOMEM;
905
906 memcpy(priv->wps_ie, ie_data_ptr, ie_len);
907 priv->wps_ie_len = ie_len;
908 mwifiex_dbg(priv->adapter, CMD,
909 "cmd: Set wps_ie_len=%d IE=%#x\n",
910 priv->wps_ie_len, priv->wps_ie[0]);
911 } else {
912 kfree(priv->wps_ie);
913 priv->wps_ie_len = ie_len;
914 mwifiex_dbg(priv->adapter, INFO,
915 "info: Reset wps_ie_len=%d\n", priv->wps_ie_len);
916 }
917 return 0;
918}
919
920
921
922
923
924
925
926static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
927 struct mwifiex_ds_encrypt_key *encrypt_key)
928{
929
930 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
931 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
932 encrypt_key, true);
933}
934
935
936
937
938
939
940
941static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
942 struct mwifiex_ds_encrypt_key *encrypt_key)
943{
944 struct mwifiex_adapter *adapter = priv->adapter;
945 int ret;
946 struct mwifiex_wep_key *wep_key;
947 int index;
948
949 if (priv->wep_key_curr_index >= NUM_WEP_KEYS)
950 priv->wep_key_curr_index = 0;
951 wep_key = &priv->wep_key[priv->wep_key_curr_index];
952 index = encrypt_key->key_index;
953 if (encrypt_key->key_disable) {
954 priv->sec_info.wep_enabled = 0;
955 } else if (!encrypt_key->key_len) {
956
957 wep_key = &priv->wep_key[index];
958 if (!wep_key->key_length) {
959 mwifiex_dbg(adapter, ERROR,
960 "key not set, so cannot enable it\n");
961 return -1;
962 }
963
964 if (adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2) {
965 memcpy(encrypt_key->key_material,
966 wep_key->key_material, wep_key->key_length);
967 encrypt_key->key_len = wep_key->key_length;
968 }
969
970 priv->wep_key_curr_index = (u16) index;
971 priv->sec_info.wep_enabled = 1;
972 } else {
973 wep_key = &priv->wep_key[index];
974 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
975
976 memcpy(wep_key->key_material,
977 encrypt_key->key_material,
978 encrypt_key->key_len);
979 wep_key->key_index = index;
980 wep_key->key_length = encrypt_key->key_len;
981 priv->sec_info.wep_enabled = 1;
982 }
983 if (wep_key->key_length) {
984 void *enc_key;
985
986 if (encrypt_key->key_disable) {
987 memset(&priv->wep_key[index], 0,
988 sizeof(struct mwifiex_wep_key));
989 goto done;
990 }
991
992 if (adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2)
993 enc_key = encrypt_key;
994 else
995 enc_key = NULL;
996
997
998 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
999 HostCmd_ACT_GEN_SET, 0, enc_key, false);
1000 if (ret)
1001 return ret;
1002 }
1003
1004done:
1005 if (priv->sec_info.wep_enabled)
1006 priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
1007 else
1008 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1009
1010 ret = mwifiex_send_cmd(priv, HostCmd_CMD_MAC_CONTROL,
1011 HostCmd_ACT_GEN_SET, 0,
1012 &priv->curr_pkt_filter, true);
1013
1014 return ret;
1015}
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
1028 struct mwifiex_ds_encrypt_key *encrypt_key)
1029{
1030 int ret;
1031 u8 remove_key = false;
1032 struct host_cmd_ds_802_11_key_material *ibss_key;
1033
1034
1035 if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) {
1036 mwifiex_dbg(priv->adapter, ERROR,
1037 "key length too long\n");
1038 return -1;
1039 }
1040
1041 if (priv->bss_mode == NL80211_IFTYPE_ADHOC) {
1042
1043
1044
1045
1046
1047 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1048 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1049 HostCmd_ACT_GEN_SET,
1050 KEY_INFO_ENABLED, encrypt_key, false);
1051 if (ret)
1052 return ret;
1053
1054 ibss_key = &priv->aes_key;
1055 memset(ibss_key, 0,
1056 sizeof(struct host_cmd_ds_802_11_key_material));
1057
1058 memcpy(ibss_key->key_param_set.key, encrypt_key->key_material,
1059 encrypt_key->key_len);
1060 memcpy(&ibss_key->key_param_set.key_len, &encrypt_key->key_len,
1061 sizeof(ibss_key->key_param_set.key_len));
1062 ibss_key->key_param_set.key_type_id
1063 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1064 ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED);
1065
1066
1067 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
1068 }
1069
1070 if (!encrypt_key->key_index)
1071 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1072
1073 if (remove_key)
1074 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1075 HostCmd_ACT_GEN_SET,
1076 !KEY_INFO_ENABLED, encrypt_key, true);
1077 else
1078 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1079 HostCmd_ACT_GEN_SET,
1080 KEY_INFO_ENABLED, encrypt_key, true);
1081
1082 return ret;
1083}
1084
1085
1086
1087
1088
1089
1090
1091static int
1092mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1093 struct mwifiex_ds_encrypt_key *encrypt_key)
1094{
1095 int status;
1096
1097 if (encrypt_key->is_wapi_key)
1098 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1099 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1100 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1101 else
1102 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1103 return status;
1104}
1105
1106
1107
1108
1109int
1110mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1111 int max_len)
1112{
1113 union {
1114 __le32 l;
1115 u8 c[4];
1116 } ver;
1117 char fw_ver[32];
1118
1119 ver.l = cpu_to_le32(adapter->fw_release_number);
1120 sprintf(fw_ver, "%u.%u.%u.p%u", ver.c[2], ver.c[1], ver.c[0], ver.c[3]);
1121
1122 snprintf(version, max_len, driver_version, fw_ver);
1123
1124 mwifiex_dbg(adapter, MSG, "info: MWIFIEX VERSION: %s\n", version);
1125
1126 return 0;
1127}
1128
1129
1130
1131
1132
1133
1134
1135int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1136 const u8 *key, int key_len, u8 key_index,
1137 const u8 *mac_addr, int disable)
1138{
1139 struct mwifiex_ds_encrypt_key encrypt_key;
1140
1141 memset(&encrypt_key, 0, sizeof(encrypt_key));
1142 encrypt_key.key_len = key_len;
1143 encrypt_key.key_index = key_index;
1144
1145 if (kp && kp->cipher == WLAN_CIPHER_SUITE_AES_CMAC)
1146 encrypt_key.is_igtk_key = true;
1147
1148 if (!disable) {
1149 if (key_len)
1150 memcpy(encrypt_key.key_material, key, key_len);
1151 else
1152 encrypt_key.is_current_wep_key = true;
1153
1154 if (mac_addr)
1155 memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN);
1156 if (kp && kp->seq && kp->seq_len) {
1157 memcpy(encrypt_key.pn, kp->seq, kp->seq_len);
1158 encrypt_key.pn_len = kp->seq_len;
1159 encrypt_key.is_rx_seq_valid = true;
1160 }
1161 } else {
1162 encrypt_key.key_disable = true;
1163 if (mac_addr)
1164 memcpy(encrypt_key.mac_addr, mac_addr, ETH_ALEN);
1165 }
1166
1167 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1168}
1169
1170
1171
1172
1173
1174
1175
1176int
1177mwifiex_get_ver_ext(struct mwifiex_private *priv, u32 version_str_sel)
1178{
1179 struct mwifiex_ver_ext ver_ext;
1180
1181 memset(&ver_ext, 0, sizeof(ver_ext));
1182 ver_ext.version_str_sel = version_str_sel;
1183 if (mwifiex_send_cmd(priv, HostCmd_CMD_VERSION_EXT,
1184 HostCmd_ACT_GEN_GET, 0, &ver_ext, true))
1185 return -1;
1186
1187 return 0;
1188}
1189
1190int
1191mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
1192 struct ieee80211_channel *chan,
1193 unsigned int duration)
1194{
1195 struct host_cmd_ds_remain_on_chan roc_cfg;
1196 u8 sc;
1197
1198 memset(&roc_cfg, 0, sizeof(roc_cfg));
1199 roc_cfg.action = cpu_to_le16(action);
1200 if (action == HostCmd_ACT_GEN_SET) {
1201 roc_cfg.band_cfg = chan->band;
1202 sc = mwifiex_chan_type_to_sec_chan_offset(NL80211_CHAN_NO_HT);
1203 roc_cfg.band_cfg |= (sc << 2);
1204
1205 roc_cfg.channel =
1206 ieee80211_frequency_to_channel(chan->center_freq);
1207 roc_cfg.duration = cpu_to_le32(duration);
1208 }
1209 if (mwifiex_send_cmd(priv, HostCmd_CMD_REMAIN_ON_CHAN,
1210 action, 0, &roc_cfg, true)) {
1211 mwifiex_dbg(priv->adapter, ERROR,
1212 "failed to remain on channel\n");
1213 return -1;
1214 }
1215
1216 return roc_cfg.status;
1217}
1218
1219
1220
1221
1222
1223
1224
1225int
1226mwifiex_get_stats_info(struct mwifiex_private *priv,
1227 struct mwifiex_ds_get_stats *log)
1228{
1229 return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_GET_LOG,
1230 HostCmd_ACT_GEN_GET, 0, log, true);
1231}
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
1247 struct mwifiex_ds_reg_rw *reg_rw,
1248 u16 action)
1249{
1250 u16 cmd_no;
1251
1252 switch (reg_rw->type) {
1253 case MWIFIEX_REG_MAC:
1254 cmd_no = HostCmd_CMD_MAC_REG_ACCESS;
1255 break;
1256 case MWIFIEX_REG_BBP:
1257 cmd_no = HostCmd_CMD_BBP_REG_ACCESS;
1258 break;
1259 case MWIFIEX_REG_RF:
1260 cmd_no = HostCmd_CMD_RF_REG_ACCESS;
1261 break;
1262 case MWIFIEX_REG_PMIC:
1263 cmd_no = HostCmd_CMD_PMIC_REG_ACCESS;
1264 break;
1265 case MWIFIEX_REG_CAU:
1266 cmd_no = HostCmd_CMD_CAU_REG_ACCESS;
1267 break;
1268 default:
1269 return -1;
1270 }
1271
1272 return mwifiex_send_cmd(priv, cmd_no, action, 0, reg_rw, true);
1273}
1274
1275
1276
1277
1278
1279
1280
1281int
1282mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1283 u32 reg_offset, u32 reg_value)
1284{
1285 struct mwifiex_ds_reg_rw reg_rw;
1286
1287 reg_rw.type = reg_type;
1288 reg_rw.offset = reg_offset;
1289 reg_rw.value = reg_value;
1290
1291 return mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_SET);
1292}
1293
1294
1295
1296
1297
1298
1299
1300int
1301mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1302 u32 reg_offset, u32 *value)
1303{
1304 int ret;
1305 struct mwifiex_ds_reg_rw reg_rw;
1306
1307 reg_rw.type = reg_type;
1308 reg_rw.offset = reg_offset;
1309 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, ®_rw, HostCmd_ACT_GEN_GET);
1310
1311 if (ret)
1312 goto done;
1313
1314 *value = reg_rw.value;
1315
1316done:
1317 return ret;
1318}
1319
1320
1321
1322
1323
1324
1325
1326int
1327mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1328 u8 *value)
1329{
1330 int ret;
1331 struct mwifiex_ds_read_eeprom rd_eeprom;
1332
1333 rd_eeprom.offset = offset;
1334 rd_eeprom.byte_count = bytes;
1335
1336
1337 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
1338 HostCmd_ACT_GEN_GET, 0, &rd_eeprom, true);
1339
1340 if (!ret)
1341 memcpy(value, rd_eeprom.value, min((u16)MAX_EEPROM_DATA,
1342 rd_eeprom.byte_count));
1343 return ret;
1344}
1345
1346
1347
1348
1349
1350static int
1351mwifiex_set_gen_ie_helper(struct mwifiex_private *priv, u8 *ie_data_ptr,
1352 u16 ie_len)
1353{
1354 struct ieee_types_vendor_header *pvendor_ie;
1355 const u8 wpa_oui[] = { 0x00, 0x50, 0xf2, 0x01 };
1356 const u8 wps_oui[] = { 0x00, 0x50, 0xf2, 0x04 };
1357 u16 unparsed_len = ie_len, cur_ie_len;
1358
1359
1360 if (!ie_len) {
1361 priv->gen_ie_buf_len = 0;
1362 priv->wps.session_enable = false;
1363 return 0;
1364 } else if (!ie_data_ptr ||
1365 ie_len <= sizeof(struct ieee_types_header)) {
1366 return -1;
1367 }
1368 pvendor_ie = (struct ieee_types_vendor_header *) ie_data_ptr;
1369
1370 while (pvendor_ie) {
1371 cur_ie_len = pvendor_ie->len + sizeof(struct ieee_types_header);
1372
1373 if (pvendor_ie->element_id == WLAN_EID_RSN) {
1374
1375 mwifiex_set_wpa_ie(priv, (u8 *)pvendor_ie, cur_ie_len);
1376 priv->wps.session_enable = false;
1377 goto next_ie;
1378 }
1379
1380 if (pvendor_ie->element_id == WLAN_EID_BSS_AC_ACCESS_DELAY) {
1381
1382 mwifiex_set_wapi_ie(priv, (u8 *)pvendor_ie,
1383 cur_ie_len);
1384 goto next_ie;
1385 }
1386
1387 if (pvendor_ie->element_id == WLAN_EID_VENDOR_SPECIFIC) {
1388
1389
1390
1391 if (!memcmp(pvendor_ie->oui, wpa_oui,
1392 sizeof(wpa_oui))) {
1393
1394
1395 mwifiex_set_wpa_ie(priv, (u8 *)pvendor_ie,
1396 cur_ie_len);
1397 priv->wps.session_enable = false;
1398 goto next_ie;
1399 }
1400
1401 if (!memcmp(pvendor_ie->oui, wps_oui,
1402 sizeof(wps_oui))) {
1403
1404
1405
1406 priv->wps.session_enable = true;
1407 mwifiex_dbg(priv->adapter, MSG,
1408 "WPS Session Enabled.\n");
1409 mwifiex_set_wps_ie(priv, (u8 *)pvendor_ie,
1410 cur_ie_len);
1411 goto next_ie;
1412 }
1413 }
1414
1415
1416
1417
1418
1419
1420 if (cur_ie_len <
1421 (sizeof(priv->gen_ie_buf) - priv->gen_ie_buf_len)) {
1422
1423
1424
1425 memcpy(priv->gen_ie_buf + priv->gen_ie_buf_len,
1426 (u8 *)pvendor_ie, cur_ie_len);
1427
1428
1429
1430 priv->gen_ie_buf_len += cur_ie_len;
1431 }
1432
1433next_ie:
1434 unparsed_len -= cur_ie_len;
1435
1436 if (unparsed_len <= sizeof(struct ieee_types_header))
1437 pvendor_ie = NULL;
1438 else
1439 pvendor_ie = (struct ieee_types_vendor_header *)
1440 (((u8 *)pvendor_ie) + cur_ie_len);
1441 }
1442
1443 return 0;
1444}
1445
1446
1447
1448
1449
1450
1451
1452static int mwifiex_misc_ioctl_gen_ie(struct mwifiex_private *priv,
1453 struct mwifiex_ds_misc_gen_ie *gen_ie,
1454 u16 action)
1455{
1456 struct mwifiex_adapter *adapter = priv->adapter;
1457
1458 switch (gen_ie->type) {
1459 case MWIFIEX_IE_TYPE_GEN_IE:
1460 if (action == HostCmd_ACT_GEN_GET) {
1461 gen_ie->len = priv->wpa_ie_len;
1462 memcpy(gen_ie->ie_data, priv->wpa_ie, gen_ie->len);
1463 } else {
1464 mwifiex_set_gen_ie_helper(priv, gen_ie->ie_data,
1465 (u16) gen_ie->len);
1466 }
1467 break;
1468 case MWIFIEX_IE_TYPE_ARP_FILTER:
1469 memset(adapter->arp_filter, 0, sizeof(adapter->arp_filter));
1470 if (gen_ie->len > ARP_FILTER_MAX_BUF_SIZE) {
1471 adapter->arp_filter_size = 0;
1472 mwifiex_dbg(adapter, ERROR,
1473 "invalid ARP filter size\n");
1474 return -1;
1475 } else {
1476 memcpy(adapter->arp_filter, gen_ie->ie_data,
1477 gen_ie->len);
1478 adapter->arp_filter_size = gen_ie->len;
1479 }
1480 break;
1481 default:
1482 mwifiex_dbg(adapter, ERROR, "invalid IE type\n");
1483 return -1;
1484 }
1485 return 0;
1486}
1487
1488
1489
1490
1491
1492
1493
1494int
1495mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len)
1496{
1497 struct mwifiex_ds_misc_gen_ie gen_ie;
1498
1499 if (ie_len > IEEE_MAX_IE_SIZE)
1500 return -EFAULT;
1501
1502 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
1503 gen_ie.len = ie_len;
1504 memcpy(gen_ie.ie_data, ie, ie_len);
1505 if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET))
1506 return -EFAULT;
1507
1508 return 0;
1509}
1510
1511
1512
1513
1514int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action,
1515 int cmd_type,
1516 struct mwifiex_ds_wakeup_reason *wakeup_reason)
1517{
1518 int status = 0;
1519
1520 status = mwifiex_send_cmd(priv, HostCmd_CMD_HS_WAKEUP_REASON,
1521 HostCmd_ACT_GEN_GET, 0, wakeup_reason,
1522 cmd_type == MWIFIEX_SYNC_CMD);
1523
1524 return status;
1525}
1526