af70b46fdcfc10a6ee4e608613fb359769a2f876
[openwrt/openwrt.git] /
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
4
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)
8
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
10 ---
11
12 --- a/include/net/cfg80211.h
13 +++ b/include/net/cfg80211.h
14 @@ -682,6 +682,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
19 *
20 * Used by the driver to indicate which info in &struct survey_info
21 * it has filled in during the get_survey().
22 @@ -695,6 +696,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),
27 };
28
29 /**
30 @@ -711,6 +713,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
35 *
36 * Used by dump_survey() to report back per-channel survey information.
37 *
38 @@ -725,6 +728,7 @@ struct survey_info {
39 u64 time_rx;
40 u64 time_tx;
41 u64 time_scan;
42 + u64 time_bss_rx;
43 u32 filled;
44 s8 noise;
45 };
46 --- a/include/uapi/linux/nl80211.h
47 +++ b/include/uapi/linux/nl80211.h
48 @@ -3836,6 +3836,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
55 * currently defined
56 * @__NL80211_SURVEY_INFO_AFTER_LAST: internal use
57 @@ -3852,6 +3854,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,
62
63 /* keep last */
64 __NL80211_SURVEY_INFO_AFTER_LAST,
65 --- a/net/wireless/nl80211.c
66 +++ b/net/wireless/nl80211.c
67 @@ -8694,6 +8694,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))
70 goto nla_put_failure;
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;
75
76 nla_nest_end(msg, infoattr);
77