mac80211: backport some upstream fixes
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 349-mac80211-fix-legacy-invalid-rxrate.patch
1 From a17d93ff3a950fefaea40e4a4bf3669b9137c533 Mon Sep 17 00:00:00 2001
2 From: Ben Greear <greearb@candelatech.com>
3 Date: Wed, 14 Dec 2016 11:30:38 -0800
4 Subject: [PATCH] mac80211: fix legacy and invalid rx-rate report
5
6 This fixes obtaining the rate info via sta_set_sinfo
7 when the rx rate is invalid (for instance, on IBSS
8 interface that has received no frames from one of its
9 peers).
10
11 Also initialize rinfo->flags for legacy rates, to not
12 rely on the whole sinfo being initialized to zero.
13
14 Signed-off-by: Ben Greear <greearb@candelatech.com>
15 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
16 ---
17 net/mac80211/sta_info.c | 14 ++++++++------
18 1 file changed, 8 insertions(+), 6 deletions(-)
19
20 --- a/net/mac80211/sta_info.c
21 +++ b/net/mac80211/sta_info.c
22 @@ -1975,6 +1975,7 @@ static void sta_stats_decode_rate(struct
23 u16 brate;
24 unsigned int shift;
25
26 + rinfo->flags = 0;
27 sband = local->hw.wiphy->bands[(rate >> 4) & 0xf];
28 brate = sband->bitrates[rate & 0xf].bitrate;
29 if (rinfo->bw == RATE_INFO_BW_5)
30 @@ -1990,14 +1991,15 @@ static void sta_stats_decode_rate(struct
31 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
32 }
33
34 -static void sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
35 +static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
36 {
37 u16 rate = ACCESS_ONCE(sta_get_last_rx_stats(sta)->last_rate);
38
39 if (rate == STA_STATS_RATE_INVALID)
40 - rinfo->flags = 0;
41 - else
42 - sta_stats_decode_rate(sta->local, rate, rinfo);
43 + return -EINVAL;
44 +
45 + sta_stats_decode_rate(sta->local, rate, rinfo);
46 + return 0;
47 }
48
49 static void sta_set_tidstats(struct sta_info *sta,
50 @@ -2202,8 +2204,8 @@ void sta_set_sinfo(struct sta_info *sta,
51 }
52
53 if (!(sinfo->filled & BIT(NL80211_STA_INFO_RX_BITRATE))) {
54 - sta_set_rate_info_rx(sta, &sinfo->rxrate);
55 - sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
56 + if (sta_set_rate_info_rx(sta, &sinfo->rxrate) == 0)
57 + sinfo->filled |= BIT(NL80211_STA_INFO_RX_BITRATE);
58 }
59
60 sinfo->filled |= BIT(NL80211_STA_INFO_TID_STATS);