Skip to content

Commit 2ad2274

Browse files
ilanpeer2jmberg-intel
authored andcommitted
mac80211: Add HE 6GHz capabilities element to probe request
On 6 GHz, the 6 GHz capabilities element should be added, do that. Signed-off-by: Ilan Peer <[email protected]> [add commit message] Link: https://lore.kernel.org/r/20200528213443.8ee764f0cde0.I2b0c66b60e11818c97c9803e04a6a197c6376243@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent 1bb9a8a commit 2ad2274

File tree

4 files changed

+58
-17
lines changed

4 files changed

+58
-17
lines changed

include/net/cfg80211.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,26 @@ ieee80211_get_he_sta_cap(const struct ieee80211_supported_band *sband)
512512
return ieee80211_get_he_iftype_cap(sband, NL80211_IFTYPE_STATION);
513513
}
514514

515+
/**
516+
* ieee80211_get_he_6ghz_capa - return HE 6 GHz capabilities
517+
* @sband: the sband to search for the STA on
518+
* @iftype: the iftype to search for
519+
*
520+
* Return: the 6GHz capabilities
521+
*/
522+
static inline __le16
523+
ieee80211_get_he_6ghz_capa(const struct ieee80211_supported_band *sband,
524+
enum nl80211_iftype iftype)
525+
{
526+
const struct ieee80211_sband_iftype_data *data =
527+
ieee80211_get_sband_iftype_data(sband, iftype);
528+
529+
if (WARN_ON(!data || !data->he_cap.has_he))
530+
return 0;
531+
532+
return data->he_6ghz_capa.capa;
533+
}
534+
515535
/**
516536
* wiphy_read_of_freq_limits - read frequency limits from device tree
517537
*

net/mac80211/ieee80211_i.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2144,7 +2144,7 @@ enum {
21442144
IEEE80211_PROBE_FLAG_RANDOM_SN = BIT(2),
21452145
};
21462146

2147-
int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
2147+
int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer,
21482148
size_t buffer_len,
21492149
struct ieee80211_scan_ies *ie_desc,
21502150
const u8 *ie, size_t ie_len,

net/mac80211/scan.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,9 @@ ieee80211_prepare_scan_chandef(struct cfg80211_chan_def *chandef,
313313
}
314314

315315
/* return false if no more work */
316-
static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
316+
static bool ieee80211_prep_hw_scan(struct ieee80211_sub_if_data *sdata)
317317
{
318+
struct ieee80211_local *local = sdata->local;
318319
struct cfg80211_scan_request *req;
319320
struct cfg80211_chan_def chandef;
320321
u8 bands_used = 0;
@@ -361,7 +362,7 @@ static bool ieee80211_prep_hw_scan(struct ieee80211_local *local)
361362
if (req->flags & NL80211_SCAN_FLAG_MIN_PREQ_CONTENT)
362363
flags |= IEEE80211_PROBE_FLAG_MIN_CONTENT;
363364

364-
ielen = ieee80211_build_preq_ies(local,
365+
ielen = ieee80211_build_preq_ies(sdata,
365366
(u8 *)local->hw_scan_req->req.ie,
366367
local->hw_scan_ies_bufsize,
367368
&local->hw_scan_req->ies,
@@ -401,9 +402,12 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
401402
if (WARN_ON(!local->scan_req))
402403
return;
403404

405+
scan_sdata = rcu_dereference_protected(local->scan_sdata,
406+
lockdep_is_held(&local->mtx));
407+
404408
if (hw_scan && !aborted &&
405409
!ieee80211_hw_check(&local->hw, SINGLE_SCAN_ON_ALL_BANDS) &&
406-
ieee80211_prep_hw_scan(local)) {
410+
ieee80211_prep_hw_scan(scan_sdata)) {
407411
int rc;
408412

409413
rc = drv_hw_scan(local,
@@ -432,9 +436,6 @@ static void __ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted)
432436
cfg80211_scan_done(scan_req, &local->scan_info);
433437
}
434438
RCU_INIT_POINTER(local->scan_req, NULL);
435-
436-
scan_sdata = rcu_dereference_protected(local->scan_sdata,
437-
lockdep_is_held(&local->mtx));
438439
RCU_INIT_POINTER(local->scan_sdata, NULL);
439440

440441
local->scanning = 0;
@@ -776,7 +777,7 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
776777
ieee80211_recalc_idle(local);
777778

778779
if (hw_scan) {
779-
WARN_ON(!ieee80211_prep_hw_scan(local));
780+
WARN_ON(!ieee80211_prep_hw_scan(sdata));
780781
rc = drv_hw_scan(local, sdata, local->hw_scan_req);
781782
} else {
782783
rc = ieee80211_start_sw_scan(local, sdata);
@@ -1274,7 +1275,7 @@ int __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
12741275

12751276
ieee80211_prepare_scan_chandef(&chandef, req->scan_width);
12761277

1277-
ieee80211_build_preq_ies(local, ie, num_bands * iebufsz,
1278+
ieee80211_build_preq_ies(sdata, ie, num_bands * iebufsz,
12781279
&sched_scan_ies, req->ie,
12791280
req->ie_len, bands_used, rate_masks, &chandef,
12801281
flags);

net/mac80211/util.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,14 +1663,28 @@ void ieee80211_send_deauth_disassoc(struct ieee80211_sub_if_data *sdata,
16631663
}
16641664
}
16651665

1666-
static int ieee80211_build_preq_ies_band(struct ieee80211_local *local,
1666+
static u8 *ieee80211_write_he_6ghz_cap(u8 *pos, __le16 cap, u8 *end)
1667+
{
1668+
if ((end - pos) < 5)
1669+
return pos;
1670+
1671+
*pos++ = WLAN_EID_EXTENSION;
1672+
*pos++ = 1 + sizeof(cap);
1673+
*pos++ = WLAN_EID_EXT_HE_6GHZ_CAPA;
1674+
memcpy(pos, &cap, sizeof(cap));
1675+
1676+
return pos + 2;
1677+
}
1678+
1679+
static int ieee80211_build_preq_ies_band(struct ieee80211_sub_if_data *sdata,
16671680
u8 *buffer, size_t buffer_len,
16681681
const u8 *ie, size_t ie_len,
16691682
enum nl80211_band band,
16701683
u32 rate_mask,
16711684
struct cfg80211_chan_def *chandef,
16721685
size_t *offset, u32 flags)
16731686
{
1687+
struct ieee80211_local *local = sdata->local;
16741688
struct ieee80211_supported_band *sband;
16751689
const struct ieee80211_sta_he_cap *he_cap;
16761690
u8 *pos = buffer, *end = buffer + buffer_len;
@@ -1848,6 +1862,14 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_local *local,
18481862
pos = ieee80211_ie_build_he_cap(pos, he_cap, end);
18491863
if (!pos)
18501864
goto out_err;
1865+
1866+
if (sband->band == NL80211_BAND_6GHZ) {
1867+
enum nl80211_iftype iftype =
1868+
ieee80211_vif_type_p2p(&sdata->vif);
1869+
__le16 cap = ieee80211_get_he_6ghz_capa(sband, iftype);
1870+
1871+
pos = ieee80211_write_he_6ghz_cap(pos, cap, end);
1872+
}
18511873
}
18521874

18531875
/*
@@ -1862,7 +1884,7 @@ static int ieee80211_build_preq_ies_band(struct ieee80211_local *local,
18621884
return pos - buffer;
18631885
}
18641886

1865-
int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
1887+
int ieee80211_build_preq_ies(struct ieee80211_sub_if_data *sdata, u8 *buffer,
18661888
size_t buffer_len,
18671889
struct ieee80211_scan_ies *ie_desc,
18681890
const u8 *ie, size_t ie_len,
@@ -1877,7 +1899,7 @@ int ieee80211_build_preq_ies(struct ieee80211_local *local, u8 *buffer,
18771899

18781900
for (i = 0; i < NUM_NL80211_BANDS; i++) {
18791901
if (bands_used & BIT(i)) {
1880-
pos += ieee80211_build_preq_ies_band(local,
1902+
pos += ieee80211_build_preq_ies_band(sdata,
18811903
buffer + pos,
18821904
buffer_len - pos,
18831905
ie, ie_len, i,
@@ -1939,7 +1961,7 @@ struct sk_buff *ieee80211_build_probe_req(struct ieee80211_sub_if_data *sdata,
19391961
return NULL;
19401962

19411963
rate_masks[chan->band] = ratemask;
1942-
ies_len = ieee80211_build_preq_ies(local, skb_tail_pointer(skb),
1964+
ies_len = ieee80211_build_preq_ies(sdata, skb_tail_pointer(skb),
19431965
skb_tailroom(skb), &dummy_ie_desc,
19441966
ie, ie_len, BIT(chan->band),
19451967
rate_masks, &chandef, flags);
@@ -2879,10 +2901,8 @@ void ieee80211_ie_build_he_6ghz_cap(struct ieee80211_sub_if_data *sdata,
28792901
}
28802902

28812903
pos = skb_put(skb, 2 + 1 + sizeof(cap));
2882-
*pos++ = WLAN_EID_EXTENSION;
2883-
*pos++ = 1 + sizeof(cap);
2884-
*pos++ = WLAN_EID_EXT_HE_6GHZ_CAPA;
2885-
put_unaligned_le16(cap, pos);
2904+
ieee80211_write_he_6ghz_cap(pos, cpu_to_le16(cap),
2905+
pos + 2 + 1 + sizeof(cap));
28862906
}
28872907

28882908
u8 *ieee80211_ie_build_ht_oper(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,

0 commit comments

Comments
 (0)