Skip to contentSkip to conversation

mac80211: refactor dynamic power save check

PATCH Superseded Kalle Valo 2 participants 5 messages Aug 12, 2009

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kalle Valo

author
#0 lore raw

PATCH 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 10a1099..03005f9 100644
@@ -1384,6 +1384,26 @@ static int ieee80211_skb_resize(struct ieee80211_local *local,
 	return 0;
 }
 
+static bool is_dynamic_ps_enabled(struct ieee80211_local *local)
+{
+	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+		/* driver doesn't support power save */
+		return false;
+
+	if (local->hw.conf.dynamic_ps_timeout <= 0)
+		/* dynamic power save disabled */
+		return false;
+
+	if (local->scanning)
+		/* we are scanning, don't enable power save */
+		return false;
+
+	if (!local->ps_sdata)
+		return false;
+
+	return true;
+}
+
 static void ieee80211_xmit(struct ieee80211_sub_if_data *sdata,
 			   struct sk_buff *skb)
 {
@@ -1396,9 +1416,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 (is_dynamic_ps_enabled(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 2/3 mac80211: fix dynamic power save for devices which have nullfunc support

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 |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
net/mac80211/tx.c +6 -1
index 03005f9..0e7273c 100644
@@ -1386,10 +1386,15 @@ static int ieee80211_skb_resize(struct ieee80211_local *local,
 
 static bool is_dynamic_ps_enabled(struct ieee80211_local *local)
 {
-	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+
+	if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
 		/* driver doesn't support power save */
 		return false;
 
+	if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
+		/* hardware does dynamic power save */
+		return false;
+
 	if (local->hw.conf.dynamic_ps_timeout <= 0)
 		/* dynamic power save disabled */
 		return false;
author
#4 lore raw

PATCH 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 7148934..72e2dc9 100644
@@ -1310,7 +1310,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
#2 lore raw

Re: [PATCH 2/3] mac80211: fix dynamic power save for devices which have nullfunc support

In reply to Kalle Valo

net/mac80211/tx.c static int ieee80211_skb_resize(struct ieee80211_local *local, · line 1392

Quoted 7 lines · Kalle Valo

static bool is_dynamic_ps_enabled(struct ieee80211_local *local) {

net/mac80211/tx.c +2 -1
-	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+
+	if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
 		/* driver doesn't support power save */
 		return false;

Why the blank line?

net/mac80211/tx.c static int ieee80211_skb_resize(struct ieee80211_local *local, · line 1396

Quoted 3 lines
net/mac80211/tx.c +3 -0
+	if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
+		/* hardware does dynamic power save */
+		return false;

FWIW, also applies to patch 1, I think I prefer

	/* check if hardware does dynamic power save */
	if (local->hw.flags & ...)
		return false;

(wrt. comment location)

and you should probably rename the function to do_software_dynamic_ps() or something like that?

johannes

author
#3 lore raw

Re: [PATCH 2/3] mac80211: fix dynamic power save for devices which have nullfunc support

Quoted 11 lines · Johannes Berg

net/mac80211/tx.c static int ieee80211_skb_resize(struct ieee80211_local *local, · line 1392

Quoted 7 lines · Kalle Valo

static bool is_dynamic_ps_enabled(struct ieee80211_local *local) {

net/mac80211/tx.c +2 -1
-	if (!(local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK))
+
+	if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
 		/* driver doesn't support power save */
 		return false;

Why the blank line?

A mistake, will remove.

Quoted 11 lines

net/mac80211/tx.c static int ieee80211_skb_resize(struct ieee80211_local *local, · line 1396

Quoted 3 lines
net/mac80211/tx.c +3 -0
+	if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
+		/* hardware does dynamic power save */
+		return false;

FWIW, also applies to patch 1, I think I prefer

	/* check if hardware does dynamic power save */
	if (local->hw.flags & ...)
		return false;

(wrt. comment location)

I'll change that.

Quoted 2 lines

and you should probably rename the function to do_software_dynamic_ps() or something like that?

I had problems coming up with a good name. "do" in a sense is confusing because the function only checks the state, it doesn't have any code to change the timer or anything like that. I'll think of this a bit more. Suggestions are welcome.

I'll send v2 later this week. John, please drop these three patches.

Signature · 1 line
Kalle Valo