diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2009-07-01 15:26:57 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-10 15:01:51 -0400 |
commit | bc92afd92088ab41223383cc6863ab4792533c54 (patch) | |
tree | a31d14843f5a63a4a4561bb2ac59e83f4550433c /net/wireless | |
parent | f21293549f60f88c74fcb9944737f11048896dc4 (diff) |
cfg80211: implement iwpower
Just on/off and timeout, and with a hacky cfg80211 method
until we figure out what we want, though this is probably
sufficient as we want to use pm_qos for wifi everywhere.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless')
-rw-r--r-- | net/wireless/Kconfig | 16 | ||||
-rw-r--r-- | net/wireless/core.c | 11 | ||||
-rw-r--r-- | net/wireless/wext-compat.c | 60 |
3 files changed, 86 insertions, 1 deletions
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index 040263118a20..c6031d5b135f 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig | |||
@@ -26,6 +26,22 @@ config CFG80211_REG_DEBUG | |||
26 | 26 | ||
27 | If unsure, say N. | 27 | If unsure, say N. |
28 | 28 | ||
29 | config CFG80211_DEFAULT_PS | ||
30 | bool "enable powersave by default" | ||
31 | depends on CFG80211 | ||
32 | default y | ||
33 | help | ||
34 | This option enables powersave mode by default. | ||
35 | |||
36 | If this causes your applications to misbehave you should fix your | ||
37 | applications instead -- they need to register their network | ||
38 | latency requirement, see Documentation/power/pm_qos_interface.txt. | ||
39 | |||
40 | config CFG80211_DEFAULT_PS_VALUE | ||
41 | int | ||
42 | default 1 if CFG80211_DEFAULT_PS | ||
43 | default 0 | ||
44 | |||
29 | config CFG80211_DEBUGFS | 45 | config CFG80211_DEBUGFS |
30 | bool "cfg80211 DebugFS entries" | 46 | bool "cfg80211 DebugFS entries" |
31 | depends on CFG80211 && DEBUG_FS | 47 | depends on CFG80211 && DEBUG_FS |
diff --git a/net/wireless/core.c b/net/wireless/core.c index e2f80dd0e4a6..413d291d07d7 100644 --- a/net/wireless/core.c +++ b/net/wireless/core.c | |||
@@ -550,12 +550,21 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, | |||
550 | } | 550 | } |
551 | wdev->netdev = dev; | 551 | wdev->netdev = dev; |
552 | wdev->sme_state = CFG80211_SME_IDLE; | 552 | wdev->sme_state = CFG80211_SME_IDLE; |
553 | mutex_unlock(&rdev->devlist_mtx); | ||
553 | #ifdef CONFIG_WIRELESS_EXT | 554 | #ifdef CONFIG_WIRELESS_EXT |
554 | wdev->wext.default_key = -1; | 555 | wdev->wext.default_key = -1; |
555 | wdev->wext.default_mgmt_key = -1; | 556 | wdev->wext.default_mgmt_key = -1; |
556 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; | 557 | wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC; |
558 | wdev->wext.ps = CONFIG_CFG80211_DEFAULT_PS_VALUE; | ||
559 | wdev->wext.ps_timeout = 500; | ||
560 | if (rdev->ops->set_power_mgmt) | ||
561 | if (rdev->ops->set_power_mgmt(wdev->wiphy, dev, | ||
562 | wdev->wext.ps, | ||
563 | wdev->wext.ps_timeout)) { | ||
564 | /* assume this means it's off */ | ||
565 | wdev->wext.ps = false; | ||
566 | } | ||
557 | #endif | 567 | #endif |
558 | mutex_unlock(&rdev->devlist_mtx); | ||
559 | break; | 568 | break; |
560 | case NETDEV_GOING_DOWN: | 569 | case NETDEV_GOING_DOWN: |
561 | if (!wdev->ssid_len) | 570 | if (!wdev->ssid_len) |
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c index 02f052fc1808..2e1ab78fb0d7 100644 --- a/net/wireless/wext-compat.c +++ b/net/wireless/wext-compat.c | |||
@@ -987,3 +987,63 @@ int cfg80211_wext_giwauth(struct net_device *dev, | |||
987 | return -EOPNOTSUPP; | 987 | return -EOPNOTSUPP; |
988 | } | 988 | } |
989 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwauth); | 989 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwauth); |
990 | |||
991 | int cfg80211_wext_siwpower(struct net_device *dev, | ||
992 | struct iw_request_info *info, | ||
993 | struct iw_param *wrq, char *extra) | ||
994 | { | ||
995 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
996 | struct cfg80211_registered_device *rdev = wiphy_to_dev(wdev->wiphy); | ||
997 | bool ps = wdev->wext.ps; | ||
998 | int timeout = wdev->wext.ps_timeout; | ||
999 | int err; | ||
1000 | |||
1001 | if (wdev->iftype != NL80211_IFTYPE_STATION) | ||
1002 | return -EINVAL; | ||
1003 | |||
1004 | if (!rdev->ops->set_power_mgmt) | ||
1005 | return -EOPNOTSUPP; | ||
1006 | |||
1007 | if (wrq->disabled) { | ||
1008 | ps = false; | ||
1009 | } else { | ||
1010 | switch (wrq->flags & IW_POWER_MODE) { | ||
1011 | case IW_POWER_ON: /* If not specified */ | ||
1012 | case IW_POWER_MODE: /* If set all mask */ | ||
1013 | case IW_POWER_ALL_R: /* If explicitely state all */ | ||
1014 | ps = true; | ||
1015 | break; | ||
1016 | default: /* Otherwise we ignore */ | ||
1017 | return -EINVAL; | ||
1018 | } | ||
1019 | |||
1020 | if (wrq->flags & ~(IW_POWER_MODE | IW_POWER_TIMEOUT)) | ||
1021 | return -EINVAL; | ||
1022 | |||
1023 | if (wrq->flags & IW_POWER_TIMEOUT) | ||
1024 | timeout = wrq->value / 1000; | ||
1025 | } | ||
1026 | |||
1027 | err = rdev->ops->set_power_mgmt(wdev->wiphy, dev, ps, timeout); | ||
1028 | if (err) | ||
1029 | return err; | ||
1030 | |||
1031 | wdev->wext.ps = ps; | ||
1032 | wdev->wext.ps_timeout = timeout; | ||
1033 | |||
1034 | return 0; | ||
1035 | |||
1036 | } | ||
1037 | EXPORT_SYMBOL_GPL(cfg80211_wext_siwpower); | ||
1038 | |||
1039 | int cfg80211_wext_giwpower(struct net_device *dev, | ||
1040 | struct iw_request_info *info, | ||
1041 | struct iw_param *wrq, char *extra) | ||
1042 | { | ||
1043 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
1044 | |||
1045 | wrq->disabled = !wdev->wext.ps; | ||
1046 | |||
1047 | return 0; | ||
1048 | } | ||
1049 | EXPORT_SYMBOL_GPL(cfg80211_wext_giwpower); | ||