1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Fri, 20 May 2016 13:38:58 +0200
3 Subject: [PATCH] brcmfmac: support get_channel cfg80211 callback
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
8 This is important for brcmfmac as some of released firmwares (e.g.
9 brcmfmac4366b-pcie.bin) may pick different channel than requested. This
10 has been tested with BCM4366B1 in D-Link DIR-885L.
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
16 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
17 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
18 @@ -4863,6 +4863,68 @@ exit:
22 +static int brcmf_cfg80211_get_channel(struct wiphy *wiphy,
23 + struct wireless_dev *wdev,
24 + struct cfg80211_chan_def *chandef)
26 + struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
27 + struct net_device *ndev = wdev->netdev;
28 + struct brcmf_if *ifp;
29 + struct brcmu_chan ch;
30 + enum nl80211_band band = 0;
31 + enum nl80211_chan_width width = 0;
37 + ifp = netdev_priv(ndev);
39 + err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
41 + brcmf_err("chanspec failed (%d)\n", err);
45 + ch.chspec = chanspec;
46 + cfg->d11inf.decchspec(&ch);
49 + case BRCMU_CHAN_BAND_2G:
50 + band = NL80211_BAND_2GHZ;
52 + case BRCMU_CHAN_BAND_5G:
53 + band = NL80211_BAND_5GHZ;
58 + case BRCMU_CHAN_BW_80:
59 + width = NL80211_CHAN_WIDTH_80;
61 + case BRCMU_CHAN_BW_40:
62 + width = NL80211_CHAN_WIDTH_40;
64 + case BRCMU_CHAN_BW_20:
65 + width = NL80211_CHAN_WIDTH_20;
67 + case BRCMU_CHAN_BW_80P80:
68 + width = NL80211_CHAN_WIDTH_80P80;
70 + case BRCMU_CHAN_BW_160:
71 + width = NL80211_CHAN_WIDTH_160;
75 + freq = ieee80211_channel_to_frequency(ch.control_ch_num, band);
76 + chandef->chan = ieee80211_get_channel(wiphy, freq);
77 + chandef->width = width;
78 + chandef->center_freq1 = ieee80211_channel_to_frequency(ch.chnum, band);
79 + chandef->center_freq2 = 0;
84 static int brcmf_cfg80211_crit_proto_start(struct wiphy *wiphy,
85 struct wireless_dev *wdev,
86 enum nl80211_crit_proto_id proto,
87 @@ -5025,6 +5087,7 @@ static struct cfg80211_ops brcmf_cfg8021
88 .mgmt_tx = brcmf_cfg80211_mgmt_tx,
89 .remain_on_channel = brcmf_p2p_remain_on_channel,
90 .cancel_remain_on_channel = brcmf_cfg80211_cancel_remain_on_channel,
91 + .get_channel = brcmf_cfg80211_get_channel,
92 .start_p2p_device = brcmf_p2p_start_device,
93 .stop_p2p_device = brcmf_p2p_stop_device,
94 .crit_proto_start = brcmf_cfg80211_crit_proto_start,