From: Ilan Peer <ilan.peer@intel.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, Ilan Peer <ilan.peer@intel.com>
Subject: [PATCH v2 09/11] wifi: mac80211_hwsim: nan: prepare for more configurable NAN settings
Date: Mon, 5 Oct 2026 10:40:34 +0300 [thread overview]
Message-ID: <20261005074037.3506633-10-ilan.peer@intel.com> (raw)
In-Reply-To: <20261005074037.3506633-1-ilan.peer@intel.com>
In preparation for handling more of the NAN configuration setting, do
some refactoring and cleanup:
- Extract mac80211_hwsim_nan_set_config() and call it both when NAN is
started and when the configuration changes.
- Add NAN_BEACON_ELEM_LEN instead of the hardcoded 27.
Assisted-by: GitHubCopilot:claude-opus-5
Signed-off-by: Ilan Peer <ilan.peer@intel.com>
---
.../net/wireless/virtual/mac80211_hwsim_nan.c | 32 +++++++++++++++----
1 file changed, 25 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim_nan.c b/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
index f0732dd2eb79..3e05c0f43f79 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim_nan.c
@@ -33,6 +33,9 @@ static_assert(DW0_TSF_MASK + 1 == 8192 * 1024);
#define NAN_RSSI_CLOSE (-60)
#define NAN_RSSI_MIDDLE (-75)
+/* Size of the NAN vendor element carrying the mandatory attributes */
+#define NAN_BEACON_ELEM_LEN 27
+
/* Quiet time at the end of each slot where TX is suppressed */
#define NAN_CHAN_SWITCH_TIME_US 256
@@ -685,7 +688,7 @@ mac80211_hwsim_nan_tx_beacon(struct mac80211_hwsim_data *data,
{
struct ieee80211_vendor_ie nan_ie = {
.element_id = WLAN_EID_VENDOR_SPECIFIC,
- .len = 27 - 2,
+ .len = NAN_BEACON_ELEM_LEN - 2,
.oui = { u32_get_bits(WLAN_OUI_WFA, 0xff0000),
u32_get_bits(WLAN_OUI_WFA, 0xff00),
u32_get_bits(WLAN_OUI_WFA, 0xff) },
@@ -694,7 +697,7 @@ mac80211_hwsim_nan_tx_beacon(struct mac80211_hwsim_data *data,
size_t alloc_size =
IEEE80211_TX_STATUS_HEADROOM +
offsetofend(struct ieee80211_mgmt, u.beacon) +
- 27 /* size of NAN vendor element */;
+ NAN_BEACON_ELEM_LEN;
struct ieee80211_nan_master_indication master_indication;
struct ieee80211_nan_attr nan_attr;
struct ieee80211_mgmt *mgmt;
@@ -893,11 +896,20 @@ mac80211_hwsim_nan_discovery_beacon_timer(struct hrtimer *timer)
return HRTIMER_RESTART;
}
+static int mac80211_hwsim_nan_set_config(struct mac80211_hwsim_data *data,
+ struct cfg80211_nan_conf *conf)
+{
+ data->nan.notify_dw = conf->enable_dw_notification;
+
+ return 0;
+}
+
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;
+ int err;
if (vif->type != NL80211_IFTYPE_NAN)
return -EINVAL;
@@ -905,6 +917,10 @@ int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
if (data->nan.device_vif)
return -EALREADY;
+ err = mac80211_hwsim_nan_set_config(data, conf);
+ if (err)
+ return err;
+
/* set this before starting the timer, as preemption might occur */
data->nan.device_vif = vif;
data->nan.bands = conf->bands;
@@ -930,8 +946,6 @@ int mac80211_hwsim_nan_start(struct ieee80211_hw *hw,
ether_addr_copy(data->nan.cluster_id, conf->cluster_id);
- data->nan.notify_dw = conf->enable_dw_notification;
-
return 0;
}
@@ -967,13 +981,17 @@ int mac80211_hwsim_nan_change_config(struct ieee80211_hw *hw,
wiphy_debug(hw->wiphy, "nan_config_changed: changes=0x%x\n", changes);
+ if (changes & CFG80211_NAN_CONF_CHANGED_CONFIG) {
+ int err = mac80211_hwsim_nan_set_config(data, conf);
+
+ if (err)
+ return err;
+ }
+
/* Handle only the changes we care about for simulation purposes */
if (changes & CFG80211_NAN_CONF_CHANGED_BANDS)
data->nan.bands = conf->bands;
- if (changes & CFG80211_NAN_CONF_CHANGED_CONFIG)
- data->nan.notify_dw = conf->enable_dw_notification;
-
if (changes & CFG80211_NAN_CONF_CHANGED_PREF) {
scoped_guard(spinlock_bh, &data->nan.state_lock)
data->nan.master_pref = conf->master_pref;
--
2.55.0
next prev parent reply other threads:[~2026-10-04 13:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 7:40 [PATCH v2 00/11] wifi: cfg80211/mac80211: add NAN Instant Communication support Ilan Peer
2026-10-04 13:41 ` Johannes Berg
2026-10-04 13:54 ` Peer, Ilan
2026-10-05 7:40 ` [PATCH v2 01/11] wifi: cfg80211: nan: add " Ilan Peer
2026-10-05 7:40 ` [PATCH v2 02/11] wifi: mac80211: nan: Update NAN configuration copy Ilan Peer
2026-10-05 7:40 ` [PATCH v2 03/11] wifi: cfg80211: nan: check Rx registration for NAN beacons Ilan Peer
2026-10-05 7:40 ` [PATCH v2 04/11] wifi: cfg80211: do not use NAN beacons to update the BSS table Ilan Peer
2026-10-05 7:40 ` [PATCH v2 05/11] wifi: mac80211: nan: allow Rx registration for NAN beacons Ilan Peer
2026-10-05 7:40 ` [PATCH v2 06/11] wifi: mac80211: accept NAN beacons only when IC is enabled Ilan Peer
2026-10-05 7:40 ` [PATCH v2 07/11] wifi: ieee80211: add NAN service ID list attribute definitions Ilan Peer
2026-10-05 7:40 ` [PATCH v2 08/11] wifi: mac80211_hwsim: nan: use ieee80211_is_nan_beacon() helper Ilan Peer
2026-10-05 7:40 ` Ilan Peer [this message]
2026-10-05 7:40 ` [PATCH v2 10/11] wifi: mac80211_hwsim: nan: Handle more of the NAN configuration Ilan Peer
2026-10-05 7:40 ` [PATCH v2 11/11] wifi: mac80211_hwsim: add NAN Instant Communication support Ilan Peer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261005074037.3506633-10-ilan.peer@intel.com \
--to=ilan.peer@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.