* [PATCH wireless-next v3 01/19] wifi: nl80211: reject NAN function add/delete when Discovery Engine is in userspace
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 02/19] wifi: nl80211/cfg80211: extend NAN function and configuration for discovery offload Shivani Baranwal
` (18 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
If the driver advertises WIPHY_NAN_FLAGS_USERSPACE_DE, the NAN Discovery
Engine is not offloaded to the driver. Reject the request to add/delete a
NAN function in cfg80211.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
net/wireless/nl80211.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5189366809db..5df058b835db 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -17419,6 +17419,12 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
if (!wdev_running(wdev))
return -ENOTCONN;
+ if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN Discovery Engine is in userspace");
+ return -EOPNOTSUPP;
+ }
+
if (!info->attrs[NL80211_ATTR_NAN_FUNC])
return -EINVAL;
@@ -17652,6 +17658,12 @@ static int nl80211_nan_del_func(struct sk_buff *skb,
if (!wdev_running(wdev))
return -ENOTCONN;
+ if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN Discovery Engine is in userspace");
+ return -EOPNOTSUPP;
+ }
+
if (!info->attrs[NL80211_ATTR_COOKIE])
return -EINVAL;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 02/19] wifi: nl80211/cfg80211: extend NAN function and configuration for discovery offload
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 01/19] wifi: nl80211: reject NAN function add/delete when Discovery Engine is in userspace Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 03/19] wifi: nl80211/cfg80211: extend NAN match indication " Shivani Baranwal
` (17 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Allow userspace to provide the NAN service parameters needed by an
offloaded Discovery Engine. Add flags for the SDEA Data Path Required,
Security Required, and GTK Required bits, and attributes for pairing
bootstrapping methods, supported NAN cipher suite IDs, and the ND-PMK.
Require SECURE_NAN for security-related service parameters, and validate
CSID arrays and ND-PMK lengths in the netlink policy.
Pairing Setup and NPK/NIK Caching are device capabilities advertised in
the Device Capability Extension attribute, so carry them in NAN config.
Accept these flags only when the Discovery Engine is offloaded and
SECURE_NAN is supported.
Store ND-PMK material in dynamically sized memory, free it with
kfree_sensitive(), and clear the ADD_NAN_FUNCTION request skb because
it may contain key material.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 24 +++++++
include/uapi/linux/nl80211.h | 36 +++++++++++
net/wireless/nl80211.c | 118 ++++++++++++++++++++++++++++++++++-
net/wireless/util.c | 2 +
4 files changed, 179 insertions(+), 1 deletion(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index c166f97dcf81..b6e4cec22652 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4249,6 +4249,8 @@ struct cfg80211_nan_band_config {
* notifications.
* @instant_comm: if true, start Instant Communication (IC) as defined in
* Chapter 13 of the Wi-Fi Aware Specification v4.0.
+ * @pairing_setup: if true, enable NAN pairing setup.
+ * @pairing_npk_caching: if true, enable NPK/NIK caching.
* @band_cfgs: array of band specific configurations, indexed by
* &enum nl80211_band values.
* @extra_nan_attrs: pointer to additional NAN attributes.
@@ -4265,6 +4267,8 @@ struct cfg80211_nan_conf {
u8 discovery_beacon_interval;
bool enable_dw_notification;
bool instant_comm;
+ bool pairing_setup;
+ bool pairing_npk_caching;
struct cfg80211_nan_band_config band_cfgs[NUM_NL80211_BANDS];
const u8 *extra_nan_attrs;
u16 extra_nan_attrs_len;
@@ -4441,6 +4445,18 @@ struct cfg80211_nan_func_filter {
* @num_tx_filters: length of &tx_filters.
* @instance_id: driver allocated id of the function.
* @cookie: unique NAN function identifier.
+ * @data_path_required: if true, the SDEA Data Path Required bit is set.
+ * @security_required: if true, the SDEA Security Required bit is set. Requires
+ * @data_path_required and %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @gtk_required: if true, the SDEA GTK Required bit is set for GTK protection
+ * of group-addressed data frames. Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @pairing_bootstrap_methods: bitmap of supported NAN pairing
+ * bootstrapping methods per the Wi-Fi Aware Specification Table 9-321.
+ * @csids: array of u32 NAN Cipher Suite ID (CSID) selectors supported by
+ * this service. See the Wi-Fi Aware Specification for cipher suite values.
+ * @num_csids: number of entries in @csids.
+ * @nd_pmk: pointer to the pre-shared NAN Data Path PMK (ND-PMK).
+ * @nd_pmk_len: length of @nd_pmk in bytes; depends on the cipher suite.
*/
struct cfg80211_nan_func {
enum nl80211_nan_function_type type;
@@ -4467,6 +4483,14 @@ struct cfg80211_nan_func {
u8 num_rx_filters;
u8 instance_id;
u64 cookie;
+ bool data_path_required;
+ bool security_required;
+ bool gtk_required;
+ u16 pairing_bootstrap_methods;
+ u32 *csids;
+ u8 num_csids;
+ const u8 *nd_pmk;
+ u8 nd_pmk_len;
};
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 97a9dd7588c3..55fc50519f8f 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -7849,6 +7849,24 @@ enum nl80211_nan_func_term_reason {
* Its type is u8 and it cannot be 0.
* @NL80211_NAN_FUNC_TERM_REASON: NAN function termination reason.
* See &enum nl80211_nan_func_term_reason.
+ * @NL80211_NAN_FUNC_DATA_PATH_REQUIRED: flag attribute. Sets the SDEA "Data
+ * Path Required" bit.
+ * @NL80211_NAN_FUNC_SECURITY_REQUIRED: flag attribute. Sets the SDEA
+ * "Security Required" bit. Requires
+ * @NL80211_NAN_FUNC_DATA_PATH_REQUIRED and
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_GTK_REQUIRED: flag attribute. Sets the SDEA "GTK
+ * Required" bit for GTK protection of group-addressed data frames.
+ * Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS: u16 bitmap of supported
+ * NAN pairing bootstrapping methods as defined in Wi-Fi Aware
+ * specification Table 9-321. Each bit corresponds to one method. Requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_CSIDS: a set of u32 NAN Cipher Suite ID (CSID)
+ * selectors supported by this service. Requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_ND_PMK: pre-shared NAN Data Path PMK (ND-PMK); its length
+ * depends on the cipher suite. Requires %NL80211_EXT_FEATURE_SECURE_NAN.
*
* @NUM_NL80211_NAN_FUNC_ATTR: internal
* @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute
@@ -7871,6 +7889,12 @@ enum nl80211_nan_func_attributes {
NL80211_NAN_FUNC_TX_MATCH_FILTER,
NL80211_NAN_FUNC_INSTANCE_ID,
NL80211_NAN_FUNC_TERM_REASON,
+ NL80211_NAN_FUNC_DATA_PATH_REQUIRED,
+ NL80211_NAN_FUNC_SECURITY_REQUIRED,
+ NL80211_NAN_FUNC_GTK_REQUIRED,
+ NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS,
+ NL80211_NAN_FUNC_CSIDS,
+ NL80211_NAN_FUNC_ND_PMK,
/* keep last */
NUM_NL80211_NAN_FUNC_ATTR,
@@ -8012,6 +8036,16 @@ enum nl80211_nan_band_conf_attributes {
* Wi-Fi Aware Specification v4.0.
* %NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL must be set as well.
* This is a flag attribute.
+ * @NL80211_NAN_CONF_PAIRING_SETUP: flag attribute. Enables NAN pairing setup
+ * and is advertised as "Pairing Setup Enabled" in the DCEA. Only valid for
+ * devices that offload the NAN Discovery Engine (i.e. without
+ * %NL80211_NAN_CAPA_USERSPACE_DE) and requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_CONF_PAIRING_NPK_CACHING: flag attribute. Enables NPK/NIK
+ * caching and is advertised as "NPK/NIK Caching Enabled" in the DCEA. Only
+ * valid for devices that offload the NAN Discovery Engine (i.e. without
+ * %NL80211_NAN_CAPA_USERSPACE_DE) and requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
* @NUM_NL80211_NAN_CONF_ATTR: Internal.
* @NL80211_NAN_CONF_ATTR_MAX: Highest NAN configuration attribute.
*
@@ -8028,6 +8062,8 @@ enum nl80211_nan_conf_attributes {
NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL,
NL80211_NAN_CONF_NOTIFY_DW,
NL80211_NAN_CONF_INSTANT_COMM,
+ NL80211_NAN_CONF_PAIRING_SETUP,
+ NL80211_NAN_CONF_PAIRING_NPK_CACHING,
/* keep last */
NUM_NL80211_NAN_CONF_ATTR,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5df058b835db..6847d1cfc4a5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -451,6 +451,34 @@ static int validate_nan_cluster_id(const struct nlattr *attr,
return 0;
}
+static int validate_nan_csids(const struct nlattr *attr,
+ struct netlink_ext_ack *extack)
+{
+ unsigned int len = nla_len(attr);
+
+ if (!len || len % sizeof(u32)) {
+ NL_SET_ERR_MSG_ATTR(extack, attr,
+ "CSIDs must be a non-empty array of u32 values");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int validate_nan_pmk(const struct nlattr *attr,
+ struct netlink_ext_ack *extack)
+{
+ unsigned int len = nla_len(attr);
+
+ if (len != WLAN_PMK_LEN && len != WLAN_PMK_LEN_SUITE_B_192) {
+ NL_SET_ERR_MSG_ATTR(extack, attr,
+ "ND-PMK length must be 32 or 48 octets");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int validate_nan_avail_blob(const struct nlattr *attr,
struct netlink_ext_ack *extack)
{
@@ -806,6 +834,8 @@ nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {
NLA_POLICY_RANGE(NLA_U8, 50, 200),
[NL80211_NAN_CONF_NOTIFY_DW] = { .type = NLA_FLAG },
[NL80211_NAN_CONF_INSTANT_COMM] = { .type = NLA_FLAG },
+ [NL80211_NAN_CONF_PAIRING_SETUP] = { .type = NLA_FLAG },
+ [NL80211_NAN_CONF_PAIRING_NPK_CACHING] = { .type = NLA_FLAG },
};
static const struct netlink_range_validation nl80211_punct_bitmap_range = {
@@ -1353,6 +1383,16 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = {
[NL80211_NAN_FUNC_TX_MATCH_FILTER] = { .type = NLA_NESTED },
[NL80211_NAN_FUNC_INSTANCE_ID] = { .type = NLA_U8 },
[NL80211_NAN_FUNC_TERM_REASON] = { .type = NLA_U8 },
+ [NL80211_NAN_FUNC_DATA_PATH_REQUIRED] = { .type = NLA_FLAG },
+ [NL80211_NAN_FUNC_SECURITY_REQUIRED] = { .type = NLA_FLAG },
+ [NL80211_NAN_FUNC_GTK_REQUIRED] = { .type = NLA_FLAG },
+ [NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] = { .type = NLA_U16 },
+ [NL80211_NAN_FUNC_CSIDS] =
+ NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_nan_csids,
+ U8_MAX * sizeof(u32)),
+ [NL80211_NAN_FUNC_ND_PMK] =
+ NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_nan_pmk,
+ WLAN_PMK_LEN_SUITE_B_192),
};
/* policy for Service Response Filter attributes */
@@ -17262,6 +17302,27 @@ static int nl80211_parse_nan_conf(struct wiphy *wiphy,
}
}
+ if (attrs[NL80211_NAN_CONF_PAIRING_SETUP] ||
+ attrs[NL80211_NAN_CONF_PAIRING_NPK_CACHING]) {
+ if (wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
+ NL_SET_ERR_MSG(info->extack,
+ "Pairing configuration requires an offloaded NAN Discovery Engine");
+ return -EOPNOTSUPP;
+ }
+
+ if (!wiphy_ext_feature_isset(wiphy,
+ NL80211_EXT_FEATURE_SECURE_NAN)) {
+ NL_SET_ERR_MSG(info->extack,
+ "Pairing configuration requires SECURE_NAN");
+ return -EOPNOTSUPP;
+ }
+ }
+
+ conf->pairing_setup =
+ nla_get_flag(attrs[NL80211_NAN_CONF_PAIRING_SETUP]);
+ conf->pairing_npk_caching =
+ nla_get_flag(attrs[NL80211_NAN_CONF_PAIRING_NPK_CACHING]);
+
out:
if (!conf->band_cfgs[NL80211_BAND_5GHZ].chan &&
(!conf->bands || conf->bands & BIT(NL80211_BAND_5GHZ))) {
@@ -17600,6 +17661,60 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
goto out;
}
+ func->data_path_required =
+ nla_get_flag(tb[NL80211_NAN_FUNC_DATA_PATH_REQUIRED]);
+ func->security_required =
+ nla_get_flag(tb[NL80211_NAN_FUNC_SECURITY_REQUIRED]);
+ func->gtk_required = nla_get_flag(tb[NL80211_NAN_FUNC_GTK_REQUIRED]);
+
+ if (func->security_required && !func->data_path_required) {
+ NL_SET_ERR_MSG(info->extack,
+ "SDEA Security Required requires Data Path Required");
+ err = -EINVAL;
+ goto out;
+ }
+
+ if (func->security_required || func->gtk_required ||
+ tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] ||
+ tb[NL80211_NAN_FUNC_CSIDS] || tb[NL80211_NAN_FUNC_ND_PMK]) {
+ if (!wiphy_ext_feature_isset(wdev->wiphy,
+ NL80211_EXT_FEATURE_SECURE_NAN)) {
+ NL_SET_ERR_MSG(info->extack,
+ "Security attributes require SECURE_NAN");
+ err = -EOPNOTSUPP;
+ goto out;
+ }
+
+ if (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS])
+ func->pairing_bootstrap_methods =
+ nla_get_u16(tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS]);
+
+ if (tb[NL80211_NAN_FUNC_CSIDS]) {
+ int len = nla_len(tb[NL80211_NAN_FUNC_CSIDS]);
+ int n = len / sizeof(u32);
+
+ func->csids = kmemdup(nla_data(tb[NL80211_NAN_FUNC_CSIDS]),
+ len, GFP_KERNEL);
+ if (!func->csids) {
+ err = -ENOMEM;
+ goto out;
+ }
+ func->num_csids = n;
+ }
+
+ if (tb[NL80211_NAN_FUNC_ND_PMK]) {
+ int len = nla_len(tb[NL80211_NAN_FUNC_ND_PMK]);
+
+ func->nd_pmk = kmemdup(nla_data(tb[NL80211_NAN_FUNC_ND_PMK]),
+ len, GFP_KERNEL);
+ if (!func->nd_pmk) {
+ err = -ENOMEM;
+ goto out;
+ }
+ func->nd_pmk_len = len;
+ }
+ }
+
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) {
err = -ENOMEM;
@@ -21211,7 +21326,8 @@ static const struct genl_small_ops nl80211_small_ops[] = {
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nl80211_nan_add_func,
.flags = GENL_ADMIN_PERM,
- .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+ .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |
+ NL80211_FLAG_CLEAR_SKB),
},
{
.cmd = NL80211_CMD_DEL_NAN_FUNCTION,
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 24cf0a2ba721..980b16c72d4f 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -2878,6 +2878,8 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f)
kfree(f->serv_spec_info);
kfree(f->srf_bf);
kfree(f->srf_macs);
+ kfree(f->csids);
+ kfree_sensitive(f->nd_pmk);
for (i = 0; i < f->num_rx_filters; i++)
kfree(f->rx_filters[i].filter);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 03/19] wifi: nl80211/cfg80211: extend NAN match indication for discovery offload
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 01/19] wifi: nl80211: reject NAN function add/delete when Discovery Engine is in userspace Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 02/19] wifi: nl80211/cfg80211: extend NAN function and configuration for discovery offload Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 04/19] wifi: nl80211/cfg80211: add NAN ranging FTM capability Shivani Baranwal
` (16 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Allow userspace to inspect every attribute in a received Service
Discovery Frame when the NAN Discovery Engine is offloaded. Such frames
can contain SDEA, NPBA, CSIA, SCIA, DCEA, and extended SSI. Report the
complete received management frame, including the 802.11 header, in
NL80211_ATTR_FRAME, along with its frequency and RSSI when available.
This lets userspace parse attributes without requiring a separate
nl80211 attribute for each.
Document that the peer Service Info may contain the SSI from the SDA or
the SDEA.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 21 +++++++++++++++++++--
include/uapi/linux/nl80211.h | 8 +++++++-
net/wireless/nl80211.c | 13 +++++++++++--
3 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b6e4cec22652..9f412fee8fe8 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -10716,8 +10716,20 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
* @inst_id: the local instance id
* @peer_inst_id: the instance id of the peer's function
* @addr: the MAC address of the peer
- * @info_len: the length of the &info
- * @info: the Service Specific Info from the peer (if any)
+ * @info_len: the length of @info
+ * @info: SSI from the peer, i.e. the Service Info of the Service Descriptor
+ * attribute (SDA) or the Service Info of the Service Descriptor Extension
+ * attribute (SDEA; extended SSI), whichever the peer used.
+ * @frame: complete management frame containing the received NAN SDF,
+ * including the 802.11 header (optional). It is reported as received and,
+ * for protected frames, after decryption, as with received frames reported
+ * with %NL80211_CMD_FRAME. This lets userspace distinguish protected
+ * (Protected Dual of Public Action) and unprotected frames.
+ * @frame_len: length of @frame
+ * @freq: frequency in MHz on which @frame was received, or 0 if unknown
+ * @rssi: received signal strength in dBm at the time of the match.
+ * Only valid when @rssi_valid is true.
+ * @rssi_valid: if true, @rssi contains a valid RSSI measurement.
* @cookie: unique identifier of the corresponding function
*/
struct cfg80211_nan_match_params {
@@ -10727,6 +10739,11 @@ struct cfg80211_nan_match_params {
const u8 *addr;
u8 info_len;
const u8 *info;
+ const u8 *frame;
+ size_t frame_len;
+ u32 freq;
+ s32 rssi;
+ bool rssi_valid;
u64 cookie;
};
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 55fc50519f8f..c30dcba96763 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1185,7 +1185,13 @@
* only a subset was changed.
* @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.
+ * %NL80211_ATTR_COOKIE. It may also contain %NL80211_ATTR_FRAME,
+ * %NL80211_ATTR_WIPHY_FREQ, and %NL80211_ATTR_RX_SIGNAL_DBM so userspace
+ * can parse any attribute in the received SDF. The frame is the complete
+ * received management frame, including the 802.11 header. It is reported as
+ * received and, for protected frames, after decryption, as with received
+ * frames reported with %NL80211_CMD_FRAME. This lets userspace distinguish
+ * protected (Protected Dual of Public Action) and unprotected frames.
*
* @NL80211_CMD_UPDATE_CONNECT_PARAMS: Update one or more connect parameters
* for subsequent roaming cases if the driver or firmware uses internal
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 6847d1cfc4a5..3375aea01e0c 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -17869,7 +17869,10 @@ void cfg80211_nan_match(struct wireless_dev *wdev,
if (WARN_ON(!match->inst_id || !match->peer_inst_id || !match->addr))
return;
- msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+ if (WARN_ON_ONCE(match->frame_len && !match->frame))
+ return;
+
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE + match->frame_len, gfp);
if (!msg)
return;
@@ -17888,7 +17891,13 @@ void cfg80211_nan_match(struct wireless_dev *wdev,
if (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, match->cookie,
NL80211_ATTR_PAD) ||
- nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, match->addr))
+ nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, match->addr) ||
+ (match->frame && match->frame_len &&
+ nla_put(msg, NL80211_ATTR_FRAME, match->frame_len, match->frame)) ||
+ (match->freq &&
+ nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, match->freq)) ||
+ (match->rssi_valid &&
+ nla_put_u32(msg, NL80211_ATTR_RX_SIGNAL_DBM, match->rssi)))
goto nla_put_failure;
match_attr = nla_nest_start_noflag(msg, NL80211_ATTR_NAN_MATCH);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 04/19] wifi: nl80211/cfg80211: add NAN ranging FTM capability
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (2 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 03/19] wifi: nl80211/cfg80211: extend NAN match indication " Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 05/19] wifi: nl80211/cfg80211: advertise NAN ranging support Shivani Baranwal
` (15 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
From: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Add NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT to the FTM type
capability enum so that userspace (e.g., wpa_supplicant) can query
whether the driver supports FTM-based ranging within a NAN Ranging
Session before initiating a NAN Ranging Request.
Add the corresponding nan_support bit to cfg80211_pmsr_capabilities
and include it in the capability advertisement in
nl80211_send_pmsr_ftm_capa(). NAN ranging always uses ASAP and a single
burst, independent of the generic ASAP capability.
Signed-off-by: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 6 +++++-
include/uapi/linux/nl80211.h | 6 ++++++
net/wireless/nl80211.c | 7 ++++++-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9f412fee8fe8..db175abf9a24 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -6314,6 +6314,9 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);
* @ftm.type.pd_support: supports peer-to-peer ranging as mentioned in the
* specification "PR Implementation Consideration Draft 1.9 rev 1" where
* PD stands for proximity detection
+ * @ftm.type.nan_support: supports NAN ranging as defined in
+ * the "Wi-Fi Aware Specification v4.0, clause 8". NAN ranging always uses
+ * ASAP and a single burst, regardless of @ftm.asap.
* @ftm.concurrent_ista_rsta_support: indicates if the device can
* simultaneously act as initiator and responder in a multi-peer
* measurement request. Only valid if @ftm.rsta_support is set.
@@ -6364,7 +6367,8 @@ struct cfg80211_pmsr_capabilities {
u32 min_allowed_ranging_interval_ntb;
struct {
u8 infra_support:1,
- pd_support:1;
+ pd_support:1,
+ nan_support:1;
} type;
u8 concurrent_ista_rsta_support:1;
u32 pd_preambles;
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index c30dcba96763..b982cb29f89e 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -8535,6 +8535,11 @@ enum nl80211_peer_measurement_ftm_capa {
* the device supports peer-to-peer ranging as mentioned in the
* specification "PR Implementation Consideration Draft 1.9 rev 1" where
* PD stands for proximity detection
+ * @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT: flag attribute indicating
+ * that the device supports NAN ranging between two NAN devices as
+ * defined in the "Wi-Fi Aware Specification v4.0, clause 8". NAN ranging
+ * uses ASAP and a single burst, irrespective of whether
+ * %NL80211_PMSR_FTM_CAPA_ATTR_ASAP is advertised.
*
* @NUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR: internal
* @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_MAX: highest attribute number
@@ -8544,6 +8549,7 @@ enum nl80211_peer_measurement_ftm_type_capa {
NL80211_PMSR_FTM_TYPE_CAPA_ATTR_INFRA_SUPPORT,
NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT,
+ NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT,
/* keep last */
NUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 3375aea01e0c..1bb2782b6206 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -2793,7 +2793,8 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,
cap->ftm.min_allowed_ranging_interval_ntb))
return -ENOBUFS;
- if (cap->ftm.type.infra_support || cap->ftm.type.pd_support) {
+ if (cap->ftm.type.infra_support || cap->ftm.type.pd_support ||
+ cap->ftm.type.nan_support) {
struct nlattr *pd_caps;
pd_caps = nla_nest_start_noflag(msg,
@@ -2809,6 +2810,10 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,
nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT))
return -ENOBUFS;
+ if (cap->ftm.type.nan_support &&
+ nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT))
+ return -ENOBUFS;
+
nla_nest_end(msg, pd_caps);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 05/19] wifi: nl80211/cfg80211: advertise NAN ranging support
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (3 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 04/19] wifi: nl80211/cfg80211: add NAN ranging FTM capability Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 06/19] wifi: nl80211/cfg80211: add support for request-based NAN ranging Shivani Baranwal
` (14 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
From: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Add NL80211_NAN_CAPA_OFFLOAD_RANGING so userspace (e.g., wpa_supplicant)
can determine whether firmware supports fully offloaded NAN ranging
before starting a NAN ranging session.
Add WIPHY_NAN_FLAGS_OFFLOAD_RANGING for drivers to report this
capability and expose it through the NAN capabilities handler.
Fully offloaded NAN ranging includes ranging session setup, update,
and termination, FTM protocol and procedure, and ranging report.
Signed-off-by: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 4 ++++
include/uapi/linux/nl80211.h | 4 ++++
net/wireless/nl80211.c | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index db175abf9a24..b4a1aadf3639 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -6451,11 +6451,15 @@ struct wiphy_radio {
* @WIPHY_NAN_FLAGS_USERSPACE_DE: Device doesn't support DE offload.
* @WIPHY_NAN_FLAGS_INSTANT_COMM: Device can switch to Instant Communication
* (IC) mode. Can only be set along with %WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC.
+ * @WIPHY_NAN_FLAGS_OFFLOAD_RANGING: Firmware supports fully offloaded NAN
+ * ranging procedure, including ranging session setup, update, and
+ * termination, FTM protocol and procedure, and ranging report.
*/
enum wiphy_nan_flags {
WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),
WIPHY_NAN_FLAGS_USERSPACE_DE = BIT(1),
WIPHY_NAN_FLAGS_INSTANT_COMM = BIT(2),
+ WIPHY_NAN_FLAGS_OFFLOAD_RANGING = BIT(3),
};
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index b982cb29f89e..baca5b0cb8ca 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -9297,6 +9297,9 @@ enum nl80211_s1g_short_beacon_attrs {
* of the Wi-Fi Aware Specification v4.0. Can only be set if
* %NL80211_NAN_CAPA_CONFIGURABLE_SYNC is set. When IC is enabled, the IC
* schedule is expected to be configured by user space.
+ * @NL80211_NAN_CAPA_OFFLOAD_RANGING: flag attribute. Firmware supports the
+ * fully offloaded NAN ranging procedure, including ranging session setup,
+ * update, and termination, FTM protocol and procedure, and ranging reports.
* @__NL80211_NAN_CAPABILITIES_LAST: Internal
* @NL80211_NAN_CAPABILITIES_MAX: Highest NAN capability attribute.
*/
@@ -9311,6 +9314,7 @@ enum nl80211_nan_capabilities {
NL80211_NAN_CAPA_CAPABILITIES,
NL80211_NAN_CAPA_PHY,
NL80211_NAN_CAPA_INSTANT_COMM,
+ NL80211_NAN_CAPA_OFFLOAD_RANGING,
/* keep last */
__NL80211_NAN_CAPABILITIES_LAST,
NL80211_NAN_CAPABILITIES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 1bb2782b6206..ab8ec24093ac 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3206,6 +3206,10 @@ static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)
nla_put_flag(msg, NL80211_NAN_CAPA_INSTANT_COMM))
goto fail;
+ if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_RANGING) &&
+ nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))
+ goto fail;
+
if (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE,
wiphy->nan_capa.op_mode) ||
nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 06/19] wifi: nl80211/cfg80211: add support for request-based NAN ranging
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (4 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 05/19] wifi: nl80211/cfg80211: advertise NAN ranging support Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 07/19] wifi: nl80211/cfg80211: add support for discovery-based " Shivani Baranwal
` (13 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
From: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Extend the peer measurement framework with a NAN FTM request type
to allow userspace (e.g., wpa_supplicant) to initiate a NAN Ranging
Request in offload mode.
Extend the nl80211 parser to handle NAN-specific FTM parameters and
validate the request type so the driver/firmware can identify and
trigger the NAN Ranging Session on behalf of userspace. Reject the
request if it is a NAN Ranging Request and the interface is not a
NAN interface, as mandated by the Wi-Fi Aware Specification, or if
the driver does not advertise NAN ranging capability.
Treat ASAP and single burst as inherent to NAN ranging. Userspace need
not request generic ASAP mode, and NUM_BURSTS_EXP must be zero if set.
Signed-off-by: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 10 +++-
include/uapi/linux/nl80211.h | 13 +++++
net/wireless/nl80211.c | 5 +-
net/wireless/nl80211.h | 3 +
net/wireless/pmsr.c | 110 ++++++++++++++++++++++++++++++++++-
5 files changed, 138 insertions(+), 3 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b4a1aadf3639..084e23d2391a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4775,6 +4775,8 @@ struct cfg80211_pmsr_result {
* @trigger_based or @non_trigger_based is set.
* @rsta: Operate as the RSTA in the measurement. Only valid if @lmr_feedback
* and either @trigger_based or @non_trigger_based is set.
+ * Also valid when @range_report is set and @request_type is
+ * %NL80211_PMSR_FTM_REQ_TYPE_NAN.
* @bss_color: the bss color of the responder. Optional. Set to zero to
* indicate the driver should set the BSS color. Only valid if
* @non_trigger_based or @trigger_based is set.
@@ -4820,6 +4822,10 @@ struct cfg80211_pmsr_result {
* provide ranging services to a peer (e.g. in RSTA role) but does
* not report the measurement results to userspace. Only valid when
* @request_type is %NL80211_PMSR_FTM_REQ_TYPE_PD.
+ * @range_report: a NAN Ranging Report is required after the FTM session.
+ * Only valid for a NAN RSTA request.
+ * @min_delta_ftm: NAN Min Delta FTM value in units of 100 microseconds.
+ * Zero indicates no preference.
*
* See also nl80211 for the respective attribute documentation.
*/
@@ -4836,6 +4842,7 @@ struct cfg80211_pmsr_ftm_request_peer {
rsta:1;
u8 num_bursts_exp;
u8 burst_duration;
+ u8 min_delta_ftm;
u8 ftms_per_burst;
u8 ftmr_retries;
u8 bss_color;
@@ -4848,7 +4855,8 @@ struct cfg80211_pmsr_ftm_request_peer {
u32 num_measurements;
u64 ingress_distance;
u64 egress_distance;
- u8 pd_suppress_range_results:1;
+ u8 pd_suppress_range_results:1,
+ range_report:1;
};
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index baca5b0cb8ca..849e6c19d122 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -8281,12 +8281,18 @@ enum nl80211_peer_measurement_resp {
* @NL80211_PMSR_FTM_REQ_TYPE_PD: peer-to-peer ranging as defined in the
* Wi-Fi Alliance specification "Proximity Ranging (PR) Implementation
* Consideration Draft 1.9 Rev 1"
+ * @NL80211_PMSR_FTM_REQ_TYPE_NAN: NAN ranging between two NAN devices as
+ * defined in the "Wi-Fi Aware Specification v4.0, clause 8".
+ * Must be issued on a %NL80211_IFTYPE_NAN interface.
+ * ASAP mode and a single burst are implied. If
+ * %NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP is present, it must be zero.
* @NUM_NL80211_PMSR_FTM_REQ_TYPE: internal
* @NL80211_PMSR_FTM_REQ_TYPE_MAX: highest request type value
*/
enum nl80211_peer_measurement_ftm_req_type {
NL80211_PMSR_FTM_REQ_TYPE_INFRA,
NL80211_PMSR_FTM_REQ_TYPE_PD,
+ NL80211_PMSR_FTM_REQ_TYPE_NAN,
/* keep last */
NUM_NL80211_PMSR_FTM_REQ_TYPE,
@@ -8656,6 +8662,11 @@ enum nl80211_peer_measurement_ftm_type_capa {
* but results are not reported to userspace, regardless of ranging role
* or type. Only valid when %NL80211_PMSR_PEER_ATTR_REQ_TYPE is set to
* %NL80211_PMSR_FTM_REQ_TYPE_PD.
+ * @NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT: Flag indicating that a NAN
+ * Ranging Report is required after the FTM session. Only valid for a NAN
+ * RSTA request.
+ * @NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM: NAN Min Delta FTM value in units
+ * of 100 microseconds (u8, 0-63). A value of 0 indicates no preference.
*
* @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal
* @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number
@@ -8686,6 +8697,8 @@ enum nl80211_peer_measurement_ftm_req {
NL80211_PMSR_FTM_REQ_ATTR_INGRESS,
NL80211_PMSR_FTM_REQ_ATTR_EGRESS,
NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS,
+ NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT,
+ NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM,
/* keep last */
NUM_NL80211_PMSR_FTM_REQ_ATTR,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index ab8ec24093ac..eb5ca1d1aff0 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -604,7 +604,7 @@ nl80211_ftm_responder_policy[NL80211_FTM_RESP_ATTR_MAX + 1] = {
.len = U8_MAX },
};
-static const struct nla_policy
+const struct nla_policy
nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
[NL80211_PMSR_FTM_REQ_ATTR_ASAP] = { .type = NLA_FLAG },
[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE] =
@@ -636,6 +636,9 @@ nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
[NL80211_PMSR_FTM_REQ_ATTR_INGRESS] = { .type = NLA_U64 },
[NL80211_PMSR_FTM_REQ_ATTR_EGRESS] = { .type = NLA_U64 },
[NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS] = { .type = NLA_FLAG },
+ [NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT] = { .type = NLA_FLAG },
+ [NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM] =
+ NLA_POLICY_MAX(NLA_U8, 63),
};
static const struct nla_policy
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index 1e75b38ad88d..98454b91fa9a 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -126,6 +126,9 @@ void cfg80211_free_coalesce(struct cfg80211_coalesce *coalesce);
/* peer measurement */
int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info);
+extern const struct nla_policy
+nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];
+
void nl80211_mlo_reconf_add_done(struct net_device *dev,
struct cfg80211_mlo_reconf_done_data *data);
diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c
index 97449bcb9a22..d1e59042f10b 100644
--- a/net/wireless/pmsr.c
+++ b/net/wireless/pmsr.c
@@ -306,11 +306,98 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev,
return 0;
}
+static int pmsr_parse_ftm_nan(struct cfg80211_registered_device *rdev,
+ struct nlattr *ftmreq,
+ struct cfg80211_pmsr_request_peer *out,
+ struct genl_info *info)
+{
+ const struct cfg80211_pmsr_capabilities *capa = rdev->wiphy.pmsr_capa;
+ struct nlattr *tb[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];
+ int err;
+
+ err = nla_parse_nested(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq,
+ nl80211_pmsr_ftm_req_attr_policy,
+ info->extack);
+ if (err)
+ return err;
+
+ out->ftm.requested = true;
+
+ /* NAN ranging always uses ASAP */
+ out->ftm.asap = true;
+
+ /* NAN ranging always uses a single burst */
+ if (tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP] &&
+ nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP]) != 0) {
+ NL_SET_ERR_MSG(info->extack,
+ "FTM: NAN ranging requires single burst");
+ return -EINVAL;
+ }
+
+ out->ftm.rsta = !!tb[NL80211_PMSR_FTM_REQ_ATTR_RSTA];
+ out->ftm.range_report =
+ !!tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT];
+ if (out->ftm.range_report && !out->ftm.rsta) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT],
+ "FTM: range report is valid only for NAN RSTA");
+ return -EINVAL;
+ }
+
+ if (tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]) {
+ out->ftm.preamble =
+ nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]);
+ if (!(capa->ftm.preambles & BIT(out->ftm.preamble))) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE],
+ "FTM: unsupported preamble for NAN ranging");
+ return -EINVAL;
+ }
+ }
+
+ if (tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]) {
+ out->ftm.ftms_per_burst =
+ nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]);
+ if (out->ftm.ftms_per_burst > 31) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],
+ "FTM: NAN FTMs per burst exceeds limit of 31");
+ return -EINVAL;
+ }
+ if (capa->ftm.max_ftms_per_burst &&
+ out->ftm.ftms_per_burst > capa->ftm.max_ftms_per_burst) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],
+ "FTM: FTMs per burst exceeds device limit");
+ return -EINVAL;
+ }
+ }
+
+ if (tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION])
+ out->ftm.burst_duration =
+ nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION]);
+
+ if (tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM])
+ out->ftm.min_delta_ftm =
+ nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM]);
+
+ if (tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS])
+ out->ftm.ingress_distance =
+ nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS]);
+
+ if (tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS])
+ out->ftm.egress_distance =
+ nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS]);
+
+ return 0;
+}
+
static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
struct nlattr *peer,
struct cfg80211_pmsr_request_peer *out,
struct genl_info *info)
{
+ struct wireless_dev *wdev = info->user_ptr[1];
struct nlattr *tb[NL80211_PMSR_PEER_ATTR_MAX + 1];
struct nlattr *req[NL80211_PMSR_REQ_ATTR_MAX + 1];
bool have_measurement_type = false;
@@ -344,6 +431,22 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
"FTM: PD request type not supported by device");
return -EINVAL;
}
+
+ if (out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_NAN) {
+ if (!rdev->wiphy.pmsr_capa->ftm.type.nan_support) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],
+ "FTM: NAN ranging not supported by device");
+ return -EOPNOTSUPP;
+ }
+ if (wdev->iftype != NL80211_IFTYPE_NAN) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],
+ "FTM: NAN ranging requires a NAN interface");
+ return -EOPNOTSUPP;
+ }
+ }
+
/* reuse info->attrs */
memset(info->attrs, 0, sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));
err = nla_parse_nested_deprecated(info->attrs, NL80211_ATTR_MAX,
@@ -390,7 +493,12 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
switch (nla_type(treq)) {
case NL80211_PMSR_TYPE_FTM:
- err = pmsr_parse_ftm(rdev, treq, out, info);
+ if (out->ftm.request_type ==
+ NL80211_PMSR_FTM_REQ_TYPE_NAN)
+ err = pmsr_parse_ftm_nan(rdev, treq,
+ out, info);
+ else
+ err = pmsr_parse_ftm(rdev, treq, out, info);
break;
default:
NL_SET_ERR_MSG_ATTR(info->extack, treq,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 07/19] wifi: nl80211/cfg80211: add support for discovery-based NAN ranging
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (5 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 06/19] wifi: nl80211/cfg80211: add support for request-based NAN ranging Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 08/19] wifi: nl80211/cfg80211: add ranging results to NAN match event Shivani Baranwal
` (12 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
From: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Extend the NAN function configuration with ranging parameters such as
the ranging interval, geofence thresholds, FTM parameters, channel, and
range report request. Add the RANGING_REQUIRED flag to express the SDEA
ranging intent for the service.
Require the device to advertise NAN ranging offload and NAN FTM support
when RANGING_REQUIRED is set. Reject ranging parameters without that
flag so the driver and firmware receive an unambiguous ranging request.
Signed-off-by: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 23 ++++++++
include/uapi/linux/nl80211.h | 25 +++++++++
net/wireless/nl80211.c | 101 +++++++++++++++++++++++++++++++++++
3 files changed, 149 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 084e23d2391a..6bb840a1aef3 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4457,6 +4457,20 @@ struct cfg80211_nan_func_filter {
* @num_csids: number of entries in @csids.
* @nd_pmk: pointer to the pre-shared NAN Data Path PMK (ND-PMK).
* @nd_pmk_len: length of @nd_pmk in bytes; depends on the cipher suite.
+ * @ranging_required: if true, the SDEA Ranging Required bit is set.
+ * @ranging_interval: interval in milliseconds between two consecutive
+ * ranging measurements, or 0 if not specified.
+ * @ingress_distance: inner geofence threshold in millimetres, or 0 if
+ * not specified.
+ * @egress_distance: outer geofence threshold in millimetres, or 0 if
+ * not specified.
+ * @ftms_per_burst: number of FTM frames per burst, or 0 if not specified.
+ * @preamble: PHY preamble for FTM frames, see &enum nl80211_preamble,
+ * or %NL80211_PREAMBLE_LEGACY if not specified.
+ * @chandef_valid: if true, @chandef is valid.
+ * @chandef: channel definition for FTM ranging.
+ * @range_report: if true, a NAN Ranging Report is required after the FTM
+ * session.
*/
struct cfg80211_nan_func {
enum nl80211_nan_function_type type;
@@ -4491,6 +4505,15 @@ struct cfg80211_nan_func {
u8 num_csids;
const u8 *nd_pmk;
u8 nd_pmk_len;
+ bool ranging_required;
+ u32 ranging_interval;
+ u32 ingress_distance;
+ u32 egress_distance;
+ u8 ftms_per_burst;
+ enum nl80211_preamble preamble;
+ bool chandef_valid;
+ struct cfg80211_chan_def chandef;
+ bool range_report;
};
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 849e6c19d122..eed7b015bb20 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -7873,6 +7873,23 @@ enum nl80211_nan_func_term_reason {
* %NL80211_EXT_FEATURE_SECURE_NAN.
* @NL80211_NAN_FUNC_ND_PMK: pre-shared NAN Data Path PMK (ND-PMK); its length
* depends on the cipher suite. Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_RANGING_REQUIRED: flag attribute. Sets the SDEA "Ranging
+ * Required" bit. Requires %NL80211_NAN_CAPA_OFFLOAD_RANGING and NAN FTM
+ * support, indicated by %NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT.
+ * @NL80211_NAN_FUNC_RANGING_INTERVAL: u32 attribute. Interval in
+ * milliseconds between two consecutive ranging measurements.
+ * @NL80211_NAN_FUNC_INGRESS_DISTANCE: u32 attribute. Inner geofence
+ * threshold in millimetres.
+ * @NL80211_NAN_FUNC_EGRESS_DISTANCE: u32 attribute. Outer geofence
+ * threshold in millimetres.
+ * @NL80211_NAN_FUNC_FTMS_PER_BURST: u8 attribute. Number of FTM
+ * frames per burst.
+ * @NL80211_NAN_FUNC_PREAMBLE: u32 attribute. PHY preamble type for
+ * FTM frames (see &enum nl80211_preamble).
+ * @NL80211_NAN_FUNC_CHAN: channel definition for FTM ranging, nested,
+ * using top-level attributes like %NL80211_ATTR_WIPHY_FREQ etc.
+ * @NL80211_NAN_FUNC_RANGE_REPORT: flag indicating that a NAN Ranging
+ * Report is required after the FTM session.
*
* @NUM_NL80211_NAN_FUNC_ATTR: internal
* @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute
@@ -7901,6 +7918,14 @@ enum nl80211_nan_func_attributes {
NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS,
NL80211_NAN_FUNC_CSIDS,
NL80211_NAN_FUNC_ND_PMK,
+ NL80211_NAN_FUNC_RANGING_REQUIRED,
+ NL80211_NAN_FUNC_RANGING_INTERVAL,
+ NL80211_NAN_FUNC_INGRESS_DISTANCE,
+ NL80211_NAN_FUNC_EGRESS_DISTANCE,
+ NL80211_NAN_FUNC_FTMS_PER_BURST,
+ NL80211_NAN_FUNC_PREAMBLE,
+ NL80211_NAN_FUNC_CHAN,
+ NL80211_NAN_FUNC_RANGE_REPORT,
/* keep last */
NUM_NL80211_NAN_FUNC_ATTR,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index eb5ca1d1aff0..7b55a34a733f 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1396,6 +1396,16 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = {
[NL80211_NAN_FUNC_ND_PMK] =
NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_nan_pmk,
WLAN_PMK_LEN_SUITE_B_192),
+ [NL80211_NAN_FUNC_RANGING_REQUIRED] = { .type = NLA_FLAG },
+ [NL80211_NAN_FUNC_RANGING_INTERVAL] = { .type = NLA_U32 },
+ [NL80211_NAN_FUNC_INGRESS_DISTANCE] = { .type = NLA_U32 },
+ [NL80211_NAN_FUNC_EGRESS_DISTANCE] = { .type = NLA_U32 },
+ [NL80211_NAN_FUNC_FTMS_PER_BURST] = NLA_POLICY_MAX(NLA_U8, 31),
+ [NL80211_NAN_FUNC_PREAMBLE] =
+ NLA_POLICY_RANGE(NLA_U32, NL80211_PREAMBLE_LEGACY,
+ NL80211_PREAMBLE_HE),
+ [NL80211_NAN_FUNC_CHAN] = NLA_POLICY_NESTED(nl80211_policy),
+ [NL80211_NAN_FUNC_RANGE_REPORT] = { .type = NLA_FLAG },
};
/* policy for Service Response Filter attributes */
@@ -17727,6 +17737,97 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
}
}
+ func->ranging_required =
+ nla_get_flag(tb[NL80211_NAN_FUNC_RANGING_REQUIRED]);
+
+ if (!func->ranging_required &&
+ (tb[NL80211_NAN_FUNC_RANGING_INTERVAL] ||
+ tb[NL80211_NAN_FUNC_INGRESS_DISTANCE] ||
+ tb[NL80211_NAN_FUNC_EGRESS_DISTANCE] ||
+ tb[NL80211_NAN_FUNC_FTMS_PER_BURST] ||
+ tb[NL80211_NAN_FUNC_PREAMBLE] ||
+ tb[NL80211_NAN_FUNC_CHAN] ||
+ tb[NL80211_NAN_FUNC_RANGE_REPORT])) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN ranging parameters require RANGING_REQUIRED");
+ err = -EINVAL;
+ goto out;
+ }
+
+ if (func->ranging_required) {
+ const struct cfg80211_pmsr_capabilities *pmsr_capa =
+ rdev->wiphy.pmsr_capa;
+
+ if (!(wdev->wiphy->nan_capa.flags &
+ WIPHY_NAN_FLAGS_OFFLOAD_RANGING) ||
+ !pmsr_capa || !pmsr_capa->ftm.supported ||
+ !pmsr_capa->ftm.type.nan_support) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN ranging not supported by device");
+ err = -EOPNOTSUPP;
+ goto out;
+ }
+
+ if (tb[NL80211_NAN_FUNC_RANGING_INTERVAL])
+ func->ranging_interval =
+ nla_get_u32(tb[NL80211_NAN_FUNC_RANGING_INTERVAL]);
+
+ if (tb[NL80211_NAN_FUNC_INGRESS_DISTANCE])
+ func->ingress_distance =
+ nla_get_u32(tb[NL80211_NAN_FUNC_INGRESS_DISTANCE]);
+
+ if (tb[NL80211_NAN_FUNC_EGRESS_DISTANCE])
+ func->egress_distance =
+ nla_get_u32(tb[NL80211_NAN_FUNC_EGRESS_DISTANCE]);
+
+ if (tb[NL80211_NAN_FUNC_FTMS_PER_BURST]) {
+ func->ftms_per_burst =
+ nla_get_u8(tb[NL80211_NAN_FUNC_FTMS_PER_BURST]);
+ if (pmsr_capa->ftm.max_ftms_per_burst &&
+ func->ftms_per_burst > pmsr_capa->ftm.max_ftms_per_burst) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_FUNC_FTMS_PER_BURST],
+ "NAN FTMs per burst exceeds device limit");
+ err = -EINVAL;
+ goto out;
+ }
+ }
+
+ if (tb[NL80211_NAN_FUNC_PREAMBLE]) {
+ func->preamble =
+ nla_get_u32(tb[NL80211_NAN_FUNC_PREAMBLE]);
+ if (!(pmsr_capa->ftm.preambles & BIT(func->preamble))) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_FUNC_PREAMBLE],
+ "NAN ranging: unsupported preamble");
+ err = -EINVAL;
+ goto out;
+ }
+ }
+
+ if (tb[NL80211_NAN_FUNC_CHAN]) {
+ /* Reuse info->attrs for chandef parsing; the original contents
+ * are no longer needed.
+ */
+ memset(info->attrs, 0,
+ sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));
+ err = nla_parse_nested(info->attrs, NL80211_ATTR_MAX,
+ tb[NL80211_NAN_FUNC_CHAN],
+ nl80211_policy, info->extack);
+ if (err)
+ goto out;
+ err = nl80211_parse_chandef(rdev, info->extack,
+ info->attrs,
+ &func->chandef, false);
+ if (err)
+ goto out;
+ func->chandef_valid = true;
+ }
+
+ func->range_report =
+ nla_get_flag(tb[NL80211_NAN_FUNC_RANGE_REPORT]);
+ }
+
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg) {
err = -ENOMEM;
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 08/19] wifi: nl80211/cfg80211: add ranging results to NAN match event
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (6 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 07/19] wifi: nl80211/cfg80211: add support for discovery-based " Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 09/19] wifi: nl80211: add NDP offload capability advertisement Shivani Baranwal
` (11 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
From: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Extend cfg80211_nan_match_params with ranging_indication and
ranging_measurement fields to allow the driver/firmware to report
NAN Ranging results as part of the NAN Service Match indication
in offload mode.
Add the corresponding attributes NL80211_NAN_MATCH_RANGING_INDICATION
and NL80211_NAN_MATCH_RANGING_MEASUREMENT and serialize them in
cfg80211_nan_match() so that userspace (e.g., wpa_supplicant) can
receive the NAN Ranging Report along with the NAN Service Match event.
Send ranging info to userspace only if ranging_indication is non-zero.
ranging_indication is a bitmask with four valid combinations:
- bit 0 set: continuous ranging
- bit 1 set: ingress condition met
- bit 2 set: egress condition met
- bit 1 and bit 2 set: both ingress and egress conditions met
Leave validation of the combination to userspace (e.g., wpa_supplicant).
Signed-off-by: Kavita Kavita <kavita.kavita@oss.qualcomm.com>
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 4 ++++
include/uapi/linux/nl80211.h | 8 ++++++++
net/wireless/nl80211.c | 11 +++++++++++
3 files changed, 23 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 6bb840a1aef3..9acb657a824e 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -10770,6 +10770,8 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
* Only valid when @rssi_valid is true.
* @rssi_valid: if true, @rssi contains a valid RSSI measurement.
* @cookie: unique identifier of the corresponding function
+ * @ranging_indication: bitmap indicating the type of ranging performed.
+ * @ranging_measurement: distance to the peer in millimetres.
*/
struct cfg80211_nan_match_params {
enum nl80211_nan_function_type type;
@@ -10784,6 +10786,8 @@ struct cfg80211_nan_match_params {
s32 rssi;
bool rssi_valid;
u64 cookie;
+ u8 ranging_indication;
+ s32 ranging_measurement;
};
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index eed7b015bb20..23d19a6e8d81 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -7968,6 +7968,12 @@ enum nl80211_nan_srf_attributes {
* @NL80211_NAN_MATCH_FUNC_PEER: the peer function
* that caused the match. This is a nested attribute.
* See &enum nl80211_nan_func_attributes.
+ * @NL80211_NAN_MATCH_RANGING_INDICATION: u8 attribute. Bitmap indicating
+ * the type of ranging performed: bit 0: continuous ranging,
+ * bit 1: ingress condition met, bit 2: egress condition met,
+ * bit 1 and bit 2: both conditions met. Only present when non-zero.
+ * @NL80211_NAN_MATCH_RANGING_MEASUREMENT: s32 attribute. Distance to
+ * the peer in millimetres measured via FTM.
*
* @NUM_NL80211_NAN_MATCH_ATTR: internal
* @NL80211_NAN_MATCH_ATTR_MAX: highest NAN match attribute
@@ -7976,6 +7982,8 @@ enum nl80211_nan_match_attributes {
__NL80211_NAN_MATCH_INVALID,
NL80211_NAN_MATCH_FUNC_LOCAL,
NL80211_NAN_MATCH_FUNC_PEER,
+ NL80211_NAN_MATCH_RANGING_INDICATION,
+ NL80211_NAN_MATCH_RANGING_MEASUREMENT,
/* keep last */
NUM_NL80211_NAN_MATCH_ATTR,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 7b55a34a733f..8d4e98fcedab 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -18042,6 +18042,17 @@ void cfg80211_nan_match(struct wireless_dev *wdev,
goto nla_put_failure;
nla_nest_end(msg, peer_func_attr);
+
+ /* report ranging info only if ranging was indicated */
+ if (match->ranging_indication) {
+ if (nla_put_u8(msg, NL80211_NAN_MATCH_RANGING_INDICATION,
+ match->ranging_indication))
+ goto nla_put_failure;
+
+ if (nla_put_s32(msg, NL80211_NAN_MATCH_RANGING_MEASUREMENT,
+ match->ranging_measurement))
+ goto nla_put_failure;
+ }
nla_nest_end(msg, match_attr);
genlmsg_end(msg, hdr);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 09/19] wifi: nl80211: add NDP offload capability advertisement
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (7 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 08/19] wifi: nl80211/cfg80211: add ranging results to NAN match event Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 10/19] wifi: nl80211/cfg80211: add support for NDP initiation in offload mode Shivani Baranwal
` (10 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Advertise whether a device performs the complete NAN Data Path setup and
teardown handshake with its peer, including security negotiation. The
device assigns NDP IDs for locally initiated sessions, manages NDI peer
stations, and derives, installs, and removes PTKs and, when requested,
the GTK.
An offloaded device negotiates NDLs for its NDPs within the local NAN
schedule configured by userspace. This includes NDC and immutable
schedules and their updates, while honoring per-NDP QoS requirements.
Userspace continues to configure the local schedule and non-evacuable
channels. The device manages peer schedules, so reject only
NL80211_CMD_NAN_SET_PEER_SCHED for devices with this capability.
Expose the capability through the NAN capabilities response so userspace
can determine whether the device supports the NAN NDP commands and
notifications. Secure NDPs additionally require SECURE_NAN.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 36 +++++++++++++++++++++++++++++--
include/uapi/linux/nl80211.h | 41 +++++++++++++++++++++++++++++++++---
net/wireless/nl80211.c | 10 +++++++++
3 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9acb657a824e..b1289d5fcd93 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5354,7 +5354,8 @@ struct mgmt_frame_regs {
* in which each entry maps each time slot to the channel on which the
* radio should operate on. If the chandef of a NAN channel is not
* changed, the channel entry must also remain unchanged. It is the
- * driver's responsibility to verify this.
+ * driver's responsibility to verify this. For offloaded NDPs, the device
+ * negotiates each NDL within this user-configured local schedule.
* @nan_set_peer_sched: configure the peer schedule for NAN. The schedule
* consists of an array of %cfg80211_nan_channel and the schedule itself,
* in which each entry maps each time slot to a channel on which the
@@ -5362,12 +5363,16 @@ struct mgmt_frame_regs {
* information such as committed DW, etc. When updating an existing peer
* schedule, the full new schedule is provided - partial updates are not
* supported, and the new schedule completely replaces the previous one.
+ * Not supported when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set; the device learns
+ * and manages peer schedules for offloaded NDPs.
*
* @nan_set_non_evac_channels: set the list of local schedule channels that
* must not be evacuated for concurrent operations. The provided list
* replaces the previous set; channels of the current schedule that are
* not included become evacuable again. All provided channels are
- * guaranteed by cfg80211 to belong to the current local schedule.
+ * guaranteed by cfg80211 to belong to the current local schedule. For
+ * offloaded NDPs, userspace configures these channels for the device to
+ * consider while negotiating NDL schedules.
*
* @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
*
@@ -6485,12 +6490,39 @@ struct wiphy_radio {
* @WIPHY_NAN_FLAGS_OFFLOAD_RANGING: Firmware supports fully offloaded NAN
* ranging procedure, including ranging session setup, update, and
* termination, FTM protocol and procedure, and ranging report.
+ * @WIPHY_NAN_FLAGS_OFFLOAD_NDP: Device offloads the complete NDP setup and
+ * teardown handshake with its peer, including NDP Request/Response/Confirm
+ * and security handshakes. Within the local NAN schedule configured by
+ * userspace, the device negotiates NDLs for offloaded NDPs, including NDC,
+ * immutable schedules, and schedule updates, honoring NDP QoS requirements.
+ * Userspace continues to configure the local schedule with
+ * %NL80211_CMD_NAN_SET_LOCAL_SCHED and its non-evacuable channels with
+ * %NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS. The device learns and manages peer
+ * NAN schedules; userspace must not set them with
+ * %NL80211_CMD_NAN_SET_PEER_SCHED. The device assigns NDP IDs for locally
+ * initiated NDPs, derives, installs, and removes PTKs and, when requested,
+ * GTKs. The device creates and removes NDI peer stations for offloaded NDPs.
+ * Userspace must not add those NDI peer stations or their
+ * keys. NDP offload is supported on all bands in
+ * &struct wiphy.nan_supported_bands. The device supplies the band-specific
+ * capabilities, such as the HE 6 GHz band and EHT capabilities, and the
+ * regulatory information in the frames it builds. The driver implements
+ * @nan_ndp_initiate,
+ * @nan_ndp_respond, and
+ * @nan_ndp_terminate callbacks. It supports
+ * %NL80211_CMD_NAN_NDP_INITIATE, %NL80211_CMD_NAN_NDP_RESPOND, and
+ * %NL80211_CMD_NAN_NDP_TERMINATE, and
+ * reports peer requests, setup status, and termination with
+ * cfg80211_nan_ndp_request(), cfg80211_nan_ndp_status(), and
+ * cfg80211_nan_ndp_terminated(). Secure NDPs require
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
*/
enum wiphy_nan_flags {
WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),
WIPHY_NAN_FLAGS_USERSPACE_DE = BIT(1),
WIPHY_NAN_FLAGS_INSTANT_COMM = BIT(2),
WIPHY_NAN_FLAGS_OFFLOAD_RANGING = BIT(3),
+ WIPHY_NAN_FLAGS_OFFLOAD_NDP = BIT(4),
};
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 23d19a6e8d81..f22ad0a018a7 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -455,7 +455,9 @@
* %NL80211_ATTR_KEY_IDX, %NL80211_ATTR_MAC, %NL80211_ATTR_KEY_CIPHER,
* and %NL80211_ATTR_KEY_SEQ attributes. %NL80211_ATTR_MAC represents
* peer's MLD address for MLO pairwise key. The link to add MLO
- * group key is identified by %NL80211_ATTR_MLO_LINK_ID.
+ * group key is identified by %NL80211_ATTR_MLO_LINK_ID. For an NDI peer
+ * station participating in an offloaded NDP, userspace must not add keys;
+ * the device manages the NDP keys.
* @NL80211_CMD_DEL_KEY: delete a key identified by %NL80211_ATTR_KEY_IDX
* or %NL80211_ATTR_MAC. %NL80211_ATTR_MAC represents peer's MLD address
* for MLO pairwise key. The link to delete group key is identified by
@@ -488,7 +490,9 @@
* @NL80211_CMD_SET_STATION: Set station attributes for station identified by
* %NL80211_ATTR_MAC on the interface identified by %NL80211_ATTR_IFINDEX.
* @NL80211_CMD_NEW_STATION: Add a station with given attributes to the
- * interface identified by %NL80211_ATTR_IFINDEX.
+ * interface identified by %NL80211_ATTR_IFINDEX. For an offloaded NDP,
+ * the device creates and removes the NDI peer station; userspace must not
+ * add a duplicate station.
* @NL80211_CMD_DEL_STATION: Remove a station identified by %NL80211_ATTR_MAC
* or, if no MAC address given, all stations, on the interface identified
* by %NL80211_ATTR_IFINDEX. For MLD station, MLD address is used in
@@ -1454,6 +1458,8 @@
* channels that remain in the new schedule keep their marking, channels
* that are removed simply lose it, and newly added channels are
* evacuable by default.
+ * For offloaded NDPs, the device negotiates NDL schedules within this
+ * user-configured local schedule.
* @NL80211_CMD_NAN_SCHED_UPDATE_DONE: Event sent to user space to notify that
* a deferred local NAN schedule update (requested with
* %NL80211_CMD_NAN_SET_LOCAL_SCHED and %NL80211_ATTR_NAN_SCHED_DEFERRED)
@@ -1461,6 +1467,8 @@
* indicates that the update was successful.
* @NL80211_CMD_NAN_SET_PEER_SCHED: Set the peer NAN schedule. NAN
* must be operational (%NL80211_CMD_START_NAN was executed).
+ * Not supported when %NL80211_NAN_CAPA_OFFLOAD_NDP is advertised; the
+ * device learns and manages peer schedules for offloaded NDPs.
* Required attributes: %NL80211_ATTR_MAC (peer NMI address) and
* %NL80211_ATTR_NAN_COMMITTED_DW.
* Optionally, the full schedule can be provided by including all of:
@@ -1522,6 +1530,8 @@
* keep their non-evacuable marking, removed channels lose it, and newly
* added channels are evacuable by default; issue this command again to
* change the non-evacuable set.
+ * For offloaded NDPs, userspace configures non-evacuable channels for the
+ * device to consider while negotiating NDL schedules.
* @NL80211_CMD_UPDATE_BEACON: Update the beacon and other templates of an AP
* interface, but only that. Same attributes as %NL80211_CMD_SET_BEACON,
* %NL80211_ATTR_BEACON_HEAD and %NL80211_ATTR_BEACON_TAIL are required,
@@ -3272,7 +3282,8 @@ enum nl80211_commands {
* the update failed.
* @NL80211_ATTR_NAN_NMI_MAC: The address of the NMI station to which this NDI
* station belongs. Used with %NL80211_CMD_NEW_STATION when adding an NDI
- * station.
+ * station. With %NL80211_NAN_CAPA_OFFLOAD_NDP, the device creates and removes
+ * NDI peer stations for offloaded NDPs; userspace must not add duplicates.
* @NL80211_ATTR_NAN_ULW: (Binary) The initial ULW(s) as published by the
* peer, as defined in the Wi-Fi Aware (TM) 4.0 specification Table 109
* (Unaligned Schedule attribute format). Used to configure the device
@@ -9346,6 +9357,29 @@ enum nl80211_s1g_short_beacon_attrs {
* @NL80211_NAN_CAPA_OFFLOAD_RANGING: flag attribute. Firmware supports the
* fully offloaded NAN ranging procedure, including ranging session setup,
* update, and termination, FTM protocol and procedure, and ranging reports.
+ * @NL80211_NAN_CAPA_OFFLOAD_NDP: flag attribute. The device performs the
+ * complete NAN Data Path setup and teardown handshake with the peer,
+ * including NDP Request/Response/Confirm and the security handshake. Within
+ * the local NAN schedule configured by userspace, the device negotiates NDLs
+ * for offloaded NDPs, including NDC, immutable schedules, and schedule
+ * updates, honoring NDP QoS requirements. Userspace continues to configure
+ * the local schedule with %NL80211_CMD_NAN_SET_LOCAL_SCHED and its
+ * non-evacuable channels with %NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS. The
+ * device learns and manages peer NAN schedules; userspace must not set them
+ * with %NL80211_CMD_NAN_SET_PEER_SCHED. The device assigns NDP IDs for
+ * locally initiated NDPs and derives, installs, and removes data path keys
+ * (PTK and, when requested, GTK). The device creates and removes NDI peer
+ * stations for offloaded NDPs. Userspace must not add those NDI peer stations
+ * or their keys. NDP offload is supported on every band that the device
+ * reports for NAN in %NL80211_ATTR_BANDS. The device supplies the band-specific
+ * capabilities, such as the HE 6 GHz band and EHT capabilities, and the
+ * regulatory information in the frames it builds. The device supports
+ * %NL80211_CMD_NAN_NDP_INITIATE,
+ * %NL80211_CMD_NAN_NDP_RESPOND, and
+ * %NL80211_CMD_NAN_NDP_TERMINATE, and reports peer requests, setup status,
+ * and termination with %NL80211_CMD_NAN_NDP_INITIATE,
+ * %NL80211_CMD_NAN_NDP_STATUS, and %NL80211_CMD_NAN_NDP_TERMINATE.
+ * Secure NDPs additionally require %NL80211_EXT_FEATURE_SECURE_NAN.
* @__NL80211_NAN_CAPABILITIES_LAST: Internal
* @NL80211_NAN_CAPABILITIES_MAX: Highest NAN capability attribute.
*/
@@ -9361,6 +9395,7 @@ enum nl80211_nan_capabilities {
NL80211_NAN_CAPA_PHY,
NL80211_NAN_CAPA_INSTANT_COMM,
NL80211_NAN_CAPA_OFFLOAD_RANGING,
+ NL80211_NAN_CAPA_OFFLOAD_NDP,
/* keep last */
__NL80211_NAN_CAPABILITIES_LAST,
NL80211_NAN_CAPABILITIES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 8d4e98fcedab..7426d2c8a40b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3223,6 +3223,10 @@ static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)
nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))
goto fail;
+ if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP) &&
+ nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))
+ goto fail;
+
if (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE,
wiphy->nan_capa.op_mode) ||
nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS,
@@ -18359,6 +18363,12 @@ static int nl80211_nan_set_peer_sched(struct sk_buff *skb,
if (wdev->iftype != NL80211_IFTYPE_NAN)
return -EOPNOTSUPP;
+ if (rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP) {
+ NL_SET_ERR_MSG(info->extack,
+ "Peer NAN schedule is managed by the device with NDP offload");
+ return -EOPNOTSUPP;
+ }
+
if (!info->attrs[NL80211_ATTR_MAC] ||
!info->attrs[NL80211_ATTR_NAN_COMMITTED_DW]) {
NL_SET_ERR_MSG(info->extack,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 10/19] wifi: nl80211/cfg80211: add support for NDP initiation in offload mode
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (8 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 09/19] wifi: nl80211: add NDP offload capability advertisement Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 11/19] wifi: nl80211/cfg80211: add support for NDP response " Shivani Baranwal
` (9 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Add NL80211_CMD_NAN_NDP_INITIATE to let userspace initiate a NAN Data
Path session when NDP management is offloaded to the device. Validate
that the initiator NDI exists locally, pass key material by pointer, and
apply the NAN security requirements to cipher suite, PMK, PMKID, and
GTK.
Let the initiator provide QoS requirements for the NDL schedule through
the minimum time slots and maximum latency fields. The device uses these
values to allocate the NDL schedule within the user-configured local
schedule.
Let the driver assign the NDP ID and return it in the command reply.
Clear the request skb after handling it because it may contain PMK data.
Trace the non-secret request parameters without recording PMK or PMKID
bytes. Build the reply and reserve the NDP ID field before calling the
driver, so reply construction cannot fail after the driver accepts the
request.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 65 ++++++++++
include/uapi/linux/nl80211.h | 105 +++++++++++++++
net/wireless/nl80211.c | 242 +++++++++++++++++++++++++++++++++++
net/wireless/rdev-ops.h | 16 +++
net/wireless/trace.h | 93 ++++++++++++++
5 files changed, 521 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b1289d5fcd93..6b3b46a993a3 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4387,6 +4387,60 @@ struct cfg80211_nan_peer_sched {
struct cfg80211_nan_peer_map maps[CFG80211_NAN_MAX_PEER_MAPS];
};
+/**
+ * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @publish_id: publisher's service instance ID
+ * @service_id: NAN service ID (%NL80211_NAN_FUNC_SERVICE_ID_LEN bytes)
+ * @init_ndi: initiator NDI MAC address. The corresponding
+ * %NL80211_IFTYPE_NAN_DATA interface must exist.
+ * @ssi: service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: NAN cipher suite ID, 0 for open NDP
+ * @pmk: ND-PMK used to derive the PTK; NULL if absent. Its length depends on
+ * the cipher suite and is given by @pmk_len. Requires non-zero
+ * @cipher_suite and %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @pmk_len: length of @pmk in bytes
+ * @pmkid: PMKID (16 octets) to include in the NDP Request, or NULL if absent
+ * @gtk_required: if true, GTK protection is required for group-addressed data
+ * frames
+ * @gtk_cipher: GTK cipher suite ID, valid when @gtk_required is true
+ * @ipv6_intf_id: IPv6 link-local interface identifier, or NULL if absent
+ * @ndp_id: output NDP ID assigned by the driver on success (1-255)
+ * @transport_info: if true, convey @transport_port and @transport_protocol to
+ * the peer in the NDPE Service Info TLV (Generic Service Protocol). These
+ * values are not conveyed if the peer does not support NDPE.
+ * @transport_port: transport port to convey when @transport_info is true
+ * @transport_protocol: IANA protocol number to convey when @transport_info is
+ * true
+ * @qos_min_slots: minimum number of NAN time slots required for this NDP; 0
+ * means no preference
+ * @qos_max_latency: maximum number of NAN slots between two non-contiguous
+ * NDL CRBs; 0xffff means no preference
+ */
+struct cfg80211_nan_ndp_initiate {
+ const u8 *peer_nmi;
+ u8 publish_id;
+ u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
+ const u8 *init_ndi;
+ const u8 *ssi;
+ u8 ssi_len;
+ u32 cipher_suite;
+ const u8 *pmk;
+ u8 pmk_len;
+ const u8 *pmkid;
+ bool gtk_required;
+ u32 gtk_cipher;
+ const u8 *ipv6_intf_id;
+ u8 ndp_id;
+ bool transport_info;
+ u16 transport_port;
+ u8 transport_protocol;
+ u8 qos_min_slots;
+ u16 qos_max_latency;
+};
+
/**
* enum cfg80211_nan_conf_changes - indicates changed fields in NAN
* configuration
@@ -5374,6 +5428,14 @@ struct mgmt_frame_regs {
* offloaded NDPs, userspace configures these channels for the device to
* consider while negotiating NDL schedules.
*
+ * @nan_ndp_initiate: Initiate a NAN Data Path session as the initiator.
+ * Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.
+ * The driver must set params->ndp_id to the assigned NDP ID (1-255) on
+ * success. Each accepted setup attempt completes asynchronously with one
+ * status notification, including on failure or timeout. If the device cannot
+ * meet the QoS requirements in @params, it reports setup failure with the
+ * Wi-Fi Aware reason QoS_UNACCEPTABLE.
+ *
* @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
*
* @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
@@ -5788,6 +5850,9 @@ struct cfg80211_ops {
int (*nan_set_non_evac_channels)(struct wiphy *wiphy,
struct wireless_dev *wdev,
struct cfg80211_nan_non_evac_channels *channels);
+ int (*nan_ndp_initiate)(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_initiate *params);
int (*set_multicast_to_unicast)(struct wiphy *wiphy,
struct net_device *dev,
const bool enabled);
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index f22ad0a018a7..33af139c4d4b 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1575,6 +1575,25 @@
* addresses (%NL80211_ATTR_MLO_LINKS, each nested link with
* %NL80211_ATTR_MLO_LINK_ID, %NL80211_ATTR_BSSID and %NL80211_ATTR_MAC).
*
+ * @NL80211_CMD_NAN_NDP_INITIATE: Initiate NAN Data Path (NDP) setup
+ * as the initiator. Requires %NL80211_NAN_CAPA_OFFLOAD_NDP,
+ * %NL80211_ATTR_MAC (peer NMI), and %NL80211_ATTR_NAN_NDP. The NDI
+ * interface specified in %NL80211_NAN_NDP_ATTR_INIT_NDI must already
+ * exist as a %NL80211_IFTYPE_NAN_DATA interface. For a locally
+ * initiated NDP, the driver assigns the NDP ID and returns it in the
+ * %NL80211_ATTR_NAN_NDP reply.
+ * %NL80211_NAN_NDP_ATTR_TRANSPORT_PORT and
+ * %NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL may be supplied together to
+ * include transport information in the NDPE Service Info TLV.
+ * %NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS and
+ * %NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY may be supplied as NDL QoS
+ * requirements. The device uses them to allocate the NDL schedule within the
+ * user-configured local schedule. If the device cannot meet the QoS
+ * requirements, setup fails and the status notification reports the Wi-Fi
+ * Aware reason QoS_UNACCEPTABLE.
+ * Each accepted setup attempt completes asynchronously with exactly one
+ * %NL80211_CMD_NAN_NDP_STATUS notification, including on failure or timeout.
+ *
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
@@ -1862,6 +1881,8 @@ enum nl80211_commands {
NL80211_CMD_EXECUTE_SMD_TRANSITION,
NL80211_CMD_COMPLETED_SMD_TRANSITION,
+ NL80211_CMD_NAN_NDP_INITIATE,
+
/* add new commands above here */
/* used to define NL80211_CMD_MAX below */
@@ -3356,6 +3377,9 @@ enum nl80211_commands {
* @NL80211_ATTR_ASSOC_PROTECTED_TWT: Enable protected TWT for the association,
* requires protected TWT support (flag attribute)
*
+ * @NL80211_ATTR_NAN_NDP: nested attribute carrying NAN Data Path parameters.
+ * See &enum nl80211_nan_ndp_attributes.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3963,6 +3987,8 @@ enum nl80211_attrs {
NL80211_ATTR_ASSOC_PROTECTED_TWT,
+ NL80211_ATTR_NAN_NDP,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@@ -8120,6 +8146,85 @@ enum nl80211_nan_conf_attributes {
NL80211_NAN_CONF_ATTR_MAX = NUM_NL80211_NAN_CONF_ATTR - 1,
};
+#define NL80211_NAN_NDP_IPV6_INTF_ID_LEN 8
+
+/**
+ * enum nl80211_nan_ndp_attributes - NAN Data Path attributes
+ *
+ * Nested attributes used within %NL80211_ATTR_NAN_NDP for NDP setup commands
+ * and events.
+ *
+ * @__NL80211_NAN_NDP_ATTR_INVALID: Invalid.
+ * @NL80211_NAN_NDP_ATTR_ID: u8 NDP ID (1-255), assigned by the NDP initiator.
+ * For locally initiated NDPs the driver assigns it and returns it in the
+ * %NL80211_CMD_NAN_NDP_INITIATE reply; do not include it in that request.
+ * @NL80211_NAN_NDP_ATTR_PUBLISH_ID: u8 publisher's service instance ID, used
+ * to match the NDP to a service.
+ * @NL80211_NAN_NDP_ATTR_SERVICE_ID: binary NAN service ID derived from the
+ * service name, %NL80211_NAN_FUNC_SERVICE_ID_LEN bytes.
+ * @NL80211_NAN_NDP_ATTR_INIT_NDI: ETH_ALEN-byte initiator NDI MAC address.
+ * For locally initiated NDPs, the corresponding
+ * %NL80211_IFTYPE_NAN_DATA interface must exist.
+ * @NL80211_NAN_NDP_ATTR_RESP_NDI: ETH_ALEN-byte responder NDI MAC address.
+ * @NL80211_NAN_NDP_ATTR_SSI: binary. Service-specific info carried in
+ * the NDP setup frames.
+ * @NL80211_NAN_NDP_ATTR_CIPHER_SUITE: u32 NAN cipher suite ID; 0 for open NDP.
+ * See the Wi-Fi Aware Specification for values.
+ * @NL80211_NAN_NDP_ATTR_PMK: binary ND-PMK used to derive the PTK; its length
+ * depends on the cipher suite. Requires non-zero
+ * @NL80211_NAN_NDP_ATTR_CIPHER_SUITE and %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_NDP_ATTR_PMKID: 16-octet PMKID. In
+ * %NL80211_CMD_NAN_NDP_INITIATE requests it identifies the PMK and is
+ * included in the SCIA of the NDP Request. In a peer-request notification,
+ * it carries the PMKID received in the peer's SCIA for cached-PMK lookup.
+ * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED: flag indicating that GTK protection is
+ * required for group-addressed data frames. Requires
+ * @NL80211_NAN_NDP_ATTR_GTK_CIPHER; IGTK and BIGTK are not covered.
+ * @NL80211_NAN_NDP_ATTR_GTK_CIPHER: u32 GTK cipher suite ID. Required if
+ * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED is set.
+ * @NL80211_NAN_NDP_ATTR_IPV6_INTF_ID: binary IPv6 link-local interface
+ * identifier, %NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes. The driver conveys it
+ * in the NDPE attribute and selects NDP or NDPE based on peer capabilities.
+ * @NL80211_NAN_NDP_ATTR_TRANSPORT_PORT: u16 transport port. Must be supplied
+ * with @NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL. The driver carries the pair
+ * in the NDPE Service Info TLV (Generic Service Protocol). If the peer does
+ * not support NDPE, the values are not conveyed.
+ * @NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL: u8 IANA protocol number. Must be
+ * supplied with @NL80211_NAN_NDP_ATTR_TRANSPORT_PORT.
+ * @NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS: optional u8 Minimum Time Slots field
+ * of the NDL QoS attribute, specifying the minimum number of NAN time slots
+ * required for this NDP. Absent or 0 means no preference.
+ * @NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY: optional u16 Maximum Latency field of
+ * the NDL QoS attribute, specifying the maximum number of NAN slots between
+ * two non-contiguous NDL CRBs. Absent or 0xffff means no preference.
+ * @__NL80211_NAN_NDP_ATTR_LAST: Internal.
+ * @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute.
+ */
+enum nl80211_nan_ndp_attributes {
+ __NL80211_NAN_NDP_ATTR_INVALID,
+
+ NL80211_NAN_NDP_ATTR_ID,
+ NL80211_NAN_NDP_ATTR_PUBLISH_ID,
+ NL80211_NAN_NDP_ATTR_SERVICE_ID,
+ NL80211_NAN_NDP_ATTR_INIT_NDI,
+ NL80211_NAN_NDP_ATTR_RESP_NDI,
+ NL80211_NAN_NDP_ATTR_SSI,
+ NL80211_NAN_NDP_ATTR_CIPHER_SUITE,
+ NL80211_NAN_NDP_ATTR_PMK,
+ NL80211_NAN_NDP_ATTR_PMKID,
+ NL80211_NAN_NDP_ATTR_GTK_REQUIRED,
+ NL80211_NAN_NDP_ATTR_GTK_CIPHER,
+ NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+ NL80211_NAN_NDP_ATTR_TRANSPORT_PORT,
+ NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL,
+ NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS,
+ NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY,
+
+ /* keep last */
+ __NL80211_NAN_NDP_ATTR_LAST,
+ NL80211_NAN_NDP_ATTR_MAX = __NL80211_NAN_NDP_ATTR_LAST - 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 7426d2c8a40b..53cd9d5cd648 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -819,6 +819,34 @@ nl80211_nan_peer_map_policy[NL80211_NAN_PEER_MAP_ATTR_MAX + 1] = {
NLA_POLICY_EXACT_LEN(CFG80211_NAN_SCHED_NUM_TIME_SLOTS),
};
+static const struct nla_policy
+nl80211_nan_ndp_policy[NL80211_NAN_NDP_ATTR_MAX + 1] = {
+ [NL80211_NAN_NDP_ATTR_ID] = NLA_POLICY_RANGE(NLA_U8, 1, 255),
+ [NL80211_NAN_NDP_ATTR_PUBLISH_ID] = { .type = NLA_U8 },
+ [NL80211_NAN_NDP_ATTR_SERVICE_ID] =
+ NLA_POLICY_EXACT_LEN(NL80211_NAN_FUNC_SERVICE_ID_LEN),
+ [NL80211_NAN_NDP_ATTR_INIT_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
+ [NL80211_NAN_NDP_ATTR_RESP_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
+ [NL80211_NAN_NDP_ATTR_SSI] = {
+ .type = NLA_BINARY,
+ .len = NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN
+ },
+ [NL80211_NAN_NDP_ATTR_CIPHER_SUITE] = { .type = NLA_U32 },
+ [NL80211_NAN_NDP_ATTR_PMK] =
+ NLA_POLICY_VALIDATE_FN(NLA_BINARY, validate_nan_pmk,
+ WLAN_PMK_LEN_SUITE_B_192),
+ [NL80211_NAN_NDP_ATTR_PMKID] =
+ NLA_POLICY_EXACT_LEN(WLAN_PMKID_LEN),
+ [NL80211_NAN_NDP_ATTR_GTK_REQUIRED] = { .type = NLA_FLAG },
+ [NL80211_NAN_NDP_ATTR_GTK_CIPHER] = { .type = NLA_U32 },
+ [NL80211_NAN_NDP_ATTR_IPV6_INTF_ID] =
+ NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_IPV6_INTF_ID_LEN),
+ [NL80211_NAN_NDP_ATTR_TRANSPORT_PORT] = { .type = NLA_U16 },
+ [NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL] = { .type = NLA_U8 },
+ [NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS] = { .type = NLA_U8 },
+ [NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY] = { .type = NLA_U16 },
+};
+
static const struct nla_policy
nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {
[NL80211_NAN_CONF_CLUSTER_ID] =
@@ -1112,6 +1140,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[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_NAN_NDP] = NLA_POLICY_NESTED(nl80211_nan_ndp_policy),
[NL80211_ATTR_FILS_KEK] = { .type = NLA_BINARY,
.len = FILS_MAX_KEK_LEN },
[NL80211_ATTR_FILS_NONCES] = NLA_POLICY_EXACT_LEN_WARN(2 * FILS_NONCE_LEN),
@@ -18504,6 +18533,212 @@ static int nl80211_nan_set_peer_sched(struct sk_buff *skb,
return rdev_nan_set_peer_sched(rdev, wdev, &sched);
}
+static bool nl80211_nan_ndi_exists(struct cfg80211_registered_device *rdev,
+ const u8 *addr)
+{
+ struct wireless_dev *wdev;
+
+ lockdep_assert_wiphy(&rdev->wiphy);
+
+ list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
+ if (wdev->iftype == NL80211_IFTYPE_NAN_DATA &&
+ ether_addr_equal(wdev_address(wdev), addr))
+ return true;
+ }
+
+ return false;
+}
+
+static int nl80211_nan_ndp_initiate(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 nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+ struct nlattr *ndp_attr, *id_attr;
+ struct cfg80211_nan_ndp_initiate params = {};
+ struct sk_buff *msg;
+ void *hdr;
+ bool secure_nan;
+ int err;
+
+ if (wdev->iftype != NL80211_IFTYPE_NAN) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP initiate requires NAN interface");
+ return -EOPNOTSUPP;
+ }
+
+ if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN NDP offload not supported by driver");
+ return -EOPNOTSUPP;
+ }
+
+ if (!info->attrs[NL80211_ATTR_MAC] ||
+ !info->attrs[NL80211_ATTR_NAN_NDP]) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP initiate requires peer NMI and NDP params");
+ return -EINVAL;
+ }
+
+ err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+ info->attrs[NL80211_ATTR_NAN_NDP],
+ nl80211_nan_ndp_policy,
+ info->extack);
+ if (err)
+ return err;
+
+ if (!!tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PORT] !=
+ !!tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL]) {
+ NL_SET_ERR_MSG(info->extack,
+ "Transport port and protocol must be supplied together");
+ return -EINVAL;
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_ID]) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_ID],
+ "NDP ID is assigned by the driver");
+ return -EINVAL;
+ }
+
+ if (!tb[NL80211_NAN_NDP_ATTR_INIT_NDI] ||
+ !tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID] ||
+ !tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP initiate requires INIT_NDI, PUBLISH_ID and SERVICE_ID");
+ return -EINVAL;
+ }
+
+ if (!nl80211_nan_ndi_exists(rdev,
+ nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]))) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_INIT_NDI],
+ "INIT_NDI must identify an existing NAN Data interface");
+ return -ENODEV;
+ }
+
+ params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+ params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+ params.publish_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID]);
+ memcpy(params.service_id,
+ nla_data(tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]),
+ NL80211_NAN_FUNC_SERVICE_ID_LEN);
+ if (tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PORT]) {
+ params.transport_info = true;
+ params.transport_port =
+ nla_get_u16(tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PORT]);
+ params.transport_protocol =
+ nla_get_u8(tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL]);
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_SSI]) {
+ params.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);
+ params.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])
+ params.cipher_suite =
+ nla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);
+
+ secure_nan = wiphy_ext_feature_isset(&rdev->wiphy,
+ NL80211_EXT_FEATURE_SECURE_NAN);
+ if (params.cipher_suite && !secure_nan) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE],
+ "NDP cipher suite requires SECURE_NAN");
+ return -EOPNOTSUPP;
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_PMK] ||
+ tb[NL80211_NAN_NDP_ATTR_PMKID] ||
+ tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {
+ if (!secure_nan || !params.cipher_suite) {
+ NL_SET_ERR_MSG(info->extack,
+ "PMK, PMKID, and GTK require SECURE_NAN and a non-zero cipher suite");
+ return -EINVAL;
+ }
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_PMK]) {
+ params.pmk = nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]);
+ params.pmk_len = nla_len(tb[NL80211_NAN_NDP_ATTR_PMK]);
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_PMKID])
+ params.pmkid = nla_data(tb[NL80211_NAN_NDP_ATTR_PMKID]);
+
+ if (tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {
+ if (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+ "GTK_CIPHER is required when GTK_REQUIRED is set");
+ return -EINVAL;
+ }
+
+ params.gtk_required = true;
+ params.gtk_cipher =
+ nla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);
+ } else if (tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],
+ "GTK_CIPHER requires GTK_REQUIRED");
+ return -EINVAL;
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID])
+ params.ipv6_intf_id =
+ nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]);
+
+ if (tb[NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS])
+ params.qos_min_slots =
+ nla_get_u8(tb[NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS]);
+
+ params.qos_max_latency = U16_MAX;
+ if (tb[NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY])
+ params.qos_max_latency =
+ nla_get_u16(tb[NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY]);
+
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
+ if (!msg)
+ return -ENOMEM;
+
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
+ NL80211_CMD_NAN_NDP_INITIATE);
+ if (!hdr) {
+ nlmsg_free(msg);
+ return -ENOMEM;
+ }
+
+ ndp_attr = nla_nest_start_noflag(msg, NL80211_ATTR_NAN_NDP);
+ if (!ndp_attr) {
+ nlmsg_free(msg);
+ return -ENOBUFS;
+ }
+
+ id_attr = nla_reserve(msg, NL80211_NAN_NDP_ATTR_ID, sizeof(u8));
+ if (!id_attr) {
+ nlmsg_free(msg);
+ return -ENOBUFS;
+ }
+
+ err = rdev_nan_ndp_initiate(rdev, wdev, ¶ms);
+ if (err) {
+ nlmsg_free(msg);
+ return err;
+ }
+
+ if (WARN_ON_ONCE(!params.ndp_id)) {
+ nlmsg_free(msg);
+ return -EINVAL;
+ }
+
+ *(u8 *)nla_data(id_attr) = params.ndp_id;
+ nla_nest_end(msg, ndp_attr);
+ genlmsg_end(msg, hdr);
+ return genlmsg_reply(msg, info);
+}
+
static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
{
if (!sched->n_channels)
@@ -21816,6 +22051,13 @@ static const struct genl_small_ops nl80211_small_ops[] = {
.flags = GENL_UNS_ADMIN_PERM,
.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP),
},
+ {
+ .cmd = NL80211_CMD_NAN_NDP_INITIATE,
+ .doit = nl80211_nan_ndp_initiate,
+ .flags = GENL_ADMIN_PERM,
+ .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |
+ NL80211_FLAG_CLEAR_SKB),
+ },
};
static struct genl_family nl80211_fam __ro_after_init = {
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index 44a4255bbc03..e60478a25a31 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1189,6 +1189,22 @@ static inline void rdev_stop_pd(struct cfg80211_registered_device *rdev,
trace_rdev_return_void(&rdev->wiphy);
}
+static inline int
+rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,
+ struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_initiate *params)
+{
+ int ret;
+
+ if (!rdev->ops->nan_ndp_initiate)
+ return -EOPNOTSUPP;
+
+ trace_rdev_nan_ndp_initiate(&rdev->wiphy, wdev, params);
+ ret = rdev->ops->nan_ndp_initiate(&rdev->wiphy, wdev, params);
+ trace_rdev_return_int(&rdev->wiphy, ret);
+ return ret;
+}
+
static inline int rdev_set_mac_acl(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct cfg80211_acl_data *params)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index b0ff3cc4176d..26e966c743c8 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2552,6 +2552,99 @@ TRACE_EVENT(rdev_nan_set_non_evac_channels,
__entry->n_channels, sizeof(u32)))
);
+#define RDEV_NAN_NDP_INITIATE_FMT_1 \
+ ", peer: %pM, init_ndi: %pM, publish_id: %u, "
+#define RDEV_NAN_NDP_INITIATE_FMT_2 \
+ "service_id: %s, ssi_len: %u, ssi: %s, "
+#define RDEV_NAN_NDP_INITIATE_FMT_3 \
+ "cipher_suite: %u, pmk_len: %u, pmkid_present: %d, "
+#define RDEV_NAN_NDP_INITIATE_FMT_4 \
+ "gtk_required: %d, gtk_cipher: %u, ipv6_intf_id_present: %d, "
+#define RDEV_NAN_NDP_INITIATE_FMT_5 \
+ "ipv6_intf_id: %s, qos_min_slots: %u, qos_max_latency: %u"
+TRACE_EVENT(rdev_nan_ndp_initiate,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_initiate *params),
+ TP_ARGS(wiphy, wdev, params),
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ __array(u8, peer_nmi, ETH_ALEN)
+ __array(u8, init_ndi, ETH_ALEN)
+ __field(u8, publish_id)
+ __array(u8, service_id, NL80211_NAN_FUNC_SERVICE_ID_LEN)
+ __field(u8, ssi_len)
+ __dynamic_array(u8, ssi, params->ssi_len)
+ __field(u32, cipher_suite)
+ __field(u8, pmk_len)
+ __field(bool, pmkid_present)
+ __field(bool, gtk_required)
+ __field(u32, gtk_cipher)
+ __field(bool, transport_info)
+ __field(u16, transport_port)
+ __field(u8, transport_protocol)
+ __field(bool, ipv6_intf_id_present)
+ __array(u8, ipv6_intf_id, NL80211_NAN_NDP_IPV6_INTF_ID_LEN)
+ __field(u8, qos_min_slots)
+ __field(u16, qos_max_latency)
+ ),
+ TP_fast_assign(
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+ memcpy(__entry->init_ndi, params->init_ndi, ETH_ALEN);
+ __entry->publish_id = params->publish_id;
+ memcpy(__entry->service_id, params->service_id,
+ NL80211_NAN_FUNC_SERVICE_ID_LEN);
+ __entry->ssi_len = params->ssi_len;
+ if (params->ssi_len)
+ memcpy(__get_dynamic_array(ssi), params->ssi,
+ params->ssi_len);
+ __entry->cipher_suite = params->cipher_suite;
+ __entry->pmk_len = params->pmk ? params->pmk_len : 0;
+ __entry->pmkid_present = !!params->pmkid;
+ __entry->gtk_required = params->gtk_required;
+ __entry->gtk_cipher = params->gtk_cipher;
+ __entry->transport_info = params->transport_info;
+ __entry->transport_port = params->transport_port;
+ __entry->transport_protocol = params->transport_protocol;
+ __entry->ipv6_intf_id_present = !!params->ipv6_intf_id;
+ if (params->ipv6_intf_id)
+ memcpy(__entry->ipv6_intf_id, params->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ else
+ memset(__entry->ipv6_intf_id, 0,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ __entry->qos_min_slots = params->qos_min_slots;
+ __entry->qos_max_latency = params->qos_max_latency;
+ ),
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ RDEV_NAN_NDP_INITIATE_FMT_1 RDEV_NAN_NDP_INITIATE_FMT_2
+ RDEV_NAN_NDP_INITIATE_FMT_3 RDEV_NAN_NDP_INITIATE_FMT_4
+ RDEV_NAN_NDP_INITIATE_FMT_5
+ ", transport_info: %d, transport_port: %u, transport_protocol: %u",
+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->peer_nmi, __entry->init_ndi,
+ __entry->publish_id,
+ __print_array(__entry->service_id,
+ NL80211_NAN_FUNC_SERVICE_ID_LEN, sizeof(u8)),
+ __entry->ssi_len,
+ __print_array(__get_dynamic_array(ssi), __entry->ssi_len,
+ sizeof(u8)),
+ __entry->cipher_suite, __entry->pmk_len,
+ __entry->pmkid_present, __entry->gtk_required,
+ __entry->gtk_cipher, __entry->ipv6_intf_id_present,
+ __print_array(__entry->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN, sizeof(u8)),
+ __entry->qos_min_slots, __entry->qos_max_latency,
+ __entry->transport_info, __entry->transport_port,
+ __entry->transport_protocol)
+);
+#undef RDEV_NAN_NDP_INITIATE_FMT_1
+#undef RDEV_NAN_NDP_INITIATE_FMT_2
+#undef RDEV_NAN_NDP_INITIATE_FMT_3
+#undef RDEV_NAN_NDP_INITIATE_FMT_4
+#undef RDEV_NAN_NDP_INITIATE_FMT_5
+
TRACE_EVENT(rdev_set_mac_acl,
TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
struct cfg80211_acl_data *params),
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 11/19] wifi: nl80211/cfg80211: add support for NDP response in offload mode
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (9 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 10/19] wifi: nl80211/cfg80211: add support for NDP initiation in offload mode Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 12/19] wifi: nl80211/cfg80211: add support for NDP termination " Shivani Baranwal
` (8 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Add NL80211_CMD_NAN_NDP_RESPOND so userspace can accept or reject an
incoming NDP request when the device offloads NDP management. Require a
local responder NDI only when accepting; the initiator NDI belongs to
the peer and is not validated as a local interface.
Restrict rejection requests to the reason and optional SSI, and enforce
the NAN security requirements when accepting. Pass PMK material by
pointer, clear the request skb, and trace request parameters without
recording key bytes.
Allow the responder to provide transport port and protocol information
when accepting an NDP request. Accept the NDL QoS requirements on
accepted responses, and reject them when rejecting an NDP.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 63 ++++++++++++
include/uapi/linux/nl80211.h | 39 +++++++-
net/wireless/nl80211.c | 179 +++++++++++++++++++++++++++++++++++
net/wireless/rdev-ops.h | 16 ++++
net/wireless/trace.h | 92 ++++++++++++++++++
5 files changed, 384 insertions(+), 5 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 6b3b46a993a3..5857ce6be50f 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4441,6 +4441,60 @@ struct cfg80211_nan_ndp_initiate {
u16 qos_max_latency;
};
+/**
+ * struct cfg80211_nan_ndp_respond - NAN NDP respond parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID from the received NDP Request
+ * @init_ndi: initiator NDI MAC from the received NDP Request
+ * @resp_ndi: responder NDI MAC. The corresponding
+ * %NL80211_IFTYPE_NAN_DATA interface must exist when accepting.
+ * @accept: if true, accept the NDP; if false, reject it
+ * @reason: Wi-Fi Aware reason code for rejection (valid when @accept is false)
+ * @ssi: response service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: NAN cipher suite ID (must match the initiator's)
+ * @pmk: ND-PMK used to derive the PTK; NULL if absent. Its length depends on
+ * the cipher suite and is given by @pmk_len. Requires non-zero
+ * @cipher_suite and %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @pmk_len: length of @pmk in bytes
+ * @gtk_required: if true, GTK protection is required for group-addressed data
+ * frames
+ * @gtk_cipher: GTK cipher suite ID, valid when @gtk_required is true
+ * @ipv6_intf_id: IPv6 link-local interface identifier, or NULL if absent
+ * @transport_info: if true, convey @transport_port and @transport_protocol to
+ * the peer in the NDPE Service Info TLV (Generic Service Protocol). These
+ * values are not conveyed if the peer does not support NDPE.
+ * @transport_port: transport port to convey when @transport_info is true
+ * @transport_protocol: IANA protocol number to convey when @transport_info is
+ * true
+ * @qos_min_slots: minimum number of NAN time slots required for this NDP; 0
+ * means no preference. Used only when accepting the NDP.
+ * @qos_max_latency: maximum number of NAN slots between two non-contiguous
+ * NDL CRBs; 0xffff means no preference. Used only when accepting the NDP.
+ */
+struct cfg80211_nan_ndp_respond {
+ const u8 *peer_nmi;
+ u8 ndp_id;
+ const u8 *init_ndi;
+ const u8 *resp_ndi;
+ bool accept;
+ u8 reason;
+ const u8 *ssi;
+ u8 ssi_len;
+ u32 cipher_suite;
+ const u8 *pmk;
+ u8 pmk_len;
+ bool gtk_required;
+ u32 gtk_cipher;
+ const u8 *ipv6_intf_id;
+ bool transport_info;
+ u16 transport_port;
+ u8 transport_protocol;
+ u8 qos_min_slots;
+ u16 qos_max_latency;
+};
+
/**
* enum cfg80211_nan_conf_changes - indicates changed fields in NAN
* configuration
@@ -5435,6 +5489,12 @@ struct mgmt_frame_regs {
* status notification, including on failure or timeout. If the device cannot
* meet the QoS requirements in @params, it reports setup failure with the
* Wi-Fi Aware reason QoS_UNACCEPTABLE.
+ * @nan_ndp_respond: Respond to an incoming NDP request as the responder.
+ * Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP. Returning
+ * success acknowledges the response command only; setup outcome is reported
+ * asynchronously after the handshake. If the accepted response's QoS
+ * requirements cannot be met, the driver reports setup failure with the
+ * Wi-Fi Aware reason QoS_UNACCEPTABLE.
*
* @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
*
@@ -5853,6 +5913,9 @@ struct cfg80211_ops {
int (*nan_ndp_initiate)(struct wiphy *wiphy,
struct wireless_dev *wdev,
struct cfg80211_nan_ndp_initiate *params);
+ int (*nan_ndp_respond)(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_respond *params);
int (*set_multicast_to_unicast)(struct wiphy *wiphy,
struct net_device *dev,
const bool enabled);
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 33af139c4d4b..1d5e2f2f08ca 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1593,6 +1593,18 @@
* Aware reason QoS_UNACCEPTABLE.
* Each accepted setup attempt completes asynchronously with exactly one
* %NL80211_CMD_NAN_NDP_STATUS notification, including on failure or timeout.
+ * @NL80211_CMD_NAN_NDP_RESPOND: Respond to a received NDP request as
+ * the responder. Requires %NL80211_NAN_CAPA_OFFLOAD_NDP. The NDI
+ * interface specified in %NL80211_NAN_NDP_ATTR_RESP_NDI must already
+ * exist as a %NL80211_IFTYPE_NAN_DATA interface. Carries
+ * %NL80211_ATTR_NAN_NDP nested with %NL80211_NAN_NDP_ATTR_* fields.
+ * The command reply only acknowledges that the response was accepted for
+ * processing; setup outcome is reported asynchronously by
+ * %NL80211_CMD_NAN_NDP_STATUS.
+ * Transport port and protocol may be supplied together only when accepting.
+ * NDL QoS attributes may also be supplied only when accepting. If the device
+ * cannot meet the QoS requirements in an accepted response, setup fails and
+ * the status notification reports the Wi-Fi Aware reason QoS_UNACCEPTABLE.
*
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
@@ -1882,6 +1894,7 @@ enum nl80211_commands {
NL80211_CMD_COMPLETED_SMD_TRANSITION,
NL80211_CMD_NAN_NDP_INITIATE,
+ NL80211_CMD_NAN_NDP_RESPOND,
/* add new commands above here */
@@ -8166,6 +8179,8 @@ enum nl80211_nan_conf_attributes {
* For locally initiated NDPs, the corresponding
* %NL80211_IFTYPE_NAN_DATA interface must exist.
* @NL80211_NAN_NDP_ATTR_RESP_NDI: ETH_ALEN-byte responder NDI MAC address.
+ * When accepting with %NL80211_CMD_NAN_NDP_RESPOND, this must identify an
+ * existing local %NL80211_IFTYPE_NAN_DATA interface.
* @NL80211_NAN_NDP_ATTR_SSI: binary. Service-specific info carried in
* the NDP setup frames.
* @NL80211_NAN_NDP_ATTR_CIPHER_SUITE: u32 NAN cipher suite ID; 0 for open NDP.
@@ -8186,17 +8201,29 @@ enum nl80211_nan_conf_attributes {
* identifier, %NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes. The driver conveys it
* in the NDPE attribute and selects NDP or NDPE based on peer capabilities.
* @NL80211_NAN_NDP_ATTR_TRANSPORT_PORT: u16 transport port. Must be supplied
- * with @NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL. The driver carries the pair
- * in the NDPE Service Info TLV (Generic Service Protocol). If the peer does
- * not support NDPE, the values are not conveyed.
+ * with @NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL. The pair may be used in
+ * %NL80211_CMD_NAN_NDP_INITIATE and in an accepting
+ * %NL80211_CMD_NAN_NDP_RESPOND. The driver carries these values in the NDPE
+ * Service Info TLV (Generic Service Protocol). If the peer does not support
+ * NDPE, these values are not conveyed.
* @NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL: u8 IANA protocol number. Must be
* supplied with @NL80211_NAN_NDP_ATTR_TRANSPORT_PORT.
* @NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS: optional u8 Minimum Time Slots field
* of the NDL QoS attribute, specifying the minimum number of NAN time slots
- * required for this NDP. Absent or 0 means no preference.
+ * required for this NDP. Absent or 0 means no preference. Used with
+ * %NL80211_CMD_NAN_NDP_INITIATE and an accepting
+ * %NL80211_CMD_NAN_NDP_RESPOND.
* @NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY: optional u16 Maximum Latency field of
* the NDL QoS attribute, specifying the maximum number of NAN slots between
- * two non-contiguous NDL CRBs. Absent or 0xffff means no preference.
+ * two non-contiguous NDL CRBs. Absent or 0xffff means no preference. Used
+ * with %NL80211_CMD_NAN_NDP_INITIATE and an accepting
+ * %NL80211_CMD_NAN_NDP_RESPOND.
+ * @NL80211_NAN_NDP_ATTR_ACCEPT: flag. If present in
+ * %NL80211_CMD_NAN_NDP_RESPOND, it accepts the request; if absent, it is
+ * rejected.
+ * @NL80211_NAN_NDP_ATTR_REASON: u8 Wi-Fi Aware reason code, not an IEEE 802.11
+ * reason code (%NL80211_ATTR_REASON_CODE). Used for rejection with
+ * %NL80211_CMD_NAN_NDP_RESPOND.
* @__NL80211_NAN_NDP_ATTR_LAST: Internal.
* @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute.
*/
@@ -8219,6 +8246,8 @@ enum nl80211_nan_ndp_attributes {
NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL,
NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS,
NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY,
+ NL80211_NAN_NDP_ATTR_ACCEPT,
+ NL80211_NAN_NDP_ATTR_REASON,
/* keep last */
__NL80211_NAN_NDP_ATTR_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 53cd9d5cd648..74be0f639315 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -845,6 +845,8 @@ nl80211_nan_ndp_policy[NL80211_NAN_NDP_ATTR_MAX + 1] = {
[NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL] = { .type = NLA_U8 },
[NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS] = { .type = NLA_U8 },
[NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY] = { .type = NLA_U16 },
+ [NL80211_NAN_NDP_ATTR_ACCEPT] = { .type = NLA_FLAG },
+ [NL80211_NAN_NDP_ATTR_REASON] = { .type = NLA_U8 },
};
static const struct nla_policy
@@ -18739,6 +18741,176 @@ static int nl80211_nan_ndp_initiate(struct sk_buff *skb,
return genlmsg_reply(msg, info);
}
+static int nl80211_nan_ndp_respond(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 nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+ struct cfg80211_nan_ndp_respond params = {};
+ bool secure_nan;
+ int err;
+
+ if (wdev->iftype != NL80211_IFTYPE_NAN) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP respond requires NAN interface");
+ return -EOPNOTSUPP;
+ }
+
+ if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN NDP offload not supported by driver");
+ return -EOPNOTSUPP;
+ }
+
+ if (!info->attrs[NL80211_ATTR_MAC] ||
+ !info->attrs[NL80211_ATTR_NAN_NDP]) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP respond requires peer NMI and NDP params");
+ return -EINVAL;
+ }
+
+ err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+ info->attrs[NL80211_ATTR_NAN_NDP],
+ nl80211_nan_ndp_policy,
+ info->extack);
+ if (err)
+ return err;
+
+ if (!!tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PORT] !=
+ !!tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL]) {
+ NL_SET_ERR_MSG(info->extack,
+ "Transport port and protocol must be supplied together");
+ return -EINVAL;
+ }
+
+ if (!tb[NL80211_NAN_NDP_ATTR_ID] ||
+ !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP respond requires NDP ID and INIT_NDI");
+ return -EINVAL;
+ }
+
+ params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+ params.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);
+ params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+ params.accept = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_ACCEPT]);
+ params.qos_max_latency = U16_MAX;
+
+ if (params.accept) {
+ if (tb[NL80211_NAN_NDP_ATTR_REASON]) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_REASON],
+ "REASON is only valid when rejecting");
+ return -EINVAL;
+ }
+
+ if (!tb[NL80211_NAN_NDP_ATTR_RESP_NDI]) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP accept requires RESP_NDI");
+ return -EINVAL;
+ }
+ params.resp_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_RESP_NDI]);
+ if (!nl80211_nan_ndi_exists(rdev,
+ params.resp_ndi)) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_RESP_NDI],
+ "RESP_NDI must identify an existing NAN Data interface");
+ return -ENODEV;
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PORT]) {
+ params.transport_info = true;
+ params.transport_port =
+ nla_get_u16(tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PORT]);
+ params.transport_protocol =
+ nla_get_u8(tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL]);
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS])
+ params.qos_min_slots =
+ nla_get_u8(tb[NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS]);
+
+ if (tb[NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY])
+ params.qos_max_latency =
+ nla_get_u16(tb[NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY]);
+ } else {
+ if (tb[NL80211_NAN_NDP_ATTR_RESP_NDI] ||
+ tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE] ||
+ tb[NL80211_NAN_NDP_ATTR_PMK] ||
+ tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED] ||
+ tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER] ||
+ tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID] ||
+ tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PORT] ||
+ tb[NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL] ||
+ tb[NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS] ||
+ tb[NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY]) {
+ NL_SET_ERR_MSG(info->extack,
+ "RESP_NDI, cipher, PMK, GTK, IPv6 IID, transport info and QoS are only valid when accepting");
+ return -EINVAL;
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_REASON])
+ params.reason =
+ nla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_SSI]) {
+ params.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);
+ params.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])
+ params.cipher_suite =
+ nla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);
+
+ secure_nan = wiphy_ext_feature_isset(&rdev->wiphy,
+ NL80211_EXT_FEATURE_SECURE_NAN);
+ if (params.cipher_suite && !secure_nan) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE],
+ "NDP cipher suite requires SECURE_NAN");
+ return -EOPNOTSUPP;
+ }
+
+ if ((tb[NL80211_NAN_NDP_ATTR_PMK] ||
+ tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) &&
+ (!secure_nan || !params.cipher_suite)) {
+ NL_SET_ERR_MSG(info->extack,
+ "PMK and GTK require SECURE_NAN and a non-zero cipher suite");
+ return -EINVAL;
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_PMK]) {
+ params.pmk = nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]);
+ params.pmk_len = nla_len(tb[NL80211_NAN_NDP_ATTR_PMK]);
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {
+ if (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+ "GTK_CIPHER is required when GTK_REQUIRED is set");
+ return -EINVAL;
+ }
+
+ params.gtk_required = true;
+ params.gtk_cipher =
+ nla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);
+ } else if (tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],
+ "GTK_CIPHER requires GTK_REQUIRED");
+ return -EINVAL;
+ }
+
+ if (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID])
+ params.ipv6_intf_id =
+ nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]);
+
+ return rdev_nan_ndp_respond(rdev, wdev, ¶ms);
+}
+
static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
{
if (!sched->n_channels)
@@ -22058,6 +22230,13 @@ static const struct genl_small_ops nl80211_small_ops[] = {
.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |
NL80211_FLAG_CLEAR_SKB),
},
+ {
+ .cmd = NL80211_CMD_NAN_NDP_RESPOND,
+ .doit = nl80211_nan_ndp_respond,
+ .flags = GENL_ADMIN_PERM,
+ .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |
+ NL80211_FLAG_CLEAR_SKB),
+ },
};
static struct genl_family nl80211_fam __ro_after_init = {
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index e60478a25a31..c58b83210d60 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1205,6 +1205,22 @@ rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,
return ret;
}
+static inline int
+rdev_nan_ndp_respond(struct cfg80211_registered_device *rdev,
+ struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_respond *params)
+{
+ int ret;
+
+ if (!rdev->ops->nan_ndp_respond)
+ return -EOPNOTSUPP;
+
+ trace_rdev_nan_ndp_respond(&rdev->wiphy, wdev, params);
+ ret = rdev->ops->nan_ndp_respond(&rdev->wiphy, wdev, params);
+ trace_rdev_return_int(&rdev->wiphy, ret);
+ return ret;
+}
+
static inline int rdev_set_mac_acl(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct cfg80211_acl_data *params)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 26e966c743c8..8c5fdbe23747 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2645,6 +2645,98 @@ TRACE_EVENT(rdev_nan_ndp_initiate,
#undef RDEV_NAN_NDP_INITIATE_FMT_4
#undef RDEV_NAN_NDP_INITIATE_FMT_5
+#define NDP_RESP_FMT_1 \
+ ", peer_nmi: %pM, ndp_id: %u, init_ndi: %pM, "
+#define NDP_RESP_FMT_2 \
+ "resp_ndi: %pM, accept: %d, reason: %u, ssi_len: %u, ssi: %s, "
+#define NDP_RESP_FMT_3 \
+ "cipher_suite: %u, pmk_len: %u, gtk_required: %d, gtk_cipher: %u, "
+#define NDP_RESP_FMT_4 \
+ "ipv6_intf_id_present: %d, ipv6_intf_id: %s, " \
+ "qos_min_slots: %u, qos_max_latency: %u"
+
+TRACE_EVENT(rdev_nan_ndp_respond,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_respond *params),
+ TP_ARGS(wiphy, wdev, params),
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ __array(u8, peer_nmi, ETH_ALEN)
+ __field(u8, ndp_id)
+ __array(u8, init_ndi, ETH_ALEN)
+ __array(u8, resp_ndi, ETH_ALEN)
+ __field(bool, accept)
+ __field(u8, reason)
+ __field(u8, ssi_len)
+ __dynamic_array(u8, ssi, params->ssi_len)
+ __field(u32, cipher_suite)
+ __field(u8, pmk_len)
+ __field(bool, gtk_required)
+ __field(u32, gtk_cipher)
+ __field(bool, transport_info)
+ __field(u16, transport_port)
+ __field(u8, transport_protocol)
+ __field(bool, ipv6_intf_id_present)
+ __array(u8, ipv6_intf_id, NL80211_NAN_NDP_IPV6_INTF_ID_LEN)
+ __field(u8, qos_min_slots)
+ __field(u16, qos_max_latency)
+ ),
+ TP_fast_assign(
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+ __entry->ndp_id = params->ndp_id;
+ memcpy(__entry->init_ndi, params->init_ndi, ETH_ALEN);
+ if (params->resp_ndi)
+ memcpy(__entry->resp_ndi, params->resp_ndi, ETH_ALEN);
+ else
+ memset(__entry->resp_ndi, 0, ETH_ALEN);
+ __entry->accept = params->accept;
+ __entry->reason = params->reason;
+ __entry->ssi_len = params->ssi_len;
+ if (params->ssi && params->ssi_len)
+ memcpy(__get_dynamic_array(ssi), params->ssi,
+ params->ssi_len);
+ __entry->cipher_suite = params->cipher_suite;
+ __entry->pmk_len = params->pmk ? params->pmk_len : 0;
+ __entry->gtk_required = params->gtk_required;
+ __entry->gtk_cipher = params->gtk_cipher;
+ __entry->transport_info = params->transport_info;
+ __entry->transport_port = params->transport_port;
+ __entry->transport_protocol = params->transport_protocol;
+ __entry->ipv6_intf_id_present = !!params->ipv6_intf_id;
+ if (params->ipv6_intf_id)
+ memcpy(__entry->ipv6_intf_id, params->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ else
+ memset(__entry->ipv6_intf_id, 0,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ __entry->qos_min_slots = params->qos_min_slots;
+ __entry->qos_max_latency = params->qos_max_latency;
+ ),
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ NDP_RESP_FMT_1 NDP_RESP_FMT_2 NDP_RESP_FMT_3 NDP_RESP_FMT_4
+ ", transport_info: %d, transport_port: %u, transport_protocol: %u",
+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->peer_nmi, __entry->ndp_id,
+ __entry->init_ndi, __entry->resp_ndi, __entry->accept,
+ __entry->reason, __entry->ssi_len,
+ __print_array(__get_dynamic_array(ssi), __entry->ssi_len,
+ sizeof(u8)),
+ __entry->cipher_suite, __entry->pmk_len,
+ __entry->gtk_required, __entry->gtk_cipher,
+ __entry->ipv6_intf_id_present,
+ __print_array(__entry->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN, sizeof(u8)),
+ __entry->qos_min_slots, __entry->qos_max_latency,
+ __entry->transport_info, __entry->transport_port,
+ __entry->transport_protocol)
+);
+#undef NDP_RESP_FMT_1
+#undef NDP_RESP_FMT_2
+#undef NDP_RESP_FMT_3
+#undef NDP_RESP_FMT_4
+
TRACE_EVENT(rdev_set_mac_acl,
TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
struct cfg80211_acl_data *params),
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 12/19] wifi: nl80211/cfg80211: add support for NDP termination in offload mode
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (10 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 11/19] wifi: nl80211/cfg80211: add support for NDP response " Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 13/19] wifi: nl80211/cfg80211: add support for NDP request indication Shivani Baranwal
` (7 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Add NL80211_CMD_NAN_NDP_TERMINATE to let userspace tear down an NDP or
cancel NDP setup in progress when the device offloads NDP management.
Pass the initiator NDI from the request through to the driver; it may
identify either the local or peer NDI and is not validated as a local
interface.
Add the termination parameter structure, command handler, and driver
callback, and trace the initiator NDI with the other request metadata.
The initiate path builds its reply before calling the driver, but the
reply can still fail to reach userspace after the driver has accepted
the setup (for example, if the socket receive buffer is full). In that
case userspace never learns the NDP ID, so use the new callback to
cancel the setup.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 24 +++++++++++
include/uapi/linux/nl80211.h | 7 ++++
net/wireless/nl80211.c | 79 +++++++++++++++++++++++++++++++++++-
net/wireless/rdev-ops.h | 16 ++++++++
net/wireless/trace.h | 27 ++++++++++++
5 files changed, 152 insertions(+), 1 deletion(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 5857ce6be50f..eda9a073422b 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4495,6 +4495,21 @@ struct cfg80211_nan_ndp_respond {
u16 qos_max_latency;
};
+/**
+ * struct cfg80211_nan_ndp_terminate - NAN NDP terminate parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID to terminate
+ * @init_ndi: initiator NDI MAC address
+ * @reason: Wi-Fi Aware reason code for termination
+ */
+struct cfg80211_nan_ndp_terminate {
+ const u8 *peer_nmi;
+ u8 ndp_id;
+ const u8 *init_ndi;
+ u8 reason;
+};
+
/**
* enum cfg80211_nan_conf_changes - indicates changed fields in NAN
* configuration
@@ -5495,6 +5510,12 @@ struct mgmt_frame_regs {
* asynchronously after the handshake. If the accepted response's QoS
* requirements cannot be met, the driver reports setup failure with the
* Wi-Fi Aware reason QoS_UNACCEPTABLE.
+ * @nan_ndp_terminate: Terminate an NDP session or cancel NDP setup in
+ * progress. cfg80211 also uses it to cancel a locally initiated setup
+ * whose NDP ID reply could not be delivered to userspace. Only valid if
+ * the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP. Returning success
+ * acknowledges the request; report completion asynchronously with
+ * cfg80211_nan_ndp_terminated().
*
* @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
*
@@ -5916,6 +5937,9 @@ struct cfg80211_ops {
int (*nan_ndp_respond)(struct wiphy *wiphy,
struct wireless_dev *wdev,
struct cfg80211_nan_ndp_respond *params);
+ int (*nan_ndp_terminate)(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_terminate *params);
int (*set_multicast_to_unicast)(struct wiphy *wiphy,
struct net_device *dev,
const bool enabled);
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 1d5e2f2f08ca..54249b98fcc7 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1605,6 +1605,12 @@
* NDL QoS attributes may also be supplied only when accepting. If the device
* cannot meet the QoS requirements in an accepted response, setup fails and
* the status notification reports the Wi-Fi Aware reason QoS_UNACCEPTABLE.
+ * @NL80211_CMD_NAN_NDP_TERMINATE: Terminate an NDP or cancel setup in progress.
+ * Requires %NL80211_NAN_CAPA_OFFLOAD_NDP. Carries %NL80211_ATTR_NAN_NDP
+ * nested with %NL80211_NAN_NDP_ATTR_ID, %NL80211_NAN_NDP_ATTR_INIT_NDI
+ * and optionally %NL80211_NAN_NDP_ATTR_REASON.
+ * The command reply acknowledges the request; teardown completion is
+ * reported asynchronously by the termination notification.
*
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
@@ -1895,6 +1901,7 @@ enum nl80211_commands {
NL80211_CMD_NAN_NDP_INITIATE,
NL80211_CMD_NAN_NDP_RESPOND,
+ NL80211_CMD_NAN_NDP_TERMINATE,
/* add new commands above here */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 74be0f639315..571432435bfa 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -18738,7 +18738,26 @@ static int nl80211_nan_ndp_initiate(struct sk_buff *skb,
*(u8 *)nla_data(id_attr) = params.ndp_id;
nla_nest_end(msg, ndp_attr);
genlmsg_end(msg, hdr);
- return genlmsg_reply(msg, info);
+ err = genlmsg_reply(msg, info);
+ if (err) {
+ struct cfg80211_nan_ndp_terminate terminate = {
+ .peer_nmi = params.peer_nmi,
+ .ndp_id = params.ndp_id,
+ .init_ndi = params.init_ndi,
+ };
+ int term_err;
+
+ /* Userspace never learned the NDP ID, so it cannot manage
+ * this NDP; cancel the setup the driver already accepted.
+ */
+ term_err = rdev_nan_ndp_terminate(rdev, wdev, &terminate);
+ if (term_err)
+ wiphy_warn(&rdev->wiphy,
+ "failed to terminate NDP %u after reply error: %d (%d)\n",
+ params.ndp_id, err, term_err);
+ }
+
+ return err;
}
static int nl80211_nan_ndp_respond(struct sk_buff *skb,
@@ -18911,6 +18930,58 @@ static int nl80211_nan_ndp_respond(struct sk_buff *skb,
return rdev_nan_ndp_respond(rdev, wdev, ¶ms);
}
+static int nl80211_nan_ndp_terminate(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 nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+ struct cfg80211_nan_ndp_terminate params = {};
+ int err;
+
+ if (wdev->iftype != NL80211_IFTYPE_NAN) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP terminate requires NAN interface");
+ return -EOPNOTSUPP;
+ }
+
+ if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN NDP offload not supported by driver");
+ return -EOPNOTSUPP;
+ }
+
+ if (!info->attrs[NL80211_ATTR_MAC] ||
+ !info->attrs[NL80211_ATTR_NAN_NDP]) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP terminate requires peer NMI and NDP params");
+ return -EINVAL;
+ }
+
+ err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+ info->attrs[NL80211_ATTR_NAN_NDP],
+ nl80211_nan_ndp_policy,
+ info->extack);
+ if (err)
+ return err;
+
+ if (!tb[NL80211_NAN_NDP_ATTR_ID] ||
+ !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {
+ NL_SET_ERR_MSG(info->extack,
+ "NDP terminate requires NDP ID and INIT_NDI");
+ return -EINVAL;
+ }
+
+ params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+ params.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);
+ params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+
+ if (tb[NL80211_NAN_NDP_ATTR_REASON])
+ params.reason = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);
+
+ return rdev_nan_ndp_terminate(rdev, wdev, ¶ms);
+}
+
static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
{
if (!sched->n_channels)
@@ -22237,6 +22308,12 @@ static const struct genl_small_ops nl80211_small_ops[] = {
.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |
NL80211_FLAG_CLEAR_SKB),
},
+ {
+ .cmd = NL80211_CMD_NAN_NDP_TERMINATE,
+ .doit = nl80211_nan_ndp_terminate,
+ .flags = GENL_ADMIN_PERM,
+ .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+ },
};
static struct genl_family nl80211_fam __ro_after_init = {
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index c58b83210d60..3e4e0d768ae5 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1221,6 +1221,22 @@ rdev_nan_ndp_respond(struct cfg80211_registered_device *rdev,
return ret;
}
+static inline int
+rdev_nan_ndp_terminate(struct cfg80211_registered_device *rdev,
+ struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_terminate *params)
+{
+ int ret;
+
+ if (!rdev->ops->nan_ndp_terminate)
+ return -EOPNOTSUPP;
+
+ trace_rdev_nan_ndp_terminate(&rdev->wiphy, wdev, params);
+ ret = rdev->ops->nan_ndp_terminate(&rdev->wiphy, wdev, params);
+ trace_rdev_return_int(&rdev->wiphy, ret);
+ return ret;
+}
+
static inline int rdev_set_mac_acl(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct cfg80211_acl_data *params)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 8c5fdbe23747..a843b52cbcfc 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2737,6 +2737,33 @@ TRACE_EVENT(rdev_nan_ndp_respond,
#undef NDP_RESP_FMT_3
#undef NDP_RESP_FMT_4
+TRACE_EVENT(rdev_nan_ndp_terminate,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+ struct cfg80211_nan_ndp_terminate *params),
+ TP_ARGS(wiphy, wdev, params),
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ __array(u8, peer_nmi, ETH_ALEN)
+ __field(u8, ndp_id)
+ __array(u8, init_ndi, ETH_ALEN)
+ __field(u8, reason)
+ ),
+ TP_fast_assign(
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+ __entry->ndp_id = params->ndp_id;
+ memcpy(__entry->init_ndi, params->init_ndi, ETH_ALEN);
+ __entry->reason = params->reason;
+ ),
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ ", peer_nmi: %pM, ndp_id: %u, init_ndi: %pM, reason: %u",
+ WIPHY_PR_ARG, WDEV_PR_ARG,
+ __entry->peer_nmi, __entry->ndp_id, __entry->init_ndi,
+ __entry->reason)
+);
+
TRACE_EVENT(rdev_set_mac_acl,
TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
struct cfg80211_acl_data *params),
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 13/19] wifi: nl80211/cfg80211: add support for NDP request indication
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (11 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 12/19] wifi: nl80211/cfg80211: add support for NDP termination " Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 14/19] wifi: nl80211/cfg80211: add support for NDP status indication Shivani Baranwal
` (6 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Use NL80211_CMD_NAN_NDP_INITIATE to notify userspace when the device
receives an NDP Request from a peer. Provide the received request
parameters through cfg80211_nan_ndp_request() so userspace can choose
the responder NDI and accept or reject the request.
Carry transport port and protocol values received from the peer in the
request indication, so userspace can learn how to reach the peer
service. Validate the notification parameters, trace them without PMKID
bytes, and deliver the event to the NAN owner or multicast group.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 55 ++++++++++++++++++++
include/uapi/linux/nl80211.h | 9 +++-
net/wireless/nl80211.c | 99 ++++++++++++++++++++++++++++++++++++
net/wireless/trace.h | 83 ++++++++++++++++++++++++++++++
4 files changed, 245 insertions(+), 1 deletion(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index eda9a073422b..caff65d0c801 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4510,6 +4510,46 @@ struct cfg80211_nan_ndp_terminate {
u8 reason;
};
+/**
+ * struct cfg80211_nan_ndp_request_params - NAN NDP request event parameters
+ *
+ * Sent to userspace when the driver receives a NDP Request frame.
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID from the received frame
+ * @init_ndi: initiator NDI MAC from the received frame
+ * @publish_id: publisher's service instance ID
+ * @ssi: service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: initiator's cipher suite ID
+ * @pmkid: PMKID from the peer's SCIA attribute (16 bytes), or NULL if absent
+ * @gtk_required: if true, initiator requires GTK protection
+ * @gtk_cipher: GTK cipher suite ID, included when @gtk_required is true
+ * @ipv6_intf_id: initiator's IPv6 link-local interface identifier, or NULL
+ * if absent
+ * @transport_info: if true, the request contained transport information
+ * @transport_port: transport port received from the peer when
+ * @transport_info is true
+ * @transport_protocol: IANA protocol number received from the peer when
+ * @transport_info is true
+ */
+struct cfg80211_nan_ndp_request_params {
+ const u8 *peer_nmi;
+ u8 ndp_id;
+ const u8 *init_ndi;
+ u8 publish_id;
+ const u8 *ssi;
+ u8 ssi_len;
+ u32 cipher_suite;
+ const u8 *pmkid;
+ bool gtk_required;
+ u32 gtk_cipher;
+ const u8 *ipv6_intf_id;
+ bool transport_info;
+ u16 transport_port;
+ u8 transport_protocol;
+};
+
/**
* enum cfg80211_nan_conf_changes - indicates changed fields in NAN
* configuration
@@ -11674,6 +11714,21 @@ cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,
}
+/**
+ * cfg80211_nan_ndp_request - notify userspace of a received NDP request
+ * @wdev: the wireless device reporting the event
+ * @params: NDP request parameters parsed from the received frame
+ * @gfp: allocation flags
+ *
+ * Notify userspace that a NAN Data Path request was received from a peer.
+ * This starts a responder-side setup attempt; the driver reports its final
+ * result once, including on rejection, failure, or timeout. Only valid when
+ * %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_request_params *params,
+ gfp_t gfp);
+
/**
* cfg80211_incumbent_signal_notify - Notify userspace of incumbent signal detection
* @wiphy: the wiphy to use
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 54249b98fcc7..5c2dbe4f1463 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1593,6 +1593,12 @@
* Aware reason QoS_UNACCEPTABLE.
* Each accepted setup attempt completes asynchronously with exactly one
* %NL80211_CMD_NAN_NDP_STATUS notification, including on failure or timeout.
+ * This command is also used as a notification when an NDP Request is
+ * received from a peer. The notification carries %NL80211_ATTR_MAC and
+ * %NL80211_ATTR_NAN_NDP with the received parameters. Userspace must ensure
+ * the responder NDI exists before sending @NL80211_CMD_NAN_NDP_RESPOND.
+ * Each indicated request is a setup attempt and completes with exactly one
+ * %NL80211_CMD_NAN_NDP_STATUS notification, including on failure or timeout.
* @NL80211_CMD_NAN_NDP_RESPOND: Respond to a received NDP request as
* the responder. Requires %NL80211_NAN_CAPA_OFFLOAD_NDP. The NDI
* interface specified in %NL80211_NAN_NDP_ATTR_RESP_NDI must already
@@ -8212,7 +8218,8 @@ enum nl80211_nan_conf_attributes {
* %NL80211_CMD_NAN_NDP_INITIATE and in an accepting
* %NL80211_CMD_NAN_NDP_RESPOND. The driver carries these values in the NDPE
* Service Info TLV (Generic Service Protocol). If the peer does not support
- * NDPE, these values are not conveyed.
+ * NDPE, these values are not conveyed. Peer-request notifications include
+ * the pair when it was included by the peer.
* @NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL: u8 IANA protocol number. Must be
* supplied with @NL80211_NAN_NDP_ATTR_TRANSPORT_PORT.
* @NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS: optional u8 Minimum Time Slots field
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 571432435bfa..c9b7a5b4600a 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -18982,6 +18982,105 @@ static int nl80211_nan_ndp_terminate(struct sk_buff *skb,
return rdev_nan_ndp_terminate(rdev, wdev, ¶ms);
}
+static void nl80211_send_nan_ndp_event(struct wireless_dev *wdev,
+ struct sk_buff *msg, gfp_t gfp)
+{
+ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
+
+ if (wdev->owner_nlportid)
+ genlmsg_unicast(wiphy_net(&rdev->wiphy), msg,
+ wdev->owner_nlportid);
+ else
+ genlmsg_multicast_netns(&nl80211_fam, wiphy_net(&rdev->wiphy),
+ msg, 0, NL80211_MCGRP_NAN, gfp);
+}
+
+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_request_params *params,
+ gfp_t gfp)
+{
+ struct wiphy *wiphy = wdev->wiphy;
+ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+ struct nlattr *ndp_attr;
+ struct sk_buff *msg;
+ void *hdr;
+
+ if (WARN_ON_ONCE(!params->peer_nmi || !params->init_ndi ||
+ !params->ndp_id || wdev->iftype != NL80211_IFTYPE_NAN ||
+ !(wiphy->nan_capa.flags &
+ WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+ return;
+
+ trace_cfg80211_nan_ndp_request(wiphy, wdev, params);
+
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+ if (!msg)
+ return;
+
+ hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_INITIATE);
+ 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, params->peer_nmi))
+ goto nla_put_failure;
+
+ ndp_attr = nla_nest_start_noflag(msg, NL80211_ATTR_NAN_NDP);
+ if (!ndp_attr)
+ goto nla_put_failure;
+
+ if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+ nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+ params->init_ndi) ||
+ nla_put_u8(msg, NL80211_NAN_NDP_ATTR_PUBLISH_ID,
+ params->publish_id))
+ goto nla_put_failure;
+
+ if (params->ssi && params->ssi_len &&
+ nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params->ssi_len,
+ params->ssi))
+ goto nla_put_failure;
+
+ if (params->cipher_suite &&
+ nla_put_u32(msg, NL80211_NAN_NDP_ATTR_CIPHER_SUITE,
+ params->cipher_suite))
+ goto nla_put_failure;
+
+ if (params->pmkid &&
+ nla_put(msg, NL80211_NAN_NDP_ATTR_PMKID, WLAN_PMKID_LEN,
+ params->pmkid))
+ goto nla_put_failure;
+
+ if (params->gtk_required &&
+ (nla_put_flag(msg, NL80211_NAN_NDP_ATTR_GTK_REQUIRED) ||
+ nla_put_u32(msg, NL80211_NAN_NDP_ATTR_GTK_CIPHER,
+ params->gtk_cipher)))
+ goto nla_put_failure;
+
+ if (params->ipv6_intf_id &&
+ nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params->ipv6_intf_id))
+ goto nla_put_failure;
+
+ if (params->transport_info &&
+ (nla_put_u16(msg, NL80211_NAN_NDP_ATTR_TRANSPORT_PORT,
+ params->transport_port) ||
+ nla_put_u8(msg, NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL,
+ params->transport_protocol)))
+ goto nla_put_failure;
+
+ nla_nest_end(msg, ndp_attr);
+ genlmsg_end(msg, hdr);
+ nl80211_send_nan_ndp_event(wdev, msg, gfp);
+ return;
+
+nla_put_failure:
+ nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_request);
+
static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
{
if (!sched->n_channels)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index a843b52cbcfc..be7b3162c821 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -4690,6 +4690,89 @@ TRACE_EVENT(cfg80211_nan_cluster_joined,
__entry->new_cluster ? " [new]" : "")
);
+#define CFG80211_NDP_REQUEST_FMT_1 \
+ ", peer_nmi: %pM, ndp_id: %u, init_ndi: %pM, "
+#define CFG80211_NDP_REQUEST_FMT_2 \
+ "publish_id: %u, ssi_len: %u, ssi: %s, "
+#define CFG80211_NDP_REQUEST_FMT_3 \
+ "cipher_suite: %u, pmkid_present: %d, "
+#define CFG80211_NDP_REQUEST_FMT_4 \
+ "gtk_required: %d, gtk_cipher: %u, "
+#define CFG80211_NDP_REQUEST_FMT_5 \
+ "ipv6_intf_id_present: %d, ipv6_intf_id: %s"
+
+TRACE_EVENT(cfg80211_nan_ndp_request,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_request_params *params),
+ TP_ARGS(wiphy, wdev, params),
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ __array(u8, peer_nmi, ETH_ALEN)
+ __field(u8, ndp_id)
+ __array(u8, init_ndi, ETH_ALEN)
+ __field(u8, publish_id)
+ __field(u8, ssi_len)
+ __dynamic_array(u8, ssi, params->ssi_len)
+ __field(u32, cipher_suite)
+ __field(bool, pmkid_present)
+ __field(bool, gtk_required)
+ __field(u32, gtk_cipher)
+ __field(bool, transport_info)
+ __field(u16, transport_port)
+ __field(u8, transport_protocol)
+ __field(bool, ipv6_intf_id_present)
+ __array(u8, ipv6_intf_id, NL80211_NAN_NDP_IPV6_INTF_ID_LEN)
+ ),
+ TP_fast_assign(
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+ __entry->ndp_id = params->ndp_id;
+ memcpy(__entry->init_ndi, params->init_ndi, ETH_ALEN);
+ __entry->publish_id = params->publish_id;
+ __entry->ssi_len = params->ssi_len;
+ if (params->ssi && params->ssi_len)
+ memcpy(__get_dynamic_array(ssi), params->ssi,
+ params->ssi_len);
+ __entry->cipher_suite = params->cipher_suite;
+ __entry->pmkid_present = !!params->pmkid;
+ __entry->gtk_required = params->gtk_required;
+ __entry->gtk_cipher = params->gtk_cipher;
+ __entry->transport_info = params->transport_info;
+ __entry->transport_port = params->transport_port;
+ __entry->transport_protocol = params->transport_protocol;
+ __entry->ipv6_intf_id_present = !!params->ipv6_intf_id;
+ if (params->ipv6_intf_id)
+ memcpy(__entry->ipv6_intf_id, params->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ else
+ memset(__entry->ipv6_intf_id, 0,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ ),
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ CFG80211_NDP_REQUEST_FMT_1 CFG80211_NDP_REQUEST_FMT_2
+ CFG80211_NDP_REQUEST_FMT_3 CFG80211_NDP_REQUEST_FMT_4
+ CFG80211_NDP_REQUEST_FMT_5
+ ", transport_info: %d, transport_port: %u, transport_protocol: %u",
+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->peer_nmi, __entry->ndp_id,
+ __entry->init_ndi, __entry->publish_id, __entry->ssi_len,
+ __print_array(__get_dynamic_array(ssi), __entry->ssi_len,
+ sizeof(u8)),
+ __entry->cipher_suite, __entry->pmkid_present,
+ __entry->gtk_required, __entry->gtk_cipher,
+ __entry->ipv6_intf_id_present,
+ __print_array(__entry->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN, sizeof(u8)),
+ __entry->transport_info, __entry->transport_port,
+ __entry->transport_protocol)
+);
+#undef CFG80211_NDP_REQUEST_FMT_1
+#undef CFG80211_NDP_REQUEST_FMT_2
+#undef CFG80211_NDP_REQUEST_FMT_3
+#undef CFG80211_NDP_REQUEST_FMT_4
+#undef CFG80211_NDP_REQUEST_FMT_5
+
TRACE_EVENT(cfg80211_incumbent_signal_notify,
TP_PROTO(struct wiphy *wiphy,
const struct cfg80211_chan_def *chandef,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 14/19] wifi: nl80211/cfg80211: add support for NDP status indication
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (12 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 13/19] wifi: nl80211/cfg80211: add support for NDP request indication Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 15/19] wifi: nl80211/cfg80211: add support for NDP terminated indication Shivani Baranwal
` (5 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Add NL80211_CMD_NAN_NDP_STATUS to notify both NDP peers when setup
finishes. Use the ACCEPT flag to indicate successful setup and include
the responder NDI on success; report the rejection or failure reason
otherwise.
Add cfg80211_nan_ndp_status() and its parameter structure, validate the
notification parameters, trace the status without key material, and
deliver it to the NAN owner or multicast group. Include the transport
port and protocol received from the peer when present.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 53 +++++++++++++++++++++++
include/uapi/linux/nl80211.h | 23 ++++++++--
net/wireless/nl80211.c | 81 ++++++++++++++++++++++++++++++++++++
net/wireless/trace.h | 73 ++++++++++++++++++++++++++++++++
4 files changed, 226 insertions(+), 4 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index caff65d0c801..6c3902939132 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4550,6 +4550,43 @@ struct cfg80211_nan_ndp_request_params {
u8 transport_protocol;
};
+/**
+ * struct cfg80211_nan_ndp_status_params - NAN NDP status event parameters
+ *
+ * Sent exactly once to userspace for each NDP setup attempt, after the driver
+ * completes setup successfully, fails it, or times it out. This covers both
+ * locally initiated NDPs and peer requests reported to userspace.
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID
+ * @init_ndi: initiator NDI MAC address
+ * @resp_ndi: responder NDI MAC address (valid when @accepted is true)
+ * @accepted: if true, NDP setup succeeded; if false, setup failed
+ * @reason: Wi-Fi Aware reason code for failure (valid when @accepted is false)
+ * @ssi: response service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @ipv6_intf_id: peer's IPv6 link-local interface identifier, or NULL if absent
+ * @transport_info: if true, the peer included transport information
+ * @transport_port: transport port received from the peer when
+ * @transport_info is true
+ * @transport_protocol: IANA protocol number received from the peer when
+ * @transport_info is true
+ */
+struct cfg80211_nan_ndp_status_params {
+ const u8 *peer_nmi;
+ u8 ndp_id;
+ const u8 *init_ndi;
+ const u8 *resp_ndi;
+ bool accepted;
+ u8 reason;
+ const u8 *ssi;
+ u8 ssi_len;
+ const u8 *ipv6_intf_id;
+ bool transport_info;
+ u16 transport_port;
+ u8 transport_protocol;
+};
+
/**
* enum cfg80211_nan_conf_changes - indicates changed fields in NAN
* configuration
@@ -11729,6 +11766,22 @@ void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
const struct cfg80211_nan_ndp_request_params *params,
gfp_t gfp);
+/**
+ * cfg80211_nan_ndp_status - notify userspace that NDP setup is complete
+ * @wdev: the wireless device reporting the event
+ * @params: NDP status parameters
+ * @gfp: allocation flags
+ *
+ * Notify userspace that NAN Data Path setup is complete. Includes the
+ * setup status and, if successful, the responder NDI. Call exactly once for
+ * every locally initiated setup attempt and every indicated peer request,
+ * including failure and timeout (for example, when the peer does not respond).
+ * Only valid when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_status(struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_status_params *params,
+ gfp_t gfp);
+
/**
* cfg80211_incumbent_signal_notify - Notify userspace of incumbent signal detection
* @wiphy: the wiphy to use
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 5c2dbe4f1463..a0d0d77346d4 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1617,6 +1617,17 @@
* and optionally %NL80211_NAN_NDP_ATTR_REASON.
* The command reply acknowledges the request; teardown completion is
* reported asynchronously by the termination notification.
+ * @NL80211_CMD_NAN_NDP_STATUS: Notification-only event sent to userspace on
+ * the initiator and responder sides when NDP setup finishes, successfully or
+ * not. If %NL80211_NAN_NDP_ATTR_ACCEPT is present, setup succeeded and
+ * %NL80211_NAN_NDP_ATTR_RESP_NDI is present; otherwise the notification
+ * carries %NL80211_NAN_NDP_ATTR_REASON. Also carries %NL80211_ATTR_MAC and
+ * %NL80211_ATTR_NAN_NDP. Exactly one status notification is sent for each
+ * setup attempt, whether initiated locally or from an indicated peer request.
+ * It is sent after success, failure, or timeout, including when the peer does
+ * not respond.
+ * %NL80211_ATTR_NAN_NDP, including transport information when it was
+ * included by the peer.
*
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
@@ -1908,6 +1919,7 @@ enum nl80211_commands {
NL80211_CMD_NAN_NDP_INITIATE,
NL80211_CMD_NAN_NDP_RESPOND,
NL80211_CMD_NAN_NDP_TERMINATE,
+ NL80211_CMD_NAN_NDP_STATUS,
/* add new commands above here */
@@ -8218,8 +8230,8 @@ enum nl80211_nan_conf_attributes {
* %NL80211_CMD_NAN_NDP_INITIATE and in an accepting
* %NL80211_CMD_NAN_NDP_RESPOND. The driver carries these values in the NDPE
* Service Info TLV (Generic Service Protocol). If the peer does not support
- * NDPE, these values are not conveyed. Peer-request notifications include
- * the pair when it was included by the peer.
+ * NDPE, these values are not conveyed. Peer-request and status notifications
+ * include the pair when it was included by the peer.
* @NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL: u8 IANA protocol number. Must be
* supplied with @NL80211_NAN_NDP_ATTR_TRANSPORT_PORT.
* @NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS: optional u8 Minimum Time Slots field
@@ -8234,10 +8246,13 @@ enum nl80211_nan_conf_attributes {
* %NL80211_CMD_NAN_NDP_RESPOND.
* @NL80211_NAN_NDP_ATTR_ACCEPT: flag. If present in
* %NL80211_CMD_NAN_NDP_RESPOND, it accepts the request; if absent, it is
- * rejected.
+ * rejected. In %NL80211_CMD_NAN_NDP_STATUS it indicates setup succeeded and
+ * @NL80211_NAN_NDP_ATTR_RESP_NDI is present.
* @NL80211_NAN_NDP_ATTR_REASON: u8 Wi-Fi Aware reason code, not an IEEE 802.11
* reason code (%NL80211_ATTR_REASON_CODE). Used for rejection with
- * %NL80211_CMD_NAN_NDP_RESPOND.
+ * %NL80211_CMD_NAN_NDP_RESPOND, setup failure with
+ * %NL80211_CMD_NAN_NDP_STATUS, or termination with
+ * %NL80211_CMD_NAN_NDP_TERMINATE.
* @__NL80211_NAN_NDP_ATTR_LAST: Internal.
* @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute.
*/
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c9b7a5b4600a..f0f25aa71b22 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -19081,6 +19081,87 @@ void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
}
EXPORT_SYMBOL(cfg80211_nan_ndp_request);
+void cfg80211_nan_ndp_status(struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_status_params *params,
+ gfp_t gfp)
+{
+ struct wiphy *wiphy = wdev->wiphy;
+ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+ struct nlattr *ndp_attr;
+ struct sk_buff *msg;
+ void *hdr;
+
+ if (WARN_ON_ONCE(!params->peer_nmi || !params->init_ndi ||
+ !params->ndp_id || wdev->iftype != NL80211_IFTYPE_NAN ||
+ !(wiphy->nan_capa.flags &
+ WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+ return;
+
+ if (WARN_ON_ONCE(params->accepted && !params->resp_ndi))
+ return;
+
+ trace_cfg80211_nan_ndp_status(wiphy, wdev, params);
+
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+ if (!msg)
+ return;
+
+ hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_STATUS);
+ 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, params->peer_nmi))
+ goto nla_put_failure;
+
+ ndp_attr = nla_nest_start_noflag(msg, NL80211_ATTR_NAN_NDP);
+ if (!ndp_attr)
+ goto nla_put_failure;
+
+ if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+ nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+ params->init_ndi))
+ goto nla_put_failure;
+
+ if (params->accepted) {
+ if (nla_put_flag(msg, NL80211_NAN_NDP_ATTR_ACCEPT) ||
+ nla_put(msg, NL80211_NAN_NDP_ATTR_RESP_NDI, ETH_ALEN,
+ params->resp_ndi))
+ goto nla_put_failure;
+ } else if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON,
+ params->reason)) {
+ goto nla_put_failure;
+ }
+
+ if (params->ssi && params->ssi_len &&
+ nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params->ssi_len,
+ params->ssi))
+ goto nla_put_failure;
+
+ if (params->ipv6_intf_id &&
+ nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params->ipv6_intf_id))
+ goto nla_put_failure;
+
+ if (params->transport_info &&
+ (nla_put_u16(msg, NL80211_NAN_NDP_ATTR_TRANSPORT_PORT,
+ params->transport_port) ||
+ nla_put_u8(msg, NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL,
+ params->transport_protocol)))
+ goto nla_put_failure;
+
+ nla_nest_end(msg, ndp_attr);
+ genlmsg_end(msg, hdr);
+ nl80211_send_nan_ndp_event(wdev, msg, gfp);
+ return;
+
+nla_put_failure:
+ nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_status);
+
static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
{
if (!sched->n_channels)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index be7b3162c821..7c3d8b3ac94f 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -4773,6 +4773,79 @@ TRACE_EVENT(cfg80211_nan_ndp_request,
#undef CFG80211_NDP_REQUEST_FMT_4
#undef CFG80211_NDP_REQUEST_FMT_5
+#define CFG_NDP_STATUS_FMT_1 \
+ ", peer_nmi: %pM, ndp_id: %u, init_ndi: %pM, "
+#define CFG_NDP_STATUS_FMT_2 \
+ "resp_ndi: %pM, accepted: %d, reason: %u, ssi_len: %u, "
+#define CFG_NDP_STATUS_FMT_3 \
+ "ssi: %s, ipv6_intf_id_present: %d, ipv6_intf_id: %s"
+
+TRACE_EVENT(cfg80211_nan_ndp_status,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_status_params *params),
+ TP_ARGS(wiphy, wdev, params),
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ __array(u8, peer_nmi, ETH_ALEN)
+ __field(u8, ndp_id)
+ __array(u8, init_ndi, ETH_ALEN)
+ __array(u8, resp_ndi, ETH_ALEN)
+ __field(bool, accepted)
+ __field(u8, reason)
+ __field(u8, ssi_len)
+ __dynamic_array(u8, ssi, params->ssi_len)
+ __field(bool, transport_info)
+ __field(u16, transport_port)
+ __field(u8, transport_protocol)
+ __field(bool, ipv6_intf_id_present)
+ __array(u8, ipv6_intf_id, NL80211_NAN_NDP_IPV6_INTF_ID_LEN)
+ ),
+ TP_fast_assign(
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+ __entry->ndp_id = params->ndp_id;
+ memcpy(__entry->init_ndi, params->init_ndi, ETH_ALEN);
+ if (params->resp_ndi)
+ memcpy(__entry->resp_ndi, params->resp_ndi, ETH_ALEN);
+ else
+ memset(__entry->resp_ndi, 0, ETH_ALEN);
+ __entry->accepted = params->accepted;
+ __entry->reason = params->reason;
+ __entry->ssi_len = params->ssi_len;
+ if (params->ssi && params->ssi_len)
+ memcpy(__get_dynamic_array(ssi), params->ssi,
+ params->ssi_len);
+ __entry->transport_info = params->transport_info;
+ __entry->transport_port = params->transport_port;
+ __entry->transport_protocol = params->transport_protocol;
+ __entry->ipv6_intf_id_present = !!params->ipv6_intf_id;
+ if (params->ipv6_intf_id)
+ memcpy(__entry->ipv6_intf_id, params->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ else
+ memset(__entry->ipv6_intf_id, 0,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+ ),
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ CFG_NDP_STATUS_FMT_1 CFG_NDP_STATUS_FMT_2 CFG_NDP_STATUS_FMT_3
+ ", transport_info: %d, transport_port: %u, transport_protocol: %u",
+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->peer_nmi, __entry->ndp_id,
+ __entry->init_ndi, __entry->resp_ndi, __entry->accepted,
+ __entry->reason, __entry->ssi_len,
+ __print_array(__get_dynamic_array(ssi), __entry->ssi_len,
+ sizeof(u8)),
+ __entry->ipv6_intf_id_present,
+ __print_array(__entry->ipv6_intf_id,
+ NL80211_NAN_NDP_IPV6_INTF_ID_LEN, sizeof(u8)),
+ __entry->transport_info, __entry->transport_port,
+ __entry->transport_protocol)
+);
+#undef CFG_NDP_STATUS_FMT_1
+#undef CFG_NDP_STATUS_FMT_2
+#undef CFG_NDP_STATUS_FMT_3
+
TRACE_EVENT(cfg80211_incumbent_signal_notify,
TP_PROTO(struct wiphy *wiphy,
const struct cfg80211_chan_def *chandef,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 15/19] wifi: nl80211/cfg80211: add support for NDP terminated indication
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (13 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 14/19] wifi: nl80211/cfg80211: add support for NDP status indication Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 16/19] wifi: nl80211/cfg80211: support updating an offloaded NAN publish function Shivani Baranwal
` (4 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Use NL80211_CMD_NAN_NDP_TERMINATE to notify userspace when an NDP is
terminated. Include the NDP identity and reason, and add the
LOCALLY_GENERATED output flag to distinguish locally initiated
termination from peer-initiated termination.
Add the termination parameter and cfg80211 notification function,
validate and trace the event, and deliver it to the NAN owner or
multicast group.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 35 +++++++++++++++++++++++
include/uapi/linux/nl80211.h | 15 +++++++++-
net/wireless/nl80211.c | 54 ++++++++++++++++++++++++++++++++++++
net/wireless/trace.h | 29 +++++++++++++++++++
4 files changed, 132 insertions(+), 1 deletion(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 6c3902939132..99d8eb202f84 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4587,6 +4587,25 @@ struct cfg80211_nan_ndp_status_params {
u8 transport_protocol;
};
+/**
+ * struct cfg80211_nan_ndp_terminated_params - NAN NDP terminated event
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID
+ * @init_ndi: initiator NDI MAC address
+ * @reason: Wi-Fi Aware reason code for termination
+ * @locally_generated: if true, teardown was initiated or detected locally
+ * (userspace or device) rather than by a peer termination request. Includes
+ * NDI down/removal, NAN stop, and peer loss.
+ */
+struct cfg80211_nan_ndp_terminated_params {
+ const u8 *peer_nmi;
+ u8 ndp_id;
+ const u8 *init_ndi;
+ u8 reason;
+ bool locally_generated;
+};
+
/**
* enum cfg80211_nan_conf_changes - indicates changed fields in NAN
* configuration
@@ -11782,6 +11801,22 @@ void cfg80211_nan_ndp_status(struct wireless_dev *wdev,
const struct cfg80211_nan_ndp_status_params *params,
gfp_t gfp);
+/**
+ * cfg80211_nan_ndp_terminated - notify userspace that an NDP was terminated
+ * @wdev: the wireless device reporting the event
+ * @params: NDP termination parameters
+ * @gfp: allocation flags
+ *
+ * Notify userspace that a NAN Data Path was torn down. Call exactly once for
+ * each established NDP, including teardown due to NDI down/removal, NAN stop,
+ * or peer loss. Only valid when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ * The locally_generated field is true when teardown was initiated or detected
+ * locally (userspace or device), and false when the peer initiated it.
+ */
+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_terminated_params *params,
+ gfp_t gfp);
+
/**
* cfg80211_incumbent_signal_notify - Notify userspace of incumbent signal detection
* @wiphy: the wiphy to use
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index a0d0d77346d4..b498d5ef094c 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1617,6 +1617,13 @@
* and optionally %NL80211_NAN_NDP_ATTR_REASON.
* The command reply acknowledges the request; teardown completion is
* reported asynchronously by the termination notification.
+ * This command is also used as a notification when an NDP is terminated.
+ * The notification carries %NL80211_ATTR_MAC and %NL80211_ATTR_NAN_NDP with
+ * %NL80211_NAN_NDP_ATTR_ID, %NL80211_NAN_NDP_ATTR_INIT_NDI,
+ * %NL80211_NAN_NDP_ATTR_REASON, and, when applicable,
+ * %NL80211_NAN_NDP_ATTR_LOCALLY_GENERATED. Exactly one notification is sent
+ * for each established NDP that terminates, including teardown due to NDI
+ * down/removal, NAN stop, or peer loss.
* @NL80211_CMD_NAN_NDP_STATUS: Notification-only event sent to userspace on
* the initiator and responder sides when NDP setup finishes, successfully or
* not. If %NL80211_NAN_NDP_ATTR_ACCEPT is present, setup succeeded and
@@ -8252,7 +8259,12 @@ enum nl80211_nan_conf_attributes {
* reason code (%NL80211_ATTR_REASON_CODE). Used for rejection with
* %NL80211_CMD_NAN_NDP_RESPOND, setup failure with
* %NL80211_CMD_NAN_NDP_STATUS, or termination with
- * %NL80211_CMD_NAN_NDP_TERMINATE.
+ * %NL80211_CMD_NAN_NDP_TERMINATE, including its termination notification.
+ * @NL80211_NAN_NDP_ATTR_LOCALLY_GENERATED: output-only flag, present in the
+ * termination notification when teardown was initiated or detected locally
+ * (by userspace or the device), rather than by a peer termination request.
+ * This includes teardown on NDI down/removal, NAN stop, and peer loss; the
+ * flag is absent when the peer initiated termination.
* @__NL80211_NAN_NDP_ATTR_LAST: Internal.
* @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute.
*/
@@ -8277,6 +8289,7 @@ enum nl80211_nan_ndp_attributes {
NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY,
NL80211_NAN_NDP_ATTR_ACCEPT,
NL80211_NAN_NDP_ATTR_REASON,
+ NL80211_NAN_NDP_ATTR_LOCALLY_GENERATED,
/* keep last */
__NL80211_NAN_NDP_ATTR_LAST,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f0f25aa71b22..f32ae55797a5 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -19162,6 +19162,60 @@ void cfg80211_nan_ndp_status(struct wireless_dev *wdev,
}
EXPORT_SYMBOL(cfg80211_nan_ndp_status);
+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_terminated_params *params,
+ gfp_t gfp)
+{
+ struct wiphy *wiphy = wdev->wiphy;
+ struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+ struct nlattr *ndp_attr;
+ struct sk_buff *msg;
+ void *hdr;
+
+ if (WARN_ON_ONCE(!params->peer_nmi || !params->init_ndi ||
+ !params->ndp_id || wdev->iftype != NL80211_IFTYPE_NAN ||
+ !(wiphy->nan_capa.flags &
+ WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+ return;
+
+ trace_cfg80211_nan_ndp_terminated(wiphy, wdev, params);
+
+ msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+ if (!msg)
+ return;
+
+ hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_TERMINATE);
+ 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, params->peer_nmi))
+ goto nla_put_failure;
+
+ ndp_attr = nla_nest_start_noflag(msg, NL80211_ATTR_NAN_NDP);
+ if (!ndp_attr)
+ goto nla_put_failure;
+
+ if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+ nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+ params->init_ndi) ||
+ nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON, params->reason) ||
+ (params->locally_generated &&
+ nla_put_flag(msg, NL80211_NAN_NDP_ATTR_LOCALLY_GENERATED)))
+ goto nla_put_failure;
+
+ nla_nest_end(msg, ndp_attr);
+ genlmsg_end(msg, hdr);
+ nl80211_send_nan_ndp_event(wdev, msg, gfp);
+ return;
+
+nla_put_failure:
+ nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_terminated);
+
static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
{
if (!sched->n_channels)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 7c3d8b3ac94f..b7e1eaa061c8 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -4846,6 +4846,35 @@ TRACE_EVENT(cfg80211_nan_ndp_status,
#undef CFG_NDP_STATUS_FMT_2
#undef CFG_NDP_STATUS_FMT_3
+TRACE_EVENT(cfg80211_nan_ndp_terminated,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const struct cfg80211_nan_ndp_terminated_params *params),
+ TP_ARGS(wiphy, wdev, params),
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ __array(u8, peer_nmi, ETH_ALEN)
+ __field(u8, ndp_id)
+ __array(u8, init_ndi, ETH_ALEN)
+ __field(u8, reason)
+ __field(bool, locally_generated)
+ ),
+ TP_fast_assign(
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+ __entry->ndp_id = params->ndp_id;
+ memcpy(__entry->init_ndi, params->init_ndi, ETH_ALEN);
+ __entry->reason = params->reason;
+ __entry->locally_generated = params->locally_generated;
+ ),
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ ", peer_nmi: %pM, ndp_id: %u, init_ndi: %pM, reason: %u, locally_generated: %d",
+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->peer_nmi,
+ __entry->ndp_id, __entry->init_ndi, __entry->reason,
+ __entry->locally_generated)
+);
+
TRACE_EVENT(cfg80211_incumbent_signal_notify,
TP_PROTO(struct wiphy *wiphy,
const struct cfg80211_chan_def *chandef,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 16/19] wifi: nl80211/cfg80211: support updating an offloaded NAN publish function
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (14 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 15/19] wifi: nl80211/cfg80211: add support for NDP terminated indication Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 17/19] wifi: nl80211/cfg80211: allow extra NAN attributes in offloaded functions Shivani Baranwal
` (3 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
With an offloaded NAN Discovery Engine, userspace may need to change the
service-specific information of an active publish function.
Add a separate NL80211_CMD_UPDATE_NAN_PUBLISH command, identified only
by a non-zero cookie, to update the service-specific information as
specified by the UpdatePublish method in Wi-Fi Aware v4.0, section
4.1.1.1. A zero-length value clears the information. All other function
parameters remain unchanged, and the update does not change the
remaining lifetime (TTL).
Keep NL80211_CMD_ADD_NAN_FUNCTION semantics unchanged for existing
drivers. Advertise the new command in the supported-commands list when
the driver provides the update callback.
As a new command, it uses strict netlink validation: generic netlink
rejects relaxed validation flags for commands at or above the family's
resv_start_op, which would make registration of the nl80211 family
fail.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 23 ++++++++++++
include/uapi/linux/nl80211.h | 8 ++++
net/wireless/nl80211.c | 71 ++++++++++++++++++++++++++++++++++++
net/wireless/rdev-ops.h | 16 ++++++++
net/wireless/trace.h | 22 +++++++++++
5 files changed, 140 insertions(+)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 99d8eb202f84..e44c5da96ece 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4735,6 +4735,21 @@ struct cfg80211_nan_func {
bool range_report;
};
+/**
+ * struct cfg80211_nan_update_publish - update NAN publish service info
+ *
+ * @cookie: non-zero cookie of the active publish function to update
+ * @serv_spec_info: replacement service-specific information. The pointer is
+ * valid only for the duration of the callback and must not be retained.
+ * @serv_spec_info_len: length of @serv_spec_info. A zero length clears the
+ * current service-specific information.
+ */
+struct cfg80211_nan_update_publish {
+ u64 cookie;
+ const u8 *serv_spec_info;
+ u8 serv_spec_info_len;
+};
+
/**
* struct cfg80211_pmk_conf - PMK configuration
*
@@ -5564,6 +5579,11 @@ struct mgmt_frame_regs {
* cfg80211_free_nan_func().
* On success the driver should assign an instance_id in the
* provided @nan_func.
+ * @nan_update_publish: Update the service-specific information of an active
+ * NAN publish function identified by the cookie in @params. Return -ENOENT if
+ * the cookie does not identify an active publish function of this wdev;
+ * subscribe functions cannot be updated. The service-info pointer is valid
+ * only for the duration of the callback.
* @del_nan_func: Delete a NAN function.
* @nan_change_conf: changes NAN configuration. The changed parameters must
* be specified in @changes (using &enum cfg80211_nan_conf_changes);
@@ -6012,6 +6032,9 @@ struct cfg80211_ops {
void (*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);
int (*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
struct cfg80211_nan_func *nan_func);
+ int (*nan_update_publish)(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ const struct cfg80211_nan_update_publish *params);
void (*del_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,
u64 cookie);
int (*nan_change_conf)(struct wiphy *wiphy,
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index b498d5ef094c..e6172abab0d6 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1175,6 +1175,13 @@
* This command is also used as a notification sent when a NAN function is
* terminated. This will contain a %NL80211_ATTR_NAN_FUNC_INST_ID
* and %NL80211_ATTR_COOKIE attributes.
+ * @NL80211_CMD_UPDATE_NAN_PUBLISH: Update only the service-specific
+ * information of an active NAN publish function. The function is identified
+ * by a non-zero %NL80211_ATTR_COOKIE. Supply the new information as
+ * %NL80211_NAN_FUNC_SERVICE_INFO nested in %NL80211_ATTR_NAN_FUNC. A
+ * zero-length service-info attribute clears the current value. All other
+ * function parameters remain unchanged, and the update does not change the
+ * function's remaining lifetime (TTL).
* @NL80211_CMD_CHANGE_NAN_CONFIG: Change current NAN
* configuration. NAN must be operational (%NL80211_CMD_START_NAN
* was executed). It must contain at least one of the following
@@ -1927,6 +1934,7 @@ enum nl80211_commands {
NL80211_CMD_NAN_NDP_RESPOND,
NL80211_CMD_NAN_NDP_TERMINATE,
NL80211_CMD_NAN_NDP_STATUS,
+ NL80211_CMD_UPDATE_NAN_PUBLISH,
/* add new commands above here */
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index f32ae55797a5..c74386dc6e01 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -3538,6 +3538,7 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,
if (rdev->wiphy.flags & WIPHY_FLAG_SMD_TRANSITION_CLIENT)
CMD(execute_st, EXECUTE_SMD_TRANSITION);
+ CMD(nan_update_publish, UPDATE_NAN_PUBLISH);
}
#undef CMD
@@ -17908,6 +17909,69 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
return -ENOBUFS;
}
+static int nl80211_nan_update_publish(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 nlattr *tb[NUM_NL80211_NAN_FUNC_ATTR];
+ struct nlattr *func_attr, *attr;
+ struct cfg80211_nan_update_publish params = {};
+ int rem, err;
+
+ if (wdev->iftype != NL80211_IFTYPE_NAN)
+ return -EOPNOTSUPP;
+
+ if (!wdev_running(wdev))
+ return -ENOTCONN;
+
+ if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
+ NL_SET_ERR_MSG(info->extack,
+ "NAN Discovery Engine is in userspace");
+ return -EOPNOTSUPP;
+ }
+
+ if (!info->attrs[NL80211_ATTR_COOKIE] ||
+ !info->attrs[NL80211_ATTR_NAN_FUNC])
+ return -EINVAL;
+
+ params.cookie = nla_get_u64(info->attrs[NL80211_ATTR_COOKIE]);
+ if (!params.cookie) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ info->attrs[NL80211_ATTR_COOKIE],
+ "NAN publish cookie must be non-zero");
+ return -EINVAL;
+ }
+
+ func_attr = info->attrs[NL80211_ATTR_NAN_FUNC];
+ nla_for_each_nested(attr, func_attr, rem) {
+ if (nla_type(attr) == NL80211_NAN_FUNC_SERVICE_INFO)
+ continue;
+
+ NL_SET_ERR_MSG_ATTR(info->extack, attr,
+ "Only service-specific information can be updated");
+ return -EINVAL;
+ }
+
+ err = nla_parse_nested(tb, NL80211_NAN_FUNC_ATTR_MAX, func_attr,
+ nl80211_nan_func_policy, info->extack);
+ if (err)
+ return err;
+
+ if (!tb[NL80211_NAN_FUNC_SERVICE_INFO]) {
+ NL_SET_ERR_MSG_ATTR(info->extack, func_attr,
+ "Service-specific information is required");
+ return -EINVAL;
+ }
+
+ params.serv_spec_info =
+ nla_data(tb[NL80211_NAN_FUNC_SERVICE_INFO]);
+ params.serv_spec_info_len =
+ nla_len(tb[NL80211_NAN_FUNC_SERVICE_INFO]);
+
+ return rdev_nan_update_publish(rdev, wdev, ¶ms);
+}
+
static int nl80211_nan_del_func(struct sk_buff *skb,
struct genl_info *info)
{
@@ -22184,6 +22248,13 @@ static const struct genl_small_ops nl80211_small_ops[] = {
.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |
NL80211_FLAG_CLEAR_SKB),
},
+ {
+ .cmd = NL80211_CMD_UPDATE_NAN_PUBLISH,
+ .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
+ .doit = nl80211_nan_update_publish,
+ .flags = GENL_ADMIN_PERM,
+ .internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+ },
{
.cmd = NL80211_CMD_DEL_NAN_FUNCTION,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index 3e4e0d768ae5..5dd95091977e 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1096,6 +1096,22 @@ rdev_add_nan_func(struct cfg80211_registered_device *rdev,
return ret;
}
+static inline int
+rdev_nan_update_publish(struct cfg80211_registered_device *rdev,
+ struct wireless_dev *wdev,
+ const struct cfg80211_nan_update_publish *params)
+{
+ int ret;
+
+ trace_rdev_nan_update_publish(&rdev->wiphy, wdev, params);
+ if (rdev->ops->nan_update_publish)
+ ret = rdev->ops->nan_update_publish(&rdev->wiphy, wdev, params);
+ else
+ ret = -EOPNOTSUPP;
+ trace_rdev_return_int(&rdev->wiphy, ret);
+ return ret;
+}
+
static inline void rdev_del_nan_func(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev, u64 cookie)
{
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index b7e1eaa061c8..0b0bef1e8cb7 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2460,6 +2460,28 @@ TRACE_EVENT(rdev_add_nan_func,
__entry->cookie)
);
+TRACE_EVENT(rdev_nan_update_publish,
+ TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+ const struct cfg80211_nan_update_publish *params),
+ TP_ARGS(wiphy, wdev, params),
+ TP_STRUCT__entry(
+ WIPHY_ENTRY
+ WDEV_ENTRY
+ __field(u64, cookie)
+ __field(u8, serv_spec_info_len)
+ ),
+ TP_fast_assign(
+ WIPHY_ASSIGN;
+ WDEV_ASSIGN;
+ __entry->cookie = params->cookie;
+ __entry->serv_spec_info_len = params->serv_spec_info_len;
+ ),
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ ", cookie=%llu, ssi_len=%u",
+ WIPHY_PR_ARG, WDEV_PR_ARG, __entry->cookie,
+ __entry->serv_spec_info_len)
+);
+
TRACE_EVENT(rdev_del_nan_func,
TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
u64 cookie),
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 17/19] wifi: nl80211/cfg80211: allow extra NAN attributes in offloaded functions
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (15 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 16/19] wifi: nl80211/cfg80211: support updating an offloaded NAN publish function Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 18/19] wifi: nl80211/cfg80211: add NAN group key capabilities to NAN functions Shivani Baranwal
` (2 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
From: Vinay Gannevaram <vganneva@qti.qualcomm.com>
With an offloaded NAN Discovery Engine the device builds and transmits
the Service Discovery Frames, so everything that goes into them has to
be expressed with function attributes. NAN pairing, however, can be
handled in user space: the PASN Authentication frames, the bootstrapping
frames and the Follow-up messages with the Shared Key Descriptor
attribute are built by user space and sent with NL80211_CMD_FRAME. For
pairing verification, the NAN Identity Resolution attribute, which user
space derives from its NAN Identity Key, must also be included in the
Publish and Subscribe messages that the device transmits in the
discovery windows.
Add NL80211_NAN_FUNC_EXTRA_ATTRS to pass a list of complete NAN
attributes that the device appends to the frames of the function. This
keeps pairing, and the NAN Identity Key, in user space.
Validate the attribute framing, bound the length like information
elements, and only accept the attribute if the driver advertises
NL80211_NAN_CAPA_FUNC_EXTRA_ATTRS.
Signed-off-by: Vinay Gannevaram <vganneva@qti.qualcomm.com>
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 14 ++++++++
include/uapi/linux/nl80211.h | 15 +++++++++
net/wireless/core.c | 4 +++
net/wireless/nl80211.c | 63 ++++++++++++++++++++++++++++++++++++
net/wireless/trace.h | 9 ++++--
net/wireless/util.c | 1 +
6 files changed, 103 insertions(+), 3 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index e44c5da96ece..0964301473e1 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4690,6 +4690,14 @@ struct cfg80211_nan_func_filter {
* @chandef: channel definition for FTM ranging.
* @range_report: if true, a NAN Ranging Report is required after the FTM
* session.
+ * @extra_attrs: additional NAN attributes to append to the Service Discovery
+ * Frames transmitted for this function. It must not contain attributes that
+ * the device adds itself, such as the Service Descriptor attribute or
+ * attributes derived from other function fields. Typical uses include the
+ * NAN Identity Resolution attribute for pairing verification in Publish and
+ * Subscribe messages. The driver is responsible for ensuring the resulting
+ * frame fits its supported limits.
+ * @extra_attrs_len: length of @extra_attrs.
*/
struct cfg80211_nan_func {
enum nl80211_nan_function_type type;
@@ -4733,6 +4741,8 @@ struct cfg80211_nan_func {
bool chandef_valid;
struct cfg80211_chan_def chandef;
bool range_report;
+ const u8 *extra_attrs;
+ u16 extra_attrs_len;
};
/**
@@ -6787,6 +6797,9 @@ struct wiphy_radio {
* cfg80211_nan_ndp_request(), cfg80211_nan_ndp_status(), and
* cfg80211_nan_ndp_terminated(). Secure NDPs require
* %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @WIPHY_NAN_FLAGS_FUNC_EXTRA_ATTRS: Driver accepts additional per-function
+ * NAN attributes when the Discovery Engine is offloaded. This flag cannot
+ * be used with %WIPHY_NAN_FLAGS_USERSPACE_DE.
*/
enum wiphy_nan_flags {
WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),
@@ -6794,6 +6807,7 @@ enum wiphy_nan_flags {
WIPHY_NAN_FLAGS_INSTANT_COMM = BIT(2),
WIPHY_NAN_FLAGS_OFFLOAD_RANGING = BIT(3),
WIPHY_NAN_FLAGS_OFFLOAD_NDP = BIT(4),
+ WIPHY_NAN_FLAGS_FUNC_EXTRA_ATTRS = BIT(5),
};
/**
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index e6172abab0d6..2581b7328867 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -7980,6 +7980,15 @@ enum nl80211_nan_func_term_reason {
* using top-level attributes like %NL80211_ATTR_WIPHY_FREQ etc.
* @NL80211_NAN_FUNC_RANGE_REPORT: flag indicating that a NAN Ranging
* Report is required after the FTM session.
+ * @NL80211_NAN_FUNC_EXTRA_ATTRS: binary attribute containing additional NAN
+ * attributes to append to Service Discovery Frames transmitted for this
+ * function. Each attribute is encoded as a one-octet ID, a two-octet
+ * little-endian length, and that many body octets. It must not contain
+ * attributes that the device adds itself, such as the Service Descriptor
+ * attribute or attributes derived from other function attributes. Typical
+ * uses include the NAN Identity Resolution attribute for pairing
+ * verification in Publish and Subscribe messages. Requires
+ * %NL80211_NAN_CAPA_FUNC_EXTRA_ATTRS.
*
* @NUM_NL80211_NAN_FUNC_ATTR: internal
* @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute
@@ -8016,6 +8025,7 @@ enum nl80211_nan_func_attributes {
NL80211_NAN_FUNC_PREAMBLE,
NL80211_NAN_FUNC_CHAN,
NL80211_NAN_FUNC_RANGE_REPORT,
+ NL80211_NAN_FUNC_EXTRA_ATTRS,
/* keep last */
NUM_NL80211_NAN_FUNC_ATTR,
@@ -9564,6 +9574,10 @@ enum nl80211_s1g_short_beacon_attrs {
* and termination with %NL80211_CMD_NAN_NDP_INITIATE,
* %NL80211_CMD_NAN_NDP_STATUS, and %NL80211_CMD_NAN_NDP_TERMINATE.
* Secure NDPs additionally require %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_CAPA_FUNC_EXTRA_ATTRS: flag attribute. The device accepts
+ * %NL80211_NAN_FUNC_EXTRA_ATTRS for NAN functions when the NAN Discovery
+ * Engine is offloaded. This capability is not available when
+ * %NL80211_NAN_CAPA_USERSPACE_DE is set.
* @__NL80211_NAN_CAPABILITIES_LAST: Internal
* @NL80211_NAN_CAPABILITIES_MAX: Highest NAN capability attribute.
*/
@@ -9580,6 +9594,7 @@ enum nl80211_nan_capabilities {
NL80211_NAN_CAPA_INSTANT_COMM,
NL80211_NAN_CAPA_OFFLOAD_RANGING,
NL80211_NAN_CAPA_OFFLOAD_NDP,
+ NL80211_NAN_CAPA_FUNC_EXTRA_ATTRS,
/* keep last */
__NL80211_NAN_CAPABILITIES_LAST,
NL80211_NAN_CAPABILITIES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 00e97ca901e2..1326786b058b 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -935,6 +935,10 @@ int wiphy_register(struct wiphy *wiphy)
!rdev->ops->add_nan_func || !rdev->ops->del_nan_func ||
!(wiphy->nan_supported_bands & BIT(NL80211_BAND_2GHZ)))))
return -EINVAL;
+ if (WARN_ON((wiphy->nan_capa.flags &
+ WIPHY_NAN_FLAGS_FUNC_EXTRA_ATTRS) &&
+ (wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE)))
+ return -EINVAL;
if (WARN_ON((wiphy->interface_modes & BIT(NL80211_IFTYPE_NAN_DATA)) &&
(!wiphy->nan_capa.phy.ht.ht_supported || wiphy->n_radio > 1)))
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c74386dc6e01..1856b9cd3f1c 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -479,6 +479,42 @@ static int validate_nan_pmk(const struct nlattr *attr,
return 0;
}
+static int validate_nan_func_extra_attrs(const struct nlattr *attr,
+ struct netlink_ext_ack *extack)
+{
+ const u8 *data = nla_data(attr);
+ unsigned int len = nla_len(attr);
+ unsigned int pos = 0;
+
+ if (!len) {
+ NL_SET_ERR_MSG_ATTR(extack, attr,
+ "NAN function extra attributes must not be empty");
+ return -EINVAL;
+ }
+
+ while (pos < len) {
+ u16 attr_len;
+
+ if (len - pos < 3) {
+ NL_SET_ERR_MSG_ATTR(extack, attr,
+ "NAN function extra attribute has a truncated header");
+ return -EINVAL;
+ }
+
+ attr_len = get_unaligned_le16(data + pos + 1);
+ pos += 3;
+ if (attr_len > len - pos) {
+ NL_SET_ERR_MSG_ATTR(extack, attr,
+ "NAN function extra attribute length exceeds remaining data");
+ return -EINVAL;
+ }
+
+ pos += attr_len;
+ }
+
+ return 0;
+}
+
static int validate_nan_avail_blob(const struct nlattr *attr,
struct netlink_ext_ack *extack)
{
@@ -1437,6 +1473,10 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = {
NL80211_PREAMBLE_HE),
[NL80211_NAN_FUNC_CHAN] = NLA_POLICY_NESTED(nl80211_policy),
[NL80211_NAN_FUNC_RANGE_REPORT] = { .type = NLA_FLAG },
+ [NL80211_NAN_FUNC_EXTRA_ATTRS] =
+ NLA_POLICY_VALIDATE_FN(NLA_BINARY,
+ validate_nan_func_extra_attrs,
+ IEEE80211_MAX_DATA_LEN),
};
/* policy for Service Response Filter attributes */
@@ -3258,6 +3298,10 @@ static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)
nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))
goto fail;
+ if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_FUNC_EXTRA_ATTRS) &&
+ nla_put_flag(msg, NL80211_NAN_CAPA_FUNC_EXTRA_ATTRS))
+ goto fail;
+
if (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE,
wiphy->nan_capa.op_mode) ||
nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS,
@@ -17719,6 +17763,25 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
goto out;
}
+ if (tb[NL80211_NAN_FUNC_EXTRA_ATTRS]) {
+ if (!(wdev->wiphy->nan_capa.flags &
+ WIPHY_NAN_FLAGS_FUNC_EXTRA_ATTRS)) {
+ NL_SET_ERR_MSG(info->extack,
+ "Extra NAN function attributes are not supported");
+ err = -EOPNOTSUPP;
+ goto out;
+ }
+
+ func->extra_attrs_len = nla_len(tb[NL80211_NAN_FUNC_EXTRA_ATTRS]);
+ func->extra_attrs =
+ kmemdup(nla_data(tb[NL80211_NAN_FUNC_EXTRA_ATTRS]),
+ func->extra_attrs_len, GFP_KERNEL);
+ if (!func->extra_attrs) {
+ err = -ENOMEM;
+ goto out;
+ }
+ }
+
func->data_path_required =
nla_get_flag(tb[NL80211_NAN_FUNC_DATA_PATH_REQUIRED]);
func->security_required =
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 0b0bef1e8cb7..85eb81d0d87f 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2448,16 +2448,19 @@ TRACE_EVENT(rdev_add_nan_func,
WDEV_ENTRY
__field(u8, func_type)
__field(u64, cookie)
+ __field(u16, extra_attrs_len)
),
TP_fast_assign(
WIPHY_ASSIGN;
WDEV_ASSIGN;
__entry->func_type = func->type;
- __entry->cookie = func->cookie
+ __entry->cookie = func->cookie;
+ __entry->extra_attrs_len = func->extra_attrs_len;
),
- TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT ", type=%u, cookie=%llu",
+ TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+ ", type=%u, cookie=%llu, extra_attrs_len=%u",
WIPHY_PR_ARG, WDEV_PR_ARG, __entry->func_type,
- __entry->cookie)
+ __entry->cookie, __entry->extra_attrs_len)
);
TRACE_EVENT(rdev_nan_update_publish,
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 980b16c72d4f..4e1cbe50af1e 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -2876,6 +2876,7 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f)
return;
kfree(f->serv_spec_info);
+ kfree(f->extra_attrs);
kfree(f->srf_bf);
kfree(f->srf_macs);
kfree(f->csids);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 18/19] wifi: nl80211/cfg80211: add NAN group key capabilities to NAN functions
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (16 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 17/19] wifi: nl80211/cfg80211: allow extra NAN attributes in offloaded functions Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-13 10:22 ` [PATCH wireless-next v3 19/19] wifi: nl80211/cfg80211: select the 5 GHz NAN channel for IC Shivani Baranwal
2026-11-17 20:05 ` [syzbot ci] Re: wifi: cfg80211/nl80211: add NAN offload support syzbot ci
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
From: Vinay Gannevaram <vganneva@qti.qualcomm.com>
A NAN service advertises in its Cipher Suite Info attribute whether it
supports group keys (GTK and IGTK, optionally BIGTK) and whether IGTK
and BIGTK use NCS-BIP-GMAC-256 instead of NCS-BIP-CMAC-128. With an
offloaded Discovery Engine and NDP setup, the device builds this
attribute for the Service Discovery Frames of the function and for the
NDP setup frames, and it distributes and installs the group keys during
NDP setup. So far, NDP offload only covers the GTK, which is requested
per NDP.
Add NL80211_NAN_FUNC_GROUP_KEYS and NL80211_NAN_FUNC_BIP_GMAC_256 to
configure the group-key support of a function. The device also uses it
for NDPs of the service and establishes the group keys that both peers
support; the per-NDP GTK requirement and GTK cipher are unchanged. Use
typed attributes rather than the raw capability field, whose other bits,
such as the number of replay counters, are properties of the device.
Signed-off-by: Vinay Gannevaram <vganneva@qti.qualcomm.com>
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 37 +++++++++++++++++++++++++++---------
include/uapi/linux/nl80211.h | 34 ++++++++++++++++++++++++++++++---
net/wireless/nl80211.c | 18 ++++++++++++++++++
3 files changed, 77 insertions(+), 12 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 0964301473e1..9aae48c2b95d 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4404,7 +4404,8 @@ struct cfg80211_nan_peer_sched {
* @pmk_len: length of @pmk in bytes
* @pmkid: PMKID (16 octets) to include in the NDP Request, or NULL if absent
* @gtk_required: if true, GTK protection is required for group-addressed data
- * frames
+ * frames. IGTK and BIGTK follow the service group-key support, see
+ * &struct cfg80211_nan_func.group_keys.
* @gtk_cipher: GTK cipher suite ID, valid when @gtk_required is true
* @ipv6_intf_id: IPv6 link-local interface identifier, or NULL if absent
* @ndp_id: output NDP ID assigned by the driver on success (1-255)
@@ -4459,7 +4460,8 @@ struct cfg80211_nan_ndp_initiate {
* @cipher_suite and %NL80211_EXT_FEATURE_SECURE_NAN.
* @pmk_len: length of @pmk in bytes
* @gtk_required: if true, GTK protection is required for group-addressed data
- * frames
+ * frames. IGTK and BIGTK follow the service group-key support, see
+ * &struct cfg80211_nan_func.group_keys.
* @gtk_cipher: GTK cipher suite ID, valid when @gtk_required is true
* @ipv6_intf_id: IPv6 link-local interface identifier, or NULL if absent
* @transport_info: if true, convey @transport_port and @transport_protocol to
@@ -4523,7 +4525,9 @@ struct cfg80211_nan_ndp_terminate {
* @ssi_len: length of @ssi
* @cipher_suite: initiator's cipher suite ID
* @pmkid: PMKID from the peer's SCIA attribute (16 bytes), or NULL if absent
- * @gtk_required: if true, initiator requires GTK protection
+ * @gtk_required: if true, the initiator requires GTK protection. IGTK and
+ * BIGTK follow the service group-key support, see
+ * &struct cfg80211_nan_func.group_keys.
* @gtk_cipher: GTK cipher suite ID, included when @gtk_required is true
* @ipv6_intf_id: initiator's IPv6 link-local interface identifier, or NULL
* if absent
@@ -4668,7 +4672,20 @@ struct cfg80211_nan_func_filter {
* @security_required: if true, the SDEA Security Required bit is set. Requires
* @data_path_required and %NL80211_EXT_FEATURE_SECURE_NAN.
* @gtk_required: if true, the SDEA GTK Required bit is set for GTK protection
- * of group-addressed data frames. Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * of group-addressed data frames. This is independent of @group_keys, which
+ * advertises service group-key support. Requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @group_keys: group-key support of the service, advertised in the Cipher
+ * Suite Info attribute of the Service Discovery Frames of this function, as
+ * defined by &enum nl80211_nan_group_keys. With
+ * %WIPHY_NAN_FLAGS_OFFLOAD_NDP the device also uses it for NDPs of the
+ * service: it advertises it in NDP setup frames (an NDP initiator uses its
+ * subscribe function) and establishes the group keys that both peers
+ * support. If zero, no group-key support is advertised. Requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @bip_gmac_256: if true, IGTK and BIGTK use NCS-BIP-GMAC-256 instead of
+ * NCS-BIP-CMAC-128. Requires @group_keys and
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
* @pairing_bootstrap_methods: bitmap of supported NAN pairing
* bootstrapping methods per the Wi-Fi Aware Specification Table 9-321.
* @csids: array of u32 NAN Cipher Suite ID (CSID) selectors supported by
@@ -4727,6 +4744,8 @@ struct cfg80211_nan_func {
bool data_path_required;
bool security_required;
bool gtk_required;
+ u8 group_keys;
+ bool bip_gmac_256;
u16 pairing_bootstrap_methods;
u32 *csids;
u8 num_csids;
@@ -6781,15 +6800,15 @@ struct wiphy_radio {
* %NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS. The device learns and manages peer
* NAN schedules; userspace must not set them with
* %NL80211_CMD_NAN_SET_PEER_SCHED. The device assigns NDP IDs for locally
- * initiated NDPs, derives, installs, and removes PTKs and, when requested,
- * GTKs. The device creates and removes NDI peer stations for offloaded NDPs.
- * Userspace must not add those NDI peer stations or their
+ * initiated NDPs, derives, installs, and removes PTKs and, when negotiated,
+ * GTKs, IGTKs, and BIGTKs (see &struct cfg80211_nan_func.group_keys). The
+ * device creates and removes NDI peer stations for offloaded NDPs. Userspace
+ * must not add those NDI peer stations or their
* keys. NDP offload is supported on all bands in
* &struct wiphy.nan_supported_bands. The device supplies the band-specific
* capabilities, such as the HE 6 GHz band and EHT capabilities, and the
* regulatory information in the frames it builds. The driver implements
- * @nan_ndp_initiate,
- * @nan_ndp_respond, and
+ * @nan_ndp_initiate, @nan_ndp_respond, and
* @nan_ndp_terminate callbacks. It supports
* %NL80211_CMD_NAN_NDP_INITIATE, %NL80211_CMD_NAN_NDP_RESPOND, and
* %NL80211_CMD_NAN_NDP_TERMINATE, and
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 2581b7328867..8976154fdfcd 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -7888,6 +7888,17 @@ enum nl80211_nan_publish_type {
NL80211_NAN_UNSOLICITED_PUBLISH = 1 << 1,
};
+/**
+ * enum nl80211_nan_group_keys - NAN group key support
+ * @NL80211_NAN_GROUP_KEYS_GTK_IGTK: the service supports GTK and IGTK.
+ * @NL80211_NAN_GROUP_KEYS_GTK_IGTK_BIGTK: the service supports GTK, IGTK,
+ * and BIGTK.
+ */
+enum nl80211_nan_group_keys {
+ NL80211_NAN_GROUP_KEYS_GTK_IGTK = 1,
+ NL80211_NAN_GROUP_KEYS_GTK_IGTK_BIGTK = 2,
+};
+
/**
* enum nl80211_nan_func_term_reason - NAN functions termination reason
*
@@ -7953,7 +7964,9 @@ enum nl80211_nan_func_term_reason {
* %NL80211_EXT_FEATURE_SECURE_NAN.
* @NL80211_NAN_FUNC_GTK_REQUIRED: flag attribute. Sets the SDEA "GTK
* Required" bit for GTK protection of group-addressed data frames.
- * Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * This is separate from @NL80211_NAN_FUNC_GROUP_KEYS, which advertises the
+ * service's group-key support in its Cipher Suite Info attribute. Requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
* @NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS: u16 bitmap of supported
* NAN pairing bootstrapping methods as defined in Wi-Fi Aware
* specification Table 9-321. Each bit corresponds to one method. Requires
@@ -7989,6 +8002,17 @@ enum nl80211_nan_func_term_reason {
* uses include the NAN Identity Resolution attribute for pairing
* verification in Publish and Subscribe messages. Requires
* %NL80211_NAN_CAPA_FUNC_EXTRA_ATTRS.
+ * @NL80211_NAN_FUNC_GROUP_KEYS: u8 attribute, see &enum nl80211_nan_group_keys.
+ * Group-key support of the service, advertised in the Cipher Suite Info
+ * attribute of the Service Discovery Frames of this function. With
+ * %NL80211_NAN_CAPA_OFFLOAD_NDP the device also uses it for NDPs of the
+ * service: it advertises it in the NDP setup frames (an NDP initiator uses
+ * its subscribe function) and establishes the group keys that both peers
+ * support. If absent, no group-key support is advertised. Requires
+ * %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_BIP_GMAC_256: flag attribute. IGTK and BIGTK use
+ * NCS-BIP-GMAC-256 instead of NCS-BIP-CMAC-128. Requires
+ * @NL80211_NAN_FUNC_GROUP_KEYS and %NL80211_EXT_FEATURE_SECURE_NAN.
*
* @NUM_NL80211_NAN_FUNC_ATTR: internal
* @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute
@@ -8026,6 +8050,8 @@ enum nl80211_nan_func_attributes {
NL80211_NAN_FUNC_CHAN,
NL80211_NAN_FUNC_RANGE_REPORT,
NL80211_NAN_FUNC_EXTRA_ATTRS,
+ NL80211_NAN_FUNC_GROUP_KEYS,
+ NL80211_NAN_FUNC_BIP_GMAC_256,
/* keep last */
NUM_NL80211_NAN_FUNC_ATTR,
@@ -8244,7 +8270,8 @@ enum nl80211_nan_conf_attributes {
* it carries the PMKID received in the peer's SCIA for cached-PMK lookup.
* @NL80211_NAN_NDP_ATTR_GTK_REQUIRED: flag indicating that GTK protection is
* required for group-addressed data frames. Requires
- * @NL80211_NAN_NDP_ATTR_GTK_CIPHER; IGTK and BIGTK are not covered.
+ * @NL80211_NAN_NDP_ATTR_GTK_CIPHER. IGTK and BIGTK are set up according to
+ * the group-key support of the service, see %NL80211_NAN_FUNC_GROUP_KEYS.
* @NL80211_NAN_NDP_ATTR_GTK_CIPHER: u32 GTK cipher suite ID. Required if
* @NL80211_NAN_NDP_ATTR_GTK_REQUIRED is set.
* @NL80211_NAN_NDP_ATTR_IPV6_INTF_ID: binary IPv6 link-local interface
@@ -9562,7 +9589,8 @@ enum nl80211_s1g_short_beacon_attrs {
* device learns and manages peer NAN schedules; userspace must not set them
* with %NL80211_CMD_NAN_SET_PEER_SCHED. The device assigns NDP IDs for
* locally initiated NDPs and derives, installs, and removes data path keys
- * (PTK and, when requested, GTK). The device creates and removes NDI peer
+ * (PTK and, when negotiated, GTK, IGTK, and BIGTK, see
+ * %NL80211_NAN_FUNC_GROUP_KEYS). The device creates and removes NDI peer
* stations for offloaded NDPs. Userspace must not add those NDI peer stations
* or their keys. NDP offload is supported on every band that the device
* reports for NAN in %NL80211_ATTR_BANDS. The device supplies the band-specific
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 1856b9cd3f1c..9b105379f3ef 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -1477,6 +1477,10 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = {
NLA_POLICY_VALIDATE_FN(NLA_BINARY,
validate_nan_func_extra_attrs,
IEEE80211_MAX_DATA_LEN),
+ [NL80211_NAN_FUNC_GROUP_KEYS] =
+ NLA_POLICY_RANGE(NLA_U8, NL80211_NAN_GROUP_KEYS_GTK_IGTK,
+ NL80211_NAN_GROUP_KEYS_GTK_IGTK_BIGTK),
+ [NL80211_NAN_FUNC_BIP_GMAC_256] = { .type = NLA_FLAG },
};
/* policy for Service Response Filter attributes */
@@ -17787,6 +17791,11 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
func->security_required =
nla_get_flag(tb[NL80211_NAN_FUNC_SECURITY_REQUIRED]);
func->gtk_required = nla_get_flag(tb[NL80211_NAN_FUNC_GTK_REQUIRED]);
+ if (tb[NL80211_NAN_FUNC_GROUP_KEYS])
+ func->group_keys =
+ nla_get_u8(tb[NL80211_NAN_FUNC_GROUP_KEYS]);
+ func->bip_gmac_256 =
+ nla_get_flag(tb[NL80211_NAN_FUNC_BIP_GMAC_256]);
if (func->security_required && !func->data_path_required) {
NL_SET_ERR_MSG(info->extack,
@@ -17796,6 +17805,8 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
}
if (func->security_required || func->gtk_required ||
+ tb[NL80211_NAN_FUNC_GROUP_KEYS] ||
+ tb[NL80211_NAN_FUNC_BIP_GMAC_256] ||
tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] ||
tb[NL80211_NAN_FUNC_CSIDS] || tb[NL80211_NAN_FUNC_ND_PMK]) {
if (!wiphy_ext_feature_isset(wdev->wiphy,
@@ -17806,6 +17817,13 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
goto out;
}
+ if (func->bip_gmac_256 && !func->group_keys) {
+ NL_SET_ERR_MSG(info->extack,
+ "BIP-GMAC-256 requires group key support");
+ err = -EINVAL;
+ goto out;
+ }
+
if (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS])
func->pairing_bootstrap_methods =
nla_get_u16(tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS]);
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [PATCH wireless-next v3 19/19] wifi: nl80211/cfg80211: select the 5 GHz NAN channel for IC
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (17 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 18/19] wifi: nl80211/cfg80211: add NAN group key capabilities to NAN functions Shivani Baranwal
@ 2026-11-13 10:22 ` Shivani Baranwal
2026-11-17 20:05 ` [syzbot ci] Re: wifi: cfg80211/nl80211: add NAN offload support syzbot ci
19 siblings, 0 replies; 21+ messages in thread
From: Shivani Baranwal @ 2026-11-13 10:22 UTC (permalink / raw)
To: johannes; +Cc: linux-wireless, kavita.kavita, vamsin, vganneva
Wi-Fi Aware v4.0 specifies that Instant Communication (IC) uses the
5 GHz NAN discovery channel when the intended peer is known to support
5 GHz; otherwise it uses the 2.4 GHz discovery channel. The NAN band
configurations already provide these discovery channels.
Add optional NL80211_NAN_CONF_INSTANT_COMM_5GHZ to select the configured
5 GHz channel for IC. Without the flag, IC uses the 2.4 GHz channel. The
flag requires IC to be enabled and a 5 GHz NAN channel to be available
after band defaults are applied. Its use is independent of Discovery
Engine offload.
Signed-off-by: Shivani Baranwal <shivani.baranwal@oss.qualcomm.com>
---
include/net/cfg80211.h | 3 +++
include/uapi/linux/nl80211.h | 8 ++++++++
net/mac80211/cfg.c | 1 +
net/wireless/nl80211.c | 13 +++++++++++++
net/wireless/trace.h | 18 ++++++++++++++----
5 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 9aae48c2b95d..96dfd5d397b5 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4249,6 +4249,8 @@ struct cfg80211_nan_band_config {
* notifications.
* @instant_comm: if true, start Instant Communication (IC) as defined in
* Chapter 13 of the Wi-Fi Aware Specification v4.0.
+ * @instant_comm_5ghz: if true, use the configured 5 GHz NAN discovery channel
+ * for Instant Communication; otherwise use the 2.4 GHz discovery channel.
* @pairing_setup: if true, enable NAN pairing setup.
* @pairing_npk_caching: if true, enable NPK/NIK caching.
* @band_cfgs: array of band specific configurations, indexed by
@@ -4267,6 +4269,7 @@ struct cfg80211_nan_conf {
u8 discovery_beacon_interval;
bool enable_dw_notification;
bool instant_comm;
+ bool instant_comm_5ghz;
bool pairing_setup;
bool pairing_npk_caching;
struct cfg80211_nan_band_config band_cfgs[NUM_NL80211_BANDS];
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index 8976154fdfcd..aaf65f693fc5 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -8200,6 +8200,8 @@ enum nl80211_nan_band_conf_attributes {
* start Instant Communication (IC) as defined in Chapter 13 of the
* Wi-Fi Aware Specification v4.0.
* %NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL must be set as well.
+ * If %NL80211_NAN_CONF_INSTANT_COMM_5GHZ is set, IC uses the configured 5 GHz
+ * NAN discovery channel; otherwise it uses the 2.4 GHz discovery channel.
* This is a flag attribute.
* @NL80211_NAN_CONF_PAIRING_SETUP: flag attribute. Enables NAN pairing setup
* and is advertised as "Pairing Setup Enabled" in the DCEA. Only valid for
@@ -8211,6 +8213,11 @@ enum nl80211_nan_band_conf_attributes {
* valid for devices that offload the NAN Discovery Engine (i.e. without
* %NL80211_NAN_CAPA_USERSPACE_DE) and requires
* %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_CONF_INSTANT_COMM_5GHZ: optional flag, valid only together with
+ * %NL80211_NAN_CONF_INSTANT_COMM and when a 5 GHz NAN band configuration
+ * provides a discovery channel. When set, IC uses that 5 GHz channel;
+ * otherwise IC uses the 2.4 GHz NAN discovery channel. Wi-Fi Aware v4.0 uses
+ * 5 GHz when the intended peer is known to support it.
* @NUM_NL80211_NAN_CONF_ATTR: Internal.
* @NL80211_NAN_CONF_ATTR_MAX: Highest NAN configuration attribute.
*
@@ -8229,6 +8236,7 @@ enum nl80211_nan_conf_attributes {
NL80211_NAN_CONF_INSTANT_COMM,
NL80211_NAN_CONF_PAIRING_SETUP,
NL80211_NAN_CONF_PAIRING_NPK_CACHING,
+ NL80211_NAN_CONF_INSTANT_COMM_5GHZ,
/* keep last */
NUM_NL80211_NAN_CONF_ATTR,
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 9e47360ee8f5..ed5955c94d5b 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -369,6 +369,7 @@ static int ieee80211_nan_conf_copy(struct cfg80211_nan_conf *dst,
src->discovery_beacon_interval;
dst->enable_dw_notification = src->enable_dw_notification;
dst->instant_comm = src->instant_comm;
+ dst->instant_comm_5ghz = src->instant_comm_5ghz;
memcpy(&dst->band_cfgs, &src->band_cfgs,
sizeof(dst->band_cfgs));
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 9b105379f3ef..ccb0994eb94d 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -905,6 +905,7 @@ nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {
[NL80211_NAN_CONF_INSTANT_COMM] = { .type = NLA_FLAG },
[NL80211_NAN_CONF_PAIRING_SETUP] = { .type = NLA_FLAG },
[NL80211_NAN_CONF_PAIRING_NPK_CACHING] = { .type = NLA_FLAG },
+ [NL80211_NAN_CONF_INSTANT_COMM_5GHZ] = { .type = NLA_FLAG },
};
static const struct netlink_range_validation nl80211_punct_bitmap_range = {
@@ -17392,6 +17393,9 @@ static int nl80211_parse_nan_conf(struct wiphy *wiphy,
nla_get_flag(attrs[NL80211_NAN_CONF_NOTIFY_DW]);
conf->instant_comm = nla_get_flag(attrs[NL80211_NAN_CONF_INSTANT_COMM]);
+ conf->instant_comm_5ghz =
+ nla_get_flag(attrs[NL80211_NAN_CONF_INSTANT_COMM_5GHZ]);
+
if (conf->instant_comm) {
if (!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_INSTANT_COMM)) {
NL_SET_ERR_MSG_ATTR(info->extack,
@@ -17449,6 +17453,15 @@ static int nl80211_parse_nan_conf(struct wiphy *wiphy,
}
}
+ if (conf->instant_comm_5ghz &&
+ (!conf->instant_comm ||
+ !conf->band_cfgs[NL80211_BAND_5GHZ].chan)) {
+ NL_SET_ERR_MSG_ATTR(info->extack,
+ attrs[NL80211_NAN_CONF_INSTANT_COMM_5GHZ],
+ "5 GHz Instant Communication requires IC and a 5 GHz NAN channel");
+ return -EINVAL;
+ }
+
if (changed_flags)
*changed_flags = changed;
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 85eb81d0d87f..f12dbc42dc54 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2387,17 +2387,22 @@ TRACE_EVENT(rdev_start_nan,
WDEV_ENTRY
__field(u8, master_pref)
__field(u8, bands)
+ __field(u8, instant_comm)
+ __field(u8, instant_comm_5ghz)
),
TP_fast_assign(
WIPHY_ASSIGN;
WDEV_ASSIGN;
__entry->master_pref = conf->master_pref;
__entry->bands = conf->bands;
+ __entry->instant_comm = conf->instant_comm;
+ __entry->instant_comm_5ghz = conf->instant_comm_5ghz;
),
TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
- ", master preference: %u, bands: 0x%0x",
+ ", master preference: %u, bands: 0x%0x, IC: %u, IC 5 GHz: %u",
WIPHY_PR_ARG, WDEV_PR_ARG, __entry->master_pref,
- __entry->bands)
+ __entry->bands, __entry->instant_comm,
+ __entry->instant_comm_5ghz)
);
TRACE_EVENT(rdev_nan_change_conf,
@@ -2409,6 +2414,8 @@ TRACE_EVENT(rdev_nan_change_conf,
WDEV_ENTRY
__field(u8, master_pref)
__field(u8, bands)
+ __field(u8, instant_comm)
+ __field(u8, instant_comm_5ghz)
__field(u32, changes)
),
TP_fast_assign(
@@ -2416,12 +2423,15 @@ TRACE_EVENT(rdev_nan_change_conf,
WDEV_ASSIGN;
__entry->master_pref = conf->master_pref;
__entry->bands = conf->bands;
+ __entry->instant_comm = conf->instant_comm;
+ __entry->instant_comm_5ghz = conf->instant_comm_5ghz;
__entry->changes = changes;
),
TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
- ", master preference: %u, bands: 0x%0x, changes: %x",
+ ", master preference: %u, bands: 0x%0x, IC: %u, IC 5 GHz: %u, changes: %x",
WIPHY_PR_ARG, WDEV_PR_ARG, __entry->master_pref,
- __entry->bands, __entry->changes)
+ __entry->bands, __entry->instant_comm,
+ __entry->instant_comm_5ghz, __entry->changes)
);
DEFINE_EVENT(wiphy_wdev_evt, rdev_stop_nan,
--
2.34.1
^ permalink raw reply related [flat|nested] 21+ messages in thread* [syzbot ci] Re: wifi: cfg80211/nl80211: add NAN offload support
2026-11-13 10:22 [PATCH wireless-next v3 00/19] wifi: cfg80211/nl80211: add NAN offload support Shivani Baranwal
` (18 preceding siblings ...)
2026-11-13 10:22 ` [PATCH wireless-next v3 19/19] wifi: nl80211/cfg80211: select the 5 GHz NAN channel for IC Shivani Baranwal
@ 2026-11-17 20:05 ` syzbot ci
19 siblings, 0 replies; 21+ messages in thread
From: syzbot ci @ 2026-11-17 20:05 UTC (permalink / raw)
To: johannes, kavita.kavita, linux-wireless, shivani.baranwal, vamsin,
vganneva
Cc: syzbot, syzkaller-bugs
syzbot ci has tested the following series
[v3] wifi: cfg80211/nl80211: add NAN offload support
https://lore.kernel.org/all/20261113102228.1917973-1-shivani.baranwal@oss.qualcomm.com
* [PATCH wireless-next v3 01/19] wifi: nl80211: reject NAN function add/delete when Discovery Engine is in userspace
* [PATCH wireless-next v3 02/19] wifi: nl80211/cfg80211: extend NAN function and configuration for discovery offload
* [PATCH wireless-next v3 03/19] wifi: nl80211/cfg80211: extend NAN match indication for discovery offload
* [PATCH wireless-next v3 04/19] wifi: nl80211/cfg80211: add NAN ranging FTM capability
* [PATCH wireless-next v3 05/19] wifi: nl80211/cfg80211: advertise NAN ranging support
* [PATCH wireless-next v3 06/19] wifi: nl80211/cfg80211: add support for request-based NAN ranging
* [PATCH wireless-next v3 07/19] wifi: nl80211/cfg80211: add support for discovery-based NAN ranging
* [PATCH wireless-next v3 08/19] wifi: nl80211/cfg80211: add ranging results to NAN match event
* [PATCH wireless-next v3 09/19] wifi: nl80211: add NDP offload capability advertisement
* [PATCH wireless-next v3 10/19] wifi: nl80211/cfg80211: add support for NDP initiation in offload mode
* [PATCH wireless-next v3 11/19] wifi: nl80211/cfg80211: add support for NDP response in offload mode
* [PATCH wireless-next v3 12/19] wifi: nl80211/cfg80211: add support for NDP termination in offload mode
* [PATCH wireless-next v3 13/19] wifi: nl80211/cfg80211: add support for NDP request indication
* [PATCH wireless-next v3 14/19] wifi: nl80211/cfg80211: add support for NDP status indication
* [PATCH wireless-next v3 15/19] wifi: nl80211/cfg80211: add support for NDP terminated indication
* [PATCH wireless-next v3 16/19] wifi: nl80211/cfg80211: support updating an offloaded NAN publish function
* [PATCH wireless-next v3 17/19] wifi: nl80211/cfg80211: allow extra NAN attributes in offloaded functions
* [PATCH wireless-next v3 18/19] wifi: nl80211/cfg80211: add NAN group key capabilities to NAN functions
* [PATCH wireless-next v3 19/19] wifi: nl80211/cfg80211: select the 5 GHz NAN channel for IC
and found the following issue:
WARNING in genl_register_family
Full report is available here:
https://ci.syzbot.org/series/51fe1835-2116-4216-afb5-89006d12c38e
***
WARNING in genl_register_family
tree: linux-next
URL: https://kernel.googlesource.com/pub/scm/linux/kernel/git/next/linux-next
base: 5dbf2415ca9821a611d09308e3b29d2c37e7cd77
arch: amd64
compiler: Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
config: https://ci.syzbot.org/builds/88ad3d6b-ffda-4626-be13-f0ecdc12abcf/config
Bluetooth: L2CAP socket layer initialized
Bluetooth: SCO socket layer initialized
NET: Registered PF_ATMPVC protocol family
NetLabel: Initializing
NetLabel: domain hash size = 128
NetLabel: protocols = UNLABELED CIPSOv4 CALIPSO
NetLabel: unlabeled traffic allowed by default
nfc: nfc_init: NFC Core ver 0.1
NET: Registered PF_NFC protocol family
mctp: management component transport protocol core
NET: Registered PF_MCTP protocol family
PCI: Using ACPI for IRQ routing
e820: register RAM buffer resource [mem 0x0009fc00-0x0009ffff]
e820: register RAM buffer resource [mem 0x7ffdf000-0x7fffffff]
pci 0000:00:01.0: vgaarb: setting as boot VGA device
pci 0000:00:01.0: vgaarb: bridge control possible
pci 0000:00:01.0: vgaarb: VGA device added: decodes=io+mem,owns=io+mem,locks=none
vgaarb: loaded
hpet: 3 channels of 0 reserved for per-cpu timers
hpet0: at MMIO 0xfed00000, IRQs 2, 8, 0
hpet0: 3 comparators, 64-bit 100.000000 MHz counter
clocksource: Switched to clocksource kvm-clock
VFS: Disk quotas dquot_6.6.0
VFS: Dquot-cache hash table entries: 512 (4096 bytes)
netfs: FS-Cache loaded
CacheFiles: Loaded
TOMOYO: 2.6.0
Mandatory Access Control activated.
AppArmor: AppArmor Filesystem Enabled
acpi PNP0C01:00: Reserved [mem 0xb0000000-0xbfffffff]
pnp: PnP ACPI init
pnp: PnP ACPI: found 4 devices
clocksource: acpi_pm: mask: 0xffffff max_cycles: 0xffffff, max_idle_ns: 2085701024 ns
NET: Registered PF_INET protocol family
IP idents hash table entries: 131072 (order: 8, 1048576 bytes, vmalloc)
tcp_listen_portaddr_hash hash table entries: 4096 (order: 7, 294912 bytes, vmalloc)
Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, vmalloc)
TCP established hash table entries: 65536 (order: 7, 524288 bytes, vmalloc)
TCP bind hash table entries: 65536 (order: 12, 9437184 bytes, vmalloc hugepage)
TCP: Hash tables configured (established 65536 bind 65536)
MPTCP token hash table entries: 8192 (order: 8, 720896 bytes, vmalloc)
UDP hash table entries: 4096 (order: 8, 1048576 bytes, vmalloc)
NET: Registered PF_UNIX/PF_LOCAL protocol family
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp-with-tls transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
------------[ cut here ]------------
i.cmd >= family->resv_start_op && (i.doit.validate || i.dumpit.validate)
WARNING: net/netlink/genetlink.c:581 at genl_register_family+0xc9e/0x17d0, CPU#1: swapper/0/1
Modules linked in:
CPU: 1 UID: 0 PID: 1 Comm: swapper/0 Not tainted syzkaller #0 PREEMPT(full)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
RIP: 0010:genl_register_family+0xc9e/0x17d0
Code: de e8 a6 98 c8 f7 83 fb 01 0f 85 26 0b 00 00 e8 18 95 c8 f7 b0 01 89 44 24 08 4c 8b 7c 24 18 e9 f3 02 00 00 e8 03 95 c8 f7 90 <0f> 0b 90 e9 82 fa ff ff e8 f5 94 c8 f7 4c 8b 7c 24 20 e9 b9 f6 ff
RSP: 0000:ffffc90000067740 EFLAGS: 00010293
RAX: ffffffff89ffd11d RBX: 0000000000000003 RCX: ffff888102aa5a00
RDX: 0000000000000000 RSI: 0000000000000003 RDI: 0000000000000000
RBP: ffffc90000067948 R08: ffffc90000067827 R09: 0000000000000000
R10: ffffc90000067800 R11: fffff5200000cf05 R12: ffffc90000067860
R13: ffffc900000677d0 R14: 00000000000000b2 R15: 1ffffffff1cf0d83
FS: 0000000000000000(0000) GS:ffff8882a7c57000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000000000000 CR3: 000000000fb48000 CR4: 00000000000006f0
Call Trace:
<TASK>
nl80211_init+0x11/0x50
cfg80211_init+0x3c/0xe0
do_one_initcall+0x250/0x870
do_initcall_level+0x10a/0x1a0
do_initcalls+0x59/0xa0
kernel_init_freeable+0x29d/0x3e0
kernel_init+0x22/0x1d0
ret_from_fork+0x514/0xb70
ret_from_fork_asm+0x1a/0x30
</TASK>
***
If these findings have caused you to resend the series or submit a
separate fix, please add the following tag to your commit message:
Tested-by: syzbot@syzkaller.appspotmail.com
---
This report is generated by a bot. It may contain errors.
syzbot ci engineers can be reached at syzkaller@googlegroups.com.
^ permalink raw reply [flat|nested] 21+ messages in thread