4f59507cab50b0218b90e92e6f2f681b8d6202a2
[oweals/openwrt.git] /
1 From 7742fce4c007141617dab9bcb90034b3c0fe2347 Mon Sep 17 00:00:00 2001
2 From: Franky Lin <franky.lin@broadcom.com>
3 Date: Thu, 26 Apr 2018 12:18:35 +0200
4 Subject: [PATCH] brcmfmac: reports boottime_ns while informing bss
5
6 Provides a timestamp in bss information so user space can see when the
7 bss info was updated. Since tsf is not available from the dongle events
8 boottime is reported instead.
9
10 Reported-by: Dmitry Shmidt <dimitrysh@google.com>
11 Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
12 Signed-off-by: Franky Lin <franky.lin@broadcom.com>
13 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 ---
16  .../broadcom/brcm80211/brcmfmac/cfg80211.c         | 26 +++++++++++-----------
17  1 file changed, 13 insertions(+), 13 deletions(-)
18
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 @@ -2728,7 +2728,6 @@ static s32 brcmf_inform_single_bss(struc
22                                    struct brcmf_bss_info_le *bi)
23  {
24         struct wiphy *wiphy = cfg_to_wiphy(cfg);
25 -       struct ieee80211_channel *notify_channel;
26         struct cfg80211_bss *bss;
27         struct ieee80211_supported_band *band;
28         struct brcmu_chan ch;
29 @@ -2738,7 +2737,7 @@ static s32 brcmf_inform_single_bss(struc
30         u16 notify_interval;
31         u8 *notify_ie;
32         size_t notify_ielen;
33 -       s32 notify_signal;
34 +       struct cfg80211_inform_bss bss_data = { 0 };
35  
36         if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
37                 brcmf_err("Bss info is larger than buffer. Discarding\n");
38 @@ -2758,27 +2757,28 @@ static s32 brcmf_inform_single_bss(struc
39                 band = wiphy->bands[NL80211_BAND_5GHZ];
40  
41         freq = ieee80211_channel_to_frequency(channel, band->band);
42 -       notify_channel = ieee80211_get_channel(wiphy, freq);
43 +       bss_data.chan = ieee80211_get_channel(wiphy, freq);
44 +       bss_data.scan_width = NL80211_BSS_CHAN_WIDTH_20;
45 +       bss_data.boottime_ns = ktime_to_ns(ktime_get_boottime());
46  
47         notify_capability = le16_to_cpu(bi->capability);
48         notify_interval = le16_to_cpu(bi->beacon_period);
49         notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
50         notify_ielen = le32_to_cpu(bi->ie_length);
51 -       notify_signal = (s16)le16_to_cpu(bi->RSSI) * 100;
52 +       bss_data.signal = (s16)le16_to_cpu(bi->RSSI) * 100;
53  
54         brcmf_dbg(CONN, "bssid: %pM\n", bi->BSSID);
55         brcmf_dbg(CONN, "Channel: %d(%d)\n", channel, freq);
56         brcmf_dbg(CONN, "Capability: %X\n", notify_capability);
57         brcmf_dbg(CONN, "Beacon interval: %d\n", notify_interval);
58 -       brcmf_dbg(CONN, "Signal: %d\n", notify_signal);
59 +       brcmf_dbg(CONN, "Signal: %d\n", bss_data.signal);
60  
61 -       bss = cfg80211_inform_bss(wiphy, notify_channel,
62 -                                 CFG80211_BSS_FTYPE_UNKNOWN,
63 -                                 (const u8 *)bi->BSSID,
64 -                                 0, notify_capability,
65 -                                 notify_interval, notify_ie,
66 -                                 notify_ielen, notify_signal,
67 -                                 GFP_KERNEL);
68 +       bss = cfg80211_inform_bss_data(wiphy, &bss_data,
69 +                                      CFG80211_BSS_FTYPE_UNKNOWN,
70 +                                      (const u8 *)bi->BSSID,
71 +                                      0, notify_capability,
72 +                                      notify_interval, notify_ie,
73 +                                      notify_ielen, GFP_KERNEL);
74  
75         if (!bss)
76                 return -ENOMEM;