* Complete list of AF_ALG algorithms used by iwd
From: Eric Biggers @ 2026-05-04 4:50 UTC (permalink / raw)
To: iwd, Marcel Holtmann, James Prestwood
Cc: linux-crypto, linux-wireless, linux-kernel, Demi Marie Obenour
With AF_ALG being on its way out due to its frequent vulnerabilities,
iwd will need to be fixed to follow the standard practice of using
userspace crypto code (for example, libcrypto) instead. In the mean
time, AF_ALG is at least going to need to be hardened by removing
unnecessary functionality, for example unnecessary algorithms.
Based on the iwd and libell source code, it appears iwd is relying on
the following algorithm names from AF_ALG. Please confirm that this
list is correct and that these are the ones we need to keep for iwd:
cmac(aes)
hmac(md5)
hmac(sha1)
hmac(sha224)
hmac(sha256)
hmac(sha384)
hmac(sha512)
md4
md5
sha1
sha224
sha256
sha384
sha512
ecb(aes)
cbc(aes)
ctr(aes)
ecb(des)
cbc(des)
cbc(des3_ede)
Also, does iwd always hold CAP_NET_ADMIN? We're also considering adding
a privilege check to AF_ALG. (It's TBD whether it would be
unconditional or controlled by a sysctl.)
- Eric
^ permalink raw reply
* [PATCH 4/4] wifi: rtw89: advertise EHT OM Control for 8922a per WFA cert
From: Louis Kotze @ 2026-05-04 4:48 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: linux-wireless, linux-kernel, Louis Kotze
In-Reply-To: <cover.1777832019.git.loukot@gmail.com>
Wi-Fi Alliance Certificate WFA129313 (RTL8922AE, 2024-05-23, firmware
6102.24.109.0) certifies "Operating mode indication" as a Wi-Fi 7
feature for this chip. The driver currently sets only MAX_MPDU_LEN +
RESTRICTED_TWT in mac_cap_info[0], leaving EHT OM Control unset.
Set IEEE80211_EHT_MAC_CAP0_OM_CONTROL in mac_cap_info[0]. EHT OM
Control extends the HE OMI control mechanism (already advertised at
the HE layer) to EHT-specific operating-mode notifications. mt76
(mt7996, mt7925) and iwlwifi mvm + mld already set this single bit
for their Wi-Fi 7 STAs; hwsim sets it in test code.
Tested on RTL8922AU against TP-Link Deco BE63; assoc + EMLSR multi-
link state remain stable.
Link: https://api.cert.wi-fi.org/api/certificate/download/public?variantId=129706 [WFA cert WFA129313]
Signed-off-by: Louis Kotze <loukot@gmail.com>
---
drivers/net/wireless/realtek/rtw89/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index aedb2a284cd4..229c9f8ea65e 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -5564,7 +5564,8 @@ static void rtw89_init_eht_cap(struct rtw89_dev *rtwdev,
eht_cap_elem->mac_cap_info[0] =
u8_encode_bits(chip->max_eht_mpdu_cap,
IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_MASK) |
- IEEE80211_EHT_MAC_CAP0_RESTRICTED_TWT;
+ IEEE80211_EHT_MAC_CAP0_RESTRICTED_TWT |
+ IEEE80211_EHT_MAC_CAP0_OM_CONTROL;
eht_cap_elem->mac_cap_info[1] = 0;
eht_cap_elem->phy_cap_info[0] =
--
2.54.0
^ permalink raw reply related
* [PATCH 3/4] wifi: rtw89: advertise MLD TID-to-link mapping and link reconfiguration
From: Louis Kotze @ 2026-05-04 4:48 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: linux-wireless, linux-kernel, Louis Kotze
In-Reply-To: <cover.1777832019.git.loukot@gmail.com>
Wi-Fi Alliance Certificate WFA129313 (RTL8922AE 802.11be and Bluetooth
combo module, 2024-05-23, FW 6102.24.109.0) certifies both "Advertised
TID-to-link mapping" and "Multi-link reconfiguration (AP removal/restart)"
as Wi-Fi 7 features for this chip. The driver currently sets
mld_capa_and_ops = 0, so the STA negotiates neither capability with the
AP.
Use FIELD_PREP_CONST() (already used elsewhere in this driver, see
usb.c:784-787) to set IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP_SAME
in the TID-to-link-map-neg-supp field, plus
IEEE80211_MLD_CAP_OP_LINK_RECONF_SUPPORT. This matches the value used by
iwlwifi for its Wi-Fi 7 STA mode (see drivers/net/wireless/intel/iwlwifi/
mld/mac80211.c IWL_MLD_CAPA_OPS macro and mvm/mac80211.c
IWL_MVM_MLD_CAPA_OPS macro), which is the established in-tree precedent
for this exact bit pattern on a Wi-Fi 7 STA.
The IEEE80211_MLD_CAP_OP_MAX_SIMUL_LINKS field is left at 0 (= 1 max
simultaneous link, matching the EMLSR-only operating mode the driver
implements per enum rtw89_mlo_mode {MLSR, EMLSR}).
These two capabilities are orthogonal to MLO operating mode (EMLSR
remains the negotiated mode per the previous patch in this series); they
let the AP perform online TID-to-link reassignments and remove or restart
links without a full assoc cycle on the STA side.
Tested on RTL8922AU (USB variant, same MAC + RF as cert'd PCIe AE)
against TP-Link Deco BE63 mesh; assoc remains stable, no regression in
EMLSR multi-link assoc behavior, all 11 wifi-health-check probes pass.
Link: https://api.cert.wi-fi.org/api/certificate/download/public?variantId=129706 [WFA cert WFA129313]
Signed-off-by: Louis Kotze <loukot@gmail.com>
---
drivers/net/wireless/realtek/rtw89/core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 986deb2c1384..aedb2a284cd4 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -221,7 +221,10 @@ static const struct wiphy_iftype_ext_capab rtw89_iftypes_ext_capa[] = {
IEEE80211_EML_CAP_EMLSR_SUPP |
(IEEE80211_EML_CAP_EML_PADDING_DELAY_256US << 1) |
(IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_32US << 4),
- .mld_capa_and_ops = 0,
+ .mld_capa_and_ops =
+ FIELD_PREP_CONST(IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP,
+ IEEE80211_MLD_CAP_OP_TID_TO_LINK_MAP_NEG_SUPP_SAME) |
+ IEEE80211_MLD_CAP_OP_LINK_RECONF_SUPPORT,
},
};
--
2.54.0
^ permalink raw reply related
* [PATCH 2/4] wifi: rtw89: advertise Multi-RU OFDMA receive for 8922a per WFA cert
From: Louis Kotze @ 2026-05-04 4:48 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: linux-wireless, linux-kernel, Louis Kotze
In-Reply-To: <cover.1777832019.git.loukot@gmail.com>
Wi-Fi Alliance Certificate WFA129313 (RTL8922AE, 2024-05-23, firmware
6102.24.109.0) attests "Multi-RU" as a certified Wi-Fi 7 feature for
this chip. The driver currently hard-zeroes the corresponding receive
cap bit in rtw89_init_eht_cap(), which prevents the AP from scheduling
Multi-RU OFDMA TBF (Trigger-Based Frame) payloads with sub-242-tone RU
allocations to this STA.
Set IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP in phy_cap_info[5]
to match the certified silicon behaviour. The Tx-side bit
(CAP5_TX_LESS_242_TONE_RU_SUPP) remains zero since this driver is
STA-mode only and Tx of Multi-RU TBFs is an AP-mode capability.
Tested on RTL8922AU (USB variant, same MAC + RF as cert'd PCIe AE)
against TP-Link Deco BE63 mesh; STA associates and remains stable for
24h+ with no regression in single-RU traffic patterns or in EMLSR
multi-link assoc behavior introduced by the previous EML+R-TWT patch.
Link: https://api.cert.wi-fi.org/api/certificate/download/public?variantId=129706 [WFA cert WFA129313]
Signed-off-by: Louis Kotze <loukot@gmail.com>
---
drivers/net/wireless/realtek/rtw89/core.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 056639db1dfa..986deb2c1384 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -5598,7 +5598,8 @@ static void rtw89_init_eht_cap(struct rtw89_dev *rtwdev,
eht_cap_elem->phy_cap_info[5] =
u8_encode_bits(IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_20US,
- IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK);
+ IEEE80211_EHT_PHY_CAP5_COMMON_NOMINAL_PKT_PAD_MASK) |
+ IEEE80211_EHT_PHY_CAP5_RX_LESS_242_TONE_RU_SUPP;
eht_cap_elem->phy_cap_info[6] = 0;
eht_cap_elem->phy_cap_info[7] = 0;
--
2.54.0
^ permalink raw reply related
* [PATCH 1/4] wifi: rtw89: advertise EML Capabilities and Restricted TWT for 8922a
From: Louis Kotze @ 2026-05-04 4:48 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: linux-wireless, linux-kernel, Louis Kotze
In-Reply-To: <cover.1777832019.git.loukot@gmail.com>
Wi-Fi Alliance Certificate WFA129313 (RTL8922AE 802.11be and Bluetooth
combo module, 2024-05-23, FW 6102.24.109.0) certifies EMLSR (Enhanced
Multilink Single-Radio) and STR (Simultaneous Transmit and Receive) for
this chip. The driver currently sets eml_capabilities = 0 and
mld_capa_and_ops = 0 in the Station iftype-ext-cap, which prevents the
AP from negotiating EMLSR mode with this STA — multi-link association
either falls back to MLSR (single-link) or fails entirely.
Populate eml_capabilities with IEEE80211_EML_CAP_EMLSR_SUPP plus
EML padding delay (256 us, IEEE80211_EML_CAP_EML_PADDING_DELAY_256US
since commit 5858f5e1588f ("wifi: Rename EMLSR delay constants and
add EMLMR helpers and definitions")) and EMLSR transition delay
(32 us) to match the EMLSR negotiation parameters Realtek's
certified silicon supports.
mld_capa_and_ops is left at 0 (= MAX_SIMUL_LINKS field 0 = "1 max
simultaneous link"), consistent with the EMLSR-only operating mode the
driver implements per enum rtw89_mlo_mode {MLSR, EMLSR} (no STR mode
in the driver despite WFA-cert silicon support).
Also add IEEE80211_EHT_MAC_CAP0_RESTRICTED_TWT to mac_cap_info[0].
The RTL8922A EHT MAC supports R-TWT for latency-sensitive scheduling;
the cap bit was hard-zeroed alongside the other EHT mac/phy caps in
rtw89_init_eht_cap().
Tested on RTL8922AU (USB variant, same MAC + RF as cert'd PCIe AE)
against TP-Link Deco BE63 mesh: dual-link MLO assoc works
(active_links = 0x4 confirms expected EMLSR mode, Link 2 / 6 GHz
active), 60h+ stable association, 11/11 wifi-health-check probes
pass, no kernel warnings or wpa_supplicant errors.
Note on EMLMR (EML Cap bit 7, IEEE80211_EML_CAP_EMLMR_SUPPORT): not
advertised. The WFA cert does NOT list EMLMR for this chip.
RTL8922A has rf_path_num=2 (single 2T2R RF block shared across 2.4,
5, 6 GHz), and the driver has no EMLMR enum, firmware H2C path, or
PHY register block. EMLSR is the architectural ceiling for this
silicon.
Link: https://api.cert.wi-fi.org/api/certificate/download/public?variantId=129706 [WFA cert WFA129313]
Signed-off-by: Louis Kotze <loukot@gmail.com>
---
drivers/net/wireless/realtek/rtw89/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/core.c b/drivers/net/wireless/realtek/rtw89/core.c
index 70feab97dccb..056639db1dfa 100644
--- a/drivers/net/wireless/realtek/rtw89/core.c
+++ b/drivers/net/wireless/realtek/rtw89/core.c
@@ -217,7 +217,10 @@ static const struct wiphy_iftype_ext_capab rtw89_iftypes_ext_capa[] = {
.extended_capabilities_mask = rtw89_ext_capa_sta,
.extended_capabilities_len = sizeof(rtw89_ext_capa_sta),
/* relevant only if EHT is supported */
- .eml_capabilities = 0,
+ .eml_capabilities =
+ IEEE80211_EML_CAP_EMLSR_SUPP |
+ (IEEE80211_EML_CAP_EML_PADDING_DELAY_256US << 1) |
+ (IEEE80211_EML_CAP_EMLSR_TRANSITION_DELAY_32US << 4),
.mld_capa_and_ops = 0,
},
};
@@ -5557,7 +5560,8 @@ static void rtw89_init_eht_cap(struct rtw89_dev *rtwdev,
eht_cap_elem->mac_cap_info[0] =
u8_encode_bits(chip->max_eht_mpdu_cap,
- IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_MASK);
+ IEEE80211_EHT_MAC_CAP0_MAX_MPDU_LEN_MASK) |
+ IEEE80211_EHT_MAC_CAP0_RESTRICTED_TWT;
eht_cap_elem->mac_cap_info[1] = 0;
eht_cap_elem->phy_cap_info[0] =
--
2.54.0
^ permalink raw reply related
* [PATCH 0/4] wifi: rtw89: advertise WFA-certified EHT capabilities for 8922a
From: Louis Kotze @ 2026-05-04 4:48 UTC (permalink / raw)
To: Ping-Ke Shih; +Cc: linux-wireless, linux-kernel, Louis Kotze
This series advances rtw89 EHT capability advertisement to match what
Realtek's own RTL8922AE silicon is certified for by the Wi-Fi Alliance
in WFA Cert WFA129313 (RTL8922AE 802.11be and Bluetooth combo module,
2024-05-23, FW 6102.24.109.0,
https://api.cert.wi-fi.org/api/certificate/download/public?variantId=129706).
The cert lists EMLSR, STR, Multi-RU, MCS 8-13, DL/UL MU-MIMO, UL OFDMA,
SU-MIMO, beamforming sounding, multi-link reconfiguration, advertised
TID-to-link mapping, BSS critical update, A-MPDU with A-MSDU, LDPC,
operating mode indication, EPCS priority access, and several other
features as certified for this chip. The driver currently advertises
some of these and hard-zeroes others. This series fills the gap for
four cap surfaces:
Patch 1/4: EML Capabilities (EMLSR_SUPP + padding/transition delays)
plus Restricted TWT (EHT MAC Cap0). EMLSR is explicitly
listed in the WFA cert. R-TWT is silicon-supported per the
chip's documented EHT MAC capabilities.
Patch 2/4: Multi-RU OFDMA receive cap (CAP5_RX_LESS_242_TONE_RU_SUPP).
Multi-RU is verbatim in the WFA cert.
Patch 3/4: MLD operation caps — TID-to-link mapping (SAME) +
Link Reconfiguration support. Both verbatim in the WFA
cert. Uses FIELD_PREP_CONST() (already used in this driver
at usb.c:784-787) and matches the bit pattern Intel uses
for its Wi-Fi 7 STAs (IWL_MVM_MLD_CAPA_OPS in
iwlwifi/mvm/mac80211.c). MAX_SIMUL_LINKS is left at 0
(= 1 max simul link) consistent with the EMLSR-only
operating mode the driver implements.
Patch 4/4: EHT OM Control (MAC Cap0). "Operating mode indication" is
verbatim in the WFA cert; mt7925 + iwlwifi mvm + hwsim
precedent.
Industry context: this series advances rtw89 along the same axis every
in-tree Linux WiFi 7 driver currently occupies — MLSR/EMLSR fast-switch
on a single physical radio. True STR multi-radio aggregation is not
implemented by any in-tree driver as of v6.15+ (iwlwifi, mt7925, ath12k,
rtw89). The only known shipping consumer STR adapter on any OS is the
Ubiquiti UniFi AirWire (closed firmware, UniFi-AP-only). This series
does not attempt STR; it brings rtw89 EMLSR negotiation in line with
the other three drivers.
Testing: applied as a stack to the morrownr/rtw89 OOT clone on Linux
6.19.11 (Bazzite F44) running RTL8922AU USB; tested against TP-Link
Deco BE63 mesh (5-node) for 48h+ continuous association. Verified caps
appear in `iw phy` output (Restricted TWT, OM Control, "Rx 1024-QAM
And 4096-QAM < 242-tone RU"). active_links = 0x4 confirms expected
EMLSR mode. wifi-health-check sweep (11 checks: wpa override, rpm-ostree
state, rtw89 build, SELinux, NM dispatchers, regdomain, link state,
SELinux AVC rate, MLO link count) passes 11/11 throughout the soak.
A/B comparison patched vs unpatched, 3-NIC concurrent reverse-mode
iperf3, 5 reps patched + 3 reps unpatched per SSID, signal -10 to
-25 dBm: no measurable throughput delta (MLO patched mean 1128 Mbps
vs unpatched mean 1174 Mbps; 6 GHz patched mean 1099 Mbps vs unpatched
mean 1169 Mbps; deltas well within ±5% noise floor and dominated by
per-test MCS variation, not patch state). The patches enable correct
cap advertisement matching what RTL8922A silicon supports per the
WFA cert; they do not aim to deliver throughput improvement in
steady-state operation against this AP. Patches are about correctness
and standards-compliance, not throughput.
Tested only on RTL8922AU (USB variant); rtw89_init_eht_cap() and the
iftype-ext-cap struct are shared across the rtw89 chip family. Non-AU
variant testing from anyone with rtw89-supported hardware is welcome.
Note on EMLMR (EML Cap bit 7): the WFA cert does NOT list EMLMR for
this chip. RTL8922A has rf_path_num=2 (single 2T2R RF block shared
across bands), and the driver has no EMLMR enum, firmware H2C path,
or PHY register block. EMLSR is the architectural ceiling for this
silicon; this series does not advertise EMLMR.
Note on follow-up: a separate audit identified five further capability
fields hard-zeroed in rtw89_init_eht_cap() (EHT A-MPDU exponent,
partial-BW DL/UL MU-MIMO, MCS 14-15, sounding dimensions, 1024/4096-QAM
wider-BW DL-OFDMA). Some of these are likely silicon ceilings (MCS 14-15
is consistent with the cert topping out at MCS 12-13); others may be
driver-only gaps. I plan to send a small ASK email separately covering
those questions before any follow-up patch series.
Louis Kotze (4):
wifi: rtw89: advertise EML Capabilities and Restricted TWT for 8922a
wifi: rtw89: advertise Multi-RU OFDMA receive for 8922a per WFA cert
wifi: rtw89: advertise MLD TID-to-link mapping and link reconfiguration
wifi: rtw89: advertise EHT OM Control for 8922a per WFA cert
drivers/net/wireless/realtek/rtw89/core.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
Louis Kotze (4):
wifi: rtw89: advertise EML Capabilities and Restricted TWT for 8922a
wifi: rtw89: advertise Multi-RU OFDMA receive for 8922a per WFA cert
wifi: rtw89: advertise MLD TID-to-link mapping and link
reconfiguration
wifi: rtw89: advertise EHT OM Control for 8922a per WFA cert
drivers/net/wireless/realtek/rtw89/core.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
base-commit: 7baf5857e15d722776898510a10546d6b2f18645
--
2.54.0
^ permalink raw reply
* [PATCH] wifi: wcn36xx: fix spelling mistakes in dxe header comment
From: Stepan Ionichev @ 2026-05-03 16:58 UTC (permalink / raw)
To: loic.poulain; +Cc: wcn36xx, linux-wireless, linux-kernel, Stepan Ionichev
Fix three spelling mistakes in the DMA Transfer Engine (DXE)
description comment at the top of dxe.c.
No functional change.
Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
---
drivers/net/wireless/ath/wcn36xx/dxe.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/wcn36xx/dxe.c b/drivers/net/wireless/ath/wcn36xx/dxe.c
index 5a0ef2295..44020ec26 100644
--- a/drivers/net/wireless/ath/wcn36xx/dxe.c
+++ b/drivers/net/wireless/ath/wcn36xx/dxe.c
@@ -16,8 +16,8 @@
/* DXE - DMA transfer engine
* we have 2 channels(High prio and Low prio) for TX and 2 channels for RX.
- * through low channels data packets are transfered
- * through high channels managment packets are transfered
+ * through low channels data packets are transferred
+ * through high channels management packets are transferred
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
--
2.33.0.windows.2
^ permalink raw reply related
* Re: [PATCH 1/2] wifi: mt76: mt792x: disable HW TX/RX encap offload to fix TDLS direct-link
From: Sean Wang @ 2026-05-03 17:53 UTC (permalink / raw)
To: ElXreno
Cc: Felix Fietkau, Lorenzo Bianconi, Ryder Lee, Shayne Chen,
Sean Wang, Matthias Brugger, AngeloGioacchino Del Regno,
Soul Huang, Ming Yen Hsieh, Deren Wu, linux-wireless,
linux-kernel, linux-arm-kernel, linux-mediatek, stable
In-Reply-To: <20260503-mt7925-tdls-fixes-v1-1-dde847e21081@gmail.com>
Hi ElXreno,
On Sat, May 2, 2026 at 8:40 PM ElXreno <elxreno@gmail.com> wrote:
>
> On MediaTek MT7925 (Connac3), QoS Data frames whose destination WCID
> is a TDLS direct-link peer are silently dropped after submission to
> firmware via the HW_80211_ENCAP TX path. The driver sees submit and
> complete counts match (firmware reports success on TX queue
> submission), but the frames never reach the PHY. iw counters show
> tx_packets growing, tx_failed = 0, tx_retries low; on the air,
> nothing.
>
> This breaks TDLS direct-link as soon as a peer auto-initiates one
> (Samsung phones do this aggressively when both peers share a BSS and
> traffic exceeds a threshold). Pattern is:
>
> 1. Any sustained direct traffic between two STAs sharing the BSS
> reaches the auto-TDLS threshold within ~1 s.
> 2. Peer initiates TDLS; mac80211 routes data frames to the TDLS-peer
> WCID and the AP stops forwarding peer-to-peer traffic per the
> 802.11z spec.
> 3. Direct-link frames are accepted by firmware, completed in the TX
> descriptor pool, but never PHY-transmitted.
> 4. TCP collapses; the peer eventually tears down the TDLS link with
> reason WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED. Cycle repeats.
>
> Effective TCP throughput drops from ~300 Mbit/s (AP route) to ~6
> Mbit/s with TDLS active.
>
> Verified on mt7925e (PCIe) at 5 GHz HE NSS 2 MCS 11 80 MHz and at
> 2.4 GHz 802.11n HT NSS 2 MCS 15. With this patch, TDLS direct link
> sustains ~750 Mbit/s and ~130 Mbit/s respectively.
>
> mt76 advertises WIPHY_FLAG_SUPPORTS_TDLS via the shared
> mt76_register_phy_helper() but does not provide TDLS-aware
> firmware-facing peer setup: no CONNECTION_TDLS constant in
> mt76_connac_mcu.h, no STA_REC_TDLS TLV, no TDLS bit in
> mt76_wcid_flags, and no TDLS-specific code in
> mt7925_mac_write_txwi_8023(). TDLS peers are registered as
> CONNECTION_INFRA_STA with peer_addr set to the peer's MAC and
> nothing else. The proprietary out-of-tree MediaTek driver carries an
> explicit cfg80211_tdls.c (PTK/TK install paths, etc.) with no
> in-tree equivalent. Whether the underlying gap is in the firmware
> HW_ENCAP path or in mt76's missing TDLS-aware setup is unclear from
> the kernel side; the software-encap path sidesteps it either way.
>
> Work around the issue by not advertising SUPPORTS_TX_ENCAP_OFFLOAD
> and SUPPORTS_RX_DECAP_OFFLOAD in mt792x_init_wiphy(). mac80211 then
> takes the software 802.11 encap path, which submits already-formed
> 802.11 frames via a different firmware path that handles all WCIDs
> correctly, including TDLS peers.
>
> mt792x_init_wiphy() is shared with the Connac2 family (mt7921/22/20/02),
> which uses the same firmware HW_ENCAP path; the disable is applied
> globally to cover the likely-affected chips. If Connac2 is later
> confirmed unaffected, the disable can be narrowed with is_mt7925().
>
> Fixes: 5c14a5f944b9 ("mt76: mt7921: introduce mt7921e support")
> Cc: stable@vger.kernel.org
> Signed-off-by: ElXreno <elxreno@gmail.com>
> Assisted-by: Claude:claude-opus-4-7 bpftrace
> ---
> drivers/net/wireless/mediatek/mt76/mt792x_core.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt792x_core.c b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
> index 152cfcca2f90..f9610c6c1597 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt792x_core.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt792x_core.c
> @@ -681,8 +681,14 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)
>
> ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
> ieee80211_hw_set(hw, HAS_RATE_CONTROL);
> - ieee80211_hw_set(hw, SUPPORTS_TX_ENCAP_OFFLOAD);
> - ieee80211_hw_set(hw, SUPPORTS_RX_DECAP_OFFLOAD);
> + /* HW TX/RX 802.11 encap offload is intentionally NOT advertised:
> + * the firmware HW_80211_ENCAP path silently drops QoS Data frames
> + * whose destination WCID is a TDLS direct-link peer, breaking TDLS
> + * data flow. The mac80211 software encap path submits already-formed
> + * 802.11 frames, which the firmware handles correctly for all WCIDs.
> + * Re-add SUPPORTS_TX_ENCAP_OFFLOAD / SUPPORTS_RX_DECAP_OFFLOAD here
> + * once the firmware HW_ENCAP path is fixed.
> + */
I do not think disabling TX/RX encap offload globally in
mt792x_init_wiphy() is the right fix.
The reported failure is specific to TDLS direct-link peers, while this
change affects all normal STA/AP/P2P data paths and all mt792x chips,
including mt7925/mt7921/22/20/02. This is too broad for a TDLS-specific issue.
The commit message already points out that mt76 lacks TDLS-aware
firmware-facing peer setup, and also mentions that the proprietary
out-of-tree MediaTek driver has an explicit cfg80211_tdls.c
implementation. If that driver supports TDLS on top of the firmware HW
encap model, I think we should try to align the in-tree driver with that
design by adding the missing TDLS-aware firmware-facing peer setup,
instead of disabling HW encap globally.
In particular, I would prefer to first check whether adding
CONNECTION_TDLS / proper TDLS peer setup on top of the current code is
enough to fix the issue.
Please avoid removing SUPPORTS_TX_ENCAP_OFFLOAD and
SUPPORTS_RX_DECAP_OFFLOAD globally from mt792x_init_wiphy().
> ieee80211_hw_set(hw, WANT_MONITOR_VIF);
> ieee80211_hw_set(hw, SUPPORTS_PS);
> ieee80211_hw_set(hw, SUPPORTS_DYNAMIC_PS);
>
> --
> 2.53.0
>
>
^ permalink raw reply
* [PATCH] wifi: rtw88: add quirk to disable deep LPS for ASUS VivoBook X515JA
From: Gabriel Maia @ 2026-05-03 16:49 UTC (permalink / raw)
To: linux-wireless; +Cc: pkshih, kvalo, Gabriel Maia
On ASUS VivoBook X515JA laptops equipped with a Realtek RTL8821CE
802.11ac PCIe adapter (PCI ID: 10ec:c821, subsystem: 1a3b:3040),
the driver periodically emits the following messages:
rtw88_8821ce 0000:01:00.0: firmware failed to leave lps state
rtw88_8821ce 0000:01:00.0: failed to send h2c command
The firmware fails to leave the Low Power State (LPS) in time,
causing subsequent h2c commands to be dropped. Disable deep LPS
to avoid this issue.
Signed-off-by: Gabriel Maia <gabriel_v_maia@estudante.sesisenai.org.br>
---
drivers/net/wireless/realtek/rtw88/pci.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
index bba370ad510c..b0eae0971ef4 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.c
+++ b/drivers/net/wireless/realtek/rtw88/pci.c
@@ -1770,6 +1770,15 @@ static const struct dmi_system_id rtw_pci_quirks[] = {
.driver_data = (void *)(BIT(QUIRK_DIS_CAP_PCI_ASPM) |
BIT(QUIRK_DIS_CAP_LPS_DEEP)),
},
+ {
+ .callback = rtw_pci_disable_caps,
+ .ident = "ASUS VivoBook X515JA",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "VivoBook_ASUSLaptop X515JA_X515JA"),
+ },
+ .driver_data = (void *)BIT(QUIRK_DIS_CAP_LPS_DEEP),
+ },
{}
};
--
2.53.0
^ permalink raw reply related
* Bug report on the mt7921e for Linux
From: Malik Belhajji @ 2026-05-03 9:43 UTC (permalink / raw)
To: linux-wireless
Hello I am reporting a bug in Linux Kernel 7.1 rc-1 when rebooting at
"Stop job for Wireless service" and Network Service a kernel panics
occurs with "Fatal Exception in Interrupt". And resuming from sleep
this occurs :
$ sudo dmesg | grep -i mt7921 [ 0.000000] Command line:
root=UUID=6a9e638f-42a5-4439-b42f-706d2e3cbf68 rw pcie_aspm=off
mt7921e.disable_aspm=1 [amdgpu.sg](http://amdgpu.sg)_display=0 quiet
splash drm.panic_screen=qr_code
initrd=\09d8cc21236248aa9d49bfef3d6bb139\7.1.0-rc1-1-mainline\initrd [
0.038745] Kernel command line:
root=UUID=6a9e638f-42a5-4439-b42f-706d2e3cbf68 rw pcie_aspm=off
mt7921e.disable_aspm=1 [amdgpu.sg](http://amdgpu.sg)_display=0 quiet
splash drm.panic_screen=qr_code
initrd=\09d8cc21236248aa9d49bfef3d6bb139\7.1.0-rc1-1-mainline\initrd [
12.372208] mt7921_common: unknown parameter 'disable_aspm' ignored [
12.401344] mt7921e 0000:03:00.0: enabling device (0000 -> 0002) [
12.410993] mt7921e 0000:03:00.0: disabling ASPM L1 [ 12.418543]
mt7921e 0000:03:00.0: ASIC revision: 79610010 [ 12.513540] mt7921e
0000:03:00.0: HW/SW Version: 0x8a108a10, Build Time: 20260224110909a [
12.775301] mt7921e 0000:03:00.0: WM Firmware Version: ____010000,
Build Time: 20260224110949 [ 50.403949] mt7921e 0000:03:00.0: Unable
to change power state from D3cold to D0, device inaccessible [
50.409580] mt7921e 0000:03:00.0: disabling ASPM L0s L1 [ 51.444481]
mt7921e 0000:03:00.0: driver own failed [ 51.444528] mt7921e
0000:03:00.0: probe with driver mt7921e failed with error -5 ~ $ sudo
modprobe -r mt7921e ~ $ sudo modprobe mt7921e ~ $ sudo dmesg | grep -i
mt7921 [ 0.000000] Command line:
root=UUID=6a9e638f-42a5-4439-b42f-706d2e3cbf68 rw pcie_aspm=off
mt7921e.disable_aspm=1 [amdgpu.sg](http://amdgpu.sg)_display=0 quiet
splash drm.panic_screen=qr_code
initrd=\09d8cc21236248aa9d49bfef3d6bb139\7.1.0-rc1-1-mainline\initrd [
0.038745] Kernel command line:
root=UUID=6a9e638f-42a5-4439-b42f-706d2e3cbf68 rw pcie_aspm=off
mt7921e.disable_aspm=1 [amdgpu.sg](http://amdgpu.sg)_display=0 quiet
splash drm.panic_screen=qr_code
initrd=\09d8cc21236248aa9d49bfef3d6bb139\7.1.0-rc1-1-mainline\initrd [
12.372208] mt7921_common: unknown parameter 'disable_aspm' ignored [
12.401344] mt7921e 0000:03:00.0: enabling device (0000 -> 0002) [
12.410993] mt7921e 0000:03:00.0: disabling ASPM L1 [ 12.418543]
mt7921e 0000:03:00.0: ASIC revision: 79610010 [ 12.513540] mt7921e
0000:03:00.0: HW/SW Version: 0x8a108a10, Build Time: 20260224110909a [
12.775301] mt7921e 0000:03:00.0: WM Firmware Version: ____010000,
Build Time: 20260224110949 [ 50.403949] mt7921e 0000:03:00.0: Unable
to change power state from D3cold to D0, device inaccessible [
50.409580] mt7921e 0000:03:00.0: disabling ASPM L0s L1 [ 51.444481]
mt7921e 0000:03:00.0: driver own failed [ 51.444528] mt7921e
0000:03:00.0: probe with driver mt7921e failed with error -5 [
94.446687] mt7921_common: unknown parameter 'disable_aspm' ignored [
94.460319] mt7921e 0000:03:00.0: Unable to change power state from
D3cold to D0, device inaccessible [ 94.460516] mt7921e 0000:03:00.0:
disabling ASPM L0s L1 [ 95.486486] mt7921e 0000:03:00.0: driver own
failed [ 95.486533] mt7921e 0000:03:00.0: probe with driver mt7921e
failed with error -5
This happens on older kernels (6.18 and 7.0) and it's annoying that
kernel panics occurs randomly with this card. Specs are ASUS TUF A17
2021 (FA706IC) EndeavourOS (Arch Linux) and dual booting with Windows
(fast startup disabled).
Best regards
^ permalink raw reply
* [PATCH v3 wireless-next 15/15] wifi: mac80211_hwsim: switch to use TXQs
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
Simply immediately TX all available packets on the corresponding queue.
This removes the HWSIM_TM_CMD_STOP_QUEUES/HWSIM_TM_CMD_RESUME_QUEUES
feature for now. It should be reasonably simple to add it back if it is
needed.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
.../wireless/virtual/mac80211_hwsim_main.c | 20 ++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index c6d1f841c04d..e510357c1411 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -2198,6 +2198,17 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
ieee80211_tx_status_irqsafe(hw, skb);
}
+static void ieee80211_hwsim_wake_tx_queue(struct ieee80211_hw *hw,
+ struct ieee80211_txq *txq)
+{
+ struct ieee80211_tx_control control = {
+ .sta = txq->sta,
+ };
+ struct sk_buff *skb;
+
+ while ((skb = ieee80211_tx_dequeue(hw, txq)))
+ mac80211_hwsim_tx(hw, &control, skb);
+}
static int mac80211_hwsim_start(struct ieee80211_hw *hw)
{
@@ -2943,11 +2954,7 @@ static int mac80211_hwsim_testmode_cmd(struct ieee80211_hw *hw,
goto nla_put_failure;
return cfg80211_testmode_reply(skb);
case HWSIM_TM_CMD_STOP_QUEUES:
- ieee80211_stop_queues(hw);
- return 0;
case HWSIM_TM_CMD_WAKE_QUEUES:
- ieee80211_wake_queues(hw);
- return 0;
default:
return -EOPNOTSUPP;
}
@@ -4051,7 +4058,7 @@ static int mac80211_hwsim_set_radar_background(struct ieee80211_hw *hw,
#define HWSIM_COMMON_OPS \
.tx = mac80211_hwsim_tx, \
- .wake_tx_queue = ieee80211_handle_wake_tx_queue, \
+ .wake_tx_queue = ieee80211_hwsim_wake_tx_queue, \
.start = mac80211_hwsim_start, \
.stop = mac80211_hwsim_stop, \
.add_interface = mac80211_hwsim_add_interface, \
@@ -5530,6 +5537,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
ieee80211_hw_set(hw, TDLS_WIDER_BW);
ieee80211_hw_set(hw, SUPPORTS_MULTI_BSSID);
ieee80211_hw_set(hw, STRICT);
+ ieee80211_hw_set(hw, BUFF_MMPDU_TXQ);
+ ieee80211_hw_set(hw, STA_MMPDU_TXQ);
if (param->mlo) {
hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_MLO;
@@ -5588,6 +5597,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
hw->vif_data_size = sizeof(struct hwsim_vif_priv);
hw->sta_data_size = sizeof(struct hwsim_sta_priv);
hw->chanctx_data_size = sizeof(struct hwsim_chanctx_priv);
+ hw->txq_data_size = 0;
memcpy(data->channels_2ghz, hwsim_channels_2ghz,
sizeof(hwsim_channels_2ghz));
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 14/15] wifi: mac80211_hwsim: refactor NAN timer handling
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
Refactor the NAN timer to more closely track the where in the NAN
schedule the device currently is. Do this by having an hrtimer that
fires at the start of every slot.
For now continue to update the current channel at the start of the DW.
In the future, the correct channel according to the schedule should be
used everywhere.
This is in preparation to more accurately simulate more of the NAN
logic.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
.../net/wireless/virtual/mac80211_hwsim_i.h | 5 +
.../wireless/virtual/mac80211_hwsim_main.c | 22 +--
.../net/wireless/virtual/mac80211_hwsim_nan.c | 160 ++++++++++++------
.../net/wireless/virtual/mac80211_hwsim_nan.h | 8 +-
4 files changed, 133 insertions(+), 62 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_i.h b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
index d345595ca588..6b2a5dccb106 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_i.h
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
@@ -128,6 +128,11 @@ struct mac80211_hwsim_data {
extern spinlock_t hwsim_radio_lock;
extern struct list_head hwsim_radios;
+ktime_t mac80211_hwsim_tsf_to_boottime(struct mac80211_hwsim_data *data,
+ u64 tsf);
+u64 mac80211_hwsim_boottime_to_tsf(struct mac80211_hwsim_data *data,
+ ktime_t ts);
+
u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
struct ieee80211_vif *vif);
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index ba2aa09b37cb..c6d1f841c04d 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -1216,12 +1216,18 @@ static inline u64 mac80211_hwsim_get_sim_tsf(void)
return ktime_to_us(ktime_get_boottime());
}
-static ktime_t mac80211_hwsim_tsf_to_boottime(struct mac80211_hwsim_data *data,
- u64 tsf)
+ktime_t mac80211_hwsim_tsf_to_boottime(struct mac80211_hwsim_data *data,
+ u64 tsf)
{
return us_to_ktime(tsf - data->tsf_offset);
}
+u64 mac80211_hwsim_boottime_to_tsf(struct mac80211_hwsim_data *data,
+ ktime_t ts)
+{
+ return ktime_to_us(ts + data->tsf_offset);
+}
+
u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
{
@@ -2045,12 +2051,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
* on channel 6 or channel 149, unless a ROC is in progress (for
* USD use cases).
*/
- if (data->nan.curr_dw_band == NL80211_BAND_2GHZ)
- channel = ieee80211_get_channel(hw->wiphy, 2437);
- else if (data->nan.curr_dw_band == NL80211_BAND_5GHZ)
- channel = ieee80211_get_channel(hw->wiphy, 5745);
- else
- channel = NULL;
+ channel = data->nan.channel;
if (WARN_ON(!channel)) {
ieee80211_free_txskb(hw, skb);
@@ -5451,8 +5452,9 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
NAN_DEV_CAPA_EXT_KEY_ID_SUPPORTED |
NAN_DEV_CAPA_NDPE_SUPPORTED;
- hrtimer_setup(&data->nan.timer, mac80211_hwsim_nan_dw_start,
- CLOCK_MONOTONIC, HRTIMER_MODE_ABS_SOFT);
+ hrtimer_setup(&data->nan.slot_timer,
+ mac80211_hwsim_nan_slot_timer,
+ CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);
}
data->if_combination.radar_detect_widths =
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_nan.c b/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
index 5d7c736d7972..f4191954ca9d 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
@@ -6,63 +6,132 @@
#include "mac80211_hwsim_i.h"
+/* Defined as the lower 23 bits being zero */
+#define DW0_TSF_MASK GENMASK(22, 0)
+
+/* DWs are repeated every 512 TUs */
+#define DWST_TU 512
+#define DWST_TSF_MASK (ieee80211_tu_to_usec(DWST_TU) - 1)
+
+#define SLOT_TU 16
+#define SLOT_TSF_MASK (ieee80211_tu_to_usec(DWST_TU) - 1)
+
+/* The 2.4 GHz DW is at the start, the 5 GHz is in slot 8 (after 128 TUs) */
+#define DW_5G_OFFSET_TU 128
+
+#define SLOT_24GHZ_DW 0
+#define SLOT_5GHZ_DW (DW_5G_OFFSET_TU / SLOT_TU)
+
+/* The special DW0 happens every 16 DWSTs (8192 TUs) */
+static_assert(16 * DWST_TU * 1024 == 8192 * 1024);
+static_assert(DW0_TSF_MASK + 1 == 8192 * 1024);
+
static u8 hwsim_nan_cluster_id[ETH_ALEN];
+static u64 hwsim_nan_get_timer_tsf(struct mac80211_hwsim_data *data)
+{
+ ktime_t expires = hrtimer_get_expires(&data->nan.slot_timer);
+
+ return mac80211_hwsim_boottime_to_tsf(data, expires);
+}
+
+static u8 hwsim_nan_slot_from_tsf(u64 tsf)
+{
+ return (tsf & DWST_TSF_MASK) / ieee80211_tu_to_usec(SLOT_TU);
+}
+
+static void
+mac80211_hwsim_nan_schedule_slot(struct mac80211_hwsim_data *data, u8 slot)
+{
+ u64 tsf = hwsim_nan_get_timer_tsf(data);
+
+ /* Only called by mac80211_hwsim_nan_dw_timer from softirq context */
+ lockdep_assert_in_softirq();
+
+ tsf &= ~DWST_TSF_MASK;
+ tsf += ieee80211_tu_to_usec(slot * SLOT_TU);
+
+ hrtimer_set_expires(&data->nan.slot_timer,
+ mac80211_hwsim_tsf_to_boottime(data, tsf));
+}
+
+static void
+mac80211_hwsim_nan_exec_state_transitions(struct mac80211_hwsim_data *data)
+{
+ /*
+ * Handle NAN role and state transitions at the end of the DW period
+ * in accordance to Wi-Fi Aware version 4.0 section 3.3.7 point 2, i.e.
+ * end of 5 GHz DW if enabled else at the end of the 2.4 GHz DW.
+ *
+ * TODO: Implement
+ */
+}
+
enum hrtimer_restart
-mac80211_hwsim_nan_dw_start(struct hrtimer *timer)
+mac80211_hwsim_nan_slot_timer(struct hrtimer *timer)
{
struct mac80211_hwsim_data *data =
container_of(timer, struct mac80211_hwsim_data,
- nan.timer);
+ nan.slot_timer);
struct ieee80211_hw *hw = data->hw;
- u64 orig_tsf = mac80211_hwsim_get_tsf(hw, NULL), tsf = orig_tsf;
- u32 dw_int = 512 * 1024;
- u64 until_dw;
+ struct ieee80211_channel *notify_dw_chan = NULL;
+ u64 tsf = hwsim_nan_get_timer_tsf(data);
+ u8 slot = hwsim_nan_slot_from_tsf(tsf);
+ bool dwst_of_dw0 = false;
+ bool dw_end = false;
if (!data->nan.device_vif)
return HRTIMER_NORESTART;
- if (data->nan.bands & BIT(NL80211_BAND_5GHZ)) {
- if (data->nan.curr_dw_band == NL80211_BAND_2GHZ) {
- dw_int = 128 * 1024;
- data->nan.curr_dw_band = NL80211_BAND_5GHZ;
- } else if (data->nan.curr_dw_band == NL80211_BAND_5GHZ) {
- data->nan.curr_dw_band = NL80211_BAND_2GHZ;
- }
- }
+ if ((tsf & DW0_TSF_MASK & ~DWST_TSF_MASK) == 0)
+ dwst_of_dw0 = true;
- until_dw = dw_int - do_div(tsf, dw_int);
- /* The timer might fire just before the actual DW, in which case
- * update the timeout to the actual next DW
- */
- if (until_dw < dw_int / 2)
- until_dw += dw_int;
+ switch (slot) {
+ case SLOT_24GHZ_DW:
+ wiphy_dbg(data->hw->wiphy, "Start of 2.4 GHz DW, is DW0=%d\n",
+ dwst_of_dw0);
+ data->nan.channel = ieee80211_get_channel(hw->wiphy, 2437);
+ break;
- /* The above do_div() call directly modifies the 'tsf' variable, thus,
- * use a copy so that the print below would show the original TSF.
- */
- wiphy_debug(hw->wiphy,
- "%s: tsf=%llx, curr_dw_band=%u, next_dw=%llu\n",
- __func__, orig_tsf, data->nan.curr_dw_band,
- until_dw);
+ case SLOT_24GHZ_DW + 1:
+ if (!(data->nan.bands & BIT(NL80211_BAND_5GHZ))) {
+ notify_dw_chan = ieee80211_get_channel(hw->wiphy, 2437);
+ dw_end = true;
+ } else {
+ notify_dw_chan = ieee80211_get_channel(hw->wiphy, 5745);
+ }
+ break;
- hrtimer_forward_now(&data->nan.timer,
- ns_to_ktime(until_dw * NSEC_PER_USEC));
+ case SLOT_5GHZ_DW:
+ if (data->nan.bands & BIT(NL80211_BAND_5GHZ)) {
+ wiphy_dbg(data->hw->wiphy, "Start of 5 GHz DW\n");
+ data->nan.channel =
+ ieee80211_get_channel(hw->wiphy, 5745);
+ }
+ break;
+
+ case SLOT_5GHZ_DW + 1:
+ if (data->nan.bands & BIT(NL80211_BAND_5GHZ)) {
+ notify_dw_chan =
+ ieee80211_get_channel(hw->wiphy, 2437);
+ dw_end = true;
+ }
+ break;
+ }
+
+ if (dw_end)
+ mac80211_hwsim_nan_exec_state_transitions(data);
- if (data->nan.notify_dw) {
- struct ieee80211_channel *ch;
+ if (data->nan.notify_dw && notify_dw_chan) {
struct wireless_dev *wdev =
ieee80211_vif_to_wdev(data->nan.device_vif);
- if (data->nan.curr_dw_band == NL80211_BAND_5GHZ)
- ch = ieee80211_get_channel(hw->wiphy, 5745);
- else
- ch = ieee80211_get_channel(hw->wiphy, 2437);
-
- cfg80211_next_nan_dw_notif(wdev, ch, GFP_ATOMIC);
+ cfg80211_next_nan_dw_notif(wdev, notify_dw_chan, GFP_ATOMIC);
}
+ mac80211_hwsim_nan_schedule_slot(data, slot + 1);
+
return HRTIMER_RESTART;
}
@@ -71,9 +140,6 @@ int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
struct cfg80211_nan_conf *conf)
{
struct mac80211_hwsim_data *data = hw->priv;
- u64 tsf = mac80211_hwsim_get_tsf(hw, NULL);
- u32 dw_int = 512 * 1000;
- u64 until_dw = dw_int - do_div(tsf, dw_int);
struct wireless_dev *wdev = ieee80211_vif_to_wdev(vif);
if (vif->type != NL80211_IFTYPE_NAN)
@@ -85,13 +151,11 @@ int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
/* set this before starting the timer, as preemption might occur */
data->nan.device_vif = vif;
data->nan.bands = conf->bands;
- data->nan.curr_dw_band = NL80211_BAND_2GHZ;
+ data->nan.channel = ieee80211_get_channel(hw->wiphy, 2437);
- wiphy_debug(hw->wiphy, "nan_started, next_dw=%llu\n",
- until_dw);
-
- hrtimer_start(&data->nan.timer,
- ns_to_ktime(until_dw * NSEC_PER_USEC),
+ /* Just run this "soon" and start in a random schedule position */
+ hrtimer_start(&data->nan.slot_timer,
+ ns_to_ktime(10 * NSEC_PER_USEC),
HRTIMER_MODE_REL_SOFT);
if (conf->cluster_id && !is_zero_ether_addr(conf->cluster_id) &&
@@ -125,7 +189,7 @@ int mac80211_hwsim_nan_stop(struct ieee80211_hw *hw,
data->nan.device_vif != vif)
return -EINVAL;
- hrtimer_cancel(&data->nan.timer);
+ hrtimer_cancel(&data->nan.slot_timer);
data->nan.device_vif = NULL;
spin_lock_bh(&hwsim_radio_lock);
@@ -159,10 +223,8 @@ int mac80211_hwsim_nan_change_config(struct ieee80211_hw *hw,
wiphy_debug(hw->wiphy, "nan_config_changed: changes=0x%x\n", changes);
/* Handle only the changes we care about for simulation purposes */
- if (changes & CFG80211_NAN_CONF_CHANGED_BANDS) {
+ if (changes & CFG80211_NAN_CONF_CHANGED_BANDS)
data->nan.bands = conf->bands;
- data->nan.curr_dw_band = NL80211_BAND_2GHZ;
- }
if (changes & CFG80211_NAN_CONF_CHANGED_CONFIG)
data->nan.notify_dw = conf->enable_dw_notification;
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_nan.h b/drivers/net/wireless/virtual/mac80211_hwsim_nan.h
index eac64ac37589..e86e7f9e9a3c 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_nan.h
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_nan.h
@@ -11,13 +11,15 @@ struct mac80211_hwsim_nan_data {
struct ieee80211_vif *device_vif;
u8 bands;
- enum nl80211_band curr_dw_band;
- struct hrtimer timer;
+ /* Current channel of the NAN device */
+ struct ieee80211_channel *channel;
+
+ struct hrtimer slot_timer;
bool notify_dw;
};
enum hrtimer_restart
-mac80211_hwsim_nan_dw_start(struct hrtimer *timer);
+mac80211_hwsim_nan_slot_timer(struct hrtimer *timer);
int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 13/15] wifi: mac80211_hwsim: register beacon timer by calculating TBTT
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
It is easy to calculate the next target beacon transmission time (TBTT)
based on the current TSF and the beacon interval. Use this method to
calculate the time to the next beacon.
With this, the bcn_delta variable can be removed and drift over time due
to the timer firing late is fully avoided.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
.../net/wireless/virtual/mac80211_hwsim_i.h | 1 -
.../wireless/virtual/mac80211_hwsim_main.c | 39 ++++++++++++-------
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_i.h b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
index b4d0a3869619..d345595ca588 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_i.h
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
@@ -103,7 +103,6 @@ struct mac80211_hwsim_data {
/* difference between this hw's clock and the real clock, in usecs */
s64 tsf_offset;
- s64 bcn_delta;
/* Stats */
u64 tx_pkts;
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index 5bf6541498ec..ba2aa09b37cb 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -1216,6 +1216,12 @@ static inline u64 mac80211_hwsim_get_sim_tsf(void)
return ktime_to_us(ktime_get_boottime());
}
+static ktime_t mac80211_hwsim_tsf_to_boottime(struct mac80211_hwsim_data *data,
+ u64 tsf)
+{
+ return us_to_ktime(tsf - data->tsf_offset);
+}
+
u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
{
@@ -1237,8 +1243,6 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw,
{
struct mac80211_hwsim_data *data = hw->priv;
u64 now = mac80211_hwsim_get_tsf(hw, vif);
- /* MLD not supported here */
- u32 bcn_int = data->link_data[0].beacon_int;
u64 delta = abs(tsf - now);
struct ieee80211_bss_conf *conf;
@@ -1247,13 +1251,10 @@ static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw,
return;
/* adjust after beaconing with new timestamp at old TBTT */
- if (tsf > now) {
+ if (tsf > now)
data->tsf_offset += delta;
- data->bcn_delta = do_div(delta, bcn_int);
- } else {
+ else
data->tsf_offset -= delta;
- data->bcn_delta = -(s64)do_div(delta, bcn_int);
- }
}
static void mac80211_hwsim_monitor_rx(struct ieee80211_hw *hw,
@@ -2410,7 +2411,9 @@ mac80211_hwsim_beacon(struct hrtimer *timer)
container_of(link_data, struct mac80211_hwsim_data,
link_data[link_data->link_id]);
struct ieee80211_hw *hw = data->hw;
- u64 bcn_int = link_data->beacon_int;
+ u32 remainder;
+ u64 tsf_now;
+ u64 tbtt;
if (!data->started)
return HRTIMER_NORESTART;
@@ -2419,13 +2422,19 @@ mac80211_hwsim_beacon(struct hrtimer *timer)
hw, IEEE80211_IFACE_ITER_NORMAL,
mac80211_hwsim_beacon_tx, link_data);
- /* beacon at new TBTT + beacon interval */
- if (data->bcn_delta) {
- bcn_int -= data->bcn_delta;
- data->bcn_delta = 0;
- }
- hrtimer_forward_now(&link_data->beacon_timer,
- ns_to_ktime(bcn_int * NSEC_PER_USEC));
+ /* TSF is the same for all VIFs, parameter is unused */
+ tsf_now = mac80211_hwsim_get_tsf(hw, NULL);
+
+ /* Wrap value to be after the next TBTT */
+ tbtt = tsf_now + link_data->beacon_int;
+
+ /* Round TBTT down to the correct time */
+ div_u64_rem(tbtt, link_data->beacon_int, &remainder);
+ tbtt = tbtt - remainder;
+
+ hrtimer_set_expires(&link_data->beacon_timer,
+ mac80211_hwsim_tsf_to_boottime(data, tbtt));
+
return HRTIMER_RESTART;
}
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 12/15] wifi: mac80211_hwsim: move timestamp writing later in the datapath
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
By delegating writing the timestamp into beacons and probe responses, we
can remove the abs_bcn_ts from the global data and still avoid any time
offset issues. This also seems conceptually closer to "real" hardware
where the timestamp will be written late in the TX path.
Move sending the SKB to the monitor interface to happen later, so that
the frame timestamp has the value filled in by mac80211_hwsim.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
.../net/wireless/virtual/mac80211_hwsim_i.h | 2 -
.../wireless/virtual/mac80211_hwsim_main.c | 110 ++++++++----------
2 files changed, 49 insertions(+), 63 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_i.h b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
index 741eb08f8a85..b4d0a3869619 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_i.h
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
@@ -104,8 +104,6 @@ struct mac80211_hwsim_data {
/* difference between this hw's clock and the real clock, in usecs */
s64 tsf_offset;
s64 bcn_delta;
- /* absolute beacon transmission time. Used to cover up "tx" delay. */
- u64 abs_bcn_ts;
/* Stats */
u64 tx_pkts;
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index 3bda5532ab62..5bf6541498ec 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -1523,6 +1523,43 @@ static inline u16 trans_tx_rate_flags_ieee2hwsim(struct ieee80211_tx_rate *rate)
return result;
}
+static void mac80211_hwsim_write_tsf(struct mac80211_hwsim_data *data,
+ struct sk_buff *skb, u64 sim_time)
+{
+ struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+ struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
+ struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
+ struct ieee80211_rate *txrate;
+ /* TODO: get MCS */
+ int bitrate = 100;
+
+ txrate = ieee80211_get_tx_rate(data->hw, info);
+ if (txrate)
+ bitrate = txrate->bitrate;
+
+ if (skb->len >= offsetofend(typeof(*mgmt), u.probe_resp.timestamp) &&
+ ieee80211_is_probe_resp(hdr->frame_control)) {
+ mgmt->u.probe_resp.timestamp =
+ cpu_to_le64(sim_time + data->tsf_offset +
+ 24 * 8 * 10 / bitrate);
+ } else if (skb->len >= offsetofend(typeof(*mgmt), u.beacon.timestamp) &&
+ ieee80211_is_beacon(mgmt->frame_control)) {
+ mgmt->u.beacon.timestamp = cpu_to_le64(sim_time +
+ data->tsf_offset +
+ 24 * 8 * 10 /
+ bitrate);
+ } else if (skb->len >= offsetofend(struct ieee80211_ext,
+ u.s1g_beacon.timestamp) &&
+ ieee80211_is_s1g_beacon(mgmt->frame_control)) {
+ struct ieee80211_ext *ext = (void *)mgmt;
+
+ ext->u.s1g_beacon.timestamp = cpu_to_le32(sim_time +
+ data->tsf_offset +
+ 10 * 8 * 10 /
+ bitrate);
+ }
+}
+
static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
struct sk_buff *my_skb,
int dst_portid,
@@ -1538,6 +1575,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES];
struct hwsim_tx_rate_flag tx_attempts_flags[IEEE80211_TX_MAX_RATES];
uintptr_t cookie;
+ u64 sim_tsf;
if (data->ps != PS_DISABLED)
hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM);
@@ -1550,6 +1588,9 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
}
}
+ sim_tsf = mac80211_hwsim_get_sim_tsf();
+ mac80211_hwsim_write_tsf(data, my_skb, sim_tsf);
+
skb = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_ATOMIC);
if (skb == NULL)
goto nla_put_failure;
@@ -1781,7 +1822,11 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_rx_status rx_status;
- u64 sim_tsf;
+ u64 sim_tsf = mac80211_hwsim_get_sim_tsf();
+
+ mac80211_hwsim_write_tsf(data, skb, sim_tsf);
+
+ mac80211_hwsim_monitor_rx(hw, skb, chan);
memset(&rx_status, 0, sizeof(rx_status));
rx_status.flag |= RX_FLAG_MACTIME_START;
@@ -1824,20 +1869,9 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
skb_ext_reset(skb);
nf_reset_ct(skb);
- /*
- * Get absolute mactime here so all HWs RX at the "same time", and
- * absolute TX time for beacon mactime so the timestamp matches.
- * Giving beacons a different mactime than non-beacons looks messy, but
- * it helps the Toffset be exact and a ~10us mactime discrepancy
- * probably doesn't really matter.
- */
if (ieee80211_is_beacon(hdr->frame_control) ||
- ieee80211_is_probe_resp(hdr->frame_control)) {
+ ieee80211_is_probe_resp(hdr->frame_control))
rx_status.boottime_ns = ktime_get_boottime_ns();
- sim_tsf = data->abs_bcn_ts;
- } else {
- sim_tsf = mac80211_hwsim_get_sim_tsf();
- }
/* Copy skb to all enabled radios that are on the current frequency */
spin_lock(&hwsim_radio_lock);
@@ -2137,27 +2171,6 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
return;
}
- if (skb->len >= 24 + 8 &&
- ieee80211_is_probe_resp(hdr->frame_control)) {
- /* fake header transmission time */
- struct ieee80211_mgmt *mgmt;
- struct ieee80211_rate *txrate;
- /* TODO: get MCS */
- int bitrate = 100;
- u64 ts;
-
- mgmt = (struct ieee80211_mgmt *)skb->data;
- txrate = ieee80211_get_tx_rate(hw, txi);
- if (txrate)
- bitrate = txrate->bitrate;
- ts = mac80211_hwsim_get_sim_tsf();
- mgmt->u.probe_resp.timestamp =
- cpu_to_le64(ts + data->tsf_offset +
- 24 * 8 * 10 / bitrate);
- }
-
- mac80211_hwsim_monitor_rx(hw, skb, channel);
-
/* wmediumd mode check */
_portid = READ_ONCE(data->wmediumd);
@@ -2291,8 +2304,6 @@ static void mac80211_hwsim_tx_frame(struct ieee80211_hw *hw,
ARRAY_SIZE(txi->control.rates));
}
- mac80211_hwsim_monitor_rx(hw, skb, chan);
-
if (_portid || hwsim_virtio_enabled)
return mac80211_hwsim_tx_frame_nl(hw, skb, _portid, chan);
@@ -2310,10 +2321,6 @@ static void __mac80211_hwsim_beacon_tx(struct ieee80211_bss_conf *link_conf,
{
struct hwsim_vif_priv *vp = (void *)vif->drv_priv;
struct ieee80211_tx_info *info;
- struct ieee80211_rate *txrate;
- struct ieee80211_mgmt *mgmt;
- /* TODO: get MCS */
- int bitrate = 100;
if (vp->skip_beacons[link_conf->link_id]) {
vp->skip_beacons[link_conf->link_id]--;
@@ -2327,27 +2334,6 @@ static void __mac80211_hwsim_beacon_tx(struct ieee80211_bss_conf *link_conf,
info->control.rates,
ARRAY_SIZE(info->control.rates));
- txrate = ieee80211_get_tx_rate(hw, info);
- if (txrate)
- bitrate = txrate->bitrate;
-
- mgmt = (struct ieee80211_mgmt *) skb->data;
- /* fake header transmission time */
- data->abs_bcn_ts = mac80211_hwsim_get_sim_tsf();
- if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
- struct ieee80211_ext *ext = (void *) mgmt;
-
- ext->u.s1g_beacon.timestamp = cpu_to_le32(data->abs_bcn_ts +
- data->tsf_offset +
- 10 * 8 * 10 /
- bitrate);
- } else {
- mgmt->u.beacon.timestamp = cpu_to_le64(data->abs_bcn_ts +
- data->tsf_offset +
- 24 * 8 * 10 /
- bitrate);
- }
-
mac80211_hwsim_tx_frame(hw, skb,
rcu_dereference(link_conf->chanctx_conf)->def.chan);
}
@@ -6033,6 +6019,8 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
if (!found)
goto out;
+ mac80211_hwsim_monitor_rx(data2->hw, skb, data2->channel);
+
/* Tx info received because the frame was broadcasted on user space,
so we get all the necessary info: tx attempts and skb control buff */
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 11/15] wifi: mac80211_hwsim: rename and switch simulation time to boottime
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
The mac80211_hwsim base time for the simulation of the TSF was based on
the real time of the system. This clock is subject to unexpected
changes. Switch it to use boottime which is always monotonic and also
continues to run through times where the system is suspended.
Also change the function name from tsf_raw to sim_tsf to better
differentiate between the TSF of the mac and the TSF base of the
simulation.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
.../wireless/virtual/mac80211_hwsim_main.c | 33 ++++++++++---------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_main.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
index 4ad2c6f38663..3bda5532ab62 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_main.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -1211,22 +1211,25 @@ static netdev_tx_t hwsim_mon_xmit(struct sk_buff *skb,
return NETDEV_TX_OK;
}
-static inline u64 mac80211_hwsim_get_tsf_raw(void)
+static inline u64 mac80211_hwsim_get_sim_tsf(void)
{
- return ktime_to_us(ktime_get_real());
-}
-
-static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data)
-{
- u64 now = mac80211_hwsim_get_tsf_raw();
- return cpu_to_le64(now + data->tsf_offset);
+ return ktime_to_us(ktime_get_boottime());
}
u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
struct ieee80211_vif *vif)
{
struct mac80211_hwsim_data *data = hw->priv;
- return le64_to_cpu(__mac80211_hwsim_get_tsf(data));
+ u64 sim_time = mac80211_hwsim_get_sim_tsf();
+
+ return sim_time + data->tsf_offset;
+}
+
+static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data)
+{
+ u64 sim_time = mac80211_hwsim_get_sim_tsf();
+
+ return cpu_to_le64(sim_time + data->tsf_offset);
}
static void mac80211_hwsim_set_tsf(struct ieee80211_hw *hw,
@@ -1778,7 +1781,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
struct ieee80211_rx_status rx_status;
- u64 now;
+ u64 sim_tsf;
memset(&rx_status, 0, sizeof(rx_status));
rx_status.flag |= RX_FLAG_MACTIME_START;
@@ -1831,9 +1834,9 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
if (ieee80211_is_beacon(hdr->frame_control) ||
ieee80211_is_probe_resp(hdr->frame_control)) {
rx_status.boottime_ns = ktime_get_boottime_ns();
- now = data->abs_bcn_ts;
+ sim_tsf = data->abs_bcn_ts;
} else {
- now = mac80211_hwsim_get_tsf_raw();
+ sim_tsf = mac80211_hwsim_get_sim_tsf();
}
/* Copy skb to all enabled radios that are on the current frequency */
@@ -1894,7 +1897,7 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,
if (mac80211_hwsim_addr_match(data2, hdr->addr1))
ack = true;
- rx_status.mactime = now + data2->tsf_offset;
+ rx_status.mactime = sim_tsf + data2->tsf_offset;
mac80211_hwsim_rx(data2, &rx_status, nskb);
}
@@ -2147,7 +2150,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
txrate = ieee80211_get_tx_rate(hw, txi);
if (txrate)
bitrate = txrate->bitrate;
- ts = mac80211_hwsim_get_tsf_raw();
+ ts = mac80211_hwsim_get_sim_tsf();
mgmt->u.probe_resp.timestamp =
cpu_to_le64(ts + data->tsf_offset +
24 * 8 * 10 / bitrate);
@@ -2330,7 +2333,7 @@ static void __mac80211_hwsim_beacon_tx(struct ieee80211_bss_conf *link_conf,
mgmt = (struct ieee80211_mgmt *) skb->data;
/* fake header transmission time */
- data->abs_bcn_ts = mac80211_hwsim_get_tsf_raw();
+ data->abs_bcn_ts = mac80211_hwsim_get_sim_tsf();
if (ieee80211_is_s1g_beacon(mgmt->frame_control)) {
struct ieee80211_ext *ext = (void *) mgmt;
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 10/15] wifi: mac80211_hwsim: split NAN handling into separate file
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
Having everything in one file for mac80211_hwsim is starting to get a
lot and it will be even worse if we implement more parts of NAN. Split
the NAN implementation into separate files to improve the code
structuring.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
MAINTAINERS | 2 +-
drivers/net/wireless/virtual/Makefile | 2 +
.../net/wireless/virtual/mac80211_hwsim_i.h | 137 ++++++++
...mac80211_hwsim.c => mac80211_hwsim_main.c} | 307 ++----------------
.../net/wireless/virtual/mac80211_hwsim_nan.c | 171 ++++++++++
.../net/wireless/virtual/mac80211_hwsim_nan.h | 34 ++
6 files changed, 365 insertions(+), 288 deletions(-)
create mode 100644 drivers/net/wireless/virtual/mac80211_hwsim_i.h
rename drivers/net/wireless/virtual/{mac80211_hwsim.c => mac80211_hwsim_main.c} (96%)
create mode 100644 drivers/net/wireless/virtual/mac80211_hwsim_nan.c
create mode 100644 drivers/net/wireless/virtual/mac80211_hwsim_nan.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 2fb1c75afd16..ac5c0314c870 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15344,7 +15344,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless.git
T: git git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git
F: Documentation/networking/mac80211-injection.rst
F: Documentation/networking/mac80211_hwsim/mac80211_hwsim.rst
-F: drivers/net/wireless/virtual/mac80211_hwsim.[ch]
+F: drivers/net/wireless/virtual/mac80211_hwsim*.[ch]
F: include/net/mac80211.h
F: net/mac80211/
diff --git a/drivers/net/wireless/virtual/Makefile b/drivers/net/wireless/virtual/Makefile
index 5773cc6d643e..6ad860dd7643 100644
--- a/drivers/net/wireless/virtual/Makefile
+++ b/drivers/net/wireless/virtual/Makefile
@@ -1,3 +1,5 @@
obj-$(CONFIG_MAC80211_HWSIM) += mac80211_hwsim.o
+mac80211_hwsim-objs += mac80211_hwsim_main.o
+mac80211_hwsim-objs += mac80211_hwsim_nan.o
obj-$(CONFIG_VIRT_WIFI) += virt_wifi.o
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_i.h b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
new file mode 100644
index 000000000000..741eb08f8a85
--- /dev/null
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_i.h
@@ -0,0 +1,137 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * mac80211_hwsim - software simulator of 802.11 radio(s) for mac80211
+ * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
+ * Copyright (c) 2011, Javier Lopez <jlopex@gmail.com>
+ * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
+ * Copyright (C) 2018 - 2025 Intel Corporation
+ */
+
+#ifndef __MAC80211_HWSIM_I_H
+#define __MAC80211_HWSIM_I_H
+
+#include <net/mac80211.h>
+#include "mac80211_hwsim.h"
+#include "mac80211_hwsim_nan.h"
+
+struct mac80211_hwsim_link_data {
+ u32 link_id;
+ u64 beacon_int /* beacon interval in us */;
+ struct hrtimer beacon_timer;
+};
+
+#define HWSIM_NUM_CHANNELS_2GHZ 14
+#define HWSIM_NUM_CHANNELS_5GHZ 40
+#define HWSIM_NUM_CHANNELS_6GHZ 59
+#define HWSIM_NUM_S1G_CHANNELS_US 51
+#define HWSIM_NUM_RATES 12
+#define HWSIM_NUM_CIPHERS 11
+
+struct mac80211_hwsim_data {
+ struct list_head list;
+ struct rhash_head rht;
+ struct ieee80211_hw *hw;
+ struct device *dev;
+ struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
+ struct ieee80211_channel channels_2ghz[HWSIM_NUM_CHANNELS_2GHZ];
+ struct ieee80211_channel channels_5ghz[HWSIM_NUM_CHANNELS_5GHZ];
+ struct ieee80211_channel channels_6ghz[HWSIM_NUM_CHANNELS_6GHZ];
+ struct ieee80211_channel channels_s1g[HWSIM_NUM_S1G_CHANNELS_US];
+ struct ieee80211_rate rates[HWSIM_NUM_RATES];
+ struct ieee80211_iface_combination if_combination;
+ struct ieee80211_iface_limit if_limits[4];
+ int n_if_limits;
+ /* Storage space for channels, etc. */
+ struct mac80211_hwsim_phy_data *phy_data;
+
+ struct ieee80211_iface_combination if_combination_radio;
+ struct wiphy_radio_freq_range radio_range[NUM_NL80211_BANDS];
+ struct wiphy_radio radio[NUM_NL80211_BANDS];
+
+ u32 ciphers[HWSIM_NUM_CIPHERS];
+
+ struct mac_address addresses[3];
+ int channels, idx;
+ bool use_chanctx;
+ bool destroy_on_close;
+ u32 portid;
+ char alpha2[2];
+ const struct ieee80211_regdomain *regd;
+
+ struct ieee80211_channel *tmp_chan;
+ struct ieee80211_channel *roc_chan;
+ u32 roc_duration;
+ struct delayed_work roc_start;
+ struct delayed_work roc_done;
+ struct delayed_work hw_scan;
+ struct cfg80211_scan_request *hw_scan_request;
+ struct ieee80211_vif *hw_scan_vif;
+ int scan_chan_idx;
+ u8 scan_addr[ETH_ALEN];
+ struct {
+ struct ieee80211_channel *channel;
+ unsigned long next_start, start, end;
+ } survey_data[HWSIM_NUM_CHANNELS_2GHZ +
+ HWSIM_NUM_CHANNELS_5GHZ +
+ HWSIM_NUM_CHANNELS_6GHZ];
+
+ struct ieee80211_channel *channel;
+ enum nl80211_chan_width bw;
+ unsigned int rx_filter;
+ bool started, idle, scanning;
+ struct mutex mutex;
+ enum ps_mode {
+ PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL
+ } ps;
+ bool ps_poll_pending;
+ struct dentry *debugfs;
+ struct cfg80211_chan_def radar_background_chandef;
+
+ atomic_t pending_cookie;
+ struct sk_buff_head pending; /* packets pending */
+ /*
+ * Only radios in the same group can communicate together (the
+ * channel has to match too). Each bit represents a group. A
+ * radio can be in more than one group.
+ */
+ u64 group;
+
+ /* group shared by radios created in the same netns */
+ int netgroup;
+ /* wmediumd portid responsible for netgroup of this radio */
+ u32 wmediumd;
+
+ /* difference between this hw's clock and the real clock, in usecs */
+ s64 tsf_offset;
+ s64 bcn_delta;
+ /* absolute beacon transmission time. Used to cover up "tx" delay. */
+ u64 abs_bcn_ts;
+
+ /* Stats */
+ u64 tx_pkts;
+ u64 rx_pkts;
+ u64 tx_bytes;
+ u64 rx_bytes;
+ u64 tx_dropped;
+ u64 tx_failed;
+
+ /* RSSI in rx status of the receiver */
+ int rx_rssi;
+
+ /* only used when pmsr capability is supplied */
+ struct cfg80211_pmsr_capabilities pmsr_capa;
+ struct cfg80211_pmsr_request *pmsr_request;
+ struct wireless_dev *pmsr_request_wdev;
+
+ struct mac80211_hwsim_link_data link_data[IEEE80211_MLD_MAX_NUM_LINKS];
+
+ struct mac80211_hwsim_nan_data nan;
+};
+
+extern spinlock_t hwsim_radio_lock;
+extern struct list_head hwsim_radios;
+
+u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif);
+
+#endif /* __MAC80211_HWSIM_I_H */
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
similarity index 96%
rename from drivers/net/wireless/virtual/mac80211_hwsim.c
rename to drivers/net/wireless/virtual/mac80211_hwsim_main.c
index d5b9170f690c..4ad2c6f38663 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_main.c
@@ -39,6 +39,7 @@
#include <linux/uaccess.h>
#include <linux/string.h>
#include "mac80211_hwsim.h"
+#include "mac80211_hwsim_i.h"
#define WARN_QUEUE 100
#define MAX_QUEUE 200
@@ -379,6 +380,8 @@ static const struct ieee80211_channel hwsim_channels_2ghz[] = {
CHAN2G(2472), /* Channel 13 */
CHAN2G(2484), /* Channel 14 */
};
+static_assert(HWSIM_NUM_CHANNELS_2GHZ == ARRAY_SIZE(hwsim_channels_2ghz),
+ "Inconsistent 2 GHz channel count");
static const struct ieee80211_channel hwsim_channels_5ghz[] = {
CHAN5G(5180), /* Channel 36 */
@@ -428,6 +431,8 @@ static const struct ieee80211_channel hwsim_channels_5ghz[] = {
CHAN5G(5920), /* Channel 184 */
CHAN5G(5925), /* Channel 185 */
};
+static_assert(HWSIM_NUM_CHANNELS_5GHZ == ARRAY_SIZE(hwsim_channels_5ghz),
+ "Inconsistent 5 GHz channel count");
static const struct ieee80211_channel hwsim_channels_6ghz[] = {
CHAN6G(5955), /* Channel 1 */
@@ -490,9 +495,10 @@ static const struct ieee80211_channel hwsim_channels_6ghz[] = {
CHAN6G(7095), /* Channel 229 */
CHAN6G(7115), /* Channel 233 */
};
+static_assert(HWSIM_NUM_CHANNELS_6GHZ == ARRAY_SIZE(hwsim_channels_6ghz),
+ "Inconsistent 6 GHz channel count");
-#define NUM_S1G_CHANS_US 51
-static struct ieee80211_channel hwsim_channels_s1g[NUM_S1G_CHANS_US];
+static struct ieee80211_channel hwsim_channels_s1g[HWSIM_NUM_S1G_CHANNELS_US];
static const struct ieee80211_sta_s1g_cap hwsim_s1g_cap = {
.s1g = true,
@@ -525,7 +531,7 @@ static void hwsim_init_s1g_channels(struct ieee80211_channel *chans)
{
int ch, freq;
- for (ch = 0; ch < NUM_S1G_CHANS_US; ch++) {
+ for (ch = 0; ch < ARRAY_SIZE(hwsim_channels_s1g); ch++) {
freq = 902000 + (ch + 1) * 500;
chans[ch].band = NL80211_BAND_S1GHZ;
chans[ch].center_freq = KHZ_TO_MHZ(freq);
@@ -548,6 +554,8 @@ static const struct ieee80211_rate hwsim_rates[] = {
{ .bitrate = 480 },
{ .bitrate = 540 }
};
+static_assert(HWSIM_NUM_RATES == ARRAY_SIZE(hwsim_rates),
+ "Inconsistent rates count");
#define DEFAULT_RX_RSSI -50
@@ -564,6 +572,8 @@ static const u32 hwsim_ciphers[] = {
WLAN_CIPHER_SUITE_BIP_GMAC_128,
WLAN_CIPHER_SUITE_BIP_GMAC_256,
};
+static_assert(HWSIM_NUM_CIPHERS == ARRAY_SIZE(hwsim_ciphers),
+ "Inconsistent cipher count");
#define OUI_QCA 0x001374
#define QCA_NL80211_SUBCMD_TEST 1
@@ -644,12 +654,11 @@ static const struct nl80211_vendor_cmd_info mac80211_hwsim_vendor_events[] = {
{ .vendor_id = OUI_QCA, .subcmd = 1 },
};
-static DEFINE_SPINLOCK(hwsim_radio_lock);
-static LIST_HEAD(hwsim_radios);
+DEFINE_SPINLOCK(hwsim_radio_lock);
+LIST_HEAD(hwsim_radios);
static struct rhashtable hwsim_radios_rht;
static int hwsim_radio_idx;
static int hwsim_radios_generation = 1;
-static u8 hwsim_nan_cluster_id[ETH_ALEN];
static struct platform_driver mac80211_hwsim_driver = {
.driver = {
@@ -657,120 +666,6 @@ static struct platform_driver mac80211_hwsim_driver = {
},
};
-struct mac80211_hwsim_link_data {
- u32 link_id;
- u64 beacon_int /* beacon interval in us */;
- struct hrtimer beacon_timer;
-};
-
-struct mac80211_hwsim_nan_data {
- struct ieee80211_vif *device_vif;
- u8 bands;
-
- enum nl80211_band curr_dw_band;
- struct hrtimer timer;
- bool notify_dw;
-};
-
-struct mac80211_hwsim_data {
- struct list_head list;
- struct rhash_head rht;
- struct ieee80211_hw *hw;
- struct device *dev;
- struct ieee80211_supported_band bands[NUM_NL80211_BANDS];
- struct ieee80211_channel channels_2ghz[ARRAY_SIZE(hwsim_channels_2ghz)];
- struct ieee80211_channel channels_5ghz[ARRAY_SIZE(hwsim_channels_5ghz)];
- struct ieee80211_channel channels_6ghz[ARRAY_SIZE(hwsim_channels_6ghz)];
- struct ieee80211_channel channels_s1g[ARRAY_SIZE(hwsim_channels_s1g)];
- struct ieee80211_rate rates[ARRAY_SIZE(hwsim_rates)];
- struct ieee80211_iface_combination if_combination;
- struct ieee80211_iface_limit if_limits[4];
- int n_if_limits;
-
- struct ieee80211_iface_combination if_combination_radio;
- struct wiphy_radio_freq_range radio_range[NUM_NL80211_BANDS];
- struct wiphy_radio radio[NUM_NL80211_BANDS];
-
- u32 ciphers[ARRAY_SIZE(hwsim_ciphers)];
-
- struct mac_address addresses[3];
- int channels, idx;
- bool use_chanctx;
- bool destroy_on_close;
- u32 portid;
- char alpha2[2];
- const struct ieee80211_regdomain *regd;
-
- struct ieee80211_channel *tmp_chan;
- struct ieee80211_channel *roc_chan;
- u32 roc_duration;
- struct delayed_work roc_start;
- struct delayed_work roc_done;
- struct delayed_work hw_scan;
- struct cfg80211_scan_request *hw_scan_request;
- struct ieee80211_vif *hw_scan_vif;
- int scan_chan_idx;
- u8 scan_addr[ETH_ALEN];
- struct {
- struct ieee80211_channel *channel;
- unsigned long next_start, start, end;
- } survey_data[ARRAY_SIZE(hwsim_channels_2ghz) +
- ARRAY_SIZE(hwsim_channels_5ghz) +
- ARRAY_SIZE(hwsim_channels_6ghz)];
-
- struct ieee80211_channel *channel;
- enum nl80211_chan_width bw;
- unsigned int rx_filter;
- bool started, idle, scanning;
- struct mutex mutex;
- enum ps_mode {
- PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL
- } ps;
- bool ps_poll_pending;
- struct dentry *debugfs;
- struct cfg80211_chan_def radar_background_chandef;
-
- atomic_t pending_cookie;
- struct sk_buff_head pending; /* packets pending */
- /*
- * Only radios in the same group can communicate together (the
- * channel has to match too). Each bit represents a group. A
- * radio can be in more than one group.
- */
- u64 group;
-
- /* group shared by radios created in the same netns */
- int netgroup;
- /* wmediumd portid responsible for netgroup of this radio */
- u32 wmediumd;
-
- /* difference between this hw's clock and the real clock, in usecs */
- s64 tsf_offset;
- s64 bcn_delta;
- /* absolute beacon transmission time. Used to cover up "tx" delay. */
- u64 abs_bcn_ts;
-
- /* Stats */
- u64 tx_pkts;
- u64 rx_pkts;
- u64 tx_bytes;
- u64 rx_bytes;
- u64 tx_dropped;
- u64 tx_failed;
-
- /* RSSI in rx status of the receiver */
- int rx_rssi;
-
- /* only used when pmsr capability is supplied */
- struct cfg80211_pmsr_capabilities pmsr_capa;
- struct cfg80211_pmsr_request *pmsr_request;
- struct wireless_dev *pmsr_request_wdev;
-
- struct mac80211_hwsim_link_data link_data[IEEE80211_MLD_MAX_NUM_LINKS];
-
- struct mac80211_hwsim_nan_data nan;
-};
-
static const struct rhashtable_params hwsim_rht_params = {
.nelem_hint = 2,
.automatic_shrinking = true,
@@ -1327,8 +1222,8 @@ static __le64 __mac80211_hwsim_get_tsf(struct mac80211_hwsim_data *data)
return cpu_to_le64(now + data->tsf_offset);
}
-static u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif)
+u64 mac80211_hwsim_get_tsf(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
{
struct mac80211_hwsim_data *data = hw->priv;
return le64_to_cpu(__mac80211_hwsim_get_tsf(data));
@@ -4130,168 +4025,6 @@ static int hwsim_pmsr_report_nl(struct sk_buff *msg, struct genl_info *info)
return err;
}
-static enum hrtimer_restart
-mac80211_hwsim_nan_dw_start(struct hrtimer *timer)
-{
- struct mac80211_hwsim_data *data =
- container_of(timer, struct mac80211_hwsim_data,
- nan.timer);
- struct ieee80211_hw *hw = data->hw;
- u64 orig_tsf = mac80211_hwsim_get_tsf(hw, NULL), tsf = orig_tsf;
- u32 dw_int = 512 * 1024;
- u64 until_dw;
-
- if (!data->nan.device_vif)
- return HRTIMER_NORESTART;
-
- if (data->nan.bands & BIT(NL80211_BAND_5GHZ)) {
- if (data->nan.curr_dw_band == NL80211_BAND_2GHZ) {
- dw_int = 128 * 1024;
- data->nan.curr_dw_band = NL80211_BAND_5GHZ;
- } else if (data->nan.curr_dw_band == NL80211_BAND_5GHZ) {
- data->nan.curr_dw_band = NL80211_BAND_2GHZ;
- }
- }
-
- until_dw = dw_int - do_div(tsf, dw_int);
-
- /* The timer might fire just before the actual DW, in which case
- * update the timeout to the actual next DW
- */
- if (until_dw < dw_int / 2)
- until_dw += dw_int;
-
- /* The above do_div() call directly modifies the 'tsf' variable, thus,
- * use a copy so that the print below would show the original TSF.
- */
- wiphy_debug(hw->wiphy,
- "%s: tsf=%llx, curr_dw_band=%u, next_dw=%llu\n",
- __func__, orig_tsf, data->nan.curr_dw_band,
- until_dw);
-
- hrtimer_forward_now(&data->nan.timer,
- ns_to_ktime(until_dw * NSEC_PER_USEC));
-
- if (data->nan.notify_dw) {
- struct ieee80211_channel *ch;
- struct wireless_dev *wdev =
- ieee80211_vif_to_wdev(data->nan.device_vif);
-
- if (data->nan.curr_dw_band == NL80211_BAND_5GHZ)
- ch = ieee80211_get_channel(hw->wiphy, 5745);
- else
- ch = ieee80211_get_channel(hw->wiphy, 2437);
-
- cfg80211_next_nan_dw_notif(wdev, ch, GFP_ATOMIC);
- }
-
- return HRTIMER_RESTART;
-}
-
-static int mac80211_hwsim_start_nan(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct cfg80211_nan_conf *conf)
-{
- struct mac80211_hwsim_data *data = hw->priv;
- u64 tsf = mac80211_hwsim_get_tsf(hw, NULL);
- u32 dw_int = 512 * 1000;
- u64 until_dw = dw_int - do_div(tsf, dw_int);
- struct wireless_dev *wdev = ieee80211_vif_to_wdev(vif);
-
- if (vif->type != NL80211_IFTYPE_NAN)
- return -EINVAL;
-
- if (data->nan.device_vif)
- return -EALREADY;
-
- /* set this before starting the timer, as preemption might occur */
- data->nan.device_vif = vif;
- data->nan.bands = conf->bands;
- data->nan.curr_dw_band = NL80211_BAND_2GHZ;
-
- wiphy_debug(hw->wiphy, "nan_started, next_dw=%llu\n",
- until_dw);
-
- hrtimer_start(&data->nan.timer,
- ns_to_ktime(until_dw * NSEC_PER_USEC),
- HRTIMER_MODE_REL_SOFT);
-
- if (!is_zero_ether_addr(conf->cluster_id) &&
- is_zero_ether_addr(hwsim_nan_cluster_id)) {
- memcpy(hwsim_nan_cluster_id, conf->cluster_id, ETH_ALEN);
- } else if (is_zero_ether_addr(hwsim_nan_cluster_id)) {
- hwsim_nan_cluster_id[0] = 0x50;
- hwsim_nan_cluster_id[1] = 0x6f;
- hwsim_nan_cluster_id[2] = 0x9a;
- hwsim_nan_cluster_id[3] = 0x01;
- hwsim_nan_cluster_id[4] = get_random_u8();
- hwsim_nan_cluster_id[5] = get_random_u8();
- }
-
- data->nan.notify_dw = conf->enable_dw_notification;
-
- cfg80211_nan_cluster_joined(wdev, hwsim_nan_cluster_id, true,
- GFP_KERNEL);
-
- return 0;
-}
-
-static int mac80211_hwsim_stop_nan(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif)
-{
- struct mac80211_hwsim_data *data = hw->priv;
- struct mac80211_hwsim_data *data2;
- bool nan_cluster_running = false;
-
- if (vif->type != NL80211_IFTYPE_NAN || !data->nan.device_vif ||
- data->nan.device_vif != vif)
- return -EINVAL;
-
- hrtimer_cancel(&data->nan.timer);
- data->nan.device_vif = NULL;
-
- spin_lock_bh(&hwsim_radio_lock);
- list_for_each_entry(data2, &hwsim_radios, list) {
- if (data2->nan.device_vif) {
- nan_cluster_running = true;
- break;
- }
- }
- spin_unlock_bh(&hwsim_radio_lock);
-
- if (!nan_cluster_running)
- memset(hwsim_nan_cluster_id, 0, ETH_ALEN);
-
- return 0;
-}
-
-static int mac80211_hwsim_change_nan_config(struct ieee80211_hw *hw,
- struct ieee80211_vif *vif,
- struct cfg80211_nan_conf *conf,
- u32 changes)
-{
- struct mac80211_hwsim_data *data = hw->priv;
-
- if (vif->type != NL80211_IFTYPE_NAN)
- return -EINVAL;
-
- if (!data->nan.device_vif)
- return -EINVAL;
-
- wiphy_debug(hw->wiphy, "nan_config_changed: changes=0x%x\n", changes);
-
- /* Handle only the changes we care about for simulation purposes */
- if (changes & CFG80211_NAN_CONF_CHANGED_BANDS) {
- data->nan.bands = conf->bands;
- data->nan.curr_dw_band = NL80211_BAND_2GHZ;
- }
-
- if (changes & CFG80211_NAN_CONF_CHANGED_CONFIG)
- data->nan.notify_dw = conf->enable_dw_notification;
-
- return 0;
-}
-
static int mac80211_hwsim_set_radar_background(struct ieee80211_hw *hw,
struct cfg80211_chan_def *chan)
{
@@ -4342,11 +4075,11 @@ static int mac80211_hwsim_set_radar_background(struct ieee80211_hw *hw,
.get_et_strings = mac80211_hwsim_get_et_strings, \
.start_pmsr = mac80211_hwsim_start_pmsr, \
.abort_pmsr = mac80211_hwsim_abort_pmsr, \
- .start_nan = mac80211_hwsim_start_nan, \
- .stop_nan = mac80211_hwsim_stop_nan, \
- .nan_change_conf = mac80211_hwsim_change_nan_config, \
.set_radar_background = mac80211_hwsim_set_radar_background, \
.set_key = mac80211_hwsim_set_key, \
+ .start_nan = mac80211_hwsim_nan_start, \
+ .stop_nan = mac80211_hwsim_nan_stop, \
+ .nan_change_conf = mac80211_hwsim_nan_change_config, \
HWSIM_DEBUGFS_OPS
#define HWSIM_NON_MLO_OPS \
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_nan.c b/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
new file mode 100644
index 000000000000..5d7c736d7972
--- /dev/null
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * mac80211_hwsim_nan - NAN software simulation for mac80211_hwsim
+ * Copyright (C) 2025 Intel Corporation
+ */
+
+#include "mac80211_hwsim_i.h"
+
+static u8 hwsim_nan_cluster_id[ETH_ALEN];
+
+enum hrtimer_restart
+mac80211_hwsim_nan_dw_start(struct hrtimer *timer)
+{
+ struct mac80211_hwsim_data *data =
+ container_of(timer, struct mac80211_hwsim_data,
+ nan.timer);
+ struct ieee80211_hw *hw = data->hw;
+ u64 orig_tsf = mac80211_hwsim_get_tsf(hw, NULL), tsf = orig_tsf;
+ u32 dw_int = 512 * 1024;
+ u64 until_dw;
+
+ if (!data->nan.device_vif)
+ return HRTIMER_NORESTART;
+
+ if (data->nan.bands & BIT(NL80211_BAND_5GHZ)) {
+ if (data->nan.curr_dw_band == NL80211_BAND_2GHZ) {
+ dw_int = 128 * 1024;
+ data->nan.curr_dw_band = NL80211_BAND_5GHZ;
+ } else if (data->nan.curr_dw_band == NL80211_BAND_5GHZ) {
+ data->nan.curr_dw_band = NL80211_BAND_2GHZ;
+ }
+ }
+
+ until_dw = dw_int - do_div(tsf, dw_int);
+
+ /* The timer might fire just before the actual DW, in which case
+ * update the timeout to the actual next DW
+ */
+ if (until_dw < dw_int / 2)
+ until_dw += dw_int;
+
+ /* The above do_div() call directly modifies the 'tsf' variable, thus,
+ * use a copy so that the print below would show the original TSF.
+ */
+ wiphy_debug(hw->wiphy,
+ "%s: tsf=%llx, curr_dw_band=%u, next_dw=%llu\n",
+ __func__, orig_tsf, data->nan.curr_dw_band,
+ until_dw);
+
+ hrtimer_forward_now(&data->nan.timer,
+ ns_to_ktime(until_dw * NSEC_PER_USEC));
+
+ if (data->nan.notify_dw) {
+ struct ieee80211_channel *ch;
+ struct wireless_dev *wdev =
+ ieee80211_vif_to_wdev(data->nan.device_vif);
+
+ if (data->nan.curr_dw_band == NL80211_BAND_5GHZ)
+ ch = ieee80211_get_channel(hw->wiphy, 5745);
+ else
+ ch = ieee80211_get_channel(hw->wiphy, 2437);
+
+ cfg80211_next_nan_dw_notif(wdev, ch, GFP_ATOMIC);
+ }
+
+ return HRTIMER_RESTART;
+}
+
+int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct cfg80211_nan_conf *conf)
+{
+ struct mac80211_hwsim_data *data = hw->priv;
+ u64 tsf = mac80211_hwsim_get_tsf(hw, NULL);
+ u32 dw_int = 512 * 1000;
+ u64 until_dw = dw_int - do_div(tsf, dw_int);
+ struct wireless_dev *wdev = ieee80211_vif_to_wdev(vif);
+
+ if (vif->type != NL80211_IFTYPE_NAN)
+ return -EINVAL;
+
+ if (data->nan.device_vif)
+ return -EALREADY;
+
+ /* set this before starting the timer, as preemption might occur */
+ data->nan.device_vif = vif;
+ data->nan.bands = conf->bands;
+ data->nan.curr_dw_band = NL80211_BAND_2GHZ;
+
+ wiphy_debug(hw->wiphy, "nan_started, next_dw=%llu\n",
+ until_dw);
+
+ hrtimer_start(&data->nan.timer,
+ ns_to_ktime(until_dw * NSEC_PER_USEC),
+ HRTIMER_MODE_REL_SOFT);
+
+ if (conf->cluster_id && !is_zero_ether_addr(conf->cluster_id) &&
+ is_zero_ether_addr(hwsim_nan_cluster_id)) {
+ memcpy(hwsim_nan_cluster_id, conf->cluster_id, ETH_ALEN);
+ } else if (is_zero_ether_addr(hwsim_nan_cluster_id)) {
+ hwsim_nan_cluster_id[0] = 0x50;
+ hwsim_nan_cluster_id[1] = 0x6f;
+ hwsim_nan_cluster_id[2] = 0x9a;
+ hwsim_nan_cluster_id[3] = 0x01;
+ hwsim_nan_cluster_id[4] = get_random_u8();
+ hwsim_nan_cluster_id[5] = get_random_u8();
+ }
+
+ data->nan.notify_dw = conf->enable_dw_notification;
+
+ cfg80211_nan_cluster_joined(wdev, hwsim_nan_cluster_id, true,
+ GFP_KERNEL);
+
+ return 0;
+}
+
+int mac80211_hwsim_nan_stop(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif)
+{
+ struct mac80211_hwsim_data *data = hw->priv;
+ struct mac80211_hwsim_data *data2;
+ bool nan_cluster_running = false;
+
+ if (vif->type != NL80211_IFTYPE_NAN || !data->nan.device_vif ||
+ data->nan.device_vif != vif)
+ return -EINVAL;
+
+ hrtimer_cancel(&data->nan.timer);
+ data->nan.device_vif = NULL;
+
+ spin_lock_bh(&hwsim_radio_lock);
+ list_for_each_entry(data2, &hwsim_radios, list) {
+ if (data2->nan.device_vif) {
+ nan_cluster_running = true;
+ break;
+ }
+ }
+ spin_unlock_bh(&hwsim_radio_lock);
+
+ if (!nan_cluster_running)
+ memset(hwsim_nan_cluster_id, 0, ETH_ALEN);
+
+ return 0;
+}
+
+int mac80211_hwsim_nan_change_config(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct cfg80211_nan_conf *conf,
+ u32 changes)
+{
+ struct mac80211_hwsim_data *data = hw->priv;
+
+ if (vif->type != NL80211_IFTYPE_NAN)
+ return -EINVAL;
+
+ if (!data->nan.device_vif)
+ return -EINVAL;
+
+ wiphy_debug(hw->wiphy, "nan_config_changed: changes=0x%x\n", changes);
+
+ /* Handle only the changes we care about for simulation purposes */
+ if (changes & CFG80211_NAN_CONF_CHANGED_BANDS) {
+ data->nan.bands = conf->bands;
+ data->nan.curr_dw_band = NL80211_BAND_2GHZ;
+ }
+
+ if (changes & CFG80211_NAN_CONF_CHANGED_CONFIG)
+ data->nan.notify_dw = conf->enable_dw_notification;
+
+ return 0;
+}
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_nan.h b/drivers/net/wireless/virtual/mac80211_hwsim_nan.h
new file mode 100644
index 000000000000..eac64ac37589
--- /dev/null
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_nan.h
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * mac80211_hwsim_nan - NAN software simulation for mac80211_hwsim
+ * Copyright (C) 2025 Intel Corporation
+ */
+
+#ifndef __MAC80211_HWSIM_NAN_H
+#define __MAC80211_HWSIM_NAN_H
+
+struct mac80211_hwsim_nan_data {
+ struct ieee80211_vif *device_vif;
+ u8 bands;
+
+ enum nl80211_band curr_dw_band;
+ struct hrtimer timer;
+ bool notify_dw;
+};
+
+enum hrtimer_restart
+mac80211_hwsim_nan_dw_start(struct hrtimer *timer);
+
+int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct cfg80211_nan_conf *conf);
+
+int mac80211_hwsim_nan_stop(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif);
+
+int mac80211_hwsim_nan_change_config(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
+ struct cfg80211_nan_conf *conf,
+ u32 changes);
+
+#endif /* __MAC80211_HWSIM_NAN_H */
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 09/15] wifi: mac80211_hwsim: move NAN related variables into a struct
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
Move it all into a common struct to better segment the code.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
drivers/net/wireless/virtual/mac80211_hwsim.c | 76 ++++++++++---------
1 file changed, 40 insertions(+), 36 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index 7ab0765cb482..d5b9170f690c 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -663,6 +663,15 @@ struct mac80211_hwsim_link_data {
struct hrtimer beacon_timer;
};
+struct mac80211_hwsim_nan_data {
+ struct ieee80211_vif *device_vif;
+ u8 bands;
+
+ enum nl80211_band curr_dw_band;
+ struct hrtimer timer;
+ bool notify_dw;
+};
+
struct mac80211_hwsim_data {
struct list_head list;
struct rhash_head rht;
@@ -759,12 +768,7 @@ struct mac80211_hwsim_data {
struct mac80211_hwsim_link_data link_data[IEEE80211_MLD_MAX_NUM_LINKS];
- struct ieee80211_vif *nan_device_vif;
- u8 nan_bands;
-
- enum nl80211_band nan_curr_dw_band;
- struct hrtimer nan_timer;
- bool notify_dw;
+ struct mac80211_hwsim_nan_data nan;
};
static const struct rhashtable_params hwsim_rht_params = {
@@ -2108,9 +2112,9 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw,
* on channel 6 or channel 149, unless a ROC is in progress (for
* USD use cases).
*/
- if (data->nan_curr_dw_band == NL80211_BAND_2GHZ)
+ if (data->nan.curr_dw_band == NL80211_BAND_2GHZ)
channel = ieee80211_get_channel(hw->wiphy, 2437);
- else if (data->nan_curr_dw_band == NL80211_BAND_5GHZ)
+ else if (data->nan.curr_dw_band == NL80211_BAND_5GHZ)
channel = ieee80211_get_channel(hw->wiphy, 5745);
else
channel = NULL;
@@ -4131,21 +4135,21 @@ mac80211_hwsim_nan_dw_start(struct hrtimer *timer)
{
struct mac80211_hwsim_data *data =
container_of(timer, struct mac80211_hwsim_data,
- nan_timer);
+ nan.timer);
struct ieee80211_hw *hw = data->hw;
u64 orig_tsf = mac80211_hwsim_get_tsf(hw, NULL), tsf = orig_tsf;
u32 dw_int = 512 * 1024;
u64 until_dw;
- if (!data->nan_device_vif)
+ if (!data->nan.device_vif)
return HRTIMER_NORESTART;
- if (data->nan_bands & BIT(NL80211_BAND_5GHZ)) {
- if (data->nan_curr_dw_band == NL80211_BAND_2GHZ) {
+ if (data->nan.bands & BIT(NL80211_BAND_5GHZ)) {
+ if (data->nan.curr_dw_band == NL80211_BAND_2GHZ) {
dw_int = 128 * 1024;
- data->nan_curr_dw_band = NL80211_BAND_5GHZ;
- } else if (data->nan_curr_dw_band == NL80211_BAND_5GHZ) {
- data->nan_curr_dw_band = NL80211_BAND_2GHZ;
+ data->nan.curr_dw_band = NL80211_BAND_5GHZ;
+ } else if (data->nan.curr_dw_band == NL80211_BAND_5GHZ) {
+ data->nan.curr_dw_band = NL80211_BAND_2GHZ;
}
}
@@ -4162,18 +4166,18 @@ mac80211_hwsim_nan_dw_start(struct hrtimer *timer)
*/
wiphy_debug(hw->wiphy,
"%s: tsf=%llx, curr_dw_band=%u, next_dw=%llu\n",
- __func__, orig_tsf, data->nan_curr_dw_band,
+ __func__, orig_tsf, data->nan.curr_dw_band,
until_dw);
- hrtimer_forward_now(&data->nan_timer,
+ hrtimer_forward_now(&data->nan.timer,
ns_to_ktime(until_dw * NSEC_PER_USEC));
- if (data->notify_dw) {
+ if (data->nan.notify_dw) {
struct ieee80211_channel *ch;
struct wireless_dev *wdev =
- ieee80211_vif_to_wdev(data->nan_device_vif);
+ ieee80211_vif_to_wdev(data->nan.device_vif);
- if (data->nan_curr_dw_band == NL80211_BAND_5GHZ)
+ if (data->nan.curr_dw_band == NL80211_BAND_5GHZ)
ch = ieee80211_get_channel(hw->wiphy, 5745);
else
ch = ieee80211_get_channel(hw->wiphy, 2437);
@@ -4197,18 +4201,18 @@ static int mac80211_hwsim_start_nan(struct ieee80211_hw *hw,
if (vif->type != NL80211_IFTYPE_NAN)
return -EINVAL;
- if (data->nan_device_vif)
+ if (data->nan.device_vif)
return -EALREADY;
/* set this before starting the timer, as preemption might occur */
- data->nan_device_vif = vif;
- data->nan_bands = conf->bands;
- data->nan_curr_dw_band = NL80211_BAND_2GHZ;
+ data->nan.device_vif = vif;
+ data->nan.bands = conf->bands;
+ data->nan.curr_dw_band = NL80211_BAND_2GHZ;
wiphy_debug(hw->wiphy, "nan_started, next_dw=%llu\n",
until_dw);
- hrtimer_start(&data->nan_timer,
+ hrtimer_start(&data->nan.timer,
ns_to_ktime(until_dw * NSEC_PER_USEC),
HRTIMER_MODE_REL_SOFT);
@@ -4224,7 +4228,7 @@ static int mac80211_hwsim_start_nan(struct ieee80211_hw *hw,
hwsim_nan_cluster_id[5] = get_random_u8();
}
- data->notify_dw = conf->enable_dw_notification;
+ data->nan.notify_dw = conf->enable_dw_notification;
cfg80211_nan_cluster_joined(wdev, hwsim_nan_cluster_id, true,
GFP_KERNEL);
@@ -4239,16 +4243,16 @@ static int mac80211_hwsim_stop_nan(struct ieee80211_hw *hw,
struct mac80211_hwsim_data *data2;
bool nan_cluster_running = false;
- if (vif->type != NL80211_IFTYPE_NAN || !data->nan_device_vif ||
- data->nan_device_vif != vif)
+ if (vif->type != NL80211_IFTYPE_NAN || !data->nan.device_vif ||
+ data->nan.device_vif != vif)
return -EINVAL;
- hrtimer_cancel(&data->nan_timer);
- data->nan_device_vif = NULL;
+ hrtimer_cancel(&data->nan.timer);
+ data->nan.device_vif = NULL;
spin_lock_bh(&hwsim_radio_lock);
list_for_each_entry(data2, &hwsim_radios, list) {
- if (data2->nan_device_vif) {
+ if (data2->nan.device_vif) {
nan_cluster_running = true;
break;
}
@@ -4271,19 +4275,19 @@ static int mac80211_hwsim_change_nan_config(struct ieee80211_hw *hw,
if (vif->type != NL80211_IFTYPE_NAN)
return -EINVAL;
- if (!data->nan_device_vif)
+ if (!data->nan.device_vif)
return -EINVAL;
wiphy_debug(hw->wiphy, "nan_config_changed: changes=0x%x\n", changes);
/* Handle only the changes we care about for simulation purposes */
if (changes & CFG80211_NAN_CONF_CHANGED_BANDS) {
- data->nan_bands = conf->bands;
- data->nan_curr_dw_band = NL80211_BAND_2GHZ;
+ data->nan.bands = conf->bands;
+ data->nan.curr_dw_band = NL80211_BAND_2GHZ;
}
if (changes & CFG80211_NAN_CONF_CHANGED_CONFIG)
- data->notify_dw = conf->enable_dw_notification;
+ data->nan.notify_dw = conf->enable_dw_notification;
return 0;
}
@@ -5716,7 +5720,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
NAN_DEV_CAPA_EXT_KEY_ID_SUPPORTED |
NAN_DEV_CAPA_NDPE_SUPPORTED;
- hrtimer_setup(&data->nan_timer, mac80211_hwsim_nan_dw_start,
+ hrtimer_setup(&data->nan.timer, mac80211_hwsim_nan_dw_start,
CLOCK_MONOTONIC, HRTIMER_MODE_ABS_SOFT);
}
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 08/15] wifi: mac80211_hwsim: remove unused nan_vif struct member
From: Miri Korenblit @ 2026-05-03 8:59 UTC (permalink / raw)
To: linux-wireless; +Cc: Benjamin Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Benjamin Berg <benjamin.berg@intel.com>
The struct also contains nan_device_vif and that is the member that is
being used.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
drivers/net/wireless/virtual/mac80211_hwsim.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index 1fcf5d0d2e13..7ab0765cb482 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -765,7 +765,6 @@ struct mac80211_hwsim_data {
enum nl80211_band nan_curr_dw_band;
struct hrtimer nan_timer;
bool notify_dw;
- struct ieee80211_vif *nan_vif;
};
static const struct rhashtable_params hwsim_rht_params = {
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 07/15] wifi: mac80211: add NAN channel evacuation support
From: Miri Korenblit @ 2026-05-03 8:58 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
A NAN channel can be evacuated, i.e. detached from its chanctx, if all
chanctxs are used by NAN and a chanctx is needed for something else.
For example if the STA interface needs to perform a channel switch.
Implement the evacuation: detach the NAN channel from its chanctx, remove
all the peer NAN channels that were using this chanctx, and update the
driver.
Internally, the NAN channel evacuation will be triggered in the scenario
described above, and API is provided for the driver to also trigger it.
The driver/device is assumed to publish a ULW to notify the peers about
the fact that we won't be present on this NAN channel anymore.
Also export this as an API for the drivers: if a driver has other
resources per channel, it might want to trigger channel evacuation in
order to free up such internal resources for other usages.
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
include/net/mac80211.h | 15 +++++
net/mac80211/chan.c | 28 ++++++---
net/mac80211/nan.c | 126 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 162 insertions(+), 7 deletions(-)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 0d1b1d726b9c..d909bc1b29ff 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -7905,6 +7905,21 @@ void ieee80211_nan_cluster_joined(struct ieee80211_vif *vif,
const u8 *cluster_id, bool new_cluster,
gfp_t gfp);
+/**
+ * ieee80211_nan_try_evacuate - try to evacuate a NAN channel
+ *
+ * This function tries to evacuate a NAN channel that is using the given
+ * channel context, to free up channel context resources.
+ *
+ * @hw: pointer as obtained from ieee80211_alloc_hw()
+ * @conf: the channel context configuration to try to evacuate. If %NULL,
+ * the NAN channel that has the fewest slots scheduled will be evacuated.
+ *
+ * Return: %true if a channel was evacuated, %false otherwise
+ */
+bool ieee80211_nan_try_evacuate(struct ieee80211_hw *hw,
+ struct ieee80211_chanctx_conf *conf);
+
/**
* ieee80211_calc_rx_airtime - calculate estimated transmission airtime for RX.
*
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
index 248531051a4e..9683d3e6e1d2 100644
--- a/net/mac80211/chan.c
+++ b/net/mac80211/chan.c
@@ -1861,16 +1861,21 @@ static int ieee80211_vif_use_reserved_switch(struct ieee80211_local *local)
}
if (n_assigned != n_reserved) {
- if (n_ready == n_reserved) {
- wiphy_info(local->hw.wiphy,
- "channel context reservation cannot be finalized because some interfaces aren't switching\n");
- err = -EBUSY;
- goto err;
- }
+ if (n_ready != n_reserved)
+ return -EAGAIN;
- return -EAGAIN;
+ if (n_assigned == n_reserved + 1 &&
+ ieee80211_nan_try_evacuate(&local->hw,
+ &ctx->replace_ctx->conf))
+ goto use_reserved;
+
+ wiphy_info(local->hw.wiphy,
+ "channel context reservation cannot be finalized because some interfaces aren't switching\n");
+ err = -EBUSY;
+ goto err;
}
+use_reserved:
ctx->conf.radar_enabled = false;
for_each_chanctx_user_reserved(local, ctx, &iter) {
if (ieee80211_link_has_in_place_reservation(iter.link) &&
@@ -2178,6 +2183,15 @@ int _ieee80211_link_use_channel(struct ieee80211_link_data *link,
ctx = ieee80211_find_or_create_chanctx(sdata, chanreq, mode,
assign_on_failure, &reused_ctx);
+ if (IS_ERR(ctx)) {
+ /* Try to evacuate a NAN channel to free up a chanctx */
+ if (ieee80211_nan_try_evacuate(&local->hw, NULL))
+ ctx = ieee80211_find_or_create_chanctx(sdata, chanreq,
+ mode,
+ assign_on_failure,
+ &reused_ctx);
+ }
+
if (IS_ERR(ctx)) {
ret = PTR_ERR(ctx);
goto out;
diff --git a/net/mac80211/nan.c b/net/mac80211/nan.c
index 4e262b624521..cea620aaee6a 100644
--- a/net/mac80211/nan.c
+++ b/net/mac80211/nan.c
@@ -334,7 +334,10 @@ int ieee80211_nan_set_local_sched(struct ieee80211_sub_if_data *sdata,
sched_idx_to_chan[i] = chan;
ieee80211_nan_init_channel(chan,
&sched->nan_channels[i]);
+ }
+ /* Also a pre-existing channel might have been ULWed, so no chanctx */
+ if (!chan->chanctx_conf) {
ret = ieee80211_nan_use_chanctx(sdata, chan, false);
if (ret) {
memset(chan, 0, sizeof(*chan));
@@ -708,3 +711,126 @@ int ieee80211_nan_set_peer_sched(struct ieee80211_sub_if_data *sdata,
ieee80211_nan_free_peer_sched(to_free);
return ret;
}
+
+static void
+ieee80211_nan_evacuate_channel(struct ieee80211_sub_if_data *sdata,
+ struct ieee80211_nan_channel *nan_channel)
+{
+ struct ieee80211_chanctx_conf *conf;
+ struct ieee80211_chanctx *ctx;
+
+ lockdep_assert_wiphy(sdata->local->hw.wiphy);
+
+ if (WARN_ON(!nan_channel || !nan_channel->chanreq.oper.chan))
+ return;
+
+ conf = nan_channel->chanctx_conf;
+ if (WARN_ON(!conf))
+ return;
+
+ nan_channel->chanctx_conf = NULL;
+
+ /* Update all peer channels that reference this chanctx */
+ ieee80211_nan_update_peer_channels(sdata, conf);
+
+ drv_vif_cfg_changed(sdata->local, sdata, BSS_CHANGED_NAN_LOCAL_SCHED);
+
+ cfg80211_nan_channel_evac(&sdata->wdev, &nan_channel->chanreq.oper,
+ GFP_KERNEL);
+
+ /* Update NDI carrier states */
+ ieee80211_nan_update_all_ndi_carriers(sdata->local);
+
+ /* Clean up the channel context if no longer used */
+ ctx = container_of(conf, struct ieee80211_chanctx, conf);
+
+ if (ieee80211_chanctx_num_assigned(sdata->local, ctx) > 0) {
+ ieee80211_recalc_chanctx_chantype(sdata->local, ctx);
+ ieee80211_recalc_smps_chanctx(sdata->local, ctx);
+ ieee80211_recalc_chanctx_min_def(sdata->local, ctx);
+ }
+
+ if (ieee80211_chanctx_refcount(sdata->local, ctx) == 0)
+ ieee80211_free_chanctx(sdata->local, ctx, false);
+}
+
+bool ieee80211_nan_try_evacuate(struct ieee80211_hw *hw,
+ struct ieee80211_chanctx_conf *conf)
+{
+ struct ieee80211_sub_if_data *sdata = NULL, *tmp;
+ struct ieee80211_local *local = hw_to_local(hw);
+ struct ieee80211_nan_channel *evac_chan = NULL;
+ struct ieee80211_nan_sched_cfg *sched_cfg;
+ struct ieee80211_chanctx *ctx = NULL;
+ int min_slot_count = INT_MAX;
+ int usable_channels = 0;
+
+ lockdep_assert_wiphy(local->hw.wiphy);
+
+ if (conf)
+ ctx = container_of(conf, struct ieee80211_chanctx, conf);
+
+ /* Find the NAN interface - there can only be one */
+ list_for_each_entry(tmp, &local->interfaces, list) {
+ if (ieee80211_sdata_running(tmp) &&
+ tmp->vif.type == NL80211_IFTYPE_NAN) {
+ sdata = tmp;
+ break;
+ }
+ }
+
+ if (!sdata)
+ return false;
+
+ sched_cfg = &sdata->vif.cfg.nan_sched;
+
+ /* Find the channel to evacuate and count usable channels */
+ for (int i = 0; i < IEEE80211_NAN_MAX_CHANNELS; i++) {
+ struct ieee80211_nan_channel *chan =
+ &sched_cfg->channels[i];
+ struct ieee80211_chanctx *chan_ctx;
+ int slot_count = 0;
+
+ if (!chan->chanreq.oper.chan || !chan->chanctx_conf)
+ continue;
+
+ usable_channels++;
+
+ chan_ctx = container_of(chan->chanctx_conf,
+ struct ieee80211_chanctx, conf);
+
+ /* If ctx specified, only consider that specific chanctx */
+ if (ctx) {
+ if (chan_ctx == ctx)
+ evac_chan = chan;
+ continue;
+ }
+
+ /* Can only evacuate channels whose chanctx is NAN-only */
+ if (ieee80211_chanctx_refcount(local, chan_ctx) > 1)
+ continue;
+
+ /* Count how many time slots use this channel */
+ for (int s = 0; s < CFG80211_NAN_SCHED_NUM_TIME_SLOTS; s++)
+ if (sched_cfg->schedule[s] == chan)
+ slot_count++;
+
+ if (slot_count < min_slot_count) {
+ min_slot_count = slot_count;
+ evac_chan = chan;
+ }
+ }
+
+ /* No suitable NAN channel found */
+ if (!evac_chan)
+ return false;
+
+ /* NAN needs at least one remaining usable channel after evacuation */
+ if (usable_channels < 2)
+ return false;
+
+ ieee80211_nan_evacuate_channel(sdata, evac_chan);
+
+ return true;
+}
+EXPORT_SYMBOL(ieee80211_nan_try_evacuate);
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 06/15] wifi: mac80211: avoid out-of-bounds access in monitor
From: Miri Korenblit @ 2026-05-03 8:58 UTC (permalink / raw)
To: linux-wireless; +Cc: Ilan Peer, Johannes Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
In NAN, we don't know on what band the frame will be sent. Therefore we
set info->band to NUM_NL80211_BANDS. However, this leads to out-of-bound
access in ieee80211_add_tx_radiotap_header when we try to access the
sbands array.
Fix it by not accessing the array if the band is NUM_NL80211_BANDS.
This means that we will not report rate info for legacy rate in NAN.
But nobody really cares about it.
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
net/mac80211/status.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 4b38aa0e902a..8716eda8317d 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -5,7 +5,7 @@
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
* Copyright 2008-2010 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2013-2014 Intel Mobile Communications GmbH
- * Copyright 2021-2025 Intel Corporation
+ * Copyright 2021-2026 Intel Corporation
*/
#include <linux/export.h>
@@ -295,9 +295,10 @@ ieee80211_add_tx_radiotap_header(struct ieee80211_local *local,
RATE_INFO_FLAGS_VHT_MCS |
RATE_INFO_FLAGS_HE_MCS)))
legacy_rate = status_rate->rate_idx.legacy;
- } else if (info->status.rates[0].idx >= 0 &&
- !(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
- IEEE80211_TX_RC_VHT_MCS))) {
+ } else if (info->band < NUM_NL80211_BANDS &&
+ info->status.rates[0].idx >= 0 &&
+ !(info->status.rates[0].flags & (IEEE80211_TX_RC_MCS |
+ IEEE80211_TX_RC_VHT_MCS))) {
struct ieee80211_supported_band *sband;
sband = local->hw.wiphy->bands[info->band];
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 05/15] wifi: mac80211: Fix a kernel panic in ieee80211_encrypt_tx_skb()
From: Miri Korenblit @ 2026-05-03 8:58 UTC (permalink / raw)
To: linux-wireless; +Cc: Andrei Otcheretianski
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
skb->dev may be NULL for frames on non-netdev devices. For example, NAN
device frames after pairing. Fix it.
Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
net/mac80211/tx.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c18de2cb3769..933c86ca21c3 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -5355,7 +5355,7 @@ static int ieee80211_beacon_protect(struct sk_buff *skb,
int ieee80211_encrypt_tx_skb(struct sk_buff *skb)
{
struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
- struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_sub_if_data *sdata = NULL;
struct sk_buff *check_skb;
struct ieee80211_tx_data tx;
ieee80211_tx_result res;
@@ -5370,7 +5370,14 @@ int ieee80211_encrypt_tx_skb(struct sk_buff *skb)
__skb_queue_head_init(&tx.skbs);
__skb_queue_tail(&tx.skbs, skb);
- sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev);
+ if (skb->dev)
+ sdata = IEEE80211_DEV_TO_SUB_IF(skb->dev);
+ else if (info->control.vif)
+ sdata = vif_to_sdata(info->control.vif);
+
+ if (WARN_ON(!sdata))
+ return -EINVAL;
+
tx.sdata = sdata;
tx.local = sdata->local;
res = ieee80211_tx_h_encrypt(&tx);
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 04/15] wifi: mac80211: Allow setting MAC address on interface creation
From: Miri Korenblit @ 2026-05-03 8:58 UTC (permalink / raw)
To: linux-wireless; +Cc: Ilan Peer, Johannes Berg
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Ilan Peer <ilan.peer@intel.com>
Allow setting the interface MAC address for NAN Device interfaces
and P2P Device interfaces on interface creation.
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
net/mac80211/iface.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 95b779c4d627..683d8db4da14 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -2280,7 +2280,12 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
sdata->dev = NULL;
strscpy(sdata->name, name, IFNAMSIZ);
- ieee80211_assign_perm_addr(local, wdev->address, type);
+
+ if (is_valid_ether_addr(params->macaddr))
+ memcpy(wdev->address, params->macaddr, ETH_ALEN);
+ else
+ ieee80211_assign_perm_addr(local, wdev->address, type);
+
memcpy(sdata->vif.addr, wdev->address, ETH_ALEN);
ether_addr_copy(sdata->vif.bss_conf.addr, sdata->vif.addr);
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 03/15] wifi: mac80211: accept protected frames for NAN device
From: Miri Korenblit @ 2026-05-03 8:58 UTC (permalink / raw)
To: linux-wireless; +Cc: Avraham Stern
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Avraham Stern <avraham.stern@intel.com>
Some frames sent to the NAN device may be protected, such as
protected action frames (in particular protected dual of
public action).
Accept robust management frames except disassoc on the NAN
device, and clean up the code a little bit.
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
net/mac80211/rx.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 82ea7404f3da..e1f376e0620c 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -4624,16 +4624,24 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
ieee80211_has_fromds(hdr->frame_control))
return false;
- /* Accept only frames that are addressed to the NAN cluster
+ /*
+ * Accept only frames that are addressed to the NAN cluster
* (based on the Cluster ID). From these frames, accept only
- * action frames or authentication frames that are addressed to
- * the local NAN interface.
+ * - public action frames,
+ * - authentication frames to the local address, and
+ * - robust management frames except disassoc.
*/
- return memcmp(sdata->u.nan.conf.cluster_id,
- hdr->addr3, ETH_ALEN) == 0 &&
- (ieee80211_is_public_action(hdr, skb->len) ||
- (ieee80211_is_auth(hdr->frame_control) &&
- ether_addr_equal(sdata->vif.addr, hdr->addr1)));
+ if (!ether_addr_equal(sdata->u.nan.conf.cluster_id, hdr->addr3))
+ return false;
+ if (ieee80211_is_public_action(hdr, skb->len))
+ return true;
+ if (ieee80211_is_auth(hdr->frame_control) &&
+ ether_addr_equal(sdata->vif.addr, hdr->addr1))
+ return true;
+ if (!ieee80211_is_disassoc(hdr->frame_control) &&
+ ieee80211_is_robust_mgmt_frame(skb))
+ return true;
+ return false;
case NL80211_IFTYPE_NAN_DATA:
if (ieee80211_has_tods(hdr->frame_control) ||
ieee80211_has_fromds(hdr->frame_control))
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 02/15] wifi: mac80211: allow userspace TX/RX over NAN Data interfaces
From: Miri Korenblit @ 2026-05-03 8:58 UTC (permalink / raw)
To: linux-wireless; +Cc: Ilan Peer
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
From: Ilan Peer <ilan.peer@intel.com>
Allow TX/RX of action frames (for NAN action frames) over
NAN Data interfaces to support cases where there's a secure
NDP and NAFs may be exchanged over that.
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
net/mac80211/main.c | 4 ++++
net/mac80211/offchannel.c | 9 +++++++--
net/mac80211/tx.c | 5 +++--
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index f47dd58770ad..8400792d67e2 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -750,6 +750,10 @@ ieee80211_default_mgmt_stypes[NUM_NL80211_IFTYPES] = {
.rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
BIT(IEEE80211_STYPE_AUTH >> 4),
},
+ [NL80211_IFTYPE_NAN_DATA] = {
+ .tx = 0xffff,
+ .rx = BIT(IEEE80211_STYPE_ACTION >> 4),
+ },
};
static const struct ieee80211_ht_cap mac80211_ht_capa_mod_mask = {
diff --git a/net/mac80211/offchannel.c b/net/mac80211/offchannel.c
index f60f6a58948b..10c962d28037 100644
--- a/net/mac80211/offchannel.c
+++ b/net/mac80211/offchannel.c
@@ -8,7 +8,7 @@
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
* Copyright 2007, Michael Wu <flamingice@sourmilk.net>
* Copyright 2009 Johannes Berg <johannes@sipsolutions.net>
- * Copyright (C) 2019, 2022-2025 Intel Corporation
+ * Copyright (C) 2019, 2022-2026 Intel Corporation
*/
#include <linux/export.h>
#include <net/mac80211.h>
@@ -898,6 +898,10 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
break;
case NL80211_IFTYPE_NAN:
break;
+ case NL80211_IFTYPE_NAN_DATA:
+ if (is_multicast_ether_addr(mgmt->da))
+ return -EOPNOTSUPP;
+ break;
default:
return -EOPNOTSUPP;
}
@@ -911,7 +915,8 @@ int ieee80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,
/* Check if the operating channel is the requested channel */
if (!params->chan && mlo_sta) {
need_offchan = false;
- } else if (sdata->vif.type == NL80211_IFTYPE_NAN) {
+ } else if (sdata->vif.type == NL80211_IFTYPE_NAN ||
+ sdata->vif.type == NL80211_IFTYPE_NAN_DATA) {
/* Frames can be sent during NAN schedule */
} else if (!need_offchan) {
struct ieee80211_chanctx_conf *chanctx_conf = NULL;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 1702f816419b..c18de2cb3769 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -5,7 +5,7 @@
* Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
* Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
* Copyright 2013-2014 Intel Mobile Communications GmbH
- * Copyright (C) 2018-2025 Intel Corporation
+ * Copyright (C) 2018-2026 Intel Corporation
*
* Transmit and frame generation functions.
*/
@@ -6377,7 +6377,8 @@ void ieee80211_tx_skb_tid(struct ieee80211_sub_if_data *sdata,
enum nl80211_band band;
rcu_read_lock();
- if (sdata->vif.type == NL80211_IFTYPE_NAN) {
+ if (sdata->vif.type == NL80211_IFTYPE_NAN ||
+ sdata->vif.type == NL80211_IFTYPE_NAN_DATA) {
band = NUM_NL80211_BANDS;
} else if (!ieee80211_vif_is_mld(&sdata->vif)) {
WARN_ON(link_id >= 0);
--
2.34.1
^ permalink raw reply related
* [PATCH v3 wireless-next 01/15] wifi: mac80211: track the id of the NAN cluster we joined
From: Miri Korenblit @ 2026-05-03 8:58 UTC (permalink / raw)
To: linux-wireless
In-Reply-To: <20260503085907.257378-1-miriam.rachel.korenblit@intel.com>
Currently, we store in nan.conf the cluster id that was configured from
upper layer to be used when the device opens a cluster.
But after we joined a cluster, the configured cluster id is no longer
relevant. Particularly, in reconfig we will give the driver the
(possibly) wrong cluster id.
Add an API to be called by the driver when joined a cluster
in which the cluster id will be updated.
Use the locally stored cluster id instead of cfg80211's copy.
Ignore cluster id updates from cfg80211 if we already have one
configured.
Adjust the drivers that use the cfg80211 API
(cfg80211_nan_cluster_joined) directly, otherwise we break functionality
(i.e. accept frame check won't evaluate to true).
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
include/net/mac80211.h | 14 ++++++++++++++
net/mac80211/cfg.c | 19 +++++++++++++++++++
net/mac80211/rx.c | 4 ++--
net/mac80211/tx.c | 2 +-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 02318a4be0e1..0d1b1d726b9c 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -7891,6 +7891,20 @@ void ieee80211_nan_func_match(struct ieee80211_vif *vif,
*/
void ieee80211_nan_sched_update_done(struct ieee80211_vif *vif);
+/**
+ * ieee80211_nan_cluster_joined - notify about NAN cluster join.
+ *
+ * This function is used to notify mac80211 about NAN cluster join.
+ *
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
+ * @cluster_id: the cluster ID that was joined
+ * @new_cluster: true if this is a new cluster
+ * @gfp: allocation flags
+ */
+void ieee80211_nan_cluster_joined(struct ieee80211_vif *vif,
+ const u8 *cluster_id, bool new_cluster,
+ gfp_t gfp);
+
/**
* ieee80211_calc_rx_airtime - calculate estimated transmission airtime for RX.
*
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 00261bd6674b..c71af8878562 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -5215,6 +5215,25 @@ void ieee80211_nan_func_match(struct ieee80211_vif *vif,
}
EXPORT_SYMBOL(ieee80211_nan_func_match);
+void ieee80211_nan_cluster_joined(struct ieee80211_vif *vif,
+ const u8 *cluster_id, bool new_cluster,
+ gfp_t gfp)
+{
+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+
+ if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
+ return;
+
+ if (WARN_ON(!sdata->u.nan.started))
+ return;
+
+ ether_addr_copy(sdata->u.nan.conf.cluster_id, cluster_id);
+
+ cfg80211_nan_cluster_joined(ieee80211_vif_to_wdev(vif), cluster_id,
+ new_cluster, gfp);
+}
+EXPORT_SYMBOL(ieee80211_nan_cluster_joined);
+
static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
struct net_device *dev,
const bool enabled)
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 3e5d1c47a5b0..82ea7404f3da 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -4629,7 +4629,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
* action frames or authentication frames that are addressed to
* the local NAN interface.
*/
- return memcmp(sdata->wdev.u.nan.cluster_id,
+ return memcmp(sdata->u.nan.conf.cluster_id,
hdr->addr3, ETH_ALEN) == 0 &&
(ieee80211_is_public_action(hdr, skb->len) ||
(ieee80211_is_auth(hdr->frame_control) &&
@@ -4646,7 +4646,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
if (!nmi)
return false;
- if (!ether_addr_equal(nmi->wdev.u.nan.cluster_id,
+ if (!ether_addr_equal(nmi->u.nan.conf.cluster_id,
hdr->addr3))
return false;
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 8e4876d1c544..1702f816419b 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2854,7 +2854,7 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
ret = -ENOTCONN;
goto free;
}
- memcpy(hdr.addr3, nmi->wdev.u.nan.cluster_id, ETH_ALEN);
+ memcpy(hdr.addr3, nmi->u.nan.conf.cluster_id, ETH_ALEN);
hdrlen = 24;
break;
}
--
2.34.1
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox