Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

wifi: nl80211: Add NAN Discovery Window (DW) notification

This notification will be used by the device to inform user space
about upcoming DW. When received, user space will be able to prepare
multicast Service Discovery Frames (SDFs) to be transmitted during the
next DW using %NL80211_CMD_FRAME command on the NAN management interface.
The device/driver will take care to transmit the frames in the correct
timing. This allows to implement a synchronized Discovery Engine (DE)
in user space, if the device doesn't support DE offload.
Note that this notification can be sent before the actual DW starts as
long as the driver/device handles the actual timing of the SDF
transmission.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20250908140015.0e1d15031bab.I5b1721e61b63910452b3c5cdcdc1e94cb094d4c9@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Andrei Otcheretianski and committed by
Johannes Berg
ba9b2cea 01b4a306

+89
+12
include/net/cfg80211.h
··· 3959 3959 * @scan_period: period (in seconds) between NAN scans. 3960 3960 * @scan_dwell_time: dwell time (in milliseconds) for NAN scans. 3961 3961 * @discovery_beacon_interval: interval (in TUs) for discovery beacons. 3962 + * @enable_dw_notification: flag to enable/disable discovery window 3963 + * notifications. 3962 3964 * @band_cfgs: array of band specific configurations, indexed by 3963 3965 * &enum nl80211_band values. 3964 3966 * @extra_nan_attrs: pointer to additional NAN attributes. ··· 3975 3973 u16 scan_period; 3976 3974 u16 scan_dwell_time; 3977 3975 u8 discovery_beacon_interval; 3976 + bool enable_dw_notification; 3978 3977 struct cfg80211_nan_band_config band_cfgs[NUM_NL80211_BANDS]; 3979 3978 const u8 *extra_nan_attrs; 3980 3979 u16 extra_nan_attrs_len; ··· 10064 10061 * @enabled: set to true if EPCS was enabled, otherwise set to false. 10065 10062 */ 10066 10063 void cfg80211_epcs_changed(struct net_device *netdev, bool enabled); 10064 + 10065 + /** 10066 + * cfg80211_next_nan_dw_notif - Notify about the next NAN Discovery Window (DW) 10067 + * @wdev: Pointer to the wireless device structure 10068 + * @chan: DW channel (6, 44 or 149) 10069 + * @gfp: Memory allocation flags 10070 + */ 10071 + void cfg80211_next_nan_dw_notif(struct wireless_dev *wdev, 10072 + struct ieee80211_channel *chan, gfp_t gfp); 10067 10073 10068 10074 #ifdef CONFIG_CFG80211_DEBUGFS 10069 10075 /**
+16
include/uapi/linux/nl80211.h
··· 1349 1349 * control EPCS configuration. Used to notify userland on the current state 1350 1350 * of EPCS. 1351 1351 * 1352 + * @NL80211_CMD_NAN_NEXT_DW_NOTIFICATION: This command is used to notify 1353 + * user space about the next NAN Discovery Window (DW). User space may use 1354 + * it to prepare frames to be sent in the next DW. 1355 + * %NL80211_ATTR_WIPHY_FREQ is used to indicate the frequency of the next 1356 + * DW. SDF transmission should be requested with %NL80211_CMD_FRAME and 1357 + * the device/driver shall take care of the actual transmission timing. 1358 + * This notification is only sent to the NAN interface owning socket 1359 + * (see %NL80211_ATTR_SOCKET_OWNER flag). 1360 + * 1352 1361 * @NL80211_CMD_MAX: highest used command number 1353 1362 * @__NL80211_CMD_AFTER_LAST: internal use 1354 1363 */ ··· 1617 1608 1618 1609 NL80211_CMD_ASSOC_MLO_RECONF, 1619 1610 NL80211_CMD_EPCS_CFG, 1611 + 1612 + NL80211_CMD_NAN_NEXT_DW_NOTIFICATION, 1620 1613 1621 1614 /* add new commands above here */ 1622 1615 ··· 7420 7409 * @NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL: Discovery beacon interval 7421 7410 * in TUs. Valid range is 50-200 TUs. If not configured the device default 7422 7411 * value is used. This is u8 (optional) 7412 + * @NL80211_NAN_CONF_NOTIFY_DW: If set, the driver will notify userspace about 7413 + * the upcoming discovery window with 7414 + * %NL80211_CMD_NAN_NEXT_DW_NOTIFICATION. 7415 + * This is a flag attribute. 7423 7416 * @NUM_NL80211_NAN_CONF_ATTR: Internal. 7424 7417 * @NL80211_NAN_CONF_ATTR_MAX: Highest NAN configuration attribute. 7425 7418 * ··· 7438 7423 NL80211_NAN_CONF_SCAN_PERIOD, 7439 7424 NL80211_NAN_CONF_SCAN_DWELL_TIME, 7440 7425 NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL, 7426 + NL80211_NAN_CONF_NOTIFY_DW, 7441 7427 7442 7428 /* keep last */ 7443 7429 NUM_NL80211_NAN_CONF_ATTR,
+45
net/wireless/nl80211.c
··· 547 547 [NL80211_NAN_CONF_SCAN_DWELL_TIME] = NLA_POLICY_RANGE(NLA_U16, 50, 512), 548 548 [NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL] = 549 549 NLA_POLICY_RANGE(NLA_U8, 50, 200), 550 + [NL80211_NAN_CONF_NOTIFY_DW] = { .type = NLA_FLAG }, 550 551 }; 551 552 552 553 static const struct netlink_range_validation nl80211_punct_bitmap_range = { ··· 15628 15627 if (attrs[NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL]) 15629 15628 conf->discovery_beacon_interval = 15630 15629 nla_get_u8(attrs[NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL]); 15630 + 15631 + if (attrs[NL80211_NAN_CONF_NOTIFY_DW]) 15632 + conf->enable_dw_notification = 15633 + nla_get_flag(attrs[NL80211_NAN_CONF_NOTIFY_DW]); 15634 + 15631 15635 out: 15632 15636 if (!conf->band_cfgs[NL80211_BAND_5GHZ].chan && 15633 15637 (!conf->bands || conf->bands & BIT(NL80211_BAND_5GHZ))) { ··· 21769 21763 nlmsg_free(msg); 21770 21764 } 21771 21765 EXPORT_SYMBOL(cfg80211_epcs_changed); 21766 + 21767 + void cfg80211_next_nan_dw_notif(struct wireless_dev *wdev, 21768 + struct ieee80211_channel *chan, gfp_t gfp) 21769 + { 21770 + struct wiphy *wiphy = wdev->wiphy; 21771 + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); 21772 + struct sk_buff *msg; 21773 + void *hdr; 21774 + 21775 + trace_cfg80211_next_nan_dw_notif(wdev, chan); 21776 + 21777 + if (!wdev->owner_nlportid) 21778 + return; 21779 + 21780 + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp); 21781 + if (!msg) 21782 + return; 21783 + 21784 + hdr = nl80211hdr_put(msg, 0, 0, 0, 21785 + NL80211_CMD_NAN_NEXT_DW_NOTIFICATION); 21786 + if (!hdr) 21787 + goto nla_put_failure; 21788 + 21789 + if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) || 21790 + nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev), 21791 + NL80211_ATTR_PAD) || 21792 + nla_put_u32(msg, NL80211_ATTR_WIPHY_FREQ, chan->center_freq)) 21793 + goto nla_put_failure; 21794 + 21795 + genlmsg_end(msg, hdr); 21796 + 21797 + genlmsg_unicast(wiphy_net(wiphy), msg, wdev->owner_nlportid); 21798 + 21799 + return; 21800 + 21801 + nla_put_failure: 21802 + nlmsg_free(msg); 21803 + } 21804 + EXPORT_SYMBOL(cfg80211_next_nan_dw_notif); 21772 21805 21773 21806 /* initialisation/exit functions */ 21774 21807
+16
net/wireless/trace.h
··· 4166 4166 WDEV_PR_ARG, __entry->enabled) 4167 4167 ); 4168 4168 4169 + TRACE_EVENT(cfg80211_next_nan_dw_notif, 4170 + TP_PROTO(struct wireless_dev *wdev, 4171 + struct ieee80211_channel *chan), 4172 + TP_ARGS(wdev, chan), 4173 + TP_STRUCT__entry( 4174 + WDEV_ENTRY 4175 + CHAN_ENTRY 4176 + ), 4177 + TP_fast_assign( 4178 + WDEV_ASSIGN; 4179 + CHAN_ASSIGN(chan); 4180 + ), 4181 + TP_printk(WDEV_PR_FMT " " CHAN_PR_FMT, 4182 + WDEV_PR_ARG, CHAN_PR_ARG) 4183 + ); 4184 + 4169 4185 #endif /* !__RDEV_OPS_TRACE || TRACE_HEADER_MULTI_READ */ 4170 4186 4171 4187 #undef TRACE_INCLUDE_PATH