Skip to content

Commit 81e54d0

Browse files
Pradeep Kumar Chitrapujmberg-intel
authored andcommitted
cfg80211: support FTM responder configuration/statistics
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 <[email protected]> Signed-off-by: Pradeep Kumar Chitrapu <[email protected]> [remove unused cfg80211_ftm_responder_params, clarify docs, move validation into policy] Signed-off-by: Johannes Berg <[email protected]>
1 parent 7057f24 commit 81e54d0

File tree

5 files changed

+328
-5
lines changed

5 files changed

+328
-5
lines changed

include/net/cfg80211.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,19 +775,30 @@ struct cfg80211_crypto_settings {
775775
* @assocresp_ies_len: length of assocresp_ies in octets
776776
* @probe_resp_len: length of probe response template (@probe_resp)
777777
* @probe_resp: probe response template (AP mode only)
778+
* @ftm_responder: enable FTM responder functionality; -1 for no change
779+
* (which also implies no change in LCI/civic location data)
780+
* @lci: LCI subelement content
781+
* @civicloc: Civic location subelement content
782+
* @lci_len: LCI data length
783+
* @civicloc_len: Civic location data length
778784
*/
779785
struct cfg80211_beacon_data {
780786
const u8 *head, *tail;
781787
const u8 *beacon_ies;
782788
const u8 *proberesp_ies;
783789
const u8 *assocresp_ies;
784790
const u8 *probe_resp;
791+
const u8 *lci;
792+
const u8 *civicloc;
793+
s8 ftm_responder;
785794

786795
size_t head_len, tail_len;
787796
size_t beacon_ies_len;
788797
size_t proberesp_ies_len;
789798
size_t assocresp_ies_len;
790799
size_t probe_resp_len;
800+
size_t lci_len;
801+
size_t civicloc_len;
791802
};
792803

793804
struct mac_address {
@@ -2796,6 +2807,40 @@ struct cfg80211_external_auth_params {
27962807
u16 status;
27972808
};
27982809

2810+
/**
2811+
* cfg80211_ftm_responder_stats - FTM responder statistics
2812+
*
2813+
* @filled: bitflag of flags using the bits of &enum nl80211_ftm_stats to
2814+
* indicate the relevant values in this struct for them
2815+
* @success_num: number of FTM sessions in which all frames were successfully
2816+
* answered
2817+
* @partial_num: number of FTM sessions in which part of frames were
2818+
* successfully answered
2819+
* @failed_num: number of failed FTM sessions
2820+
* @asap_num: number of ASAP FTM sessions
2821+
* @non_asap_num: number of non-ASAP FTM sessions
2822+
* @total_duration_ms: total sessions durations - gives an indication
2823+
* of how much time the responder was busy
2824+
* @unknown_triggers_num: number of unknown FTM triggers - triggers from
2825+
* initiators that didn't finish successfully the negotiation phase with
2826+
* the responder
2827+
* @reschedule_requests_num: number of FTM reschedule requests - initiator asks
2828+
* for a new scheduling although it already has scheduled FTM slot
2829+
* @out_of_window_triggers_num: total FTM triggers out of scheduled window
2830+
*/
2831+
struct cfg80211_ftm_responder_stats {
2832+
u32 filled;
2833+
u32 success_num;
2834+
u32 partial_num;
2835+
u32 failed_num;
2836+
u32 asap_num;
2837+
u32 non_asap_num;
2838+
u64 total_duration_ms;
2839+
u32 unknown_triggers_num;
2840+
u32 reschedule_requests_num;
2841+
u32 out_of_window_triggers_num;
2842+
};
2843+
27992844
/**
28002845
* struct cfg80211_ops - backend description for wireless configuration
28012846
*
@@ -3128,6 +3173,9 @@ struct cfg80211_external_auth_params {
31283173
*
31293174
* @tx_control_port: TX a control port frame (EAPoL). The noencrypt parameter
31303175
* tells the driver that the frame should not be encrypted.
3176+
*
3177+
* @get_ftm_responder_stats: Retrieve FTM responder statistics, if available.
3178+
* Statistics should be cumulative, currently no way to reset is provided.
31313179
*/
31323180
struct cfg80211_ops {
31333181
int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow);
@@ -3433,6 +3481,10 @@ struct cfg80211_ops {
34333481
const u8 *buf, size_t len,
34343482
const u8 *dest, const __be16 proto,
34353483
const bool noencrypt);
3484+
3485+
int (*get_ftm_responder_stats)(struct wiphy *wiphy,
3486+
struct net_device *dev,
3487+
struct cfg80211_ftm_responder_stats *ftm_stats);
34363488
};
34373489

34383490
/*

include/uapi/linux/nl80211.h

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,9 @@
10331033
* %NL80211_ATTR_CHANNEL_WIDTH,%NL80211_ATTR_NSS attributes with its
10341034
* address(specified in %NL80211_ATTR_MAC).
10351035
*
1036+
* @NL80211_CMD_GET_FTM_RESPONDER_STATS: Retrieve FTM responder statistics, in
1037+
* the %NL80211_ATTR_FTM_RESPONDER_STATS attribute.
1038+
*
10361039
* @NL80211_CMD_MAX: highest used command number
10371040
* @__NL80211_CMD_AFTER_LAST: internal use
10381041
*/
@@ -1245,6 +1248,8 @@ enum nl80211_commands {
12451248

12461249
NL80211_CMD_CONTROL_PORT_FRAME,
12471250

1251+
NL80211_CMD_GET_FTM_RESPONDER_STATS,
1252+
12481253
/* add new commands above here */
12491254

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

26832696
NL80211_ATTR_HE_CAPABILITY,
26842697

2698+
NL80211_ATTR_FTM_RESPONDER,
2699+
2700+
NL80211_ATTR_FTM_RESPONDER_STATS,
2701+
26852702
/* add attributes here, update the policy in nl80211.c */
26862703

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

52735293
/* add new features before the definition below */
52745294
NUM_NL80211_EXT_FEATURES,
@@ -5808,4 +5828,74 @@ enum nl80211_external_auth_action {
58085828
NL80211_EXTERNAL_AUTH_ABORT,
58095829
};
58105830

5831+
/**
5832+
* enum nl80211_ftm_responder_attributes - fine timing measurement
5833+
* responder attributes
5834+
* @__NL80211_FTM_RESP_ATTR_INVALID: Invalid
5835+
* @NL80211_FTM_RESP_ATTR_ENABLED: FTM responder is enabled
5836+
* @NL80211_FTM_RESP_ATTR_LCI: The content of Measurement Report Element
5837+
* (9.4.2.22 in 802.11-2016) with type 8 - LCI (9.4.2.22.10)
5838+
* @NL80211_FTM_RESP_ATTR_CIVIC: The content of Measurement Report Element
5839+
* (9.4.2.22 in 802.11-2016) with type 11 - Civic (Section 9.4.2.22.13)
5840+
* @__NL80211_FTM_RESP_ATTR_LAST: Internal
5841+
* @NL80211_FTM_RESP_ATTR_MAX: highest FTM responder attribute.
5842+
*/
5843+
enum nl80211_ftm_responder_attributes {
5844+
__NL80211_FTM_RESP_ATTR_INVALID,
5845+
5846+
NL80211_FTM_RESP_ATTR_ENABLED,
5847+
NL80211_FTM_RESP_ATTR_LCI,
5848+
NL80211_FTM_RESP_ATTR_CIVICLOC,
5849+
5850+
/* keep last */
5851+
__NL80211_FTM_RESP_ATTR_LAST,
5852+
NL80211_FTM_RESP_ATTR_MAX = __NL80211_FTM_RESP_ATTR_LAST - 1,
5853+
};
5854+
5855+
/*
5856+
* enum nl80211_ftm_responder_stats - FTM responder statistics
5857+
*
5858+
* These attribute types are used with %NL80211_ATTR_FTM_RESPONDER_STATS
5859+
* when getting FTM responder statistics.
5860+
*
5861+
* @__NL80211_FTM_STATS_INVALID: attribute number 0 is reserved
5862+
* @NL80211_FTM_STATS_SUCCESS_NUM: number of FTM sessions in which all frames
5863+
* were ssfully answered (u32)
5864+
* @NL80211_FTM_STATS_PARTIAL_NUM: number of FTM sessions in which part of the
5865+
* frames were successfully answered (u32)
5866+
* @NL80211_FTM_STATS_FAILED_NUM: number of failed FTM sessions (u32)
5867+
* @NL80211_FTM_STATS_ASAP_NUM: number of ASAP sessions (u32)
5868+
* @NL80211_FTM_STATS_NON_ASAP_NUM: number of non-ASAP sessions (u32)
5869+
* @NL80211_FTM_STATS_TOTAL_DURATION_MSEC: total sessions durations - gives an
5870+
* indication of how much time the responder was busy (u64, msec)
5871+
* @NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM: number of unknown FTM triggers -
5872+
* triggers from initiators that didn't finish successfully the negotiation
5873+
* phase with the responder (u32)
5874+
* @NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM: number of FTM reschedule requests
5875+
* - initiator asks for a new scheduling although it already has scheduled
5876+
* FTM slot (u32)
5877+
* @NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM: number of FTM triggers out of
5878+
* scheduled window (u32)
5879+
* @NL80211_FTM_STATS_PAD: used for padding, ignore
5880+
* @__NL80211_TXQ_ATTR_AFTER_LAST: Internal
5881+
* @NL80211_FTM_STATS_MAX: highest possible FTM responder stats attribute
5882+
*/
5883+
enum nl80211_ftm_responder_stats {
5884+
__NL80211_FTM_STATS_INVALID,
5885+
NL80211_FTM_STATS_SUCCESS_NUM,
5886+
NL80211_FTM_STATS_PARTIAL_NUM,
5887+
NL80211_FTM_STATS_FAILED_NUM,
5888+
NL80211_FTM_STATS_ASAP_NUM,
5889+
NL80211_FTM_STATS_NON_ASAP_NUM,
5890+
NL80211_FTM_STATS_TOTAL_DURATION_MSEC,
5891+
NL80211_FTM_STATS_UNKNOWN_TRIGGERS_NUM,
5892+
NL80211_FTM_STATS_RESCHEDULE_REQUESTS_NUM,
5893+
NL80211_FTM_STATS_OUT_OF_WINDOW_TRIGGERS_NUM,
5894+
NL80211_FTM_STATS_PAD,
5895+
5896+
/* keep last */
5897+
__NL80211_FTM_STATS_AFTER_LAST,
5898+
NL80211_FTM_STATS_MAX = __NL80211_FTM_STATS_AFTER_LAST - 1
5899+
};
5900+
58115901
#endif /* __LINUX_NL80211_H */

0 commit comments

Comments
 (0)