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 facd5d8bc5e1..ef8c84aab332 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -10638,6 +10638,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; @@ -10652,6 +10654,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 e71db9de3ef2..bc70a8e31af6 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7872,6 +7872,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 @@ -7880,6 +7886,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 f86d593a1baf..97ee36dd8b11 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -18023,6 +18023,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