Skip to contentSkip to conversation

wireless: add wow support

PATCH New Luis R. Rodriguez 2 participants 16 messages Jul 15, 2009

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover wireless: add wow support

This series adds Wake-on-Wireless support for wireless with initial support for ath9k. No event reporting is done yet, we'll leave that for later once we figure out a unified method for all devices (including non-wireless).

If you are not familiar with WoW you are encouraged to read:

http://wireless.kernel.org/en/users/Documentation/WoW

Please note not all laptops/desktops will have support for allowing WoW. You will need proper BIOS support, also not all cards have it enabled.

Luis R. Rodriguez (5):
ath9k: do not stop the queues in driver stop
adm8211: remove uneeded code during suspend/resume
cfg80211: add WoW support
mac80211: add WoW support
ath9k: Add Wake-on-Wireless-LAN support

 drivers/net/wireless/adm8211.c              |   19 +-
 drivers/net/wireless/at76c50x-usb.c         |    3 +-
 drivers/net/wireless/ath/ar9170/main.c      |    2 +-
 drivers/net/wireless/ath/ath5k/base.c       |    4 +-
 drivers/net/wireless/ath/ath9k/Makefile     |    1 +
 drivers/net/wireless/ath/ath9k/ath9k.h      |   18 +
 drivers/net/wireless/ath/ath9k/debug.c      |    1 -
 drivers/net/wireless/ath/ath9k/hw.c         |   22 ++
 drivers/net/wireless/ath/ath9k/hw.h         |   21 ++
 drivers/net/wireless/ath/ath9k/initvals.h   |   31 ++
 drivers/net/wireless/ath/ath9k/main.c       |   27 ++-
 drivers/net/wireless/ath/ath9k/pci.c        |  102 ++++++
 drivers/net/wireless/ath/ath9k/reg.h        |  154 ++++++++
 drivers/net/wireless/ath/ath9k/wow.c        |  511 +++++++++++++++++++++++++++
 drivers/net/wireless/b43/main.c             |    2 +-
 drivers/net/wireless/b43legacy/main.c       |    2 +-
 drivers/net/wireless/iwlwifi/iwl-agn.c      |    2 +-
 drivers/net/wireless/iwlwifi/iwl3945-base.c |    2 +-
 drivers/net/wireless/libertas_tf/main.c     |    2 +-
 drivers/net/wireless/mac80211_hwsim.c       |    2 +-
 drivers/net/wireless/mwl8k.c                |    2 +-
 drivers/net/wireless/p54/main.c             |    2 +-
 drivers/net/wireless/rt2x00/rt2x00.h        |    2 +-
 drivers/net/wireless/rt2x00/rt2x00mac.c     |    2 +-
 drivers/net/wireless/rtl818x/rtl8180_dev.c  |    2 +-
 drivers/net/wireless/rtl818x/rtl8187_dev.c  |    2 +-
 drivers/net/wireless/wl12xx/wl1251_main.c   |    2 +-
 drivers/net/wireless/zd1211rw/zd_mac.c      |    2 +-
 include/linux/nl80211.h                     |   46 +++
 include/net/cfg80211.h                      |   26 ++-
 include/net/mac80211.h                      |   17 +-
 net/mac80211/cfg.c                          |    5 +-
 net/mac80211/debugfs.c                      |    2 +-
 net/mac80211/driver-ops.h                   |    6 +-
 net/mac80211/driver-trace.h                 |    6 +-
 net/mac80211/ieee80211_i.h                  |   12 +-
 net/mac80211/iface.c                        |    6 +-
 net/mac80211/pm.c                           |   31 ++-
 net/mac80211/util.c                         |   14 +
 net/wireless/core.h                         |    3 +
 net/wireless/nl80211.c                      |  116 ++++++
 net/wireless/sysfs.c                        |    2 +-
 42 files changed, 1172 insertions(+), 64 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/wow.c
#1 lore raw

PATCH 1/5 ath9k: do not stop the queues in driver stop

mac80211 will have disabled the queues for us when needed.

---
 drivers/net/wireless/ath/ath9k/main.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath9k/main.c +0 -2
index d14f8c9..907434a 100644
@@ -2101,8 +2101,6 @@ static void ath9k_stop(struct ieee80211_hw *hw)
 
 	mutex_lock(&sc->mutex);
 
