lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1511313990-19334-1-git-send-email-li.jin@broadcom.com>
Date:   Tue, 21 Nov 2017 17:26:30 -0800
From:   Li Jin <li.jin@...adcom.com>
To:     Kalle Valo <kvalo@...eaurora.org>,
        Wright Feng <wright.feng@...ress.com>,
        Chi-Hsien Lin <chi-hsien.lin@...ress.com>,
        Hante Meuleman <hante.meuleman@...adcom.com>,
        Franky Lin <franky.lin@...adcom.com>,
        Arend van Spriel <arend.vanspriel@...adcom.com>
Cc:     linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        brcm80211-dev-list@...ress.com,
        brcm80211-dev-list.pdl@...adcom.com,
        linux-wireless@...r.kernel.org, Jason Uy <jason.uy@...adcom.com>,
        Li Jin <li.jin@...adcom.com>
Subject: [PATCH INTERNAL V2 1/1] brcmfmac: add console log support with configurable read size

From: Jason Uy <jason.uy@...adcom.com>

Add support for configurable read size so that older wifi
chips that have size restrictions can be supported.

Signed-off-by: Jason Uy <jason.uy@...adcom.com>
Reviewed-by: Ray Jui <ray.jui@...adcom.com>
Reviewed-by: Scott Branden <scott.branden@...adcom.com>
Signed-off-by: Li Jin <li.jin@...adcom.com>
---
 .../wireless/broadcom/brcm80211/brcmfmac/common.c  |  5 +++
 .../wireless/broadcom/brcm80211/brcmfmac/common.h  |  2 ++
 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c    | 39 ++++++++++++++++++++--
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 7a2b495..e1bfcaa 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -52,6 +52,10 @@ int brcmf_msg_level;
 module_param_named(debug, brcmf_msg_level, int, S_IRUSR | S_IWUSR);
 MODULE_PARM_DESC(debug, "Level of debug output");
 
+static unsigned int brcmf_log_size;
+module_param_named(logsize, brcmf_log_size, int, 0000);
+MODULE_PARM_DESC(logsize, "Size of log output to read each time");
+
 static int brcmf_p2p_enable;
 module_param_named(p2pon, brcmf_p2p_enable, int, 0);
 MODULE_PARM_DESC(p2pon, "Enable legacy p2p management functionality");
@@ -287,6 +291,7 @@ struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
 	settings->feature_disable = brcmf_feature_disable;
 	settings->fcmode = brcmf_fcmode;
 	settings->roamoff = !!brcmf_roamoff;
+	settings->log_size = brcmf_log_size;
 #ifdef DEBUG
 	settings->ignore_probe_fail = !!brcmf_ignore_probe_fail;
 #endif
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
index a62f8e7..f3eab04 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
@@ -51,6 +51,7 @@ extern struct brcmf_mp_global_t brcmf_mp_global;
  * @roamoff: Firmware roaming off?
  * @ignore_probe_fail: Ignore probe failure.
  * @country_codes: If available, pointer to struct for translating country codes
+ * @log_size: limit the read size when accessing log from wifi chip
  * @bus: Bus specific platform data. Only SDIO at the mmoment.
  */
 struct brcmf_mp_device {
@@ -60,6 +61,7 @@ struct brcmf_mp_device {
 	bool		roamoff;
 	bool		ignore_probe_fail;
 	struct brcmfmac_pd_cc *country_codes;
+	unsigned int	log_size;
 	union {
 		struct brcmfmac_sdio_pd sdio;
 	} bus;
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index 613caca..71ba680 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -2790,6 +2790,10 @@ static int brcmf_sdio_readconsole(struct brcmf_sdio *bus)
 	u8 line[CONSOLE_LINE_MAX], ch;
 	u32 n, idx, addr;
 	int rv;
+	unsigned int left_to_read;
+	unsigned int offset;
+	unsigned int cur_read_size;
+	unsigned int log_size = bus->sdiodev->settings->log_size;
 
 	/* Don't do anything until FWREADY updates console address */
 	if (bus->console_addr == 0)
@@ -2823,9 +2827,38 @@ static int brcmf_sdio_readconsole(struct brcmf_sdio *bus)
 
 	/* Read the console buffer */
 	addr = le32_to_cpu(c->log_le.buf);
-	rv = brcmf_sdiod_ramrw(bus->sdiodev, false, addr, c->buf, c->bufsize);
-	if (rv < 0)
-		return rv;
+
+	if (log_size > 0) {
+		/* limit the amount of data to read in case wifi chip has
+		 * restrictions
+		 */
+		left_to_read = c->bufsize;
+		offset = 0;
+		while (left_to_read) {
+			cur_read_size = (left_to_read > log_size) ?
+					 log_size :
+					 left_to_read;
+
+			rv = brcmf_sdiod_ramrw(bus->sdiodev,
+					       false,
+					       addr + offset,
+					       c->buf + offset,
+					       cur_read_size);
+			if (rv < 0)
+				return rv;
+
+			left_to_read -= cur_read_size;
+			offset += cur_read_size;
+		}
+	} else {
+		rv = brcmf_sdiod_ramrw(bus->sdiodev,
+				       false,
+				       addr,
+				       c->buf,
+				       c->bufsize);
+		if (rv < 0)
+			return rv;
+	}
 
 	while (c->last != idx) {
 		for (n = 0; n < CONSOLE_LINE_MAX - 2; n++) {
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