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 | 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