linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations
@ 2025-06-22 22:24 Andrei Otcheretianski
  2025-06-22 22:24 ` [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands Andrei Otcheretianski
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Andrei Otcheretianski @ 2025-06-22 22:24 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski

This patch series extends exiting NAN APIs to support more
configuration options for NAN synchronization and a user space oriented
NAN Service Discovery implementation.
Existing NAN APIs are very limited and not really used, resulting in
vendors using proprietary vendor commands and a need to offload NAN
protocol implementations to the device firmware or driver.
In this series, additional APIs are added which allow to extend the
configuration of the NAN Synchronization logic and support user space
oriented NAN Service Discovery implementation.
With this design, wireless devices/drivers are still required to
implement NAN synchronization and cluster merging. NAN Discovery Engine,
may be either offloaded (keep using the existing APIs) or alternatively
implemented in user space.
To support user space oriented NAN Discovery Engine, the device will
notify user space with %NL80211_CMD_NAN_NEXT_DW_NOTIFICATION about the
upcoming Discovery Window (DW). This notification should be used as a
trigger for transmission of uncsolicited multicast SDF's (i.e.
unsolicited publish and active subscribe). Once SDF transmission is
requested with %NL80211_CMD_FRAME, the device shall take care of the
actual frame transmission during the upcoming DW.
Note, this notification may be sent before the actual DW start time.
On DW termination, the device/driver shall flush all untransmitted NAN
management frames. Untransmitted frames shall not be carried forward to
the next DW.
Note that such approach may not be appropriate for highly power
efficient devices or scenarios that require long discovery sessions, as
it may require the host to wake up for each DW.
User space can in turn turn off this notification using
%NL80211_NAN_CONF_NOTIFY_DW configuration flag if it doesn't intend to
send unsolicited multicast SDFs to prevent unneeded wake ups.

%NL80211_CMD_NAN_CLUSTER_JOINED notification shall be sent once after
new NAN cluster has been started or the device has joined an existing
cluster. In addition each time, cluster merge procedure results in
cluster merging, user space shall be notified. This is required, as
cluster ID is used as address 3 in SDF frames. Untransmitted frames
should be flushed, when this notification is generated in order to
prevent transmission of SDFs with invalid address 3.

This patch series goal is to provide APIs to support NAN synchronization
and user space oriented Service Discovery. It will be further extended
in a separate patch set to support user space implementation of NAN data
path (NDP) and NDL schedule establishment.

Andrei Otcheretianski (5):
  wifi: nl80211: Add more configuration options for NAN commands
  wifi: nl80211: Add more NAN capabilities
  wifi: nl80211: Add NAN Discovery Window (DW) notification
  wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API
  wifi: cfg80211: Add cluster joined notification API's

 include/net/cfg80211.h       |  95 +++++++++
 include/uapi/linux/nl80211.h | 144 +++++++++++++-
 net/wireless/nl80211.c       | 373 +++++++++++++++++++++++++++++++----
 net/wireless/trace.h         |  34 ++++
 4 files changed, 607 insertions(+), 39 deletions(-)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands
  2025-06-22 22:24 [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Andrei Otcheretianski
@ 2025-06-22 22:24 ` Andrei Otcheretianski
  2025-06-26 12:46   ` Johannes Berg
                     ` (2 more replies)
  2025-06-22 22:24 ` [RFC 2/5] wifi: nl80211: Add more NAN capabilities Andrei Otcheretianski
                   ` (4 subsequent siblings)
  5 siblings, 3 replies; 19+ messages in thread
From: Andrei Otcheretianski @ 2025-06-22 22:24 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski

