Wi-Fi Aware v4.0 specifies that Instant Communication (IC) uses the 5 GHz NAN discovery channel when the intended peer is known to support 5 GHz; otherwise it uses the 2.4 GHz discovery channel. The NAN band configurations already provide these discovery channels. Add optional NL80211_NAN_CONF_INSTANT_COMM_5GHZ to select the configured 5 GHz channel for IC. Without the flag, IC uses the 2.4 GHz channel. The flag requires IC to be enabled and a 5 GHz NAN channel to be available after band defaults are applied. Its use is independent of Discovery Engine offload. Signed-off-by: Shivani Baranwal --- include/net/cfg80211.h | 3 +++ include/uapi/linux/nl80211.h | 10 +++++++++- net/mac80211/cfg.c | 1 + net/wireless/nl80211.c | 13 +++++++++++++ net/wireless/trace.h | 18 ++++++++++++++---- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index f056eea67a0d..ac87ab226638 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4249,6 +4249,8 @@ struct cfg80211_nan_band_config { * notifications. * @instant_comm: if true, start Instant Communication (IC) as defined in * Chapter 13 of the Wi-Fi Aware Specification v4.0. + * @instant_comm_5ghz: if true, use the configured 5 GHz NAN discovery channel + * for Instant Communication; otherwise use the 2.4 GHz discovery channel. * @pairing_setup: if true, enable NAN pairing setup. * @pairing_npk_caching: if true, enable NPK/NIK caching. * @band_cfgs: array of band specific configurations, indexed by @@ -4267,6 +4269,7 @@ struct cfg80211_nan_conf { u8 discovery_beacon_interval; bool enable_dw_notification; bool instant_comm; + bool instant_comm_5ghz; bool pairing_setup; bool pairing_npk_caching; struct cfg80211_nan_band_config band_cfgs[NUM_NL80211_BANDS]; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 2ab8f0c0bd1d..5281fef9e5f0 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -8191,7 +8191,9 @@ enum nl80211_nan_band_conf_attributes { * start Instant Communication (IC) as defined in Chapter 13 of the * Wi-Fi Aware Specification v4.0. * %NL80211_NAN_CONF_DISCOVERY_BEACON_INTERVAL must be set as well. - * This is a flag attribute. + * If %NL80211_NAN_CONF_INSTANT_COMM_5GHZ is set, IC uses the configured + * 5 GHz NAN discovery channel; otherwise it uses the 2.4 GHz discovery + * channel. This is a flag attribute. * @NL80211_NAN_CONF_PAIRING_SETUP: flag attribute. Enables NAN pairing setup * and is advertised as "Pairing Setup Enabled" in the DCEA. Only valid for * devices that offload the NAN Discovery Engine (i.e. without @@ -8202,6 +8204,11 @@ enum nl80211_nan_band_conf_attributes { * valid for devices that offload the NAN Discovery Engine (i.e. without * %NL80211_NAN_CAPA_USERSPACE_DE) and requires * %NL80211_EXT_FEATURE_SECURE_NAN. + * @NL80211_NAN_CONF_INSTANT_COMM_5GHZ: optional flag, valid only together with + * %NL80211_NAN_CONF_INSTANT_COMM and when a 5 GHz NAN band configuration + * provides a discovery channel. When set, IC uses that 5 GHz channel; + * otherwise IC uses the 2.4 GHz NAN discovery channel. Wi-Fi Aware v4.0 + * uses 5 GHz when the intended peer is known to support it. * @NUM_NL80211_NAN_CONF_ATTR: Internal. * @NL80211_NAN_CONF_ATTR_MAX: Highest NAN configuration attribute. * @@ -8220,6 +8227,7 @@ enum nl80211_nan_conf_attributes { NL80211_NAN_CONF_INSTANT_COMM, NL80211_NAN_CONF_PAIRING_SETUP, NL80211_NAN_CONF_PAIRING_NPK_CACHING, + NL80211_NAN_CONF_INSTANT_COMM_5GHZ, /* keep last */ NUM_NL80211_NAN_CONF_ATTR, diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 9e47360ee8f5..ed5955c94d5b 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -369,6 +369,7 @@ static int ieee80211_nan_conf_copy(struct cfg80211_nan_conf *dst, src->discovery_beacon_interval; dst->enable_dw_notification = src->enable_dw_notification; dst->instant_comm = src->instant_comm; + dst->instant_comm_5ghz = src->instant_comm_5ghz; memcpy(&dst->band_cfgs, &src->band_cfgs, sizeof(dst->band_cfgs)); diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a4e86c420ef4..9002b68fc630 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -914,6 +914,7 @@ nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = { [NL80211_NAN_CONF_INSTANT_COMM] = { .type = NLA_FLAG }, [NL80211_NAN_CONF_PAIRING_SETUP] = { .type = NLA_FLAG }, [NL80211_NAN_CONF_PAIRING_NPK_CACHING] = { .type = NLA_FLAG }, + [NL80211_NAN_CONF_INSTANT_COMM_5GHZ] = { .type = NLA_FLAG }, }; static const struct netlink_range_validation nl80211_punct_bitmap_range = { @@ -17401,6 +17402,9 @@ static int nl80211_parse_nan_conf(struct wiphy *wiphy, nla_get_flag(attrs[NL80211_NAN_CONF_NOTIFY_DW]); conf->instant_comm = nla_get_flag(attrs[NL80211_NAN_CONF_INSTANT_COMM]); + conf->instant_comm_5ghz = + nla_get_flag(attrs[NL80211_NAN_CONF_INSTANT_COMM_5GHZ]); + if (conf->instant_comm) { if (!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_INSTANT_COMM)) { NL_SET_ERR_MSG_ATTR(info->extack, @@ -17458,6 +17462,15 @@ static int nl80211_parse_nan_conf(struct wiphy *wiphy, } } + if (conf->instant_comm_5ghz && + (!conf->instant_comm || + !conf->band_cfgs[NL80211_BAND_5GHZ].chan)) { + NL_SET_ERR_MSG_ATTR(info->extack, + attrs[NL80211_NAN_CONF_INSTANT_COMM_5GHZ], + "5 GHz Instant Communication requires IC and a 5 GHz NAN channel"); + return -EINVAL; + } + if (changed_flags) *changed_flags = changed; diff --git a/net/wireless/trace.h b/net/wireless/trace.h index a1e6af3d77ba..405b232508f0 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h @@ -2387,17 +2387,22 @@ TRACE_EVENT(rdev_start_nan, WDEV_ENTRY __field(u8, master_pref) __field(u8, bands) + __field(u8, instant_comm) + __field(u8, instant_comm_5ghz) ), TP_fast_assign( WIPHY_ASSIGN; WDEV_ASSIGN; __entry->master_pref = conf->master_pref; __entry->bands = conf->bands; + __entry->instant_comm = conf->instant_comm; + __entry->instant_comm_5ghz = conf->instant_comm_5ghz; ), TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT - ", master preference: %u, bands: 0x%0x", + ", master preference: %u, bands: 0x%0x, IC: %u, IC 5 GHz: %u", WIPHY_PR_ARG, WDEV_PR_ARG, __entry->master_pref, - __entry->bands) + __entry->bands, __entry->instant_comm, + __entry->instant_comm_5ghz) ); TRACE_EVENT(rdev_nan_change_conf, @@ -2409,6 +2414,8 @@ TRACE_EVENT(rdev_nan_change_conf, WDEV_ENTRY __field(u8, master_pref) __field(u8, bands) + __field(u8, instant_comm) + __field(u8, instant_comm_5ghz) __field(u32, changes) ), TP_fast_assign( @@ -2416,12 +2423,15 @@ TRACE_EVENT(rdev_nan_change_conf, WDEV_ASSIGN; __entry->master_pref = conf->master_pref; __entry->bands = conf->bands; + __entry->instant_comm = conf->instant_comm; + __entry->instant_comm_5ghz = conf->instant_comm_5ghz; __entry->changes = changes; ), TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT - ", master preference: %u, bands: 0x%0x, changes: %x", + ", master preference: %u, bands: 0x%0x, IC: %u, IC 5 GHz: %u, changes: %x", WIPHY_PR_ARG, WDEV_PR_ARG, __entry->master_pref, - __entry->bands, __entry->changes) + __entry->bands, __entry->instant_comm, + __entry->instant_comm_5ghz, __entry->changes) ); DEFINE_EVENT(wiphy_wdev_evt, rdev_stop_nan, -- 2.34.1