Add optional result reporting control for proximity detection (PD) requests, allowing userspace to disable ranging result reports when measurement data is not needed. This reduces unnecessary data transfer and processing overhead for applications that only require proximity detection without detailed ranging measurements. The implementation validates that result reporting control is only used with PD requests and ensures proper configuration when operating as responder (RSTA role). For RSTA operations requesting results, either LMR feedback or range report must be enabled to provide a mechanism for result delivery. This prevents invalid configurations where results are requested but no delivery method is available. Signed-off-by: Peddolla Harshavardhan Reddy --- include/net/cfg80211.h | 8 +++++++- include/uapi/linux/nl80211.h | 9 +++++++++ net/wireless/nl80211.c | 1 + net/wireless/pmsr.c | 19 +++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 890d4b007033..00ef211f20f1 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -4394,6 +4394,11 @@ struct cfg80211_pmsr_result { * in this case. * @range_report: negotiate for FTM range report. Only valid for * EDCA based ranging. + * @pd_require_range_results: flag to enable receiving results + * for PD requests. if this flag is disabled then ranging result will not + * be reported regardless of ranging role or the type or ranging. Only + * valid if @pd_request is set. in case @rsta is set, either @range_report + * or @lmr_feedback should be set inorder for the request to be valid. * See also nl80211 for the respective attribute documentation. */ struct cfg80211_pmsr_ftm_request_peer { @@ -4419,7 +4424,8 @@ struct cfg80211_pmsr_ftm_request_peer { u8 measurements_per_aw; u64 ingress_distancemm; u64 egress_distancemm; - u8 range_report:1; + u8 range_report:1, + pd_require_range_results:1; }; /** diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index af80248d24a1..85223b16eb84 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7995,6 +7995,14 @@ enum nl80211_peer_measurement_ftm_capa { * (units mm, u64) * @NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT: Negotiate Range report in case of * EDCA based ranging. + * @NL80211_PMSR_FTM_REQ_ATTR_PD_REPORT_RESULT: flag to enable receiving results + * for PD requests. if this flag is disabled then ranging result will not + * reported regardless of ranging role or the type or ranging. Only valid + * if %NL80211_PMSR_PEER_ATTR_PD_REQUEST is set. in case + * %NL80211_PMSR_FTM_REQ_ATTR_RSTA is set, either + * %NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT or + * %NL80211_PMSR_FTM_REQ_ATTR_LMR_FEEDBACK should be set inorder for + * request to be valid. * * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number @@ -8024,6 +8032,7 @@ enum nl80211_peer_measurement_ftm_req { NL80211_PMSR_FTM_REQ_ATTR_INGRESS, NL80211_PMSR_FTM_REQ_ATTR_EGRESS, NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT, + NL80211_PMSR_FTM_REQ_ATTR_PD_REPORT_RESULT, /* keep last */ NUM_NL80211_PMSR_FTM_REQ_ATTR, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index bbb80032d615..6d53eb3eb78c 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -374,6 +374,7 @@ nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = { [NL80211_PMSR_FTM_REQ_ATTR_INGRESS] = { .type = NLA_U64 }, [NL80211_PMSR_FTM_REQ_ATTR_EGRESS] = { .type = NLA_U64 }, [NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT] = { .type = NLA_FLAG }, + [NL80211_PMSR_FTM_REQ_ATTR_PD_REPORT_RESULT] = { .type = NLA_FLAG }, }; static const struct nla_policy diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c index f89fcd9bb505..a55eb73e6938 100644 --- a/net/wireless/pmsr.c +++ b/net/wireless/pmsr.c @@ -260,6 +260,25 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, return -EINVAL; } + if (tb[NL80211_PMSR_FTM_REQ_ATTR_PD_REPORT_RESULT]) + out->ftm.pd_require_range_results = + nla_get_flag(tb[NL80211_PMSR_FTM_REQ_ATTR_PD_REPORT_RESULT]); + + if (!out->pd_request && out->ftm.pd_require_range_results) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[NL80211_PMSR_FTM_REQ_ATTR_PD_REPORT_RESULT], + "FTM: require range result flag only valid for PD requests"); + return -EINVAL; + } + + if (out->ftm.pd_require_range_results && out->ftm.rsta && + (!out->ftm.range_report && !out->ftm.lmr_feedback)) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[NL80211_PMSR_FTM_REQ_ATTR_PD_REPORT_RESULT], + "FTM: range results requested for responder without LMR or range report"); + return -EINVAL; + } + return 0; } -- 2.34.1