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 --- include/net/cfg80211.h | 33 +++++++++++++++++++++++++++++++-- include/uapi/linux/nl80211.h | 31 +++++++++++++++++++++++++++++++ net/wireless/nl80211.c | 10 ++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 4689d8d15c42..47939950e30c 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5355,7 +5355,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 @@ -5363,12 +5364,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 * @@ -6486,12 +6491,36 @@ 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. NDP offload is supported on all bands in + * &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 + * the &cfg80211_ops.nan_ndp_initiate, &cfg80211_ops.nan_ndp_respond, and + * &cfg80211_ops.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 56ed7e2c12ed..894754addd93 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -1455,6 +1455,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) @@ -1462,6 +1464,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: @@ -1523,6 +1527,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, @@ -9347,6 +9353,30 @@ enum nl80211_s1g_short_beacon_attrs { * 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. */ @@ -9362,6 +9392,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 7f069c0908d8..8c7ee9be0df3 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -3224,6 +3224,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, @@ -18363,6 +18367,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