cfg80211: add peer measurement with FTM initiator API
Subsystems (2)
Johannes Berg
maintainerPATCH v4 1/2 cfg80211: add peer measurement with FTM initiator API
From: Johannes Berg <[email protected]>
Add a new "peer measurement" API, that can be used to measure certain things related to a peer. Right now, only implement FTM (flight time measurement) over it, but the idea is that it'll be extensible to also support measuring the necessary things to calculate e.g. angle-of-arrival for WiGig.
The API is structured to have a generic list of peers and channels to measure with/on, and then for each of those a set of measurements (again, only FTM right now) to perform.
Results are sent to the requesting socket, including a final complete message.
Closing the controlling netlink socket will abort a running measurement.
---
v3:
- add a bit to report "final" for partial results
- remove list keeping etc. and just unicast out the results to the requester (big code reduction ...)
- also send complete message unicast, and as a result remove the multicast group
- separate out struct cfg80211_pmsr_ftm_request_peer from struct cfg80211_pmsr_request_peer
- document timeout == 0 if no timeout
- disallow setting timeout nl80211 attribute to 0, must not include attribute for no timeout
- make MAC address randomization optional
- change num bursts exponent default to 0 (1 burst, rather rather than the old default of 15==don't care)
v4:
- clarify NL80211_ATTR_TIMEOUT documentation
--- include/net/cfg80211.h | 255 ++++++++++++++++ include/uapi/linux/nl80211.h | 412 +++++++++++++++++++++++++ net/wireless/Makefile | 1 + net/wireless/core.c | 33 ++ net/wireless/core.h | 4 + net/wireless/nl80211.c | 200 +++++++++--- net/wireless/nl80211.h | 41 +++ net/wireless/pmsr.c | 576 +++++++++++++++++++++++++++++++++++ net/wireless/rdev-ops.h | 25 ++ net/wireless/trace.h | 68 +++++ 10 files changed, 1581 insertions(+), 34 deletions(-) create mode 100644 net/wireless/pmsr.c
include/net/cfg80211.h +255 -0
@@ -2848,6 +2848,191 @@ struct cfg80211_ftm_responder_stats {u32 out_of_window_triggers_num; }; +/** +* struct cfg80211_pmsr_ftm_result - FTM result +* @failure_reason: if this measurement failed (PMSR status is +* %NL80211_PMSR_STATUS_FAILURE), this gives a more precise +* reason than just "failure" +* @burst_index: if reporting partial results, this is the index +* in [0 .. num_bursts-1] of the burst that's being reported +* @num_ftmr_attempts: number of FTM request frames transmitted +* @num_ftmr_successes: number of FTM request frames acked +* @busy_retry_time: if failure_reason is %NL80211_PMSR_FTM_FAILURE_PEER_BUSY, +* fill this to indicate in how many seconds a retry is deemed possible +* by the responder +* @num_bursts_exp: actual number of bursts exponent negotiated +* @burst_duration: actual burst duration negotiated +* @frames_per_burst: actual frames per burst negotiated +* @lci_len: length of LCI information (if present) +* @civicloc_len: length of civic location information (if present) +* @lci: LCI data (may be %NULL) +* @civicloc: civic location data (may be %NULL) +* @rssi_avg: average RSSI over FTM action frames reported +* @rssi_spread: spread of the RSSI over FTM action frames reported +* @tx_rate: bitrate for transmitted FTM action frame response +* @rx_rate: bitrate of received FTM action frame +* @rtt_avg: average of RTTs measured (must have either this or @dist_avg) +* @rtt_variance: variance of RTTs measured (note that standard deviation is +* the square root of the variance) +* @rtt_spread: spread of the RTTs measured +* @dist_avg: average of distances (mm) measured +* (must have either this or @rtt_avg) +* @dist_variance: variance of distances measured (see also @rtt_variance) +* @dist_spread: spread of distances measured (see also @rtt_spread) +* @num_ftmr_attempts_valid: @num_ftmr_attempts is valid +* @num_ftmr_successes_valid: @num_ftmr_successes is valid +* @rssi_avg_valid: @rssi_avg is valid +* @rssi_spread_valid: @rssi_spread is valid +* @tx_rate_valid: @tx_rate is valid +* @rx_rate_valid: @rx_rate is valid +* @rtt_avg_valid: @rtt_avg is valid +* @rtt_variance_valid: @rtt_variance is valid +* @rtt_spread_valid: @rtt_spread is valid +* @dist_avg_valid: @dist_avg is valid +* @dist_variance_valid: @dist_variance is valid +* @dist_spread_valid: @dist_spread is valid +*/ +struct cfg80211_pmsr_ftm_result { +const u8 *lci; +const u8 *civicloc; +unsigned int lci_len; +unsigned int civicloc_len; +enum nl80211_peer_measurement_ftm_failure_reasons failure_reason; +u32 num_ftmr_attempts, num_ftmr_successes; +s16 burst_index; +u8 busy_retry_time; +u8 num_bursts_exp; +u8 burst_duration; +u8 frames_per_burst; +s32 rssi_avg; +s32 rssi_spread; +struct rate_info tx_rate, rx_rate; +s64 rtt_avg; +s64 rtt_variance; +s64 rtt_spread; +s64 dist_avg; +s64 dist_variance; +s64 dist_spread; + +u16 num_ftmr_attempts_valid:1 , + num_ftmr_successes_valid:1 , + rssi_avg_valid:1 , + rssi_spread_valid:1 , + tx_rate_valid:1 , + rx_rate_valid:1 , + rtt_avg_valid:1 , + rtt_variance_valid:1 , + rtt_spread_valid:1 , + dist_avg_valid:1 , + dist_variance_valid:1 , + dist_spread_valid:1 ; +}; + +/** +* struct cfg80211_pmsr_result - peer measurement result +* @addr: address of the peer +* @host_time: host time (use ktime_get_boottime() adjust to the time when the +* measurement was made) +* @ap_tsf: AP's TSF at measurement time +* @status: status of the measurement +* @partial: indicates that this is a partial result for this type +* @final: if reporting partial results, mark this as the last one +* @ap_tsf_valid: indicates the @ap_tsf value is valid +* @type: type of the measurement reported, note that we only support reporting +* one type at a time, but you can report multiple results separately and +* they're all aggregated for userspace. +*/ +struct cfg80211_pmsr_result { +u64 host_time, ap_tsf; +enum nl80211_peer_measurement_status status; + +u8 addr[ETH_ALEN ]; + +u8 partial:1 , + final:1 , + ap_tsf_valid:1 ; + +enum nl80211_peer_measurement_type type; + +union { +struct cfg80211_pmsr_ftm_result ftm; + }; +}; + +/** +* struct cfg80211_pmsr_ftm_request_peer - FTM request data +* @requested: indicates FTM is requested +* @preamble: frame preamble to use +* @burst_period: burst period to use +* @asap: indicates to use ASAP mode +* @num_bursts_exp: number of bursts exponent +* @burst_duration: burst duration +* @frames_per_burst: number of frames per burst +* @ftmr_retries: number of retries for FTM request +* @request_lci: request LCI information +* @request_civicloc: request civic location information +* +* See also nl80211 for the respective attribute documentation. +*/ +struct cfg80211_pmsr_ftm_request_peer { +enum nl80211_preamble preamble; +u16 burst_period; +bool requested; +bool asap; +u8 num_bursts_exp; +u8 burst_duration; +u8 frames_per_burst; +u8 ftmr_retries; +bool request_lci; +bool request_civicloc; +}; + +/** +* struct cfg80211_pmsr_request_peer - peer data for a peer measurement request +* @addr: MAC address +* @chandef: channel to use +* @report_ap_tsf: report the associated AP's TSF +* @ftm: FTM data, see &struct cfg80211_pmsr_ftm_request_peer +*/ +struct cfg80211_pmsr_request_peer { +u8 addr[ETH_ALEN ]; +struct cfg80211_chan_def chandef; +bool report_ap_tsf; +struct cfg80211_pmsr_ftm_request_peer ftm; +}; + +/** +* struct cfg80211_pmsr_request - peer measurement request +* @cookie: cookie, set by cfg80211 +* @nl_portid: netlink portid - used by cfg80211 +* @drv_data: driver data for this request, if required for aborting, +* not otherwise freed or anything by cfg80211 +* @mac_addr: MAC address used for (randomised) request +* @mac_addr_mask: MAC address mask used for randomisation, bits that +* are 0 in the mask should be randomised, bits that are 1 should +* be taken from the @mac_addr +* @list: used by cfg80211 to hold on to the request +* @timeout: timeout (in milliseconds) for the whole operation, if +* zero it means there's no timeout +* @n_peers: number of peers to do measurements with +* @peers: per-peer measurement request data +*/ +struct cfg80211_pmsr_request { +u64 cookie; +void *drv_data; +u32 n_peers; +u32 nl_portid; + +u32 timeout; + +u8 mac_addr[ETH_ALEN ]__aligned(2) ; +u8 mac_addr_mask[ETH_ALEN ]__aligned(2) ; + +struct list_head list; + +struct cfg80211_pmsr_request_peer peers[]; +}; +/** * struct cfg80211_ops - backend description for wireless configuration *
@@ -3183,6 +3368,8 @@ struct cfg80211_ftm_responder_stats {* * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available. * Statistics should be cumulative, currently no way to reset is provided. +* @start_pmsr: start peer measurement (e.g. FTM) +* @abort_pmsr: abort peer measurement */ struct cfg80211_ops {int (*suspend)(struct wiphy *wiphy,struct cfg80211_wowlan *wow);
@@ -3492,6 +3679,11 @@ struct cfg80211_ops {int (*get_ftm_responder_stats)(struct wiphy *wiphy,struct net_device *dev,struct cfg80211_ftm_responder_stats *ftm_stats); + +int (*start_pmsr)(struct wiphy *wiphy,struct wireless_dev *wdev, +struct cfg80211_pmsr_request *request); +void (*abort_pmsr)(struct wiphy *wiphy,struct wireless_dev *wdev, +struct cfg80211_pmsr_request *request); };/*
@@ -3863,6 +4055,33 @@ struct wiphy_iftype_ext_capab {u8 extended_capabilities_len; }; +/** +* struct cfg80211_pmsr_capabilities - cfg80211 peer measurement capabilities +* @max_peers: maximum number of peers in a single measurement +* @report_ap_tsf: can report assoc AP's TSF for radio resource measurement +* @randomize_mac_addr: can randomize MAC address for measurement +* @ftm.supported: FTM measurement is supported +* @ftm.asap: ASAP-mode is supported +* @ftm.non_asap: non-ASAP-mode is supported +* @ftm.request_lci: can request LCI data +* @ftm.request_civicloc: can request civic location data +* @ftm.preambles: bitmap of preambles supported (&enum nl80211_preamble) +* @ftm.bandwidths: bitmap of bandwidths supported (&enum nl80211_chan_width) +*/ +struct cfg80211_pmsr_capabilities { +unsigned int max_peers; +bool report_ap_tsf; +bool randomize_mac_addr; + +struct { +bool supported; +bool asap, non_asap; +bool request_lci, request_civicloc; +u32 preambles; +u32 bandwidths; + } ftm; +}; +/** * struct wiphy - wireless hardware description * @reg_notifier: the driver's regulatory notification callback,
@@ -4027,6 +4246,8 @@ struct wiphy_iftype_ext_capab {* @txq_limit: configuration of internal TX queue frame limit * @txq_memory_limit: configuration internal TX queue memory limit * @txq_quantum: configuration of internal TX queue scheduler quantum +* +* @pmsr_capa: peer measurement capabilities */ struct wiphy {/* assign these fields before you register the wiphy */
@@ -4163,6 +4384,8 @@ struct wiphy {u32 txq_memory_limit;u32 txq_quantum; +const struct cfg80211_pmsr_capabilities *pmsr_capa; +char priv[0 ]__aligned(NETDEV_ALIGN) ; };
@@ -4365,6 +4588,9 @@ struct cfg80211_cqm_config;* @owner_nlportid: (private) owner socket port ID * @nl_owner_dead: (private) owner socket went away * @cqm_config: (private) nl80211 RSSI monitor state +* @pmsr_list: (private) peer measurement requests +* @pmsr_lock: (private) peer measurements requests/results lock +* @pmsr_free_wk: (private) peer measurements cleanup work */ struct wireless_dev {struct wiphy *wiphy;
@@ -4436,6 +4662,10 @@ struct wireless_dev {#endif struct cfg80211_cqm_config *cqm_config; + +struct list_head pmsr_list; +spinlock_t pmsr_lock; +struct work_struct pmsr_free_wk; };static inline u8 *wdev_address (struct wireless_dev *wdev)
@@ -6630,6 +6860,31 @@ int cfg80211_external_auth_request(struct net_device *netdev,struct cfg80211_external_auth_params *params, gfp_t gfp); +/** +* cfg80211_pmsr_report - report peer measurement result data +* @wdev: the wireless device reporting the measurement +* @req: the original measurement request +* @result: the result data +* @gfp: allocation flags +*/ +void cfg80211_pmsr_report (struct wireless_dev *wdev, +struct cfg80211_pmsr_request *req, +struct cfg80211_pmsr_result *result, +gfp_t gfp); + +/** +* cfg80211_pmsr_complete - report peer measurement completed +* @wdev: the wireless device reporting the measurement +* @req: the original measurement request +* @gfp: allocation flags +* +* Report that the entire measurement completed, after this +* the request pointer will no longer be valid. +*/ +void cfg80211_pmsr_complete (struct wireless_dev *wdev, +struct cfg80211_pmsr_request *req, +gfp_t gfp); +/* Logging, debugging and troubleshooting/diagnostic helpers. */ /* wiphy_printk helpers, similar to dev_printk */
include/uapi/linux/nl80211.h +412 -0
440 lines not on this page · raw message
net/wireless/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_WEXT_PRIV) += wext-priv.o cfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o cfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o ocb.o +cfg80211-y += pmsr.o cfg80211-$(CONFIG_OF) += of.o cfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o cfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o
net/wireless/core.c +33 -0
@@ -664,6 +664,34 @@ int wiphy_register(struct wiphy *wiphy)return -EINVAL ;#endif +if (WARN_ON (wiphy->pmsr_capa && !wiphy->pmsr_capa->ftm.supported)) +return -EINVAL ; + +if (wiphy->pmsr_capa && wiphy->pmsr_capa->ftm.supported) { +if (WARN_ON (!wiphy->pmsr_capa->ftm.asap && + !wiphy->pmsr_capa->ftm.non_asap)) +return -EINVAL ; +if (WARN_ON (!wiphy->pmsr_capa->ftm.preambles || + !wiphy->pmsr_capa->ftm.bandwidths)) +return -EINVAL ; +if (WARN_ON (wiphy->pmsr_capa->ftm.preambles & + ~(BIT (NL80211_PREAMBLE_LEGACY ) | +BIT (NL80211_PREAMBLE_HT ) | +BIT (NL80211_PREAMBLE_VHT ) | +BIT (NL80211_PREAMBLE_DMG )))) +return -EINVAL ; +if (WARN_ON (wiphy->pmsr_capa->ftm.bandwidths & + ~(BIT (NL80211_CHAN_WIDTH_20_NOHT ) | +BIT (NL80211_CHAN_WIDTH_20 ) | +BIT (NL80211_CHAN_WIDTH_40 ) | +BIT (NL80211_CHAN_WIDTH_80 ) | +BIT (NL80211_CHAN_WIDTH_80P80 ) | +BIT (NL80211_CHAN_WIDTH_160 ) | +BIT (NL80211_CHAN_WIDTH_5 ) | +BIT (NL80211_CHAN_WIDTH_10 )))) +return -EINVAL ; + } +/* * if a wiphy has unsupported modes for regulatory channel enforcement, * opt-out of enforcement checking
@@ -1053,6 +1081,8 @@ static void __cfg80211_unregister_wdev(struct wireless_dev *wdev, bool sync)flush_work (&wdev->disconnect_wk);cfg80211_cqm_config_free (wdev); + +cfg80211_pmsr_free_wdev (wdev); }void cfg80211_unregister_wdev (struct wireless_dev *wdev)
@@ -1174,6 +1204,9 @@ void cfg80211_init_wdev(struct cfg80211_registered_device *rdev,spin_lock_init (&wdev->event_lock);INIT_LIST_HEAD (&wdev->mgmt_registrations);spin_lock_init (&wdev->mgmt_registrations_lock); +INIT_LIST_HEAD (&wdev->pmsr_list); +spin_lock_init (&wdev->pmsr_lock); +INIT_WORK (&wdev->pmsr_free_wk, cfg80211_pmsr_free_wk);/* * We get here also when the interface changes network namespaces,
net/wireless/core.h +4 -0
@@ -530,4 +530,8 @@ void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,void cfg80211_cqm_config_free (struct wireless_dev *wdev); +void cfg80211_release_pmsr (struct wireless_dev *wdev,u32 portid); +void cfg80211_pmsr_free_wdev (struct wireless_dev *wdev); +void cfg80211_pmsr_free_wk (struct work_struct *work); +#endif /* __NET_WIRELESS_CORE_H */
net/wireless/nl80211.c +166 -34
280 lines not on this page · raw message
net/wireless/nl80211.h +41 -0
53 lines not on this page · raw message
net/wireless/pmsr.c new file +576 -0
576 lines not on this page · raw message
net/wireless/rdev-ops.h +25 -0
@@ -1247,4 +1247,29 @@ rdev_get_ftm_responder_stats(struct cfg80211_registered_device *rdev,return ret; } +static inline int +rdev_start_pmsr (struct cfg80211_registered_device *rdev, +struct wireless_dev *wdev, +struct cfg80211_pmsr_request *request) +{ +int ret = -EOPNOTSUPP ; + +trace_rdev_start_pmsr (&rdev->wiphy, wdev, request->cookie); +if (rdev->ops->start_pmsr) + ret = rdev->ops->start_pmsr (&rdev->wiphy, wdev, request); +trace_rdev_return_int (&rdev->wiphy, ret); +return ret; +} + +static inline void +rdev_abort_pmsr (struct cfg80211_registered_device *rdev, +struct wireless_dev *wdev, +struct cfg80211_pmsr_request *request) +{ +trace_rdev_abort_pmsr (&rdev->wiphy, wdev, request->cookie); +if (rdev->ops->abort_pmsr) + rdev->ops->abort_pmsr (&rdev->wiphy, wdev, request); +trace_rdev_return_void (&rdev->wiphy); +} +#endif /* __CFG80211_RDEV_OPS */
net/wireless/trace.h +68 -0
86 lines not on this page · raw message
Signature · 1 line
2.17.2
Johannes Berg
maintainerPATCH v4 2/2 mac80211: allow drivers to use peer measurement API
From: Johannes Berg <[email protected]>
There's nothing much for mac80211 to do, so only pass through the requests with minimal checks and tracing. The driver must call cfg80211's results APIs.
---
v4: first version - just takes the same number as the cfg80211 patch
--- include/net/mac80211.h | 7 +++++++ net/mac80211/cfg.c | 22 ++++++++++++++++++++++ net/mac80211/driver-ops.h | 34 ++++++++++++++++++++++++++++++++++ net/mac80211/trace.h | 12 ++++++++++++ 4 files changed, 75 insertions(+)
include/net/mac80211.h +7 -0
@@ -3623,6 +3623,9 @@ enum ieee80211_reconfig_type {* skb is always a real frame, head may or may not be an A-MSDU. * @get_ftm_responder_stats: Retrieve FTM responder statistics, if available. * Statistics should be cumulative, currently no way to reset is provided. +* +* @start_pmsr: start peer measurement (e.g. FTM) (this call can sleep) +* @abort_pmsr: abort peer measurement (this call can sleep) */ struct ieee80211_ops { void (*tx)(struct ieee80211_hw *hw,
@@ -3911,6 +3914,10 @@ struct ieee80211_ops {int (*get_ftm_responder_stats)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct cfg80211_ftm_responder_stats *ftm_stats); +int (*start_pmsr)(struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct cfg80211_pmsr_request *request); +void (*abort_pmsr)(struct ieee80211_hw *hw,struct ieee80211_vif *vif, +struct cfg80211_pmsr_request *request); };/**
net/mac80211/cfg.c +22 -0
@@ -3849,6 +3849,26 @@ ieee80211_get_ftm_responder_stats(struct wiphy *wiphy,return drv_get_ftm_responder_stats (local, sdata, ftm_stats); } +static int +ieee80211_start_pmsr (struct wiphy *wiphy,struct wireless_dev *dev, +struct cfg80211_pmsr_request *request) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_sub_if_data *sdata =IEEE80211_WDEV_TO_SUB_IF (dev); + +return drv_start_pmsr (local, sdata, request); +} + +static void +ieee80211_abort_pmsr (struct wiphy *wiphy,struct wireless_dev *dev, +struct cfg80211_pmsr_request *request) +{ +struct ieee80211_local *local =wiphy_priv (wiphy); +struct ieee80211_sub_if_data *sdata =IEEE80211_WDEV_TO_SUB_IF (dev); + +return drv_abort_pmsr (local, sdata, request); +} +const struct cfg80211_ops mac80211_config_ops = { .add_virtual_intf = ieee80211_add_iface, .del_virtual_intf = ieee80211_del_iface,
@@ -3944,4 +3964,6 @@ const struct cfg80211_ops mac80211_config_ops = { .tx_control_port = ieee80211_tx_control_port, .get_txq_stats = ieee80211_get_txq_stats, .get_ftm_responder_stats = ieee80211_get_ftm_responder_stats, + .start_pmsr = ieee80211_start_pmsr, + .abort_pmsr = ieee80211_abort_pmsr, };
net/mac80211/driver-ops.h +34 -0
@@ -1199,6 +1199,40 @@ drv_get_ftm_responder_stats(struct ieee80211_local *local,return ret; } +static inline int drv_start_pmsr (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +struct cfg80211_pmsr_request *request) +{ +int ret = -EOPNOTSUPP ; + +might_sleep (); +if (!check_sdata_in_driver (sdata)) +return -EIO ; + +trace_drv_start_pmsr (local, sdata); + +if (local->ops->start_pmsr) + ret = local->ops->start_pmsr (&local->hw, &sdata->vif, request); +trace_drv_return_int (local, ret); + +return ret; +} + +static inline void drv_abort_pmsr (struct ieee80211_local *local, +struct ieee80211_sub_if_data *sdata, +struct cfg80211_pmsr_request *request) +{ +trace_drv_abort_pmsr (local, sdata); + +might_sleep (); +if (!check_sdata_in_driver (sdata)) +return ; + +if (local->ops->abort_pmsr) + local->ops->abort_pmsr (&local->hw, &sdata->vif, request); +trace_drv_return_void (local); +} +static inline int drv_start_nan (struct ieee80211_local *local,struct ieee80211_sub_if_data *sdata,struct cfg80211_nan_conf *conf)
net/mac80211/trace.h +12 -0
@@ -1882,6 +1882,18 @@ TRACE_EVENT(drv_del_nan_func, ) ); +DEFINE_EVENT (local_sdata_evt, drv_start_pmsr, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata), +TP_ARGS (local, sdata) +); + +DEFINE_EVENT (local_sdata_evt, drv_abort_pmsr, + TP_PROTO(struct ieee80211_local *local, + struct ieee80211_sub_if_data *sdata), +TP_ARGS (local, sdata) +); +/* * Tracing for API calls that drivers call. */
Signature · 1 line
2.17.2
On 10/16/2018 12:30 PM, Johannes Berg wrote:
[...]
Quoted 8 lines
+ * @rtt_avg: average of RTTs measured (must have either this or @dist_avg)
+ * @rtt_variance: variance of RTTs measured (note that standard deviation is
+ * the square root of the variance)
+ * @rtt_spread: spread of the RTTs measured
+ * @dist_avg: average of distances (mm) measured
+ * (must have either this or @rtt_avg)
+ * @dist_variance: variance of distances measured (see also @rtt_variance)
+ * @dist_spread: spread of distances measured (see also @rtt_spread)
I don't remember much from my statistics class, can you please provide some details about the variance and spread fields? Alternatively I can look at the first driver implementation for reference, unless it is calculated by FW :-)
include/net/cfg80211.h struct cfg80211_ftm_responder_stats { · line 2939
Quoted 10 lines
include/net/cfg80211.h +10
-0+ +/** +* struct cfg80211_pmsr_result - peer measurement result +* @addr: address of the peer +* @host_time: host time (use ktime_get_boottime() adjust to the time when the +* measurement was made) +* @ap_tsf: AP's TSF at measurement time +* @status: status of the measurement +* @partial: indicates that this is a partial result for this type +* @final: if reporting partial results, mark this as the last one
Maybe it is enough to have just the "final" bit? I mean if final bit is clear doesn't this imply the result is partial since more results will follow?
[...]
Quoted 7 lines
/*
include/net/cfg80211.h +2
-0@@ -3863,6 +4055,33 @@ struct wiphy_iftype_ext_capab {u8 extended_capabilities_len; }; +/** +* struct cfg80211_pmsr_capabilities - cfg80211 peer measurement capabilities
include/net/cfg80211.h struct wiphy_iftype_ext_capab { · line 4069
Quoted 10 lines
include/net/cfg80211.h +10
-0+* @max_peers: maximum number of peers in a single measurement +* @report_ap_tsf: can report assoc AP's TSF for radio resource measurement +* @randomize_mac_addr: can randomize MAC address for measurement +* @ftm.supported: FTM measurement is supported +* @ftm.asap: ASAP-mode is supported +* @ftm.non_asap: non-ASAP-mode is supported +* @ftm.request_lci: can request LCI data +* @ftm.request_civicloc: can request civic location data +* @ftm.preambles: bitmap of preambles supported (&enum nl80211_preamble) +* @ftm.bandwidths: bitmap of bandwidths supported (&enum nl80211_chan_width)
Consider adding ftm.max_bursts (or max_bursts_exponent) and ftm.max_measurements_per_burst (is this the same as frames_per_burst?). For example in our implementation we can't do more than 6 measurements per burst because of resource limitations.
Quoted 32 lines
include/uapi/linux/nl80211.h +32
-0+ +/** +* enum nl80211_peer_measurement_ftm_resp - FTM response attributes +* @__NL80211_PMSR_FTM_RESP_ATTR_INVALID: invalid +* +* @NL80211_PMSR_FTM_RESP_ATTR_FAIL_REASON: FTM-specific failure reason +* (u32, optional) +* @NL80211_PMSR_FTM_RESP_ATTR_BURST_INDEX: optional, if bursts are reported +* as separate results then it will be the burst index 0...(N-1) and +* the top level will indicate partial results (u32) +* @NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_ATTEMPTS: number of FTM Request frames +* transmitted (u32, optional) +* @NL80211_PMSR_FTM_RESP_ATTR_NUM_FTMR_SUCCESSES: number of FTM Request frames +* that were acknowleged (u32, optional) +* @NL80211_PMSR_FTM_RESP_ATTR_BUSY_RETRY_TIME: retry time received from the +* busy peer (u32, seconds) +* @NL80211_PMSR_FTM_RESP_ATTR_NUM_BURSTS_EXP: actual number of bursts exponent +* used by the responder (similar to request, u8) +* @NL80211_PMSR_FTM_RESP_ATTR_BURST_DURATION: actual burst duration used by +* the responder (similar to request, u8) +* @NL80211_PMSR_FTM_RESP_ATTR_FRAMES_PER_BURST: actual frames per burst used +* by the responder (similar to request, u8) +* @NL80211_PMSR_FTM_RESP_ATTR_RSSI_AVG: average RSSI across all FTM action +* frames (optional, s32, 1/2 dBm) +* @NL80211_PMSR_FTM_RESP_ATTR_RSSI_SPREAD: RSSI spread across all FTM action +* frames (optional, s32, 1/2 dBm) +* @NL80211_PMSR_FTM_RESP_ATTR_TX_RATE: bitrate we used for the response to the +* FTM action frame (optional, nested, using &enum nl80211_rate_info +* attributes) +* @NL80211_PMSR_FTM_RESP_ATTR_RX_RATE: bitrate the responder used for the FTM +* action frame (optional, nested, using &enum nl80211_rate_info attrs) +* @NL80211_PMSR_FTM_RESP_ATTR_RTT_AVG: average RTT (s64, picoseconds, optional
include/uapi/linux/nl80211.h enum nl80211_ftm_responder_stats { · line 6282
Quoted 10 lines
include/uapi/linux/nl80211.h +10
-0+* but one of RTT/DIST must be present) +* @NL80211_PMSR_FTM_RESP_ATTR_RTT_VARIANCE: RTT variance (u64, ps^2, note that +* standard deviation is the square root of variance, optional) +* @NL80211_PMSR_FTM_RESP_ATTR_RTT_SPREAD: RTT spread (u64, picoseconds, +* optional) +* @NL80211_PMSR_FTM_RESP_ATTR_DIST_AVG: average distance (s64, mm, optional +* but one of RTT/DIST must be present) +* @NL80211_PMSR_FTM_RESP_ATTR_DIST_VARIANCE: distance variance (u64, mm^2, note +* that standard deviation is the square root of variance, optional) +* @NL80211_PMSR_FTM_RESP_ATTR_DIST_SPREAD: distance spread (u64, mm, optional)
Ok I see variance and spread are better documented here, maybe move the units information to the above structure definitions?
[...]
Quoted 9 lines
net/wireless/nl80211.h +1
-0@@ -4,8 +4,45 @@#include "core.h" +/* multicast groups */
net/wireless/nl80211.h line 17
Quoted 10 lines
net/wireless/nl80211.h +10
-0+enum nl80211_multicast_groups { +NL80211_MCGRP_CONFIG , +NL80211_MCGRP_SCAN , +NL80211_MCGRP_REGULATORY , +NL80211_MCGRP_MLME , +NL80211_MCGRP_VENDOR , +NL80211_MCGRP_NAN , +NL80211_MCGRP_TESTMODE /* keep last - ifdef! */ +}; +
Are these changes needed anymore since you don't send results as multicast?
[snipped the rest, looks ok]
Thanks,
Lior
Johannes Berg
maintainerQuoted 13 lines · Lior David
On 10/16/2018 12:30 PM, Johannes Berg wrote:
[...]
Quoted 8 lines
+ * @rtt_avg: average of RTTs measured (must have either this or @dist_avg)
+ * @rtt_variance: variance of RTTs measured (note that standard deviation is
+ * the square root of the variance)
+ * @rtt_spread: spread of the RTTs measured
+ * @dist_avg: average of distances (mm) measured
+ * (must have either this or @rtt_avg)
+ * @dist_variance: variance of distances measured (see also @rtt_variance)
+ * @dist_spread: spread of distances measured (see also @rtt_spread)
Quoted 3 lines
I don't remember much from my statistics class, can you please provide some details about the variance and spread fields? Alternatively I can look at the first driver implementation for reference, unless it is calculated by FW :-)
It can only be calculated by firmware, unless the firmware reports all measurements.
Spread here is just "highest value - lowest value.
Variance is a more complicated measure of the distribution... What do you want to know? Here we have a finite set of values, so
https://en.wikipedia.org/wiki/Variance#Population_variance
Quoted 5 lines
Quoted 2 lines
+ * @partial: indicates that this is a partial result for this type
+ * @final: if reporting partial results, mark this as the last oneMaybe it is enough to have just the "final" bit? I mean if final bit is clear doesn't this imply the result is partial since more results will follow?
Hmm, good point.
Quoted 13 lines
Quoted 4 lines
+/**
+ * structcfg80211_pmsr_capabilities- cfg80211 peer measurement capabilities
+ * @max_peers: maximum number of peers in a single measurement
+ * @report_ap_tsf: can report assoc AP's TSF for radio resource measurementQuoted 8 lines
+ * @randomize_mac_addr: can randomize MAC address for measurement
+ * @ftm.supported: FTM measurement is supported
+ * @ftm.asap: ASAP-mode is supported
+ * @ftm.non_asap: non-ASAP-mode is supported
+ * @ftm.request_lci: can request LCI data
+ * @ftm.request_civicloc: can request civic location data
+ * @ftm.preambles: bitmap of preambles supported (&enumnl80211_preamble)
+ * @ftm.bandwidths: bitmap of bandwidths supported (&enumnl80211_chan_width)
Quoted 1 line
Consider adding ftm.max_bursts (or
max_bursts_exponent)
Ok.
Quoted 4 lines
and
ftm.max_measurements_per_burst (is this the same asframes_per_burst?). For example in our implementation we can't do more than 6 measurements per burst because of resource limitations.
I guess measurements per burst are frames per burst? I'm not counting 4x the frames because those are exchanged.
The spec says "FTMs per Burst", so perhaps I should align with that.
I suppose we can add that.
Quoted 2 lines
Ok I see variance and spread are better documented here, maybe move the units information to the above structure definitions?
Well, they may seem above - but I thought it was more important to document it better in the userspace API.
Quoted 5 lines
Quoted 5 lines
net/wireless/nl80211.h +5
-0+/* multicast groups */ +enum nl80211_multicast_groups { +NL80211_MCGRP_CONFIG , +NL80211_MCGRP_SCAN , +NL80211_MCGRP_REGULATORY ,
Quoted 8 lines
net/wireless/nl80211.h line 17
Quoted 6 lines
net/wireless/nl80211.h +6
-0+NL80211_MCGRP_MLME , +NL80211_MCGRP_VENDOR , +NL80211_MCGRP_NAN , + NL80211_MCGRP_TESTMODE /* keep last - ifdef! */ +}; +Are these changes needed anymore since you don't send results as multicast?
No, good point.
johannes