Commit 88e920b4 authored by Thomas Pedersen's avatar Thomas Pedersen Committed by Johannes Berg

nl80211: specify RSSI threshold in scheduled scan

Support configuring an RSSI threshold in dBm (s32) when requesting
scheduled scan, below which a BSS won't be reported by the cfg80211
driver.
Signed-off-by: default avatarThomas Pedersen <c_tpeder@qca.qualcomm.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent d0f718c1
...@@ -1542,6 +1542,9 @@ enum nl80211_attrs { ...@@ -1542,6 +1542,9 @@ enum nl80211_attrs {
#define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10 #define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10
/* default RSSI threshold for scan results if none specified. */
#define NL80211_SCAN_RSSI_THOLD_OFF -300
/** /**
* enum nl80211_iftype - (virtual) interface types * enum nl80211_iftype - (virtual) interface types
* *
...@@ -1974,6 +1977,8 @@ enum nl80211_reg_rule_attr { ...@@ -1974,6 +1977,8 @@ enum nl80211_reg_rule_attr {
* @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved * @__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID: attribute number 0 is reserved
* @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching, * @NL80211_SCHED_SCAN_MATCH_ATTR_SSID: SSID to be used for matching,
* only report BSS with matching SSID. * only report BSS with matching SSID.
* @NL80211_SCHED_SCAN_MATCH_ATTR_RSSI: RSSI threshold (in dBm) for reporting a
* BSS in scan results. Filtering is turned off if not specified.
* @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter * @NL80211_SCHED_SCAN_MATCH_ATTR_MAX: highest scheduled scan filter
* attribute number currently defined * attribute number currently defined
* @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use * @__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST: internal use
...@@ -1982,6 +1987,7 @@ enum nl80211_sched_scan_match_attr { ...@@ -1982,6 +1987,7 @@ enum nl80211_sched_scan_match_attr {
__NL80211_SCHED_SCAN_MATCH_ATTR_INVALID, __NL80211_SCHED_SCAN_MATCH_ATTR_INVALID,
NL80211_SCHED_SCAN_MATCH_ATTR_SSID, NL80211_SCHED_SCAN_MATCH_ATTR_SSID,
NL80211_SCHED_SCAN_MATCH_ATTR_RSSI,
/* keep last */ /* keep last */
__NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST, __NL80211_SCHED_SCAN_MATCH_ATTR_AFTER_LAST,
......
...@@ -1027,6 +1027,7 @@ struct cfg80211_match_set { ...@@ -1027,6 +1027,7 @@ struct cfg80211_match_set {
* @wiphy: the wiphy this was for * @wiphy: the wiphy this was for
* @dev: the interface * @dev: the interface
* @channels: channels to scan * @channels: channels to scan
* @rssi_thold: don't report scan results below this threshold (in s32 dBm)
*/ */
struct cfg80211_sched_scan_request { struct cfg80211_sched_scan_request {
struct cfg80211_ssid *ssids; struct cfg80211_ssid *ssids;
...@@ -1037,6 +1038,7 @@ struct cfg80211_sched_scan_request { ...@@ -1037,6 +1038,7 @@ struct cfg80211_sched_scan_request {
size_t ie_len; size_t ie_len;
struct cfg80211_match_set *match_sets; struct cfg80211_match_set *match_sets;
int n_match_sets; int n_match_sets;
s32 rssi_thold;
/* internal */ /* internal */
struct wiphy *wiphy; struct wiphy *wiphy;
......
...@@ -340,6 +340,7 @@ static const struct nla_policy ...@@ -340,6 +340,7 @@ static const struct nla_policy
nl80211_match_policy[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1] = { nl80211_match_policy[NL80211_SCHED_SCAN_MATCH_ATTR_MAX + 1] = {
[NL80211_SCHED_SCAN_MATCH_ATTR_SSID] = { .type = NLA_BINARY, [NL80211_SCHED_SCAN_MATCH_ATTR_SSID] = { .type = NLA_BINARY,
.len = IEEE80211_MAX_SSID_LEN }, .len = IEEE80211_MAX_SSID_LEN },
[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI] = { .type = NLA_U32 },
}; };
/* ifidx get helper */ /* ifidx get helper */
...@@ -4387,7 +4388,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, ...@@ -4387,7 +4388,7 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
nla_for_each_nested(attr, nla_for_each_nested(attr,
info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH], info->attrs[NL80211_ATTR_SCHED_SCAN_MATCH],
tmp) { tmp) {
struct nlattr *ssid; struct nlattr *ssid, *rssi;
nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX, nla_parse(tb, NL80211_SCHED_SCAN_MATCH_ATTR_MAX,
nla_data(attr), nla_len(attr), nla_data(attr), nla_len(attr),
...@@ -4403,6 +4404,12 @@ static int nl80211_start_sched_scan(struct sk_buff *skb, ...@@ -4403,6 +4404,12 @@ static int nl80211_start_sched_scan(struct sk_buff *skb,
request->match_sets[i].ssid.ssid_len = request->match_sets[i].ssid.ssid_len =
nla_len(ssid); nla_len(ssid);
} }
rssi = tb[NL80211_SCHED_SCAN_MATCH_ATTR_RSSI];
if (rssi)
request->rssi_thold = nla_get_u32(rssi);
else
request->rssi_thold =
NL80211_SCAN_RSSI_THOLD_OFF;
i++; i++;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment