brcmfmac: fallback to mimo_bw_cap for older firmwares
authorArend van Spriel <arend@broadcom.com>
Thu, 20 Mar 2014 09:18:03 +0000 (10:18 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 20 Mar 2014 15:55:41 +0000 (11:55 -0400)
In order to support the driver behaviour introduced by:

   commit d0575a5a703978c43e25128421158c78534ba100
   Author: Daniel Kim <dekim@broadcom.com>
   Date:   Wed Mar 12 18:12:14 2014 -0700

       brcmfmac: Enable 40MHz bandwidth in 2GHz band and OBSS scanning

in devices that do not support bwcap firmware command a fallback
is added.

Reviewed-by: Daniel (Deognyoun) Kim <dekim@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c

index 428b4cb94da1e13cfd95f9283cf4912e6e1ec1af..e0e649aab8dbc5bffca9de3f58ddbb97bd898732 100644 (file)
@@ -4930,16 +4930,27 @@ static void init_vif_event(struct brcmf_cfg80211_vif_event *event)
        mutex_init(&event->vif_event_lock);
 }
 
-static int brcmf_set_bwcap(struct brcmf_if *ifp, u32 band, u32 bw_cap)
+static int brcmf_enable_bw40_2g(struct brcmf_if *ifp)
 {
        struct brcmf_fil_bwcap_le band_bwcap;
+       u32 val;
        int err;
 
-       band_bwcap.band = cpu_to_le32(band);
-       band_bwcap.bw_cap = cpu_to_le32(bw_cap);
-       err = brcmf_fil_iovar_data_set(ifp, "bw_cap", &band_bwcap,
-                                      sizeof(band_bwcap));
+       /* verify support for bw_cap command */
+       val = WLC_BAND_5G;
+       err = brcmf_fil_iovar_int_get(ifp, "bw_cap", &val);
 
+       if (!err) {
+               /* only set 2G bandwidth using bw_cap command */
+               band_bwcap.band = cpu_to_le32(WLC_BAND_2G);
+               band_bwcap.bw_cap = cpu_to_le32(WLC_BW_40MHZ_BIT);
+               err = brcmf_fil_iovar_data_set(ifp, "bw_cap", &band_bwcap,
+                                              sizeof(band_bwcap));
+       } else {
+               brcmf_dbg(INFO, "fallback to mimo_bw_cap\n");
+               val = WLC_N_BW_40ALL;
+               err = brcmf_fil_iovar_int_set(ifp, "mimo_bw_cap", val);
+       }
        return err;
 }
 
@@ -5005,11 +5016,10 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
         */
        if (wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.cap &
            IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
-               err = brcmf_set_bwcap(ifp, WLC_BAND_2G, WLC_BW_CAP_40MHZ);
-               if (!err) {
+               err = brcmf_enable_bw40_2g(ifp);
+               if (!err)
                        err = brcmf_fil_iovar_int_set(ifp, "obss_coex",
                                                      BRCMF_OBSS_COEX_AUTO);
-               }
        }
 
        err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1);