Skip to contentSkip to conversation

brcmfmac: OBSS configuration and other cleanup

PATCH New Arend van Spriel 1 participant 5 messages Mar 20, 2014 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

cover brcmfmac: OBSS configuration and other cleanup

Hope this series is still in the _now_. Just a couple of small patches that are ready for the v3.15 stream.

The series applies to the master branch of the wireless-next repository.

Arend van Spriel (3):
brcmfmac: reinit watchdog completion after handling watchdog
brcmfmac: only show error message when brcmf_sdiod_regrw_helper()
fails
brcmfmac: fallback to mimo_bw_cap for older firmwares

Daniel Kim (1):
brcmfmac: Enable 40MHz bandwidth in 2GHz band and OBSS scanning
operations

 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c   |   41 ++++++++++----------
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    1 +
 .../net/wireless/brcm80211/brcmfmac/fwil_types.h   |   10 +++++
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |   36 +++++++++++++++++
 4 files changed, 68 insertions(+), 20 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/4 brcmfmac: Enable 40MHz bandwidth in 2GHz band and OBSS scanning operations

From: Daniel Kim <[email protected]>

This patch enables 40MHz bandwidth in 2GHz band after checking whether cfg80211 allows it or not, and enables OBSS scanning operations to to support 20/40 BSS coexistence.

---
 .../net/wireless/brcm80211/brcmfmac/fwil_types.h   |   10 ++++++++
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |   26 ++++++++++++++++++++
 2 files changed, 36 insertions(+)
drivers/net/wireless/brcm80211/brcmfmac/fwil_types.h +10 -0
index af17a5b..614e488 100644
@@ -48,6 +48,11 @@
 
 #define BRCMF_MAXRATES_IN_SET		16	/* max # of rates in rateset */
 
+/* OBSS Coex Auto/On/Off */
+#define BRCMF_OBSS_COEX_AUTO		(-1)
+#define BRCMF_OBSS_COEX_OFF		0
+#define BRCMF_OBSS_COEX_ON		1
+
 enum brcmf_fil_p2p_if_types {
 	BRCMF_FIL_P2P_IF_CLIENT,
 	BRCMF_FIL_P2P_IF_GO,
@@ -87,6 +92,11 @@ struct brcmf_fil_bss_enable_le {
 	__le32 enable;
 };
 
+struct brcmf_fil_bwcap_le {
+	__le32 band;
+	__le32 bw_cap;
+};
+
 /**
  * struct tdls_iovar - common structure for tdls iovars.
  *
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +26 -0
index 9f75afb..428b4cb 100644
@@ -191,6 +191,7 @@ static struct ieee80211_supported_band __wl_band_2ghz = {
 	.n_channels = ARRAY_SIZE(__wl_2ghz_channels),
 	.bitrates = wl_g_rates,
 	.n_bitrates = wl_g_rates_size,
+	.ht_cap = {IEEE80211_HT_CAP_SUP_WIDTH_20_40, true},
 };
 
 static struct ieee80211_supported_band __wl_band_5ghz_a = {
@@ -4929,6 +4930,19 @@ 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)
+{
+	struct brcmf_fil_bwcap_le band_bwcap;
+	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));
+
+	return err;
+}
+
 struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
 						  struct device *busdev)
 {
@@ -4986,6 +5000,18 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
 		goto cfg80211_p2p_attach_out;
 	}
 
+	/* If cfg80211 didn't disable 40MHz HT CAP in wiphy_register(),
+	 * setup 40MHz in 2GHz band and enable OBSS scanning.
+	 */
+	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_fil_iovar_int_set(ifp, "obss_coex",
+						      BRCMF_OBSS_COEX_AUTO);
+		}
+	}
+
 	err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1);
 	if (err) {
 		brcmf_dbg(INFO, "TDLS not enabled (%d)\n", err);
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 4/4 brcmfmac: fallback to mimo_bw_cap for older firmwares

In reply to Arend van Spriel

In order to support the driver behaviour introduced by:

commit d0575a5a703978c43e25128421158c78534ba100
Author: Daniel Kim <[email protected]>
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.

---
 .../net/wireless/brcm80211/brcmfmac/wl_cfg80211.c  |   26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +18 -8
index 428b4cb..e0e649a 100644
@@ -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);
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/4 brcmfmac: reinit watchdog completion after handling watchdog

