aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/libertas')
-rw-r--r--drivers/net/wireless/libertas/cmd.c37
-rw-r--r--drivers/net/wireless/libertas/cmdresp.c30
-rw-r--r--drivers/net/wireless/libertas/decl.h2
-rw-r--r--drivers/net/wireless/libertas/dev.h6
-rw-r--r--drivers/net/wireless/libertas/ethtool.c24
-rw-r--r--drivers/net/wireless/libertas/host.h120
-rw-r--r--drivers/net/wireless/libertas/if_sdio.c58
-rw-r--r--drivers/net/wireless/libertas/if_usb.c12
-rw-r--r--drivers/net/wireless/libertas/main.c79
-rw-r--r--drivers/net/wireless/libertas/radiotap.h4
-rw-r--r--drivers/net/wireless/libertas/rx.c8
-rw-r--r--drivers/net/wireless/libertas/scan.c2
-rw-r--r--drivers/net/wireless/libertas/types.h66
13 files changed, 276 insertions, 172 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index cdb9b9650d73..0fa6b0e59ea5 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -70,6 +70,8 @@ static u8 is_command_allowed_in_ps(u16 cmd)
70 switch (cmd) { 70 switch (cmd) {
71 case CMD_802_11_RSSI: 71 case CMD_802_11_RSSI:
72 return 1; 72 return 1;
73 case CMD_802_11_HOST_SLEEP_CFG:
74 return 1;
73 default: 75 default:
74 break; 76 break;
75 } 77 }
@@ -185,6 +187,23 @@ out:
185 return ret; 187 return ret;
186} 188}
187 189
190static int lbs_ret_host_sleep_cfg(struct lbs_private *priv, unsigned long dummy,
191 struct cmd_header *resp)
192{
193 lbs_deb_enter(LBS_DEB_CMD);
194 if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
195 priv->is_host_sleep_configured = 0;
196 if (priv->psstate == PS_STATE_FULL_POWER) {
197 priv->is_host_sleep_activated = 0;
198 wake_up_interruptible(&priv->host_sleep_q);
199 }
200 } else {
201 priv->is_host_sleep_configured = 1;
202 }
203 lbs_deb_leave(LBS_DEB_CMD);
204 return 0;
205}
206
188int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria, 207int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
189 struct wol_config *p_wol_config) 208 struct wol_config *p_wol_config)
190{ 209{
@@ -202,12 +221,11 @@ int lbs_host_sleep_cfg(struct lbs_private *priv, uint32_t criteria,
202 else 221 else
203 cmd_config.wol_conf.action = CMD_ACT_ACTION_NONE; 222 cmd_config.wol_conf.action = CMD_ACT_ACTION_NONE;
204 223
205 ret = lbs_cmd_with_response(priv, CMD_802_11_HOST_SLEEP_CFG, &cmd_config); 224 ret = __lbs_cmd(priv, CMD_802_11_HOST_SLEEP_CFG, &cmd_config.hdr,
225 le16_to_cpu(cmd_config.hdr.size),
226 lbs_ret_host_sleep_cfg, 0);
206 if (!ret) { 227 if (!ret) {
207 if (criteria) { 228 if (p_wol_config)
208 lbs_deb_cmd("Set WOL criteria to %x\n", criteria);
209 priv->wol_criteria = criteria;
210 } else
211 memcpy((uint8_t *) p_wol_config, 229 memcpy((uint8_t *) p_wol_config,
212 (uint8_t *)&cmd_config.wol_conf, 230 (uint8_t *)&cmd_config.wol_conf,
213 sizeof(struct wol_config)); 231 sizeof(struct wol_config));
@@ -712,6 +730,10 @@ static void lbs_queue_cmd(struct lbs_private *priv,
712 } 730 }
713 } 731 }
714 732
733 if (le16_to_cpu(cmdnode->cmdbuf->command) ==
734 CMD_802_11_WAKEUP_CONFIRM)
735 addtail = 0;
736
715 spin_lock_irqsave(&priv->driver_lock, flags); 737 spin_lock_irqsave(&priv->driver_lock, flags);
716 738
717 if (addtail) 739 if (addtail)
@@ -1353,6 +1375,11 @@ static void lbs_send_confirmsleep(struct lbs_private *priv)
1353 /* We don't get a response on the sleep-confirmation */ 1375 /* We don't get a response on the sleep-confirmation */
1354 priv->dnld_sent = DNLD_RES_RECEIVED; 1376 priv->dnld_sent = DNLD_RES_RECEIVED;
1355 1377
1378 if (priv->is_host_sleep_configured) {
1379 priv->is_host_sleep_activated = 1;
1380 wake_up_interruptible(&priv->host_sleep_q);
1381 }
1382
1356 /* If nothing to do, go back to sleep (?) */ 1383 /* If nothing to do, go back to sleep (?) */
1357 if (!kfifo_len(&priv->event_fifo) && !priv->resp_len[priv->resp_idx]) 1384 if (!kfifo_len(&priv->event_fifo) && !priv->resp_len[priv->resp_idx])
1358 priv->psstate = PS_STATE_SLEEP; 1385 priv->psstate = PS_STATE_SLEEP;
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c
index 88f7131d66e9..d6c306353640 100644
--- a/drivers/net/wireless/libertas/cmdresp.c
+++ b/drivers/net/wireless/libertas/cmdresp.c
@@ -17,6 +17,7 @@
17#include "dev.h" 17#include "dev.h"
18#include "assoc.h" 18#include "assoc.h"
19#include "wext.h" 19#include "wext.h"
20#include "cmd.h"
20 21
21/** 22/**
22 * @brief This function handles disconnect event. it 23 * @brief This function handles disconnect event. it
@@ -341,32 +342,10 @@ done:
341 return ret; 342 return ret;
342} 343}
343 344
344static int lbs_send_confirmwake(struct lbs_private *priv)
345{
346 struct cmd_header cmd;
347 int ret = 0;
348
349 lbs_deb_enter(LBS_DEB_HOST);
350
351 cmd.command = cpu_to_le16(CMD_802_11_WAKEUP_CONFIRM);
352 cmd.size = cpu_to_le16(sizeof(cmd));
353 cmd.seqnum = cpu_to_le16(++priv->seqnum);
354 cmd.result = 0;
355
356 lbs_deb_hex(LBS_DEB_HOST, "wake confirm", (u8 *) &cmd,
357 sizeof(cmd));
358
359 ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) &cmd, sizeof(cmd));
360 if (ret)
361 lbs_pr_alert("SEND_WAKEC_CMD: Host to Card failed for Confirm Wake\n");
362
363 lbs_deb_leave_args(LBS_DEB_HOST, "ret %d", ret);
364 return ret;
365}
366
367int lbs_process_event(struct lbs_private *priv, u32 event) 345int lbs_process_event(struct lbs_private *priv, u32 event)
368{ 346{
369 int ret = 0; 347 int ret = 0;
348 struct cmd_header cmd;
370 349
371 lbs_deb_enter(LBS_DEB_CMD); 350 lbs_deb_enter(LBS_DEB_CMD);
372 351
@@ -410,7 +389,10 @@ int lbs_process_event(struct lbs_private *priv, u32 event)
410 if (priv->reset_deep_sleep_wakeup) 389 if (priv->reset_deep_sleep_wakeup)
411 priv->reset_deep_sleep_wakeup(priv); 390 priv->reset_deep_sleep_wakeup(priv);
412 priv->is_deep_sleep = 0; 391 priv->is_deep_sleep = 0;
413 lbs_send_confirmwake(priv); 392 lbs_cmd_async(priv, CMD_802_11_WAKEUP_CONFIRM, &cmd,
393 sizeof(cmd));
394 priv->is_host_sleep_activated = 0;
395 wake_up_interruptible(&priv->host_sleep_q);
414 break; 396 break;
415 397
416 case MACREG_INT_CODE_DEEP_SLEEP_AWAKE: 398 case MACREG_INT_CODE_DEEP_SLEEP_AWAKE:
diff --git a/drivers/net/wireless/libertas/decl.h b/drivers/net/wireless/libertas/decl.h
index 709ffcad22ad..61db8bc62b3c 100644
--- a/drivers/net/wireless/libertas/decl.h
+++ b/drivers/net/wireless/libertas/decl.h
@@ -38,7 +38,7 @@ int lbs_set_mac_address(struct net_device *dev, void *addr);
38void lbs_set_multicast_list(struct net_device *dev); 38void lbs_set_multicast_list(struct net_device *dev);
39 39
40int lbs_suspend(struct lbs_private *priv); 40int lbs_suspend(struct lbs_private *priv);
41void lbs_resume(struct lbs_private *priv); 41int lbs_resume(struct lbs_private *priv);
42 42
43void lbs_queue_event(struct lbs_private *priv, u32 event); 43void lbs_queue_event(struct lbs_private *priv, u32 event);
44void lbs_notify_command_response(struct lbs_private *priv, u8 resp_idx); 44void lbs_notify_command_response(struct lbs_private *priv, u8 resp_idx);
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h
index a54880e4ad2b..71c5ad46ebf6 100644
--- a/drivers/net/wireless/libertas/dev.h
+++ b/drivers/net/wireless/libertas/dev.h
@@ -75,6 +75,7 @@ struct lbs_private {
75 75
76 /* Deep sleep */ 76 /* Deep sleep */
77 int is_deep_sleep; 77 int is_deep_sleep;
78 int deep_sleep_required;
78 int is_auto_deep_sleep_enabled; 79 int is_auto_deep_sleep_enabled;
79 int wakeup_dev_required; 80 int wakeup_dev_required;
80 int is_activity_detected; 81 int is_activity_detected;
@@ -82,6 +83,11 @@ struct lbs_private {
82 wait_queue_head_t ds_awake_q; 83 wait_queue_head_t ds_awake_q;
83 struct timer_list auto_deepsleep_timer; 84 struct timer_list auto_deepsleep_timer;
84 85
86 /* Host sleep*/
87 int is_host_sleep_configured;
88 int is_host_sleep_activated;
89 wait_queue_head_t host_sleep_q;
90
85 /* Hardware access */ 91 /* Hardware access */
86 void *card; 92 void *card;
87 u8 fw_ready; 93 u8 fw_ready;
diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c
index 3804a58d7f4e..0cf31bbf6567 100644
--- a/drivers/net/wireless/libertas/ethtool.c
+++ b/drivers/net/wireless/libertas/ethtool.c
@@ -69,14 +69,11 @@ static void lbs_ethtool_get_wol(struct net_device *dev,
69{ 69{
70 struct lbs_private *priv = dev->ml_priv; 70 struct lbs_private *priv = dev->ml_priv;
71 71
72 if (priv->wol_criteria == 0xffffffff) {
73 /* Interface driver didn't configure wake */
74 wol->supported = wol->wolopts = 0;
75 return;
76 }
77
78 wol->supported = WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY; 72 wol->supported = WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY;
79 73
74 if (priv->wol_criteria == EHS_REMOVE_WAKEUP)
75 return;
76
80 if (priv->wol_criteria & EHS_WAKE_ON_UNICAST_DATA) 77 if (priv->wol_criteria & EHS_WAKE_ON_UNICAST_DATA)
81 wol->wolopts |= WAKE_UCAST; 78 wol->wolopts |= WAKE_UCAST;
82 if (priv->wol_criteria & EHS_WAKE_ON_MULTICAST_DATA) 79 if (priv->wol_criteria & EHS_WAKE_ON_MULTICAST_DATA)
@@ -91,23 +88,22 @@ static int lbs_ethtool_set_wol(struct net_device *dev,
91 struct ethtool_wolinfo *wol) 88 struct ethtool_wolinfo *wol)
92{ 89{
93 struct lbs_private *priv = dev->ml_priv; 90 struct lbs_private *priv = dev->ml_priv;
94 uint32_t criteria = 0;
95 91
96 if (wol->wolopts & ~(WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY)) 92 if (wol->wolopts & ~(WAKE_UCAST|WAKE_MCAST|WAKE_BCAST|WAKE_PHY))
97 return -EOPNOTSUPP; 93 return -EOPNOTSUPP;
98 94
95 priv->wol_criteria = 0;
99 if (wol->wolopts & WAKE_UCAST) 96 if (wol->wolopts & WAKE_UCAST)
100 criteria |= EHS_WAKE_ON_UNICAST_DATA; 97 priv->wol_criteria |= EHS_WAKE_ON_UNICAST_DATA;
101 if (wol->wolopts & WAKE_MCAST) 98 if (wol->wolopts & WAKE_MCAST)
102 criteria |= EHS_WAKE_ON_MULTICAST_DATA; 99 priv->wol_criteria |= EHS_WAKE_ON_MULTICAST_DATA;
103 if (wol->wolopts & WAKE_BCAST) 100 if (wol->wolopts & WAKE_BCAST)
104 criteria |= EHS_WAKE_ON_BROADCAST_DATA; 101 priv->wol_criteria |= EHS_WAKE_ON_BROADCAST_DATA;
105 if (wol->wolopts & WAKE_PHY) 102 if (wol->wolopts & WAKE_PHY)
106 criteria |= EHS_WAKE_ON_MAC_EVENT; 103 priv->wol_criteria |= EHS_WAKE_ON_MAC_EVENT;
107 if (wol->wolopts == 0) 104 if (wol->wolopts == 0)
108 criteria |= EHS_REMOVE_WAKEUP; 105 priv->wol_criteria |= EHS_REMOVE_WAKEUP;
109 106 return 0;
110 return lbs_host_sleep_cfg(priv, criteria, (struct wol_config *)NULL);
111} 107}
112 108
113const struct ethtool_ops lbs_ethtool_ops = { 109const struct ethtool_ops lbs_ethtool_ops = {
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h
index 3809c0b49464..3bd5d3b6037a 100644
--- a/drivers/net/wireless/libertas/host.h
+++ b/drivers/net/wireless/libertas/host.h
@@ -326,7 +326,7 @@ struct txpd {
326 u8 pktdelay_2ms; 326 u8 pktdelay_2ms;
327 /* reserved */ 327 /* reserved */
328 u8 reserved1; 328 u8 reserved1;
329} __attribute__ ((packed)); 329} __packed;
330 330
331/* RxPD Descriptor */ 331/* RxPD Descriptor */
332struct rxpd { 332struct rxpd {
@@ -339,8 +339,8 @@ struct rxpd {
339 u8 bss_type; 339 u8 bss_type;
340 /* BSS number */ 340 /* BSS number */
341 u8 bss_num; 341 u8 bss_num;
342 } __attribute__ ((packed)) bss; 342 } __packed bss;
343 } __attribute__ ((packed)) u; 343 } __packed u;
344 344
345 /* SNR */ 345 /* SNR */
346 u8 snr; 346 u8 snr;
@@ -366,14 +366,14 @@ struct rxpd {
366 /* Pkt Priority */ 366 /* Pkt Priority */
367 u8 priority; 367 u8 priority;
368 u8 reserved[3]; 368 u8 reserved[3];
369} __attribute__ ((packed)); 369} __packed;
370 370
371struct cmd_header { 371struct cmd_header {
372 __le16 command; 372 __le16 command;
373 __le16 size; 373 __le16 size;
374 __le16 seqnum; 374 __le16 seqnum;
375 __le16 result; 375 __le16 result;
376} __attribute__ ((packed)); 376} __packed;
377 377
378/* Generic structure to hold all key types. */ 378/* Generic structure to hold all key types. */
379struct enc_key { 379struct enc_key {
@@ -387,7 +387,7 @@ struct enc_key {
387struct lbs_offset_value { 387struct lbs_offset_value {
388 u32 offset; 388 u32 offset;
389 u32 value; 389 u32 value;
390} __attribute__ ((packed)); 390} __packed;
391 391
392/* 392/*
393 * Define data structure for CMD_GET_HW_SPEC 393 * Define data structure for CMD_GET_HW_SPEC
@@ -426,7 +426,7 @@ struct cmd_ds_get_hw_spec {
426 426
427 /*FW/HW capability */ 427 /*FW/HW capability */
428 __le32 fwcapinfo; 428 __le32 fwcapinfo;
429} __attribute__ ((packed)); 429} __packed;
430 430
431struct cmd_ds_802_11_subscribe_event { 431struct cmd_ds_802_11_subscribe_event {
432 struct cmd_header hdr; 432 struct cmd_header hdr;
@@ -440,7 +440,7 @@ struct cmd_ds_802_11_subscribe_event {
440 * bump this up a bit. 440 * bump this up a bit.
441 */ 441 */
442 uint8_t tlv[128]; 442 uint8_t tlv[128];
443} __attribute__ ((packed)); 443} __packed;
444 444
445/* 445/*
446 * This scan handle Country Information IE(802.11d compliant) 446 * This scan handle Country Information IE(802.11d compliant)
@@ -452,7 +452,7 @@ struct cmd_ds_802_11_scan {
452 uint8_t bsstype; 452 uint8_t bsstype;
453 uint8_t bssid[ETH_ALEN]; 453 uint8_t bssid[ETH_ALEN];
454 uint8_t tlvbuffer[0]; 454 uint8_t tlvbuffer[0];
455} __attribute__ ((packed)); 455} __packed;
456 456
457struct cmd_ds_802_11_scan_rsp { 457struct cmd_ds_802_11_scan_rsp {
458 struct cmd_header hdr; 458 struct cmd_header hdr;
@@ -460,7 +460,7 @@ struct cmd_ds_802_11_scan_rsp {
460 __le16 bssdescriptsize; 460 __le16 bssdescriptsize;
461 uint8_t nr_sets; 461 uint8_t nr_sets;
462 uint8_t bssdesc_and_tlvbuffer[0]; 462 uint8_t bssdesc_and_tlvbuffer[0];
463} __attribute__ ((packed)); 463} __packed;
464 464
465struct cmd_ds_802_11_get_log { 465struct cmd_ds_802_11_get_log {
466 struct cmd_header hdr; 466 struct cmd_header hdr;
@@ -478,20 +478,20 @@ struct cmd_ds_802_11_get_log {
478 __le32 fcserror; 478 __le32 fcserror;
479 __le32 txframe; 479 __le32 txframe;
480 __le32 wepundecryptable; 480 __le32 wepundecryptable;
481} __attribute__ ((packed)); 481} __packed;
482 482
483struct cmd_ds_mac_control { 483struct cmd_ds_mac_control {
484 struct cmd_header hdr; 484 struct cmd_header hdr;
485 __le16 action; 485 __le16 action;
486 u16 reserved; 486 u16 reserved;
487} __attribute__ ((packed)); 487} __packed;
488 488
489struct cmd_ds_mac_multicast_adr { 489struct cmd_ds_mac_multicast_adr {
490 struct cmd_header hdr; 490 struct cmd_header hdr;
491 __le16 action; 491 __le16 action;
492 __le16 nr_of_adrs; 492 __le16 nr_of_adrs;
493 u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE]; 493 u8 maclist[ETH_ALEN * MRVDRV_MAX_MULTICAST_LIST_SIZE];
494} __attribute__ ((packed)); 494} __packed;
495 495
496struct cmd_ds_802_11_authenticate { 496struct cmd_ds_802_11_authenticate {
497 struct cmd_header hdr; 497 struct cmd_header hdr;
@@ -499,14 +499,14 @@ struct cmd_ds_802_11_authenticate {
499 u8 bssid[ETH_ALEN]; 499 u8 bssid[ETH_ALEN];
500 u8 authtype; 500 u8 authtype;
501 u8 reserved[10]; 501 u8 reserved[10];
502} __attribute__ ((packed)); 502} __packed;
503 503
504struct cmd_ds_802_11_deauthenticate { 504struct cmd_ds_802_11_deauthenticate {
505 struct cmd_header hdr; 505 struct cmd_header hdr;
506 506
507 u8 macaddr[ETH_ALEN]; 507 u8 macaddr[ETH_ALEN];
508 __le16 reasoncode; 508 __le16 reasoncode;
509} __attribute__ ((packed)); 509} __packed;
510 510
511struct cmd_ds_802_11_associate { 511struct cmd_ds_802_11_associate {
512 struct cmd_header hdr; 512 struct cmd_header hdr;
@@ -517,7 +517,7 @@ struct cmd_ds_802_11_associate {
517 __le16 bcnperiod; 517 __le16 bcnperiod;
518 u8 dtimperiod; 518 u8 dtimperiod;
519 u8 iebuf[512]; /* Enough for required and most optional IEs */ 519 u8 iebuf[512]; /* Enough for required and most optional IEs */
520} __attribute__ ((packed)); 520} __packed;
521 521
522struct cmd_ds_802_11_associate_response { 522struct cmd_ds_802_11_associate_response {
523 struct cmd_header hdr; 523 struct cmd_header hdr;
@@ -526,7 +526,7 @@ struct cmd_ds_802_11_associate_response {
526 __le16 statuscode; 526 __le16 statuscode;
527 __le16 aid; 527 __le16 aid;
528 u8 iebuf[512]; 528 u8 iebuf[512];
529} __attribute__ ((packed)); 529} __packed;
530 530
531struct cmd_ds_802_11_set_wep { 531struct cmd_ds_802_11_set_wep {
532 struct cmd_header hdr; 532 struct cmd_header hdr;
@@ -540,7 +540,7 @@ struct cmd_ds_802_11_set_wep {
540 /* 40, 128bit or TXWEP */ 540 /* 40, 128bit or TXWEP */
541 uint8_t keytype[4]; 541 uint8_t keytype[4];
542 uint8_t keymaterial[4][16]; 542 uint8_t keymaterial[4][16];
543} __attribute__ ((packed)); 543} __packed;
544 544
545struct cmd_ds_802_11_snmp_mib { 545struct cmd_ds_802_11_snmp_mib {
546 struct cmd_header hdr; 546 struct cmd_header hdr;
@@ -549,40 +549,40 @@ struct cmd_ds_802_11_snmp_mib {
549 __le16 oid; 549 __le16 oid;
550 __le16 bufsize; 550 __le16 bufsize;
551 u8 value[128]; 551 u8 value[128];
552} __attribute__ ((packed)); 552} __packed;
553 553
554struct cmd_ds_mac_reg_access { 554struct cmd_ds_mac_reg_access {
555 __le16 action; 555 __le16 action;
556 __le16 offset; 556 __le16 offset;
557 __le32 value; 557 __le32 value;
558} __attribute__ ((packed)); 558} __packed;
559 559
560struct cmd_ds_bbp_reg_access { 560struct cmd_ds_bbp_reg_access {
561 __le16 action; 561 __le16 action;
562 __le16 offset; 562 __le16 offset;
563 u8 value; 563 u8 value;
564 u8 reserved[3]; 564 u8 reserved[3];
565} __attribute__ ((packed)); 565} __packed;
566 566
567struct cmd_ds_rf_reg_access { 567struct cmd_ds_rf_reg_access {
568 __le16 action; 568 __le16 action;
569 __le16 offset; 569 __le16 offset;
570 u8 value; 570 u8 value;
571 u8 reserved[3]; 571 u8 reserved[3];
572} __attribute__ ((packed)); 572} __packed;
573 573
574struct cmd_ds_802_11_radio_control { 574struct cmd_ds_802_11_radio_control {
575 struct cmd_header hdr; 575 struct cmd_header hdr;
576 576
577 __le16 action; 577 __le16 action;
578 __le16 control; 578 __le16 control;
579} __attribute__ ((packed)); 579} __packed;
580 580
581struct cmd_ds_802_11_beacon_control { 581struct cmd_ds_802_11_beacon_control {
582 __le16 action; 582 __le16 action;
583 __le16 beacon_enable; 583 __le16 beacon_enable;
584 __le16 beacon_period; 584 __le16 beacon_period;
585} __attribute__ ((packed)); 585} __packed;
586 586
587struct cmd_ds_802_11_sleep_params { 587struct cmd_ds_802_11_sleep_params {
588 struct cmd_header hdr; 588 struct cmd_header hdr;
@@ -607,7 +607,7 @@ struct cmd_ds_802_11_sleep_params {
607 607
608 /* reserved field, should be set to zero */ 608 /* reserved field, should be set to zero */
609 __le16 reserved; 609 __le16 reserved;
610} __attribute__ ((packed)); 610} __packed;
611 611
612struct cmd_ds_802_11_rf_channel { 612struct cmd_ds_802_11_rf_channel {
613 struct cmd_header hdr; 613 struct cmd_header hdr;
@@ -617,7 +617,7 @@ struct cmd_ds_802_11_rf_channel {
617 __le16 rftype; /* unused */ 617 __le16 rftype; /* unused */
618 __le16 reserved; /* unused */ 618 __le16 reserved; /* unused */
619 u8 channellist[32]; /* unused */ 619 u8 channellist[32]; /* unused */
620} __attribute__ ((packed)); 620} __packed;
621 621
622struct cmd_ds_802_11_rssi { 622struct cmd_ds_802_11_rssi {
623 /* weighting factor */ 623 /* weighting factor */
@@ -626,21 +626,21 @@ struct cmd_ds_802_11_rssi {
626 __le16 reserved_0; 626 __le16 reserved_0;
627 __le16 reserved_1; 627 __le16 reserved_1;
628 __le16 reserved_2; 628 __le16 reserved_2;
629} __attribute__ ((packed)); 629} __packed;
630 630
631struct cmd_ds_802_11_rssi_rsp { 631struct cmd_ds_802_11_rssi_rsp {
632 __le16 SNR; 632 __le16 SNR;
633 __le16 noisefloor; 633 __le16 noisefloor;
634 __le16 avgSNR; 634 __le16 avgSNR;
635 __le16 avgnoisefloor; 635 __le16 avgnoisefloor;
636} __attribute__ ((packed)); 636} __packed;
637 637
638struct cmd_ds_802_11_mac_address { 638struct cmd_ds_802_11_mac_address {
639 struct cmd_header hdr; 639 struct cmd_header hdr;
640 640
641 __le16 action; 641 __le16 action;
642 u8 macadd[ETH_ALEN]; 642 u8 macadd[ETH_ALEN];
643} __attribute__ ((packed)); 643} __packed;
644 644
645struct cmd_ds_802_11_rf_tx_power { 645struct cmd_ds_802_11_rf_tx_power {
646 struct cmd_header hdr; 646 struct cmd_header hdr;
@@ -649,26 +649,26 @@ struct cmd_ds_802_11_rf_tx_power {
649 __le16 curlevel; 649 __le16 curlevel;
650 s8 maxlevel; 650 s8 maxlevel;
651 s8 minlevel; 651 s8 minlevel;
652} __attribute__ ((packed)); 652} __packed;
653 653
654struct cmd_ds_802_11_monitor_mode { 654struct cmd_ds_802_11_monitor_mode {
655 __le16 action; 655 __le16 action;
656 __le16 mode; 656 __le16 mode;
657} __attribute__ ((packed)); 657} __packed;
658 658
659struct cmd_ds_set_boot2_ver { 659struct cmd_ds_set_boot2_ver {
660 struct cmd_header hdr; 660 struct cmd_header hdr;
661 661
662 __le16 action; 662 __le16 action;
663 __le16 version; 663 __le16 version;
664} __attribute__ ((packed)); 664} __packed;
665 665
666struct cmd_ds_802_11_fw_wake_method { 666struct cmd_ds_802_11_fw_wake_method {
667 struct cmd_header hdr; 667 struct cmd_header hdr;
668 668
669 __le16 action; 669 __le16 action;
670 __le16 method; 670 __le16 method;
671} __attribute__ ((packed)); 671} __packed;
672 672
673struct cmd_ds_802_11_ps_mode { 673struct cmd_ds_802_11_ps_mode {
674 __le16 action; 674 __le16 action;
@@ -676,7 +676,7 @@ struct cmd_ds_802_11_ps_mode {
676 __le16 multipledtim; 676 __le16 multipledtim;
677 __le16 reserved; 677 __le16 reserved;
678 __le16 locallisteninterval; 678 __le16 locallisteninterval;
679} __attribute__ ((packed)); 679} __packed;
680 680
681struct cmd_confirm_sleep { 681struct cmd_confirm_sleep {
682 struct cmd_header hdr; 682 struct cmd_header hdr;
@@ -686,7 +686,7 @@ struct cmd_confirm_sleep {
686 __le16 multipledtim; 686 __le16 multipledtim;
687 __le16 reserved; 687 __le16 reserved;
688 __le16 locallisteninterval; 688 __le16 locallisteninterval;
689} __attribute__ ((packed)); 689} __packed;
690 690
691struct cmd_ds_802_11_data_rate { 691struct cmd_ds_802_11_data_rate {
692 struct cmd_header hdr; 692 struct cmd_header hdr;
@@ -694,14 +694,14 @@ struct cmd_ds_802_11_data_rate {
694 __le16 action; 694 __le16 action;
695 __le16 reserved; 695 __le16 reserved;
696 u8 rates[MAX_RATES]; 696 u8 rates[MAX_RATES];
697} __attribute__ ((packed)); 697} __packed;
698 698
699struct cmd_ds_802_11_rate_adapt_rateset { 699struct cmd_ds_802_11_rate_adapt_rateset {
700 struct cmd_header hdr; 700 struct cmd_header hdr;
701 __le16 action; 701 __le16 action;
702 __le16 enablehwauto; 702 __le16 enablehwauto;
703 __le16 bitmap; 703 __le16 bitmap;
704} __attribute__ ((packed)); 704} __packed;
705 705
706struct cmd_ds_802_11_ad_hoc_start { 706struct cmd_ds_802_11_ad_hoc_start {
707 struct cmd_header hdr; 707 struct cmd_header hdr;
@@ -718,14 +718,14 @@ struct cmd_ds_802_11_ad_hoc_start {
718 __le16 capability; 718 __le16 capability;
719 u8 rates[MAX_RATES]; 719 u8 rates[MAX_RATES];
720 u8 tlv_memory_size_pad[100]; 720 u8 tlv_memory_size_pad[100];
721} __attribute__ ((packed)); 721} __packed;
722 722
723struct cmd_ds_802_11_ad_hoc_result { 723struct cmd_ds_802_11_ad_hoc_result {
724 struct cmd_header hdr; 724 struct cmd_header hdr;
725 725
726 u8 pad[3]; 726 u8 pad[3];
727 u8 bssid[ETH_ALEN]; 727 u8 bssid[ETH_ALEN];
728} __attribute__ ((packed)); 728} __packed;
729 729
730struct adhoc_bssdesc { 730struct adhoc_bssdesc {
731 u8 bssid[ETH_ALEN]; 731 u8 bssid[ETH_ALEN];
@@ -746,7 +746,7 @@ struct adhoc_bssdesc {
746 * Adhoc join command and will cause a binary layout mismatch with 746 * Adhoc join command and will cause a binary layout mismatch with
747 * the firmware 747 * the firmware
748 */ 748 */
749} __attribute__ ((packed)); 749} __packed;
750 750
751struct cmd_ds_802_11_ad_hoc_join { 751struct cmd_ds_802_11_ad_hoc_join {
752 struct cmd_header hdr; 752 struct cmd_header hdr;
@@ -754,18 +754,18 @@ struct cmd_ds_802_11_ad_hoc_join {
754 struct adhoc_bssdesc bss; 754 struct adhoc_bssdesc bss;
755 __le16 failtimeout; /* Reserved on v9 and later */ 755 __le16 failtimeout; /* Reserved on v9 and later */
756 __le16 probedelay; /* Reserved on v9 and later */ 756 __le16 probedelay; /* Reserved on v9 and later */
757} __attribute__ ((packed)); 757} __packed;
758 758
759struct cmd_ds_802_11_ad_hoc_stop { 759struct cmd_ds_802_11_ad_hoc_stop {
760 struct cmd_header hdr; 760 struct cmd_header hdr;
761} __attribute__ ((packed)); 761} __packed;
762 762
763struct cmd_ds_802_11_enable_rsn { 763struct cmd_ds_802_11_enable_rsn {
764 struct cmd_header hdr; 764 struct cmd_header hdr;
765 765
766 __le16 action; 766 __le16 action;
767 __le16 enable; 767 __le16 enable;
768} __attribute__ ((packed)); 768} __packed;
769 769
770struct MrvlIEtype_keyParamSet { 770struct MrvlIEtype_keyParamSet {
771 /* type ID */ 771 /* type ID */
@@ -785,7 +785,7 @@ struct MrvlIEtype_keyParamSet {
785 785
786 /* key material of size keylen */ 786 /* key material of size keylen */
787 u8 key[32]; 787 u8 key[32];
788} __attribute__ ((packed)); 788} __packed;
789 789
790#define MAX_WOL_RULES 16 790#define MAX_WOL_RULES 16
791 791
@@ -797,7 +797,7 @@ struct host_wol_rule {
797 __le16 reserve; 797 __le16 reserve;
798 __be32 sig_mask; 798 __be32 sig_mask;
799 __be32 signature; 799 __be32 signature;
800} __attribute__ ((packed)); 800} __packed;
801 801
802struct wol_config { 802struct wol_config {
803 uint8_t action; 803 uint8_t action;
@@ -805,7 +805,7 @@ struct wol_config {
805 uint8_t no_rules_in_cmd; 805 uint8_t no_rules_in_cmd;
806 uint8_t result; 806 uint8_t result;
807 struct host_wol_rule rule[MAX_WOL_RULES]; 807 struct host_wol_rule rule[MAX_WOL_RULES];
808} __attribute__ ((packed)); 808} __packed;
809 809
810struct cmd_ds_host_sleep { 810struct cmd_ds_host_sleep {
811 struct cmd_header hdr; 811 struct cmd_header hdr;
@@ -813,7 +813,7 @@ struct cmd_ds_host_sleep {
813 uint8_t gpio; 813 uint8_t gpio;
814 uint16_t gap; 814 uint16_t gap;
815 struct wol_config wol_conf; 815 struct wol_config wol_conf;
816} __attribute__ ((packed)); 816} __packed;
817 817
818 818
819 819
@@ -822,7 +822,7 @@ struct cmd_ds_802_11_key_material {
822 822
823 __le16 action; 823 __le16 action;
824 struct MrvlIEtype_keyParamSet keyParamSet[2]; 824 struct MrvlIEtype_keyParamSet keyParamSet[2];
825} __attribute__ ((packed)); 825} __packed;
826 826
827struct cmd_ds_802_11_eeprom_access { 827struct cmd_ds_802_11_eeprom_access {
828 struct cmd_header hdr; 828 struct cmd_header hdr;
@@ -832,7 +832,7 @@ struct cmd_ds_802_11_eeprom_access {
832 /* firmware says it returns a maximum of 20 bytes */ 832 /* firmware says it returns a maximum of 20 bytes */
833#define LBS_EEPROM_READ_LEN 20 833#define LBS_EEPROM_READ_LEN 20
834 u8 value[LBS_EEPROM_READ_LEN]; 834 u8 value[LBS_EEPROM_READ_LEN];
835} __attribute__ ((packed)); 835} __packed;
836 836
837struct cmd_ds_802_11_tpc_cfg { 837struct cmd_ds_802_11_tpc_cfg {
838 struct cmd_header hdr; 838 struct cmd_header hdr;
@@ -843,7 +843,7 @@ struct cmd_ds_802_11_tpc_cfg {
843 int8_t P1; 843 int8_t P1;
844 int8_t P2; 844 int8_t P2;
845 uint8_t usesnr; 845 uint8_t usesnr;
846} __attribute__ ((packed)); 846} __packed;
847 847
848 848
849struct cmd_ds_802_11_pa_cfg { 849struct cmd_ds_802_11_pa_cfg {
@@ -854,14 +854,14 @@ struct cmd_ds_802_11_pa_cfg {
854 int8_t P0; 854 int8_t P0;
855 int8_t P1; 855 int8_t P1;
856 int8_t P2; 856 int8_t P2;
857} __attribute__ ((packed)); 857} __packed;
858 858
859 859
860struct cmd_ds_802_11_led_ctrl { 860struct cmd_ds_802_11_led_ctrl {
861 __le16 action; 861 __le16 action;
862 __le16 numled; 862 __le16 numled;
863 u8 data[256]; 863 u8 data[256];
864} __attribute__ ((packed)); 864} __packed;
865 865
866struct cmd_ds_802_11_afc { 866struct cmd_ds_802_11_afc {
867 __le16 afc_auto; 867 __le16 afc_auto;
@@ -875,22 +875,22 @@ struct cmd_ds_802_11_afc {
875 __le16 carrier_offset; /* signed */ 875 __le16 carrier_offset; /* signed */
876 }; 876 };
877 }; 877 };
878} __attribute__ ((packed)); 878} __packed;
879 879
880struct cmd_tx_rate_query { 880struct cmd_tx_rate_query {
881 __le16 txrate; 881 __le16 txrate;
882} __attribute__ ((packed)); 882} __packed;
883 883
884struct cmd_ds_get_tsf { 884struct cmd_ds_get_tsf {
885 __le64 tsfvalue; 885 __le64 tsfvalue;
886} __attribute__ ((packed)); 886} __packed;
887 887
888struct cmd_ds_bt_access { 888struct cmd_ds_bt_access {
889 __le16 action; 889 __le16 action;
890 __le32 id; 890 __le32 id;
891 u8 addr1[ETH_ALEN]; 891 u8 addr1[ETH_ALEN];
892 u8 addr2[ETH_ALEN]; 892 u8 addr2[ETH_ALEN];
893} __attribute__ ((packed)); 893} __packed;
894 894
895struct cmd_ds_fwt_access { 895struct cmd_ds_fwt_access {
896 __le16 action; 896 __le16 action;
@@ -910,7 +910,7 @@ struct cmd_ds_fwt_access {
910 __le32 snr; 910 __le32 snr;
911 __le32 references; 911 __le32 references;
912 u8 prec[ETH_ALEN]; 912 u8 prec[ETH_ALEN];
913} __attribute__ ((packed)); 913} __packed;
914 914
915struct cmd_ds_mesh_config { 915struct cmd_ds_mesh_config {
916 struct cmd_header hdr; 916 struct cmd_header hdr;
@@ -920,14 +920,14 @@ struct cmd_ds_mesh_config {
920 __le16 type; 920 __le16 type;
921 __le16 length; 921 __le16 length;
922 u8 data[128]; /* last position reserved */ 922 u8 data[128]; /* last position reserved */
923} __attribute__ ((packed)); 923} __packed;
924 924
925struct cmd_ds_mesh_access { 925struct cmd_ds_mesh_access {
926 struct cmd_header hdr; 926 struct cmd_header hdr;
927 927
928 __le16 action; 928 __le16 action;
929 __le32 data[32]; /* last position reserved */ 929 __le32 data[32]; /* last position reserved */
930} __attribute__ ((packed)); 930} __packed;
931 931
932/* Number of stats counters returned by the firmware */ 932/* Number of stats counters returned by the firmware */
933#define MESH_STATS_NUM 8 933#define MESH_STATS_NUM 8
@@ -957,6 +957,6 @@ struct cmd_ds_command {
957 struct cmd_ds_fwt_access fwt; 957 struct cmd_ds_fwt_access fwt;
958 struct cmd_ds_802_11_beacon_control bcn_ctrl; 958 struct cmd_ds_802_11_beacon_control bcn_ctrl;
959 } params; 959 } params;
960} __attribute__ ((packed)); 960} __packed;
961 961
962#endif 962#endif
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
index 64dd345d30f5..6e71346a7550 100644
--- a/drivers/net/wireless/libertas/if_sdio.c
+++ b/drivers/net/wireless/libertas/if_sdio.c
@@ -1182,11 +1182,69 @@ static void if_sdio_remove(struct sdio_func *func)
1182 lbs_deb_leave(LBS_DEB_SDIO); 1182 lbs_deb_leave(LBS_DEB_SDIO);
1183} 1183}
1184 1184
1185static int if_sdio_suspend(struct device *dev)
1186{
1187 struct sdio_func *func = dev_to_sdio_func(dev);
1188 int ret;
1189 struct if_sdio_card *card = sdio_get_drvdata(func);
1190
1191 mmc_pm_flag_t flags = sdio_get_host_pm_caps(func);
1192
1193 lbs_pr_info("%s: suspend: PM flags = 0x%x\n",
1194 sdio_func_id(func), flags);
1195
1196 /* If we aren't being asked to wake on anything, we should bail out
1197 * and let the SD stack power down the card.
1198 */
1199 if (card->priv->wol_criteria == EHS_REMOVE_WAKEUP) {
1200 lbs_pr_info("Suspend without wake params -- "
1201 "powering down card.");
1202 return -ENOSYS;
1203 }
1204
1205 if (!(flags & MMC_PM_KEEP_POWER)) {
1206 lbs_pr_err("%s: cannot remain alive while host is suspended\n",
1207 sdio_func_id(func));
1208 return -ENOSYS;
1209 }
1210
1211 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
1212 if (ret)
1213 return ret;
1214
1215 ret = lbs_suspend(card->priv);
1216 if (ret)
1217 return ret;
1218
1219 return sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ);
1220}
1221
1222static int if_sdio_resume(struct device *dev)
1223{
1224 struct sdio_func *func = dev_to_sdio_func(dev);
1225 struct if_sdio_card *card = sdio_get_drvdata(func);
1226 int ret;
1227
1228 lbs_pr_info("%s: resume: we're back\n", sdio_func_id(func));
1229
1230 ret = lbs_resume(card->priv);
1231
1232 return ret;
1233}
1234
1235static const struct dev_pm_ops if_sdio_pm_ops = {
1236 .suspend = if_sdio_suspend,
1237 .resume = if_sdio_resume,
1238};
1239
1185static struct sdio_driver if_sdio_driver = { 1240static struct sdio_driver if_sdio_driver = {
1186 .name = "libertas_sdio", 1241 .name = "libertas_sdio",
1187 .id_table = if_sdio_ids, 1242 .id_table = if_sdio_ids,
1188 .probe = if_sdio_probe, 1243 .probe = if_sdio_probe,
1189 .remove = if_sdio_remove, 1244 .remove = if_sdio_remove,
1245 .drv = {
1246 .pm = &if_sdio_pm_ops,
1247 },
1190}; 1248};
1191 1249
1192/*******************************************************************/ 1250/*******************************************************************/
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
index f41594c7ac16..3678e532874f 100644
--- a/drivers/net/wireless/libertas/if_usb.c
+++ b/drivers/net/wireless/libertas/if_usb.c
@@ -613,16 +613,14 @@ static void if_usb_receive_fwload(struct urb *urb)
613 return; 613 return;
614 } 614 }
615 615
616 syncfwheader = kmalloc(sizeof(struct fwsyncheader), GFP_ATOMIC); 616 syncfwheader = kmemdup(skb->data + IPFIELD_ALIGN_OFFSET,
617 sizeof(struct fwsyncheader), GFP_ATOMIC);
617 if (!syncfwheader) { 618 if (!syncfwheader) {
618 lbs_deb_usbd(&cardp->udev->dev, "Failure to allocate syncfwheader\n"); 619 lbs_deb_usbd(&cardp->udev->dev, "Failure to allocate syncfwheader\n");
619 kfree_skb(skb); 620 kfree_skb(skb);
620 return; 621 return;
621 } 622 }
622 623
623 memcpy(syncfwheader, skb->data + IPFIELD_ALIGN_OFFSET,
624 sizeof(struct fwsyncheader));
625
626 if (!syncfwheader->cmd) { 624 if (!syncfwheader->cmd) {
627 lbs_deb_usb2(&cardp->udev->dev, "FW received Blk with correct CRC\n"); 625 lbs_deb_usb2(&cardp->udev->dev, "FW received Blk with correct CRC\n");
628 lbs_deb_usb2(&cardp->udev->dev, "FW received Blk seqnum = %d\n", 626 lbs_deb_usb2(&cardp->udev->dev, "FW received Blk seqnum = %d\n",
@@ -1043,6 +1041,12 @@ static int if_usb_suspend(struct usb_interface *intf, pm_message_t message)
1043 if (priv->psstate != PS_STATE_FULL_POWER) 1041 if (priv->psstate != PS_STATE_FULL_POWER)
1044 return -1; 1042 return -1;
1045 1043
1044 if (priv->wol_criteria == EHS_REMOVE_WAKEUP) {
1045 lbs_pr_info("Suspend attempt without "
1046 "configuring wake params!\n");
1047 return -ENOSYS;
1048 }
1049
1046 ret = lbs_suspend(priv); 1050 ret = lbs_suspend(priv);
1047 if (ret) 1051 if (ret)
1048 goto out; 1052 goto out;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index d9b8ee130c45..abfecc4814b4 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -625,16 +625,13 @@ static int lbs_thread(void *data)
625 return 0; 625 return 0;
626} 626}
627 627
628static int lbs_suspend_callback(struct lbs_private *priv, unsigned long dummy, 628static int lbs_ret_host_sleep_activate(struct lbs_private *priv,
629 struct cmd_header *cmd) 629 unsigned long dummy,
630 struct cmd_header *cmd)
630{ 631{
631 lbs_deb_enter(LBS_DEB_FW); 632 lbs_deb_enter(LBS_DEB_FW);
632 633 priv->is_host_sleep_activated = 1;
633 netif_device_detach(priv->dev); 634 wake_up_interruptible(&priv->host_sleep_q);
634 if (priv->mesh_dev)
635 netif_device_detach(priv->mesh_dev);
636
637 priv->fw_ready = 0;
638 lbs_deb_leave(LBS_DEB_FW); 635 lbs_deb_leave(LBS_DEB_FW);
639 return 0; 636 return 0;
640} 637}
@@ -646,39 +643,65 @@ int lbs_suspend(struct lbs_private *priv)
646 643
647 lbs_deb_enter(LBS_DEB_FW); 644 lbs_deb_enter(LBS_DEB_FW);
648 645
649 if (priv->wol_criteria == 0xffffffff) { 646 if (priv->is_deep_sleep) {
650 lbs_pr_info("Suspend attempt without configuring wake params!\n"); 647 ret = lbs_set_deep_sleep(priv, 0);
651 return -EINVAL; 648 if (ret) {
649 lbs_pr_err("deep sleep cancellation failed: %d\n", ret);
650 return ret;
651 }
652 priv->deep_sleep_required = 1;
652 } 653 }
653 654
654 memset(&cmd, 0, sizeof(cmd)); 655 memset(&cmd, 0, sizeof(cmd));
656 ret = lbs_host_sleep_cfg(priv, priv->wol_criteria,
657 (struct wol_config *)NULL);
658 if (ret) {
659 lbs_pr_info("Host sleep configuration failed: %d\n", ret);
660 return ret;
661 }
662 if (priv->psstate == PS_STATE_FULL_POWER) {
663 ret = __lbs_cmd(priv, CMD_802_11_HOST_SLEEP_ACTIVATE, &cmd,
664 sizeof(cmd), lbs_ret_host_sleep_activate, 0);
665 if (ret)
666 lbs_pr_info("HOST_SLEEP_ACTIVATE failed: %d\n", ret);
667 }
655 668
656 ret = __lbs_cmd(priv, CMD_802_11_HOST_SLEEP_ACTIVATE, &cmd, 669 if (!wait_event_interruptible_timeout(priv->host_sleep_q,
657 sizeof(cmd), lbs_suspend_callback, 0); 670 priv->is_host_sleep_activated, (10 * HZ))) {
658 if (ret) 671 lbs_pr_err("host_sleep_q: timer expired\n");
659 lbs_pr_info("HOST_SLEEP_ACTIVATE failed: %d\n", ret); 672 ret = -1;
673 }
674 netif_device_detach(priv->dev);
675 if (priv->mesh_dev)
676 netif_device_detach(priv->mesh_dev);
660 677
661 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); 678 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
662 return ret; 679 return ret;
663} 680}
664EXPORT_SYMBOL_GPL(lbs_suspend); 681EXPORT_SYMBOL_GPL(lbs_suspend);
665 682
666void lbs_resume(struct lbs_private *priv) 683int lbs_resume(struct lbs_private *priv)
667{ 684{
668 lbs_deb_enter(LBS_DEB_FW); 685 int ret;
686 uint32_t criteria = EHS_REMOVE_WAKEUP;
669 687
670 priv->fw_ready = 1; 688 lbs_deb_enter(LBS_DEB_FW);
671 689
672 /* Firmware doesn't seem to give us RX packets any more 690 ret = lbs_host_sleep_cfg(priv, criteria, (struct wol_config *)NULL);
673 until we send it some command. Might as well update */
674 lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0,
675 0, 0, NULL);
676 691
677 netif_device_attach(priv->dev); 692 netif_device_attach(priv->dev);
678 if (priv->mesh_dev) 693 if (priv->mesh_dev)
679 netif_device_attach(priv->mesh_dev); 694 netif_device_attach(priv->mesh_dev);
680 695
681 lbs_deb_leave(LBS_DEB_FW); 696 if (priv->deep_sleep_required) {
697 priv->deep_sleep_required = 0;
698 ret = lbs_set_deep_sleep(priv, 1);
699 if (ret)
700 lbs_pr_err("deep sleep activation failed: %d\n", ret);
701 }
702
703 lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
704 return ret;
682} 705}
683EXPORT_SYMBOL_GPL(lbs_resume); 706EXPORT_SYMBOL_GPL(lbs_resume);
684 707
@@ -834,10 +857,13 @@ static int lbs_init_adapter(struct lbs_private *priv)
834 priv->psstate = PS_STATE_FULL_POWER; 857 priv->psstate = PS_STATE_FULL_POWER;
835 priv->is_deep_sleep = 0; 858 priv->is_deep_sleep = 0;
836 priv->is_auto_deep_sleep_enabled = 0; 859 priv->is_auto_deep_sleep_enabled = 0;
860 priv->deep_sleep_required = 0;
837 priv->wakeup_dev_required = 0; 861 priv->wakeup_dev_required = 0;
838 init_waitqueue_head(&priv->ds_awake_q); 862 init_waitqueue_head(&priv->ds_awake_q);
839 priv->authtype_auto = 1; 863 priv->authtype_auto = 1;
840 864 priv->is_host_sleep_configured = 0;
865 priv->is_host_sleep_activated = 0;
866 init_waitqueue_head(&priv->host_sleep_q);
841 mutex_init(&priv->lock); 867 mutex_init(&priv->lock);
842 868
843 setup_timer(&priv->command_timer, lbs_cmd_timeout_handler, 869 setup_timer(&priv->command_timer, lbs_cmd_timeout_handler,
@@ -976,6 +1002,7 @@ struct lbs_private *lbs_add_card(void *card, struct device *dmdev)
976 1002
977 priv->wol_criteria = 0xffffffff; 1003 priv->wol_criteria = 0xffffffff;
978 priv->wol_gpio = 0xff; 1004 priv->wol_gpio = 0xff;
1005 priv->wol_gap = 20;
979 1006
980 goto done; 1007 goto done;
981 1008
@@ -1031,6 +1058,10 @@ void lbs_remove_card(struct lbs_private *priv)
1031 wake_up_interruptible(&priv->ds_awake_q); 1058 wake_up_interruptible(&priv->ds_awake_q);
1032 } 1059 }
1033 1060
1061 priv->is_host_sleep_configured = 0;
1062 priv->is_host_sleep_activated = 0;
1063 wake_up_interruptible(&priv->host_sleep_q);
1064
1034 /* Stop the thread servicing the interrupts */ 1065 /* Stop the thread servicing the interrupts */
1035 priv->surpriseremoved = 1; 1066 priv->surpriseremoved = 1;
1036 kthread_stop(priv->main_thread); 1067 kthread_stop(priv->main_thread);
diff --git a/drivers/net/wireless/libertas/radiotap.h b/drivers/net/wireless/libertas/radiotap.h
index d16b26416e82..b3c8ea6d610e 100644
--- a/drivers/net/wireless/libertas/radiotap.h
+++ b/drivers/net/wireless/libertas/radiotap.h
@@ -6,7 +6,7 @@ struct tx_radiotap_hdr {
6 u8 txpower; 6 u8 txpower;
7 u8 rts_retries; 7 u8 rts_retries;
8 u8 data_retries; 8 u8 data_retries;
9} __attribute__ ((packed)); 9} __packed;
10 10
11#define TX_RADIOTAP_PRESENT ( \ 11#define TX_RADIOTAP_PRESENT ( \
12 (1 << IEEE80211_RADIOTAP_RATE) | \ 12 (1 << IEEE80211_RADIOTAP_RATE) | \
@@ -34,7 +34,7 @@ struct rx_radiotap_hdr {
34 u8 flags; 34 u8 flags;
35 u8 rate; 35 u8 rate;
36 u8 antsignal; 36 u8 antsignal;
37} __attribute__ ((packed)); 37} __packed;
38 38
39#define RX_RADIOTAP_PRESENT ( \ 39#define RX_RADIOTAP_PRESENT ( \
40 (1 << IEEE80211_RADIOTAP_FLAGS) | \ 40 (1 << IEEE80211_RADIOTAP_FLAGS) | \
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c
index 7a377f5b7662..1c63f8ce7349 100644
--- a/drivers/net/wireless/libertas/rx.c
+++ b/drivers/net/wireless/libertas/rx.c
@@ -15,7 +15,7 @@ struct eth803hdr {
15 u8 dest_addr[6]; 15 u8 dest_addr[6];
16 u8 src_addr[6]; 16 u8 src_addr[6];
17 u16 h803_len; 17 u16 h803_len;
18} __attribute__ ((packed)); 18} __packed;
19 19
20struct rfc1042hdr { 20struct rfc1042hdr {
21 u8 llc_dsap; 21 u8 llc_dsap;
@@ -23,17 +23,17 @@ struct rfc1042hdr {
23 u8 llc_ctrl; 23 u8 llc_ctrl;
24 u8 snap_oui[3]; 24 u8 snap_oui[3];
25 u16 snap_type; 25 u16 snap_type;
26} __attribute__ ((packed)); 26} __packed;
27 27
28struct rxpackethdr { 28struct rxpackethdr {
29 struct eth803hdr eth803_hdr; 29 struct eth803hdr eth803_hdr;
30 struct rfc1042hdr rfc1042_hdr; 30 struct rfc1042hdr rfc1042_hdr;
31} __attribute__ ((packed)); 31} __packed;
32 32
33struct rx80211packethdr { 33struct rx80211packethdr {
34 struct rxpd rx_pd; 34 struct rxpd rx_pd;
35 void *eth80211_hdr; 35 void *eth80211_hdr;
36} __attribute__ ((packed)); 36} __packed;
37 37
38static int process_rxed_802_11_packet(struct lbs_private *priv, 38static int process_rxed_802_11_packet(struct lbs_private *priv,
39 struct sk_buff *skb); 39 struct sk_buff *skb);
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 24cd54b3a806..7d82f13bdf1d 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -666,7 +666,7 @@ void lbs_scan_worker(struct work_struct *work)
666/** 666/**
667 * @brief Interpret a BSS scan response returned from the firmware 667 * @brief Interpret a BSS scan response returned from the firmware
668 * 668 *
669 * Parse the various fixed fields and IEs passed back for a a BSS probe 669 * Parse the various fixed fields and IEs passed back for a BSS probe
670 * response or beacon from the scan command. Record information as needed 670 * response or beacon from the scan command. Record information as needed
671 * in the scan table struct bss_descriptor for that entry. 671 * in the scan table struct bss_descriptor for that entry.
672 * 672 *
diff --git a/drivers/net/wireless/libertas/types.h b/drivers/net/wireless/libertas/types.h
index 3e72c86ceca8..462fbb4cb743 100644
--- a/drivers/net/wireless/libertas/types.h
+++ b/drivers/net/wireless/libertas/types.h
@@ -11,7 +11,7 @@
11struct ieee_ie_header { 11struct ieee_ie_header {
12 u8 id; 12 u8 id;
13 u8 len; 13 u8 len;
14} __attribute__ ((packed)); 14} __packed;
15 15
16struct ieee_ie_cf_param_set { 16struct ieee_ie_cf_param_set {
17 struct ieee_ie_header header; 17 struct ieee_ie_header header;
@@ -20,19 +20,19 @@ struct ieee_ie_cf_param_set {
20 u8 cfpperiod; 20 u8 cfpperiod;
21 __le16 cfpmaxduration; 21 __le16 cfpmaxduration;
22 __le16 cfpdurationremaining; 22 __le16 cfpdurationremaining;
23} __attribute__ ((packed)); 23} __packed;
24 24
25 25
26struct ieee_ie_ibss_param_set { 26struct ieee_ie_ibss_param_set {
27 struct ieee_ie_header header; 27 struct ieee_ie_header header;
28 28
29 __le16 atimwindow; 29 __le16 atimwindow;
30} __attribute__ ((packed)); 30} __packed;
31 31
32union ieee_ss_param_set { 32union ieee_ss_param_set {
33 struct ieee_ie_cf_param_set cf; 33 struct ieee_ie_cf_param_set cf;
34 struct ieee_ie_ibss_param_set ibss; 34 struct ieee_ie_ibss_param_set ibss;
35} __attribute__ ((packed)); 35} __packed;
36 36
37struct ieee_ie_fh_param_set { 37struct ieee_ie_fh_param_set {
38 struct ieee_ie_header header; 38 struct ieee_ie_header header;
@@ -41,18 +41,18 @@ struct ieee_ie_fh_param_set {
41 u8 hopset; 41 u8 hopset;
42 u8 hoppattern; 42 u8 hoppattern;
43 u8 hopindex; 43 u8 hopindex;
44} __attribute__ ((packed)); 44} __packed;
45 45
46struct ieee_ie_ds_param_set { 46struct ieee_ie_ds_param_set {
47 struct ieee_ie_header header; 47 struct ieee_ie_header header;
48 48
49 u8 channel; 49 u8 channel;
50} __attribute__ ((packed)); 50} __packed;
51 51
52union ieee_phy_param_set { 52union ieee_phy_param_set {
53 struct ieee_ie_fh_param_set fh; 53 struct ieee_ie_fh_param_set fh;
54 struct ieee_ie_ds_param_set ds; 54 struct ieee_ie_ds_param_set ds;
55} __attribute__ ((packed)); 55} __packed;
56 56
57/** TLV type ID definition */ 57/** TLV type ID definition */
58#define PROPRIETARY_TLV_BASE_ID 0x0100 58#define PROPRIETARY_TLV_BASE_ID 0x0100
@@ -100,28 +100,28 @@ union ieee_phy_param_set {
100struct mrvl_ie_header { 100struct mrvl_ie_header {
101 __le16 type; 101 __le16 type;
102 __le16 len; 102 __le16 len;
103} __attribute__ ((packed)); 103} __packed;
104 104
105struct mrvl_ie_data { 105struct mrvl_ie_data {
106 struct mrvl_ie_header header; 106 struct mrvl_ie_header header;
107 u8 Data[1]; 107 u8 Data[1];
108} __attribute__ ((packed)); 108} __packed;
109 109
110struct mrvl_ie_rates_param_set { 110struct mrvl_ie_rates_param_set {
111 struct mrvl_ie_header header; 111 struct mrvl_ie_header header;
112 u8 rates[1]; 112 u8 rates[1];
113} __attribute__ ((packed)); 113} __packed;
114 114
115struct mrvl_ie_ssid_param_set { 115struct mrvl_ie_ssid_param_set {
116 struct mrvl_ie_header header; 116 struct mrvl_ie_header header;
117 u8 ssid[1]; 117 u8 ssid[1];
118} __attribute__ ((packed)); 118} __packed;
119 119
120struct mrvl_ie_wildcard_ssid_param_set { 120struct mrvl_ie_wildcard_ssid_param_set {
121 struct mrvl_ie_header header; 121 struct mrvl_ie_header header;
122 u8 MaxSsidlength; 122 u8 MaxSsidlength;
123 u8 ssid[1]; 123 u8 ssid[1];
124} __attribute__ ((packed)); 124} __packed;
125 125
126struct chanscanmode { 126struct chanscanmode {
127#ifdef __BIG_ENDIAN_BITFIELD 127#ifdef __BIG_ENDIAN_BITFIELD
@@ -133,7 +133,7 @@ struct chanscanmode {
133 u8 disablechanfilt:1; 133 u8 disablechanfilt:1;
134 u8 reserved_2_7:6; 134 u8 reserved_2_7:6;
135#endif 135#endif
136} __attribute__ ((packed)); 136} __packed;
137 137
138struct chanscanparamset { 138struct chanscanparamset {
139 u8 radiotype; 139 u8 radiotype;
@@ -141,12 +141,12 @@ struct chanscanparamset {
141 struct chanscanmode chanscanmode; 141 struct chanscanmode chanscanmode;
142 __le16 minscantime; 142 __le16 minscantime;
143 __le16 maxscantime; 143 __le16 maxscantime;
144} __attribute__ ((packed)); 144} __packed;
145 145
146struct mrvl_ie_chanlist_param_set { 146struct mrvl_ie_chanlist_param_set {
147 struct mrvl_ie_header header; 147 struct mrvl_ie_header header;
148 struct chanscanparamset chanscanparam[1]; 148 struct chanscanparamset chanscanparam[1];
149} __attribute__ ((packed)); 149} __packed;
150 150
151struct mrvl_ie_cf_param_set { 151struct mrvl_ie_cf_param_set {
152 struct mrvl_ie_header header; 152 struct mrvl_ie_header header;
@@ -154,86 +154,86 @@ struct mrvl_ie_cf_param_set {
154 u8 cfpperiod; 154 u8 cfpperiod;
155 __le16 cfpmaxduration; 155 __le16 cfpmaxduration;
156 __le16 cfpdurationremaining; 156 __le16 cfpdurationremaining;
157} __attribute__ ((packed)); 157} __packed;
158 158
159struct mrvl_ie_ds_param_set { 159struct mrvl_ie_ds_param_set {
160 struct mrvl_ie_header header; 160 struct mrvl_ie_header header;
161 u8 channel; 161 u8 channel;
162} __attribute__ ((packed)); 162} __packed;
163 163
164struct mrvl_ie_rsn_param_set { 164struct mrvl_ie_rsn_param_set {
165 struct mrvl_ie_header header; 165 struct mrvl_ie_header header;
166 u8 rsnie[1]; 166 u8 rsnie[1];
167} __attribute__ ((packed)); 167} __packed;
168 168
169struct mrvl_ie_tsf_timestamp { 169struct mrvl_ie_tsf_timestamp {
170 struct mrvl_ie_header header; 170 struct mrvl_ie_header header;
171 __le64 tsftable[1]; 171 __le64 tsftable[1];
172} __attribute__ ((packed)); 172} __packed;
173 173
174/* v9 and later firmware only */ 174/* v9 and later firmware only */
175struct mrvl_ie_auth_type { 175struct mrvl_ie_auth_type {
176 struct mrvl_ie_header header; 176 struct mrvl_ie_header header;
177 __le16 auth; 177 __le16 auth;
178} __attribute__ ((packed)); 178} __packed;
179 179
180/** Local Power capability */ 180/** Local Power capability */
181struct mrvl_ie_power_capability { 181struct mrvl_ie_power_capability {
182 struct mrvl_ie_header header; 182 struct mrvl_ie_header header;
183 s8 minpower; 183 s8 minpower;
184 s8 maxpower; 184 s8 maxpower;
185} __attribute__ ((packed)); 185} __packed;
186 186
187/* used in CMD_802_11_SUBSCRIBE_EVENT for SNR, RSSI and Failure */ 187/* used in CMD_802_11_SUBSCRIBE_EVENT for SNR, RSSI and Failure */
188struct mrvl_ie_thresholds { 188struct mrvl_ie_thresholds {
189 struct mrvl_ie_header header; 189 struct mrvl_ie_header header;
190 u8 value; 190 u8 value;
191 u8 freq; 191 u8 freq;
192} __attribute__ ((packed)); 192} __packed;
193 193
194struct mrvl_ie_beacons_missed { 194struct mrvl_ie_beacons_missed {
195 struct mrvl_ie_header header; 195 struct mrvl_ie_header header;
196 u8 beaconmissed; 196 u8 beaconmissed;
197 u8 reserved; 197 u8 reserved;
198} __attribute__ ((packed)); 198} __packed;
199 199
200struct mrvl_ie_num_probes { 200struct mrvl_ie_num_probes {
201 struct mrvl_ie_header header; 201 struct mrvl_ie_header header;
202 __le16 numprobes; 202 __le16 numprobes;
203} __attribute__ ((packed)); 203} __packed;
204 204
205struct mrvl_ie_bcast_probe { 205struct mrvl_ie_bcast_probe {
206 struct mrvl_ie_header header; 206 struct mrvl_ie_header header;
207 __le16 bcastprobe; 207 __le16 bcastprobe;
208} __attribute__ ((packed)); 208} __packed;
209 209
210struct mrvl_ie_num_ssid_probe { 210struct mrvl_ie_num_ssid_probe {
211 struct mrvl_ie_header header; 211 struct mrvl_ie_header header;
212 __le16 numssidprobe; 212 __le16 numssidprobe;
213} __attribute__ ((packed)); 213} __packed;
214 214
215struct led_pin { 215struct led_pin {
216 u8 led; 216 u8 led;
217 u8 pin; 217 u8 pin;
218} __attribute__ ((packed)); 218} __packed;
219 219
220struct mrvl_ie_ledgpio { 220struct mrvl_ie_ledgpio {
221 struct mrvl_ie_header header; 221 struct mrvl_ie_header header;
222 struct led_pin ledpin[1]; 222 struct led_pin ledpin[1];
223} __attribute__ ((packed)); 223} __packed;
224 224
225struct led_bhv { 225struct led_bhv {
226 uint8_t firmwarestate; 226 uint8_t firmwarestate;
227 uint8_t led; 227 uint8_t led;
228 uint8_t ledstate; 228 uint8_t ledstate;
229 uint8_t ledarg; 229 uint8_t ledarg;
230} __attribute__ ((packed)); 230} __packed;
231 231
232 232
233struct mrvl_ie_ledbhv { 233struct mrvl_ie_ledbhv {
234 struct mrvl_ie_header header; 234 struct mrvl_ie_header header;
235 struct led_bhv ledbhv[1]; 235 struct led_bhv ledbhv[1];
236} __attribute__ ((packed)); 236} __packed;
237 237
238/* Meant to be packed as the value member of a struct ieee80211_info_element. 238/* Meant to be packed as the value member of a struct ieee80211_info_element.
239 * Note that the len member of the ieee80211_info_element varies depending on 239 * Note that the len member of the ieee80211_info_element varies depending on
@@ -248,12 +248,12 @@ struct mrvl_meshie_val {
248 uint8_t mesh_capability; 248 uint8_t mesh_capability;
249 uint8_t mesh_id_len; 249 uint8_t mesh_id_len;
250 uint8_t mesh_id[IEEE80211_MAX_SSID_LEN]; 250 uint8_t mesh_id[IEEE80211_MAX_SSID_LEN];
251} __attribute__ ((packed)); 251} __packed;
252 252
253struct mrvl_meshie { 253struct mrvl_meshie {
254 u8 id, len; 254 u8 id, len;
255 struct mrvl_meshie_val val; 255 struct mrvl_meshie_val val;
256} __attribute__ ((packed)); 256} __packed;
257 257
258struct mrvl_mesh_defaults { 258struct mrvl_mesh_defaults {
259 __le32 bootflag; 259 __le32 bootflag;
@@ -261,6 +261,6 @@ struct mrvl_mesh_defaults {
261 uint8_t reserved; 261 uint8_t reserved;
262 __le16 channel; 262 __le16 channel;
263 struct mrvl_meshie meshie; 263 struct mrvl_meshie meshie;
264} __attribute__ ((packed)); 264} __packed;
265 265
266#endif 266#endif