Linux wireless drivers development
 help / color / mirror / Atom feed
* [PATCH v3 0/5] add scan flags support
@ 2012-10-04  4:47 Bing Zhao
  2012-10-04  4:47 ` [PATCH v3 1/5] {nl,cfg}80211: add a flags word to scan requests Bing Zhao
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Bing Zhao @ 2012-10-04  4:47 UTC (permalink / raw)
  To: linux-wireless
  Cc: Johannes Berg, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang, Bing Zhao

This is the v3 series prepared by Amitkumar Karwar.

1/5: Remove unnecessary "enum cfg80211_scan_flags" (Johannes Berg)
     Add missing check for "nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS"
     (Johannes Berg)

2/5: Add WIPHY_FLAG_LOW_PRIORITY_SCAN flag so that device can advertise
     low priority scan capability. An error will be returned to the
     application if device doesn't support this feature.
     Flush scan table feature is by default enabled.
     (Johannes Berg)

3/5, 4/5: Rearrange the code to avoid static forward declarations.
     (Johannes Berg)

5/5: Removed use of unlikely() macro (Johannes Berg)
     Advertise low priority scan capability (Johannes Berg)

---
Amitkumar Karwar (1):
  cfg80211: code rearrangement to avoid forward declarations

Sam Leffler (4):
  {nl,cfg}80211: add a flags word to scan requests
  cfg80211: add scan flag to indicate its priority
  cfg80211: add support for flushing old scan results
  mac80211: add support for tx to abort low priority scan requests

 include/linux/nl80211.h    |   19 +++++++
 include/net/cfg80211.h     |    9 +++
 net/mac80211/ieee80211_i.h |    2 +
 net/mac80211/main.c        |    3 +-
 net/mac80211/scan.c        |   21 ++++++--
 net/wireless/nl80211.c     |   22 ++++++++
 net/wireless/scan.c        |  119 ++++++++++++++++++++++++++-----------------
 net/wireless/sme.c         |    1 +
 8 files changed, 144 insertions(+), 52 deletions(-)


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 1/5] {nl,cfg}80211: add a flags word to scan requests
  2012-10-04  4:47 [PATCH v3 0/5] add scan flags support Bing Zhao
@ 2012-10-04  4:47 ` Bing Zhao
  2012-10-04  4:47 ` [PATCH v3 2/5] cfg80211: add scan flag to indicate its priority Bing Zhao
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Bing Zhao @ 2012-10-04  4:47 UTC (permalink / raw)
  To: linux-wireless
  Cc: Johannes Berg, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang, Bing Zhao

From: Sam Leffler <sleffler@chromium.org>

Add a flags word to direct and scheduled scan requests; it will
be used for control of optional behaviours such as flushing the
bss cache prior to doing a scan.

Signed-off-by: Sam Leffler <sleffler@chromium.org>
Tested-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
v3: Remove unnecessary "enum cfg80211_scan_flags" and add missing
    check for "nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS...".
    (Johannes Berg)

 include/linux/nl80211.h |   14 ++++++++++++++
 include/net/cfg80211.h  |    4 ++++
 net/wireless/nl80211.c  |   12 ++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index 179a0c2..bac473a 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -1276,6 +1276,8 @@ enum nl80211_commands {
  * @NL80211_ATTR_SAE_DATA: SAE elements in Authentication frames. This starts
  *	with the Authentication transaction sequence number field.
  *
+ * @NL80211_ATTR_SCAN_FLAGS: scan request control flags (u32)
+ *
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
  */
@@ -1535,6 +1537,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_SAE_DATA,
 
+	NL80211_ATTR_SCAN_FLAGS,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -3080,4 +3084,14 @@ enum nl80211_connect_failed_reason {
 	NL80211_CONN_FAIL_BLOCKED_CLIENT,
 };
 
+/**
+ * enum nl80211_scan_flags -  scan request control flags
+ *
+ * Scan request control flags are used to control the handling
+ * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
+ * requests.
+ */
+enum nl80211_scan_flags {
+};
+
 #endif /* __LINUX_NL80211_H */
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 04df773..7c70e99 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1000,6 +1000,7 @@ struct cfg80211_ssid {
  * @n_channels: total number of channels to scan
  * @ie: optional information element(s) to add into Probe Request or %NULL
  * @ie_len: length of ie in octets
+ * @flags: bit field of flags controlling operation
  * @rates: bitmap of rates to advertise for each band
  * @wiphy: the wiphy this was for
  * @wdev: the wireless device to scan for
@@ -1012,6 +1013,7 @@ struct cfg80211_scan_request {
 	u32 n_channels;
 	const u8 *ie;
 	size_t ie_len;
+	u32 flags;
 
 	u32 rates[IEEE80211_NUM_BANDS];
 
@@ -1044,6 +1046,7 @@ struct cfg80211_match_set {
  * @interval: interval between each scheduled scan cycle
  * @ie: optional information element(s) to add into Probe Request or %NULL
  * @ie_len: length of ie in octets
+ * @flags: bit field of flags controlling operation
  * @match_sets: sets of parameters to be matched for a scan result
  * 	entry to be considered valid and to be passed to the host
  * 	(others are filtered out).
@@ -1061,6 +1064,7 @@ struct cfg80211_sched_scan_request {
 	u32 interval;
 	const u8 *ie;
 	size_t ie_len;
+	u32 flags;
 	struct cfg80211_match_set *match_sets;
 	int n_match_sets;
 	s32 rssi_thold;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 746f649..714e46d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -355,6 +355,7 @@ static const struct nla_policy nl80211_policy[NL80211_ATTR_MAX+1] = {
 	[NL80211_ATTR_WDEV] = { .type = NLA_U64 },
 	[NL80211_ATTR_USER_REG_HINT_TYPE] = { .type = NLA_U32 },
 	[NL80211_ATTR_SAE_DATA] = { .type = NLA_BINARY, },
+	[NL80211_ATTR_SCAN_FLAGS] = { .type = NLA_U32 },
 };
 
 /* policy for the key attributes */
@@ -4362,6 +4363,10 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 		}
 	}
 
+	if (info->attrs[NL80211_ATTR_SCAN_FLAGS])
+		request->flags = nla_get_u32(
+			info->attrs[NL80211_ATTR_SCAN_FLAGS]);
+
 	request->no_cck =
 		nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
 
@@ -4593,6 +4598,10 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
 		       request->ie_len);
 	}
 
+	if (info->attrs[NL80211_ATTR_SCAN_FLAGS])
+		request->flags = nla_get_u32(
+			info->attrs[NL80211_ATTR_SCAN_FLAGS]);
+
 	request->dev = dev;
 	request->wiphy = &rdev->wiphy;
 	request->interval = interval;
@@ -7658,6 +7667,9 @@ static int nl80211_add_scan_req(struct sk_buff *msg,
 	    nla_put(msg, NL80211_ATTR_IE, req->ie_len, req->ie))
 		goto nla_put_failure;
 
+	if (req->flags)
+		nla_put_u32(msg, NL80211_ATTR_SCAN_FLAGS, req->flags);
+
 	return 0;
  nla_put_failure:
 	return -ENOBUFS;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 2/5] cfg80211: add scan flag to indicate its priority
  2012-10-04  4:47 [PATCH v3 0/5] add scan flags support Bing Zhao
  2012-10-04  4:47 ` [PATCH v3 1/5] {nl,cfg}80211: add a flags word to scan requests Bing Zhao
