From 57663336983d5124459de50b72148d6902fa49bc Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 26 Feb 2016 22:12:47 +0200 Subject: [PATCH 1/3] cfg80211: Allow a scan request for a specific BSSID This allows scans for a specific BSSID to be optimized by the user space application by requesting the driver to set the Probe Request frame BSSID field (Address 3) to the specified BSSID instead of the wildcard BSSID. This prevents other APs from replying which reduces airtime need and latency in getting the response from the target AP through. This is an optimization and as such, it is acceptable for some of the drivers not to support the mechanism. If not supported, the wildcard BSSID will be used and more responses may be received. Signed-off-by: Jouni Malinen Signed-off-by: Johannes Berg Git-commit: 0889675a9503f48d1ad01b4eaa202f89469b2b62 Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Change-Id: I20cf654661c11880055d022e0c9ec77beab659e8 CRs-fixed: 996660 Signed-off-by: Vidyullatha Kanchanapally --- include/net/cfg80211.h | 2 ++ include/uapi/linux/nl80211.h | 4 +++- net/wireless/nl80211.c | 6 ++++++ net/wireless/scan.c | 2 ++ net/wireless/sme.c | 2 ++ 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index e0b0d2b12b88..8d29e441ae71 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1455,6 +1455,7 @@ struct cfg80211_ssid { * @mac_addr_mask: MAC address mask used with randomisation, bits that * are 0 in the mask should be randomised, bits that are 1 should * be taken from the @mac_addr + * @bssid: BSSID to scan for (most commonly, the wildcard BSSID) */ struct cfg80211_scan_request { struct cfg80211_ssid *ssids; @@ -1471,6 +1472,7 @@ struct cfg80211_scan_request { u8 mac_addr[ETH_ALEN] __aligned(2); u8 mac_addr_mask[ETH_ALEN] __aligned(2); + u8 bssid[ETH_ALEN] __aligned(2); /* internal */ struct wiphy *wiphy; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index b5323800eeb5..c4984741be61 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -322,7 +322,9 @@ * @NL80211_CMD_GET_SCAN: get scan results * @NL80211_CMD_TRIGGER_SCAN: trigger a new scan with the given parameters * %NL80211_ATTR_TX_NO_CCK_RATE is used to decide whether to send the - * probe requests at CCK rate or not. + * probe requests at CCK rate or not. %NL80211_ATTR_MAC can be used to + * specify a BSSID to scan for; if not included, the wildcard BSSID will + * be used. * @NL80211_CMD_NEW_SCAN_RESULTS: scan notification (as a reply to * NL80211_CMD_GET_SCAN and on the "scan" multicast group) * @NL80211_CMD_SCAN_ABORTED: scan was aborted, for unspecified reasons, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 6e9722f71f9a..da01a2cc5cd9 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -6022,6 +6022,12 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info) request->no_cck = nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); + if (info->attrs[NL80211_ATTR_MAC]) + memcpy(request->bssid, nla_data(info->attrs[NL80211_ATTR_MAC]), + ETH_ALEN); + else + eth_broadcast_addr(request->bssid); + request->wdev = wdev; request->wiphy = &rdev->wiphy; request->scan_start = jiffies; diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 30f967665e84..16c3424507c3 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -1293,6 +1293,8 @@ int cfg80211_wext_siwscan(struct net_device *dev, if (wiphy->bands[i]) creq->rates[i] = (1 << wiphy->bands[i]->n_bitrates) - 1; + eth_broadcast_addr(creq->bssid); + rdev->scan_req = creq; err = rdev_scan(rdev, creq); if (err) { diff --git a/net/wireless/sme.c b/net/wireless/sme.c index e9be8c3b177b..44f420dfa8e3 100644 --- a/net/wireless/sme.c +++ b/net/wireless/sme.c @@ -142,6 +142,8 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev) wdev->conn->params.ssid_len); request->ssids[0].ssid_len = wdev->conn->params.ssid_len; + eth_broadcast_addr(request->bssid); + request->wdev = wdev; request->wiphy = &rdev->wiphy; request->scan_start = jiffies; From 6038e87f08945254a8cfb181ef3c1b6b6e06029f Mon Sep 17 00:00:00 2001 From: Vidyullatha Kanchanapally Date: Tue, 19 Apr 2016 15:11:26 +0530 Subject: [PATCH 2/3] cfg80211: Define macro to indicate bssid based scan support Define macro to indicate backport support for bssid parameter in scan request. Change-Id: I542b0de66948610135cf69a3d24c1561017fe7a8 CRs-Fixed: 996660 Signed-off-by: Vidyullatha Kanchanapally --- include/net/cfg80211.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8d29e441ae71..010a076a8c80 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -63,6 +63,8 @@ struct wiphy; +#define CFG80211_SCAN_BSSID 1 + /* * wireless hardware capability structures */ From 1b4ea777695255892b0d54bfe805f5383841ca36 Mon Sep 17 00:00:00 2001 From: Vidyullatha Kanchanapally Date: Wed, 27 Apr 2016 11:58:08 +0530 Subject: [PATCH 3/3] cfg80211: Define macro to indicate prev_bssid connect support Define macro to indicate backport support for prev_bssid parameter in connect request. This parameter allows the driver to decide whether to do a new association or a re-association on a cfg80211 connect request. Change-Id: I760e2999ec56c9aa0c44ac7b062ee1755192299f CRs-Fixed: 1004073 Signed-off-by: Vidyullatha Kanchanapally --- include/net/cfg80211.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 010a076a8c80..3ee07db23049 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -64,6 +64,7 @@ struct wiphy; #define CFG80211_SCAN_BSSID 1 +#define CFG80211_CONNECT_PREV_BSSID 1 /* * wireless hardware capability structures