nl80211: add power save commands
Subsystems (2)
RFC PATCH 1/1 nl80211: add power save commands
From: Kalle Valo <[email protected]>
The only missing command from nl80211, which Wireless Extensions had, was support for power save mode. Add a simple command to make it possible to enable and disable power save.
I was also planning about extending the interface, for example adding the timeout value, but after thinking more about this I decided not to do it. Basically there were three reasons.
Firstly, the parameters for power save are very much hardware dependent. Trying to find a unified interface which would work with all hardware, and still make sense to users, will be very difficult.
Secondly, IEEE 802.11 power save implementation in Linux is still in state of flux. We have a long way to still to go and there is no way to predict what kind of implementation we will have after two years. And because we need to support nl80211 interface a long time, practically forever, adding now parameters to nl80211 might create maintenance problems later on.
Third issue is the users. Power save parameters are mostly used for debugging, so debugfs is better, more flexible, interface for this. For example, wpa_supplicant currently doesn't configure anything related to power save mode. It's better to strive that kernel can automatically optimise the power save parameters, like with help of pm qos network and other traffic parameters.
Later on, when we have better understanding of power save, we can extend this command with more features, if there's a need for that.
--- include/linux/nl80211.h | 10 +++ include/net/cfg80211.h | 7 +- net/wireless/core.c | 16 +++-- net/wireless/nl80211.c | 132 ++++++++++++++++++++++++++++++++++++++++++++ net/wireless/wext-compat.c | 10 ++- 5 files changed, 160 insertions(+), 15 deletions(-)
include/linux/nl80211.h +10 -0
@@ -387,6 +387,9 @@ enum nl80211_commands {NL80211_CMD_SET_TX_BITRATE_MASK , +NL80211_CMD_SET_POWER_SAVE , + NL80211_CMD_GET_POWER_SAVE, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -798,6 +801,8 @@ enum nl80211_attrs {NL80211_ATTR_TX_RATES , +NL80211_ATTR_PS_STATE , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -1534,4 +1539,9 @@ enum nl80211_band { NL80211_BAND_5GHZ, }; +enum nl80211_ps_state { +NL80211_PS_DISABLED , +NL80211_PS_ENABLED , +}; +#endif /* __LINUX_NL80211_H */
include/net/cfg80211.h +4 -3
@@ -1144,7 +1144,6 @@ struct cfg80211_ops {struct net_device *dev, u64 cookie); -/* some temporary stuff to finish wext */ int (*set_power_mgmt)(struct wiphy *wiphy,struct net_device *dev,bool enabled,int timeout); };
@@ -1478,6 +1477,9 @@ struct wireless_dev {struct cfg80211_internal_bss *auth_bsses[MAX_AUTH_BSSES ];struct cfg80211_internal_bss *current_bss;/* associated / joined */ +bool ps; +int ps_timeout; + #ifdef CONFIG_CFG80211_WEXT /* wext data */ struct {
@@ -1489,8 +1491,7 @@ struct wireless_dev {u8 bssid[ETH_ALEN ], prev_bssid[ETH_ALEN ];u8 ssid[IEEE80211_MAX_SSID_LEN ];s8 default_key, default_mgmt_key; -bool ps, prev_bssid_valid; - int ps_timeout; + bool prev_bssid_valid; } wext;#endif };
net/wireless/core.c +9 -7
@@ -695,19 +695,21 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, wdev->wext.default_key =-1 ; wdev->wext.default_mgmt_key =-1 ; wdev->wext.connect.auth_type =NL80211_AUTHTYPE_AUTOMATIC ; +#endif +if (wdev->wiphy->flags &WIPHY_FLAG_PS_ON_BY_DEFAULT ) - wdev->wext.ps = true; + wdev->ps = true;else - wdev->wext.ps = false; - wdev->wext.ps_timeout =100 ; + wdev->ps = false; + wdev->ps_timeout =100 ;if (rdev->ops->set_power_mgmt)if (rdev->ops->set_power_mgmt (wdev->wiphy, dev, - wdev->wext.ps, - wdev->wext.ps_timeout)) { + wdev->ps, + wdev->ps_timeout)) {/* assume this means it's off */ - wdev->wext.ps = false; + wdev->ps = false; } -#endif +if (!dev->ethtool_ops) dev->ethtool_ops = &cfg80211_ethtool_ops;
net/wireless/nl80211.c +132 -0
150 lines not on this page · raw message
net/wireless/wext-compat.c +5 -5
@@ -1099,8 +1099,8 @@ int cfg80211_wext_siwpower(struct net_device *dev, {struct wireless_dev *wdev = dev->ieee80211_ptr;struct cfg80211_registered_device *rdev =wiphy_to_dev (wdev->wiphy); -bool ps = wdev->wext.ps; -int timeout = wdev->wext.ps_timeout; +bool ps = wdev->ps; +int timeout = wdev->ps_timeout;int err;if (wdev->iftype !=NL80211_IFTYPE_STATION )
@@ -1133,8 +1133,8 @@ int cfg80211_wext_siwpower(struct net_device *dev,if (err)return err; - wdev->wext.ps = ps; - wdev->wext.ps_timeout = timeout; + wdev->ps = ps; + wdev->ps_timeout = timeout;return 0 ;
@@ -1147,7 +1147,7 @@ int cfg80211_wext_giwpower(struct net_device *dev, {struct wireless_dev *wdev = dev->ieee80211_ptr; - wrq->disabled = !wdev->wext.ps; + wrq->disabled = !wdev->ps;return 0 ; }
RFC PATCH 1/2 iw: update nl80211.h to include power save commands
--- nl80211.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
nl80211.h +10 -0
@@ -387,6 +387,9 @@ enum nl80211_commands {NL80211_CMD_SET_TX_BITRATE_MASK , +NL80211_CMD_SET_POWER_SAVE , + NL80211_CMD_GET_POWER_SAVE, +/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
@@ -798,6 +801,8 @@ enum nl80211_attrs {NL80211_ATTR_TX_RATES , +NL80211_ATTR_PS_STATE , +/* add attributes here, update the policy in nl80211.c */ __NL80211_ATTR_AFTER_LAST,
@@ -1534,4 +1539,9 @@ enum nl80211_band { NL80211_BAND_5GHZ, }; +enum nl80211_ps_state { +NL80211_PS_DISABLED , +NL80211_PS_ENABLED , +}; +#endif /* __LINUX_NL80211_H */
RFC PATCH 2/2 iw: add set/get power_save commands
In reply to Kalle Valo--- Makefile | 2 + ps.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletions(-) create mode 100644 ps.c
Makefile +1 -1
@@ -17,7 +17,7 @@ CFLAGS += -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing OBJS = iw.o genl.o event.o info.o phy.o \ interface.o ibss.o station.o survey.o util.o \ mesh.o mpath.o scan.o reg.o version.o \ - reason.o status.o connect.o link.o offch.o + reason.o status.o connect.o link.o offch.o ps.o OBJS += sections.o ALL = iw
ps.c new file +83 -0
83 lines not on this page · raw message
Quoted 4 lines · Kalle Valo
From: Kalle Valo <[email protected]>
The only missing command from nl80211, which Wireless Extensions had, was support for power save mode.
BTW I actually found another which is missing to be complete to wext:
iwconfig wlan0 txpower 17
I guess I should take care of that since I'm the regulatory dork.
Quoted 2 lines
Add a simple command to make it possible
to enable and disable power save.
Thanks a lot for this.
Luis
Quoted 9 lines · Luis R. Rodriguez
Quoted 4 lines · Kalle Valo
From: Kalle Valo <[email protected]>
The only missing command from nl80211, which Wireless Extensions had, was support for power save mode.
BTW I actually found another which is missing to be complete to wext:
iwconfig wlan0 txpower 17
Oh, good to know. I'll update the commit log to note this.
Quoted 1 line
I guess I should take care of that since I'm the regulatory dork.
It would be great if you can do that. The faster we can get rid of WE the better.
Signature · 1 line
Kalle Valo
Quoted 1 line
The only missing command from nl80211, which Wireless Extensions had,
"iwconfig XXX modulation" ?
Johannes Berg
maintainerQuoted 4 lines · Holger Schurig
Quoted 1 line
The only missing command from nl80211, which Wireless Extensions
had,
"iwconfig XXX modulation" ?
LOL!
But if you wish you can emulate that with rate mask settings. Not in cfg80211 though please.
johannes
Quoted 2 lines
But if you wish you can emulate that with rate mask settings. Not in cfg80211 though please.
No, modulaton != rates.
AFAIK you can run 1 MB/s with both CCK (802.11b) and with OFDM (802.11g), but they generate different wave-forms.
With madwifi cards I had circumstances where the absolute range of CCK was higher than that of OFDM, even when limiting to 1, 2, 5.5, 11 MB/s. This didn't happen in every storage warehouse, but it happens. I don't have a clue why, the theory --- as far as I understand it, which isn't far --- tells me otherwise.
Signature · 1 line
http://www.holgerschurig.de
Johannes Berg
maintainerQuoted 7 lines · Holger Schurig
Quoted 2 lines
But if you wish you can emulate that with rate mask settings. Not in cfg80211 though please.
No, modulaton != rates.
AFAIK you can run 1 MB/s with both CCK (802.11b) and with OFDM (802.11g), but they generate different wave-forms.
No.
johannes
Johannes Berg
maintainerQuoted 10 lines · Johannes Berg
Quoted 7 lines · Holger Schurig
Quoted 2 lines
But if you wish you can emulate that with rate mask settings. Not in cfg80211 though please.
No, modulaton != rates.
AFAIK you can run 1 MB/s with both CCK (802.11b) and with OFDM (802.11g), but they generate different wave-forms.
No.
Well I should qualify. 1 Mbit isn't CCK, it's DSSS. 5.5 and 11 are CCK, or optionally PBCC, but I've seen exactly one AP that might support this (indicated by supporting 22 Mbit, but not 33).
In practice, the only supported rates at least in mac80211 right now are
DSSS: 1 2
CCK: 5.5 11
OFDM: 6 9 ...
The supported preambles would be ERP and DSSS on 2.4 GHz, and OFDM (does that preamble even have a specific name?) on 5 GHz, I think.
johannes
I stand corrected.
Now that you told me so, I was even able to find a reference for this, table 4-5 in
http://books.google.com/books?id=TOuyW0bUoncC&pg=PA189
Signature · 1 line
http://www.holgerschurig.de
Johannes Berg
maintainerQuoted 4 lines · Holger Schurig
Now that you told me so, I was even able to find a reference for this, table 4-5 in
Cool. I dug up some of it from the spec ;)
But maybe we need to go back to your statement about range ...?
johannes
Quoted 3 lines · Holger Schurig
Quoted 1 line
The only missing command from nl80211, which Wireless Extensions had,
"iwconfig XXX modulation" ?
Heh, I didn't even know about that command. I'll add "usable command" to the commit log :)
Signature · 1 line
Kalle Valo
Johannes Berg
maintainernet/wireless/nl80211.c static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = { · line 149
Quoted 4 lines · Kalle Valo
net/wireless/nl80211.c +1
-0[NL80211_ATTR_COOKIE] = { .type = NLA_U64 }, [NL80211_ATTR_TX_RATES] = { .type = NLA_NESTED }, + [NL80211_ATTR_PS_STATE] = { .type = NLA_U8 }, };
Looks good to me, though typically we use NLA_U32 for enums. Should we deviate from that because we won't ever extend this anyway, or should we use NLA_U32 to be more consistent?
johannes
Quoted 10 lines · Johannes Berg
net/wireless/nl80211.c static struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] __read_mostly = { · line 149
Quoted 4 lines · Kalle Valo
net/wireless/nl80211.c +1
-0[NL80211_ATTR_COOKIE] = { .type = NLA_U64 }, [NL80211_ATTR_TX_RATES] = { .type = NLA_NESTED }, + [NL80211_ATTR_PS_STATE] = { .type = NLA_U8 }, };Looks good to me, though typically we use
NLA_U32for enums. Should we deviate from that because we won't ever extend this anyway, or should we useNLA_U32to be more consistent?
Good point. In my opinion we should definitely use u32 for consistency, there's no real reason to use u8 here. If it's ok for you, I'll send v2 later today which uses u32.
Thank you for the review.
Signature · 1 line
Kalle Valo