Current NAN API's have only basic configuration for master
preference and operating bands. Add and parse additional parameters
which provide more control for NAN synchronization. The newly added
attributes allow to publish additional NAN attributes and vendor
elements in NAN beacons, control scan and discovery beacons
periodicity, enable/disable DW notifications etc.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 include/net/cfg80211.h       |  71 +++++++++
 include/uapi/linux/nl80211.h |  94 +++++++++++-
 net/wireless/nl80211.c       | 289 ++++++++++++++++++++++++++++++-----
 3 files changed, 415 insertions(+), 39 deletions(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 47b4235eea59..b3d3b039c913 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3758,6 +3758,30 @@ struct cfg80211_qos_map {
 	struct cfg80211_dscp_range up[8];
 };
 
+/**
+ * struct cfg80211_nan_band_config - NAN band specific configuration
+ *
+ * @chan: Pointer to the IEEE 802.11 channel structure. The channel to be used
+ *	for NAN operations on this band. For 2.4 GHz band, this is always
+ *	channel 6. For 5 GHz band, the channel is either 44 or 149, according
+ *	to the regulatory constraints.
+ * @rssi_close: RSSI close threshold used for NAN master selection. If not
+ *	specified (set to 0), default device value is used. The value should
+ *	be greater than -60 dBm (unsigned).
+ * @rssi_middle: RSSI middle threshold used for NAN master selection. If not
+ *	specified (set to 0), default device value is used. The value should be
+ *	greater than -75 dBm and less than rssi_close.
+ * @awake_dw_interval: Committed DW interval. Valid values range: 0-5. 0
+ *	indicates no wakeup for DW and can't be used on 2.4GHz band, otherwise
+ *	2^(n-1).
+ */
+struct cfg80211_nan_band_config {
+	struct ieee80211_channel *chan;
+	u8 rssi_close;
+	u8 rssi_middle;
+	u8 awake_dw_interval;
+};
+
 /**
  * struct cfg80211_nan_conf - NAN configuration
  *
@@ -3767,10 +3791,35 @@ struct cfg80211_qos_map {
  * @bands: operating bands, a bitmap of &enum nl80211_band values.
  *	For instance, for NL80211_BAND_2GHZ, bit 0 would be set
  *	(i.e. BIT(NL80211_BAND_2GHZ)).
+ * @cluster_id: cluster ID used for NAN synchronization
+ * @scan_period: period (in seconds) between NAN scans.
+ * @scan_dwell_time: dwell time (in milliseconds) for NAN scans.
+ * @discovery_beacon_interval: interval (in TUs) for discovery beacons.
+ * @enable_dw_notification: flag to enable/disable discovery window
+ *	notifications.
+ * @low_band_cfg: configuration for the low band.
+ * @high_band_cfg: configuration for the high band.
+ * @enable_scan: Flag to enable or disable scanning on 5 GHz band.
+ * @extra_nan_attrs: pointer to additional NAN attributes.
+ * @extra_nan_attrs_len: length of the additional NAN attributes.
+ * @vendor_elems: pointer to vendor-specific elements.
+ * @vendor_elems_len: length of the vendor-specific elements.
  */
 struct cfg80211_nan_conf {
 	u8 master_pref;
 	u8 bands;
+	u16 cluster_id;
+	u16 scan_period;
+	u16 scan_dwell_time;
+	u16 discovery_beacon_interval;
+	bool enable_dw_notification;
+	struct cfg80211_nan_band_config low_band_cfg;
+	struct cfg80211_nan_band_config high_band_cfg;
+	bool enable_hb_scan;
+	u8 *extra_nan_attrs;
+	size_t extra_nan_attrs_len;
+	u8 *vendor_elems;
+	size_t vendor_elems_len;
 };
 
 /**
@@ -3779,10 +3828,32 @@ struct cfg80211_nan_conf {
  *
  * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
  * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
+ * @CFG80211_NAN_CONF_CHANGED_CLUSTER_ID: cluster ID
+ * @CFG80211_NAN_CONF_CHANGED_SCAN_PERIOD: scan period
+ * @CFG80211_NAN_CONF_CHANGED_SCAN_DWELL_TIME: scan dwell time
+ * @CFG80211_NAN_CONF_CHANGED_DISCOVERY_BEACON_INTERVAL: discovery beacon
+ *	interval
+ * @CFG80211_NAN_CONF_CHANGED_ENABLE_DW_NOTIFICATION: enable DW notification
+ * @CFG80211_NAN_CONF_CHANGED_AWAKE_DW_INTERVALs: awake DW intervals (both
+ *	bands)
+ * @CFG80211_NAN_CONF_CHANGED_RSSI_THOLDS: RSSI thresholds (both bands)
+ * @CFG80211_NAN_CONF_CHANGED_ENABLE_HB_SCAN: enable high band scan
+ * @CFG80211_NAN_CONF_CHANGED_EXTRA_ATTRS: extra attributes
+ * @CFG80211_NAN_CONF_CHANGED_VENDOR_ELEMS: vendor elements
  */
 enum cfg80211_nan_conf_changes {
 	CFG80211_NAN_CONF_CHANGED_PREF = BIT(0),
 	CFG80211_NAN_CONF_CHANGED_BANDS = BIT(1),
+	CFG80211_NAN_CONF_CHANGED_CLUSTER_ID = BIT(2),
+	CFG80211_NAN_CONF_CHANGED_SCAN_PERIOD = BIT(3),
+	CFG80211_NAN_CONF_CHANGED_SCAN_DWELL_TIME = BIT(4),
+	CFG80211_NAN_CONF_CHANGED_DISCOVERY_BEACON_INTERVAL = BIT(5),
+	CFG80211_NAN_CONF_CHANGED_ENABLE_DW_NOTIFICATION = BIT(6),
+	CFG80211_NAN_CONF_CHANGED_AWAKE_DW_INTERVALS = BIT(7),
+	CFG80211_NAN_CONF_CHANGED_RSSI_THOLDS = BIT(8),
+	CFG80211_NAN_CONF_CHANGED_ENABLE_HB_SCAN = BIT(9),
+	CFG80211_NAN_CONF_CHANGED_EXTRA_ATTRS = BIT(10),
+	CFG80211_NAN_CONF_CHANGED_VENDOR_ELEMS = BIT(11),
 };
 
 /**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index a289014abe37..a68c486e2083 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1085,8 +1085,9 @@
  *	%NL80211_ATTR_NAN_MASTER_PREF attribute and optional
  *	%NL80211_ATTR_BANDS attributes.  If %NL80211_ATTR_BANDS is
  *	omitted or set to 0, it means don't-care and the device will
- *	decide what to use.  After this command NAN functions can be
- *	added.
+ *	decide what to use. Additional cluster configuration may be
+ *	optionally provided with %NL80211_ATTR_NAN_CONFIG.
+ *	After this command NAN functions can be added.
  * @NL80211_CMD_STOP_NAN: Stop the NAN operation, identified by
  *	its %NL80211_ATTR_WDEV interface.
  * @NL80211_CMD_ADD_NAN_FUNCTION: Add a NAN function. The function is defined
@@ -1115,6 +1116,8 @@
  *	current configuration is not changed.  If it is present but
  *	set to zero, the configuration is changed to don't-care
  *	(i.e. the device can decide what to do).
+ * 	Additional parameters may be provided with
+ *	%NL80211_ATTR_NAN_CONFIG.
  * @NL80211_CMD_NAN_MATCH: Notification sent when a match is reported.
  *	This will contain a %NL80211_ATTR_NAN_MATCH nested attribute and
  *	%NL80211_ATTR_COOKIE.
@@ -2907,6 +2910,12 @@ enum nl80211_commands {
  *	APs Support". Drivers may set additional flags that they support
  *	in the kernel or device.
  *
+ * @NL80211_ATTR_NAN_CONFIG: Nested attribute for
+ *	extended NAN cluster configuration. This is used with
+ *	%NL80211_CMD_START_NAN and %NL80211_CMD_CHANGE_NAN_CONFIG.
+ *	See &enum nl80211_nan_conf_attributes for details.
+ *	This attribute is optional.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3464,6 +3473,7 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS,
 
+	NL80211_ATTR_NAN_CONFIG,
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -7252,6 +7262,86 @@ enum nl80211_nan_match_attributes {
 	NL80211_NAN_MATCH_ATTR_MAX = NUM_NL80211_NAN_MATCH_ATTR - 1
 };
 
+/**
+ * enum nl80211_nan_band_conf_attributes - NAN band configuration attributes
+ * @__NL80211_NAN_BAND_CONF_INVALID: Invalid.
+ * @NL80211_NAN_BAND_CONF_CHAN: Discovery channel. Ignored on 2.4GHz band.
+ *	Either 44 or 149 for 5 GHz band.
+ * @NL80211_NAN_BAND_CONF_RSSI_CLOSE: RSSI close for NAN cluster state changes.
+ *	This is unsigned 8-bit value in dBm (absolute value).
+ * @NL80211_NAN_BAND_CONF_RSSI_MIDDLE: RSSI middle for NAN cluster state
+ * 	changes. This is unsigned 8-bit value in dBm (absolute value).
+ * @NL80211_NAN_BAND_CONF_WAKE_DW: Committed DW information (values 0-5).
+ * 	Value 0 means that the device will not wake up during the
+ * 	discovery window. Values 1-5 mean that the device will wake up
+ * 	during each 2^(n - 1) discovery window, where n is the value of
+ *	this attribute. Setting this attribute to 0 is not allowed on
+ *	2.4 GHz band.
+ * @NUM_NL80211_NAN_BAND_CONF_ATTR: Internal.
+ * @NL80211_NAN_BAND_CONF_ATTR_MAX: Highest NAN band configuration attribute.
+ *
+ * These attributes are used to configure NAN band-specific parameters. Note,
+ * that both RSSI attributes should be configured (or both left unset), while
+ * RSSI close should be higher than (>) -65 dBm and RSSI middle should be
+ * below the RSSI close value but not lower than (>=) -75 dBm.
+ */
+enum nl80211_nan_band_conf_attributes {
+	__NL80211_NAN_BAND_CONF_INVALID,
+	NL80211_NAN_BAND_CONF_CHAN,
+	NL80211_NAN_BAND_CONF_RSSI_CLOSE,
+	NL80211_NAN_BAND_CONF_RSSI_MIDDLE,
+	NL80211_NAN_BAND_CONF_WAKE_DW,
+
+	/* keep last */
+	NUM_NL80211_NAN_BAND_CONF_ATTR,
+	NL80211_NAN_BAND_CONF_ATTR_MAX = NUM_NL80211_NAN_BAND_CONF_ATTR - 1,
+};
+
+/**
+ * enum nl80211_nan_conf_attributes - NAN configuration attributes
+ * @__NL80211_NAN_CONF_INVALID: Invalid attribute, used for validation.
+ * @NL80211_NAN_CONF_CLUSTER_ID: ID for the NAN cluster.
+ * @NL80211_NAN_CONF_EXTRA_ATTRS: Additional NAN attributes to be
+ *	published in the beacons. (optional)
+ * @NL80211_NAN_CONF_VENDOR_ELEMS: Vendor-specific elements that will
+ *	be published in the beacons. (optional)
+ * @NL80211_NAN_CONF_2GHZ_CONFIG: Configuration for the 2.4 GHz band.
+ * @NL80211_NAN_CONF_5GHZ_CONFIG: Configuration for the 5 GHz band.
+ * @NL80211_NAN_CONF_SCAN_PERIOD: Scan period in seconds.
+ *	Zero value will disable scanning.
+ * @NL80211_NAN_CONF_SCAN_DWELL_TIME: Scan dwell time in TUs per channel.
+ *	Only non-zero values are valid. The optimal value depends on the
+ *	the discovery beacon interval of other devices in the cluster.
+ * @NL80211_NAN_CONF_ENABLE_HB_SCAN: If set, the device will enable scan on
+ *	5 GHz.
+ * @NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL: Discovery beacon interval
+ *	in TUs. Valid range is 50-200 TUs.
+ * @NL80211_NAN_CONF_NOTIFY_DW: If set, the driver will notify userspace about
+ *	the upcoming discovery window with
+ *	%NL80211_CMD_NAN_NEXT_DW_NOTIFICATION.
+ * @NUM_NL80211_NAN_CONF_ATTR: Internal.
+ * @NL80211_NAN_CONF_ATTR_MAX: Highest NAN configuration attribute.
+ *
+ * These attributes are used to configure NAN-specific parameters.
+ */
+enum nl80211_nan_conf_attributes {
+	__NL80211_NAN_CONF_INVALID,
+	NL80211_NAN_CONF_CLUSTER_ID,
+	NL80211_NAN_CONF_EXTRA_ATTRS,
+	NL80211_NAN_CONF_VENDOR_ELEMS,
+	NL80211_NAN_CONF_2GHZ_CONFIG,
+	NL80211_NAN_CONF_5GHZ_CONFIG,
+	NL80211_NAN_CONF_SCAN_PERIOD,
+	NL80211_NAN_CONF_SCAN_DWELL_TIME,
+	NL80211_NAN_CONF_ENABLE_HB_SCAN,
+	NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL,
+	NL80211_NAN_CONF_NOTIFY_DW,
+
+	/* keep last */
+	NUM_NL80211_NAN_CONF_ATTR,
+	NL80211_NAN_CONF_ATTR_MAX = NUM_NL80211_NAN_CONF_ATTR - 1,
+};
+
 /**
  * enum nl80211_external_auth_action - Action to perform with external
  *     authentication request. Used by NL80211_ATTR_EXTERNAL_AUTH_ACTION.
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 85f139016da2..6727580c0a50 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -479,6 +479,28 @@ nl80211_sta_wme_policy[NL80211_STA_WME_MAX + 1] = {
 	[NL80211_STA_WME_MAX_SP] = { .type = NLA_U8 },
 };
 
+static const struct nla_policy
+nl80211_nan_band_conf_policy[NL80211_NAN_BAND_CONF_ATTR_MAX + 1] = {
+	[NL80211_NAN_BAND_CONF_CHAN] = { .type = NLA_U8 },
+	[NL80211_NAN_BAND_CONF_RSSI_CLOSE] = { .type = NLA_U8 },
+	[NL80211_NAN_BAND_CONF_RSSI_MIDDLE] = { .type = NLA_U8 },
+	[NL80211_NAN_BAND_CONF_WAKE_DW] = { .type = NLA_U8},
+};
+
+static const struct nla_policy
+nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {
+	[NL80211_NAN_CONF_CLUSTER_ID] = NLA_POLICY_MIN(NLA_U16, 1),
+	[NL80211_NAN_CONF_EXTRA_ATTRS] = { .type = NLA_BINARY },
+	[NL80211_NAN_CONF_VENDOR_ELEMS] = { .type = NLA_BINARY },
+	[NL80211_NAN_CONF_2GHZ_CONFIG] = NLA_POLICY_NESTED(nl80211_nan_band_conf_policy),
+	[NL80211_NAN_CONF_5GHZ_CONFIG] = NLA_POLICY_NESTED(nl80211_nan_band_conf_policy),
+	[NL80211_NAN_CONF_SCAN_PERIOD] = { .type = NLA_U16 },
+	[NL80211_NAN_CONF_SCAN_DWELL_TIME] = NLA_POLICY_RANGE(NLA_U16, 50, 512),
+	[NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL] = NLA_POLICY_RANGE(NLA_U16, 50, 200),
+	[NL80211_NAN_CONF_NOTIFY_DW] = { .type = NLA_FLAG },
+	[NL80211_NAN_CONF_ENABLE_HB_SCAN] = { .type = NLA_FLAG },
+};
+
 static const struct netlink_range_validation nl80211_punct_bitmap_range = {
 	.min = 0,
 	.max = 0xffff,
@@ -748,6 +770,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_MU_MIMO_FOLLOW_MAC_ADDR] = NLA_POLICY_EXACT_LEN_WARN(ETH_ALEN),
 	[NL80211_ATTR_NAN_MASTER_PREF] = NLA_POLICY_MIN(NLA_U8, 1),
 	[NL80211_ATTR_BANDS] = { .type = NLA_U32 },
+	[NL80211_ATTR_NAN_CONFIG] = NLA_POLICY_NESTED(nl80211_nan_conf_policy),
 	[NL80211_ATTR_NAN_FUNC] = { .type = NLA_NESTED },
 	[NL80211_ATTR_FILS_KEK] = { .type = NLA_BINARY,
 				    .len = FILS_MAX_KEK_LEN },
@@ -14483,40 +14506,249 @@ static int nl80211_stop_p2p_device(struct sk_buff *skb, struct genl_info *info)
 	return 0;
 }
 
-static int nl80211_start_nan(struct sk_buff *skb, struct genl_info *info)
+static bool nl80211_valid_nan_freq(struct wiphy *wiphy, int freq)
 {
-	struct cfg80211_registered_device *rdev = info->user_ptr[0];
-	struct wireless_dev *wdev = info->user_ptr[1];
-	struct cfg80211_nan_conf conf = {};
+	struct ieee80211_channel *chan;
+	struct cfg80211_chan_def def;
+
+	/* Check if the frequency is valid for NAN */
+	if (freq != 2437 && freq != 5220 && freq != 5745)
+		return false;
+
+	chan = ieee80211_get_channel(wiphy, freq);
+	if (!chan)
+		return false;
+
+	cfg80211_chandef_create(&def, chan, NL80211_CHAN_NO_HT);
+
+	/* Check if the channel is allowed */
+	if (!cfg80211_reg_can_beacon(wiphy, &def, NL80211_IFTYPE_NAN))
+		return false;
+
+	return true;
+}
+
+static int nl80211_parse_nan_band_config(struct wiphy *wiphy,
+					 struct nlattr *attr,
+					 struct cfg80211_nan_band_config *cfg,
+					 u32 *changed, struct genl_info *info,
+					 enum nl80211_band band)
+{
+	struct nlattr *tb[NL80211_NAN_BAND_CONF_ATTR_MAX + 1];
 	int err;
 
-	if (wdev->iftype != NL80211_IFTYPE_NAN)
-		return -EOPNOTSUPP;
+	err = nla_parse_nested(tb, NL80211_NAN_BAND_CONF_ATTR_MAX, attr, NULL,
+			       info->extack);
+	if (err)
+		return err;
 
-	if (wdev_running(wdev))
-		return -EEXIST;
+	if (tb[NL80211_NAN_BAND_CONF_CHAN]) {
+		u8 ch = nla_get_u8(tb[NL80211_NAN_BAND_CONF_CHAN]);
+		int freq = ieee80211_channel_to_frequency(ch, band);
 
-	if (rfkill_blocked(rdev->wiphy.rfkill))
-		return -ERFKILL;
+		if (!nl80211_valid_nan_freq(wiphy, freq))
+			return -EINVAL;
 
-	if (!info->attrs[NL80211_ATTR_NAN_MASTER_PREF])
-		return -EINVAL;
+		cfg->chan = ieee80211_get_channel(wiphy, freq);
+	}
 
-	conf.master_pref =
-		nla_get_u8(info->attrs[NL80211_ATTR_NAN_MASTER_PREF]);
+	if (tb[NL80211_NAN_BAND_CONF_RSSI_CLOSE]) {
+		cfg->rssi_close =
+			nla_get_u8(tb[NL80211_NAN_BAND_CONF_RSSI_CLOSE]);
+		if (cfg->rssi_close > 60 ||
+		    !tb[NL80211_NAN_BAND_CONF_RSSI_MIDDLE])
+			return -EINVAL;
+
+		*changed |= CFG80211_NAN_CONF_CHANGED_RSSI_THOLDS;
+	}
+
+	if (tb[NL80211_NAN_BAND_CONF_RSSI_MIDDLE]) {
+		cfg->rssi_middle =
+			nla_get_u8(tb[NL80211_NAN_BAND_CONF_RSSI_MIDDLE]);
+		if (!cfg->rssi_close || cfg->rssi_middle > 75 ||
+		    cfg->rssi_middle <= cfg->rssi_close)
+			return -EINVAL;
+
+		*changed |= CFG80211_NAN_CONF_CHANGED_RSSI_THOLDS;
+	}
+
+	if (tb[NL80211_NAN_BAND_CONF_WAKE_DW]) {
+		cfg->awake_dw_interval =
+			nla_get_u8(tb[NL80211_NAN_BAND_CONF_WAKE_DW]);
+		if (cfg->awake_dw_interval > 5)
+			return -EINVAL;
+
+		if (band == NL80211_BAND_2GHZ && cfg->awake_dw_interval == 0)
+			return -EINVAL;
+
+		*changed |= CFG80211_NAN_CONF_CHANGED_AWAKE_DW_INTERVALS;
+	}
+
+	return 0;
+}
+
+static int nl80211_parse_nan_conf(struct wiphy *wiphy,
+				  struct genl_info *info,
+				  struct cfg80211_nan_conf *conf,
+				  u32 *changed)
+{
+	struct nlattr *attrs[NL80211_NAN_CONF_ATTR_MAX + 1];
+	int err;
+
+	if (info->attrs[NL80211_ATTR_NAN_MASTER_PREF]) {
+		conf->master_pref =
+			nla_get_u8(info->attrs[NL80211_ATTR_NAN_MASTER_PREF]);
+
+		*changed |= CFG80211_NAN_CONF_CHANGED_PREF;
+	}
 
 	if (info->attrs[NL80211_ATTR_BANDS]) {
 		u32 bands = nla_get_u32(info->attrs[NL80211_ATTR_BANDS]);
 
-		if (bands & ~(u32)wdev->wiphy->nan_supported_bands)
+		if (bands & ~(u32)wiphy->nan_supported_bands)
 			return -EOPNOTSUPP;
 
 		if (bands && !(bands & BIT(NL80211_BAND_2GHZ)))
 			return -EINVAL;
 
-		conf.bands = bands;
+		conf->bands = bands;
+		*changed |= CFG80211_NAN_CONF_CHANGED_BANDS;
+	}
+
+	if (!info->attrs[NL80211_ATTR_NAN_CONFIG])
+		return 0;
+
+	err = nla_parse_nested(attrs, NL80211_NAN_CONF_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_NAN_CONFIG], NULL,
+			       info->extack);
+	if (err)
+		return err;
+
+	if (attrs[NL80211_NAN_CONF_CLUSTER_ID]) {
+		conf->cluster_id =
+			nla_get_u8(attrs[NL80211_NAN_CONF_CLUSTER_ID]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_CLUSTER_ID;
+	}
+
+	if (attrs[NL80211_NAN_CONF_EXTRA_ATTRS]) {
+		conf->extra_nan_attrs =
+			nla_data(attrs[NL80211_NAN_CONF_EXTRA_ATTRS]);
+		conf->extra_nan_attrs_len =
+			nla_len(attrs[NL80211_NAN_CONF_EXTRA_ATTRS]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_EXTRA_ATTRS;
+	}
+
+	if (attrs[NL80211_NAN_CONF_VENDOR_ELEMS]) {
+		conf->vendor_elems =
+			nla_data(attrs[NL80211_NAN_CONF_VENDOR_ELEMS]);
+		conf->vendor_elems_len =
+			nla_len(attrs[NL80211_NAN_CONF_VENDOR_ELEMS]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_VENDOR_ELEMS;
+	}
+
+	conf->low_band_cfg.awake_dw_interval = 1;
+
+	if (conf->bands & BIT(NL80211_BAND_5GHZ))
+		conf->high_band_cfg.awake_dw_interval = 1;
+
+	if (attrs[NL80211_NAN_CONF_2GHZ_CONFIG]) {
+		err = nl80211_parse_nan_band_config(wiphy,
+						    attrs[NL80211_NAN_CONF_2GHZ_CONFIG],
+						    &conf->low_band_cfg,
+						    changed, info,
+						    NL80211_BAND_2GHZ);
+		if (err)
+			return err;
+	}
+
+	if (!conf->low_band_cfg.chan) {
+		/* If no 2GHz channel is specified, use the default */
+		conf->low_band_cfg.chan =
+			ieee80211_get_channel(wiphy, 2437);
+		if (!conf->low_band_cfg.chan ||
+			!nl80211_valid_nan_freq(wiphy, 2437))
+			return -EINVAL;
+	}
+
+	/* If the user configured 5 GHz channel use it or fail */
+	if (attrs[NL80211_NAN_CONF_5GHZ_CONFIG]) {
+		err = nl80211_parse_nan_band_config(wiphy,
+						    attrs[NL80211_NAN_CONF_5GHZ_CONFIG],
+						    &conf->high_band_cfg,
+						    changed, info,
+						    NL80211_BAND_5GHZ);
+		if (err)
+			return err;
+	}
+
+	if (!conf->high_band_cfg.chan) {
+		/* If no 5GHz channel is specified use default, if possible */
+		if (nl80211_valid_nan_freq(wiphy, 5745)) {
+			conf->high_band_cfg.chan =
+				ieee80211_get_channel(wiphy, 5745);
+		} else if (nl80211_valid_nan_freq(wiphy, 5220)) {
+			conf->high_band_cfg.chan =
+				ieee80211_get_channel(wiphy, 5220);
+		} else {
+			/* Disable 5GHZ */
+			conf->bands &= ~BIT(NL80211_BAND_5GHZ);
+		}
 	}
 
+	if (attrs[NL80211_NAN_CONF_SCAN_PERIOD]) {
+		conf->scan_period =
+			nla_get_u16(attrs[NL80211_NAN_CONF_SCAN_PERIOD]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_SCAN_PERIOD;
+	}
+
+	if (attrs[NL80211_NAN_CONF_SCAN_DWELL_TIME]) {
+		conf->scan_dwell_time =
+			nla_get_u16(attrs[NL80211_NAN_CONF_SCAN_DWELL_TIME]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_SCAN_DWELL_TIME;
+	}
+
+	if (attrs[NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL]) {
+		conf->discovery_beacon_interval =
+			nla_get_u16(attrs[NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_DISCOVERY_BEACON_INTERVAL;
+	}
+
+	if (attrs[NL80211_NAN_CONF_NOTIFY_DW]) {
+		conf->enable_dw_notification =
+			nla_get_flag(attrs[NL80211_NAN_CONF_NOTIFY_DW]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_ENABLE_DW_NOTIFICATION;
+	}
+
+	if (attrs[NL80211_NAN_CONF_ENABLE_HB_SCAN]) {
+		conf->enable_hb_scan =
+			nla_get_flag(attrs[NL80211_NAN_CONF_ENABLE_HB_SCAN]);
+		*changed |= CFG80211_NAN_CONF_CHANGED_ENABLE_HB_SCAN;
+	}
+
+	return 0;
+}
+
+static int nl80211_start_nan(struct sk_buff *skb, struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct wireless_dev *wdev = info->user_ptr[1];
+	struct cfg80211_nan_conf conf = {};
+	int err;
+	u32 changed = 0;
+
+	if (wdev->iftype != NL80211_IFTYPE_NAN)
+		return -EOPNOTSUPP;
+
+	if (wdev_running(wdev))
+		return -EEXIST;
+
+	if (rfkill_blocked(rdev->wiphy.rfkill))
+		return -ERFKILL;
+
+	err = nl80211_parse_nan_conf(&rdev->wiphy, info, &conf, &changed);
+	if (err)
+		return err;
+
 	err = rdev_start_nan(rdev, wdev, &conf);
 	if (err)
 		return err;
@@ -14871,6 +15103,7 @@ static int nl80211_nan_change_config(struct sk_buff *skb,
 	struct wireless_dev *wdev = info->user_ptr[1];
 	struct cfg80211_nan_conf conf = {};
 	u32 changed = 0;
+	int err;
 
 	if (wdev->iftype != NL80211_IFTYPE_NAN)
 		return -EOPNOTSUPP;
@@ -14878,27 +15111,9 @@ static int nl80211_nan_change_config(struct sk_buff *skb,
 	if (!wdev_running(wdev))
 		return -ENOTCONN;
 
-	if (info->attrs[NL80211_ATTR_NAN_MASTER_PREF]) {
-		conf.master_pref =
-			nla_get_u8(info->attrs[NL80211_ATTR_NAN_MASTER_PREF]);
-		if (conf.master_pref <= 1 || conf.master_pref == 255)
-			return -EINVAL;
-
-		changed |= CFG80211_NAN_CONF_CHANGED_PREF;
-	}
-
-	if (info->attrs[NL80211_ATTR_BANDS]) {
-		u32 bands = nla_get_u32(info->attrs[NL80211_ATTR_BANDS]);
-
-		if (bands & ~(u32)wdev->wiphy->nan_supported_bands)
-			return -EOPNOTSUPP;
-
-		if (bands && !(bands & BIT(NL80211_BAND_2GHZ)))
-			return -EINVAL;
-
-		conf.bands = bands;
-		changed |= CFG80211_NAN_CONF_CHANGED_BANDS;
-	}
+	err = nl80211_parse_nan_conf(&rdev->wiphy, info, &conf, &changed);
+	if (err)
+		return err;
 
 	if (!changed)
 		return -EINVAL;
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC 2/5] wifi: nl80211: Add more NAN capabilities
  2025-06-22 22:24 [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Andrei Otcheretianski
  2025-06-22 22:24 ` [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands Andrei Otcheretianski
@ 2025-06-22 22:24 ` Andrei Otcheretianski
  2025-06-26 12:51   ` Johannes Berg
  2025-07-08 12:13   ` Vinay Gannevaram
  2025-06-22 22:24 ` [RFC 3/5] wifi: nl80211: Add NAN Discovery Window (DW) notification Andrei Otcheretianski
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 19+ messages in thread
From: Andrei Otcheretianski @ 2025-06-22 22:24 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski

Add better break down for NAN capabilities, as NAN has multiple optional
features. This allows to better indicate which features are supported or
or offloaded to the device.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 include/uapi/linux/nl80211.h | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index a68c486e2083..f2d4a2007463 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -2915,6 +2915,10 @@ enum nl80211_commands {
  *	%NL80211_CMD_START_NAN and %NL80211_CMD_CHANGE_NAN_CONFIG.
  *	See &enum nl80211_nan_conf_attributes for details.
  *	This attribute is optional.
+ * @NL80211_ATTR_NAN_CAPABILITIES: Nested attribute for NAN capabilities.
+ *	This is used with %NL80211_CMD_GET_WIPHY to indicate the NAN
+ *	capabilities supported by the driver. See &enum nl80211_nan_capabilities
+ *	for details.
  *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -3474,6 +3478,7 @@ enum nl80211_attrs {
 	NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS,
 
 	NL80211_ATTR_NAN_CONFIG,
+	NL80211_ATTR_NAN_CAPABILITIES,
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -8226,4 +8231,35 @@ enum nl80211_wiphy_radio_freq_range {
 	NL80211_WIPHY_RADIO_FREQ_ATTR_MAX = __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST - 1,
 };
 
+/**
+ * enum nl80211_nan_capabilities - NAN (Neighbor Aware Networking)
+ *	capabilities.
+ *
+ * @__NL80211_NAN_CAPABILITIES_INVALID: Invalid.
+ * @NL80211_NAN_CAPA_SYNC_OFFLOAD: Flag attribute indicating that
+ *	NAN synchronization offload is supported. If this capability is set,
+ *	the driver must be able to handle %NL80211_ATTR_NAN_CONFIG
+ *	attribute in the %NL80211_CMD_START_NAN (and change) command.
+ * @NL80211_NAN_CAPA_DE_OFFLOAD: Flag attribute indicating that
+ *	NAN Discovery Engine (DE) offload is supported. Drivers/devices that set
+ *	this capability must be able to handle %NL80211_CMD_ADD_NAN_FUNCTION,
+ *	%NL80211_CMD_DEL_NAN_FUNCTION and %NL80211_CMD_NAN_MATCH commands.
+ * @NL80211_NAN_CAPA_DW_NOTIF_SUPPORT: Flag attribute indicating that
+ *	the device supports notifying user space about the upcoming
+ *	discovery window (DW) using %NL80211_CMD_NAN_NEXT_DW_NOTIFICATION.
+ *
+ * @__NL80211_NAN_CAPABILITIES_LAST: Internal
+ * @NL80211_NAN_CAPABILITES_MAX: Highest NAN capability attribute.
+ */
+enum nl80211_nan_capabilities {
+	__NL80211_NAN_CAPABILITIES_INVALID,
+
+	NL80211_NAN_CAPA_SYNC_OFFLOAD,
+	NL80211_NAN_CAPA_DE_OFFLOAD,
+	NL80211_NAN_CAPA_DW_NOTIF_SUPPORT,
+	/* keep last */
+	__NL80211_NAN_CAPABILITIES_LAST,
+	NL80211_NAN_CAPABILITES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,
+};
+
 #endif /* __LINUX_NL80211_H */
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC 3/5] wifi: nl80211: Add NAN Discovery Window (DW) notification
  2025-06-22 22:24 [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Andrei Otcheretianski
  2025-06-22 22:24 ` [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands Andrei Otcheretianski
  2025-06-22 22:24 ` [RFC 2/5] wifi: nl80211: Add more NAN capabilities Andrei Otcheretianski
@ 2025-06-22 22:24 ` Andrei Otcheretianski
  2025-06-22 22:24 ` [RFC 4/5] wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API Andrei Otcheretianski
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 19+ messages in thread
From: Andrei Otcheretianski @ 2025-06-22 22:24 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski

This notification will be used by the device to inform user space
about upcoming DW. When received, user space will be able to prepare
multicast Service Discovery Frames (SDFs) to be transmitted during the
next DW using %NL80211_CMD_FRAME command on the NAN management interface.
The device/driver will take care to transmit the frames in the correct
timing and flush the queues upon the termination of the DW.
This allows to implement a synchronized Discovery Engine (DE) in user
space, if the device doesn't support DE offload.
Note that this notification can be sent before the actual DW starts as
long as the driver/device handles the actual timing of the SDF
transmission.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 include/uapi/linux/nl80211.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index f2d4a2007463..134cea046bd0 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1347,6 +1347,11 @@
  *	control EPCS configuration. Used to notify userland on the current state
  *	of EPCS.
  *
+ * @NL80211_CMD_NAN_NEXT_DW_NOTIFICATION: This command is used to notify
+ *	userspace about the next Discovery Window (DW). Userspace may use it
+ *	to prepare frames to be sent in the next DW. %NL80211_ATTR_WIPHY_FREQ
+ *	is used to indicate the frequency of the next DW.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -1607,6 +1612,8 @@ enum nl80211_commands {
 	NL80211_CMD_ASSOC_MLO_RECONF,
 	NL80211_CMD_EPCS_CFG,
 
+	NL80211_CMD_NAN_NEXT_DW_NOTIFICATION,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC 4/5] wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API
  2025-06-22 22:24 [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Andrei Otcheretianski
                   ` (2 preceding siblings ...)
  2025-06-22 22:24 ` [RFC 3/5] wifi: nl80211: Add NAN Discovery Window (DW) notification Andrei Otcheretianski
@ 2025-06-22 22:24 ` Andrei Otcheretianski
  2025-06-27  8:44   ` Johannes Berg
  2025-06-22 22:24 ` [RFC 5/5] wifi: cfg80211: Add cluster joined notification API's Andrei Otcheretianski
  2025-07-08 12:42 ` [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Vinay Gannevaram
  5 siblings, 1 reply; 19+ messages in thread
From: Andrei Otcheretianski @ 2025-06-22 22:24 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski

Implement and export a new API that will be used by drivers to notify
user space about upcoming NAN Discovery Window (DW).

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 include/net/cfg80211.h | 10 ++++++++++
 net/wireless/nl80211.c | 41 +++++++++++++++++++++++++++++++++++++++++
 net/wireless/trace.h   | 16 ++++++++++++++++
 3 files changed, 67 insertions(+)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b3d3b039c913..27a3b8795d9b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -9871,6 +9871,16 @@ void cfg80211_schedule_channels_check(struct wireless_dev *wdev);
  */
 void cfg80211_epcs_changed(struct net_device *netdev, bool enabled);
 
+/**
+ * cfg80211_next_nan_dw_notif - Notify about the next NAN Discovery Window (DW)
+ * @wdev: Pointer to the wireless device structure
+ * @chan: DW channel (6, 44 or 149)
+ * @gfp: Memory allocation flags
+  */
+void cfg80211_next_nan_dw_notif(struct wireless_dev *wdev,
+				struct ieee80211_channel *chan,
+				gfp_t gfp);
+
 #ifdef CONFIG_CFG80211_DEBUGFS
 /**
  * wiphy_locked_debugfs_read - do a locked read in debugfs
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6727580c0a50..5936ec1557fe 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -20823,6 +20823,47 @@ void cfg80211_epcs_changed(struct net_device *netdev, bool enabled)
 }
 EXPORT_SYMBOL(cfg80211_epcs_changed);
 
+void cfg80211_next_nan_dw_notif(struct wireless_dev *wdev,
+				struct ieee80211_channel *chan,
+				gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct sk_buff *msg;
+	void *hdr;
+
+	trace_cfg80211_next_nan_dw_notif(wdev, chan);
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0,
+			     NL80211_CMD_NAN_NEXT_DW_NOTIFICATION);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+			      NL80211_ATTR_PAD) ||
+	    nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq))
+		goto nla_put_failure;
+
+	genlmsg_end(msg, hdr);
+
+	if (!wdev->owner_nlportid)
+		genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy),
+					msg, 0, NL80211_MCGRP_NAN, gfp);
+	else
+		genlmsg_unicast(wiphy_net(&rdev->wiphy), msg,
+				wdev->owner_nlportid);
+
+	return;
+
+ nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_next_nan_dw_notif);
+
 /* initialisation/exit functions */
 
 int __init nl80211_init(void)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 61a5eca9c513..bf84e6abaf69 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -4187,6 +4187,22 @@ TRACE_EVENT(cfg80211_epcs_changed,
 		  WDEV_PR_ARG, __entry->enabled)
 );
 
+TRACE_EVENT(cfg80211_next_nan_dw_notif,
+	TP_PROTO(struct wireless_dev *wdev,
+		 struct ieee80211_channel *chan),
+	TP_ARGS(wdev, chan),
+	TP_STRUCT__entry(
+		WDEV_ENTRY
+		CHAN_ENTRY
+	),
+	TP_fast_assign(
+		WDEV_ASSIGN;
+		CHAN_ASSIGN(chan);
+	),
+	TP_printk(WDEV_PR_FMT " " CHAN_PR_FMT,
+		  WDEV_PR_ARG, CHAN_PR_ARG)
+);
+
 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [RFC 5/5] wifi: cfg80211: Add cluster joined notification API's
  2025-06-22 22:24 [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Andrei Otcheretianski
                   ` (3 preceding siblings ...)
  2025-06-22 22:24 ` [RFC 4/5] wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API Andrei Otcheretianski
@ 2025-06-22 22:24 ` Andrei Otcheretianski
  2025-07-08 12:42 ` [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Vinay Gannevaram
  5 siblings, 0 replies; 19+ messages in thread
From: Andrei Otcheretianski @ 2025-06-22 22:24 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Andrei Otcheretianski

The drivers should notify upper layers and user space when a NAN device
joins a cluster. This is needed, for example, to set the correct addr3
in SDF frames. Add API to report cluster join event.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
---
 include/net/cfg80211.h       | 14 ++++++++++++
 include/uapi/linux/nl80211.h |  9 +++++++-
 net/wireless/nl80211.c       | 43 ++++++++++++++++++++++++++++++++++++
 net/wireless/trace.h         | 18 +++++++++++++++
 4 files changed, 83 insertions(+), 1 deletion(-)

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 27a3b8795d9b..93516ea07f7c 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -9881,6 +9881,20 @@ void cfg80211_next_nan_dw_notif(struct wireless_dev *wdev,
 				struct ieee80211_channel *chan,
 				gfp_t gfp);
 
+/**
+ * cfg80211_nan_cluster_joined - Notify about NAN cluster join
+ * @wdev: Pointer to the wireless device structure
+ * @cluster_id: Cluster ID of the NAN cluster that was joined or started
+ * @new_cluster: Indicates if this is a new cluster or an existing one
+ * @gfp: Memory allocation flags
+ *
+ * This function is used to notify user space when a NAN cluster has been
+ * joined, providing the cluster ID and a flag whether it is a new cluster.
+ */
+void cfg80211_nan_cluster_joined(struct wireless_dev *wdev,
+				 u16 cluster_id, bool new_cluster,
+				 gfp_t gfp);
+
 #ifdef CONFIG_CFG80211_DEBUGFS
 /**
  * wiphy_locked_debugfs_read - do a locked read in debugfs
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 134cea046bd0..d883f4a639e8 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1351,6 +1351,9 @@
  *	userspace about the next Discovery Window (DW). Userspace may use it
  *	to prepare frames to be sent in the next DW. %NL80211_ATTR_WIPHY_FREQ
  *	is used to indicate the frequency of the next DW.
+ * @NL80211_CMD_NAN_CLUSTER_JOINED: This command is used to notify
+ * 	userspace that the NAN new cluster has been joined. The cluster ID is
+ *	indicated by %NL80211_ATTR_MAC.
  *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
@@ -1613,7 +1616,7 @@ enum nl80211_commands {
 	NL80211_CMD_EPCS_CFG,
 
 	NL80211_CMD_NAN_NEXT_DW_NOTIFICATION,
-
+	NL80211_CMD_NAN_CLUSTER_JOINED,
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -2926,6 +2929,9 @@ enum nl80211_commands {
  *	This is used with %NL80211_CMD_GET_WIPHY to indicate the NAN
  *	capabilities supported by the driver. See &enum nl80211_nan_capabilities
  *	for details.
+ * @NL80211_ATTR_NAN_NEW_CLUSTER: Flag attribute indicating that a new
+ *	NAN cluster has been created. This is used with
+ *	%NL80211_CMD_NAN_CLUSTER_JOINED
  *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
@@ -3486,6 +3492,7 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_NAN_CONFIG,
 	NL80211_ATTR_NAN_CAPABILITIES,
+	NL80211_ATTR_NAN_NEW_CLUSTER,
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5936ec1557fe..f979fc1b504a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -20864,6 +20864,49 @@ void cfg80211_next_nan_dw_notif(struct wireless_dev *wdev,
 }
 EXPORT_SYMBOL(cfg80211_next_nan_dw_notif);
 
+void cfg80211_nan_cluster_joined(struct wireless_dev *wdev,
+				 u16 cluster_id, bool new_cluster,
+				 gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct sk_buff *msg;
+	void *hdr;
+	u8 nan_cluster_addr[ETH_ALEN] = { 0x51, 0x6f, 0x9a, 0x01, 0x00, 0x00 };
+
+	nan_cluster_addr[5] = cluster_id & 0xff;
+	nan_cluster_addr[4] = (cluster_id >> 8) & 0xff;
+	trace_cfg80211_nan_cluster_joined(wdev, cluster_id, new_cluster);
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_CLUSTER_JOINED);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+				NL80211_ATTR_PAD) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, nan_cluster_addr) ||
+	    (new_cluster && nla_put_flag(msg, NL80211_ATTR_NAN_NEW_CLUSTER)))
+		goto nla_put_failure;
+
+	genlmsg_end(msg, hdr);
+
+	if (!wdev->owner_nlportid)
+		genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy),
+					msg, 0, NL80211_MCGRP_NAN, gfp);
+	else
+		genlmsg_unicast(wiphy_net(&rdev->wiphy), msg,
+				wdev->owner_nlportid);
+	return;
+
+ nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_cluster_joined);
+
 /* initialisation/exit functions */
 
 int __init nl80211_init(void)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index bf84e6abaf69..deafd0b4f94c 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -4203,6 +4203,24 @@ TRACE_EVENT(cfg80211_next_nan_dw_notif,
 		  WDEV_PR_ARG, CHAN_PR_ARG)
 );
 
+TRACE_EVENT(cfg80211_nan_cluster_joined,
+	TP_PROTO(struct wireless_dev *wdev,
+		 u16 cluster_id, bool new_cluster),
+	TP_ARGS(wdev, cluster_id, new_cluster),
+	TP_STRUCT__entry(
+		WDEV_ENTRY
+		__field(u16, cluster_id)
+		__field(bool, new_cluster)
+	),
+	TP_fast_assign(
+		WDEV_ASSIGN;
+		__entry->cluster_id = cluster_id;
+		__entry->new_cluster = new_cluster;
+	),
+	TP_printk(WDEV_PR_FMT " cluster_id 0x%04x %s",
+		  WDEV_PR_ARG, __entry->cluster_id,
+		  __entry->new_cluster ? "[new]" : "")
+);
 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */
 
 #undef TRACE_INCLUDE_PATH
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands
  2025-06-22 22:24 ` [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands Andrei Otcheretianski
@ 2025-06-26 12:46   ` Johannes Berg
  2025-07-08 12:00     ` Otcheretianski, Andrei
  2025-07-08 12:49   ` Vinay Gannevaram
       [not found]   ` <d3526485-9f53-4202-8a88-489f3cf424d5@quicinc.com>
  2 siblings, 1 reply; 19+ messages in thread
From: Johannes Berg @ 2025-06-26 12:46 UTC (permalink / raw)
  To: Andrei Otcheretianski; +Cc: linux-wireless

On Mon, 2025-06-23 at 01:24 +0300, Andrei Otcheretianski wrote:
> 
> + * @rssi_close: RSSI close threshold used for NAN master selection. If not
> + *	specified (set to 0), default device value is used. The value should
> + *	be greater than -60 dBm (unsigned).
> + * @rssi_middle: RSSI middle threshold used for NAN master selection. If not
> + *	specified (set to 0), default device value is used. The value should be
> + *	greater than -75 dBm and less than rssi_close.

I think these are not described well, and I also don't understand why we
shouldn't use negative values in the APIs? I know the iwlwifi firmware
doesn't like to do it, but that's not a good reason not to do it in
other places?

> +	struct cfg80211_nan_band_config low_band_cfg;
> +	struct cfg80211_nan_band_config high_band_cfg;
> +	bool enable_hb_scan;

When we have "nan_supported_bands", it seems to me these should really
be by arbitrary band, and bitmap of bands to enable scan on, or
something like that ... also this really applies to the nl80211 API.

> +	u8 *extra_nan_attrs;
> +	u8 *vendor_elems;

const u8 *, presumably

> +	size_t vendor_elems_len;

Also not sure I see a need for size_t here, it's certainly going to be
limited to a netlink attribute (u16?) anyway?

> + * @NL80211_NAN_BAND_CONF_CHAN: Discovery channel. 

> Ignored on 2.4GHz band.

Shouldn't be ignored. Either require a correct value, or reject the
presence of the attribute.

> + *	Either 44 or 149 for 5 GHz band.

We should use frequencies.

A lot of these are missing docs about their attribute type too.

> + * @NL80211_NAN_BAND_CONF_RSSI_CLOSE: RSSI close for NAN cluster state changes.
> + *	This is unsigned 8-bit value in dBm (absolute value).

Nah, see above.

> +	/* Check if the channel is allowed */
> +	if (!cfg80211_reg_can_beacon(wiphy, &def, NL80211_IFTYPE_NAN))
> +		return false;
> +
> +	return true;

return cfg80211_reg_can_beacon()?

> +	if (!conf->low_band_cfg.chan) {
> +		/* If no 2GHz channel is specified, use the default */
> +		conf->low_band_cfg.chan =
> +			ieee80211_get_channel(wiphy, 2437);
> +		if (!conf->low_band_cfg.chan ||
> +			!nl80211_valid_nan_freq(wiphy, 2437))
> +			return -EINVAL;

code style

> +static int nl80211_start_nan(struct sk_buff *skb, struct genl_info *info)
> +{
> +	struct cfg80211_registered_device *rdev = info->user_ptr[0];
> +	struct wireless_dev *wdev = info->user_ptr[1];
> +	struct cfg80211_nan_conf conf = {};
> +	int err;
> +	u32 changed = 0;

what's that 'changed' even doing?

johannes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC 2/5] wifi: nl80211: Add more NAN capabilities
  2025-06-22 22:24 ` [RFC 2/5] wifi: nl80211: Add more NAN capabilities Andrei Otcheretianski
@ 2025-06-26 12:51   ` Johannes Berg
  2025-07-08 13:06     ` Otcheretianski, Andrei
  2025-07-08 12:13   ` Vinay Gannevaram
  1 sibling, 1 reply; 19+ messages in thread
From: Johannes Berg @ 2025-06-26 12:51 UTC (permalink / raw)
  To: Andrei Otcheretianski; +Cc: linux-wireless

On Mon, 2025-06-23 at 01:24 +0300, Andrei Otcheretianski wrote:
> Add better break down for NAN capabilities, as NAN has multiple optional
> features. This allows to better indicate which features are supported or
> or offloaded to the device.
> 
> Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
> ---
>  include/uapi/linux/nl80211.h | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
> index a68c486e2083..f2d4a2007463 100644
> --- a/include/uapi/linux/nl80211.h
> +++ b/include/uapi/linux/nl80211.h
> @@ -2915,6 +2915,10 @@ enum nl80211_commands {
>   *	%NL80211_CMD_START_NAN and %NL80211_CMD_CHANGE_NAN_CONFIG.
>   *	See &enum nl80211_nan_conf_attributes for details.
>   *	This attribute is optional.
> + * @NL80211_ATTR_NAN_CAPABILITIES: Nested attribute for NAN capabilities.
> + *	This is used with %NL80211_CMD_GET_WIPHY to indicate the NAN
> + *	capabilities supported by the driver. See &enum nl80211_nan_capabilities
> + *	for details.
>   *
>   * @NUM_NL80211_ATTR: total number of nl80211_attrs available
>   * @NL80211_ATTR_MAX: highest attribute number currently defined
> @@ -3474,6 +3478,7 @@ enum nl80211_attrs {
>  	NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS,
>  
>  	NL80211_ATTR_NAN_CONFIG,
> +	NL80211_ATTR_NAN_CAPABILITIES,
>  	/* add attributes here, update the policy in nl80211.c */
>  
>  	__NL80211_ATTR_AFTER_LAST,
> @@ -8226,4 +8231,35 @@ enum nl80211_wiphy_radio_freq_range {
>  	NL80211_WIPHY_RADIO_FREQ_ATTR_MAX = __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST - 1,
>  };
>  
> +/**
> + * enum nl80211_nan_capabilities - NAN (Neighbor Aware Networking)
> + *	capabilities.
> + *
> + * @__NL80211_NAN_CAPABILITIES_INVALID: Invalid.
> + * @NL80211_NAN_CAPA_SYNC_OFFLOAD: Flag attribute indicating that
> + *	NAN synchronization offload is supported. If this capability is set,
> + *	the driver must be able to handle %NL80211_ATTR_NAN_CONFIG
> + *	attribute in the %NL80211_CMD_START_NAN (and change) command.
> + * @NL80211_NAN_CAPA_DE_OFFLOAD: Flag attribute indicating that
> + *	NAN Discovery Engine (DE) offload is supported. Drivers/devices that set
> + *	this capability must be able to handle %NL80211_CMD_ADD_NAN_FUNCTION,
> + *	%NL80211_CMD_DEL_NAN_FUNCTION and %NL80211_CMD_NAN_MATCH commands.
> + * @NL80211_NAN_CAPA_DW_NOTIF_SUPPORT: Flag attribute indicating that
> + *	the device supports notifying user space about the upcoming
> + *	discovery window (DW) using %NL80211_CMD_NAN_NEXT_DW_NOTIFICATION.
> + *
> + * @__NL80211_NAN_CAPABILITIES_LAST: Internal
> + * @NL80211_NAN_CAPABILITES_MAX: Highest NAN capability attribute.
> + */
> +enum nl80211_nan_capabilities {
> +	__NL80211_NAN_CAPABILITIES_INVALID,
> +
> +	NL80211_NAN_CAPA_SYNC_OFFLOAD,
> +	NL80211_NAN_CAPA_DE_OFFLOAD,
> +	NL80211_NAN_CAPA_DW_NOTIF_SUPPORT,

This seems complex, why not just add three new extended flags?

johannes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC 4/5] wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API
  2025-06-22 22:24 ` [RFC 4/5] wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API Andrei Otcheretianski
@ 2025-06-27  8:44   ` Johannes Berg
  2025-07-08 13:21     ` Otcheretianski, Andrei
  0 siblings, 1 reply; 19+ messages in thread
From: Johannes Berg @ 2025-06-27  8:44 UTC (permalink / raw)
  To: Andrei Otcheretianski; +Cc: linux-wireless

On Mon, 2025-06-23 at 01:24 +0300, Andrei Otcheretianski wrote:
> Implement and export a new API that will be used by drivers to notify
> user space about upcoming NAN Discovery Window (DW).

Seems there's not that much point in splitting a 67 line patch and a 7
line patch (#3) that really belong together?

> +	if (!wdev->owner_nlportid)
> +		genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy),
> +					msg, 0, NL80211_MCGRP_NAN, gfp);
> +	else
> +		genlmsg_unicast(wiphy_net(&rdev->wiphy), msg,
> +				wdev->owner_nlportid);

I feel like perhaps the new design should just enforce the owner?
Otherwise how would all of this possibly work ... any application starts
listening and sending frames? Seems like a recipe for confusion.

johannes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands
  2025-06-26 12:46   ` Johannes Berg
@ 2025-07-08 12:00     ` Otcheretianski, Andrei
  2025-07-08 12:24       ` Johannes Berg
  0 siblings, 1 reply; 19+ messages in thread
From: Otcheretianski, Andrei @ 2025-07-08 12:00 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless@vger.kernel.org

> > + * @rssi_close: RSSI close threshold used for NAN master selection. If not
> > + *	specified (set to 0), default device value is used. The value should
> > + *	be greater than -60 dBm (unsigned).
> > + * @rssi_middle: RSSI middle threshold used for NAN master selection. If
> not
> > + *	specified (set to 0), default device value is used. The value should be
> > + *	greater than -75 dBm and less than rssi_close.
> 
> I think these are not described well, and I also don't understand why we
> shouldn't use negative values in the APIs? I know the iwlwifi firmware doesn't
> like to do it, but that's not a good reason not to do it in other places?

Sure. Will make it signed.

> 
> > +	struct cfg80211_nan_band_config low_band_cfg;
> > +	struct cfg80211_nan_band_config high_band_cfg;
> > +	bool enable_hb_scan;
> 
> When we have "nan_supported_bands", it seems to me these should really be
> by arbitrary band, and bitmap of bands to enable scan on, or something like
> that ... also this really applies to the nl80211 API.

NAN synchronization is only defined for 2.4 and 5 GHZ bands.
Now, "bands" (supported bands) field existed before, and I didn't want to change it.
Having an array of band_configs imho looks overkill.
Regarding enable_hb_scan (if this comment refers to this field),
it can't be for "arbitrary" band, as disabling scanning on 2.4GHz is not allowed.

> 
> > +	u8 *extra_nan_attrs;
> > +	u8 *vendor_elems;
> 
> const u8 *, presumably
> 
> > +	size_t vendor_elems_len;
> 
> Also not sure I see a need for size_t here, it's certainly going to be limited to a
> netlink attribute (u16?) anyway?

Will change to u16
> 
> > + * @NL80211_NAN_BAND_CONF_CHAN: Discovery channel.
> 
> > Ignored on 2.4GHz band.
> 
> Shouldn't be ignored. Either require a correct value, or reject the presence of
> the attribute.

Ok.

> 
> > + *	Either 44 or 149 for 5 GHz band.
> 
> We should use frequencies.

Ok. I'll change to freq.

> 
> A lot of these are missing docs about their attribute type too.
> 

Sure. Fixed

> > + * @NL80211_NAN_BAND_CONF_RSSI_CLOSE: RSSI close for NAN cluster
> state changes.
> > + *	This is unsigned 8-bit value in dBm (absolute value).
> 
> Nah, see above.

Will make it signed

> 
> > +	/* Check if the channel is allowed */
> > +	if (!cfg80211_reg_can_beacon(wiphy, &def, NL80211_IFTYPE_NAN))
> > +		return false;
> > +
> > +	return true;
> 
> return cfg80211_reg_can_beacon()?
> 

Of course :)

> > +	if (!conf->low_band_cfg.chan) {
> > +		/* If no 2GHz channel is specified, use the default */
> > +		conf->low_band_cfg.chan =
> > +			ieee80211_get_channel(wiphy, 2437);
> > +		if (!conf->low_band_cfg.chan ||
> > +			!nl80211_valid_nan_freq(wiphy, 2437))
> > +			return -EINVAL;
> 
> code style
> 

Fixed

> > +static int nl80211_start_nan(struct sk_buff *skb, struct genl_info
> > +*info) {
> > +	struct cfg80211_registered_device *rdev = info->user_ptr[0];
> > +	struct wireless_dev *wdev = info->user_ptr[1];
> > +	struct cfg80211_nan_conf conf = {};
> > +	int err;
> > +	u32 changed = 0;
> 
> what's that 'changed' even doing?

Nothing here. It is needed only in change_config(), but I still need to pass a valid pointer.
I'll make it support NULL..
> 
> johannes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC 2/5] wifi: nl80211: Add more NAN capabilities
  2025-06-22 22:24 ` [RFC 2/5] wifi: nl80211: Add more NAN capabilities Andrei Otcheretianski
  2025-06-26 12:51   ` Johannes Berg
@ 2025-07-08 12:13   ` Vinay Gannevaram
  2025-07-08 15:58     ` Jeff Johnson
  2025-07-21 16:38     ` Otcheretianski, Andrei
  1 sibling, 2 replies; 19+ messages in thread
From: Vinay Gannevaram @ 2025-07-08 12:13 UTC (permalink / raw)
  To: Andrei Otcheretianski, johannes; +Cc: linux-wireless


On 6/23/2025 3:54 AM, Andrei Otcheretianski wrote:
> Add better break down for NAN capabilities, as NAN has multiple optional
> features. This allows to better indicate which features are supported or
> or offloaded to the device.
>
> Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
> ---
>   include/uapi/linux/nl80211.h | 36 ++++++++++++++++++++++++++++++++++++
>   1 file changed, 36 insertions(+)
>
> diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
> index a68c486e2083..f2d4a2007463 100644
> --- a/include/uapi/linux/nl80211.h
> +++ b/include/uapi/linux/nl80211.h
> @@ -2915,6 +2915,10 @@ enum nl80211_commands {
>    *	%NL80211_CMD_START_NAN and %NL80211_CMD_CHANGE_NAN_CONFIG.
>    *	See &enum nl80211_nan_conf_attributes for details.
>    *	This attribute is optional.
> + * @NL80211_ATTR_NAN_CAPABILITIES: Nested attribute for NAN capabilities.
> + *	This is used with %NL80211_CMD_GET_WIPHY to indicate the NAN
> + *	capabilities supported by the driver. See &enum nl80211_nan_capabilities
> + *	for details.
>    *
>    * @NUM_NL80211_ATTR: total number of nl80211_attrs available
>    * @NL80211_ATTR_MAX: highest attribute number currently defined
> @@ -3474,6 +3478,7 @@ enum nl80211_attrs {
>   	NL80211_ATTR_ASSOC_MLD_EXT_CAPA_OPS,
>   
>   	NL80211_ATTR_NAN_CONFIG,
> +	NL80211_ATTR_NAN_CAPABILITIES,
>   	/* add attributes here, update the policy in nl80211.c */
>   
>   	__NL80211_ATTR_AFTER_LAST,
> @@ -8226,4 +8231,35 @@ enum nl80211_wiphy_radio_freq_range {
>   	NL80211_WIPHY_RADIO_FREQ_ATTR_MAX = __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST - 1,
>   };
>   
> +/**
> + * enum nl80211_nan_capabilities - NAN (Neighbor Aware Networking)
> + *	capabilities.
> + *
> + * @__NL80211_NAN_CAPABILITIES_INVALID: Invalid.
> + * @NL80211_NAN_CAPA_SYNC_OFFLOAD: Flag attribute indicating that
> + *	NAN synchronization offload is supported. If this capability is set,
> + *	the driver must be able to handle %NL80211_ATTR_NAN_CONFIG
> + *	attribute in the %NL80211_CMD_START_NAN (and change) command.
> + * @NL80211_NAN_CAPA_DE_OFFLOAD: Flag attribute indicating that
> + *	NAN Discovery Engine (DE) offload is supported. Drivers/devices that set
> + *	this capability must be able to handle %NL80211_CMD_ADD_NAN_FUNCTION,
> + *	%NL80211_CMD_DEL_NAN_FUNCTION and %NL80211_CMD_NAN_MATCH commands.
> + * @NL80211_NAN_CAPA_DW_NOTIF_SUPPORT: Flag attribute indicating that
> + *	the device supports notifying user space about the upcoming
> + *	discovery window (DW) using %NL80211_CMD_NAN_NEXT_DW_NOTIFICATION.

Can we add below additional capabilities also.

* @NL80211_NAN_CAPA_INSTANT_MODE_SUPPORT: Flag attribute indicating if the

  *    device supports instant mode operation for faster NAN session setup.
  * @NL80211_NAN_CAPA_6G_SUPPORT: Flag attribute indicating if the device
  *    supports NAN operation in 6 GHz band.
  * @NL80211_NAN_CAPA_HE_SUPPORT: Flag attribute indicating if the device
  *    supports 802.11ax (HE) features in NAN.
  * @NL80211_NAN_CAPA_PAIRING_SUPPORT: Flag attribute indicating if the 
device
  *    supports secure pairing over NAN.
  * @NL80211_NAN_CAPA_SET_CLUSTER_ID_SUPPORT: Flag attribute indicating 
if the
  *    device supports setting a custom cluster ID for NAN operation.
  * @NL80211_NAN_CAPA_PERIODIC_RANGING_SUPPORT: Flag attribute 
indicating if the
  *    device supports periodic ranging sessions over NAN.
  * @NL80211_NAN_CAPA_RTT_SUPPORTED_BW: (u32) Bitmask indicating supported
  *    bandwidths for RTT (ranging) over NAN.
  * @NL80211_NAN_CAPA_MAX_CONCURRENT_CLUSTERS: (u8) value to indicate 
maximum
  *    number of clusters the device can join concurrently.
  * @NL80211_NAN_CAPA_MAX_PUBLISH_SESSIONS: (u8) value to indicate 
maximum number
  *    of concurrent publish sessions supported.
  * @NL80211_NAN_CAPA_MAX_SUBSCRIBE_SESSIONS: (u8) value to indicate maximum
  *    number of concurrent subscribe sessions supported.
  * @NL80211_NAN_CAPA_MAX_MATCH_FILTER_LEN: (u16) Maximum length (in 
bytes) of an
  *    individual match filter.
  * @NL80211_NAN_CAPA_MAX_TOTAL_MATCH_FILTER_LEN: (u16) Maximum total length
  *    (in bytes) of all match filters combined across sessions.
  * @NL80211_NAN_CAPA_MAX_SSI_LEN: (u16) Maximum length (in bytes) of 
the service
  *    specific info (SSI) field.
  * @NL80211_NAN_CAPA_MAX_NDI_IFACES: (u8) Maximum number of NAN Data 
Interfaces
  *    (NDI) supported concurrently.
  * @NL80211_NAN_CAPA_MAX_NDP_SESSIONS: (u8) Maximum number of 
concurrent NAN
  *    Data Path (NDP) sessions supported.
  * @NL80211_NAN_CAPA_MAX_QUEUED_TRANSMIT_FOLLOWUP_MSGS: (u16) Maximum 
number of
  *    follow-up messages that can be queued for transmission.
  * @NL80211_NAN_CAPA_MAX_SDEA_SSI_LEN: (u16) Maximum length (in bytes) 
of the
  *    extended service specific info (SDEA SSI) field.
  * @NL80211_NAN_CAPA_MAX_SUBSCRIBE_ADDRESSES: (u8) Maximum number of 
subscribe
  *    addresses supported.
  * @NL80211_NAN_CAPA_MAX_RX_CHAINS: (u8) Maximum number of receive chains
  *    supported for NAN operation.
> + *
> + * @__NL80211_NAN_CAPABILITIES_LAST: Internal
> + * @NL80211_NAN_CAPABILITES_MAX: Highest NAN capability attribute.
> + */
> +enum nl80211_nan_capabilities {
> +	__NL80211_NAN_CAPABILITIES_INVALID,
> +
> +	NL80211_NAN_CAPA_SYNC_OFFLOAD,
> +	NL80211_NAN_CAPA_DE_OFFLOAD,
> +	NL80211_NAN_CAPA_DW_NOTIF_SUPPORT,
     NL80211_NAN_CAPA_INSTANT_MODE_SUPPORT,
     NL80211_NAN_CAPA_6G_SUPPORT,
     NL80211_NAN_CAPA_HE_SUPPORT,
     NL80211_NAN_CAPA_PAIRING_SUPPORT,
     NL80211_NAN_CAPA_SET_CLUSTER_ID_SUPPORT,
     NL80211_NAN_CAPA_PERIODIC_RANGING_SUPPORT,
     NL80211_NAN_CAPA_RTT_SUPPORTED_BW,
     NL80211_NAN_CAPA_MAX_CONCURRENT_CLUSTERS,
     NL80211_NAN_CAPA_MAX_PUBLISH_SESSIONS,
     NL80211_NAN_CAPA_MAX_SUBSCRIBE_SESSIONS,
     NL80211_NAN_CAPA_MAX_MATCH_FILTER_LEN,
     NL80211_NAN_CAPA_MAX_TOTAL_MATCH_FILTER_LEN,
     NL80211_NAN_CAPA_MAX_SSI_LEN,
     NL80211_NAN_CAPA_MAX_NDI_IFACES,
     NL80211_NAN_CAPA_MAX_NDP_SESSIONS,
     NL80211_NAN_CAPA_MAX_QUEUED_TRANSMIT_FOLLOWUP_MSGS,
     NL80211_NAN_CAPA_MAX_SDEA_SSI_LEN,
     NL80211_NAN_CAPA_MAX_SUBSCRIBE_ADDRESSES,
     NL80211_NAN_CAPA_MAX_RX_CHAINS,
> +	/* keep last */
> +	__NL80211_NAN_CAPABILITIES_LAST,
> +	NL80211_NAN_CAPABILITES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,
> +};
> +
>   #endif /* __LINUX_NL80211_H */

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands
  2025-07-08 12:00     ` Otcheretianski, Andrei
@ 2025-07-08 12:24       ` Johannes Berg
  0 siblings, 0 replies; 19+ messages in thread
From: Johannes Berg @ 2025-07-08 12:24 UTC (permalink / raw)
  To: Otcheretianski, Andrei; +Cc: linux-wireless@vger.kernel.org

On Tue, 2025-07-08 at 12:00 +0000, Otcheretianski, Andrei wrote:
> > 
> > When we have "nan_supported_bands", it seems to me these should really be
> > by arbitrary band, and bitmap of bands to enable scan on, or something like
> > that ... also this really applies to the nl80211 API.
> 
> NAN synchronization is only defined for 2.4 and 5 GHZ bands.
> Now, "bands" (supported bands) field existed before, and I didn't want to change it.
> Having an array of band_configs imho looks overkill.

Sure, there are any number of things that are not (yet!) defined. I
still don't think that's a good way to do software architecture. We
didn't _need_ to support MLO for P2P, but in software architecture,
handling everything as the currently supported special cases mostly ends
up hurting in my experience.

And Vinay was just also asking for a 6G support flag. Am I supposed to
believe NAN operation there is only unsynchronised, or how does that
match?

> Regarding enable_hb_scan (if this comment refers to this field),
> it can't be for "arbitrary" band, as disabling scanning on 2.4GHz is not allowed.

We can still represent it that way ("scan bands"?) and just forbid
certain values, that's not really much of an argument either?

johannes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations
  2025-06-22 22:24 [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Andrei Otcheretianski
                   ` (4 preceding siblings ...)
  2025-06-22 22:24 ` [RFC 5/5] wifi: cfg80211: Add cluster joined notification API's Andrei Otcheretianski
@ 2025-07-08 12:42 ` Vinay Gannevaram
  5 siblings, 0 replies; 19+ messages in thread
From: Vinay Gannevaram @ 2025-07-08 12:42 UTC (permalink / raw)
  To: Andrei Otcheretianski, johannes; +Cc: linux-wireless


On 6/23/2025 3:54 AM, Andrei Otcheretianski wrote:
> To support user space oriented NAN Discovery Engine, the device will
> notify user space with %NL80211_CMD_NAN_NEXT_DW_NOTIFICATION about the
> upcoming Discovery Window (DW). This notification should be used as a
> trigger for transmission of uncsolicited multicast SDF's (i.e.
s/uncsolicited/unsolicited
> unsolicited publish and active subscribe). Once SDF transmission is
> requested with %NL80211_CMD_FRAME, the device shall take care of the
> actual frame transmission during the upcoming DW.
Any specific reason for not carrying the untransmitted frames to next 
DW? Any scenarios that this could cause failures?

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands
  2025-06-22 22:24 ` [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands Andrei Otcheretianski
  2025-06-26 12:46   ` Johannes Berg
@ 2025-07-08 12:49   ` Vinay Gannevaram
       [not found]   ` <d3526485-9f53-4202-8a88-489f3cf424d5@quicinc.com>
  2 siblings, 0 replies; 19+ messages in thread
From: Vinay Gannevaram @ 2025-07-08 12:49 UTC (permalink / raw)
  To: Andrei Otcheretianski, johannes; +Cc: linux-wireless


On 6/23/2025 3:54 AM, Andrei Otcheretianski wrote:
> + * @low_band_cfg: configuration for the low band.
> + * @high_band_cfg: configuration for the high band.
> + * @enable_scan: Flag to enable or disable scanning on 5 GHz band.
s/enable_scan/enable_hb_scan
> + * @extra_nan_attrs: pointer to additional NAN attributes.
> + * @extra_nan_attrs_len: length of the additional NAN attributes.
> + * @vendor_elems: pointer to vendor-specific elements.
> + * @vendor_elems_len: length of the vendor-specific elements.
Can you please review if the following additional parameters would be 
required for the drivers to start nan or change the config.

* @max_publish_sids_in_beacon: This indicates maximum number of service 
IDs that can be accommodated in the Service ID List attribute in a NAN 
beacon.
* @max_subscribe_sids_in_beacon: This indicates maximum number of 
service IDs that can be accommodated in the Subscribe Service ID List 
attribute in a NAN beacon.
* @hop_limit: Maximum number of hops that is allowed to join a cluster. 
Value 0 indicates no such restriction.
* @rssi_window_size: Moving average of RSSI to decide NAN role switch.
* @nss: No of TX and RX chains to be used. This can be reconfigured 
using change configs for any change in power setting.
* @enable_dw_early_termination: Flag to enable/disable early DW 
termination. The device can decide to move out of the DW before the 
dwell time if this is enabled.
>    */
>   struct cfg80211_nan_conf {
>   	u8 master_pref;
>   	u8 bands;
> +	u16 cluster_id;
> +	u16 scan_period;
> +	u16 scan_dwell_time;
> +	u16 discovery_beacon_interval;
> +	bool enable_dw_notification;
> +	struct cfg80211_nan_band_config low_band_cfg;
> +	struct cfg80211_nan_band_config high_band_cfg;
> +	bool enable_hb_scan;
> +	u8 *extra_nan_attrs;
> +	size_t extra_nan_attrs_len;
> +	u8 *vendor_elems;
> +	size_t vendor_elems_len;
u8 max_publish_sids_in_beacon;
u8 max_subscribe_sids_in_beacon;
u8 hop_limit;
u16 rssi_window_size;
u8 nss;
bool enable_dw_early_termination;
>   };
>   
>   /**
> @@ -3779,10 +3828,32 @@ struct cfg80211_nan_conf {
>    *
>    * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
>    * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
> + * @CFG80211_NAN_CONF_CHANGED_CLUSTER_ID: cluster ID
> + * @CFG80211_NAN_CONF_CHANGED_SCAN_PERIOD: scan period
> + * @CFG80211_NAN_CONF_CHANGED_SCAN_DWELL_TIME: scan dwell time

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands
       [not found]   ` <d3526485-9f53-4202-8a88-489f3cf424d5@quicinc.com>
@ 2025-07-08 12:59     ` Otcheretianski, Andrei
  0 siblings, 0 replies; 19+ messages in thread
From: Otcheretianski, Andrei @ 2025-07-08 12:59 UTC (permalink / raw)
  To: Vinay Gannevaram, johannes@sipsolutions.net
  Cc: linux-wireless@vger.kernel.org, maheshkkv@google.com


Hi Vinay,
Thanks for reviewing, just a general note, can you make sure you reply inline in plaintext, so it makes it easier to reply 😊

> > + * @low_band_cfg: configuration for the low band.
> > + * @high_band_cfg: configuration for the high band.
> > + * @enable_scan: Flag to enable or disable scanning on 5 GHz band.

> s/enable_scan/enable_hb_scan 

Will fix. Thanks.

> > + * @extra_nan_attrs: pointer to additional NAN attributes. >
> > + * @extra_nan_attrs_len: length of the additional NAN attributes.
> > + * @vendor_elems: pointer to vendor-specific elements.
> > + * @vendor_elems_len: length of the vendor-specific elements.

> Can you please review if the following additional parameters would be required for the drivers to start nan or change the config. 
> * @max_publish_sids_in_beacon: This indicates maximum number of service IDs that can be accommodated in the Service ID List attribute in a NAN beacon. 
> * @max_subscribe_sids_in_beacon: This indicates maximum number of service IDs that can be accommodated in the Subscribe Service ID List attribute in a NAN beacon. 

These look like capabilities of the device and not as configuration no?
I think it makes more sense that the device will report it. (See my next capability patch).
However, specifically for these parameters, as I see it, the user space will configure service ids list using extra_nan_attrs.
So if needed, I would instead report more generic max_extran_nan_attrs_size capability. (Same for vendor elements).

> * @hop_limit: Maximum number of hops that is allowed to join a cluster. Value 0 indicates no such restriction. 

Actually we considered it and even had some long discussions with Mahesh (cc'ed) why is this needed.
In my understanding limiting hop may result in cluster synchronization being broken, or some undefined behavior.
Can you explain what is the scenario that you are trying to solve by limiting the hop count?

> * @rssi_window_size: Moving average of RSSI to decide NAN role switch. 

This should be implementation specific. Implementing moving average for all the beacons around is not trivial.
The device may also implement instead some other algorithms for averaging like (EWA) etc..
Do you have any specific scenario where user space needs to configure it?

> * @nss: No of TX and RX chains to be used. This can be reconfigured using change configs for any change in power setting.

Not sure what it means. Is it for ranging only maybe?
I didn't cover any ranging related parameters in this patch series. If needed, maybe it should be added separately.
If it's for general NAN synchronization, I'm not sure what it means as NAN device uses only 6mbit rate - I think it will always use a single antenna.

> * @enable_dw_early_termination: Flag to enable/disable early DW termination. The device can decide to move out of the DW before the dwell time if this is enabled. 

This one makes sense, but we will also need a corresponding capability since it's an optional feature.

>  /**
> @@ -3779,10 +3828,32 @@ struct cfg80211_nan_conf {
>   *
>   * @CFG80211_NAN_CONF_CHANGED_PREF: master preference
>   * @CFG80211_NAN_CONF_CHANGED_BANDS: operating bands
> + * @CFG80211_NAN_CONF_CHANGED_CLUSTER_ID: cluster ID
> + * @CFG80211_NAN_CONF_CHANGED_SCAN_PERIOD: scan period
> + * @CFG80211_NAN_CONF_CHANGED_SCAN_DWELL_TIME: scan dwell time
> 
>

Andrei

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [RFC 2/5] wifi: nl80211: Add more NAN capabilities
  2025-06-26 12:51   ` Johannes Berg
@ 2025-07-08 13:06     ` Otcheretianski, Andrei
  0 siblings, 0 replies; 19+ messages in thread
From: Otcheretianski, Andrei @ 2025-07-08 13:06 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless@vger.kernel.org


> > +enum nl80211_nan_capabilities {
> > +	__NL80211_NAN_CAPABILITIES_INVALID,
> > +
> > +	NL80211_NAN_CAPA_SYNC_OFFLOAD,
> > +	NL80211_NAN_CAPA_DE_OFFLOAD,
> > +	NL80211_NAN_CAPA_DW_NOTIF_SUPPORT,
> 
> This seems complex, why not just add three new extended flags?
> 

It will be further extended with more complex capabilities that can't be represented as flags.
This is especially true for data path related capabilities. Like number of NDPs/NDLs. Schedule constraints etc..

> johannes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [RFC 4/5] wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API
  2025-06-27  8:44   ` Johannes Berg
@ 2025-07-08 13:21     ` Otcheretianski, Andrei
  0 siblings, 0 replies; 19+ messages in thread
From: Otcheretianski, Andrei @ 2025-07-08 13:21 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless@vger.kernel.org

> Seems there's not that much point in splitting a 67 line patch and a 7 line patch
> (#3) that really belong together?

Sure, merged together.

> 
> > +	if (!wdev->owner_nlportid)
> > +		genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev-
> >wiphy),
> > +					msg, 0, NL80211_MCGRP_NAN, gfp);
> > +	else
> > +		genlmsg_unicast(wiphy_net(&rdev->wiphy), msg,
> > +				wdev->owner_nlportid);
> 
> I feel like perhaps the new design should just enforce the owner?
> Otherwise how would all of this possibly work ... any application starts
> listening and sending frames? Seems like a recipe for confusion.

I'll enforce here owner nl port.

> 
> johannes

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [RFC 2/5] wifi: nl80211: Add more NAN capabilities
  2025-07-08 12:13   ` Vinay Gannevaram
@ 2025-07-08 15:58     ` Jeff Johnson
  2025-07-21 16:38     ` Otcheretianski, Andrei
  1 sibling, 0 replies; 19+ messages in thread
From: Jeff Johnson @ 2025-07-08 15:58 UTC (permalink / raw)
  To: Vinay Gannevaram, Andrei Otcheretianski, johannes; +Cc: linux-wireless

On 7/8/2025 5:13 AM, Vinay Gannevaram wrote:
>   * @NL80211_NAN_CAPA_6G_SUPPORT: Flag attribute indicating if the device
>   *    supports NAN operation in 6 GHz band.

I have a generic request that in wifi we use GHZ instead of G in any
identifiers. This avoids confusion on whether G means a frequency band or
cellular generation.

/jeff

^ permalink raw reply	[flat|nested] 19+ messages in thread

* RE: [RFC 2/5] wifi: nl80211: Add more NAN capabilities
  2025-07-08 12:13   ` Vinay Gannevaram
  2025-07-08 15:58     ` Jeff Johnson
@ 2025-07-21 16:38     ` Otcheretianski, Andrei
  1 sibling, 0 replies; 19+ messages in thread
From: Otcheretianski, Andrei @ 2025-07-21 16:38 UTC (permalink / raw)
  To: Vinay Gannevaram, johannes@sipsolutions.net
  Cc: linux-wireless@vger.kernel.org, maheshkkv@google.com

> 
> Can we add below additional capabilities also.
>

Some of the below capabilities make sense to me. I can add few of them now, but in general, I think it would be better to add them together with the API definition of the specific feature they introduce. This way it will be possible to properly describe what exactly is required from the underlying driver/device.
 
> * @NL80211_NAN_CAPA_INSTANT_MODE_SUPPORT: Flag attribute indicating
> if the
> 
>   *    device supports instant mode operation for faster NAN session setup.

I think this one should be added together with some command/configuration to enter exist instant communication mode.

>   * @NL80211_NAN_CAPA_6G_SUPPORT: Flag attribute indicating if the device
>   *    supports NAN operation in 6 GHz band.

I will make it more generic. Supported bands bitmap (see my other comment below)

>   * @NL80211_NAN_CAPA_HE_SUPPORT: Flag attribute indicating if the device
>   *    supports 802.11ax (HE) features in NAN.

Same, see my (last) comment regarding device capabilities reporting.

>   * @NL80211_NAN_CAPA_PAIRING_SUPPORT: Flag attribute indicating if the
> device
>   *    supports secure pairing over NAN.

PASN pairing + bootstrapping will be done entirely in user space (wpa_supplicant).
What exactly this flag means in context of device/driver capabilities? I guess the device should be able to handle all the new keys derived during PASN (NM-TK etc)..
I think it's better to define what exactly is expected here and thus, it's better to define together when this feature is implemented.

>   * @NL80211_NAN_CAPA_SET_CLUSTER_ID_SUPPORT: Flag attribute
> indicating if the
>   *    device supports setting a custom cluster ID for NAN operation.

Do we really need a capability for that? The device can just ignore what user space configures? Also, this doesn't sound like a very complex requirement, no?
And I don't know why it's needed..

>   * @NL80211_NAN_CAPA_PERIODIC_RANGING_SUPPORT: Flag attribute
> indicating if the
>   *    device supports periodic ranging sessions over NAN.

This should be defined together with ranging commands.

>   * @NL80211_NAN_CAPA_RTT_SUPPORTED_BW: (u32) Bitmask indicating
> supported
>   *    bandwidths for RTT (ranging) over NAN.

same

>   * @NL80211_NAN_CAPA_MAX_CONCURRENT_CLUSTERS: (u8) value to
> indicate maximum
>   *    number of clusters the device can join concurrently.

How come the device can join multiple clusters? The whole idea in NAN is that the clusters shall converge..
How would it work with the existing API's with cluster_join and dw_notification?
Anyway, even though I don't understand why and how it can be used, the way to do so is to support multiple NMI interfaces. 
Reporting interface types combinations already exists in interface combinations API's (NL80211_ATTR_INTERFACE_COMBINATIONS)

>   * @NL80211_NAN_CAPA_MAX_PUBLISH_SESSIONS: (u8) value to indicate
> maximum number
>   *    of concurrent publish sessions supported.
>   * @NL80211_NAN_CAPA_MAX_SUBSCRIBE_SESSIONS: (u8) value to indicate
> maximum

What exactly is subsribe/publish *session*? I guess this limitation only applies for the offloaded DE scenario.
The existing APIs for offloaded DE use the notion of NAN function, which may be either publish, subsrcribe or follow up.
How this *session* limitation applies to it?
I think it would be clearer to define it as MAX_DE_FUNCS no?

>   *    number of concurrent subscribe sessions supported.
>   * @NL80211_NAN_CAPA_MAX_MATCH_FILTER_LEN: (u16) Maximum length
> (in
> bytes) of an
>   *    individual match filter.
>   * @NL80211_NAN_CAPA_MAX_TOTAL_MATCH_FILTER_LEN: (u16) Maximum
> total length
>   *    (in bytes) of all match filters combined across sessions.

Which filters? TX / RX filters? Is this limit applies for both? What about SRF filters? Bloom filter support.
I think it 

>   * @NL80211_NAN_CAPA_MAX_SSI_LEN: (u16) Maximum length (in bytes) of
> the service
>   *    specific info (SSI) field.

This one makes sense, but better define it together with all the other DE limitations. I guess we will need also max for vendor elements and NAN attributes lengths etc.

>   * @NL80211_NAN_CAPA_MAX_NDI_IFACES: (u8) Maximum number of NAN
> Data Interfaces
>   *    (NDI) supported concurrently.

NDI is eventually a netdev interface, so it will be reported via existing API's for supported iftypes and combinations.

>   * @NL80211_NAN_CAPA_MAX_NDP_SESSIONS: (u8) Maximum number of
> concurrent NAN
>   *    Data Path (NDP) sessions supported.

NDP session is not a real limitation. We can have multiple NDPs between same peers over same NDI reusing the same security. Such NDPs will not consume any resource at all.
The proper way to define it, is to report the maximum number of peer NAN stations and NDI's.
Since this is not trivial, I prefer to add it together with the definition of NAN datapath APIs.

>   * @NL80211_NAN_CAPA_MAX_QUEUED_TRANSMIT_FOLLOWUP_MSGS:
> (u16) Maximum number of
>   *    follow-up messages that can be queued for transmission.

For offloaded DE, as I mentioned before, I think it should be MAX_DE_FUNCS which include both publish, subscribe and follow ups. For non-offloaded case, this limitation doesn't apply as it is just management frame which is transmitted with NL80211_FRAME_CMD, similar to any other management frame.

>   * @NL80211_NAN_CAPA_MAX_SDEA_SSI_LEN: (u16) Maximum length (in
> bytes) of the
>   *    extended service specific info (SDEA SSI) field.

There's no need to define both SDEA SSI and SDA SSI as the offloaded DE API (ADD_FUNC) has only one attribute for SSI and it's up to the device to decide whether it should go in SDEA or SDA.
Actually the spec defines that SSI with length over 255 bytes should go into SDEA.

>   * @NL80211_NAN_CAPA_MAX_SUBSCRIBE_ADDRESSES: (u8) Maximum
> number of subscribe
>   *    addresses supported.

What is subscribe address? I don't think I understand what this means.

>   * @NL80211_NAN_CAPA_MAX_RX_CHAINS: (u8) Maximum number of
> receive chains
>   *    supported for NAN operation.

I think it is better to report the entire device capability (similar to the contents of NAN device capability attribute) as it includes everything.
- supported bands bitmap
- operation mode (which include VHT/HE/80+80 etc support bits)
- antennas bitmap (it has both tx and rx antennas)
- max channel switch time
- capabilities (dfs master bit, extended key_id, simultaneous ndp, ndpe, s3 capable etc..)

Andrei

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2025-07-21 16:38 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-22 22:24 [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Andrei Otcheretianski
2025-06-22 22:24 ` [RFC 1/5] wifi: nl80211: Add more configuration options for NAN commands Andrei Otcheretianski
2025-06-26 12:46   ` Johannes Berg
2025-07-08 12:00     ` Otcheretianski, Andrei
2025-07-08 12:24       ` Johannes Berg
2025-07-08 12:49   ` Vinay Gannevaram
     [not found]   ` <d3526485-9f53-4202-8a88-489f3cf424d5@quicinc.com>
2025-07-08 12:59     ` Otcheretianski, Andrei
2025-06-22 22:24 ` [RFC 2/5] wifi: nl80211: Add more NAN capabilities Andrei Otcheretianski
2025-06-26 12:51   ` Johannes Berg
2025-07-08 13:06     ` Otcheretianski, Andrei
2025-07-08 12:13   ` Vinay Gannevaram
2025-07-08 15:58     ` Jeff Johnson
2025-07-21 16:38     ` Otcheretianski, Andrei
2025-06-22 22:24 ` [RFC 3/5] wifi: nl80211: Add NAN Discovery Window (DW) notification Andrei Otcheretianski
2025-06-22 22:24 ` [RFC 4/5] wifi: cfg80211: Add cfg80211_next_nan_dw_notif() API Andrei Otcheretianski
2025-06-27  8:44   ` Johannes Berg
2025-07-08 13:21     ` Otcheretianski, Andrei
2025-06-22 22:24 ` [RFC 5/5] wifi: cfg80211: Add cluster joined notification API's Andrei Otcheretianski
2025-07-08 12:42 ` [RFC 0/5] wifi: nl80211: Extend NAN APIs to allow more flexible implementations Vinay Gannevaram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).