From 55ab5eccd1a5ec98416b611c5aa6fdb4c9b51062 Mon Sep 17 00:00:00 2001 From: Miri Korenblit Date: Tue, 22 Sep 2026 14:01:51 +0300 Subject: [PATCH] wifi: nl80211: allow a NAN peer schedule with 2 channels in the same slot A NAN peer that has dual radio can schedule a slot to 2 different channels. Until now, for single radio devices, we disallowed such a peer schedule. This was done so because the assumption was that the user space needs to pick one of the channels for us, according to its logic. But for devices that have their ULW logic offloaded, it can be useful if we program it with the full information and let it decide what to do. For example: - peer has slot S scheduled to C1 and C2 - local schedule has S scheduled to C1 - in practice, the device is on C2 at S, for example due to non-NAN activity In that case, this extra information can actually be useful to the device, and bring to more efficient usage of the time. Allow a peer schedule that has a single slot scheduled to two different channels. Signed-off-by: Miri Korenblit Link: https://patch.msgid.link/20260922140131.6c3e3f552bda.I056644aaeea3f96605272651c4108e9ff224caf1@changeid Signed-off-by: Johannes Berg --- include/uapi/linux/nl80211.h | 10 ++++++---- net/wireless/nl80211.c | 23 ++--------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index be9e2842a736..75d4c5d6a7a3 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -1406,10 +1406,12 @@ * be provided. * Each peer channel must be compatible with at least one local channel * set by %NL80211_CMD_SET_LOCAL_NAN_SCHED. Different maps must not - * contain compatible channels. - * For single-radio devices (n_radio <= 1), different maps must not - * schedule the same time slot, as the device cannot operate on multiple - * channels simultaneously. + * contain compatible channels. Two maps may schedule the same time slot. + * The device decides at runtime which of the channels to follow. + * For example, the local schedule may place slot S on channel c1 while + * the peer advertises slot S on both c1 and c2. If the device is anyway + * on c2 during slot S (e.g. via the ULW mechanism for non-NAN activity), + * it may use slot S on c2 to communicate with the peer. * When updating an existing peer schedule, the full new schedule must be * provided - partial updates are not supported. The new schedule will * completely replace the previous one. diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 58d336498125..16c63383923b 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -17566,8 +17566,7 @@ nl80211_parse_nan_peer_map(struct genl_info *info, struct nlattr *map_attr, map->schedule, n_channels); } -static int nl80211_nan_validate_map_pair(struct wiphy *wiphy, - struct genl_info *info, +static int nl80211_nan_validate_map_pair(struct genl_info *info, const struct cfg80211_nan_peer_map *map1, const struct cfg80211_nan_peer_map *map2, struct cfg80211_nan_channel *nan_channels) @@ -17602,24 +17601,6 @@ static int nl80211_nan_validate_map_pair(struct wiphy *wiphy, } } - /* - * Check for conflicting time slots between maps. - * Only check for single-radio devices (n_radio <= 1) which cannot - * operate on multiple channels simultaneously. - */ - if (wiphy->n_radio > 1) - return 0; - - for (int i = 0; i < ARRAY_SIZE(map1->schedule); i++) { - if (map1->schedule[i] != NL80211_NAN_SCHED_NOT_AVAIL_SLOT && - map2->schedule[i] != NL80211_NAN_SCHED_NOT_AVAIL_SLOT) { - NL_SET_ERR_MSG_FMT(info->extack, - "Maps %u and %u both schedule slot %d", - map1->map_id, map2->map_id, i); - return -EINVAL; - } - } - return 0; } @@ -17736,7 +17717,7 @@ static int nl80211_nan_set_peer_sched(struct sk_buff *skb, /* Validate against previous maps */ for (int j = 0; j < n_maps; j++) { - ret = nl80211_nan_validate_map_pair(&rdev->wiphy, info, + ret = nl80211_nan_validate_map_pair(info, &sched.maps[j], &sched.maps[n_maps], nan_channels);