In reply to Arend van Spriel

The watchdog thread waits on completion that is set from a timer. As the completion is count based this could mean that on a busy system the watchdog is handled multiple times with a very short interval. This is not the intended behaviour. After handling the watchdog it should wait for the next timer expiry. This is accomplished by reinitializing the completion.

---
 drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c |    1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +1 -0
index 859eddd..47a6f39 100644
@@ -3994,6 +3994,7 @@ brcmf_sdio_watchdog_thread(void *data)
 			brcmf_sdio_bus_watchdog(bus);
 			/* Count the tick for reference */
 			bus->sdcnt.tickcnt++;
+			reinit_completion(&bus->watchdog_wait);
 		} else
 			break;
 	}
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/4 brcmfmac: only show error message when brcmf_sdiod_regrw_helper() fails

In reply to Arend van Spriel

In the function brcmf_sdiod_request_data() an error message is logged, but the calling function retries it. This patch will only log an error message when retry limit is reached. The low-level error is still logged by a SDIO debug message.

---
 drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c |   41 +++++++++++-----------
 1 file changed, 21 insertions(+), 20 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +21 -20
index 6e8718b..a16e644 100644
@@ -269,26 +269,17 @@ static int brcmf_sdiod_request_data(struct brcmf_sdio_dev *sdiodev, u8 fn,
 		break;
 	}
 
-	if (ret) {
-		/*
-		 * SleepCSR register access can fail when
-		 * waking up the device so reduce this noise
-		 * in the logs.
-		 */
-		if (addr != SBSDIO_FUNC1_SLEEPCSR)
-			brcmf_err("failed to %s data F%d@0x%05x, err: %d\n",
-				  write ? "write" : "read", fn, addr, ret);
-		else
-			brcmf_dbg(SDIO, "failed to %s data F%d@0x%05x, err: %d\n",
-				  write ? "write" : "read", fn, addr, ret);
-	}
+	if (ret)
+		brcmf_dbg(SDIO, "failed to %s data F%d@0x%05x, err: %d\n",
+			  write ? "write" : "read", fn, addr, ret);
+
 	return ret;
 }
 
 static int brcmf_sdiod_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
 				   u8 regsz, void *data, bool write)
 {
-	u8 func_num;
+	u8 func;
 	s32 retry = 0;
 	int ret;
 
@@ -302,9 +293,9 @@ static int brcmf_sdiod_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
 	 * The rest: function 1 silicon backplane core registers
 	 */
 	if ((addr & ~REG_F0_REG_MASK) == 0)
-		func_num = SDIO_FUNC_0;
+		func = SDIO_FUNC_0;
 	else
-		func_num = SDIO_FUNC_1;
+		func = SDIO_FUNC_1;
 
 	do {
 		if (!write)
@@ -312,16 +303,26 @@ static int brcmf_sdiod_regrw_helper(struct brcmf_sdio_dev *sdiodev, u32 addr,
 		/* for retry wait for 1 ms till bus get settled down */
 		if (retry)
 			usleep_range(1000, 2000);
-		ret = brcmf_sdiod_request_data(sdiodev, func_num, addr, regsz,
+		ret = brcmf_sdiod_request_data(sdiodev, func, addr, regsz,
 					       data, write);
 	} while (ret != 0 && ret != -ENOMEDIUM &&
 		 retry++ < SDIOH_API_ACCESS_RETRY_LIMIT);
 
 	if (ret == -ENOMEDIUM)
 		brcmf_bus_change_state(sdiodev->bus_if, BRCMF_BUS_NOMEDIUM);
-	else if (ret != 0)
-		brcmf_err("failed with %d\n", ret);
-
+	else if (ret != 0) {
+		/*
+		 * SleepCSR register access can fail when
+		 * waking up the device so reduce this noise
+		 * in the logs.
+		 */
+		if (addr != SBSDIO_FUNC1_SLEEPCSR)
+			brcmf_err("failed to %s data F%d@0x%05x, err: %d\n",
+				  write ? "write" : "read", func, addr, ret);
+		else
+			brcmf_dbg(SDIO, "failed to %s data F%d@0x%05x, err: %d\n",
+				  write ? "write" : "read", func, addr, ret);
+	}
 	return ret;
 }
 
Signature · 1 line
1.7.9.5