mac80211: refactor dynamic power save check
Subsystems (2)
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
@@ -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 );
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
@@ -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 */
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_STACKis 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_STACKinis_dynamic_ps_enabled(), instead checkIEEE80211_HW_SUPPORTS_PSandIEEE80211_HW_SUPPORTS_DYNAMIC_PSflags and act accordingly.Tested with wl1251.
Signed-off-by Kalle Valo <[email protected]>
Quoted 24 lines
---
net/mac80211/tx.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)net/mac80211/tx.c +5
-1@@ -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 */
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_STACKis 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_STACKinis_dynamic_ps_enabled(), instead checkIEEE80211_HW_SUPPORTS_PSandIEEE80211_HW_SUPPORTS_DYNAMIC_PSflags and act accordingly.
Quoted 5 lines
Quoted 3 lines
Tested with wl1251.
Signed-off-by Kalle Valo <[email protected]>Acked-by Johannes Berg <[email protected]>
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
PATCH v2 3/3 wl1251: enable power save
In reply to Kalle ValoFrom: 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
@@ -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 ;
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.
Signed-off-by Kalle Valo <[email protected]>
Quoted 49 lines
---
net/mac80211/tx.c | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-)net/mac80211/tx.c +21
-3@@ -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 );