nl80211/cfg80211: adding 'scan_cancel' command.
Subsystems (2)
RFC 1/2 nl80211/cfg80211: adding 'scan_cancel' command.
Mostly from an energy consumption and cpu load perspective, it can be useful to stop a triggered scan earlier, when one finds the desired scan results.
Adding the ability to stop a scan from user space by exposing new NL80211_CMD_SCAN_CANCEL API.
--- include/linux/nl80211.h | 6 ++++++ include/net/cfg80211.h | 2 ++ net/wireless/core.h | 1 + net/wireless/nl80211.c | 13 +++++++++++++ net/wireless/scan.c | 15 +++++++++++++++ 5 files changed, 37 insertions(+), 0 deletions(-)
include/linux/nl80211.h +6 -0
@@ -491,6 +491,11 @@* this command may also be sent by the driver as an MLME event to * inform userspace of the new replay counter. * +* @NL80211_CMD_SCAN_CANCEL: Stop currently running scan (both sw and hw). +* This will eventually call ieee80211_scan_cancel() in mac80211 which +* will clean up scan_req resources. If we try to stop a not running +* scan it will return -ENOENT. +* * @NL80211_CMD_MAX: highest used command number * @__NL80211_CMD_AFTER_LAST: internal use */
@@ -615,6 +620,7 @@ enum nl80211_commands {NL80211_CMD_SET_REKEY_OFFLOAD , + NL80211_CMD_SCAN_CANCEL,/* add new commands above here */ /* used to define NL80211_CMD_MAX below */
include/net/cfg80211.h +2 -0
@@ -1334,6 +1334,7 @@ struct cfg80211_gtk_rekey_data {* @set_ringparam: Set tx and rx ring sizes. * * @get_ringparam: Get tx and rx ring current and maximum sizes. +* @scan_cancel: Stop triggered scan, return 0 if successful. */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy,struct cfg80211_wowlan *wow);
@@ -1516,6 +1517,7 @@ struct cfg80211_ops {int (*set_rekey_data)(struct wiphy *wiphy,struct net_device *dev,struct cfg80211_gtk_rekey_data *data); +void (*scan_cancel)(struct wiphy *wiphy,struct net_device *dev); };/*
net/wireless/core.h +1 -0
@@ -421,6 +421,7 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak);void __cfg80211_sched_scan_results (struct work_struct *wk);int __cfg80211_stop_sched_scan (struct cfg80211_registered_device *rdev,bool driver_initiated); +int cfg80211_scan_cancel (struct cfg80211_registered_device *rdev);void cfg80211_upload_connect_keys (struct wireless_dev *wdev); int cfg80211_change_iface(struct cfg80211_registered_device *rdev, struct net_device *dev, enum nl80211_iftype ntype,
net/wireless/nl80211.c +13 -0
@@ -3641,6 +3641,11 @@ static int nl80211_stop_sched_scan(struct sk_buff *skb,return err; } +static int nl80211_scan_cancel (struct sk_buff *skb,struct genl_info *info) +{ +return cfg80211_scan_cancel (info->user_ptr[0 ]); +} + static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb, u32 seq, int flags, struct cfg80211_registered_device *rdev,
@@ -5759,6 +5764,14 @@ static struct genl_ops nl80211_ops[] = { NL80211_FLAG_NEED_RTNL, }, { + .cmd = NL80211_CMD_SCAN_CANCEL, + .doit = nl80211_scan_cancel, + .policy = nl80211_policy, + .flags = GENL_ADMIN_PERM, + .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_NEED_RTNL, + }, + { .cmd = NL80211_CMD_GET_SCAN, .policy = nl80211_policy, .dumpit = nl80211_dump_scan,
net/wireless/scan.c +15 -0
@@ -155,6 +155,21 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,return 0 ; } +int cfg80211_scan_cancel (struct cfg80211_registered_device *rdev) +{ +struct net_device *dev; + +ASSERT_RDEV_LOCK (rdev); + +if (!rdev->ops->scan_cancel) +return -EOPNOTSUPP ; +if (!rdev->scan_req) +return -ENOENT ; + + dev = rdev->scan_req->dev; + rdev->ops->scan_cancel (&rdev->wiphy, dev); +return 0 ; +}static void bss_release (struct kref *ref) {struct cfg80211_internal_bss *bss;
Signature · 1 line
1.7.0.4
RFC 2/2 mac80211: adding 'scan_cancel' command.
Implementing the scan_cancel operation in the mac80211. Mostly from an energy consumption and cpu load perspective, it can be useful to stop a scan earlier.
--- net/mac80211/cfg.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
net/mac80211/cfg.c +8 -0
@@ -1382,6 +1382,13 @@ ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)return ieee80211_request_sched_scan_stop (sdata); } +static void ieee80211_scan_cancel_req (struct wiphy *wiphy, +struct net_device *dev) +{ +struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); +ieee80211_scan_cancel (sdata->local); +} +static int ieee80211_auth (struct wiphy *wiphy,struct net_device *dev,struct cfg80211_auth_request *req) {
@@ -2151,6 +2158,7 @@ struct cfg80211_ops mac80211_config_ops = { .suspend = ieee80211_suspend, .resume = ieee80211_resume, .scan = ieee80211_scan, + .scan_cancel = ieee80211_scan_cancel_req, .sched_scan_start = ieee80211_sched_scan_start, .sched_scan_stop = ieee80211_sched_scan_stop, .auth = ieee80211_auth,
Signature · 1 line
1.7.0.4
Johannes Berg
maintainerQuoted 5 lines · Victor Goldenshtein
Mostly from an energy consumption and cpu load perspective, it can be useful to stop a triggered scan earlier, when one finds the desired scan results.
Adding the ability to stop a scan from user space by exposing newNL80211_CMD_SCAN_CANCELAPI.
As I said to you privately, I don't think having this API before a partial results notification is useful. Therefore, I don't think this should be merged before a partial results notification patch.
A few comments on the code:
include/linux/nl80211.h line 497
Quoted 9 lines
+++
b/include/linux/nl80211.hinclude/linux/nl80211.h +4
-0@@ -491,6 +491,11 @@* this command may also be sent by the driver as an MLME event to * inform userspace of the new replay counter. * +* @NL80211_CMD_SCAN_CANCEL: Stop currently running scan (both sw and hw). +* This will eventually call ieee80211_scan_cancel() in mac80211 which +* will clean up scan_req resources. If we try to stop a not running +* scan it will return -ENOENT.
You must not mention mac80211 here. You're writing a comment about the implementation, while a comment about the API/semantics is required.
include/linux/nl80211.h enum nl80211_commands { · line 624
Quoted 6 lines
include/linux/nl80211.h +1
-0@@ -615,6 +620,7 @@ enum nl80211_commands {NL80211_CMD_SET_REKEY_OFFLOAD , + NL80211_CMD_SCAN_CANCEL,/* add new commands above here */
Please keep the blank line.
Quoted 14 lines
include/linux/nl80211.h +0
-0/* used to define NL80211_CMD_MAX below */ include/net/cfg80211.h +1
-0@@ -1334,6 +1334,7 @@ struct cfg80211_gtk_rekey_data {* @set_ringparam: Set tx and rx ring sizes. * * @get_ringparam: Get tx and rx ring current and maximum sizes. +* @scan_cancel: Stop triggered scan, return 0 if successful. */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy,struct cfg80211_wowlan *wow);
include/net/cfg80211.h struct cfg80211_ops { · line 1520
Quoted 4 lines
include/net/cfg80211.h +1
-0@@ -1516,6 +1517,7 @@ struct cfg80211_ops {int (*set_rekey_data)(struct wiphy *wiphy,struct net_device *dev,struct cfg80211_gtk_rekey_data *data); +void (*scan_cancel)(struct wiphy *wiphy,struct net_device *dev);
Since this struct isn't ABI it'd be more useful to put the scan_cancel with the scan call.
include/net/cfg80211.h struct cfg80211_ops { · line 1522
Quoted 2 lines
include/net/cfg80211.h +2
-0+ .internal_flags = NL80211_FLAG_NEED_NETDEV_UP | + NL80211_FLAG_NEED_RTNL,
whitespace?
include/net/cfg80211.h struct cfg80211_ops {
Quoted 9 lines
include/net/cfg80211.h +9
-0+if (!rdev->ops->scan_cancel) +return -EOPNOTSUPP ; +if (!rdev->scan_req) +return -ENOENT ; + + dev = rdev->scan_req->dev; + rdev->ops->scan_cancel (&rdev->wiphy, dev); +return 0 ; +}
So ... does this mean the driver is still expected to send a "scan aborted" event? That would be useful to document ... not the mac80211 internals.
johannes