@ 2012-10-04  4:47 ` Bing Zhao
  2012-10-10  8:16   ` Johannes Berg
  2012-10-04  4:47 ` [PATCH v3 3/5] cfg80211: code rearrangement to avoid forward declarations Bing Zhao
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Bing Zhao @ 2012-10-04  4:47 UTC (permalink / raw)
  To: linux-wireless
  Cc: Johannes Berg, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang, Bing Zhao

From: Sam Leffler <sleffler@chromium.org>

Add NL80211_SCAN_FLAG_LOW_PRIORITY flag support. It tells drivers
that this is a low priority scan request, so that they can take
necessary action.
Drivers need to advertise low priority scan capability during
registration.

Signed-off-by: Sam Leffler <sleffler@chromium.org>
Tested-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
v3: Add WIPHY_FLAG_LOW_PRIORITY_SCAN flag so that device can advertise
    low priority scan capability. An error will be returned to the
    application if device doesn't support this feature.
    Flush scan table feature is by default enabled.
    (Johannes Berg)

 include/linux/nl80211.h |    3 +++
 include/net/cfg80211.h  |    2 ++
 net/wireless/nl80211.c  |   12 ++++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index bac473a..a1d5704 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -3090,8 +3090,11 @@ enum nl80211_connect_failed_reason {
  * Scan request control flags are used to control the handling
  * of NL80211_CMD_TRIGGER_SCAN and NL80211_CMD_START_SCHED_SCAN
  * requests.
+ *
+ * @NL80211_SCAN_FLAG_LOW_PRIORITY: scan request has low priority
  */
 enum nl80211_scan_flags {
+	NL80211_SCAN_FLAG_LOW_PRIORITY			= 1<<0,
 };
 
 #endif /* __LINUX_NL80211_H */
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 7c70e99..dcad5cd 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1915,6 +1915,7 @@ struct cfg80211_ops {
  *	responds to probe-requests in hardware.
  * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX.
  * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call.
+ * @WIPHY_FLAG_LOW_PRIORITY_SCAN: Device handles low priority scan differently.
  */
 enum wiphy_flags {
 	WIPHY_FLAG_CUSTOM_REGULATORY		= BIT(0),
@@ -1938,6 +1939,7 @@ enum wiphy_flags {
 	WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD	= BIT(19),
 	WIPHY_FLAG_OFFCHAN_TX			= BIT(20),
 	WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL	= BIT(21),
+	WIPHY_FLAG_LOW_PRIORITY_SCAN		= BIT(22),
 };
 
 /**
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 714e46d..b26b7f7 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4363,9 +4363,13 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 		}
 	}
 
-	if (info->attrs[NL80211_ATTR_SCAN_FLAGS])
+	if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) {
 		request->flags = nla_get_u32(
 			info->attrs[NL80211_ATTR_SCAN_FLAGS]);
+		if (!(wiphy->flags & WIPHY_FLAG_LOW_PRIORITY_SCAN) &&
+		    (request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY))
+			return -EOPNOTSUPP;
+	}
 
 	request->no_cck =
 		nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]);
@@ -4598,9 +4602,13 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
 		       request->ie_len);
 	}
 
-	if (info->attrs[NL80211_ATTR_SCAN_FLAGS])
+	if (info->attrs[NL80211_ATTR_SCAN_FLAGS]) {
 		request->flags = nla_get_u32(
 			info->attrs[NL80211_ATTR_SCAN_FLAGS]);
+		if (!(wiphy->flags & WIPHY_FLAG_LOW_PRIORITY_SCAN) &&
+		    (request->flags & NL80211_SCAN_FLAG_LOW_PRIORITY))
+			return -EOPNOTSUPP;
+	}
 
 	request->dev = dev;
 	request->wiphy = &rdev->wiphy;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 3/5] cfg80211: code rearrangement to avoid forward declarations
  2012-10-04  4:47 [PATCH v3 0/5] add scan flags support Bing Zhao
  2012-10-04  4:47 ` [PATCH v3 1/5] {nl,cfg}80211: add a flags word to scan requests Bing Zhao
  2012-10-04  4:47 ` [PATCH v3 2/5] cfg80211: add scan flag to indicate its priority Bing Zhao
@ 2012-10-04  4:47 ` Bing Zhao
  2012-10-04  4:47 ` [PATCH v3 4/5] cfg80211: add support for flushing old scan results Bing Zhao
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Bing Zhao @ 2012-10-04  4:47 UTC (permalink / raw)
  To: linux-wireless
  Cc: Johannes Berg, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang, Bing Zhao

From: Amitkumar Karwar <akarwar@marvell.com>

bss_release() and __cfg80211_unlink_bss() function definitions
are moved at the begining of the file. They are used in next
patch in this series.

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
v3: avoid static forward declaration (Johannes Berg)

 net/wireless/scan.c |   54 +++++++++++++++++++++++++-------------------------
 1 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 9730c98..2005096 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -20,6 +20,33 @@
 
 #define IEEE80211_SCAN_RESULT_EXPIRE	(30 * HZ)
 
+static void bss_release(struct kref *ref)
+{
+	struct cfg80211_internal_bss *bss;
+
+	bss = container_of(ref, struct cfg80211_internal_bss, ref);
+	if (bss->pub.free_priv)
+		bss->pub.free_priv(&bss->pub);
+
+	if (bss->beacon_ies_allocated)
+		kfree(bss->pub.beacon_ies);
+	if (bss->proberesp_ies_allocated)
+		kfree(bss->pub.proberesp_ies);
+
+	BUG_ON(atomic_read(&bss->hold));
+
+	kfree(bss);
+}
+
+/* must hold dev->bss_lock! */
+static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
+				  struct cfg80211_internal_bss *bss)
+{
+	list_del_init(&bss->list);
+	rb_erase(&bss->rbn, &dev->bss_tree);
+	kref_put(&bss->ref, bss_release);
+}
+
 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
 {
 	struct cfg80211_scan_request *request;
@@ -158,24 +185,6 @@ int __cfg80211_stop_sched_scan(struct cfg80211_registered_device *rdev,
 	return 0;
 }
 
-static void bss_release(struct kref *ref)
-{
-	struct cfg80211_internal_bss *bss;
-
-	bss = container_of(ref, struct cfg80211_internal_bss, ref);
-	if (bss->pub.free_priv)
-		bss->pub.free_priv(&bss->pub);
-
-	if (bss->beacon_ies_allocated)
-		kfree(bss->pub.beacon_ies);
-	if (bss->proberesp_ies_allocated)
-		kfree(bss->pub.proberesp_ies);
-
-	BUG_ON(atomic_read(&bss->hold));
-
-	kfree(bss);
-}
-
 /* must hold dev->bss_lock! */
 void cfg80211_bss_age(struct cfg80211_registered_device *dev,
                       unsigned long age_secs)
@@ -189,15 +198,6 @@ void cfg80211_bss_age(struct cfg80211_registered_device *dev,
 }
 
 /* must hold dev->bss_lock! */
-static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
-				  struct cfg80211_internal_bss *bss)
-{
-	list_del_init(&bss->list);
-	rb_erase(&bss->rbn, &dev->bss_tree);
-	kref_put(&bss->ref, bss_release);
-}
-
-/* must hold dev->bss_lock! */
 void cfg80211_bss_expire(struct cfg80211_registered_device *dev)
 {
 	struct cfg80211_internal_bss *bss, *tmp;
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 4/5] cfg80211: add support for flushing old scan results
  2012-10-04  4:47 [PATCH v3 0/5] add scan flags support Bing Zhao
                   ` (2 preceding siblings ...)
  2012-10-04  4:47 ` [PATCH v3 3/5] cfg80211: code rearrangement to avoid forward declarations Bing Zhao
@ 2012-10-04  4:47 ` Bing Zhao
  2012-10-04  4:47 ` [PATCH v3 5/5] mac80211: add support for tx to abort low priority scan requests Bing Zhao
  2012-10-10  8:18 ` [PATCH v3 0/5] add scan flags support Johannes Berg
  5 siblings, 0 replies; 11+ messages in thread
