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 | 8 ++++++++ net/wireless/nl80211.c | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 9d386803e101..4689d8d15c42 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -10771,6 +10771,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; @@ -10785,6 +10787,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 6955dc5a28f5..56ed7e2c12ed 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7968,6 +7968,12 @@ enum nl80211_nan_srf_attributes { * @NL80211_NAN_MATCH_FUNC_PEER: the peer function * that caused the match. This is a nested attribute. * See &enum nl80211_nan_func_attributes. + * @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 @@ -7976,6 +7982,8 @@ enum nl80211_nan_match_attributes { __NL80211_NAN_MATCH_INVALID, NL80211_NAN_MATCH_FUNC_LOCAL, NL80211_NAN_MATCH_FUNC_PEER, + 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 5aed12783097..7f069c0908d8 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -18046,6 +18046,17 @@ void cfg80211_nan_match(struct wireless_dev *wdev, goto nla_put_failure; nla_nest_end(msg, peer_func_attr); + + /* 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