Some devices support different preamble and bandwidth configurations for proximity detection (PD) versus standard ranging, but capabilities currently report only a single set for all FTM measurements. Introduce separate preamble and bandwidth capability reporting for PD requests with EDCA and NTB-based ranging, allowing devices to advertise different supported preambles and bandwidths for PD operations. Signed-off-by: Peddolla Harshavardhan Reddy --- include/net/cfg80211.h | 16 ++++++++++++++++ include/uapi/linux/nl80211.h | 22 ++++++++++++++++++++++ net/wireless/nl80211.c | 12 ++++++++++++ net/wireless/pmsr.c | 21 +++++++++++++++++++-- 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 1b663627a0e6..61651ecc3c9d 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -5832,6 +5832,18 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type); * @ftm.support_rsta: supports operating as RSTA in PMSR FTM request * @ftm.support_edca_responder: supports operating as FTM responder in PMSR FTM * request for EDCA-based ranging + * @ftm.pd_edca_preambles: bitmap of preambles supported + * (&enum nl80211_preamble) in case of PD request with EDCA based + * initiator or responder role. ignored if @pd_support is not set. + * @ftm.pd_ntb_preambles: bitmap of preambles supported + * (&enum nl80211_preamble) in case of PD request with NTB based + * initiator or responder role. ignored if @pd_support is not set. + * @ftm.pd_edca_bandwidths: bitmap of bandwidths supported + * (&enum nl80211_chan_width) in case of PD request with EDCA based + * initiator or responder role. ignored if @pd_support is not set. + * @ftm.pd_ntb_bandwidths: bitmap of bandwidths supported + * (&enum nl80211_chan_width) in case of PD request with NTB based + * initiator or responder role. ignored if @pd_support is not set. */ struct cfg80211_pmsr_capabilities { unsigned int max_peers; @@ -5867,6 +5879,10 @@ struct cfg80211_pmsr_capabilities { u32 min_allowed_ranging_interval_ntb; u8 support_rsta:1, support_edca_responder:1; + u32 pd_edca_preambles; + u32 pd_ntb_preambles; + u32 pd_edca_bandwidths; + u32 pd_ntb_bandwidths; } ftm; }; diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h index 174592017486..f064d6a260fb 100644 --- a/include/uapi/linux/nl80211.h +++ b/include/uapi/linux/nl80211.h @@ -7942,6 +7942,24 @@ enum nl80211_peer_measurement_attrs { * @NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_NTB: u32 attribute indicating * the minimum NTB ranging interval supported by the device * in milli seconds. (0 means unknown) + * @NL80211_PMSR_FTM_CAPA_ATTR_PD_EDCA_PREAMBLES: u32 bitmap of values from + * &enum nl80211_preamble indicating the supported preambles for FTM in + * case of PD based EDCA initiator or responder role. + * @NL80211_PMSR_FTM_CAPA_ATTR_PD_NTB_PREAMBLES: u32 bitmap of values from + * &enum nl80211_preamble indicating the supported preambles for FTM in + * case of PD based NTB initiator or responder role. + * @NL80211_PMSR_FTM_CAPA_ATTR_PD_EDCA_BANDWIDTHS: u32 bitmap of values from + * &enum nl80211_chan_width indicating the supported channel + * bandwidths for FTM in case of PD based EDCA initiator or responder role. + * Note that a higher channel bandwidth may be configured to allow for + * other measurements types with different bandwidth requirement in the + * same measurement. + * @NL80211_PMSR_FTM_CAPA_ATTR_PD_NTB_BANDWIDTHS: u32 bitmap of values from + * &enum nl80211_chan_width indicating the supported channel + * bandwidths for FTM in case of PD based NTB initiator or responder role. + * Note that a higher channel bandwidth may be configured to allow for + * other measurements types with different bandwidth requirement in the + * same measurement. * * @NUM_NL80211_PMSR_FTM_CAPA_ATTR: internal * @NL80211_PMSR_FTM_CAPA_ATTR_MAX: highest attribute number @@ -7972,6 +7990,10 @@ enum nl80211_peer_measurement_ftm_capa { NL80211_PMSR_FTM_CAPA_ATTR_MAX_NUM_RX_ANTENNAS, NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_EDCA, NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_NTB, + NL80211_PMSR_FTM_CAPA_ATTR_PD_EDCA_PREAMBLES, + NL80211_PMSR_FTM_CAPA_ATTR_PD_NTB_PREAMBLES, + NL80211_PMSR_FTM_CAPA_ATTR_PD_EDCA_BANDWIDTHS, + NL80211_PMSR_FTM_CAPA_ATTR_PD_NTB_BANDWIDTHS, /* keep last */ NUM_NL80211_PMSR_FTM_CAPA_ATTR, diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index e6969578f4f1..1deedb1c6c50 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -2412,6 +2412,18 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap, nla_put_u32(msg, NL80211_PMSR_FTM_CAPA_ATTR_MIN_INTERVAL_NTB, cap->ftm.min_allowed_ranging_interval_ntb)) return -ENOBUFS; + if (nla_put_u32(msg, NL80211_PMSR_FTM_CAPA_ATTR_PD_EDCA_PREAMBLES, + cap->ftm.pd_edca_preambles)) + return -ENOBUFS; + if (nla_put_u32(msg, NL80211_PMSR_FTM_CAPA_ATTR_PD_NTB_PREAMBLES, + cap->ftm.pd_ntb_preambles)) + return -ENOBUFS; + if (nla_put_u32(msg, NL80211_PMSR_FTM_CAPA_ATTR_PD_EDCA_BANDWIDTHS, + cap->ftm.pd_edca_bandwidths)) + return -ENOBUFS; + if (nla_put_u32(msg, NL80211_PMSR_FTM_CAPA_ATTR_PD_NTB_BANDWIDTHS, + cap->ftm.pd_ntb_bandwidths)) + return -ENOBUFS; nla_nest_end(msg, ftm); return 0; diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c index f2bbbf8eb6f2..c4c027fc0b63 100644 --- a/net/wireless/pmsr.c +++ b/net/wireless/pmsr.c @@ -17,11 +17,19 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, u32 preamble = NL80211_PREAMBLE_DMG; /* only optional in DMG */ /* validate existing data */ - if (!(rdev->wiphy.pmsr_capa->ftm.bandwidths & BIT(out->chandef.width))) { + if (!out->pd_request && + !(rdev->wiphy.pmsr_capa->ftm.bandwidths & BIT(out->chandef.width))) { NL_SET_ERR_MSG(info->extack, "FTM: unsupported bandwidth"); return -EINVAL; } + if (out->pd_request && + !(rdev->wiphy.pmsr_capa->ftm.pd_edca_bandwidths & BIT(out->chandef.width)) && + !(rdev->wiphy.pmsr_capa->ftm.pd_ntb_bandwidths & BIT(out->chandef.width))) { + NL_SET_ERR_MSG(info->extack, "FTM: unsupported bandwidth for pd request"); + return -EINVAL; + } + /* no validation needed - was already done via nested policy */ nla_parse_nested_deprecated(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq, NULL, NULL); @@ -44,13 +52,22 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev, } } - if (!(capa->ftm.preambles & BIT(preamble))) { + if (!out->pd_request && !(capa->ftm.preambles & BIT(preamble))) { NL_SET_ERR_MSG_ATTR(info->extack, tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE], "FTM: invalid preamble"); return -EINVAL; } + if (out->pd_request && + !(capa->ftm.pd_ntb_preambles & BIT(preamble)) && + !(capa->ftm.pd_edca_preambles & BIT(preamble))) { + NL_SET_ERR_MSG_ATTR(info->extack, + tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE], + "FTM: invalid preamble for PD request"); + return -EINVAL; + } + out->ftm.preamble = preamble; out->ftm.burst_period = 0; -- 2.34.1