Proximity detection often does not require detailed ranging measurements, yet userspace currently receives full FTM results for every request, causing unnecessary data transfer, host wakeups, and processing overhead. Add an optional control to suppress ranging result reporting for peer-to-peer PD requests. Introduce the NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS flag, when set with a PD request, the device may perform the measurements (e.g. when acting as RSTA) but must not report the measurement results to userspace. Validate that the flag is only accepted when a PD request is present, reject otherwise. Signed-off-by: Peddolla Harshavardhan Reddy --- include/net/cfg80211.h | 8 +++++++- include/uapi/linux/nl80211.h | 6 +++++- net/wireless/nl80211.c | 1 + net/wireless/pmsr.c | 10 ++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index d841ada4ddc1..96abe2eb28bb 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4427,6 +4427,11 @@ struct cfg80211_pmsr_result { * indicate the driver should set the BSS color. Only valid if * @non_trigger_based or @trigger_based is set. * @pd_request: indicates a peer-to-peer PD request. + * @pd_suppress_range_results: flag to suppress ranging results for PD + * requests. When set, the device performs ranging measurements to + * provide ranging services to a peer (e.g. in RSTA role) but does + * not report the measurement results to userspace. Only valid when + * @pd_request is set. * @min_time_between_measurements: minimum time between two consecutive range * measurements in units of 100 micro seconds, applicable for * non trigger based ranging. Only valid if @non_trigger_based is set. @@ -4477,7 +4482,8 @@ struct cfg80211_pmsr_ftm_request_peer { u8 ftmr_retries; u8 bss_color; - u8 pd_request:1; + u8 pd_request:1, + pd_suppress_range_results:1; u32 min_time_between_measurements; u32 max_time_between_measurements; u32 availability_window; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index f6bd944fea1b..d5ac40a385f0 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -8118,7 +8118,10 @@ enum nl80211_peer_measurement_ftm_capa { * @NL80211_PMSR_FTM_REQ_ATTR_EGRESS: the measurement result of the peer * needs to be indicated in case the device moves out of this range. * (units mm, u64). - * + * @NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS: Flag to suppress ranging + * results for PD requests. When set, ranging measurements are performed + * but results are not reported to userspace, regardless of ranging role + * or type. Only valid when %NL80211_PMSR_PEER_ATTR_PD_REQUEST is set. * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number */ @@ -8148,6 +8151,7 @@ enum nl80211_peer_measurement_ftm_req { NL80211_PMSR_FTM_REQ_ATTR_PAD, NL80211_PMSR_FTM_REQ_ATTR_INGRESS, NL80211_PMSR_FTM_REQ_ATTR_EGRESS, + NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS, /* keep last */ NUM_NL80211_PMSR_FTM_REQ_ATTR, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 74b7c4651061..cd4129ae61eb 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -397,6 +397,7 @@ nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = { [NL80211_PMSR_FTM_REQ_ATTR_NUM_MEASUREMENTS] = { .type = NLA_U32 }, [NL80211_PMSR_FTM_REQ_ATTR_INGRESS] = { .type = NLA_U64 }, [NL80211_PMSR_FTM_REQ_ATTR_EGRESS] = { .type = NLA_U64 }, + [NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS] = { .type = NLA_FLAG }, }; static const struct nla_policy diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c index d010d19d148f..21df12680839 100644 --- a/net/wireless/pmsr.c +++ b/net/wireless/pmsr.c @@ -288,6 +288,16 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, out->ftm.egress_distancemm = nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS]); + out->ftm.pd_suppress_range_results = + nla_get_flag(tb[NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS]); + + if (!out->ftm.pd_request && out->ftm.pd_suppress_range_results) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS], + "FTM: suppress range result flag only valid for PD requests"); + return -EINVAL; + } + return 0; } -- 2.34.1