Skip to contentSkip to conversation

mac80211: refactor dynamic power save check

PATCH In review Kalle Valo 2 participants 6 messages Oct 27, 2009

Subsystems (2)
lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

PATCH v2 1/3 mac80211: refactor dynamic power save check

From: Kalle Valo <[email protected]>

Refactor dynamic power save checks to a function of it's own for better readibility. No functional changes.

---

 net/mac80211/tx.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)
net/mac80211/tx.c +21 -3
index db4bda6..c59ed84 100644
@@ -1387,6 +1387,26 @@ static int ieee80211_skb_resize(struct ieee80211_local *local,
 	return 0;
 }
 
+static bool need_dynamic_ps(struct ieee80211_local *local)
+{
+	/* driver doesn't support power save */
+	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+		return false;
+
+	/* dynamic power save disabled */
+	if (local->hw.conf.dynamic_ps_timeout <= 0)
+		return false;
+
+	/* we are scanning, don't enable power save */
+	if (local->scanning)
+		return false;
+
+	if (!local->ps_sdata)
+		return false;
+
+	return true;
+}
+
 static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
 			   struct sk_buff *skb)
 {
@@ -1399,9 +1419,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
 
 	dev_hold(sdata->dev);
 
-	if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
-	    local->hw.conf.dynamic_ps_timeout > 0 &&
-	    !(local->scanning) && local->ps_sdata) {
+	if (need_dynamic_ps(local)) {
 		if (local->hw.conf.flags & IEEE80211_CONF_PS) {
 			ieee80211_stop_queues_by_reason(&local->hw,
 					IEEE80211_QUEUE_STOP_REASON_PS);
author
#1 lore raw

PATCH v2 2/3 mac80211: fix dynamic power save for devices with nullfunc support in hw

From: Kalle Valo <[email protected]>

In TX path it was assumed that dynamic power save works only if IEEE80211_HW_PS_NULLFUNC_STACK is set. But is not the case, there are devices which have nullfunc support in hardware but need mac80211 to handle dynamic power save timers, TI's wl1251 is one of them.

The fix is to not check for IEEE80211_HW_PS_NULLFUNC_STACK in is_dynamic_ps_enabled(), instead check IEEE80211_HW_SUPPORTS_PS and IEEE80211_HW_SUPPORTS_DYNAMIC_PS flags and act accordingly.

Tested with wl1251.

---

 net/mac80211/tx.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
net/mac80211/tx.c +5 -1
index c59ed84..66dab40 100644
@@ -1390,7 +1390,11 @@ static int ieee80211_skb_resize(struct ieee80211_local *local,
 static bool need_dynamic_ps(struct ieee80211_local *local)
 {
 	/* driver doesn't support power save */
-	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+	if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
+		return false;
+
+	/* hardware does dynamic power save */
+	if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
 		return false;
 
 	/* dynamic power save disabled */
maintainer Acked-by on v2 2/3
#2 lore raw

Re: [PATCH v2 2/3] mac80211: fix dynamic power save for devices with nullfunc support in hw

Quoted 7 lines · Kalle Valo

From: Kalle Valo <[email protected]>

In TX path it was assumed that dynamic power save works only if IEEE80211_HW_PS_NULLFUNC_STACK is set. But is not the case, there are devices which have nullfunc support in hardware but need mac80211 to handle dynamic power save timers, TI's wl1251 is one of them.

Quoted 7 lines

The fix is to not check for IEEE80211_HW_PS_NULLFUNC_STACK in is_dynamic_ps_enabled(), instead check IEEE80211_HW_SUPPORTS_PS and IEEE80211_HW_SUPPORTS_DYNAMIC_PS flags and act accordingly.

Tested with wl1251.

Quoted 24 lines

---

 net/mac80211/tx.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
net/mac80211/tx.c +5 -1
index c59ed84..66dab40 100644
@@ -1390,7 +1390,11 @@ static int ieee80211_skb_resize(struct ieee80211_local *local,
 static bool need_dynamic_ps(struct ieee80211_local *local)
 {
 	/* driver doesn't support power save */
-	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+	if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
+		return false;
+
+	/* hardware does dynamic power save */
+	if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
 		return false;
 
 	/* dynamic power save disabled */
author
#3 lore raw

Re: [PATCH v2 2/3] mac80211: fix dynamic power save for devices with nullfunc support in hw

Quoted 12 lines · Johannes Berg
Quoted 11 lines · Kalle Valo

From: Kalle Valo <[email protected]>

In TX path it was assumed that dynamic power save works only if IEEE80211_HW_PS_NULLFUNC_STACK is set. But is not the case, there are devices which have nullfunc support in hardware but need mac80211 to handle dynamic power save timers, TI's wl1251 is one of them.

The fix is to not check for IEEE80211_HW_PS_NULLFUNC_STACK in is_dynamic_ps_enabled(), instead check IEEE80211_HW_SUPPORTS_PS and IEEE80211_HW_SUPPORTS_DYNAMIC_PS flags and act accordingly.

Quoted 5 lines
Quoted 3 lines

Tested with wl1251.

Thanks!

For the record, I sent v1 back in August:

http://www.spinics.net/lists/linux-wireless/msg37717.html

Better late than ever :)

Signature · 1 line
Kalle Valo
author
#4 lore raw

PATCH v2 3/3 wl1251: enable power save

In reply to Kalle Valo

From: Kalle Valo <[email protected]>

wl1251 supports power save and it can be enabled now.

---

 drivers/net/wireless/wl12xx/wl1251_main.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/wireless/wl12xx/wl1251_main.c +2 -1
index ec01e9d..60a337a 100644
@@ -1311,7 +1311,8 @@ int wl1251_init_ieee80211(struct wl1251 *wl)
 	wl->hw->channel_change_time = 10000;
 
 	wl->hw->flags = IEEE80211_HW_SIGNAL_DBM |
-		IEEE80211_HW_NOISE_DBM;
+		IEEE80211_HW_NOISE_DBM |
+		IEEE80211_HW_SUPPORTS_PS;
 
 	wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
 	wl->hw->wiphy->max_scan_ssids = 1;
maintainer Reviewed-by on v2 1/3
#5 lore raw
In reply to Kalle Valo
Quoted 6 lines · Kalle Valo

From: Kalle Valo <[email protected]>

Refactor dynamic power save checks to a function of it's own for better readibility. No functional changes.

Quoted 49 lines

---

 net/mac80211/tx.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)
net/mac80211/tx.c +21 -3
index db4bda6..c59ed84 100644
@@ -1387,6 +1387,26 @@ static int ieee80211_skb_resize(struct ieee80211_local *local,
 	return 0;
 }
 
+static bool need_dynamic_ps(struct ieee80211_local *local)
+{
+	/* driver doesn't support power save */
+	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+		return false;
+
+	/* dynamic power save disabled */
+	if (local->hw.conf.dynamic_ps_timeout <= 0)
+		return false;
+
+	/* we are scanning, don't enable power save */
+	if (local->scanning)
+		return false;
+
+	if (!local->ps_sdata)
+		return false;
+
+	return true;
+}
+
 static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
 			   struct sk_buff *skb)
 {
@@ -1399,9 +1419,7 @@ static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
 
 	dev_hold(sdata->dev);
 
-	if ((local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK) &&
-	    local->hw.conf.dynamic_ps_timeout > 0 &&
-	    !(local->scanning) && local->ps_sdata) {
+	if (need_dynamic_ps(local)) {
 		if (local->hw.conf.flags & IEEE80211_CONF_PS) {
 			ieee80211_stop_queues_by_reason(&local->hw,
 					IEEE80211_QUEUE_STOP_REASON_PS);