]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: cfg80211: add ingress/egress distance thresholds for FTM
authorPeddolla Harshavardhan Reddy <peddolla.reddy@oss.qualcomm.com>
Mon, 20 Apr 2026 09:08:52 +0000 (14:38 +0530)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 5 May 2026 11:43:36 +0000 (13:43 +0200)
Proximity detection applications need to receive measurement results
only when devices cross specific distance boundaries to avoid
unnecessary host wakeups and reduce power consumption.

Introduce configurable distance-based reporting thresholds that
drivers can use to implement selective result reporting. Add ingress
and egress distance parameters allowing applications to specify when
results should be reported as peers cross these boundaries.

Signed-off-by: Peddolla Harshavardhan Reddy <peddolla.reddy@oss.qualcomm.com>
Link: https://patch.msgid.link/20260420090856.2152905-10-peddolla.reddy@oss.qualcomm.com
[remove mm units from variables]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
include/net/cfg80211.h
include/uapi/linux/nl80211.h
net/wireless/nl80211.c
net/wireless/pmsr.c

index 5669948e0f3d5c048a542c0035b7472d78701ba9..87e8487503396dbde97558d722ab6cb6ccbf6b02 100644 (file)
@@ -4622,6 +4622,18 @@ struct cfg80211_pmsr_result {
  *     exchanges as configured by @ftms_per_burst. Only valid if
  *     @non_trigger_based is set. If set to 0, the firmware or driver
  *     can automatically select an appropriate value.
+ * @ingress_distance: optional ingress threshold in units of mm. When set,
+ *     the measurement result of the peer needs to be indicated if the device
+ *     moves into this range. Measurement results need to be sent on a burst
+ *     index basis in this case.
+ * @egress_distance: optional egress threshold in units of mm. When set,
+ *     the measurement result of the peer needs to be indicated if the device
+ *     moves out of this range. Measurement results need to be sent on a burst
+ *     index basis in this case.
+ *     If neither or only one of @ingress_distance and @egress_distance
+ *     is set, only the specified threshold is used. If both are set, both
+ *     thresholds are applied. If neither is set, results are reported without
+ *     threshold filtering.
  *
  * See also nl80211 for the respective attribute documentation.
  */
@@ -4648,6 +4660,8 @@ struct cfg80211_pmsr_ftm_request_peer {
        u8 availability_window;
        u32 nominal_time;
        u32 num_measurements;
+       u64 ingress_distance;
+       u64 egress_distance;
 };
 
 /**
index e31ff2a745b216b5e489e5511f5ba2a399cfa372..02fe42b4f29c1ed6ab32511c5931a91a29beff2f 100644 (file)
@@ -8341,6 +8341,18 @@ enum nl80211_peer_measurement_ftm_type_capa {
  *     %NL80211_PMSR_FTM_REQ_ATTR_NON_TRIGGER_BASED is set.
  *     If the attribute is absent ("no preference"), the driver or firmware
  *     can choose a suitable value.
+ * @NL80211_PMSR_FTM_REQ_ATTR_PAD: ignore, for u64/s64 padding only.
+ * @NL80211_PMSR_FTM_REQ_ATTR_INGRESS: optional u64 attribute in units of mm.
+ *     When specified, the measurement result of the peer needs to be
+ *     indicated if the device moves into this range.
+ * @NL80211_PMSR_FTM_REQ_ATTR_EGRESS: optional u64 attribute in units of mm.
+ *     When specified, the measurement result of the peer needs to be
+ *     indicated if the device moves out of this range.
+ *     If neither or only one of @NL80211_PMSR_FTM_REQ_ATTR_INGRESS and
+ *     @NL80211_PMSR_FTM_REQ_ATTR_EGRESS is specified, only the specified
+ *     threshold is used. If both are specified, both thresholds are applied.
+ *     If neither is specified, results are reported without threshold
+ *     filtering.
  *
  * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal
  * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number
@@ -8367,6 +8379,9 @@ enum nl80211_peer_measurement_ftm_req {
        NL80211_PMSR_FTM_REQ_ATTR_NOMINAL_TIME,
        NL80211_PMSR_FTM_REQ_ATTR_AW_DURATION,
        NL80211_PMSR_FTM_REQ_ATTR_NUM_MEASUREMENTS,
+       NL80211_PMSR_FTM_REQ_ATTR_PAD,
+       NL80211_PMSR_FTM_REQ_ATTR_INGRESS,
+       NL80211_PMSR_FTM_REQ_ATTR_EGRESS,
 
        /* keep last */
        NUM_NL80211_PMSR_FTM_REQ_ATTR,
index 0ffaa2cd780872db88149390073db4e1134b0589..ae968d53fcea33f582124ddd102f0dee58f4746f 100644 (file)
@@ -485,6 +485,8 @@ nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
        [NL80211_PMSR_FTM_REQ_ATTR_NOMINAL_TIME] = { .type = NLA_U32 },
        [NL80211_PMSR_FTM_REQ_ATTR_AW_DURATION] = NLA_POLICY_MAX(NLA_U32, 255),
        [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 },
 };
 
 static const struct nla_policy
index 432d34be7945ea2f2715efbd00bbf2e3ac7da7e0..2d6ace7f048dd74e13c67ca42bda1866f8e3cdf7 100644 (file)
@@ -264,6 +264,14 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev,
                                nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_MEASUREMENTS]);
        }
 
+       if (tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS])
+               out->ftm.ingress_distance =
+                       nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS]);
+
+       if (tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS])
+               out->ftm.egress_distance =
+                       nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS]);
+
        return 0;
 }