Skip to content

Commit

Permalink
cfg80211: support FTM responder configuration/statistics
Browse files Browse the repository at this point in the history
Allow userspace to enable fine timing measurement responder
functionality with configurable lci/civic parameters in AP mode.
This can be done at AP start or changing beacon parameters.

A new EXT_FEATURE flag is introduced for drivers to advertise
the capability.

Also nl80211 API support for retrieving statistics is added.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Pradeep Kumar Chitrapu <pradeepc@codeaurora.org>
[remove unused cfg80211_ftm_responder_params, clarify docs,
 move validation into policy]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Pradeep Kumar Chitrapu authored and jmberg-intel committed Oct 2, 2018
1 parent 7057f24 commit 81e54d0
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 5 deletions.
52 changes: 52 additions & 0 deletions include/net/cfg80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,19 +775,30 @@ struct cfg80211_crypto_settings {
* @assocresp_ies_len: length of assocresp_ies in octets
* @probe_resp_len: length of probe response template (@probe_resp)
* @probe_resp: probe response template (AP mode only)
* @ftm_responder: enable FTM responder functionality; -1 for no change
* (which also implies no change in LCI/civic location data)
* @lci: LCI subelement content
* @civicloc: Civic location subelement content
* @lci_len: LCI data length
* @civicloc_len: Civic location data length
*/
struct cfg80211_beacon_data {
const u8 *head, *tail;
const u8 *beacon_ies;
const u8 *proberesp_ies;
const u8 *assocresp_ies;
const u8 *probe_resp;
const u8 *lci;
const u8 *civicloc;
s8 ftm_responder;

size_t head_len, tail_len;
size_t beacon_ies_len;
size_t proberesp_ies_len;
size_t assocresp_ies_len;
size_t probe_resp_len;
size_t lci_len;
size_t civicloc_len;
};

struct mac_address {
Expand Down Expand Up @@ -2796,6 +2807,40 @@ struct cfg80211_external_auth_params {
u16 status;
};

/**
* cfg80211_ftm_responder_stats - FTM responder statistics
*
* @filled: bitflag of flags using the bits of &enum nl80211_ftm_stats to
* indicate the relevant values in this struct for them
* @success_num: number of FTM sessions in which all frames were successfully
* answered
* @partial_num: number of FTM sessions in which part of frames were
* successfully answered
* @failed_num: number of failed FTM sessions
* @asap_num: number of ASAP FTM sessions
* @non_asap_num: number of non-ASAP FTM sessions
* @total_duration_ms: total sessions durations - gives an indication
* of how much time the responder was busy
* @unknown_triggers_num: number of unknown FTM triggers - triggers from
* initiators that didn't finish successfully the negotiation phase with
* the responder
* @reschedule_requests_num: number of FTM reschedule requests - initiator asks
* for a new scheduling although it already has scheduled FTM slot
* @out_of_window_triggers_num: total FTM triggers out of scheduled window
*/
struct cfg80211_ftm_responder_stats {
u32 filled;
u32 success_num;
u32 partial_num;
u32 failed_num;
u32 asap_num;
u32 non_asap_num;
u64 total_duration_ms;
u32 unknown_triggers_num;
u32 reschedule_requests_num;
u32 out_of_window_triggers_num;
};

/**
* struct cfg80211_ops - backend description for wireless configuration
*
Expand Down Expand Up @@ -3128,6 +3173,9 @@ struct cfg80211_external_auth_params {
*
* @tx_control_port: TX a control port frame (EAPoL). The noencrypt parameter
* tells the driver that the frame should not be encrypted.
*
* @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
* Statistics should be cumulative, currently no way to reset is provided.
*/
struct cfg80211_ops {
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
Expand Down Expand Up @@ -3433,6 +3481,10 @@ struct cfg80211_ops {
const u8 *buf, size_t len,
const u8 *dest, const __be16 proto,
const bool noencrypt);

int (*get_ftm_responder_stats)(struct wiphy *wiphy,
struct net_device *dev,
struct cfg80211_ftm_responder_stats *ftm_stats);
};

/*
Expand Down
90 changes: 90 additions & 0 deletions include/uapi/linux/nl80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,9 @@
* %NL80211_ATTR_CHANNEL_WIDTH,%NL80211_ATTR_NSS attributes with its
* address(specified in %NL80211_ATTR_MAC).
*
* @NL80211_CMD_GET_FTM_RESPONDER_STATS: Retrieve FTM responder statistics, in
* the %NL80211_ATTR_FTM_RESPONDER_STATS attribute.
*
* @NL80211_CMD_MAX: highest used command number
* @__NL80211_CMD_AFTER_LAST: internal use
*/
Expand Down Expand Up @@ -1245,6 +1248,8 @@ enum nl80211_commands {

NL80211_CMD_CONTROL_PORT_FRAME,

NL80211_CMD_GET_FTM_RESPONDER_STATS,

/* add new commands above here */

/* used to define NL80211_CMD_MAX below */
Expand Down Expand Up @@ -2241,6 +2246,14 @@ enum nl80211_commands {
* association request when used with NL80211_CMD_NEW_STATION). Can be set
* only if %NL80211_STA_FLAG_WME is set.
*
* @NL80211_ATTR_FTM_RESPONDER: nested attribute which user-space can include
* in %NL80211_CMD_START_AP or %NL80211_CMD_SET_BEACON for fine timing
* measurement (FTM) responder functionality and containing parameters as
* possible, see &enum nl80211_ftm_responder_attr
*
* @NL80211_ATTR_FTM_RESPONDER_STATS: Nested attribute with FTM responder
* statistics, see &enum nl80211_ftm_responder_stats.
*
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
Expand Down Expand Up @@ -2682,6 +2695,10 @@ enum nl80211_attrs {

NL80211_ATTR_HE_CAPABILITY,

NL80211_ATTR_FTM_RESPONDER,

NL80211_ATTR_FTM_RESPONDER_STATS,

/* add attributes here, update the policy in nl80211.c */

__NL80211_ATTR_AFTER_LAST,
Expand Down Expand Up @@ -5225,6 +5242,8 @@ enum nl80211_feature_flags {
* @NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT: Driver/device can omit all data
* except for supported rates from the probe request content if requested
* by the %NL80211_SCAN_FLAG_MIN_PREQ_CONTENT flag.
* @NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER: Driver supports enabling fine
* timing measurement responder role.
*
* @NL80211_EXT_FEATURE_CAN_REPLACE_PTK0: Driver/device confirm that they are
* able to rekey an in-use key correctly. Userspace must not rekey PTK keys
Expand Down Expand Up @@ -5269,6 +5288,7 @@ enum nl80211_ext_feature_index {
NL80211_EXT_FEATURE_SCAN_RANDOM_SN,
NL80211_EXT_FEATURE_SCAN_MIN_PREQ_CONTENT,
NL80211_EXT_FEATURE_CAN_REPLACE_PTK0,
NL80211_EXT_FEATURE_ENABLE_FTM_RESPONDER,

/* add new features before the definition below */
NUM_NL80211_EXT_FEATURES,
Expand Down Expand Up @@ -5808,4 +5828,74 @@ enum nl80211_external_auth_action {
NL80211_EXTERNAL_AUTH_ABORT,
};

/**
* enum nl80211_ftm_responder_attributes - fine timing measurement
* responder attributes
* @__NL80211_FTM_RESP_ATTR_INVALID: Invalid
* @NL80211_FTM_RESP_ATTR_ENABLED: FTM responder is enabled
* @NL80211_FTM_RESP_ATTR_LCI: The content of Measurement Report Element
* (9.4.2.22 in 802.11-2016) with type 8 - LCI (9.4.2.22.10)
* @NL80211_FTM_RESP_ATTR_CIVIC: The content of Measurement Report Element
* (9.4.2.22 in 802.11-2016) with type 11 - Civic (Section 9.4.2.22.13)
* @__NL80211_FTM_RESP_ATTR_LAST: Internal
* @NL80211_FTM_RESP_ATTR_MAX: highest FTM responder attribute.
*/
enum nl80211_ftm_responder_attributes {
__NL80211_FTM_RESP_ATTR_INVALID,

NL80211_FTM_RESP_ATTR_ENABLED,
NL80211_FTM_RESP_ATTR_LCI,
NL80211_FTM_RESP_ATTR_CIVICLOC,

/* keep last */
__NL80211_FTM_RESP_ATTR_LAST,
NL80211_FTM_RESP_ATTR_MAX = __NL80211_FTM_RESP_ATTR_LAST - 1,
};

/*
* enum nl80211_ftm_responder_stats - FTM responder statistics
*
* These attribute types are used with %NL80211_ATTR_FTM_RESPONDER_STATS
* when getting FTM responder statistics.
*
* @__NL80211_FTM_STATS_INVALID: attribute number 0 is reserved
* @NL80211_FTM_STATS_SUCCESS_NUM: number of FTM sessions in which all frames
* were ssfully answered (u32)
* @NL80211_FTM_STATS_PARTIAL_NUM: number of FTM sessions in which part of the
* frames were successfully answered (u32)
* @NL80211_FTM_STATS_FAILED_NUM: number of failed FTM sessions (u32)
* @NL80211_FTM_STATS_ASAP_NUM: number of ASAP sessions (u32)
* @NL80211_FTM_STATS_NON_ASAP_NUM: number of non-ASAP sessions (u32)
* @NL80211_FTM_STATS_TOTAL_DURATION_MSEC: total sessions durations - gives an
* indication of how much time the responder was busy (u64, msec)
* @NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM: number of unknown FTM triggers -
* triggers from initiators that didn't finish successfully the negotiation
* phase with the responder (u32)
* @NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM: number of FTM reschedule requests
* - initiator asks for a new scheduling although it already has scheduled
* FTM slot (u32)
* @NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM: number of FTM triggers out of
* scheduled window (u32)
* @NL80211_FTM_STATS_PAD: used for padding, ignore
* @__NL80211_TXQ_ATTR_AFTER_LAST: Internal
* @NL80211_FTM_STATS_MAX: highest possible FTM responder stats attribute
*/
enum nl80211_ftm_responder_stats {
__NL80211_FTM_STATS_INVALID,
NL80211_FTM_STATS_SUCCESS_NUM,
NL80211_FTM_STATS_PARTIAL_NUM,
NL80211_FTM_STATS_FAILED_NUM,
NL80211_FTM_STATS_ASAP_NUM,
NL80211_FTM_STATS_NON_ASAP_NUM,
NL80211_FTM_STATS_TOTAL_DURATION_MSEC,
NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM,
NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM,
NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM,
NL80211_FTM_STATS_PAD,

/* keep last */
__NL80211_FTM_STATS_AFTER_LAST,
NL80211_FTM_STATS_MAX = __NL80211_FTM_STATS_AFTER_LAST - 1
};

#endif /* __LINUX_NL80211_H */
Loading

0 comments on commit 81e54d0

Please sign in to comment.