mac80211: implement dynamic power save
This patch implements dynamic power save for mac80211. Basically it means enabling power save mode after an idle period. Implementing it dynamically gives a good compromise of low power consumption and low latency. Some hardware have support for this in firmware, but some require the host to do it. The dynamic power save is implemented by adding an timeout to ieee80211_subif_start_xmit(). The timeout can be enabled from userspace with Wireless Extensions. For example, the command below enables the dynamic power save and sets the time timeout to 500 ms: iwconfig wlan0 power timeout 500m Power save now only works with devices which handle power save in firmware. It's also disabled by default and the heuristics when and how to enable is considered as a policy decision and will be left for the userspace to handle. In case the firmware has support for this, drivers can disable this feature with IEEE80211_HW_NO_STACK_DYNAMIC_PS. Big thanks to Johannes Berg for the help with the design and code. Signed-off-by: Kalle Valo <kalle.valo@nokia.com> Acked-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
committed by
John W. Linville
parent
ce7c9111a9
commit
520eb82076
@ -833,7 +833,7 @@ static int ieee80211_ioctl_siwpower(struct net_device *dev,
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
||||
struct ieee80211_conf *conf = &local->hw.conf;
|
||||
int ret = 0;
|
||||
int ret = 0, timeout = 0;
|
||||
bool ps;
|
||||
|
||||
if (sdata->vif.type != NL80211_IFTYPE_STATION)
|
||||
@ -841,6 +841,7 @@ static int ieee80211_ioctl_siwpower(struct net_device *dev,
|
||||
|
||||
if (wrq->disabled) {
|
||||
ps = false;
|
||||
timeout = 0;
|
||||
goto set;
|
||||
}
|
||||
|
||||
@ -850,22 +851,31 @@ static int ieee80211_ioctl_siwpower(struct net_device *dev,
|
||||
case IW_POWER_ALL_R: /* If explicitely state all */
|
||||
ps = true;
|
||||
break;
|
||||
default: /* Otherwise we don't support it */
|
||||
return -EINVAL;
|
||||
default: /* Otherwise we ignore */
|
||||
break;
|
||||
}
|
||||
|
||||
if (ps == local->powersave)
|
||||
return ret;
|
||||
if (wrq->flags & IW_POWER_TIMEOUT)
|
||||
timeout = wrq->value / 1000;
|
||||
|
||||
set:
|
||||
if (ps == local->powersave && timeout == local->dynamic_ps_timeout)
|
||||
return ret;
|
||||
|
||||
local->powersave = ps;
|
||||
local->dynamic_ps_timeout = timeout;
|
||||
|
||||
if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) {
|
||||
if (local->powersave)
|
||||
conf->flags |= IEEE80211_CONF_PS;
|
||||
else
|
||||
conf->flags &= ~IEEE80211_CONF_PS;
|
||||
|
||||
if (!(local->hw.flags & IEEE80211_HW_NO_STACK_DYNAMIC_PS) &&
|
||||
local->dynamic_ps_timeout > 0)
|
||||
mod_timer(&local->dynamic_ps_timer, jiffies +
|
||||
msecs_to_jiffies(local->dynamic_ps_timeout));
|
||||
else {
|
||||
if (local->powersave)
|
||||
conf->flags |= IEEE80211_CONF_PS;
|
||||
else
|
||||
conf->flags &= ~IEEE80211_CONF_PS;
|
||||
}
|
||||
ret = ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user