wlan-ap-Telecominfraproject/feeds/ipq95xx/mac80211/patches/qca/036-nl80211-add-wide-band-scan-support.patch
John Crispin 144c5d00f4 ipq95xx/mac80211: update to ATH12.3-CS
Signed-off-by: John Crispin <john@phrozen.org>
2024-02-28 18:56:21 +01:00

152 lines
5.1 KiB
Diff

--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -2407,6 +2407,7 @@ struct cfg80211_scan_6ghz_params {
* @channels: channels to scan on.
* @n_channels: total number of channels to scan
* @scan_width: channel width for scanning
+ * @chandef: defines the channel to do wide band scan
* @ie: optional information element(s) to add into Probe Request or %NULL
* @ie_len: length of ie in octets
* @duration: how long to listen on each channel, in TUs. If
@@ -2437,6 +2438,7 @@ struct cfg80211_scan_request {
int n_ssids;
u32 n_channels;
enum nl80211_bss_scan_width scan_width;
+ struct cfg80211_chan_def *chandef;
const u8 *ie;
size_t ie_len;
u16 duration;
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -6273,6 +6273,9 @@ enum nl80211_feature_flags {
* @NL80211_EXT_FEATURE_RADAR_BACKGROUND: Device supports background radar/CAC
* detection.
*
+ * @NL80211_EXT_FEATURE_WIDE_BAND_SCAN: Driver/device supports wide band scan
+ * on a frequency along with its corresponding phymode (40Mhz, 80Mhz)
+ *
* @NUM_NL80211_EXT_FEATURES: number of extended features.
* @MAX_NL80211_EXT_FEATURES: highest extended feature index.
*/
@@ -6339,6 +6342,7 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_PROT_RANGE_NEGO_AND_MEASURE,
NL80211_EXT_FEATURE_BSS_COLOR,
NL80211_EXT_FEATURE_FILS_CRYPTO_OFFLOAD,
+ NL80211_EXT_FEATURE_WIDE_BAND_SCAN,
NL80211_EXT_FEATURE_RADAR_BACKGROUND,
/* add new features before the definition below */
@@ -6456,6 +6460,8 @@ enum nl80211_timeout_reason {
* %NL80211_ATTR_SCAN_FREQUENCIES will not be included.
* @NL80211_SCAN_FLAG_COLOCATED_6GHZ: scan for colocated APs reported by
* 2.4/5 GHz APs
+ * @NL80211_SCAN_FLAG_WIDE_BAND_SCAN: This flag intends the driver to perform
+ * wide band scan only if the driver supports it.
*/
enum nl80211_scan_flags {
NL80211_SCAN_FLAG_LOW_PRIORITY = 1<<0,
@@ -6473,6 +6479,7 @@ enum nl80211_scan_flags {
NL80211_SCAN_FLAG_MIN_PREQ_CONTENT = 1<<12,
NL80211_SCAN_FLAG_FREQ_KHZ = 1<<13,
NL80211_SCAN_FLAG_COLOCATED_6GHZ = 1<<14,
+ NL80211_SCAN_FLAG_WIDE_BAND_SCAN = 1<<15,
};
/**
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -732,11 +732,13 @@ static int __ieee80211_start_scan(struct
local->hw_scan_req = kmalloc(
sizeof(*local->hw_scan_req) +
+ sizeof(*req->chandef) +
req->n_channels * sizeof(req->channels[0]) +
local->hw_scan_ies_bufsize, GFP_KERNEL);
if (!local->hw_scan_req)
return -ENOMEM;
+ local->hw_scan_req->req.chandef = req->chandef;
local->hw_scan_req->req.ssids = req->ssids;
local->hw_scan_req->req.n_ssids = req->n_ssids;
ies = (u8 *)local->hw_scan_req +
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -8833,7 +8833,10 @@ nl80211_check_scan_flags(struct wiphy *w
NL80211_EXT_FEATURE_SCAN_RANDOM_SN) ||
!nl80211_check_scan_feat(wiphy, *flags,
NL80211_SCAN_FLAG_MIN_PREQ_CONTENT,
- NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT))
+ NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT) ||
+ !nl80211_check_scan_feat(wiphy, *flags,
+ NL80211_SCAN_FLAG_WIDE_BAND_SCAN,
+ NL80211_EXT_FEATURE_WIDE_BAND_SCAN))
return -EOPNOTSUPP;
if (*flags & NL80211_SCAN_FLAG_RANDOM_ADDR) {
@@ -8858,10 +8861,12 @@ static int nl80211_trigger_scan(struct s
struct cfg80211_scan_request *request;
struct nlattr *scan_freqs = NULL;
bool scan_freqs_khz = false;
+ struct cfg80211_chan_def chandef;
struct nlattr *attr;
struct wiphy *wiphy;
- int err, tmp, n_ssids = 0, n_channels, i;
+ int err, tmp, n_ssids = 0, n_channels = 0, i;
size_t ie_len;
+ bool chandef_found = false;
wiphy = &rdev->wiphy;
@@ -8874,7 +8879,12 @@ static int nl80211_trigger_scan(struct s
if (rdev->scan_req || rdev->scan_msg)
return -EBUSY;
- if (info->attrs[NL80211_ATTR_SCAN_FREQ_KHZ]) {
+ if (info->attrs[NL80211_ATTR_WIPHY_FREQ]) {
+ if (nl80211_parse_chandef(rdev, info, &chandef)) {
+ return -EINVAL;
+ }
+ chandef_found = true;
+ } else if (info->attrs[NL80211_ATTR_SCAN_FREQ_KHZ]) {
if (!wiphy_ext_feature_isset(wiphy,
NL80211_EXT_FEATURE_SCAN_FREQ_KHZ))
return -EOPNOTSUPP;
@@ -8887,6 +8897,8 @@ static int nl80211_trigger_scan(struct s
n_channels = validate_scan_freqs(scan_freqs);
if (!n_channels)
return -EINVAL;
+ } else if (chandef_found) {
+ n_channels = 1;
} else {
n_channels = ieee80211_get_num_supported_channels(wiphy);
}
@@ -8907,12 +8919,19 @@ static int nl80211_trigger_scan(struct s
return -EINVAL;
request = kzalloc(sizeof(*request)
+ + sizeof(*request->chandef)
+ sizeof(*request->ssids) * n_ssids
+ sizeof(*request->channels) * n_channels
+ ie_len, GFP_KERNEL);
if (!request)
return -ENOMEM;
+ if (chandef_found) {
+ request->chandef = &chandef;
+ request->channels[0] = chandef.chan;
+ request->n_channels = n_channels;
+ }
+
if (n_ssids)
request->ssids = (void *)&request->channels[n_channels];
request->n_ssids = n_ssids;
@@ -8946,7 +8965,7 @@ static int nl80211_trigger_scan(struct s
request->channels[i] = chan;
i++;
}
- } else {
+ } else if (!chandef_found) {
enum nl80211_band band;
/* all channels */