1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Wed, 28 Aug 2019 12:13:55 +0200
3 Subject: [PATCH] cfg80211: add local BSS receive time to survey information
5 This is useful for checking how much airtime is being used up by other
6 transmissions on the channel, e.g. by calculating (time_rx - time_bss_rx)
7 or (time_busy - time_bss_rx - time_tx)
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 --- a/include/net/cfg80211.h
13 +++ b/include/net/cfg80211.h
14 @@ -668,6 +668,7 @@ ieee80211_chandef_max_power(struct cfg80
15 * @SURVEY_INFO_TIME_RX: receive time was filled in
16 * @SURVEY_INFO_TIME_TX: transmit time was filled in
17 * @SURVEY_INFO_TIME_SCAN: scan time was filled in
18 + * @SURVEY_INFO_TIME_BSS_RX: local BSS receive time was filled in
20 * Used by the driver to indicate which info in &struct survey_info
21 * it has filled in during the get_survey().
22 @@ -681,6 +682,7 @@ enum survey_info_flags {
23 SURVEY_INFO_TIME_RX = BIT(5),
24 SURVEY_INFO_TIME_TX = BIT(6),
25 SURVEY_INFO_TIME_SCAN = BIT(7),
26 + SURVEY_INFO_TIME_BSS_RX = BIT(8),
30 @@ -697,6 +699,7 @@ enum survey_info_flags {
31 * @time_rx: amount of time the radio spent receiving data
32 * @time_tx: amount of time the radio spent transmitting data
33 * @time_scan: amount of time the radio spent for scanning
34 + * @time_bss_rx: amount of time the radio spent receiving data on a local BSS
36 * Used by dump_survey() to report back per-channel survey information.
38 @@ -711,6 +714,7 @@ struct survey_info {
46 --- a/include/uapi/linux/nl80211.h
47 +++ b/include/uapi/linux/nl80211.h
48 @@ -3693,6 +3693,8 @@ enum nl80211_user_reg_hint_type {
49 * @NL80211_SURVEY_INFO_TIME_SCAN: time the radio spent for scan
50 * (on this channel or globally)
51 * @NL80211_SURVEY_INFO_PAD: attribute used for padding for 64-bit alignment
52 + * @NL80211_SURVEY_INFO_TIME_BSS_RX: amount of time the radio spent
53 + * receiving local BSS data
54 * @NL80211_SURVEY_INFO_MAX: highest survey info attribute number
56 * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
57 @@ -3709,6 +3711,7 @@ enum nl80211_survey_info {
58 NL80211_SURVEY_INFO_TIME_TX,
59 NL80211_SURVEY_INFO_TIME_SCAN,
60 NL80211_SURVEY_INFO_PAD,
61 + NL80211_SURVEY_INFO_TIME_BSS_RX,
64 __NL80211_SURVEY_INFO_AFTER_LAST,
65 --- a/net/wireless/nl80211.c
66 +++ b/net/wireless/nl80211.c
67 @@ -8367,6 +8367,10 @@ static int nl80211_send_survey(struct sk
68 nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME_SCAN,
69 survey->time_scan, NL80211_SURVEY_INFO_PAD))
71 + if ((survey->filled & SURVEY_INFO_TIME_BSS_RX) &&
72 + nla_put_u64_64bit(msg, NL80211_SURVEY_INFO_TIME_BSS_RX,
73 + survey->time_bss_rx, NL80211_SURVEY_INFO_PAD))
74 + goto nla_put_failure;
76 nla_nest_end(msg, infoattr);