Devices may support different preamble and bandwidth configurations for proximity detection (PD) ranging versus standard ranging. Add separate pd_preambles and pd_bandwidths fields to cfg80211_pmsr_capabilities to allow drivers to advertise PD-specific capabilities. Expose these over nl80211 using new attributes NL80211_PMSR_FTM_CAPA_ATTR_PD_PREAMBLES and NL80211_PMSR_FTM_CAPA_ATTR_PD_BANDWIDTHS, advertised only when pd_support is set. For PD requests, validate bandwidth and preamble against pd_bandwidths and pd_preambles. For non-PD requests, validate against the existing bandwidths and preambles fields.
Unified · Split
| @@ -6053,6 +6053,10 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type); · 6052 unmodified lines | |||
| 6053 | * @ftm.concurrent_ista_rsta_support: indicates if the device can | 6053 | * @ftm.concurrent_ista_rsta_support: indicates if the device can |
| 6054 | * simultaneously act as initiator and responder in a multi-peer | 6054 | * simultaneously act as initiator and responder in a multi-peer |
| 6055 | * measurement request. Only valid if @ftm.rsta_support is set. | 6055 | * measurement request. Only valid if @ftm.rsta_support is set. |
| 6056 | * @ftm.pd_preambles: bitmap of preambles supported (&enum nl80211_preamble) | ||
| 6057 | * for PD ranging requests. Ignored if @ftm.type.pd_support is not set. | ||
| 6058 | * @ftm.pd_bandwidths: bitmap of bandwidths supported (&enum nl80211_chan_width) | ||
| 6059 | * for PD ranging requests. Ignored if @ftm.type.pd_support is not set. | ||
| 6056 | */ | 6060 | */ |
| 6057 | struct cfg80211_pmsr_capabilities { | 6061 | struct cfg80211_pmsr_capabilities { |
| 6058 | unsigned int max_peers; | 6062 | unsigned int max_peers; |
| @@ -6099,6 +6103,8 @@ struct cfg80211_pmsr_capabilities { · 40 unmodified lines | |||
| 6099 | pd_support:1; | 6103 | pd_support:1; |
| 6100 | } type; | 6104 | } type; |
| 6101 | u8 concurrent_ista_rsta_support:1; | 6105 | u8 concurrent_ista_rsta_support:1; |
| 6106 | u32 pd_preambles; | ||
| 6107 | u32 pd_bandwidths; | ||
| 6102 | } ftm; | 6108 | } ftm; |
| 6103 | }; | 6109 | }; |
| 6104 | 6110 | ||
| @@ -8189,6 +8189,14 @@ enum nl80211_peer_measurement_attrs { · 8188 unmodified lines | |||
| 8189 | * to estimate the burst period to be given in the FTM request for the | 8189 | * to estimate the burst period to be given in the FTM request for the |
| 8190 | * NTB ranging case. If non-zero, this value will be used to validate | 8190 | * NTB ranging case. If non-zero, this value will be used to validate |
| 8191 | * the nominal time in the FTM request. | 8191 | * the nominal time in the FTM request. |
| 8192 | * @NL80211_PMSR_FTM_CAPA_ATTR_PD_PREAMBLES: u32 bitmap of values from | ||
| 8193 | * &enum nl80211_preamble indicating the supported preambles for PD | ||
| 8194 | * ranging requests. Only valid if %NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT | ||
| 8195 | * is set. | ||
| 8196 | * @NL80211_PMSR_FTM_CAPA_ATTR_PD_BANDWIDTHS: u32 bitmap of values from | ||
| 8197 | * &enum nl80211_chan_width indicating the supported channel bandwidths | ||
| 8198 | * for PD ranging requests. Only valid if | ||
| 8199 | * %NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT is set. | ||
| 8192 | * | 8200 | * |
| 8193 | * @NUM_NL80211_PMSR_FTM_CAPA_ATTR: internal | 8201 | * @NUM_NL80211_PMSR_FTM_CAPA_ATTR: internal |
| 8194 | * @NL80211_PMSR_FTM_CAPA_ATTR_MAX: highest attribute number | 8202 | * @NL80211_PMSR_FTM_CAPA_ATTR_MAX: highest attribute number |
| @@ -8225,6 +8233,8 @@ enum nl80211_peer_measurement_ftm_capa { · 30 unmodified lines | |||
| 8225 | NL80211_PMSR_FTM_CAPA_ATTR_MAX_NUM_RX_ANTENNAS, | 8233 | NL80211_PMSR_FTM_CAPA_ATTR_MAX_NUM_RX_ANTENNAS, |
| 8226 | NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_EDCA, | 8234 | NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_EDCA, |
| 8227 | NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_NTB, | 8235 | NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_NTB, |
| 8236 | NL80211_PMSR_FTM_CAPA_ATTR_PD_PREAMBLES, | ||
| 8237 | NL80211_PMSR_FTM_CAPA_ATTR_PD_BANDWIDTHS, | ||
| 8228 | 8238 | ||
| 8229 | /* keep last */ | 8239 | /* keep last */ |
| 8230 | NUM_NL80211_PMSR_FTM_CAPA_ATTR, | 8240 | NUM_NL80211_PMSR_FTM_CAPA_ATTR, |
| @@ -2615,6 +2615,18 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap, · 2614 unmodified lines | |||
| 2615 | if (cap->ftm.concurrent_ista_rsta_support && | 2615 | if (cap->ftm.concurrent_ista_rsta_support && |
| 2616 | nla_put_flag(msg, NL80211_PMSR_FTM_CAPA_ATTR_CONCURRENT_ISTA_RSTA_SUPPORT)) | 2616 | nla_put_flag(msg, NL80211_PMSR_FTM_CAPA_ATTR_CONCURRENT_ISTA_RSTA_SUPPORT)) |
| 2617 | return -ENOBUFS; | 2617 | return -ENOBUFS; |
| 2618 | |||
| 2619 | if (cap->ftm.type.pd_support) { | ||
| 2620 | if (cap->ftm.pd_preambles && | ||
| 2621 | nla_put_u32(msg, NL80211_PMSR_FTM_CAPA_ATTR_PD_PREAMBLES, | ||
| 2622 | cap->ftm.pd_preambles)) | ||
| 2623 | return -ENOBUFS; | ||
| 2624 | if (cap->ftm.pd_bandwidths && | ||
| 2625 | nla_put_u32(msg, NL80211_PMSR_FTM_CAPA_ATTR_PD_BANDWIDTHS, | ||
| 2626 | cap->ftm.pd_bandwidths)) | ||
| 2627 | return -ENOBUFS; | ||
| 2628 | } | ||
| 2629 | |||
| 2618 | nla_nest_end(msg, ftm); | 2630 | nla_nest_end(msg, ftm); |
| 2619 | return 0; | 2631 | return 0; |
| 2620 | } | 2632 | } |
| @@ -17,11 +17,19 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, · 16 unmodified lines | |||
| 17 | u32 preamble = NL80211_PREAMBLE_DMG; /* only optional in DMG */ | 17 | u32 preamble = NL80211_PREAMBLE_DMG; /* only optional in DMG */ |
| 18 | 18 | ||
| 19 | /* validate existing data */ | 19 | /* validate existing data */ |
| 20 | if (!(rdev->wiphy.pmsr_capa->ftm.bandwidths & BIT(out->chandef.width))) { | 20 | if (out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_INFRA && |
| 21 | !(capa->ftm.bandwidths & BIT(out->chandef.width))) { | ||
| 21 | NL_SET_ERR_MSG(info->extack, "FTM: unsupported bandwidth"); | 22 | NL_SET_ERR_MSG(info->extack, "FTM: unsupported bandwidth"); |
| 22 | return -EINVAL; | 23 | return -EINVAL; |
| 23 | } | 24 | } |
| 24 | 25 | ||
| 26 | if (out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_PD && | ||
| 27 | !(capa->ftm.pd_bandwidths & BIT(out->chandef.width))) { | ||
| 28 | NL_SET_ERR_MSG(info->extack, | ||
| 29 | "FTM: unsupported bandwidth for PD request"); | ||
| 30 | return -EINVAL; | ||
| 31 | } | ||
| 32 | |||
| 25 | /* no validation needed - was already done via nested policy */ | 33 | /* no validation needed - was already done via nested policy */ |
| 26 | nla_parse_nested_deprecated(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq, | 34 | nla_parse_nested_deprecated(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq, |
| 27 | NULL, NULL); | 35 | NULL, NULL); |
| @@ -44,13 +52,22 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, · 16 unmodified lines | |||
| 44 | } | 52 | } |
| 45 | } | 53 | } |
| 46 | 54 | ||
| 47 | if (!(capa->ftm.preambles & BIT(preamble))) { | 55 | if (out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_INFRA && |
| 56 | !(capa->ftm.preambles & BIT(preamble))) { | ||
| 48 | NL_SET_ERR_MSG_ATTR(info->extack, | 57 | NL_SET_ERR_MSG_ATTR(info->extack, |
| 49 | tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE], | 58 | tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE], |
| 50 | "FTM: invalid preamble"); | 59 | "FTM: invalid preamble"); |
| 51 | return -EINVAL; | 60 | return -EINVAL; |
| 52 | } | 61 | } |
| 53 | 62 | ||
| 63 | if (out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_PD && | ||
| 64 | !(capa->ftm.pd_preambles & BIT(preamble))) { | ||
| 65 | NL_SET_ERR_MSG_ATTR(info->extack, | ||
| 66 | tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE], | ||
| 67 | "FTM: invalid preamble for PD request"); | ||
| 68 | return -EINVAL; | ||
| 69 | } | ||
| 70 | |||
| 54 | out->ftm.preamble = preamble; | 71 | out->ftm.preamble = preamble; |
| 55 | 72 | ||
| 56 | out->ftm.burst_period = 0; | 73 | out->ftm.burst_period = 0; |