rpcd: iwinfo plugin fixes
[openwrt.git] / package / kernel / mac80211 / patches / 351-0010-brcmfmac-fix-setting-AP-channel-with-new-firmwares.patch
1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Fri, 27 May 2016 21:07:19 +0200
3 Subject: [PATCH] brcmfmac: fix setting AP channel with new firmwares
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 Firmware for new chipsets is based on a new major version of code
9 internally maintained at Broadcom. E.g. brcmfmac4366b-pcie.bin (used for
10 BCM4366B1) is based on 10.10.69.3309 while brcmfmac43602-pcie.ap.bin was
11 based on 7.35.177.56.
12
13 Currently setting AP 5 GHz channel doesn't work reliably with BCM4366B1.
14 When setting e.g. 36 control channel with VHT80 (center channel 42)
15 firmware may randomly pick one of:
16 1) 52 control channel with 58 as center one
17 2) 100 control channel with 106 as center one
18 3) 116 control channel with 122 as center one
19 4) 149 control channel with 155 as center one
20
21 It seems new firmwares require setting AP mode (BRCMF_C_SET_AP) before
22 specifying a channel. Changing an order of firmware calls fixes the
23 problem. This requirement resulted in two separated "chanspec" calls,
24 one in AP code path and one in P2P path.
25
26 This fix was verified with BCM4366B1 and tested for regressions on
27 BCM43602.
28
29 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
30 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
31 ---
32
33 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
34 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
35 @@ -4398,7 +4398,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
36         struct brcmf_join_params join_params;
37         enum nl80211_iftype dev_role;
38         struct brcmf_fil_bss_enable_le bss_enable;
39 -       u16 chanspec;
40 +       u16 chanspec = chandef_to_chanspec(&cfg->d11inf, &settings->chandef);
41         bool mbss;
42         int is_11d;
43  
44 @@ -4474,16 +4474,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
45  
46         brcmf_config_ap_mgmt_ie(ifp->vif, &settings->beacon);
47  
48 +       /* Parameters shared by all radio interfaces */
49         if (!mbss) {
50 -               chanspec = chandef_to_chanspec(&cfg->d11inf,
51 -                                              &settings->chandef);
52 -               err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec);
53 -               if (err < 0) {
54 -                       brcmf_err("Set Channel failed: chspec=%d, %d\n",
55 -                                 chanspec, err);
56 -                       goto exit;
57 -               }
58 -
59                 if (is_11d != ifp->vif->is_11d) {
60                         err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
61                                                     is_11d);
62 @@ -4531,6 +4523,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
63                 err = -EINVAL;
64                 goto exit;
65         }
66 +
67 +       /* Interface specific setup */
68         if (dev_role == NL80211_IFTYPE_AP) {
69                 if ((brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS)) && (!mbss))
70                         brcmf_fil_iovar_int_set(ifp, "mbss", 1);
71 @@ -4540,6 +4534,17 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
72                         brcmf_err("setting AP mode failed %d\n", err);
73                         goto exit;
74                 }
75 +               if (!mbss) {
76 +                       /* Firmware 10.x requires setting channel after enabling
77 +                        * AP and before bringing interface up.
78 +                        */
79 +                       err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec);
80 +                       if (err < 0) {
81 +                               brcmf_err("Set Channel failed: chspec=%d, %d\n",
82 +                                         chanspec, err);
83 +                               goto exit;
84 +                       }
85 +               }
86                 err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
87                 if (err < 0) {
88                         brcmf_err("BRCMF_C_UP error (%d)\n", err);
89 @@ -4561,7 +4566,13 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
90                         goto exit;
91                 }
92                 brcmf_dbg(TRACE, "AP mode configuration complete\n");
93 -       } else {
94 +       } else if (dev_role == NL80211_IFTYPE_P2P_GO) {
95 +               err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec);
96 +               if (err < 0) {
97 +                       brcmf_err("Set Channel failed: chspec=%d, %d\n",
98 +                                 chanspec, err);
99 +                       goto exit;
100 +               }
101                 err = brcmf_fil_bsscfg_data_set(ifp, "ssid", &ssid_le,
102                                                 sizeof(ssid_le));
103                 if (err < 0) {
104 @@ -4578,7 +4589,10 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
105                 }
106  
107                 brcmf_dbg(TRACE, "GO mode configuration complete\n");
108 +       } else {
109 +               WARN_ON(1);
110         }
111 +
112         set_bit(BRCMF_VIF_STATUS_AP_CREATED, &ifp->vif->sme_state);
113         brcmf_net_setcarrier(ifp, true);
114