1 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
2 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
3 @@ -2910,6 +2910,63 @@ done:
7 +brcmf_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev,
8 + int idx, struct survey_info *survey)
10 + struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
11 + struct brcmf_if *ifp = netdev_priv(ndev);
12 + struct brcmu_chan ch;
13 + enum nl80211_band band = 0;
19 + memset(survey, 0, sizeof(struct survey_info));
21 + if (idx >= cfg->pub->num_chan_stats || cfg->pub->chan_stats == NULL)
23 + if (cfg->pub->chan_stats[idx].freq == 0)
25 + survey->filled = SURVEY_INFO_NOISE_DBM;
26 + survey->channel = ieee80211_get_channel(wiphy, cfg->pub->chan_stats[idx].freq);
27 + survey->noise = cfg->pub->chan_stats[idx].noise;
31 + err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
33 + brcmf_err("chanspec failed (%d)\n", err);
37 + ch.chspec = chanspec;
38 + cfg->d11inf.decchspec(&ch);
41 + case BRCMU_CHAN_BAND_2G:
42 + band = NL80211_BAND_2GHZ;
44 + case BRCMU_CHAN_BAND_5G:
45 + band = NL80211_BAND_5GHZ;
49 + freq = ieee80211_channel_to_frequency(ch.control_ch_num, band);
50 + survey->channel = ieee80211_get_channel(wiphy, freq);
52 + err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_PHY_NOISE, &noise);
54 + brcmf_err("Could not get noise (%d)\n", err);
58 + survey->filled = SURVEY_INFO_NOISE_DBM | SURVEY_INFO_IN_USE;
59 + survey->noise = le32_to_cpu(noise);
64 brcmf_cfg80211_dump_station(struct wiphy *wiphy, struct net_device *ndev,
65 int idx, u8 *mac, struct station_info *sinfo)
67 @@ -3005,6 +3062,7 @@ static s32 brcmf_inform_single_bss(struc
72 u16 notify_capability;
75 @@ -3029,6 +3087,17 @@ static s32 brcmf_inform_single_bss(struc
76 band = NL80211_BAND_5GHZ;
78 freq = ieee80211_channel_to_frequency(channel, band);
79 + for (i = 0;i < cfg->pub->num_chan_stats;i++) {
80 + if (freq == cfg->pub->chan_stats[i].freq)
82 + if (cfg->pub->chan_stats[i].freq == 0)
85 + if (i < cfg->pub->num_chan_stats) {
86 + cfg->pub->chan_stats[i].freq = freq;
87 + cfg->pub->chan_stats[i].noise = bi->phy_noise;
90 bss_data.chan = ieee80211_get_channel(wiphy, freq);
91 bss_data.scan_width = NL80211_BSS_CHAN_WIDTH_20;
92 bss_data.boottime_ns = ktime_to_ns(ktime_get_boottime());
93 @@ -5515,6 +5584,7 @@ static struct cfg80211_ops brcmf_cfg8021
94 .leave_ibss = brcmf_cfg80211_leave_ibss,
95 .get_station = brcmf_cfg80211_get_station,
96 .dump_station = brcmf_cfg80211_dump_station,
97 + .dump_survey = brcmf_cfg80211_dump_survey,
98 .set_tx_power = brcmf_cfg80211_set_tx_power,
99 .get_tx_power = brcmf_cfg80211_get_tx_power,
100 .add_key = brcmf_cfg80211_add_key,
101 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
102 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
103 @@ -1356,6 +1356,8 @@ int brcmf_attach(struct device *dev)
105 /* Link to bus module */
107 + drvr->chan_stats = vzalloc(256 * sizeof(struct brcmf_chan_stats));
108 + drvr->num_chan_stats = 256;
110 /* Attach and link in the protocol */
111 ret = brcmf_proto_attach(drvr);
112 @@ -1438,6 +1440,12 @@ void brcmf_detach(struct device *dev)
116 + drvr->num_chan_stats = 0;
117 + if (drvr->chan_stats) {
118 + vfree(drvr->chan_stats);
119 + drvr->chan_stats = NULL;
123 unregister_inetaddr_notifier(&drvr->inetaddr_notifier);
125 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
126 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
127 @@ -91,6 +91,11 @@ struct brcmf_rev_info {
131 +struct brcmf_chan_stats {
136 /* Common structure for module and instance linkage */
138 /* Linkage ponters */
139 @@ -100,6 +105,9 @@ struct brcmf_pub {
140 struct cfg80211_ops *ops;
141 struct brcmf_cfg80211_info *config;
143 + int num_chan_stats;
144 + struct brcmf_chan_stats *chan_stats;
146 /* Internal brcmf items */
147 uint hdrlen; /* Total BRCMF header length (proto + bus) */