-	ieee80211_stop_queues(hw);
-
 	if (ath9k_wiphy_started(sc)) {
 		mutex_unlock(&sc->mutex);
 		return; /* another wiphy still in use */
Signature · 1 line
1.6.0.6
#2 lore raw

PATCH 2/5 adm8211: remove uneeded code during suspend/resume

In reply to Luis R. Rodriguez

mac80211 drivers do not need to stop the software queues or call their own stop() callback upon suspend as we do it for drivers. Equally drivers don't have to call their own start() or start the queues as mac80211 will do it for us.

---
 drivers/net/wireless/adm8211.c |   17 -----------------
 1 files changed, 0 insertions(+), 17 deletions(-)
drivers/net/wireless/adm8211.c +0 -17
index ecc9383..5695911 100644
@@ -1964,14 +1964,6 @@ static void __devexit adm8211_remove(struct pci_dev *pdev)
 #ifdef CONFIG_PM
 static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state)
 {
-	struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-	struct adm8211_priv *priv = dev->priv;
-
-	if (priv->mode != NL80211_IFTYPE_UNSPECIFIED) {
-		ieee80211_stop_queues(dev);
-		adm8211_stop(dev);
-	}
-
 	pci_save_state(pdev);
 	pci_set_power_state(pdev, pci_choose_state(pdev, state));
 	return 0;
@@ -1979,17 +1971,8 @@ static int adm8211_suspend(struct pci_dev *pdev, pm_message_t state)
 
 static int adm8211_resume(struct pci_dev *pdev)
 {
-	struct ieee80211_hw *dev = pci_get_drvdata(pdev);
-	struct adm8211_priv *priv = dev->priv;
-
 	pci_set_power_state(pdev, PCI_D0);
 	pci_restore_state(pdev);
-
-	if (priv->mode != NL80211_IFTYPE_UNSPECIFIED) {
-		adm8211_start(dev);
-		ieee80211_wake_queues(dev);
-	}
-
 	return 0;
 }
 #endif /* CONFIG_PM */
Signature · 1 line
1.6.0.6
#3 lore raw

PATCH 3/5 cfg80211: add WoW support

In reply to Luis R. Rodriguez

We support a set and get for WoW parameters. We support setting of 3 type of triggers:

* Magic Packet
* Beacon miss
* Link change (no longer associated)

Not yet supported:

* User pattern match

The user pattern match will need a parser as patterns can be customized. It should be noted WoW will require suspend to S3 Hot (power cable plugged), and proper BIOS support to receive PCI PMEs and kick the box on.

For USB this may be easier and no BIOS intervention should be required.

Drivers which support WoW must set their supported hardware/driver triggers on the wiphy's cfg80211 wow_triggers_supported. cfg80211 drivers will be informed of the enabled wow triggers through the suspend() cfg80211 callback. By default we disable all triggers.

---
 include/linux/nl80211.h |   46 +++++++++++++++++++
 include/net/cfg80211.h  |   26 ++++++++++-
 net/wireless/core.h     |    3 +
 net/wireless/nl80211.c  |  116 +++++++++++++++++++++++++++++++++++++++++++++++
 net/wireless/sysfs.c    |    2 +-
 5 files changed, 190 insertions(+), 3 deletions(-)
include/linux/nl80211.h +46 -0
index 962e223..0c869ca 100644
@@ -262,6 +262,18 @@
  *	reasons, for this the %NL80211_ATTR_DISCONNECTED_BY_AP and
  *	%NL80211_ATTR_REASON_CODE attributes are used.
  *
+ * @NL80211_CMD_GET_WOW: get Wake-on-Wireless-LAN (WoW) settings.
+ * @NL80211_CMD_SET_WOW: set Wake-on-Wireless-LAN (Wow) settings. Wake on
+ *	wireless makes use of standard Wake-on-LAN (WoL) frames, you receive
+ *	a WoW frame when your AP sends you a regular WOL frame. The difference
+ *	difference WoL is you need to be associated to an AP in order to
+ *	receive WoW frames, so additional triggers are available for a wakeup.
+ *	A driver capable of WoW should initialize the wiphy with its supported
+ *	WoW triggers. Upon suspend cfg80211 will inform the driver of the user
+ *	enabled triggers. By default no WoW triggers are enabled.
+ *	For more information see:
+ *	http://wireless.kernel.org/en/users/Documentation/WoW
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -336,6 +348,9 @@ enum nl80211_commands {
 	NL80211_CMD_ROAM,
 	NL80211_CMD_DISCONNECT,
 
+	NL80211_CMD_GET_WOW,
+	NL80211_CMD_SET_WOW,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -355,6 +370,8 @@ enum nl80211_commands {
 #define NL80211_CMD_DEAUTHENTICATE NL80211_CMD_DEAUTHENTICATE
 #define NL80211_CMD_DISASSOCIATE NL80211_CMD_DISASSOCIATE
 #define NL80211_CMD_REG_BEACON_HINT NL80211_CMD_REG_BEACON_HINT
+#define NL80211_CMD_GET_WOW NL80211_CMD_GET_WOW
+#define NL80211_CMD_SET_WOW NL80211_CMD_SET_WOW
 
 /**
  * enum nl80211_attrs - nl80211 netlink attributes
@@ -573,6 +590,12 @@ enum nl80211_commands {
  *	and join_ibss(), key information is in a nested attribute each
  *	with %NL80211_KEY_* sub-attributes
  *
+ * @NL80211_ATTR_WOW_TRIGGERS_SUPPORTED: the supported WoW triggers
+ * @NL80211_ATTR_WOW_TRIGGERS_ENABLED: used by %NL80211_CMD_SET_WOW to
+ *	indicate which WoW triggers should be enabled. This is also
+ *	used by %NL80211_CMD_GET_WOW to get the currently enabled WoW
+ *	triggers.
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -701,6 +724,9 @@ enum nl80211_attrs {
 	NL80211_ATTR_KEY,
 	NL80211_ATTR_KEYS,
 
+	NL80211_ATTR_WOW_TRIGGERS_SUPPORTED,
+	NL80211_ATTR_WOW_TRIGGERS_ENABLED,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -1372,4 +1398,24 @@ enum nl80211_key_attributes {
 	NL80211_KEY_MAX = __NL80211_KEY_AFTER_LAST - 1
 };
 
+/**
+ * enum nl80211_wow_triggers - Wake-on-Wireless-LAN triggers
+ *
+ * NL80211_WOW_TRIGGER_MAGIC_PACKET: a wake signal will be sent to the
+ *     devices if a magic packet is received.
+ * NL80211_WOW_TRIGGER_BMISS: WoW signal will be sent to the device when
+ *     a beacon has been missed by the associated AP.
+ * NL80211_WOW_TRIGGER_LINK_CHANGE: a wake signal will be sent to
+ *     the device if a link change is detected on the device.
+ * NL80211_WOW_TRIGGER_USER_PATTERN: a wake signal will be sent to the
+ *     device if a user configurable pattern is received by
+ *     the device.
+ */
+enum nl80211_wow_triggers {
+	NL80211_WOW_TRIGGER_MAGIC_PACKET	= 1 << 0,
+	NL80211_WOW_TRIGGER_BMISS		= 1 << 1,
+	NL80211_WOW_TRIGGER_LINK_CHANGE		= 1 << 2,
+	NL80211_WOW_TRIGGER_PATTERN		= 1 << 3,
+};
+
 #endif /* __LINUX_NL80211_H */
include/net/cfg80211.h +24 -2
index a981ca8..d45fcec 100644
@@ -828,6 +828,21 @@ struct cfg80211_bitrate_mask {
 	u32 maxrate; /* in kbps, 0 == no limit */
 };
 
+/*
+ * struct cfg80211_wow - Wake on Wireless-LAN support info
+ *
+ * This structure defines the WoW triggers enabled and set for the device.
+ * For now we only carry the supported tiggers but this is expected to grow
+ * once we add support for user patterns.
+ *
+ * @triggers_enabled: enabled triggers by the user. Default
+ *	is to disable all triggers. The flags for this bitmask
+ *	are %NL80211_WOW_TRIGGER_*.
+ */
+struct cfg80211_wow {
+	u32 triggers_enabled;
+};
+
 /**
  * struct cfg80211_ops - backend description for wireless configuration
  *
@@ -841,7 +856,8 @@ struct cfg80211_bitrate_mask {
  * wireless extensions but this is subject to reevaluation as soon as this
  * code is used more widely and we have a first user without wext.
  *
- * @suspend: wiphy device needs to be suspended
+ * @suspend: wiphy device needs to be suspended. We pass the struct cfg80211_wow
+ *	so the device enables the appropriate triggers during suspend.
  * @resume: wiphy device needs to be resumed
  *
  * @add_virtual_intf: create a new virtual interface with the given name,
@@ -931,7 +947,7 @@ struct cfg80211_bitrate_mask {
  * @testmode_cmd: run a test mode command
  */
 struct cfg80211_ops {
-	int	(*suspend)(struct wiphy *wiphy);
+	int	(*suspend)(struct wiphy *wiphy, struct cfg80211_wow *wow);
 	int	(*resume)(struct wiphy *wiphy);
 
 	int	(*add_virtual_intf)(struct wiphy *wiphy, char *name,
@@ -1088,6 +1104,10 @@ struct cfg80211_ops {
  * @frag_threshold: Fragmentation threshold (dot11FragmentationThreshold);
  *	-1 = fragmentation disabled, only odd values >= 256 used
  * @rts_threshold: RTS threshold (dot11RTSThreshold); -1 = RTS/CTS disabled
+ * @wow_triggers_supported: supported bitmask of Wake-on-Wireless triggers.
+ *	The flags for this bitmask are %NL80211_WOW_TRIGGER_*. The driver
+ *	should set the capabilities before registering the wiphy. WoW triggers
+ *	which should be used are passed to the driver upon suspend.
  */
 struct wiphy {
 	/* assign these fields before you register the wiphy */
@@ -1115,6 +1135,8 @@ struct wiphy {
 	u32 frag_threshold;
 	u32 rts_threshold;
 
+	u32 wow_triggers_supported;
+
 	/* If multiple wiphys are registered and you're handed e.g.
 	 * a regular netdev with assigned ieee80211_ptr, you won't
 	 * know whether it points to a wiphy your driver has registered
net/wireless/core.h +3 -0
index 2ec8ddb..1d250cd 100644
@@ -66,6 +66,9 @@ struct cfg80211_registered_device {
 	struct work_struct conn_work;
 	struct work_struct event_work;
 
+	/* Used to keep track of user configurable triggers */
+	struct cfg80211_wow wow;
+
 #ifdef CONFIG_CFG80211_DEBUGFS
 	/* Debugfs entries */
 	struct wiphy_debugfsdentries {
net/wireless/nl80211.c +116 -0

134 lines not on this page · raw message

net/wireless/sysfs.c +1 -1
index efe3c5c..8b60a5b 100644
@@ -64,7 +64,7 @@ static int wiphy_suspend(struct device *dev, pm_message_t state)
 
 	if (rdev->ops->suspend) {
 		rtnl_lock();
-		ret = rdev->ops->suspend(&rdev->wiphy);
+		ret = rdev->ops->suspend(&rdev->wiphy, &rdev->wow);
 		rtnl_unlock();
 	}
 
Signature · 1 line
1.6.0.6
maintainer
#4 lore raw

PATCH 3/5 cfg80211: add WoW support

net/wireless/nl80211.c unlock_rtnl: · line 4050

Quoted 3 lines · Luis R. Rodriguez
net/wireless/nl80211.c +3 -0
+	/* Draw up a netlink message to send back */
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!msg) {

Need to use DEFAULT_SIZE or something.

net/wireless/nl80211.c unlock_rtnl: · line 4113

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	if (!(wiphy->wow_triggers_supported & triggers_requested)) {
+		err = -EOPNOTSUPP;
+		goto out;

This seems wrong, should be "requested & supported != requested", I think.

Quoted 7 lines
net/wireless/nl80211.c +3 -0
@@ -4253,6 +4359,16 @@ static struct genl_ops nl80211_ops[] = {
 	{
 		.cmd = NL80211_CMD_DISCONNECT,
 		.doit = nl80211_disconnect,
+	},
+	{
+		.cmd = NL80211_CMD_GET_WOW,

net/wireless/nl80211.c static struct genl_ops nl80211_ops[] = { · line 4374

Quoted 10 lines
net/wireless/nl80211.c +7 -0
+		.doit = nl80211_get_wow,
+		.policy = nl80211_policy,
+		/* can be retrieved by unprivileged users */
+	},
+	{
+		.cmd = NL80211_CMD_SET_WOW,
+		.doit = nl80211_set_wow,
 		.policy = nl80211_policy,
 		.flags = GENL_ADMIN_PERM,
 	},

This messes up the disconnect command.

johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20090715/ded12ee6/attachment.pgp

#5 lore raw

PATCH 3/5 cfg80211: add WoW support

Quoted 7 lines · Johannes Berg

net/wireless/nl80211.c unlock_rtnl: · line 4050

Quoted 3 lines · Luis R. Rodriguez
net/wireless/nl80211.c +3 -0
+	/* Draw up a netlink message to send back */
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!msg) {

Need to use DEFAULT_SIZE or something.

Will change it, thanks. I see NLMSG_DEFAULT_SIZE is smaller than NLMSG_GOODSIZE (it removes the NLMSG_HDRLEN), but no documentation for either, when should I use either?

Quoted 6 lines

net/wireless/nl80211.c unlock_rtnl: · line 4113

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	if (!(wiphy->wow_triggers_supported & triggers_requested)) {
+		err = -EOPNOTSUPP;
+		goto out;

This seems wrong, should be "requested & supported != requested", I think.

The above one won't return -EOPNOTSUPP when you add additional junk, you're right, better to just inform userspace of that.

Quoted 11 lines
Quoted 11 lines
net/wireless/nl80211.c +7 -0
@@ -4253,6 +4359,16 @@ static struct genl_ops nl80211_ops[] = {
 	{
 		.cmd = NL80211_CMD_DISCONNECT,
 		.doit = nl80211_disconnect,
+	},
+	{
+		.cmd = NL80211_CMD_GET_WOW,
+		.doit = nl80211_get_wow,
+		.policy = nl80211_policy,
+		/* can be retrieved by unprivileged users */
+	},
Quoted 8 lines

net/wireless/nl80211.c static struct genl_ops nl80211_ops[] = { · line 4374

Quoted 6 lines
net/wireless/nl80211.c +3 -0
+	{
+		.cmd = NL80211_CMD_SET_WOW,
+		.doit = nl80211_set_wow,
 		.policy = nl80211_policy,
 		.flags = GENL_ADMIN_PERM,
 	},

This messes up the disconnect command.

Must have been a rebase issue, strange, thanks, will fix up.

Luis

maintainer
#6 lore raw

PATCH 3/5 cfg80211: add WoW support

Quoted 3 lines · Luis R. Rodriguez

Will change it, thanks. I see NLMSG_DEFAULT_SIZE is smaller than NLMSG_GOODSIZE (it removes the NLMSG_HDRLEN), but no documentation for either, when should I use either?

I don't know, but GOODSIZE is larger than a page or something, iirc. There was a patch recently changing all the users.

Quoted 9 lines
Quoted 6 lines

net/wireless/nl80211.c unlock_rtnl: · line 4113

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	if (!(wiphy->wow_triggers_supported & triggers_requested)) {
+		err = -EOPNOTSUPP;
+		goto out;

This seems wrong, should be "requested & supported != requested", I think.

The above one won't return -EOPNOTSUPP when you add additional junk, you're right, better to just inform userspace of that.

Your version also disallows turning off WoW again, afaict.

johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20090715/d69ce2af/attachment-0001.pgp

#7 lore raw

PATCH 3/5 cfg80211: add WoW support

Quoted 8 lines · Johannes Berg
Quoted 7 lines · Luis R. Rodriguez
Quoted 6 lines

net/wireless/nl80211.c unlock_rtnl: · line 4113

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	if (!(wiphy->wow_triggers_supported & triggers_requested)) {
+		err = -EOPNOTSUPP;
+		goto out;

This seems wrong, should be "requested & supported != requested", I think.

Quoted 4 lines
Quoted 2 lines

The above one won't return -EOPNOTSUPP when you add additional junk, you're right, better to just inform userspace of that.

Your version also disallows turning off WoW again, afaict.

That is something we do want, as otherwise we'll keep the device powered on. Will consider both.

Luis

maintainer
#8 lore raw

PATCH 3/5 cfg80211: add WoW support

Quoted 9 lines · Luis R. Rodriguez
Quoted 8 lines · Johannes Berg
Quoted 7 lines · Luis R. Rodriguez
Quoted 6 lines

net/wireless/nl80211.c unlock_rtnl: · line 4113

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	if (!(wiphy->wow_triggers_supported & triggers_requested)) {
+		err = -EOPNOTSUPP;
+		goto out;

This seems wrong, should be "requested & supported != requested", I think.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

The above one won't return -EOPNOTSUPP when you add additional junk, you're right, better to just inform userspace of that.

Your version also disallows turning off WoW again, afaict.

That is something we do want, as otherwise we'll keep the device powered on. Will consider both.

Huh? There has to be a way to turn off wow again after you've actually resumed for other reasons, or whatever.

johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20090715/287aad5e/attachment.pgp

#9 lore raw

PATCH 3/5 cfg80211: add WoW support

Quoted 13 lines · Johannes Berg
Quoted 12 lines · Luis R. Rodriguez
Quoted 11 lines · Johannes Berg
Quoted 9 lines · Luis R. Rodriguez
Quoted 6 lines

net/wireless/nl80211.c unlock_rtnl: · line 4113

Quoted 3 lines
net/wireless/nl80211.c +3 -0
+	if (!(wiphy->wow_triggers_supported & triggers_requested)) {
+		err = -EOPNOTSUPP;
+		goto out;

This seems wrong, should be "requested & supported != requested", I think.

The above one won't return -EOPNOTSUPP when you add additional junk, you're right, better to just inform userspace of that.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Your version also disallows turning off WoW again, afaict.

That is something we do want, as otherwise we'll keep the device powered on. Will consider both.

Huh? There has to be a way to turn off wow again after you've actually resumed for other reasons, or whatever.

Yes, we want that.

Luis

#10 lore raw

PATCH 4/5 mac80211: add WoW support

In reply to Luis R. Rodriguez

If we're associated and have not already gone into PS mode we ensure send a nullfunc frame before going to suspend. Upon resume we ensure we restore PS mode if it was enabled and inform the driver accordingly, also notify the AP we're awake.

WoW requires the radio to be left on during suspend, to do this we inform drivers of the requested wow triggers on the mac80211 stop callback.

---
 drivers/net/wireless/adm8211.c              |    2 +-
 drivers/net/wireless/at76c50x-usb.c         |    3 +-
 drivers/net/wireless/ath/ar9170/main.c      |    2 +-
 drivers/net/wireless/ath/ath5k/base.c       |    4 +-
 drivers/net/wireless/ath/ath9k/main.c       |    2 +-
 drivers/net/wireless/b43/main.c             |    2 +-
 drivers/net/wireless/b43legacy/main.c       |    2 +-
 drivers/net/wireless/iwlwifi/iwl-agn.c      |    2 +-
 drivers/net/wireless/iwlwifi/iwl3945-base.c |    2 +-
 drivers/net/wireless/libertas_tf/main.c     |    2 +-
 drivers/net/wireless/mac80211_hwsim.c       |    2 +-
 drivers/net/wireless/mwl8k.c                |    2 +-
 drivers/net/wireless/p54/main.c             |    2 +-
 drivers/net/wireless/rt2x00/rt2x00.h        |    2 +-
 drivers/net/wireless/rt2x00/rt2x00mac.c     |    2 +-
 drivers/net/wireless/rtl818x/rtl8180_dev.c  |    2 +-
 drivers/net/wireless/rtl818x/rtl8187_dev.c  |    2 +-
 drivers/net/wireless/wl12xx/wl1251_main.c   |    2 +-
 drivers/net/wireless/zd1211rw/zd_mac.c      |    2 +-
 include/net/mac80211.h                      |   17 +++++++++-----
 net/mac80211/cfg.c                          |    5 ++-
 net/mac80211/debugfs.c                      |    2 +-
 net/mac80211/driver-ops.h                   |    6 ++--
 net/mac80211/driver-trace.h                 |    6 +++-
 net/mac80211/ieee80211_i.h                  |   12 ++++++++-
 net/mac80211/iface.c                        |    6 ++--
 net/mac80211/pm.c                           |   31 +++++++++++++++++++++++++-
 net/mac80211/util.c                         |   14 ++++++++++++
 28 files changed, 99 insertions(+), 41 deletions(-)
drivers/net/wireless/adm8211.c +1 -1
index 5695911..776a715 100644
@@ -1547,7 +1547,7 @@ fail:
 	return retval;
 }
 
-static void adm8211_stop(struct ieee80211_hw *dev)
+static void adm8211_stop(struct ieee80211_hw *dev, struct cfg80211_wow *wow)
 {
 	struct adm8211_priv *priv = dev->priv;
 
drivers/net/wireless/at76c50x-usb.c +2 -1
index 13303fa..8357fef 100644
@@ -1767,7 +1767,8 @@ error:
 	return 0;
 }
 
-static void at76_mac80211_stop(struct ieee80211_hw *hw)
+static void at76_mac80211_stop(struct ieee80211_hw *hw,
+			       struct cfg80211_wow *wow)
 {
 	struct at76_priv *priv = hw->priv;
 
drivers/net/wireless/ath/ar9170/main.c +1 -1
index 51753ed..2c2f002 100644
@@ -1132,7 +1132,7 @@ out:
 	return err;
 }
 
-static void ar9170_op_stop(struct ieee80211_hw *hw)
+static void ar9170_op_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct ar9170 *ar = hw->priv;
 	unsigned int i;
drivers/net/wireless/ath/ath5k/base.c +2 -2
index 20ba6fa..0bd53e8 100644
@@ -223,7 +223,7 @@ static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb,
 static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan);
 static int ath5k_reset_wake(struct ath5k_softc *sc);
 static int ath5k_start(struct ieee80211_hw *hw);
-static void ath5k_stop(struct ieee80211_hw *hw);
+static void ath5k_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow);
 static int ath5k_add_interface(struct ieee80211_hw *hw,
 		struct ieee80211_if_init_conf *conf);
 static void ath5k_remove_interface(struct ieee80211_hw *hw,
@@ -2735,7 +2735,7 @@ static int ath5k_start(struct ieee80211_hw *hw)
 	return ath5k_init(hw->priv);
 }
 
-static void ath5k_stop(struct ieee80211_hw *hw)
+static void ath5k_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	ath5k_stop_hw(hw->priv);
 }
drivers/net/wireless/ath/ath9k/main.c +1 -1
index 907434a..f40f2cf 100644
@@ -2087,7 +2087,7 @@ exit:
 	return 0;
 }
 
-static void ath9k_stop(struct ieee80211_hw *hw)
+static void ath9k_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct ath_wiphy *aphy = hw->priv;
 	struct ath_softc *sc = aphy->sc;
drivers/net/wireless/b43/main.c +1 -1
index e71c8d9..f0ca9d0 100644
@@ -4368,7 +4368,7 @@ static int b43_op_start(struct ieee80211_hw *hw)
 	return err;
 }
 
-static void b43_op_stop(struct ieee80211_hw *hw)
+static void b43_op_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct b43_wl *wl = hw_to_b43_wl(hw);
 	struct b43_wldev *dev = wl->current_dev;
drivers/net/wireless/b43legacy/main.c +1 -1
index c4973c1..9235578 100644
@@ -3469,7 +3469,7 @@ out_mutex_unlock:
 	return err;
 }
 
-static void b43legacy_op_stop(struct ieee80211_hw *hw)
+static void b43legacy_op_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
 	struct b43legacy_wldev *dev = wl->current_dev;
drivers/net/wireless/iwlwifi/iwl-agn.c +1 -1
index 13279b1..fd2c146 100644
@@ -2137,7 +2137,7 @@ out:
 	return 0;
 }
 
-static void iwl_mac_stop(struct ieee80211_hw *hw)
+static void iwl_mac_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct iwl_priv *priv = hw->priv;
 
drivers/net/wireless/iwlwifi/iwl3945-base.c +1 -1
index a05a039..83cc25c 100644
@@ -3126,7 +3126,7 @@ out_release_irq:
 	return ret;
 }
 
-static void iwl3945_mac_stop(struct ieee80211_hw *hw)
+static void iwl3945_mac_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct iwl_priv *priv = hw->priv;
 
drivers/net/wireless/libertas_tf/main.c +1 -1
index 4872345..8557ca4 100644
@@ -291,7 +291,7 @@ err_prog_firmware:
 	return ret;
 }
 
-static void lbtf_op_stop(struct ieee80211_hw *hw)
+static void lbtf_op_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct lbtf_private *priv = hw->priv;
 	unsigned long flags;
drivers/net/wireless/mac80211_hwsim.c +1 -1
index 2e2af65..516a31c 100644
@@ -488,7 +488,7 @@ static int mac80211_hwsim_start(struct ieee80211_hw *hw)
 }
 
 
-static void mac80211_hwsim_stop(struct ieee80211_hw *hw)
+static void mac80211_hwsim_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct mac80211_hwsim_data *data = hw->priv;
 	data->started = 0;
drivers/net/wireless/mwl8k.c +1 -1
index b9eded8..1261f8d 100644
@@ -2917,7 +2917,7 @@ static int mwl8k_stop_wt(struct work_struct *wt)
 	return rc;
 }
 
-static void mwl8k_stop(struct ieee80211_hw *hw)
+static void mwl8k_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	int rc;
 	struct mwl8k_stop_worker *worker;
drivers/net/wireless/p54/main.c +1 -1
index c9a0545..43b5940 100644
@@ -190,7 +190,7 @@ out:
 	return err;
 }
 
-static void p54_stop(struct ieee80211_hw *dev)
+static void p54_stop(struct ieee80211_hw *dev, struct cfg80211_wow *wow)
 {
 	struct p54_common *priv = dev->priv;
 	int i;
drivers/net/wireless/rt2x00/rt2x00.h +1 -1
index 71f37cb..e2701fa 100644
@@ -953,7 +953,7 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev,
  */
 int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb);
 int rt2x00mac_start(struct ieee80211_hw *hw);
-void rt2x00mac_stop(struct ieee80211_hw *hw);
+void rt2x00mac_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow);
 int rt2x00mac_add_interface(struct ieee80211_hw *hw,
 			    struct ieee80211_if_init_conf *conf);
 void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
drivers/net/wireless/rt2x00/rt2x00mac.c +1 -1
index b7e0ddd..4522c96 100644
@@ -179,7 +179,7 @@ int rt2x00mac_start(struct ieee80211_hw *hw)
 }
 EXPORT_SYMBOL_GPL(rt2x00mac_start);
 
-void rt2x00mac_stop(struct ieee80211_hw *hw)
+void rt2x00mac_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct rt2x00_dev *rt2x00dev = hw->priv;
 
drivers/net/wireless/rtl818x/rtl8180_dev.c +1 -1
index 09f46ab..807605c 100644
@@ -628,7 +628,7 @@ static int rtl8180_start(struct ieee80211_hw *dev)
 	return ret;
 }
 
-static void rtl8180_stop(struct ieee80211_hw *dev)
+static void rtl8180_stop(struct ieee80211_hw *dev, struct cfg80211_wow *wow)
 {
 	struct rtl8180_priv *priv = dev->priv;
 	u8 reg;
drivers/net/wireless/rtl818x/rtl8187_dev.c +1 -1
index c9b9dbe..fd1e8f8 100644
@@ -989,7 +989,7 @@ static int rtl8187_start(struct ieee80211_hw *dev)
 	return 0;
 }
 
-static void rtl8187_stop(struct ieee80211_hw *dev)
+static void rtl8187_stop(struct ieee80211_hw *dev, struct cfg80211_wow *wow)
 {
 	struct rtl8187_priv *priv = dev->priv;
 	struct sk_buff *skb;
drivers/net/wireless/wl12xx/wl1251_main.c +1 -1
index cf5e054..a87a25a 100644
@@ -376,7 +376,7 @@ out:
 	return ret;
 }
 
-static void wl1251_op_stop(struct ieee80211_hw *hw)
+static void wl1251_op_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct wl1251 *wl = hw->priv;
 
drivers/net/wireless/zd1211rw/zd_mac.c +1 -1
index 9600b72..70dcf01 100644
@@ -256,7 +256,7 @@ out:
 	return r;
 }
 
-static void zd_op_stop(struct ieee80211_hw *hw)
+static void zd_op_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct zd_mac *mac = zd_hw_mac(hw);
 	struct zd_chip *chip = &mac->chip;
include/net/mac80211.h +11 -6
index 7dd67a1..004e6b3 100644
@@ -545,6 +545,7 @@ enum ieee80211_conf_flags {
  * @IEEE80211_CONF_CHANGE_CHANNEL: the channel/channel_type changed
  * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed
  * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed
+ * @IEEE80211_CONF_CHANGE_WOW: Wake-on-Wireless LAN triggers have changed
  */
 enum ieee80211_conf_changed {
 	_IEEE80211_CONF_CHANGE_RADIO_ENABLED	= BIT(0),
@@ -555,6 +556,7 @@ enum ieee80211_conf_changed {
 	IEEE80211_CONF_CHANGE_CHANNEL		= BIT(6),
 	IEEE80211_CONF_CHANGE_RETRY_LIMITS	= BIT(7),
 	IEEE80211_CONF_CHANGE_IDLE		= BIT(8),
+	IEEE80211_CONF_CHANGE_WOW		= BIT(9),
 };
 
 static inline __deprecated enum ieee80211_conf_changed
@@ -1294,11 +1296,14 @@ enum ieee80211_ampdu_mlme_action {
  *	Must be implemented.
  *
  * @stop: Called after last netdevice attached to the hardware
- *	is disabled. This should turn off the hardware (at least
- *	it must turn off frame reception.)
- *	May be called right after add_interface if that rejects
- *	an interface.
- *	Must be implemented.
+ *	is disabled or during suspend. This should turn off the
+ *	hardware (at least it must turn off frame reception) unless
+ *	the device wants to enable Wake-on-Wireless-LAN. In order to
+ *	process WoW triggers the radio must be left on and the driver
+ *	must enable the triggers in hardware. This callback may be
+ *	called right after add_interface if that rejects an interface.
+ *	Must be implemented. WoW triggers which should be enabled prior
+ *	suspend are passed in the callback.
  *
  * @add_interface: Called when a netdevice attached to the hardware is
  *	enabled. Because it is not called for monitor mode devices, @start
@@ -1425,7 +1430,7 @@ enum ieee80211_ampdu_mlme_action {
 struct ieee80211_ops {
 	int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb);
 	int (*start)(struct ieee80211_hw *hw);
-	void (*stop)(struct ieee80211_hw *hw);
+	void (*stop)(struct ieee80211_hw *hw, struct cfg80211_wow *wow);
 	int (*add_interface)(struct ieee80211_hw *hw,
 			     struct ieee80211_if_init_conf *conf);
 	void (*remove_interface)(struct ieee80211_hw *hw,
net/mac80211/cfg.c +3 -2
index 52928ad..afa6476 100644
@@ -1138,15 +1138,16 @@ static int ieee80211_set_channel(struct wiphy *wiphy,
 }
 
 #ifdef CONFIG_PM
-static int ieee80211_suspend(struct wiphy *wiphy)
+static int ieee80211_suspend(struct wiphy *wiphy, struct cfg80211_wow *wow)
 {
-	return __ieee80211_suspend(wiphy_priv(wiphy));
+	return __ieee80211_suspend(wiphy_priv(wiphy), wow);
 }
 
 static int ieee80211_resume(struct wiphy *wiphy)
 {
 	return __ieee80211_resume(wiphy_priv(wiphy));
 }
+
 #else
 #define ieee80211_suspend NULL
 #define ieee80211_resume NULL
net/mac80211/debugfs.c +1 -1
index 96991b6..8985c40 100644
@@ -115,7 +115,7 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf,
 	struct ieee80211_local *local = file->private_data;
 
 	rtnl_lock();
-	__ieee80211_suspend(&local->hw);
+	__ieee80211_suspend(&local->hw, NULL);
 	__ieee80211_resume(&local->hw);
 	rtnl_unlock();
 
net/mac80211/driver-ops.h +3 -3
index 4100c36..f12488f 100644
@@ -17,10 +17,10 @@ static inline int drv_start(struct ieee80211_local *local)
 	return ret;
 }
 
-static inline void drv_stop(struct ieee80211_local *local)
+static inline void drv_stop(struct ieee80211_local *local, struct cfg80211_wow *wow)
 {
-	local->ops->stop(&local->hw);
-	trace_drv_stop(local);
+	local->ops->stop(&local->hw, wow);
+	trace_drv_stop(local, wow);
 }
 
 static inline int drv_add_interface(struct ieee80211_local *local,
net/mac80211/driver-trace.h +4 -2
index 48c93d1..f83f913 100644
@@ -51,16 +51,18 @@ TRACE_EVENT(drv_start,
 );
 
 TRACE_EVENT(drv_stop,
-	TP_PROTO(struct ieee80211_local *local),
+	TP_PROTO(struct ieee80211_local *local, struct cfg80211_wow *wow),
 
-	TP_ARGS(local),
+	TP_ARGS(local, wow),
 
 	TP_STRUCT__entry(
 		LOCAL_ENTRY
+		__field(u32, triggers_enabled)
 	),
 
 	TP_fast_assign(
 		LOCAL_ASSIGN;
+		__entry->triggers_enabled = wow->triggers_enabled;
 	),
 
 	TP_printk(
net/mac80211/ieee80211_i.h +10 -2
index 6a01771..2ebf56d 100644
@@ -612,6 +612,14 @@ struct ieee80211_local {
 	 */
 	bool quiescing;
 
+	/*
+	 * This will be true if we had enabled PS before going to suspend.
+	 * We use this to help resume restore the PS state to what it was.
+	 * Note that this only makes sense if we're associated and are a
+	 * station.
+	 */
+	bool ps_before_suspend;
+
 	int tx_headroom; /* required headroom for hardware/radiotap */
 
 	/* Tasklet and skb queue to process calls from IRQ mode. All frames
@@ -1035,14 +1043,14 @@ void ieee80211_process_measurement_req(struct ieee80211_sub_if_data *sdata,
 int ieee80211_reconfig(struct ieee80211_local *local);
 
 #ifdef CONFIG_PM
-int __ieee80211_suspend(struct ieee80211_hw *hw);
+int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wow *wow);
 
 static inline int __ieee80211_resume(struct ieee80211_hw *hw)
 {
 	return ieee80211_reconfig(hw_to_local(hw));
 }
 #else
-static inline int __ieee80211_suspend(struct ieee80211_hw *hw)
+static inline int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	return 0;
 }
net/mac80211/iface.c +3 -3
index cadb0f6..b5e1c76 100644
@@ -195,7 +195,7 @@ static int ieee80211_open(struct net_device *dev)
 	 */
 	if (!is_valid_ether_addr(dev->dev_addr)) {
 		if (!local->open_count)
-			drv_stop(local);
+			drv_stop(local, NULL);
 		return -EADDRNOTAVAIL;
 	}
 
@@ -321,7 +321,7 @@ static int ieee80211_open(struct net_device *dev)
 	drv_remove_interface(local, &conf);
  err_stop:
 	if (!local->open_count)
-		drv_stop(local);
+		drv_stop(local, NULL);
  err_del_bss:
 	sdata->bss = NULL;
 	if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
@@ -532,7 +532,7 @@ static int ieee80211_stop(struct net_device *dev)
 	ieee80211_recalc_ps(local, -1);
 
 	if (local->open_count == 0) {
-		drv_stop(local);
+		drv_stop(local, NULL);
 
 		ieee80211_led_radio(local, false);
 
net/mac80211/pm.c +29 -2
index 7a549f9..d1918ad 100644
@@ -6,7 +6,7 @@
 #include "driver-ops.h"
 #include "led.h"
 
-int __ieee80211_suspend(struct ieee80211_hw *hw)
+int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 {
 	struct ieee80211_local *local = hw_to_local(hw);
 	struct ieee80211_sub_if_data *sdata;
@@ -16,6 +16,33 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
 
 	ieee80211_scan_cancel(local);
 
+	local->ps_before_suspend = !!(local->hw.conf.flags & IEEE80211_CONF_PS);
+
+	if (wow->triggers_enabled) {
+		if (!local->ps_before_suspend) {
+			local->hw.conf.flags |= IEEE80211_CONF_PS;
+			ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
+		}
+
+		del_timer_sync(&local->dynamic_ps_timer);
+		cancel_work_sync(&local->dynamic_ps_enable_work);
+
+		list_for_each_entry(sdata, &local->interfaces, list) {
+			struct ieee80211_if_managed *ifmgd;
+
+			if (sdata->vif.type != NL80211_IFTYPE_STATION)
+				continue;
+
+			ifmgd = &sdata->u.mgd;
+			if (!ifmgd->associated)
+				continue;
+
+			if (!local->ps_before_suspend)
+				ieee80211_send_nullfunc(local, sdata, 1);
+		}
+
+	}
+
 	ieee80211_stop_queues_by_reason(hw,
 			IEEE80211_QUEUE_STOP_REASON_SUSPEND);
 
@@ -61,7 +88,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
 	/* stop hardware - this must stop RX */
 	if (local->open_count) {
 		ieee80211_led_radio(local, false);
-		drv_stop(local);
+		drv_stop(local, wow);
 	}
 
 	/* remove STAs */
net/mac80211/util.c +14 -0
index 7fc5584..c6985ce 100644
@@ -970,6 +970,9 @@ int ieee80211_reconfig(struct ieee80211_local *local)
 	 */
 	local->suspended = false;
 
+	if (from_suspend && local->ps_before_suspend)
+		local->hw.conf.flags |= IEEE80211_CONF_PS;
+
 	/* restart hardware */
 	if (local->open_count) {
 		res = drv_start(local);
@@ -1072,6 +1075,17 @@ int ieee80211_reconfig(struct ieee80211_local *local)
 		return 0;
 
 #ifdef CONFIG_PM
+	if (!local->ps_before_suspend) {
+		list_for_each_entry(sdata, &local->interfaces, list) {
+			struct ieee80211_if_managed *ifmgd;
+			if (sdata->vif.type != NL80211_IFTYPE_STATION)
+				continue;
+			ifmgd = &sdata->u.mgd;
+			if (ifmgd->associated)
+				ieee80211_send_nullfunc(local, sdata, 0);
+		}
+	}
+
 	local->suspended = false;
 
 	list_for_each_entry(sdata, &local->interfaces, list) {
Signature · 1 line
1.6.0.6
maintainer
#11 lore raw

PATCH 4/5 mac80211: add WoW support

Quoted 8 lines · Luis R. Rodriguez

If we're associated and have not already gone into PS mode we ensure send a nullfunc frame before going to suspend. Upon resume we ensure we restore PS mode if it was enabled and inform the driver accordingly, also notify the AP we're awake.

WoW requires the radio to be left on during suspend, to do this we inform drivers of the requested wow triggers on the mac80211 stop callback.

I don't think this patch would work if ath9k unprogrammed the hardware correctly in ->remove_interface(), since you don't seem to skip that call.

johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20090715/da7448d6/attachment.pgp

#12 lore raw

PATCH 4/5 mac80211: add WoW support

Quoted 6 lines · Johannes Berg
Quoted 5 lines · Luis R. Rodriguez

If we're associated and have not already gone into PS mode we ensure send a nullfunc frame before going to suspend. Upon resume we ensure we restore PS mode if it was enabled and inform the driver accordingly, also notify the AP we're awake.

Quoted 7 lines
Quoted 3 lines

WoW requires the radio to be left on during suspend, to do this we inform drivers of the requested wow triggers on the mac80211 stop callback.

I don't think this patch would work if ath9k unprogrammed the hardware correctly in ->remove_interface(), since you don't seem to skip that call.

We just stop ANI in remove interface and reclaim beacon resources. As per documentation it seems we are not correctly removing the MAC address in ath9k for the removed interface to stop sending ACKs back. I'd rather see that as a separate patch fix, but you do have a point. As is right now though this doesn't affect WoW.

Luis

maintainer
#13 lore raw

PATCH 4/5 mac80211: add WoW support

Quoted 15 lines · Luis R. Rodriguez
Quoted 6 lines · Johannes Berg
Quoted 5 lines · Luis R. Rodriguez

If we're associated and have not already gone into PS mode we ensure send a nullfunc frame before going to suspend. Upon resume we ensure we restore PS mode if it was enabled and inform the driver accordingly, also notify the AP we're awake.

Quoted 7 lines
Quoted 3 lines

WoW requires the radio to be left on during suspend, to do this we inform drivers of the requested wow triggers on the mac80211 stop callback.

I don't think this patch would work if ath9k unprogrammed the hardware correctly in ->remove_interface(), since you don't seem to skip that call.

Quoted 5 lines

We just stop ANI in remove interface and reclaim beacon resources. As per documentation it seems we are not correctly removing the MAC address in ath9k for the removed interface to stop sending ACKs back. I'd rather see that as a separate patch fix, but you do have a point. As is right now though this doesn't affect WoW.

You haven't understood my point -- it makes your WoW patch invalid because drivers that implement remove_interface properly cannot possibly implement WoW this way.

johannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 801 bytes
Desc: This is a digitally signed message part
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20090715/4405ad17/attachment.pgp

#14 lore raw

PATCH 4/5 mac80211: add WoW support

Quoted 22 lines · Johannes Berg
Quoted 15 lines · Luis R. Rodriguez
Quoted 6 lines · Johannes Berg
Quoted 5 lines · Luis R. Rodriguez

If we're associated and have not already gone into PS mode we ensure send a nullfunc frame before going to suspend. Upon resume we ensure we restore PS mode if it was enabled and inform the driver accordingly, also notify the AP we're awake.

Quoted 7 lines
Quoted 3 lines

WoW requires the radio to be left on during suspend, to do this we inform drivers of the requested wow triggers on the mac80211 stop callback.

I don't think this patch would work if ath9k unprogrammed the hardware correctly in ->remove_interface(), since you don't seem to skip that call.

Quoted 5 lines

We just stop ANI in remove interface and reclaim beacon resources. As per documentation it seems we are not correctly removing the MAC address in ath9k for the removed interface to stop sending ACKs back. I'd rather see that as a separate patch fix, but you do have a point. As is right now though this doesn't affect WoW.

Quoted 3 lines

You haven't understood my point -- it makes your WoW patch invalid because drivers that implement remove_interface properly cannot possibly implement WoW this way.

Ah sure, will respin and add some stuff for this...

Luis

#15 lore raw

PATCH 5/5 ath9k: Add Wake-on-Wireless-LAN support

In reply to Luis R. Rodriguez

This adds WoW suppport for ath9k. Note that not all cards have WoW support available; you also need BIOS support to trigger a wake from the device's PCI PME. We enable only Magic Packet triggers for now, note that if you disconnect you won't get a wake up. Beacon miss and link change triggers need more testing before being enabled.

Tested on AR9280 with Magic Packet.

---
 drivers/net/wireless/ath/ath9k/Makefile   |    1 +
 drivers/net/wireless/ath/ath9k/ath9k.h    |   18 +
 drivers/net/wireless/ath/ath9k/debug.c    |    1 -
 drivers/net/wireless/ath/ath9k/hw.c       |   22 ++
 drivers/net/wireless/ath/ath9k/hw.h       |   21 ++
 drivers/net/wireless/ath/ath9k/initvals.h |   31 ++
 drivers/net/wireless/ath/ath9k/main.c     |   23 ++
 drivers/net/wireless/ath/ath9k/pci.c      |  102 ++++++
 drivers/net/wireless/ath/ath9k/reg.h      |  154 +++++++++
 drivers/net/wireless/ath/ath9k/wow.c      |  511 +++++++++++++++++++++++++++++
 10 files changed, 883 insertions(+), 1 deletions(-)
 create mode 100644 drivers/net/wireless/ath/ath9k/wow.c
drivers/net/wireless/ath/ath9k/Makefile +1 -0
index 783bc39..d4a598d 100644
@@ -14,5 +14,6 @@ ath9k-y +=	hw.o \
 ath9k-$(CONFIG_PCI) += pci.o
 ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o
 ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o
+ath9k-$(CONFIG_PM) += wow.o
 
 obj-$(CONFIG_ATH9K) += ath9k.o
drivers/net/wireless/ath/ath9k/ath9k.h +18 -0
index 1576812..2723385 100644
@@ -604,6 +604,12 @@ struct ath_softc {
 
 	struct ath_ani ani;
 	struct ath9k_node_stats nodestats;
+#ifdef CONFIG_PM
+	bool wow_got_bmiss_intr;
+	bool wow_sleep_proc_intr;
+	u32 wow_intr_before_sleep;
+	u32 wow_triggers_enabled;
+#endif
 #ifdef CONFIG_ATH9K_DEBUG
 	struct ath9k_debug debug;
 #endif
@@ -612,6 +618,18 @@ struct ath_softc {
 	struct delayed_work tx_complete_work;
 };
 
+#ifdef CONFIG_PM
+/*
+ * WoW trigger types
+ */
+#define AH_WOW_USER_PATTERN_EN		0x1
+#define AH_WOW_MAGIC_PATTERN_EN		0x2
+#define AH_WOW_LINK_CHANGE		0x4
+#define AH_WOW_BEACON_MISS		0x8
+#define AH_WOW_MAX_EVENTS		4
+
+#endif
+
 struct ath_wiphy {
 	struct ath_softc *sc; /* shared for all virtual wiphys */
 	struct ieee80211_hw *hw;
drivers/net/wireless/ath/ath9k/debug.c +0 -1
index 9f99f00..8705c35 100644
@@ -486,7 +486,6 @@ static const struct file_operations fops_wiphy = {
 	.owner = THIS_MODULE
 };
 
-
 int ath9k_init_debug(struct ath_softc *sc)
 {
 	sc->debug.debug_mask = ath9k_debug;
drivers/net/wireless/ath/ath9k/hw.c +22 -0
index b9d1a13..3d98f8d 100644
@@ -718,6 +718,12 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
 			ARRAY_SIZE(ar9285PciePhy_clkreq_always_on_L1_9285_1_2),
 				  2);
 		}
+#ifdef CONFIG_PM
+		/* SerDes values during WOW sleep */
+		INIT_INI_ARRAY(&ah->iniPcieSerdesWow,
+			       ar9285PciePhy_AWOW_9285_1_2,
+			       ARRAY_SIZE(ar9285PciePhy_AWOW_9285_1_2), 2);
+#endif
 	} else if (AR_SREV_9285_10_OR_LATER(ah)) {
 		INIT_INI_ARRAY(&ah->iniModes, ar9285Modes_9285,
 			       ARRAY_SIZE(ar9285Modes_9285), 6);
@@ -748,6 +754,12 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
 			       ar9280PciePhy_clkreq_always_on_L1_9280,
 			       ARRAY_SIZE(ar9280PciePhy_clkreq_always_on_L1_9280), 2);
 		}
+#ifdef CONFIG_PM
+		/* SerDes values during WOW sleep */
+		INIT_INI_ARRAY(&ah->iniPcieSerdesWow, ar9280PciePhy_AWOW_9280,
+			       ARRAY_SIZE(ar9280PciePhy_AWOW_9280), 2);
+#endif
+
 		INIT_INI_ARRAY(&ah->iniModesAdditional,
 			       ar9280Modes_fast_clock_9280_2,
 			       ARRAY_SIZE(ar9280Modes_fast_clock_9280_2), 3);
@@ -893,6 +905,16 @@ static struct ath_hw *ath9k_hw_do_attach(u16 devid, struct ath_softc *sc,
 		goto bad;
 	}
 
+#ifdef CONFIG_PM
+	/* WOW */
+	ath9k_wow_set_gpio_reset_low(ah);
+	/* Clear the Wow Status */
+	REG_WRITE(ah, AR_PCIE_PM_CTRL, REG_READ(ah, AR_PCIE_PM_CTRL) |
+		  AR_PMCTRL_WOW_PME_CLR);
+	REG_WRITE(ah, AR_WOW_PATTERN_REG,
+		  AR_WOW_CLEAR_EVENTS(REG_READ(ah, AR_WOW_PATTERN_REG)));
+#endif
+
 	if (AR_SREV_9285(ah))
 		ah->tx_trig_level = (AR_FTRIG_256B >> AR_FTRIG_S);
 	else
drivers/net/wireless/ath/ath9k/hw.h +21 -0
index 9a4570d..6126b99 100644
@@ -520,6 +520,11 @@ struct ath_hw {
 	int initPDADC;
 	int PDADCdelta;
 
+#ifdef CONFIG_PM
+	/* WoW mask -- used to indicate which WoW we have enabled */
+	u32 ah_wowEventMask;
+#endif
+
 	struct ar5416IniArray iniModes;
 	struct ar5416IniArray iniCommon;
 	struct ar5416IniArray iniBank0;
@@ -535,6 +540,10 @@ struct ath_hw {
 	struct ar5416IniArray iniModesAdditional;
 	struct ar5416IniArray iniModesRxGain;
 	struct ar5416IniArray iniModesTxGain;
+#ifdef CONFIG_PM
+	/* SerDes values during WOW sleep */
+	struct ar5416IniArray iniPcieSerdesWow;
+#endif
 };
 
 /* Attach, Detach, Reset */
@@ -613,4 +622,16 @@ enum ath9k_int ath9k_hw_set_interrupts(struct ath_hw *ah, enum ath9k_int ints);
 
 void ath9k_hw_btcoex_enable(struct ath_hw *ah);
 
+#ifdef CONFIG_PM
+
+/* WOW - Wake on Wireless */
+void ath9k_wow_set_gpio_reset_low(struct ath_hw *ah);
+/* Called when going to suspend/hibernate */
+void ath9k_hw_wow_enable(struct ath_hw *ah, u32 patternEnable);
+/* Called when coming back up from suspend/hibernation */
+u32 ath9k_hw_wow_wake_up(struct ath_hw *ah);
+const char *ath9k_hw_wow_event_to_string(u32 wow_event);
+
+#endif /* CONFIG_PM */
+
 #endif
drivers/net/wireless/ath/ath9k/initvals.h +31 -0
index f67a2a9..52e1743 100644
@@ -3439,6 +3439,22 @@ static const u32 ar9280PciePhy_clkreq_always_on_L1_9280[][2] = {
     {0x00004044,  0x00000000 },
 };
 
+#ifdef CONFIG_PM
+/* Auto generated PCI-E PHY config for AR9280 with WOW */
+static const u_int32_t ar9280PciePhy_AWOW_9280[][2] = {
+    {0x00004040,  0x9248fd00 },
+    {0x00004040,  0x24924924 },
+    {0x00004040,  0xa8000019 },
+    {0x00004040,  0x13160820 },
+    {0x00004040,  0xe5980560 },
+    {0x00004040,  0xc01ddffd },
+    {0x00004040,  0x1aaabe41 },
+    {0x00004040,  0xbe105554 },
+    {0x00004040,  0x00043007 },
+    {0x00004044,  0x00000000 },
+};
+#endif
+
 /* AR9285 Revsion 10*/
 static const u_int32_t ar9285Modes_9285[][6] = {
     { 0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160, 0x000001e0 },
@@ -4849,3 +4865,18 @@ static const u_int32_t ar9285PciePhy_clkreq_off_L1_9285_1_2[][2] = {
     {0x00004040,  0x00043007 },
     {0x00004044,  0x00000000 },
 };
+
+#ifdef CONFIG_PM
+static const u_int32_t ar9285PciePhy_AWOW_9285_1_2[][2] = {
+    {0x00004040,  0x9248fd00 },
+    {0x00004040,  0x24924924 },
+    {0x00004040,  0xa8000019 },
+    {0x00004040,  0x13160820 },
+    {0x00004040,  0xe5980560 },
+    {0x00004040,  0xc01ddffd },
+    {0x00004040,  0x1aaabe41 },
+    {0x00004040,  0xbe105554 },
+    {0x00004040,  0x00043007 },
+    {0x00004044,  0x00000000 },
+};
+#endif /* CONFIG_PM */
drivers/net/wireless/ath/ath9k/main.c +23 -0
index f40f2cf..84c0fed 100644
@@ -596,6 +596,20 @@ irqreturn_t ath_isr(int irq, void *dev)
 		ath9k_hw_set_interrupts(ah, sc->imask);
 	}
 
+	if (status & ATH9K_INT_BMISS) {
+#ifdef CONFIG_PM
+		if (sc->wow_sleep_proc_intr) {
+			DPRINTF(sc, (ATH_DBG_ANY | ATH_DBG_INTERRUPT),
+				"during WoW we got a BMISS\n");
+			sc->wow_got_bmiss_intr = true;
+			sc->wow_sleep_proc_intr = false;
+		}
+#else
+		/* BMISS not enabled on ath9k unless WoW is enabled */
+		DPRINTF(sc, ATH_DBG_INTERRUPT,
+			"spurious unattended beacon miss interrupt\n");
+#endif
+	}
 	if (!(ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
 		if (status & ATH9K_INT_TIM_TIMER) {
 			/* Clear RxAbort bit so that we can
@@ -2094,6 +2108,15 @@ static void ath9k_stop(struct ieee80211_hw *hw, struct cfg80211_wow *wow)
 
 	aphy->state = ATH_WIPHY_INACTIVE;
 
+#ifdef CONFIG_PM
+	if (wow && wow->triggers_enabled) {
+		sc->wow_triggers_enabled = wow->triggers_enabled;
+		DPRINTF(sc, ATH_DBG_ANY, "Leaving radio on during "
+			"suspend for WoW\n");
+		return;
+	}
+#endif
+
 	if (sc->sc_flags & SC_OP_INVALID) {
 		DPRINTF(sc, ATH_DBG_ANY, "Device not present\n");
 		return;
drivers/net/wireless/ath/ath9k/pci.c +102 -0

141 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/reg.h +154 -0

164 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/wow.c new file +511 -0

511 lines not on this page · raw message

Signature · 1 line
1.6.0.6