1: 311a02cfcd91 = 1: b95588684bb9 wifi: nl80211: reject NAN function add/delete when Discovery Engine is in userspace  2: 9ce1592e75cf = 2: 675c0dd9723f wifi: nl80211/cfg80211: extend NAN function and configuration for discovery offload  3: 60d60eadfe52 = 3: 8b3bfca4ca75 wifi: nl80211/cfg80211: extend NAN match indication for discovery offload  4: 6abb3f88fd79 = 4: 9876e75d503d wifi: nl80211/cfg80211: add NAN ranging FTM capability  5: ae2453757211 = 5: eac616b3cf7e wifi: nl80211/cfg80211: advertise NAN ranging support  6: 3212946a7947 = 6: 80a8ef44c7a8 wifi: nl80211/cfg80211: add support for request-based NAN ranging  7: 6ce0a6fe7a76 = 7: 4f5d17d6ab07 wifi: nl80211/cfg80211: add support for discovery-based NAN ranging  8: 975000d6ad45 = 8: 72f9f0d0613f wifi: nl80211/cfg80211: add ranging results to NAN match event  9: e502452629e8 ! 9: df8806db53e3 wifi: nl80211: add NDP offload capability advertisement @@ Commit message wifi: nl80211: add NDP offload capability advertisement  Advertise whether a device performs the complete NAN Data Path setup and - teardown handshake, including security negotiation. An offload device - assigns NDP IDs for locally initiated sessions and derives and installs - the data path keys, including GTK when requested. + 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.  - NDP Request/Response/Confirm frames carry the NDL attribute and NAN - Availability, so the device that runs the handshake owns the schedule. - Userspace schedule configuration would conflict with that negotiated - state. Reject NL80211_CMD_NAN_SET_LOCAL_SCHED, - NL80211_CMD_NAN_SET_PEER_SCHED, and - NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS for such devices. - Signed-off-by: Shivani Baranwal   ## include/net/cfg80211.h ## @@ include/net/cfg80211.h: struct mgmt_frame_regs { * 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. Not supported when -+ * %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set; the device manages the schedule. ++ * 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 @@ include/net/cfg80211.h: struct mgmt_frame_regs { * 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. ++ * 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. Not -+ * supported when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set; the device manages -+ * channel evacuation. ++ * 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 * @@ include/net/cfg80211.h: struct wiphy_radio { * 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. It negotiates the NDL and manages local and peer -+ * NAN schedules, including NDC and immutable schedules, ULW, schedule updates, -+ * and evacuation of its own channels. It 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 configure NAN schedules or add those NDI peer stations or their -+ * keys. 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 ++ * 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 @@ include/uapi/linux/nl80211.h * 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. -+ * Not supported when %NL80211_NAN_CAPA_OFFLOAD_NDP is advertised; the -+ * device manages the local NAN schedule for offloaded NDPs. ++ * 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) @@ include/uapi/linux/nl80211.h * 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. -+ * Not supported when %NL80211_NAN_CAPA_OFFLOAD_NDP is advertised; the -+ * device manages channel evacuation for offloaded NDPs. ++ * 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, @@ include/uapi/linux/nl80211.h: enum nl80211_s1g_short_beacon_attrs { * 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. It -+ * negotiates the NDL and manages local and peer NAN schedules, including NDC -+ * and immutable schedules, ULW, schedule updates, and evacuation of its own -+ * channels. It 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 configure NAN schedules or add those NDI peer stations or their -+ * keys. In particular, %NL80211_CMD_NAN_SET_LOCAL_SCHED, -+ * %NL80211_CMD_NAN_SET_PEER_SCHED, and -+ * %NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS are not supported. The device -+ * supports %NL80211_CMD_NAN_NDP_INITIATE, %NL80211_CMD_NAN_NDP_RESPOND, and ++ * 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. @@ net/wireless/nl80211.c: static int nl80211_put_nan_capa(struct wiphy *wiphy, str if (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE, wiphy->nan_capa.op_mode) || nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS, -@@ net/wireless/nl80211.c: static int nl80211_nan_validate_map_pair(struct genl_info *info, - return 0; - } -  -+static int -+nl80211_nan_sched_offload_check(struct wiphy *wiphy, -+ struct genl_info *info) -+{ -+ if (!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) -+ return 0; -+ -+ NL_SET_ERR_MSG(info->extack, -+ "NAN schedule is managed by the device with NDP offload"); -+ return -EOPNOTSUPP; -+} -+ - static int nl80211_nan_set_peer_sched(struct sk_buff *skb, - struct genl_info *info) - {  @@ net/wireless/nl80211.c: static int nl80211_nan_set_peer_sched(struct sk_buff *skb, if (wdev->iftype != NL80211_IFTYPE_NAN) return -EOPNOTSUPP;  -+ ret = nl80211_nan_sched_offload_check(&rdev->wiphy, info); -+ if (ret) -+ return ret; ++ 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, -@@ net/wireless/nl80211.c: static int nl80211_nan_set_local_sched(struct sk_buff *skb, - if (wdev->iftype != NL80211_IFTYPE_NAN) - return -EOPNOTSUPP; -  -+ ret = nl80211_nan_sched_offload_check(&rdev->wiphy, info); -+ if (ret) -+ return ret; -+ - if (!wdev_running(wdev)) - return -ENOTCONN; -  -@@ net/wireless/nl80211.c: static int nl80211_nan_set_non_evac_channels(struct sk_buff *skb, - { - struct cfg80211_registered_device *rdev = info->user_ptr[0]; - struct wireless_dev *wdev = info->user_ptr[1]; -- int rem, i = 0, n_channels = 0; -+ int rem, i = 0, n_channels = 0, ret; - struct nlattr *channel; -  - if (wdev->iftype != NL80211_IFTYPE_NAN) - return -EOPNOTSUPP; -  -+ ret = nl80211_nan_sched_offload_check(&rdev->wiphy, info); -+ if (ret) -+ return ret; -+ - if (!wdev_running(wdev)) - return -ENOTCONN; -  10: d27d2ae2fe58 ! 10: f687c3beff4a wifi: nl80211/cfg80211: add support for NDP initiation in offload mode @@ Commit message apply the NAN security requirements to cipher suite, PMK, PMKID, and GTK.  - Let the initiator provide transport port and protocol information for - its service in the NDPE Service Info TLV. It can also request a - preferred NDL channel or require that the device include it. The device - chooses the bandwidth and reports setup failure if it cannot use a - forced channel. + 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. + 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   @@ include/net/cfg80211.h: struct cfg80211_nan_peer_sched {  + * @transport_port: transport port to convey when @transport_info is true  + * @transport_protocol: IANA protocol number to convey when @transport_info is  + * true -+ * @chan: preferred channel for the NDL, or NULL when the device chooses the -+ * channels -+ * @chan_forced: if true, @chan must be included in the NDL; valid only when -+ * @chan is non-NULL ++ * @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; @@ include/net/cfg80211.h: struct cfg80211_nan_peer_sched {  + bool transport_info;  + u16 transport_port;  + u8 transport_protocol; -+ struct ieee80211_channel *chan; -+ bool chan_forced; ++ u8 qos_min_slots; ++ u16 qos_max_latency;  +};  + /** * enum cfg80211_nan_conf_changes - indicates changed fields in NAN * configuration  @@ include/net/cfg80211.h: struct mgmt_frame_regs { - * supported when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set; the device manages - * channel evacuation. + * 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 parameters -+ * specify a channel, drivers advertising NDP offload must honor it as a -+ * channel preference. If the channel is forced and cannot be included in the -+ * NDL, the driver must fail the request. ++ * 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 * @@ include/net/cfg80211.h: struct cfg80211_ops {  ## include/uapi/linux/nl80211.h ##  @@ - * and multiple can be nested in %NL80211_ATTR_MLO_LINKS but then the - * update isn't atomic if any failures happen. - * Only supported with %NL80211_EXT_FEATURE_UPDATE_BEACON. -+ * + * 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 @@ include/uapi/linux/nl80211.h  + * %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. -+ * Without %NL80211_NAN_NDP_ATTR_CHANNEL_FREQ, the device chooses the -+ * channels of the NDL. A supplied channel frequency is a preference unless -+ * %NL80211_NAN_NDP_ATTR_CHANNEL_FORCED is also present; the device may then -+ * use other channels. With %NL80211_NAN_NDP_ATTR_CHANNEL_FORCED, the device -+ * must include the requested channel in the NDL or fail setup, reporting the -+ * failure with %NL80211_CMD_NAN_NDP_STATUS. The device chooses the bandwidth. ++ * %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.  + * @@ include/uapi/linux/nl80211.h * @__NL80211_CMD_AFTER_LAST: internal use */  @@ include/uapi/linux/nl80211.h: enum nl80211_commands { -  - NL80211_CMD_UPDATE_BEACON, + NL80211_CMD_EXECUTE_SMD_TRANSITION, + NL80211_CMD_COMPLETED_SMD_TRANSITION,   + NL80211_CMD_NAN_NDP_INITIATE,  + @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes {  + * 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_CHANNEL_FREQ: optional u32 channel frequency in MHz. -+ * Valid only with %NL80211_CMD_NAN_NDP_INITIATE. When supplied without -+ * @NL80211_NAN_NDP_ATTR_CHANNEL_FORCED it is a preference, and the device -+ * may use other channels for the NDL. Without this attribute, the device -+ * chooses the NDL channels. The device chooses the channel bandwidth. -+ * @NL80211_NAN_NDP_ATTR_CHANNEL_FORCED: optional flag valid only with -+ * %NL80211_CMD_NAN_NDP_INITIATE and -+ * @NL80211_NAN_NDP_ATTR_CHANNEL_FREQ. The requested channel must be included -+ * in the NDL. If it cannot be used, for example because it is incompatible -+ * with peer availability, setup fails. ++ * @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.  + */ @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes {  + NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,  + NL80211_NAN_NDP_ATTR_TRANSPORT_PORT,  + NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL, -+ NL80211_NAN_NDP_ATTR_CHANNEL_FREQ, -+ NL80211_NAN_NDP_ATTR_CHANNEL_FORCED, ++ NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS, ++ NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY,  +  + /* keep last */  + __NL80211_NAN_NDP_ATTR_LAST, @@ net/wireless/nl80211.c: nl80211_nan_peer_map_policy[NL80211_NAN_PEER_MAP_ATTR_MA  + 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_CHANNEL_FREQ] = { .type = NLA_U32 }, -+ [NL80211_NAN_NDP_ATTR_CHANNEL_FORCED] = { .type = NLA_FLAG }, ++ [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] =  @@ net/wireless/nl80211.c: static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = { - [NL80211_ATTR_NAN_MAX_CHAN_SWITCH_TIME] = { .type = NLA_U16 }, - [NL80211_ATTR_NAN_PEER_MAPS] = - NLA_POLICY_NESTED_ARRAY(nl80211_nan_peer_map_policy), + [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_NPCA_PRIMARY_FREQ] = { .type = NLA_U32 }, - [NL80211_ATTR_NPCA_PUNCT_BITMAP] = - NLA_POLICY_FULL_RANGE(NLA_U32, &nl80211_punct_bitmap_range), + [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),  @@ net/wireless/nl80211.c: static int nl80211_nan_set_peer_sched(struct sk_buff *skb, return rdev_nan_set_peer_sched(rdev, wdev, &sched); } @@ net/wireless/nl80211.c: static int nl80211_nan_set_peer_sched(struct sk_buff *sk  +{  + 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], *ndp_attr; ++ 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; @@ net/wireless/nl80211.c: static int nl80211_nan_set_peer_sched(struct sk_buff *sk  + return -EINVAL;  + }  + -+ if (tb[NL80211_NAN_NDP_ATTR_CHANNEL_FORCED] && -+ !tb[NL80211_NAN_NDP_ATTR_CHANNEL_FREQ]) { -+ NL_SET_ERR_MSG_ATTR(info->extack, -+ tb[NL80211_NAN_NDP_ATTR_CHANNEL_FORCED], -+ "CHANNEL_FORCED requires CHANNEL_FREQ"); -+ return -EINVAL; -+ } -+  + if (tb[NL80211_NAN_NDP_ATTR_ID]) {  + NL_SET_ERR_MSG_ATTR(info->extack,  + tb[NL80211_NAN_NDP_ATTR_ID], @@ net/wireless/nl80211.c: static int nl80211_nan_set_peer_sched(struct sk_buff *sk  + params.ipv6_intf_id =  + nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]);  + -+ if (tb[NL80211_NAN_NDP_ATTR_CHANNEL_FREQ]) { -+ u32 freq = nla_get_u32(tb[NL80211_NAN_NDP_ATTR_CHANNEL_FREQ]); ++ 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.chan = ieee80211_get_channel(&rdev->wiphy, freq); -+ if (!params.chan) { -+ NL_SET_ERR_MSG_ATTR(info->extack, -+ tb[NL80211_NAN_NDP_ATTR_CHANNEL_FREQ], -+ "Channel frequency is not supported"); -+ return -EINVAL; -+ } -+ if (params.chan->flags & IEEE80211_CHAN_DISABLED) { -+ NL_SET_ERR_MSG_ATTR(info->extack, -+ tb[NL80211_NAN_NDP_ATTR_CHANNEL_FREQ], -+ "Channel is disabled"); -+ return -EINVAL; -+ } -+ if (!(rdev->wiphy.nan_supported_bands & -+ BIT(params.chan->band))) { -+ NL_SET_ERR_MSG_ATTR(info->extack, -+ tb[NL80211_NAN_NDP_ATTR_CHANNEL_FREQ], -+ "Channel band is not supported for NAN"); -+ return -EOPNOTSUPP; -+ } -+ params.chan_forced = -+ !!tb[NL80211_NAN_NDP_ATTR_CHANNEL_FORCED]; -+ } ++ 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) @@ net/wireless/nl80211.c: static int nl80211_nan_set_peer_sched(struct sk_buff *sk  + 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); @@ net/wireless/nl80211.c: static int nl80211_nan_set_peer_sched(struct sk_buff *sk  + return -EINVAL;  + }  + -+ ndp_attr = nla_nest_start_noflag(msg, NL80211_ATTR_NAN_NDP); -+ if (!ndp_attr || -+ nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params.ndp_id)) -+ goto nla_put_failure; -+ ++ *(u8 *)nla_data(id_attr) = params.ndp_id;  + nla_nest_end(msg, ndp_attr);  + genlmsg_end(msg, hdr);  + return genlmsg_reply(msg, info); -+ -+nla_put_failure: -+ nlmsg_free(msg); -+ return -ENOBUFS;  +}  + static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched) { if (!sched->n_channels)  @@ net/wireless/nl80211.c: static const struct genl_small_ops nl80211_small_ops[] = { - .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP | - NL80211_FLAG_NO_WIPHY_MTX), + .flags = GENL_UNS_ADMIN_PERM, + .internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP), },  + {  + .cmd = NL80211_CMD_NAN_NDP_INITIATE, @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_set_non_evac_channels,  +#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, channel_freq: %u, channel_forced: %d" ++ "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), @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_set_non_evac_channels,  + __field(u8, transport_protocol)  + __field(bool, ipv6_intf_id_present)  + __array(u8, ipv6_intf_id, NL80211_NAN_NDP_IPV6_INTF_ID_LEN) -+ __field(u32, channel_freq) -+ __field(bool, channel_forced) ++ __field(u8, qos_min_slots) ++ __field(u16, qos_max_latency)  + ),  + TP_fast_assign(  + WIPHY_ASSIGN; @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_set_non_evac_channels,  + else  + memset(__entry->ipv6_intf_id, 0,  + NL80211_NAN_NDP_IPV6_INTF_ID_LEN); -+ __entry->channel_freq = params->chan ? -+ params->chan->center_freq : 0; -+ __entry->channel_forced = params->chan_forced; ++ __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 @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_set_non_evac_channels,  + __entry->gtk_cipher, __entry->ipv6_intf_id_present,  + __print_array(__entry->ipv6_intf_id,  + NL80211_NAN_NDP_IPV6_INTF_ID_LEN, sizeof(u8)), -+ __entry->channel_freq, __entry->channel_forced, ++ __entry->qos_min_slots, __entry->qos_max_latency,  + __entry->transport_info, __entry->transport_port,  + __entry->transport_protocol)  +); 11: adbdefb7c794 ! 11: 59d667380aed wifi: nl80211/cfg80211: add support for NDP response in offload mode @@ Commit message recording key bytes.  Allow the responder to provide transport port and protocol information - when accepting an NDP request. Reject channel request attributes on the - response command, since channel selection is requested by the initiator. + 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   ## include/net/cfg80211.h ##  @@ include/net/cfg80211.h: struct cfg80211_nan_ndp_initiate { - bool chan_forced; + u16 qos_max_latency; };   +/** @@ include/net/cfg80211.h: struct cfg80211_nan_ndp_initiate {  + * @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; @@ include/net/cfg80211.h: struct cfg80211_nan_ndp_initiate {  + 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  @@ include/net/cfg80211.h: struct mgmt_frame_regs { - * specify a channel, drivers advertising NDP offload must honor it as a - * channel preference. If the channel is forced and cannot be included in the - * NDL, the driver must fail the request. + * 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. ++ * 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 * @@ include/net/cfg80211.h: struct cfg80211_ops {  ## include/uapi/linux/nl80211.h ##  @@ - * failure with %NL80211_CMD_NAN_NDP_STATUS. The device chooses the bandwidth. + * 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 @@ include/uapi/linux/nl80211.h  + * 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  @@ include/uapi/linux/nl80211.h: enum nl80211_commands { - NL80211_CMD_UPDATE_BEACON, + NL80211_CMD_COMPLETED_SMD_TRANSITION,  NL80211_CMD_NAN_NDP_INITIATE,  + NL80211_CMD_NAN_NDP_RESPOND, @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes {  + * 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_CHANNEL_FREQ: optional u32 channel frequency in MHz. -@@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes { - * @NL80211_NAN_NDP_ATTR_CHANNEL_FREQ. The requested channel must be included - * in the NDL. If it cannot be used, for example because it is incompatible - * with peer availability, setup fails. + * @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. @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes { */  @@ include/uapi/linux/nl80211.h: enum nl80211_nan_ndp_attributes { NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL, - NL80211_NAN_NDP_ATTR_CHANNEL_FREQ, - NL80211_NAN_NDP_ATTR_CHANNEL_FORCED, + NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS, + NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY,  + NL80211_NAN_NDP_ATTR_ACCEPT,  + NL80211_NAN_NDP_ATTR_REASON,  @@ include/uapi/linux/nl80211.h: enum nl80211_nan_ndp_attributes { ## net/wireless/nl80211.c ##  @@ net/wireless/nl80211.c: nl80211_nan_ndp_policy[NL80211_NAN_NDP_ATTR_MAX + 1] = { [NL80211_NAN_NDP_ATTR_TRANSPORT_PROTOCOL] = { .type = NLA_U8 }, - [NL80211_NAN_NDP_ATTR_CHANNEL_FREQ] = { .type = NLA_U32 }, - [NL80211_NAN_NDP_ATTR_CHANNEL_FORCED] = { .type = NLA_FLAG }, + [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  @@ net/wireless/nl80211.c: static int nl80211_nan_ndp_initiate(struct sk_buff *skb, - return -ENOBUFS; + return genlmsg_reply(msg, info); }   +static int nl80211_nan_ndp_respond(struct sk_buff *skb, @@ net/wireless/nl80211.c: static int nl80211_nan_ndp_initiate(struct sk_buff *skb,  + return -EINVAL;  + }  + -+ if (tb[NL80211_NAN_NDP_ATTR_CHANNEL_FREQ] || -+ tb[NL80211_NAN_NDP_ATTR_CHANNEL_FORCED]) { -+ NL_SET_ERR_MSG(info->extack, -+ "Channel request is only valid with NDP initiate"); -+ return -EINVAL; -+ } -+  + if (!tb[NL80211_NAN_NDP_ATTR_ID] ||  + !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {  + NL_SET_ERR_MSG(info->extack, @@ net/wireless/nl80211.c: static int nl80211_nan_ndp_initiate(struct sk_buff *skb,  + 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]) { @@ net/wireless/nl80211.c: static int nl80211_nan_ndp_initiate(struct sk_buff *skb,  + 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] || @@ net/wireless/nl80211.c: static int nl80211_nan_ndp_initiate(struct sk_buff *skb,  + 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_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 only valid when accepting"); ++ "RESP_NDI, cipher, PMK, GTK, IPv6 IID, transport info and QoS are only valid when accepting");  + return -EINVAL;  + }  + @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_ndp_initiate,  +#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" ++ "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, @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_ndp_initiate,  + __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; @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_ndp_initiate,  + 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 @@ net/wireless/trace.h: TRACE_EVENT(rdev_nan_ndp_initiate,  + __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)  +); 12: 470b53e6f011 ! 12: dc4677336bba wifi: nl80211/cfg80211: add support for NDP termination in offload mode @@ Metadata ## Commit message ## wifi: nl80211/cfg80211: add support for NDP termination in offload mode  - Add NL80211_CMD_NAN_NDP_TERMINATE to let userspace tear down an - established NDP session when the device offloads NDP management. Pass - the initiator NDI from the request through to the driver; it may + 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   ## include/net/cfg80211.h ##  @@ include/net/cfg80211.h: struct cfg80211_nan_ndp_respond { - u8 transport_protocol; + u16 qos_max_latency; };   +/** @@ include/net/cfg80211.h: struct cfg80211_nan_ndp_respond { * enum cfg80211_nan_conf_changes - indicates changed fields in NAN * configuration  @@ include/net/cfg80211.h: struct mgmt_frame_regs { - * 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. -+ * @nan_ndp_terminate: Terminate an established NDP session. -+ * Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP. Returning -+ * success acknowledges the request; report completion asynchronously with + * 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 @@ include/net/cfg80211.h: struct cfg80211_ops {  ## include/uapi/linux/nl80211.h ##  @@ - * processing; setup outcome is reported asynchronously by - * %NL80211_CMD_NAN_NDP_STATUS. - * Transport port and protocol may be supplied together only when accepting. -+ * @NL80211_CMD_NAN_NDP_TERMINATE: Terminate an established NDP. + * 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. @@ include/uapi/linux/nl80211.h: enum nl80211_commands {   ## net/wireless/nl80211.c ## +@@ net/wireless/nl80211.c: 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,  @@ net/wireless/nl80211.c: static int nl80211_nan_ndp_respond(struct sk_buff *skb, return rdev_nan_ndp_respond(rdev, wdev, ¶ms); } 13: b4fdd3145c05 ! 13: 6ee328f3e8bb wifi: nl80211/cfg80211: add support for NDP request indication @@ include/net/cfg80211.h: cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,  ## include/uapi/linux/nl80211.h ##  @@ - * failure with %NL80211_CMD_NAN_NDP_STATUS. The device chooses the bandwidth. + * 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 @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes {  + * 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_CHANNEL_FREQ: optional u32 channel frequency in MHz. + * @NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS: optional u8 Minimum Time Slots field  ## net/wireless/nl80211.c ##  @@ net/wireless/nl80211.c: static int nl80211_nan_ndp_terminate(struct sk_buff *skb, 14: 87541134b0fd ! 14: f65c34c0add2 wifi: nl80211/cfg80211: add support for NDP status indication @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes {  + * 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_CHANNEL_FREQ: optional u32 channel frequency in MHz. + * @NL80211_NAN_NDP_ATTR_QOS_MIN_SLOTS: optional u8 Minimum Time Slots field  @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes { - * %NL80211_CMD_NAN_NDP_INITIATE and - * @NL80211_NAN_NDP_ATTR_CHANNEL_FREQ. The requested channel must be included - * in the NDL. If it cannot be used, for example because it is incompatible -- * with peer availability, setup fails. -+ * with the peer's availability, setup fails and the failure is reported -+ * with %NL80211_CMD_NAN_NDP_STATUS. + * %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. 15: 55bb62fcd497 ! 15: 818342eb59f1 wifi: nl80211/cfg80211: add support for NDP terminated indication @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes { * @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute. */  @@ include/uapi/linux/nl80211.h: enum nl80211_nan_ndp_attributes { - NL80211_NAN_NDP_ATTR_CHANNEL_FORCED, + NL80211_NAN_NDP_ATTR_QOS_MAX_LATENCY, NL80211_NAN_NDP_ATTR_ACCEPT, NL80211_NAN_NDP_ATTR_REASON,  + NL80211_NAN_NDP_ATTR_LOCALLY_GENERATED, 16: 2532ddc027f0 < -: ------------ wifi: nl80211/cfg80211: support updating an offloaded NAN publish function  -: ------------ > 16: 94d83509341f wifi: nl80211/cfg80211: support updating an offloaded NAN publish function 17: b759557a2605 ! 17: 5d525efba5c2 wifi: nl80211/cfg80211: allow extra NAN attributes in offloaded functions @@ net/wireless/trace.h: TRACE_EVENT(rdev_add_nan_func,  + __entry->cookie, __entry->extra_attrs_len) );  - TRACE_EVENT(rdev_del_nan_func, + TRACE_EVENT(rdev_nan_update_publish,  ## net/wireless/util.c ##  @@ net/wireless/util.c: void cfg80211_free_nan_func(struct cfg80211_nan_func *f) 18: bce6c60d0cb4 ! 18: 155cc1af8d0f wifi: nl80211/cfg80211: add NAN group key capabilities to NAN functions @@ include/net/cfg80211.h: struct cfg80211_nan_func { u32 *csids; u8 num_csids;  @@ include/net/cfg80211.h: struct wiphy_radio { - * and security handshakes. It negotiates the NDL and manages local and peer - * NAN schedules, including NDC and immutable schedules, ULW, schedule updates, - * and evacuation of its own channels. It 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 configure NAN schedules or add those NDI peer stations or their -- * keys. The driver implements @nan_ndp_initiate, @nan_ndp_respond, and -+ * 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 configure NAN schedules or add those NDI peer stations or their keys. -+ * 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 + * %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  ## include/uapi/linux/nl80211.h ##  @@ include/uapi/linux/nl80211.h: enum nl80211_nan_publish_type { @@ include/uapi/linux/nl80211.h: enum nl80211_nan_conf_attributes { * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED is set. * @NL80211_NAN_NDP_ATTR_IPV6_INTF_ID: binary IPv6 link-local interface  @@ include/uapi/linux/nl80211.h: enum nl80211_s1g_short_beacon_attrs { - * negotiates the NDL and manages local and peer NAN schedules, including NDC - * and immutable schedules, ULW, schedule updates, and evacuation of its own - * channels. It 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 configure NAN schedules or add those NDI peer stations or their -- * keys. In particular, %NL80211_CMD_NAN_SET_LOCAL_SCHED, -- * %NL80211_CMD_NAN_SET_PEER_SCHED, and -+ * installs, and removes data path keys (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 configure -+ * NAN schedules or add those NDI peer stations or their keys. In particular, -+ * %NL80211_CMD_NAN_SET_LOCAL_SCHED, %NL80211_CMD_NAN_SET_PEER_SCHED, and - * %NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS are not supported. 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, + * 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  ## net/wireless/nl80211.c ##  @@ net/wireless/nl80211.c: nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = { 19: 8472e385c13b < -: ------------ wifi: nl80211/cfg80211: pass Instant Communication frequency for NAN offload  -: ------------ > 19: 76396e407375 wifi: nl80211/cfg80211: select the 5 GHz NAN channel for IC