History

wifi: cfg80211: add PD-specific preamble and bandwidth capabilities

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.

Peddolla Harshavardhan Reddy committed 6 months ago

Commit 5733daa1 parent 99529ed4 files · +47 −2Browse files

Unified · Split

4 files
  1. include/net/cfg80211.h +6 −0
  2. include/uapi/linux/nl80211.h +10 −0
  3. net/wireless/nl80211.c +12 −0
  4. net/wireless/pmsr.c +19 −2
include/net/cfg80211.h+6−0
@@ -6053,6 +6053,10 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type); · 6052 unmodified lines
60536053 * @ftm.concurrent_ista_rsta_support: indicates if the device can
60546054 * simultaneously act as initiator and responder in a multi-peer
60556055 * 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.
60566060 */
60576061 struct cfg80211_pmsr_capabilities {
60586062 unsigned int max_peers;
@@ -6099,6 +6103,8 @@ struct cfg80211_pmsr_capabilities { · 40 unmodified lines
60996103 pd_support:1;
61006104 } type;
61016105 u8 concurrent_ista_rsta_support:1;
6106+ u32 pd_preambles;
6107+ u32 pd_bandwidths;
61026108 } ftm;
61036109 };
61046110
include/uapi/linux/nl80211.h+10−0
@@ -8189,6 +8189,14 @@ enum nl80211_peer_measurement_attrs { · 8188 unmodified lines
81898189 * to estimate the burst period to be given in the FTM request for the
81908190 * NTB ranging case. If non-zero, this value will be used to validate
81918191 * 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.
81928200 *
81938201 * @NUM_NL80211_PMSR_FTM_CAPA_ATTR: internal
81948202 * @NL80211_PMSR_FTM_CAPA_ATTR_MAX: highest attribute number
@@ -8225,6 +8233,8 @@ enum nl80211_peer_measurement_ftm_capa { · 30 unmodified lines
82258233 NL80211_PMSR_FTM_CAPA_ATTR_MAX_NUM_RX_ANTENNAS,
82268234 NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_EDCA,
82278235 NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_NTB,
8236+ NL80211_PMSR_FTM_CAPA_ATTR_PD_PREAMBLES,
8237+ NL80211_PMSR_FTM_CAPA_ATTR_PD_BANDWIDTHS,
82288238
82298239 /* keep last */
82308240 NUM_NL80211_PMSR_FTM_CAPA_ATTR,
net/wireless/nl80211.c+12−0
@@ -2615,6 +2615,18 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap, · 2614 unmodified lines
26152615 if (cap->ftm.concurrent_ista_rsta_support &&
26162616 nla_put_flag(msg, NL80211_PMSR_FTM_CAPA_ATTR_CONCURRENT_ISTA_RSTA_SUPPORT))
26172617 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+
26182630 nla_nest_end(msg, ftm);
26192631 return 0;
26202632 }
net/wireless/pmsr.c+19−2
@@ -17,11 +17,19 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, · 16 unmodified lines
1717 u32 preamble = NL80211_PREAMBLE_DMG; /* only optional in DMG */
1818
1919 /* 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))) {
2122 NL_SET_ERR_MSG(info->extack, "FTM: unsupported bandwidth");
2223 return -EINVAL;
2324 }
2425
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+
2533 /* no validation needed - was already done via nested policy */
2634 nla_parse_nested_deprecated(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq,
2735 NULL, NULL);
@@ -44,13 +52,22 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, · 16 unmodified lines
4452 }
4553 }
4654
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))) {
4857 NL_SET_ERR_MSG_ATTR(info->extack,
4958 tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE],
5059 "FTM: invalid preamble");
5160 return -EINVAL;
5261 }
5362
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+
5471 out->ftm.preamble = preamble;
5572
5673 out->ftm.burst_period = 0;