From: Kavita Kavita Extend cfg80211_nan_match_params with ranging_indication and ranging_measurement fields to allow the driver/firmware to report NAN Ranging results as part of the NAN Service Match indication in offload mode. Add the corresponding attributes NL80211_NAN_MATCH_RANGING_INDICATION and NL80211_NAN_MATCH_RANGING_MEASUREMENT and serialize them in cfg80211_nan_match() so that userspace (e.g., wpa_supplicant) can receive the NAN Ranging Report along with the NAN Service Match event. Send ranging info to userspace only if ranging_indication is non-zero. ranging_indication is a bitmask with four valid combinations: - bit 0 set: continuous ranging - bit 1 set: ingress condition met - bit 2 set: egress condition met - bit 1 and bit 2 set: both ingress and egress conditions met Leave validation of the combination to userspace (e.g., wpa_supplicant). Signed-off-by: Kavita Kavita Signed-off-by: Shivani Baranwal --- include/net/cfg80211.h | 4 ++++ include/uapi/linux/nl80211.h | 11 ++++++++++- net/wireless/nl80211.c | 11 +++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 6ac4e2e22881..aadfed50b4e2 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -10635,6 +10635,8 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f); * Only valid when @rssi_valid is true. * @rssi_valid: if true, @rssi contains a valid RSSI measurement. * @cookie: unique identifier of the corresponding function + * @ranging_indication: bitmap indicating the type of ranging performed. + * @ranging_measurement: distance to the peer in millimetres. */ struct cfg80211_nan_match_params { enum nl80211_nan_function_type type; @@ -10657,6 +10659,8 @@ struct cfg80211_nan_match_params { s32 rssi; bool rssi_valid; u64 cookie; + u8 ranging_indication; + s32 ranging_measurement; }; /** diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 1e640a03e73d..af2b3a12572e 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7888,7 +7888,8 @@ enum nl80211_nan_srf_attributes { * See &enum nl80211_nan_func_attributes. * @NL80211_NAN_MATCH_SDEA_CTRL: u16 SDEA control field from the peer's * Service Descriptor Extension Attribute. Bit 2 indicates Data Path - * Required, bit 6 Security Required, bit 10 GTK Required. + * Required, bit 6 Security Required, bit 7 Ranging Required, bit 10 + * GTK Required. * @NL80211_NAN_MATCH_BOOTSTRAP_METHODS: u16 bitmap of the peer's * supported NAN pairing bootstrapping methods per the Wi-Fi Aware * Specification Table 9-321. @@ -7907,6 +7908,12 @@ enum nl80211_nan_srf_attributes { * @NL80211_NAN_MATCH_RSSI: s32 attribute. Received signal strength in dBm * at the time of the match. Only present when the driver provides a * valid RSSI measurement. + * @NL80211_NAN_MATCH_RANGING_INDICATION: u8 attribute. Bitmap indicating + * the type of ranging performed: bit 0: continuous ranging, + * bit 1: ingress condition met, bit 2: egress condition met, + * bit 1 and bit 2: both conditions met. Only present when non-zero. + * @NL80211_NAN_MATCH_RANGING_MEASUREMENT: s32 attribute. Distance to + * the peer in millimetres measured via FTM. * * @NUM_NL80211_NAN_MATCH_ATTR: internal * @NL80211_NAN_MATCH_ATTR_MAX: highest NAN match attribute @@ -7924,6 +7931,8 @@ enum nl80211_nan_match_attributes { NL80211_NAN_MATCH_EXTRA_INFO, NL80211_NAN_MATCH_IES, NL80211_NAN_MATCH_RSSI, + NL80211_NAN_MATCH_RANGING_INDICATION, + NL80211_NAN_MATCH_RANGING_MEASUREMENT, /* keep last */ NUM_NL80211_NAN_MATCH_ATTR, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index e480f556ce62..3147eeab84da 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -18017,6 +18017,17 @@ void cfg80211_nan_match(struct wireless_dev *wdev, nla_put_s32(msg, NL80211_NAN_MATCH_RSSI, match->rssi)) goto nla_put_failure; + /* report ranging info only if ranging was indicated */ + if (match->ranging_indication) { + if (nla_put_u8(msg, NL80211_NAN_MATCH_RANGING_INDICATION, + match->ranging_indication)) + goto nla_put_failure; + + if (nla_put_s32(msg, NL80211_NAN_MATCH_RANGING_MEASUREMENT, + match->ranging_measurement)) + goto nla_put_failure; + } + nla_nest_end(msg, match_attr); genlmsg_end(msg, hdr); -- 2.34.1