rpcd: iwinfo plugin fixes
[openwrt.git] / package / kernel / mac80211 / patches / 351-0008-brcmfmac-support-get_channel-cfg80211-callback.patch
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
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
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.
11
12 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
13 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
14 ---
15
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:
19         return err;
20  }
21  
22 +static int brcmf_cfg80211_get_channel(struct wiphy *wiphy,
23 +                                     struct wireless_dev *wdev,
24 +                                     struct cfg80211_chan_def *chandef)
25 +{
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;
32 +       u32 chanspec;
33 +       int freq, err;
34 +
35 +       if (!ndev)
36 +               return -ENODEV;
37 +       ifp = netdev_priv(ndev);
38 +
39 +       err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
40 +       if (err) {
41 +               brcmf_err("chanspec failed (%d)\n", err);
42 +               return err;
43 +       }
44 +
45 +       ch.chspec = chanspec;
46 +       cfg->d11inf.decchspec(&ch);
47 +
48 +       switch (ch.band) {
49 +       case BRCMU_CHAN_BAND_2G:
50 +               band = NL80211_BAND_2GHZ;
51 +               break;
52 +       case BRCMU_CHAN_BAND_5G:
53 +               band = NL80211_BAND_5GHZ;
54 +               break;
55 +       }
56 +
57 +       switch (ch.bw) {
58 +       case BRCMU_CHAN_BW_80:
59 +               width = NL80211_CHAN_WIDTH_80;
60 +               break;
61 +       case BRCMU_CHAN_BW_40:
62 +               width = NL80211_CHAN_WIDTH_40;
63 +               break;
64 +       case BRCMU_CHAN_BW_20:
65 +               width = NL80211_CHAN_WIDTH_20;
66 +               break;
67 +       case BRCMU_CHAN_BW_80P80:
68 +               width = NL80211_CHAN_WIDTH_80P80;
69 +               break;
70 +       case BRCMU_CHAN_BW_160:
71 +               width = NL80211_CHAN_WIDTH_160;
72 +               break;
73 +       }
74 +
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;
80 +
81 +       return 0;
82 +}
83 +
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,