From: Bing Zhao @ 2012-10-04  4:47 UTC (permalink / raw)
  To: linux-wireless
  Cc: Johannes Berg, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang, Bing Zhao

From: Sam Leffler <sleffler@chromium.org>

Add an NL80211_SCAN_FLAG_FLUSH flag that causes old bss cache
entries to be flushed on scan completion. This is useful for
collecting guaranteed fresh scan/survey result (e.g. on resume).

For normal scan, flushing only happens on successful completion
of a scan; i.e. it does not happen if the scan is aborted.
For scheduled scan, previous scan results are flushed everytime
when we get new scan results.

Signed-off-by: Sam Leffler <sleffler@chromium.org>
Tested-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
v3: avoid static forward declaration (Johannes Berg)

 include/linux/nl80211.h |    2 +
 include/net/cfg80211.h  |    3 ++
 net/wireless/nl80211.c  |    2 +
 net/wireless/scan.c     |   65 ++++++++++++++++++++++++++++++++--------------
 net/wireless/sme.c      |    1 +
 5 files changed, 53 insertions(+), 20 deletions(-)

diff --git a/include/linux/nl80211.h b/include/linux/nl80211.h
index a1d5704..df1b04a 100644
--- a/include/linux/nl80211.h
+++ b/include/linux/nl80211.h
@@ -3092,9 +3092,11 @@ enum nl80211_connect_failed_reason {
  * requests.
  *
  * @NL80211_SCAN_FLAG_LOW_PRIORITY: scan request has low priority
+ * @NL80211_SCAN_FLAG_FLUSH: flush cache before scanning
  */
 enum nl80211_scan_flags {
 	NL80211_SCAN_FLAG_LOW_PRIORITY			= 1<<0,
+	NL80211_SCAN_FLAG_FLUSH				= 1<<1,
 };
 
 #endif /* __LINUX_NL80211_H */
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index dcad5cd..dc54c0f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1003,6 +1003,7 @@ struct cfg80211_ssid {
  * @flags: bit field of flags controlling operation
  * @rates: bitmap of rates to advertise for each band
  * @wiphy: the wiphy this was for
+ * @scan_start: time (in jiffies) when the scan started
  * @wdev: the wireless device to scan for
  * @aborted: (internal) scan request was notified as aborted
  * @no_cck: used to send probe requests at non CCK rate in 2GHz band
@@ -1021,6 +1022,7 @@ struct cfg80211_scan_request {
 
 	/* internal */
 	struct wiphy *wiphy;
+	unsigned long scan_start;
 	bool aborted;
 	bool no_cck;
 
@@ -1072,6 +1074,7 @@ struct cfg80211_sched_scan_request {
 	/* internal */
 	struct wiphy *wiphy;
 	struct net_device *dev;
+	unsigned long scan_start;
 
 	/* keep last */
 	struct ieee80211_channel *channels[0];
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b26b7f7..c562d8e 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -4376,6 +4376,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 
 	request->wdev = wdev;
 	request->wiphy = &rdev->wiphy;
+	request->scan_start = jiffies;
 
 	rdev->scan_req = request;
 	err = rdev->ops->scan(&rdev->wiphy, request);
@@ -4613,6 +4614,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
 	request->dev = dev;
 	request->wiphy = &rdev->wiphy;
 	request->interval = interval;
+	request->scan_start = jiffies;
 
 	err = rdev->ops->sched_scan_start(&rdev->wiphy, dev, request);
 	if (!err) {
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 2005096..646a64f 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -47,6 +47,27 @@ static void __cfg80211_unlink_bss(struct cfg80211_registered_device *dev,
 	kref_put(&bss->ref, bss_release);
 }
 
+/* must hold dev->bss_lock! */
+static void __cfg80211_bss_expire(struct cfg80211_registered_device *dev,
+				  unsigned long expire_time)
+{
+	struct cfg80211_internal_bss *bss, *tmp;
+	bool expired = false;
+
+	list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) {
+		if (atomic_read(&bss->hold))
+			continue;
+		if (!time_after(expire_time, bss->ts))
+			continue;
+
+		__cfg80211_unlink_bss(dev, bss);
+		expired = true;
+	}
+
+	if (expired)
+		dev->bss_generation++;
+}
+
 void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
 {
 	struct cfg80211_scan_request *request;
@@ -72,10 +93,17 @@ void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev, bool leak)
 	if (wdev->netdev)
 		cfg80211_sme_scan_done(wdev->netdev);
 
-	if (request->aborted)
+	if (request->aborted) {
 		nl80211_send_scan_aborted(rdev, wdev);
-	else
+	} else {
+		if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
+			/* flush entries from previous scans */
+			spin_lock_bh(&rdev->bss_lock);
+			__cfg80211_bss_expire(rdev, request->scan_start);
+			spin_unlock_bh(&rdev->bss_lock);
+		}
 		nl80211_send_scan_done(rdev, wdev);
+	}
 
 #ifdef CONFIG_CFG80211_WEXT
 	if (wdev->netdev && !request->aborted) {
@@ -126,16 +154,26 @@ EXPORT_SYMBOL(cfg80211_scan_done);
 void __cfg80211_sched_scan_results(struct work_struct *wk)
 {
 	struct cfg80211_registered_device *rdev;
+	struct cfg80211_sched_scan_request *request;
 
 	rdev = container_of(wk, struct cfg80211_registered_device,
 			    sched_scan_results_wk);
 
+	request = rdev->sched_scan_req;
+
 	mutex_lock(&rdev->sched_scan_mtx);
 
 	/* we don't have sched_scan_req anymore if the scan is stopping */
-	if (rdev->sched_scan_req)
-		nl80211_send_sched_scan_results(rdev,
-						rdev->sched_scan_req->dev);
+	if (request) {
+		if (request->flags & NL80211_SCAN_FLAG_FLUSH) {
+			/* flush entries from previous scans */
+			spin_lock_bh(&rdev->bss_lock);
+			__cfg80211_bss_expire(rdev, request->scan_start);
+			spin_unlock_bh(&rdev->bss_lock);
+			request->scan_start = jiffies + request->interval;
+		}
+		nl80211_send_sched_scan_results(rdev, request->dev);
+	}
 
 	mutex_unlock(&rdev->sched_scan_mtx);
 }
@@ -197,23 +235,9 @@ void cfg80211_bss_age(struct cfg80211_registered_device *dev,
 	}
 }
 
-/* must hold dev->bss_lock! */
 void cfg80211_bss_expire(struct cfg80211_registered_device *dev)
 {
-	struct cfg80211_internal_bss *bss, *tmp;
-	bool expired = false;
-
-	list_for_each_entry_safe(bss, tmp, &dev->bss_list, list) {
-		if (atomic_read(&bss->hold))
-			continue;
-		if (!time_after(jiffies, bss->ts + IEEE80211_SCAN_RESULT_EXPIRE))
-			continue;
-		__cfg80211_unlink_bss(dev, bss);
-		expired = true;
-	}
-
-	if (expired)
-		dev->bss_generation++;
+	__cfg80211_bss_expire(dev, jiffies - IEEE80211_SCAN_RESULT_EXPIRE);
 }
 
 const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len)
@@ -962,6 +986,7 @@ int cfg80211_wext_siwscan(struct net_device *dev,
 	creq->ssids = (void *)&creq->channels[n_channels];
 	creq->n_channels = n_channels;
 	creq->n_ssids = 1;
+	creq->scan_start = jiffies;
 
 	/* translate "Scan on frequencies" request */
 	i = 0;
diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 055d596..07d717e 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -138,6 +138,7 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
 
 	request->wdev = wdev;
 	request->wiphy = &rdev->wiphy;
+	request->scan_start = jiffies;
 
 	rdev->scan_req = request;
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v3 5/5] mac80211: add support for tx to abort low priority scan requests
  2012-10-04  4:47 [PATCH v3 0/5] add scan flags support Bing Zhao
                   ` (3 preceding siblings ...)
  2012-10-04  4:47 ` [PATCH v3 4/5] cfg80211: add support for flushing old scan results Bing Zhao
@ 2012-10-04  4:47 ` Bing Zhao
  2012-10-10  8:18 ` [PATCH v3 0/5] add scan flags support Johannes Berg
  5 siblings, 0 replies; 11+ messages in thread
From: Bing Zhao @ 2012-10-04  4:47 UTC (permalink / raw)
  To: linux-wireless
  Cc: Johannes Berg, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang, Bing Zhao

From: Sam Leffler <sleffler@chromium.org>

Use NL80211_SCAN_FLAG_LOW_PRIORITY flag in mac80211's scan state
machine to prematurely terminate scan operations if outbound
traffic collides. This is useful for marking background scans so
they don't affect throughput.

Signed-off-by: Sam Leffler <sleffler@chromium.org>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
---
v3: Removed use of unlikely() macro (Johannes Berg)
    Advertise low priority scan capability (Johannes Berg)

 net/mac80211/ieee80211_i.h |    2 ++
 net/mac80211/main.c        |    3 ++-
 net/mac80211/scan.c        |   21 +++++++++++++++++----
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 1fd7dfc..8c68877 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -866,6 +866,7 @@ enum {
  * @SCAN_SUSPEND: Suspend the scan and go back to operating channel to
  *	send out data
  * @SCAN_RESUME: Resume the scan and scan the next channel
+ * @SCAN_ABORT: Abort the scan and go back to operating channel
  */
 enum mac80211_scan_state {
 	SCAN_DECISION,
@@ -873,6 +874,7 @@ enum mac80211_scan_state {
 	SCAN_SEND_PROBE,
 	SCAN_SUSPEND,
 	SCAN_RESUME,
+	SCAN_ABORT,
 };
 
 struct ieee80211_local {
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 473b755..da7e007 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -593,7 +593,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
 			WIPHY_FLAG_4ADDR_AP |
 			WIPHY_FLAG_4ADDR_STATION |
 			WIPHY_FLAG_REPORTS_OBSS |
-			WIPHY_FLAG_OFFCHAN_TX;
+			WIPHY_FLAG_OFFCHAN_TX |
+			WIPHY_FLAG_LOW_PRIORITY_SCAN;
 
 	if (ops->remain_on_channel)
 		wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index 5671fe5..8c41c91 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -466,6 +466,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
 			sizeof(*local->hw_scan_req) +
 			req->n_channels * sizeof(req->channels[0]);
 		local->hw_scan_req->ie = ies;
+		local->hw_scan_req->flags = req->flags;
 
 		local->hw_scan_band = 0;
 
@@ -566,6 +567,7 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local,
 	unsigned long min_beacon_int = 0;
 	struct ieee80211_sub_if_data *sdata;
 	struct ieee80211_channel *next_chan;
+	enum mac80211_scan_state next_scan_state;
 
 	/*
 	 * check if at least one STA interface is associated,
@@ -624,10 +626,18 @@ static void ieee80211_scan_state_decision(struct ieee80211_local *local,
 			usecs_to_jiffies(min_beacon_int * 1024) *
 			local->hw.conf.listen_interval);
 
-	if (associated && (!tx_empty || bad_latency || listen_int_exceeded))
-		local->next_scan_state = SCAN_SUSPEND;
-	else
-		local->next_scan_state = SCAN_SET_CHANNEL;
+	if (associated && !tx_empty) {
+		if (local->scan_req->flags & NL80211_SCAN_FLAG_LOW_PRIORITY)
+			next_scan_state = SCAN_ABORT;
+		else
+			next_scan_state = SCAN_SUSPEND;
+	} else if (associated && (bad_latency || listen_int_exceeded)) {
+		next_scan_state = SCAN_SUSPEND;
+	} else {
+		next_scan_state = SCAN_SET_CHANNEL;
+	}
+
+	local->next_scan_state = next_scan_state;
 
 	*next_delay = 0;
 }
@@ -798,6 +808,9 @@ void ieee80211_scan_work(struct work_struct *work)
 		case SCAN_RESUME:
 			ieee80211_scan_state_resume(local, &next_delay);
 			break;
+		case SCAN_ABORT:
+			aborted = true;
+			goto out_complete;
 		}
 	} while (next_delay == 0);
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 2/5] cfg80211: add scan flag to indicate its priority
  2012-10-04  4:47 ` [PATCH v3 2/5] cfg80211: add scan flag to indicate its priority Bing Zhao
@ 2012-10-10  8:16   ` Johannes Berg
  0 siblings, 0 replies; 11+ messages in thread
From: Johannes Berg @ 2012-10-10  8:16 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang

On Wed, 2012-10-03 at 21:47 -0700, Bing Zhao wrote:
> v3: Add WIPHY_FLAG_LOW_PRIORITY_SCAN flag so that device can advertise
>     low priority scan capability. An error will be returned to the
>     application if device doesn't support this feature.
>     Flush scan table feature is by default enabled.
>     (Johannes Berg)

Great, but you're not advertising it to userspace? I think that should
be there so it can know whether it can request flush etc?

Also, how should flush really work with scheduled scan? Or should it be
documented to not work there?

johannes


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 0/5] add scan flags support
  2012-10-04  4:47 [PATCH v3 0/5] add scan flags support Bing Zhao
                   ` (4 preceding siblings ...)
  2012-10-04  4:47 ` [PATCH v3 5/5] mac80211: add support for tx to abort low priority scan requests Bing Zhao
@ 2012-10-10  8:18 ` Johannes Berg
  2012-10-10 13:56   ` Amitkumar Karwar
  5 siblings, 1 reply; 11+ messages in thread
From: Johannes Berg @ 2012-10-10  8:18 UTC (permalink / raw)
  To: Bing Zhao
  Cc: linux-wireless, John W. Linville, Sam Leffler, Amitkumar Karwar,
	Avinash Patil, Nishant Sarmukadam, Frank Huang

Hi,

I think this is good, but needs the userspace advertisement.

We can either advertise the scan flags word to userspace and set the
supported flags, but then I'm not sure how to handle scheduled vs.
regular scan. Alternatively we could use nl80211 feature flags (instead
of wiphy flags) which get advertised directly... I'm not really sure
what's better.

What would be the behaviour of flush in a scheduled scan?

johannes


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v3 0/5] add scan flags support
  2012-10-10  8:18 ` [PATCH v3 0/5] add scan flags support Johannes Berg
@ 2012-10-10 13:56   ` Amitkumar Karwar
  2012-10-11 12:14     ` Johannes Berg
  0 siblings, 1 reply; 11+ messages in thread
From: Amitkumar Karwar @ 2012-10-10 13:56 UTC (permalink / raw)
  To: 'Johannes Berg', Bing Zhao
  Cc: linux-wireless@vger.kernel.org, John W. Linville, Sam Leffler,
	Avinash Patil, Nishant Sarmukadam, Frank Huang

Hi Johannes,

> 
> I think this is good, but needs the userspace advertisement.
> 
> We can either advertise the scan flags word to userspace and set the
> supported flags, but then I'm not sure how to handle scheduled vs.
> regular scan. Alternatively we could use nl80211 feature flags (instead
> of wiphy flags) which get advertised directly... I'm not really sure
> what's better.

Ok. We will make use of nl80211 feature flags in updated version so that these capabilities will be advertised to userspace as well.

> 
> What would be the behaviour of flush in a scheduled scan?

As per our understanding, scheduled scan is triggered from application. Driver/hardware will keep on scanning the network periodically using specified time interval and provide scan results to cfg80211.

We have added code (v3 patch 4/5) to flush older scan entries whenever new results are available. scan_start time is used for this. Everytime it's getting modified to "jiffies + interval" for future use.

Please let's know your comments.

Thanks,
Amitkumar Karwar


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 0/5] add scan flags support
  2012-10-10 13:56   ` Amitkumar Karwar
@ 2012-10-11 12:14     ` Johannes Berg
  2012-10-11 12:29       ` Amitkumar Karwar
  0 siblings, 1 reply; 11+ messages in thread
From: Johannes Berg @ 2012-10-11 12:14 UTC (permalink / raw)
  To: Amitkumar Karwar
  Cc: Bing Zhao, linux-wireless@vger.kernel.org, John W. Linville,
	Sam Leffler, Avinash Patil, Nishant Sarmukadam, Frank Huang

Hi,

> > What would be the behaviour of flush in a scheduled scan?
> 
> As per our understanding, scheduled scan is triggered from
> application. Driver/hardware will keep on scanning the network
> periodically using specified time interval and provide scan results to
> cfg80211.

Right.

> We have added code (v3 patch 4/5) to flush older scan entries whenever
> new results are available. scan_start time is used for this. Everytime
> it's getting modified to "jiffies + interval" for future use.

Ah. But that's in the wrong units (jiffies vs. ms).

johannes


^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH v3 0/5] add scan flags support
  2012-10-11 12:14     ` Johannes Berg
@ 2012-10-11 12:29       ` Amitkumar Karwar
  0 siblings, 0 replies; 11+ messages in thread
From: Amitkumar Karwar @ 2012-10-11 12:29 UTC (permalink / raw)
  To: 'Johannes Berg'
  Cc: Bing Zhao, linux-wireless@vger.kernel.org, John W. Linville,
	Sam Leffler, Avinash Patil, Nishant Sarmukadam, Frank Huang

Hi Johannes,

> > We have added code (v3 patch 4/5) to flush older scan entries whenever
> > new results are available. scan_start time is used for this. Everytime
> > it's getting modified to "jiffies + interval" for future use.
> 
> Ah. But that's in the wrong units (jiffies vs. ms).

Thanks for pointing this out. We will use msecs_to_jiffies() for correct comparison.

Thanks,
Amitkumar Karwar

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2012-10-11 12:30 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-04  4:47 [PATCH v3 0/5] add scan flags support Bing Zhao
2012-10-04  4:47 ` [PATCH v3 1/5] {nl,cfg}80211: add a flags word to scan requests Bing Zhao
2012-10-04  4:47 ` [PATCH v3 2/5] cfg80211: add scan flag to indicate its priority Bing Zhao
2012-10-10  8:16   ` Johannes Berg
2012-10-04  4:47 ` [PATCH v3 3/5] cfg80211: code rearrangement to avoid forward declarations Bing Zhao
2012-10-04  4:47 ` [PATCH v3 4/5] cfg80211: add support for flushing old scan results Bing Zhao
2012-10-04  4:47 ` [PATCH v3 5/5] mac80211: add support for tx to abort low priority scan requests Bing Zhao
2012-10-10  8:18 ` [PATCH v3 0/5] add scan flags support Johannes Berg
2012-10-10 13:56   ` Amitkumar Karwar
2012-10-11 12:14     ` Johannes Berg
2012-10-11 12:29       ` Amitkumar Karwar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox