From: Stanislaw Gruszka <sgruszka@redhat.com>
To: Arend van Spriel <arend@broadcom.com>
Cc: linux-wireless@vger.kernel.org,
Johannes Berg <johannes@sipsolutions.net>
Subject: [PATCH v2] cfg80211: allow to configure dynamic PS timeout
Date: Wed, 1 Oct 2014 11:27:10 +0200 [thread overview]
Message-ID: <20141001092710.GB2011@redhat.com> (raw)
In-Reply-To: <542AB893.9090201@broadcom.com>
Dynamic power save timeout value is suppose to be configurable via
wext, but due to iwconfig bug is not possible to set using that tool.
Allow to configure PS timeout via nl80211 - add NL80211_ATTR_PS_TIMEOUT
attribute which become timeout stated in ms.
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
v1 -> v2 : add documentation.
include/uapi/linux/nl80211.h | 5 +++++
net/wireless/nl80211.c | 21 +++++++++++++++++----
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 4b28dc0..66a9ba8 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1638,6 +1638,9 @@ enum nl80211_commands {
* @NL80211_ATTR_SMPS_MODE: SMPS mode to use (ap mode). see
* &enum nl80211_smps_mode.
*
+ * @NL80211_ATTR_PS_TIMEOUT: Dynamic power save timeout value in miliseconds.
+ * Special value -1 means driver default.
+ *
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
*/
@@ -1990,6 +1993,8 @@ enum nl80211_attrs {
NL80211_ATTR_SMPS_MODE,
+ NL80211_ATTR_PS_TIMEOUT,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index cb9f5a4..39ee3c7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -7991,7 +7991,7 @@ static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info)
struct net_device *dev = info->user_ptr[1];
u8 ps_state;
bool state;
- int err;
+ int err, ps_timeout;
if (!info->attrs[NL80211_ATTR_PS_STATE])
return -EINVAL;
@@ -8003,17 +8003,27 @@ static int nl80211_set_power_save(struct sk_buff *skb, struct genl_info *info)
wdev = dev->ieee80211_ptr;
+ if (info->attrs[NL80211_ATTR_PS_TIMEOUT]) {
+ ps_timeout = nla_get_s32(info->attrs[NL80211_ATTR_PS_TIMEOUT]);
+ if (ps_timeout < 0 && ps_timeout != -1)
+ return -EINVAL;
+ } else {
+ ps_timeout = wdev->ps_timeout;
+ }
+
if (!rdev->ops->set_power_mgmt)
return -EOPNOTSUPP;
state = (ps_state == NL80211_PS_ENABLED) ? true : false;
- if (state == wdev->ps)
+ if (state == wdev->ps && ps_timeout == wdev->ps_timeout)
return 0;
- err = rdev_set_power_mgmt(rdev, dev, state, wdev->ps_timeout);
- if (!err)
+ err = rdev_set_power_mgmt(rdev, dev, state, ps_timeout);
+ if (!err) {
wdev->ps = state;
+ wdev->ps_timeout = ps_timeout;
+ }
return err;
}
@@ -8051,6 +8061,9 @@ static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info)
if (nla_put_u32(msg, NL80211_ATTR_PS_STATE, ps_state))
goto nla_put_failure;
+ if (nla_put_s32(msg, NL80211_ATTR_PS_TIMEOUT, wdev->ps_timeout))
+ goto nla_put_failure;
+
genlmsg_end(msg, hdr);
return genlmsg_reply(msg, info);
--
1.8.3.1
next prev parent reply other threads:[~2014-10-01 9:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-30 13:18 [PATCH] cfg80211: allow to configure dynamic PS timeout Stanislaw Gruszka
2014-09-30 14:04 ` Arend van Spriel
2014-09-30 14:05 ` Arend van Spriel
2014-10-01 9:27 ` Stanislaw Gruszka [this message]
2014-10-06 15:00 ` [PATCH v2] " Johannes Berg
2014-10-07 11:03 ` Stanislaw Gruszka
2014-10-07 12:05 ` Johannes Berg
2014-10-07 12:32 ` Krishna Chaitanya
2014-10-07 12:47 ` Johannes Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141001092710.GB2011@redhat.com \
--to=sgruszka@redhat.com \
--cc=arend@broadcom.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).