aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2018-06-17 22:46:35 +0200
committerRafał Miłecki <rafal@milecki.pl>2018-06-17 22:46:35 +0200
commit3c8bb92655c68a07abf5358ef23eb98422ed8d6d (patch)
tree43961eb68b7f2af4ddc99402dab68ea32a0290c3
parent0da9303e5b444e2c98c24719c48c09f4c976c5a7 (diff)
downloadupstream-3c8bb92655c68a07abf5358ef23eb98422ed8d6d.tar.gz
upstream-3c8bb92655c68a07abf5358ef23eb98422ed8d6d.tar.bz2
upstream-3c8bb92655c68a07abf5358ef23eb98422ed8d6d.zip
mac80211: backport brcmfmac data structure rework
It backports brcmfmac commits from kernel 4.17. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
-rw-r--r--package/kernel/mac80211/patches/326-v4.17-0001-brcmfmac-reject-too-long-PSK.patch27
-rw-r--r--package/kernel/mac80211/patches/327-v4.17-0001-brcmfmac-do-not-convert-linux-error-to-firmware-erro.patch31
-rw-r--r--package/kernel/mac80211/patches/327-v4.17-0002-brcmfmac-use-brcmf_chip_name-to-store-name-in-revinf.patch203
-rw-r--r--package/kernel/mac80211/patches/327-v4.17-0003-brcmfmac-use-brcmf_chip_name-for-consistency.patch69
-rw-r--r--package/kernel/mac80211/patches/327-v4.17-0004-brcmfmac-allocate-struct-brcmf_pub-instance-using-wi.patch452
-rw-r--r--package/kernel/mac80211/patches/327-v4.17-0005-brcmfmac-use-wiphy-debugfs-dir-entry.patch349
-rw-r--r--package/kernel/mac80211/patches/327-v4.17-0006-brcmfmac-derive-firmware-filenames-from-basename-map.patch286
-rw-r--r--package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch14
-rw-r--r--package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch2
-rw-r--r--package/kernel/mac80211/patches/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch2
10 files changed, 1426 insertions, 9 deletions
diff --git a/package/kernel/mac80211/patches/326-v4.17-0001-brcmfmac-reject-too-long-PSK.patch b/package/kernel/mac80211/patches/326-v4.17-0001-brcmfmac-reject-too-long-PSK.patch
new file mode 100644
index 0000000000..b83f2fce8b
--- /dev/null
+++ b/package/kernel/mac80211/patches/326-v4.17-0001-brcmfmac-reject-too-long-PSK.patch
@@ -0,0 +1,27 @@
+From 64d1519edc959f5b8f86a66a51c40971c215e4ec Mon Sep 17 00:00:00 2001
+From: Johannes Berg <johannes.berg@intel.com>
+Date: Mon, 19 Feb 2018 13:30:45 +0100
+Subject: [PATCH] brcmfmac: reject too long PSK
+
+nl80211 already allows specifying 48 bytes, but brcmfmac
+only supports 32. Reject keys that are too long.
+
+Signed-off-by: Johannes Berg <johannes.berg@intel.com>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -5125,6 +5125,9 @@ static int brcmf_cfg80211_set_pmk(struct
+ if (WARN_ON(ifp->vif->profile.use_fwsup != BRCMF_PROFILE_FWSUP_1X))
+ return -EINVAL;
+
++ if (conf->pmk_len > BRCMF_WSEC_MAX_PSK_LEN)
++ return -ERANGE;
++
+ return brcmf_set_pmk(ifp, conf->pmk, conf->pmk_len);
+ }
+
diff --git a/package/kernel/mac80211/patches/327-v4.17-0001-brcmfmac-do-not-convert-linux-error-to-firmware-erro.patch b/package/kernel/mac80211/patches/327-v4.17-0001-brcmfmac-do-not-convert-linux-error-to-firmware-erro.patch
new file mode 100644
index 0000000000..2e9ec8b963
--- /dev/null
+++ b/package/kernel/mac80211/patches/327-v4.17-0001-brcmfmac-do-not-convert-linux-error-to-firmware-erro.patch
@@ -0,0 +1,31 @@
+From 1170f6d1be6a39e1a115a2c0f50923eb4ce2a7ec Mon Sep 17 00:00:00 2001
+From: Arend Van Spriel <arend.vanspriel@broadcom.com>
+Date: Thu, 22 Mar 2018 21:28:20 +0100
+Subject: [PATCH] brcmfmac: do not convert linux error to firmware error string
+
+In case of a linux error brcmf_fil_cmd_data() blurts an error message
+in which the error code is translated to an error string. However, it
+maps it to a firmware error string which should not happen. Simply
+print only the numeric error code and be done with it.
+
+Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
+Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
+Reviewed-by: Franky Lin <franky.lin@broadcom.com>
+Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
+@@ -124,8 +124,7 @@ brcmf_fil_cmd_data(struct brcmf_if *ifp,
+ data, len, &fwerr);
+
+ if (err) {
+- brcmf_dbg(FIL, "Failed: %s (%d)\n",
+- brcmf_fil_get_errstr((u32)(-err)), err);
++ brcmf_dbg(FIL, "Failed: error=%d\n", err);
+ } else if (fwerr < 0) {
+ brcmf_dbg(FIL, "Firmware error: %s (%d)\n",
+ brcmf_fil_get_errstr((u32)(-fwerr)), fwerr);
diff --git a/package/kernel/mac80211/patches/327-v4.17-0002-brcmfmac-use-brcmf_chip_name-to-store-name-in-revinf.patch b/package/kernel/mac80211/patches/327-v4.17-0002-brcmfmac-use-brcmf_chip_name-to-store-name-in-revinf.patch
new file mode 100644
index 0000000000..790811957a
--- /dev/null
+++ b/package/kernel/mac80211/patches/327-v4.17-0002-brcmfmac-use-brcmf_chip_name-to-store-name-in-revinf.patch
@@ -0,0 +1,203 @@
+From 756a2b390874d274f2f615921318ef0856ff9313 Mon Sep 17 00:00:00 2001
+From: Arend Van Spriel <arend.vanspriel@broadcom.com>
+Date: Thu, 22 Mar 2018 21:28:21 +0100
+Subject: [PATCH] brcmfmac: use brcmf_chip_name() to store name in revinfo
+
+The chip id can either be four or five digits. For the chip name either
+the hexadecimal value needs to be taken (four digits) or the decimal
+value (five digits). The function brcmf_chip_name() does this conversion
+so use it to store the name in driver revision info.
+
+Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
+Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
+Reviewed-by: Franky Lin <franky.lin@broadcom.com>
+Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/chip.c | 9 +++++----
+ .../wireless/broadcom/brcm80211/brcmfmac/chip.h | 3 ++-
+ .../wireless/broadcom/brcm80211/brcmfmac/common.c | 23 ++++++++++++++++------
+ .../wireless/broadcom/brcm80211/brcmfmac/core.c | 10 +---------
+ .../wireless/broadcom/brcm80211/brcmfmac/core.h | 3 +--
+ 5 files changed, 26 insertions(+), 22 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+@@ -464,12 +464,12 @@ static void brcmf_chip_ai_resetcore(stru
+ ci->ops->read32(ci->ctx, core->wrapbase + BCMA_IOCTL);
+ }
+
+-static char *brcmf_chip_name(uint chipid, char *buf, uint len)
++char *brcmf_chip_name(u32 id, u32 rev, char *buf, uint len)
+ {
+ const char *fmt;
+
+- fmt = ((chipid > 0xa000) || (chipid < 0x4000)) ? "%d" : "%x";
+- snprintf(buf, len, fmt, chipid);
++ fmt = ((id > 0xa000) || (id < 0x4000)) ? "BCM%d/%u" : "BCM%x/%u";
++ snprintf(buf, len, fmt, id, rev);
+ return buf;
+ }
+
+@@ -924,7 +924,8 @@ static int brcmf_chip_recognition(struct
+ ci->pub.chiprev = (regdata & CID_REV_MASK) >> CID_REV_SHIFT;
+ socitype = (regdata & CID_TYPE_MASK) >> CID_TYPE_SHIFT;
+
+- brcmf_chip_name(ci->pub.chip, ci->pub.name, sizeof(ci->pub.name));
++ brcmf_chip_name(ci->pub.chip, ci->pub.chiprev,
++ ci->pub.name, sizeof(ci->pub.name));
+ brcmf_dbg(INFO, "found %s chip: BCM%s, rev=%d\n",
+ socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name,
+ ci->pub.chiprev);
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.h
+@@ -45,7 +45,7 @@ struct brcmf_chip {
+ u32 rambase;
+ u32 ramsize;
+ u32 srsize;
+- char name[8];
++ char name[12];
+ };
+
+ /**
+@@ -93,5 +93,6 @@ void brcmf_chip_resetcore(struct brcmf_c
+ void brcmf_chip_set_passive(struct brcmf_chip *ci);
+ bool brcmf_chip_set_active(struct brcmf_chip *ci, u32 rstvec);
+ bool brcmf_chip_sr_capable(struct brcmf_chip *pub);
++char *brcmf_chip_name(u32 chipid, u32 chiprev, char *buf, uint len);
+
+ #endif /* BRCMF_AXIDMP_H */
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -30,6 +30,7 @@
+ #include "common.h"
+ #include "of.h"
+ #include "firmware.h"
++#include "chip.h"
+
+ MODULE_AUTHOR("Broadcom Corporation");
+ MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
+@@ -131,14 +132,13 @@ static int brcmf_c_download(struct brcmf
+ static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
+ {
+ struct brcmf_bus *bus = ifp->drvr->bus_if;
+- struct brcmf_rev_info *ri = &ifp->drvr->revinfo;
+ u8 fw_name[BRCMF_FW_NAME_LEN];
+ u8 *ptr;
+ size_t len;
+ s32 err;
+
+ memset(fw_name, 0, BRCMF_FW_NAME_LEN);
+- err = brcmf_bus_get_fwname(bus, ri->chipnum, ri->chiprev, fw_name);
++ err = brcmf_bus_get_fwname(bus, bus->chip, bus->chiprev, fw_name);
+ if (err) {
+ brcmf_err("get firmware name failed (%d)\n", err);
+ goto done;
+@@ -238,6 +238,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ {
+ s8 eventmask[BRCMF_EVENTING_MASK_LEN];
+ u8 buf[BRCMF_DCMD_SMLEN];
++ struct brcmf_bus *bus;
+ struct brcmf_rev_info_le revinfo;
+ struct brcmf_rev_info *ri;
+ char *clmver;
+@@ -253,16 +254,18 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ }
+ memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
+
++ bus = ifp->drvr->bus_if;
++ ri = &ifp->drvr->revinfo;
++
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_REVINFO,
+ &revinfo, sizeof(revinfo));
+- ri = &ifp->drvr->revinfo;
+ if (err < 0) {
+ brcmf_err("retrieving revision info failed, %d\n", err);
++ strlcpy(ri->chipname, "UNKNOWN", sizeof(ri->chipname));
+ } else {
+ ri->vendorid = le32_to_cpu(revinfo.vendorid);
+ ri->deviceid = le32_to_cpu(revinfo.deviceid);
+ ri->radiorev = le32_to_cpu(revinfo.radiorev);
+- ri->chiprev = le32_to_cpu(revinfo.chiprev);
+ ri->corerev = le32_to_cpu(revinfo.corerev);
+ ri->boardid = le32_to_cpu(revinfo.boardid);
+ ri->boardvendor = le32_to_cpu(revinfo.boardvendor);
+@@ -270,15 +273,23 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ ri->driverrev = le32_to_cpu(revinfo.driverrev);
+ ri->ucoderev = le32_to_cpu(revinfo.ucoderev);
+ ri->bus = le32_to_cpu(revinfo.bus);
+- ri->chipnum = le32_to_cpu(revinfo.chipnum);
+ ri->phytype = le32_to_cpu(revinfo.phytype);
+ ri->phyrev = le32_to_cpu(revinfo.phyrev);
+ ri->anarev = le32_to_cpu(revinfo.anarev);
+ ri->chippkg = le32_to_cpu(revinfo.chippkg);
+ ri->nvramrev = le32_to_cpu(revinfo.nvramrev);
++
++ if (!bus->chip) {
++ bus->chip = le32_to_cpu(revinfo.chipnum);
++ bus->chiprev = le32_to_cpu(revinfo.chiprev);
++ }
+ }
+ ri->result = err;
+
++ if (bus->chip)
++ brcmf_chip_name(bus->chip, bus->chiprev,
++ ri->chipname, sizeof(ri->chipname));
++
+ /* Do any CLM downloading */
+ err = brcmf_c_process_clm_blob(ifp);
+ if (err < 0) {
+@@ -299,7 +310,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ strsep(&ptr, "\n");
+
+ /* Print fw version info */
+- brcmf_info("Firmware version = %s\n", buf);
++ brcmf_info("Firmware: %s %s\n", ri->chipname, buf);
+
+ /* locate firmware version number for ethtool */
+ ptr = strrchr(buf, ' ') + 1;
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -1002,8 +1002,7 @@ static int brcmf_revinfo_read(struct seq
+ seq_printf(s, "vendorid: 0x%04x\n", ri->vendorid);
+ seq_printf(s, "deviceid: 0x%04x\n", ri->deviceid);
+ seq_printf(s, "radiorev: %s\n", brcmu_dotrev_str(ri->radiorev, drev));
+- seq_printf(s, "chipnum: %u (%x)\n", ri->chipnum, ri->chipnum);
+- seq_printf(s, "chiprev: %u\n", ri->chiprev);
++ seq_printf(s, "chip: %s\n", ri->chipname);
+ seq_printf(s, "chippkg: %u\n", ri->chippkg);
+ seq_printf(s, "corerev: %u\n", ri->corerev);
+ seq_printf(s, "boardid: 0x%04x\n", ri->boardid);
+@@ -1053,13 +1052,6 @@ static int brcmf_bus_started(struct brcm
+
+ brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
+
+- /* assure we have chipid before feature attach */
+- if (!bus_if->chip) {
+- bus_if->chip = drvr->revinfo.chipnum;
+- bus_if->chiprev = drvr->revinfo.chiprev;
+- brcmf_dbg(INFO, "firmware revinfo: chip %x (%d) rev %d\n",
+- bus_if->chip, bus_if->chip, bus_if->chiprev);
+- }
+ brcmf_feat_attach(drvr);
+
+ ret = brcmf_proto_init_done(drvr);
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+@@ -87,7 +87,6 @@ struct brcmf_rev_info {
+ u32 vendorid;
+ u32 deviceid;
+ u32 radiorev;
+- u32 chiprev;
+ u32 corerev;
+ u32 boardid;
+ u32 boardvendor;
+@@ -95,7 +94,7 @@ struct brcmf_rev_info {
+ u32 driverrev;
+ u32 ucoderev;
+ u32 bus;
+- u32 chipnum;
++ char chipname[12];
+ u32 phytype;
+ u32 phyrev;
+ u32 anarev;
diff --git a/package/kernel/mac80211/patches/327-v4.17-0003-brcmfmac-use-brcmf_chip_name-for-consistency.patch b/package/kernel/mac80211/patches/327-v4.17-0003-brcmfmac-use-brcmf_chip_name-for-consistency.patch
new file mode 100644
index 0000000000..e3d06f32cc
--- /dev/null
+++ b/package/kernel/mac80211/patches/327-v4.17-0003-brcmfmac-use-brcmf_chip_name-for-consistency.patch
@@ -0,0 +1,69 @@
+From c88cfa075de356ddf40c668896b2126340f19ba4 Mon Sep 17 00:00:00 2001
+From: Arend Van Spriel <arend.vanspriel@broadcom.com>
+Date: Thu, 22 Mar 2018 21:28:22 +0100
+Subject: [PATCH] brcmfmac: use brcmf_chip_name() for consistency
+
+When logging the chip id/revision information make use of
+brcmf_chip_name() so it is always the same.
+
+Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
+Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
+Reviewed-by: Franky Lin <franky.lin@broadcom.com>
+Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c | 5 ++---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 7 +++++--
+ 2 files changed, 7 insertions(+), 5 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/chip.c
+@@ -926,9 +926,8 @@ static int brcmf_chip_recognition(struct
+
+ brcmf_chip_name(ci->pub.chip, ci->pub.chiprev,
+ ci->pub.name, sizeof(ci->pub.name));
+- brcmf_dbg(INFO, "found %s chip: BCM%s, rev=%d\n",
+- socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name,
+- ci->pub.chiprev);
++ brcmf_dbg(INFO, "found %s chip: %s\n",
++ socitype == SOCI_SB ? "SB" : "AXI", ci->pub.name);
+
+ if (socitype == SOCI_SB) {
+ if (ci->pub.chip != BRCM_CC_4329_CHIP_ID) {
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+@@ -25,6 +25,7 @@
+ #include "firmware.h"
+ #include "core.h"
+ #include "common.h"
++#include "chip.h"
+
+ #define BRCMF_FW_MAX_NVRAM_SIZE 64000
+ #define BRCMF_FW_NVRAM_DEVPATH_LEN 19 /* devpath0=pcie/1/4/ */
+@@ -567,6 +568,7 @@ int brcmf_fw_map_chip_to_name(u32 chip,
+ u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
+ char nvram_name[BRCMF_FW_NAME_LEN])
+ {
++ char chipname[12];
+ u32 i;
+ char end;
+
+@@ -581,6 +583,8 @@ int brcmf_fw_map_chip_to_name(u32 chip,
+ return -ENODEV;
+ }
+
++ brcmf_chip_name(chip, chiprev, chipname, sizeof(chipname));
++
+ /* check if firmware path is provided by module parameter */
+ if (brcmf_mp_global.firmware_path[0] != '\0') {
+ strlcpy(fw_name, brcmf_mp_global.firmware_path,
+@@ -601,8 +605,7 @@ int brcmf_fw_map_chip_to_name(u32 chip,
+ if ((nvram_name) && (mapping_table[i].nvram))
+ strlcat(nvram_name, mapping_table[i].nvram, BRCMF_FW_NAME_LEN);
+
+- brcmf_info("using %s for chip %#08x(%d) rev %#08x\n",
+- fw_name, chip, chip, chiprev);
++ brcmf_info("using %s for chip %s\n", fw_name, chipname);
+
+ return 0;
+ }
diff --git a/package/kernel/mac80211/patches/327-v4.17-0004-brcmfmac-allocate-struct-brcmf_pub-instance-using-wi.patch b/package/kernel/mac80211/patches/327-v4.17-0004-brcmfmac-allocate-struct-brcmf_pub-instance-using-wi.patch
new file mode 100644
index 0000000000..42adff61b9
--- /dev/null
+++ b/package/kernel/mac80211/patches/327-v4.17-0004-brcmfmac-allocate-struct-brcmf_pub-instance-using-wi.patch
@@ -0,0 +1,452 @@
+From 856d5a011c86b59f6564be4508912fb1d866adfc Mon Sep 17 00:00:00 2001
+From: Arend Van Spriel <arend.vanspriel@broadcom.com>
+Date: Thu, 22 Mar 2018 21:28:23 +0100
+Subject: [PATCH] brcmfmac: allocate struct brcmf_pub instance using
+ wiphy_new()
+
+Rework the driver so the wiphy instance holds the main driver information
+in its private buffer. Previously it held struct brcmf_cfg80211_info
+instance so a bit of reorg was needed. This was done so that the wiphy
+name or its parent device can be shown in debug output.
+
+Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
+Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
+Reviewed-by: Franky Lin <franky.lin@broadcom.com>
+Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/btcoex.c | 2 +-
+ .../broadcom/brcm80211/brcmfmac/cfg80211.c | 86 ++++++++++------------
+ .../broadcom/brcm80211/brcmfmac/cfg80211.h | 17 +++--
+ .../wireless/broadcom/brcm80211/brcmfmac/common.c | 2 +
+ .../wireless/broadcom/brcm80211/brcmfmac/core.c | 27 +++++--
+ .../wireless/broadcom/brcm80211/brcmfmac/core.h | 1 +
+ .../net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | 2 +-
+ 7 files changed, 76 insertions(+), 61 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/btcoex.c
+@@ -462,7 +462,7 @@ static void brcmf_btcoex_dhcp_end(struct
+ int brcmf_btcoex_set_mode(struct brcmf_cfg80211_vif *vif,
+ enum brcmf_btcoex_mode mode, u16 duration)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(vif->wdev.wiphy);
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy);
+ struct brcmf_btcoex_info *btci = cfg->btcoex;
+ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -753,7 +753,7 @@ s32 brcmf_notify_escan_complete(struct b
+ static int brcmf_cfg80211_del_ap_iface(struct wiphy *wiphy,
+ struct wireless_dev *wdev)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct net_device *ndev = wdev->netdev;
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ int ret;
+@@ -786,7 +786,7 @@ err_unarm:
+ static
+ int brcmf_cfg80211_del_iface(struct wiphy *wiphy, struct wireless_dev *wdev)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct net_device *ndev = wdev->netdev;
+
+ if (ndev && ndev == cfg_to_ndev(cfg))
+@@ -831,7 +831,7 @@ brcmf_cfg80211_change_iface(struct wiphy
+ enum nl80211_iftype type,
+ struct vif_params *params)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_cfg80211_vif *vif = ifp->vif;
+ s32 infra = 0;
+@@ -2127,17 +2127,15 @@ static s32
+ brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
+ s32 *dbm)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+- struct net_device *ndev = cfg_to_ndev(cfg);
+- struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_cfg80211_vif *vif = wdev_to_vif(wdev);
+ s32 qdbm = 0;
+ s32 err;
+
+ brcmf_dbg(TRACE, "Enter\n");
+- if (!check_vif_up(ifp->vif))
++ if (!check_vif_up(vif))
+ return -EIO;
+
+- err = brcmf_fil_iovar_int_get(ifp, "qtxpower", &qdbm);
++ err = brcmf_fil_iovar_int_get(vif->ifp, "qtxpower", &qdbm);
+ if (err) {
+ brcmf_err("error (%d)\n", err);
+ goto done;
+@@ -3359,7 +3357,7 @@ brcmf_cfg80211_sched_scan_start(struct w
+ struct cfg80211_sched_scan_request *req)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+
+ brcmf_dbg(SCAN, "Enter: n_match_sets=%d n_ssids=%d\n",
+ req->n_match_sets, req->n_ssids);
+@@ -5191,6 +5189,12 @@ static struct cfg80211_ops brcmf_cfg8021
+ .del_pmk = brcmf_cfg80211_del_pmk,
+ };
+
++struct cfg80211_ops *brcmf_cfg80211_get_ops(void)
++{
++ return kmemdup(&brcmf_cfg80211_ops, sizeof(brcmf_cfg80211_ops),
++ GFP_KERNEL);
++}
++
+ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
+ enum nl80211_iftype type)
+ {
+@@ -5898,7 +5902,7 @@ static void brcmf_update_bw40_channel_fl
+ static int brcmf_construct_chaninfo(struct brcmf_cfg80211_info *cfg,
+ u32 bw_cap[])
+ {
+- struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg));
++ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
+ struct ieee80211_supported_band *band;
+ struct ieee80211_channel *channel;
+ struct wiphy *wiphy;
+@@ -6013,7 +6017,7 @@ fail_pbuf:
+
+ static int brcmf_enable_bw40_2g(struct brcmf_cfg80211_info *cfg)
+ {
+- struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg));
++ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
+ struct ieee80211_supported_band *band;
+ struct brcmf_fil_bwcap_le band_bwcap;
+ struct brcmf_chanspec_list *list;
+@@ -6198,10 +6202,10 @@ static void brcmf_update_vht_cap(struct
+ }
+ }
+
+-static int brcmf_setup_wiphybands(struct wiphy *wiphy)
++static int brcmf_setup_wiphybands(struct brcmf_cfg80211_info *cfg)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
+- struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg));
++ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
++ struct wiphy *wiphy;
+ u32 nmode = 0;
+ u32 vhtmode = 0;
+ u32 bw_cap[2] = { WLC_BW_20MHZ_BIT, WLC_BW_20MHZ_BIT };
+@@ -6795,8 +6799,8 @@ static s32 brcmf_translate_country_code(
+ static void brcmf_cfg80211_reg_notifier(struct wiphy *wiphy,
+ struct regulatory_request *req)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
+- struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg));
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
+ struct brcmf_fil_country_le ccreq;
+ s32 err;
+ int i;
+@@ -6831,7 +6835,7 @@ static void brcmf_cfg80211_reg_notifier(
+ brcmf_err("Firmware rejected country setting\n");
+ return;
+ }
+- brcmf_setup_wiphybands(wiphy);
++ brcmf_setup_wiphybands(cfg);
+ }
+
+ static void brcmf_free_wiphy(struct wiphy *wiphy)
+@@ -6858,17 +6862,15 @@ static void brcmf_free_wiphy(struct wiph
+ if (wiphy->wowlan != &brcmf_wowlan_support)
+ kfree(wiphy->wowlan);
+ #endif
+- wiphy_free(wiphy);
+ }
+
+ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
+- struct device *busdev,
++ struct cfg80211_ops *ops,
+ bool p2pdev_forced)
+ {
++ struct wiphy *wiphy = drvr->wiphy;
+ struct net_device *ndev = brcmf_get_ifp(drvr, 0)->ndev;
+ struct brcmf_cfg80211_info *cfg;
+- struct wiphy *wiphy;
+- struct cfg80211_ops *ops;
+ struct brcmf_cfg80211_vif *vif;
+ struct brcmf_if *ifp;
+ s32 err = 0;
+@@ -6880,26 +6882,13 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ return NULL;
+ }
+
+- ops = kmemdup(&brcmf_cfg80211_ops, sizeof(*ops), GFP_KERNEL);
+- if (!ops)
+- return NULL;
+-
+- ifp = netdev_priv(ndev);
+-#ifdef CONFIG_PM
+- if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_WOWL_GTK))
+- ops->set_rekey_data = brcmf_cfg80211_set_rekey_data;
+-#endif
+- wiphy = wiphy_new(ops, sizeof(struct brcmf_cfg80211_info));
+- if (!wiphy) {
++ cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
++ if (!cfg) {
+ brcmf_err("Could not allocate wiphy device\n");
+- goto ops_out;
++ return NULL;
+ }
+- memcpy(wiphy->perm_addr, drvr->mac, ETH_ALEN);
+- set_wiphy_dev(wiphy, busdev);
+
+- cfg = wiphy_priv(wiphy);
+ cfg->wiphy = wiphy;
+- cfg->ops = ops;
+ cfg->pub = drvr;
+ init_vif_event(&cfg->vif_event);
+ INIT_LIST_HEAD(&cfg->vif_list);
+@@ -6908,6 +6897,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ if (IS_ERR(vif))
+ goto wiphy_out;
+
++ ifp = netdev_priv(ndev);
+ vif->ifp = ifp;
+ vif->wdev.netdev = ndev;
+ ndev->ieee80211_ptr = &vif->wdev;
+@@ -6934,6 +6924,11 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ if (err < 0)
+ goto priv_out;
+
++ /* regulatory notifer below needs access to cfg so
++ * assign it now.
++ */
++ drvr->config = cfg;
++
+ brcmf_dbg(INFO, "Registering custom regulatory\n");
+ wiphy->reg_notifier = brcmf_cfg80211_reg_notifier;
+ wiphy->regulatory_flags |= REGULATORY_CUSTOM_REG;
+@@ -6947,13 +6942,17 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ cap = &wiphy->bands[NL80211_BAND_2GHZ]->ht_cap.cap;
+ *cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
+ }
++#ifdef CONFIG_PM
++ if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_WOWL_GTK))
++ ops->set_rekey_data = brcmf_cfg80211_set_rekey_data;
++#endif
+ err = wiphy_register(wiphy);
+ if (err < 0) {
+ brcmf_err("Could not register wiphy device (%d)\n", err);
+ goto priv_out;
+ }
+
+- err = brcmf_setup_wiphybands(wiphy);
++ err = brcmf_setup_wiphybands(cfg);
+ if (err) {
+ brcmf_err("Setting wiphy bands failed (%d)\n", err);
+ goto wiphy_unreg_out;
+@@ -6970,12 +6969,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ else
+ *cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
+ }
+- /* p2p might require that "if-events" get processed by fweh. So
+- * activate the already registered event handlers now and activate
+- * the rest when initialization has completed. drvr->config needs to
+- * be assigned before activating events.
+- */
+- drvr->config = cfg;
++
+ err = brcmf_fweh_activate_events(ifp);
+ if (err) {
+ brcmf_err("FWEH activation failed (%d)\n", err);
+@@ -7043,8 +7037,7 @@ priv_out:
+ ifp->vif = NULL;
+ wiphy_out:
+ brcmf_free_wiphy(wiphy);
+-ops_out:
+- kfree(ops);
++ kfree(cfg);
+ return NULL;
+ }
+
+@@ -7059,4 +7052,5 @@ void brcmf_cfg80211_detach(struct brcmf_
+ kfree(cfg->ops);
+ wl_deinit_priv(cfg);
+ brcmf_free_wiphy(cfg->wiphy);
++ kfree(cfg);
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
+@@ -355,20 +355,24 @@ static inline struct wiphy *cfg_to_wiphy
+
+ static inline struct brcmf_cfg80211_info *wiphy_to_cfg(struct wiphy *w)
+ {
+- return (struct brcmf_cfg80211_info *)(wiphy_priv(w));
++ struct brcmf_pub *drvr = wiphy_priv(w);
++ return drvr->config;
+ }
+
+ static inline struct brcmf_cfg80211_info *wdev_to_cfg(struct wireless_dev *wd)
+ {
+- return (struct brcmf_cfg80211_info *)(wdev_priv(wd));
++ return wiphy_to_cfg(wd->wiphy);
++}
++
++static inline struct brcmf_cfg80211_vif *wdev_to_vif(struct wireless_dev *wdev)
++{
++ return container_of(wdev, struct brcmf_cfg80211_vif, wdev);
+ }
+
+ static inline
+ struct net_device *cfg_to_ndev(struct brcmf_cfg80211_info *cfg)
+ {
+- struct brcmf_cfg80211_vif *vif;
+- vif = list_first_entry(&cfg->vif_list, struct brcmf_cfg80211_vif, list);
+- return vif->wdev.netdev;
++ return brcmf_get_ifp(cfg->pub, 0)->ndev;
+ }
+
+ static inline struct brcmf_cfg80211_info *ndev_to_cfg(struct net_device *ndev)
+@@ -395,11 +399,12 @@ brcmf_cfg80211_connect_info *cfg_to_conn
+ }
+
+ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
+- struct device *busdev,
++ struct cfg80211_ops *ops,
+ bool p2pdev_forced);
+ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
+ s32 brcmf_cfg80211_up(struct net_device *ndev);
+ s32 brcmf_cfg80211_down(struct net_device *ndev);
++struct cfg80211_ops *brcmf_cfg80211_get_ops(void);
+ enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
+
+ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -252,6 +252,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ brcmf_err("Retreiving cur_etheraddr failed, %d\n", err);
+ goto done;
+ }
++ memcpy(ifp->drvr->wiphy->perm_addr, ifp->drvr->mac, ETH_ALEN);
+ memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac));
+
+ bus = ifp->drvr->bus_if;
+@@ -279,6 +280,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ ri->chippkg = le32_to_cpu(revinfo.chippkg);
+ ri->nvramrev = le32_to_cpu(revinfo.nvramrev);
+
++ /* use revinfo if not known yet */
+ if (!bus->chip) {
+ bus->chip = le32_to_cpu(revinfo.chipnum);
+ bus->chiprev = le32_to_cpu(revinfo.chiprev);
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -1021,7 +1021,7 @@ static int brcmf_revinfo_read(struct seq
+ return 0;
+ }
+
+-static int brcmf_bus_started(struct brcmf_pub *drvr)
++static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops)
+ {
+ int ret = -1;
+ struct brcmf_bus *bus_if = drvr->bus_if;
+@@ -1060,7 +1060,7 @@ static int brcmf_bus_started(struct brcm
+
+ brcmf_proto_add_if(drvr, ifp);
+
+- drvr->config = brcmf_cfg80211_attach(drvr, bus_if->dev,
++ drvr->config = brcmf_cfg80211_attach(drvr, ops,
+ drvr->settings->p2p_enable);
+ if (drvr->config == NULL) {
+ ret = -ENOMEM;
+@@ -1115,17 +1115,26 @@ fail:
+
+ int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings)
+ {
++ struct wiphy *wiphy;
++ struct cfg80211_ops *ops;
+ struct brcmf_pub *drvr = NULL;
+ int ret = 0;
+ int i;
+
+ brcmf_dbg(TRACE, "Enter\n");
+
+- /* Allocate primary brcmf_info */
+- drvr = kzalloc(sizeof(*drvr), GFP_ATOMIC);
+- if (!drvr)
++ ops = brcmf_cfg80211_get_ops();
++ if (!ops)
+ return -ENOMEM;
+
++ wiphy = wiphy_new(ops, sizeof(*drvr));
++ if (!wiphy)
++ return -ENOMEM;
++
++ set_wiphy_dev(wiphy, dev);
++ drvr = wiphy_priv(wiphy);
++ drvr->wiphy = wiphy;
++
+ for (i = 0; i < ARRAY_SIZE(drvr->if2bss); i++)
+ drvr->if2bss[i] = BRCMF_BSSIDX_INVALID;
+
+@@ -1154,15 +1163,18 @@ int brcmf_attach(struct device *dev, str
+ /* attach firmware event handler */
+ brcmf_fweh_attach(drvr);
+
+- ret = brcmf_bus_started(drvr);
++ ret = brcmf_bus_started(drvr, ops);
+ if (ret != 0) {
+ brcmf_err("dongle is not responding: err=%d\n", ret);
+ goto fail;
+ }
++
++ drvr->config->ops = ops;
+ return 0;
+
+ fail:
+ brcmf_detach(dev);
++ kfree(ops);
+
+ return ret;
+ }
+@@ -1220,6 +1232,7 @@ void brcmf_detach(struct device *dev)
+ brcmf_remove_interface(drvr->iflist[i], false);
+
+ brcmf_cfg80211_detach(drvr->config);
++ drvr->config = NULL;
+
+ brcmf_bus_stop(drvr->bus_if);
+
+@@ -1227,7 +1240,7 @@ void brcmf_detach(struct device *dev)
+
+ brcmf_debug_detach(drvr);
+ bus_if->drvr = NULL;
+- kfree(drvr);
++ wiphy_free(drvr->wiphy);
+ }
+
+ s32 brcmf_iovar_data_set(struct device *dev, char *name, void *data, u32 len)
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h
+@@ -107,6 +107,7 @@ struct brcmf_pub {
+ /* Linkage ponters */
+ struct brcmf_bus *bus_if;
+ struct brcmf_proto *proto;
++ struct wiphy *wiphy;
+ struct brcmf_cfg80211_info *config;
+
+ /* Internal brcmf items */
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+@@ -2229,7 +2229,7 @@ fail:
+ */
+ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
+ {
+- struct brcmf_cfg80211_info *cfg = wiphy_priv(wiphy);
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_p2p_info *p2p = &cfg->p2p;
+ struct brcmf_cfg80211_vif *vif;
+ enum nl80211_iftype iftype;
diff --git a/package/kernel/mac80211/patches/327-v4.17-0005-brcmfmac-use-wiphy-debugfs-dir-entry.patch b/package/kernel/mac80211/patches/327-v4.17-0005-brcmfmac-use-wiphy-debugfs-dir-entry.patch
new file mode 100644
index 0000000000..c5485c390a
--- /dev/null
+++ b/package/kernel/mac80211/patches/327-v4.17-0005-brcmfmac-use-wiphy-debugfs-dir-entry.patch
@@ -0,0 +1,349 @@
+From 34789d0cf682c643862792750a06c31ccf016cbc Mon Sep 17 00:00:00 2001
+From: Arend Van Spriel <arend.vanspriel@broadcom.com>
+Date: Thu, 22 Mar 2018 21:28:24 +0100
+Subject: [PATCH] brcmfmac: use wiphy debugfs dir entry
+
+The driver used to create a brcmfmac dir entry at the top level
+debugfs mount point. This moves the debugfs entries into the
+wiphy debugfs dir entry.
+
+Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
+Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
+Reviewed-by: Franky Lin <franky.lin@broadcom.com>
+Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/bcdc.c | 6 ++++
+ .../wireless/broadcom/brcm80211/brcmfmac/common.c | 5 ---
+ .../wireless/broadcom/brcm80211/brcmfmac/core.c | 11 +++---
+ .../wireless/broadcom/brcm80211/brcmfmac/debug.c | 42 ++--------------------
+ .../wireless/broadcom/brcm80211/brcmfmac/debug.h | 17 ---------
+ .../wireless/broadcom/brcm80211/brcmfmac/feature.c | 3 ++
+ .../wireless/broadcom/brcm80211/brcmfmac/feature.h | 7 ++++
+ .../broadcom/brcm80211/brcmfmac/fwsignal.c | 11 +++---
+ .../broadcom/brcm80211/brcmfmac/fwsignal.h | 1 +
+ .../wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | 8 +++--
+ .../wireless/broadcom/brcm80211/brcmfmac/proto.c | 3 +-
+ .../wireless/broadcom/brcm80211/brcmfmac/proto.h | 7 ++++
+ 12 files changed, 47 insertions(+), 74 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
+@@ -445,6 +445,11 @@ brcmf_proto_bcdc_init_done(struct brcmf_
+ return 0;
+ }
+
++static void brcmf_proto_bcdc_debugfs_create(struct brcmf_pub *drvr)
++{
++ brcmf_fws_debugfs_create(drvr);
++}
++
+ int brcmf_proto_bcdc_attach(struct brcmf_pub *drvr)
+ {
+ struct brcmf_bcdc *bcdc;
+@@ -472,6 +477,7 @@ int brcmf_proto_bcdc_attach(struct brcmf
+ drvr->proto->del_if = brcmf_proto_bcdc_del_if;
+ drvr->proto->reset_if = brcmf_proto_bcdc_reset_if;
+ drvr->proto->init_done = brcmf_proto_bcdc_init_done;
++ drvr->proto->debugfs_create = brcmf_proto_bcdc_debugfs_create;
+ drvr->proto->pd = bcdc;
+
+ drvr->hdrlen += BCDC_HEADER_LEN + BRCMF_PROT_FW_SIGNAL_MAX_TXBYTES;
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -529,9 +529,6 @@ static int __init brcmfmac_module_init(v
+ {
+ int err;
+
+- /* Initialize debug system first */
+- brcmf_debugfs_init();
+-
+ /* Get the platform data (if available) for our devices */
+ err = platform_driver_probe(&brcmf_pd, brcmf_common_pd_probe);
+ if (err == -ENODEV)
+@@ -543,7 +540,6 @@ static int __init brcmfmac_module_init(v
+ /* Continue the initialization by registering the different busses */
+ err = brcmf_core_init();
+ if (err) {
+- brcmf_debugfs_exit();
+ if (brcmfmac_pdata)
+ platform_driver_unregister(&brcmf_pd);
+ }
+@@ -556,7 +552,6 @@ static void __exit brcmfmac_module_exit(
+ brcmf_core_exit();
+ if (brcmfmac_pdata)
+ platform_driver_unregister(&brcmf_pd);
+- brcmf_debugfs_exit();
+ }
+
+ module_init(brcmfmac_module_init);
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -1050,8 +1050,6 @@ static int brcmf_bus_started(struct brcm
+ if (ret < 0)
+ goto fail;
+
+- brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
+-
+ brcmf_feat_attach(drvr);
+
+ ret = brcmf_proto_init_done(drvr);
+@@ -1094,6 +1092,11 @@ static int brcmf_bus_started(struct brcm
+ #endif
+ #endif /* CONFIG_INET */
+
++ /* populate debugfs */
++ brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
++ brcmf_feat_debugfs_create(drvr);
++ brcmf_proto_debugfs_create(drvr);
++
+ return 0;
+
+ fail:
+@@ -1146,9 +1149,6 @@ int brcmf_attach(struct device *dev, str
+ drvr->bus_if->drvr = drvr;
+ drvr->settings = settings;
+
+- /* attach debug facilities */
+- brcmf_debug_attach(drvr);
+-
+ /* Attach and link in the protocol */
+ ret = brcmf_proto_attach(drvr);
+ if (ret != 0) {
+@@ -1238,7 +1238,6 @@ void brcmf_detach(struct device *dev)
+
+ brcmf_proto_detach(drvr);
+
+- brcmf_debug_detach(drvr);
+ bus_if->drvr = NULL;
+ wiphy_free(drvr->wiphy);
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.c
+@@ -25,8 +25,6 @@
+ #include "fweh.h"
+ #include "debug.h"
+
+-static struct dentry *root_folder;
+-
+ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
+ size_t len)
+ {
+@@ -54,44 +52,9 @@ int brcmf_debug_create_memdump(struct br
+ return 0;
+ }
+
+-void brcmf_debugfs_init(void)
+-{
+- root_folder = debugfs_create_dir(KBUILD_MODNAME, NULL);
+- if (IS_ERR(root_folder))
+- root_folder = NULL;
+-}
+-
+-void brcmf_debugfs_exit(void)
+-{
+- if (!root_folder)
+- return;
+-
+- debugfs_remove_recursive(root_folder);
+- root_folder = NULL;
+-}
+-
+-int brcmf_debug_attach(struct brcmf_pub *drvr)
+-{
+- struct device *dev = drvr->bus_if->dev;
+-
+- if (!root_folder)
+- return -ENODEV;
+-
+- drvr->dbgfs_dir = debugfs_create_dir(dev_name(dev), root_folder);
+- return PTR_ERR_OR_ZERO(drvr->dbgfs_dir);
+-}
+-
+-void brcmf_debug_detach(struct brcmf_pub *drvr)
+-{
+- brcmf_fweh_unregister(drvr, BRCMF_E_PSM_WATCHDOG);
+-
+- if (!IS_ERR_OR_NULL(drvr->dbgfs_dir))
+- debugfs_remove_recursive(drvr->dbgfs_dir);
+-}
+-
+ struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr)
+ {
+- return drvr->dbgfs_dir;
++ return drvr->wiphy->debugfsdir;
+ }
+
+ int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
+@@ -99,7 +62,8 @@ int brcmf_debugfs_add_entry(struct brcmf
+ {
+ struct dentry *e;
+
++ WARN(!drvr->wiphy->debugfsdir, "wiphy not (yet) registered\n");
+ e = debugfs_create_devm_seqfile(drvr->bus_if->dev, fn,
+- drvr->dbgfs_dir, read_fn);
++ drvr->wiphy->debugfsdir, read_fn);
+ return PTR_ERR_OR_ZERO(e);
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -113,29 +113,12 @@ extern int brcmf_msg_level;
+ struct brcmf_bus;
+ struct brcmf_pub;
+ #ifdef DEBUG
+-void brcmf_debugfs_init(void);
+-void brcmf_debugfs_exit(void);
+-int brcmf_debug_attach(struct brcmf_pub *drvr);
+-void brcmf_debug_detach(struct brcmf_pub *drvr);
+ struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr);
+ int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
+ int (*read_fn)(struct seq_file *seq, void *data));
+ int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
+ size_t len);
+ #else
+-static inline void brcmf_debugfs_init(void)
+-{
+-}
+-static inline void brcmf_debugfs_exit(void)
+-{
+-}
+-static inline int brcmf_debug_attach(struct brcmf_pub *drvr)
+-{
+- return 0;
+-}
+-static inline void brcmf_debug_detach(struct brcmf_pub *drvr)
+-{
+-}
+ static inline
+ int brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
+ int (*read_fn)(struct seq_file *seq, void *data))
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
+@@ -228,7 +228,10 @@ void brcmf_feat_attach(struct brcmf_pub
+ /* no quirks */
+ break;
+ }
++}
+
++void brcmf_feat_debugfs_create(struct brcmf_pub *drvr)
++{
+ brcmf_debugfs_add_entry(drvr, "features", brcmf_feat_debugfs_read);
+ }
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
+@@ -90,6 +90,13 @@ enum brcmf_feat_quirk {
+ void brcmf_feat_attach(struct brcmf_pub *drvr);
+
+ /**
++ * brcmf_feat_debugfs_create() - create debugfs entries.
++ *
++ * @drvr: driver instance.
++ */
++void brcmf_feat_debugfs_create(struct brcmf_pub *drvr);
++
++/**
+ * brcmf_feat_is_enabled() - query feature.
+ *
+ * @ifp: interface instance.
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
+@@ -2399,10 +2399,6 @@ struct brcmf_fws_info *brcmf_fws_attach(
+ brcmu_pktq_init(&fws->desc.other.psq, BRCMF_FWS_PSQ_PREC_COUNT,
+ BRCMF_FWS_PSQ_LEN);
+
+- /* create debugfs file for statistics */
+- brcmf_debugfs_add_entry(drvr, "fws_stats",
+- brcmf_debugfs_fws_stats_read);
+-
+ brcmf_dbg(INFO, "%s bdcv2 tlv signaling [%x]\n",
+ fws->fw_signals ? "enabled" : "disabled", tlv);
+ return fws;
+@@ -2429,6 +2425,13 @@ void brcmf_fws_detach(struct brcmf_fws_i
+ kfree(fws);
+ }
+
++void brcmf_fws_debugfs_create(struct brcmf_pub *drvr)
++{
++ /* create debugfs file for statistics */
++ brcmf_debugfs_add_entry(drvr, "fws_stats",
++ brcmf_debugfs_fws_stats_read);
++}
++
+ bool brcmf_fws_queue_skbs(struct brcmf_fws_info *fws)
+ {
+ return !fws->avoid_queueing;
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.h
+@@ -20,6 +20,7 @@
+
+ struct brcmf_fws_info *brcmf_fws_attach(struct brcmf_pub *drvr);
+ void brcmf_fws_detach(struct brcmf_fws_info *fws);
++void brcmf_fws_debugfs_create(struct brcmf_pub *drvr);
+ bool brcmf_fws_queue_skbs(struct brcmf_fws_info *fws);
+ bool brcmf_fws_fc_active(struct brcmf_fws_info *fws);
+ void brcmf_fws_hdrpull(struct brcmf_if *ifp, s16 siglen, struct sk_buff *skb);
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
+@@ -1418,6 +1418,11 @@ static int brcmf_msgbuf_stats_read(struc
+ }
+ #endif
+
++static void brcmf_msgbuf_debugfs_create(struct brcmf_pub *drvr)
++{
++ brcmf_debugfs_add_entry(drvr, "msgbuf_stats", brcmf_msgbuf_stats_read);
++}
++
+ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr)
+ {
+ struct brcmf_bus_msgbuf *if_msgbuf;
+@@ -1472,6 +1477,7 @@ int brcmf_proto_msgbuf_attach(struct brc
+ drvr->proto->delete_peer = brcmf_msgbuf_delete_peer;
+ drvr->proto->add_tdls_peer = brcmf_msgbuf_add_tdls_peer;
+ drvr->proto->rxreorder = brcmf_msgbuf_rxreorder;
++ drvr->proto->debugfs_create = brcmf_msgbuf_debugfs_create;
+ drvr->proto->pd = msgbuf;
+
+ init_waitqueue_head(&msgbuf->ioctl_resp_wait);
+@@ -1525,8 +1531,6 @@ int brcmf_proto_msgbuf_attach(struct brc
+ spin_lock_init(&msgbuf->flowring_work_lock);
+ INIT_LIST_HEAD(&msgbuf->work_queue);
+
+- brcmf_debugfs_add_entry(drvr, "msgbuf_stats", brcmf_msgbuf_stats_read);
+-
+ return 0;
+
+ fail:
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
+@@ -54,7 +54,8 @@ int brcmf_proto_attach(struct brcmf_pub
+ if (!proto->tx_queue_data || (proto->hdrpull == NULL) ||
+ (proto->query_dcmd == NULL) || (proto->set_dcmd == NULL) ||
+ (proto->configure_addr_mode == NULL) ||
+- (proto->delete_peer == NULL) || (proto->add_tdls_peer == NULL)) {
++ (proto->delete_peer == NULL) || (proto->add_tdls_peer == NULL) ||
++ (proto->debugfs_create == NULL)) {
+ brcmf_err("Not all proto handlers have been installed\n");
+ goto fail;
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.h
+@@ -48,6 +48,7 @@ struct brcmf_proto {
+ void (*del_if)(struct brcmf_if *ifp);
+ void (*reset_if)(struct brcmf_if *ifp);
+ int (*init_done)(struct brcmf_pub *drvr);
++ void (*debugfs_create)(struct brcmf_pub *drvr);
+ void *pd;
+ };
+
+@@ -156,4 +157,10 @@ brcmf_proto_init_done(struct brcmf_pub *
+ return drvr->proto->init_done(drvr);
+ }
+
++static inline void
++brcmf_proto_debugfs_create(struct brcmf_pub *drvr)
++{
++ drvr->proto->debugfs_create(drvr);
++}
++
+ #endif /* BRCMFMAC_PROTO_H */
diff --git a/package/kernel/mac80211/patches/327-v4.17-0006-brcmfmac-derive-firmware-filenames-from-basename-map.patch b/package/kernel/mac80211/patches/327-v4.17-0006-brcmfmac-derive-firmware-filenames-from-basename-map.patch
new file mode 100644
index 0000000000..0b1ae56bc0
--- /dev/null
+++ b/package/kernel/mac80211/patches/327-v4.17-0006-brcmfmac-derive-firmware-filenames-from-basename-map.patch
@@ -0,0 +1,286 @@
+From 41f573dbb534f14e62a4a5411f602c970cad1d77 Mon Sep 17 00:00:00 2001
+From: Arend Van Spriel <arend.vanspriel@broadcom.com>
+Date: Thu, 22 Mar 2018 21:28:25 +0100
+Subject: [PATCH] brcmfmac: derive firmware filenames from basename mapping
+
+Instead of defining individual filenames for firmware and nvram
+use a basename and derive the names from that.
+
+Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
+Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
+Reviewed-by: Franky Lin <franky.lin@broadcom.com>
+Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../broadcom/brcm80211/brcmfmac/firmware.c | 31 ++++++---
+ .../broadcom/brcm80211/brcmfmac/firmware.h | 24 ++-----
+ .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 56 ++++++++---------
+ .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 73 +++++++++++-----------
+ .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 10 +--
+ 5 files changed, 96 insertions(+), 98 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+@@ -563,6 +563,13 @@ int brcmf_fw_get_firmwares(struct device
+ 0);
+ }
+
++static void brcmf_fw_get_full_name(char fw_name[BRCMF_FW_NAME_LEN],
++ const char *fw_base, const char *extension)
++{
++ strlcat(fw_name, fw_base, BRCMF_FW_NAME_LEN);
++ strlcat(fw_name, extension, BRCMF_FW_NAME_LEN);
++}
++
+ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
+ struct brcmf_firmware_mapping mapping_table[],
+ u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
+@@ -587,25 +594,31 @@ int brcmf_fw_map_chip_to_name(u32 chip,
+
+ /* check if firmware path is provided by module parameter */
+ if (brcmf_mp_global.firmware_path[0] != '\0') {
+- strlcpy(fw_name, brcmf_mp_global.firmware_path,
+- BRCMF_FW_NAME_LEN);
+- if ((nvram_name) && (mapping_table[i].nvram))
++ if (fw_name)
++ strlcpy(fw_name, brcmf_mp_global.firmware_path,
++ BRCMF_FW_NAME_LEN);
++ if (nvram_name)
+ strlcpy(nvram_name, brcmf_mp_global.firmware_path,
+ BRCMF_FW_NAME_LEN);
+
+ end = brcmf_mp_global.firmware_path[
+ strlen(brcmf_mp_global.firmware_path) - 1];
+ if (end != '/') {
+- strlcat(fw_name, "/", BRCMF_FW_NAME_LEN);
+- if ((nvram_name) && (mapping_table[i].nvram))
++ if (fw_name)
++ strlcat(fw_name, "/", BRCMF_FW_NAME_LEN);
++ if (nvram_name)
+ strlcat(nvram_name, "/", BRCMF_FW_NAME_LEN);
+ }
+ }
+- strlcat(fw_name, mapping_table[i].fw, BRCMF_FW_NAME_LEN);
+- if ((nvram_name) && (mapping_table[i].nvram))
+- strlcat(nvram_name, mapping_table[i].nvram, BRCMF_FW_NAME_LEN);
+
+- brcmf_info("using %s for chip %s\n", fw_name, chipname);
++ brcmf_info("using %s for chip %s\n",
++ mapping_table[i].fw_base, chipname);
++ if (fw_name)
++ brcmf_fw_get_full_name(fw_name,
++ mapping_table[i].fw_base, ".bin");
++ if (nvram_name)
++ brcmf_fw_get_full_name(nvram_name,
++ mapping_table[i].fw_base, ".txt");
+
+ return 0;
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
+@@ -38,28 +38,16 @@
+ struct brcmf_firmware_mapping {
+ u32 chipid;
+ u32 revmask;
+- const char *fw;
+- const char *nvram;
++ const char *fw_base;
+ };
+
+-#define BRCMF_FW_NVRAM_DEF(fw_nvram_name, fw, nvram) \
+-static const char BRCM_ ## fw_nvram_name ## _FIRMWARE_NAME[] = \
+- BRCMF_FW_DEFAULT_PATH fw; \
+-static const char BRCM_ ## fw_nvram_name ## _NVRAM_NAME[] = \
+- BRCMF_FW_DEFAULT_PATH nvram; \
+-MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw);
+-
+-#define BRCMF_FW_DEF(fw_name, fw) \
+-static const char BRCM_ ## fw_name ## _FIRMWARE_NAME[] = \
+- BRCMF_FW_DEFAULT_PATH fw; \
+-MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw) \
+-
+-#define BRCMF_FW_NVRAM_ENTRY(chipid, mask, name) \
+- { chipid, mask, \
+- BRCM_ ## name ## _FIRMWARE_NAME, BRCM_ ## name ## _NVRAM_NAME }
++#define BRCMF_FW_DEF(fw_name, fw_base) \
++static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \
++ BRCMF_FW_DEFAULT_PATH fw_base; \
++MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin")
+
+ #define BRCMF_FW_ENTRY(chipid, mask, name) \
+- { chipid, mask, BRCM_ ## name ## _FIRMWARE_NAME, NULL }
++ { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
+
+ int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
+ struct brcmf_firmware_mapping mapping_table[],
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+@@ -46,36 +46,36 @@ enum brcmf_pcie_state {
+ BRCMFMAC_PCIE_STATE_UP
+ };
+
+-BRCMF_FW_NVRAM_DEF(43602, "brcmfmac43602-pcie.bin", "brcmfmac43602-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4350, "brcmfmac4350-pcie.bin", "brcmfmac4350-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4350C, "brcmfmac4350c2-pcie.bin", "brcmfmac4350c2-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4356, "brcmfmac4356-pcie.bin", "brcmfmac4356-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(43570, "brcmfmac43570-pcie.bin", "brcmfmac43570-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4358, "brcmfmac4358-pcie.bin", "brcmfmac4358-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4359, "brcmfmac4359-pcie.bin", "brcmfmac4359-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4365B, "brcmfmac4365b-pcie.bin", "brcmfmac4365b-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4365C, "brcmfmac4365c-pcie.bin", "brcmfmac4365c-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4366B, "brcmfmac4366b-pcie.bin", "brcmfmac4366b-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4366C, "brcmfmac4366c-pcie.bin", "brcmfmac4366c-pcie.txt");
+-BRCMF_FW_NVRAM_DEF(4371, "brcmfmac4371-pcie.bin", "brcmfmac4371-pcie.txt");
++BRCMF_FW_DEF(43602, "brcmfmac43602-pcie");
++BRCMF_FW_DEF(4350, "brcmfmac4350-pcie");
++BRCMF_FW_DEF(4350C, "brcmfmac4350c2-pcie");
++BRCMF_FW_DEF(4356, "brcmfmac4356-pcie");
++BRCMF_FW_DEF(43570, "brcmfmac43570-pcie");
++BRCMF_FW_DEF(4358, "brcmfmac4358-pcie");
++BRCMF_FW_DEF(4359, "brcmfmac4359-pcie");
++BRCMF_FW_DEF(4365B, "brcmfmac4365b-pcie");
++BRCMF_FW_DEF(4365C, "brcmfmac4365c-pcie");
++BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie");
++BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");
++BRCMF_FW_DEF(4371, "brcmfmac4371-pcie");
+
+ static struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43602_CHIP_ID, 0xFFFFFFFF, 43602),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43465_CHIP_ID, 0xFFFFFFF0, 4366C),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4350_CHIP_ID, 0x000000FF, 4350C),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4350_CHIP_ID, 0xFFFFFF00, 4350),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43525_CHIP_ID, 0xFFFFFFF0, 4365C),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43567_CHIP_ID, 0xFFFFFFFF, 43570),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43569_CHIP_ID, 0xFFFFFFFF, 43570),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43570_CHIP_ID, 0xFFFFFFFF, 43570),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4358_CHIP_ID, 0xFFFFFFFF, 4358),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4359_CHIP_ID, 0xFFFFFFFF, 4359),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4365_CHIP_ID, 0x0000000F, 4365B),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4365_CHIP_ID, 0xFFFFFFF0, 4365C),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4366_CHIP_ID, 0x0000000F, 4366B),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4366_CHIP_ID, 0xFFFFFFF0, 4366C),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
++ BRCMF_FW_ENTRY(BRCM_CC_43602_CHIP_ID, 0xFFFFFFFF, 43602),
++ BRCMF_FW_ENTRY(BRCM_CC_43465_CHIP_ID, 0xFFFFFFF0, 4366C),
++ BRCMF_FW_ENTRY(BRCM_CC_4350_CHIP_ID, 0x000000FF, 4350C),
++ BRCMF_FW_ENTRY(BRCM_CC_4350_CHIP_ID, 0xFFFFFF00, 4350),
++ BRCMF_FW_ENTRY(BRCM_CC_43525_CHIP_ID, 0xFFFFFFF0, 4365C),
++ BRCMF_FW_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356),
++ BRCMF_FW_ENTRY(BRCM_CC_43567_CHIP_ID, 0xFFFFFFFF, 43570),
++ BRCMF_FW_ENTRY(BRCM_CC_43569_CHIP_ID, 0xFFFFFFFF, 43570),
++ BRCMF_FW_ENTRY(BRCM_CC_43570_CHIP_ID, 0xFFFFFFFF, 43570),
++ BRCMF_FW_ENTRY(BRCM_CC_4358_CHIP_ID, 0xFFFFFFFF, 4358),
++ BRCMF_FW_ENTRY(BRCM_CC_4359_CHIP_ID, 0xFFFFFFFF, 4359),
++ BRCMF_FW_ENTRY(BRCM_CC_4365_CHIP_ID, 0x0000000F, 4365B),
++ BRCMF_FW_ENTRY(BRCM_CC_4365_CHIP_ID, 0xFFFFFFF0, 4365C),
++ BRCMF_FW_ENTRY(BRCM_CC_4366_CHIP_ID, 0x0000000F, 4366B),
++ BRCMF_FW_ENTRY(BRCM_CC_4366_CHIP_ID, 0xFFFFFFF0, 4366C),
++ BRCMF_FW_ENTRY(BRCM_CC_4371_CHIP_ID, 0xFFFFFFFF, 4371),
+ };
+
+ #define BRCMF_PCIE_FW_UP_TIMEOUT 2000 /* msec */
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+@@ -600,47 +600,44 @@ static const struct sdiod_drive_str sdio
+ {4, 0x1}
+ };
+
+-BRCMF_FW_NVRAM_DEF(43143, "brcmfmac43143-sdio.bin", "brcmfmac43143-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(43241B0, "brcmfmac43241b0-sdio.bin",
+- "brcmfmac43241b0-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(43241B4, "brcmfmac43241b4-sdio.bin",
+- "brcmfmac43241b4-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(43241B5, "brcmfmac43241b5-sdio.bin",
+- "brcmfmac43241b5-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4329, "brcmfmac4329-sdio.bin", "brcmfmac4329-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4330, "brcmfmac4330-sdio.bin", "brcmfmac4330-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4334, "brcmfmac4334-sdio.bin", "brcmfmac4334-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(43340, "brcmfmac43340-sdio.bin", "brcmfmac43340-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4335, "brcmfmac4335-sdio.bin", "brcmfmac4335-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(43362, "brcmfmac43362-sdio.bin", "brcmfmac43362-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4339, "brcmfmac4339-sdio.bin", "brcmfmac4339-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(43430A0, "brcmfmac43430a0-sdio.bin", "brcmfmac43430a0-sdio.txt");
++BRCMF_FW_DEF(43143, "brcmfmac43143-sdio");
++BRCMF_FW_DEF(43241B0, "brcmfmac43241b0-sdio");
++BRCMF_FW_DEF(43241B4, "brcmfmac43241b4-sdio");
++BRCMF_FW_DEF(43241B5, "brcmfmac43241b5-sdio");
++BRCMF_FW_DEF(4329, "brcmfmac4329-sdio");
++BRCMF_FW_DEF(4330, "brcmfmac4330-sdio");
++BRCMF_FW_DEF(4334, "brcmfmac4334-sdio");
++BRCMF_FW_DEF(43340, "brcmfmac43340-sdio");
++BRCMF_FW_DEF(4335, "brcmfmac4335-sdio");
++BRCMF_FW_DEF(43362, "brcmfmac43362-sdio");
++BRCMF_FW_DEF(4339, "brcmfmac4339-sdio");
++BRCMF_FW_DEF(43430A0, "brcmfmac43430a0-sdio");
+ /* Note the names are not postfixed with a1 for backward compatibility */
+-BRCMF_FW_NVRAM_DEF(43430A1, "brcmfmac43430-sdio.bin", "brcmfmac43430-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(43455, "brcmfmac43455-sdio.bin", "brcmfmac43455-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4354, "brcmfmac4354-sdio.bin", "brcmfmac4354-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4356, "brcmfmac4356-sdio.bin", "brcmfmac4356-sdio.txt");
+-BRCMF_FW_NVRAM_DEF(4373, "brcmfmac4373-sdio.bin", "brcmfmac4373-sdio.txt");
++BRCMF_FW_DEF(43430A1, "brcmfmac43430-sdio");
++BRCMF_FW_DEF(43455, "brcmfmac43455-sdio");
++BRCMF_FW_DEF(4354, "brcmfmac4354-sdio");
++BRCMF_FW_DEF(4356, "brcmfmac4356-sdio");
++BRCMF_FW_DEF(4373, "brcmfmac4373-sdio");
+
+ static struct brcmf_firmware_mapping brcmf_sdio_fwnames[] = {
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43143_CHIP_ID, 0xFFFFFFFF, 43143),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43241_CHIP_ID, 0x0000001F, 43241B0),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43241_CHIP_ID, 0x00000020, 43241B4),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43241_CHIP_ID, 0xFFFFFFC0, 43241B5),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4329_CHIP_ID, 0xFFFFFFFF, 4329),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4330_CHIP_ID, 0xFFFFFFFF, 4330),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4334_CHIP_ID, 0xFFFFFFFF, 4334),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43340_CHIP_ID, 0xFFFFFFFF, 43340),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43341_CHIP_ID, 0xFFFFFFFF, 43340),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4335_CHIP_ID, 0xFFFFFFFF, 4335),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43362_CHIP_ID, 0xFFFFFFFE, 43362),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4339_CHIP_ID, 0xFFFFFFFF, 4339),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43430_CHIP_ID, 0x00000001, 43430A0),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_43430_CHIP_ID, 0xFFFFFFFE, 43430A1),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4345_CHIP_ID, 0xFFFFFFC0, 43455),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, 4354),
+- BRCMF_FW_NVRAM_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356),
+- BRCMF_FW_NVRAM_ENTRY(CY_CC_4373_CHIP_ID, 0xFFFFFFFF, 4373)
++ BRCMF_FW_ENTRY(BRCM_CC_43143_CHIP_ID, 0xFFFFFFFF, 43143),
++ BRCMF_FW_ENTRY(BRCM_CC_43241_CHIP_ID, 0x0000001F, 43241B0),
++ BRCMF_FW_ENTRY(BRCM_CC_43241_CHIP_ID, 0x00000020, 43241B4),
++ BRCMF_FW_ENTRY(BRCM_CC_43241_CHIP_ID, 0xFFFFFFC0, 43241B5),
++ BRCMF_FW_ENTRY(BRCM_CC_4329_CHIP_ID, 0xFFFFFFFF, 4329),
++ BRCMF_FW_ENTRY(BRCM_CC_4330_CHIP_ID, 0xFFFFFFFF, 4330),
++ BRCMF_FW_ENTRY(BRCM_CC_4334_CHIP_ID, 0xFFFFFFFF, 4334),
++ BRCMF_FW_ENTRY(BRCM_CC_43340_CHIP_ID, 0xFFFFFFFF, 43340),
++ BRCMF_FW_ENTRY(BRCM_CC_43341_CHIP_ID, 0xFFFFFFFF, 43340),
++ BRCMF_FW_ENTRY(BRCM_CC_4335_CHIP_ID, 0xFFFFFFFF, 4335),
++ BRCMF_FW_ENTRY(BRCM_CC_43362_CHIP_ID, 0xFFFFFFFE, 43362),
++ BRCMF_FW_ENTRY(BRCM_CC_4339_CHIP_ID, 0xFFFFFFFF, 4339),
++ BRCMF_FW_ENTRY(BRCM_CC_43430_CHIP_ID, 0x00000001, 43430A0),
++ BRCMF_FW_ENTRY(BRCM_CC_43430_CHIP_ID, 0xFFFFFFFE, 43430A1),
++ BRCMF_FW_ENTRY(BRCM_CC_4345_CHIP_ID, 0xFFFFFFC0, 43455),
++ BRCMF_FW_ENTRY(BRCM_CC_4354_CHIP_ID, 0xFFFFFFFF, 4354),
++ BRCMF_FW_ENTRY(BRCM_CC_4356_CHIP_ID, 0xFFFFFFFF, 4356),
++ BRCMF_FW_ENTRY(CY_CC_4373_CHIP_ID, 0xFFFFFFFF, 4373)
+ };
+
+ static void pkt_align(struct sk_buff *p, int len, int align)
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
+@@ -46,11 +46,11 @@
+ #define BRCMF_USB_CBCTL_READ 1
+ #define BRCMF_USB_MAX_PKT_SIZE 1600
+
+-BRCMF_FW_DEF(43143, "brcmfmac43143.bin");
+-BRCMF_FW_DEF(43236B, "brcmfmac43236b.bin");
+-BRCMF_FW_DEF(43242A, "brcmfmac43242a.bin");
+-BRCMF_FW_DEF(43569, "brcmfmac43569.bin");
+-BRCMF_FW_DEF(4373, "brcmfmac4373.bin");
++BRCMF_FW_DEF(43143, "brcmfmac43143");
++BRCMF_FW_DEF(43236B, "brcmfmac43236b");
++BRCMF_FW_DEF(43242A, "brcmfmac43242a");
++BRCMF_FW_DEF(43569, "brcmfmac43569");
++BRCMF_FW_DEF(4373, "brcmfmac4373");
+
+ static struct brcmf_firmware_mapping brcmf_usb_fwnames[] = {
+ BRCMF_FW_ENTRY(BRCM_CC_43143_CHIP_ID, 0xFFFFFFFF, 43143),
diff --git a/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch b/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch
index a1670469d6..63849f48db 100644
--- a/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch
+++ b/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch
@@ -13,7 +13,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
-@@ -1310,6 +1310,7 @@ int __init brcmf_core_init(void)
+@@ -1314,6 +1314,7 @@ int __init brcmf_core_init(void)
{
if (!schedule_work(&brcmf_driver_work))
return -EBUSY;
@@ -23,7 +23,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
}
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
-@@ -444,6 +444,7 @@ struct brcmf_fw {
+@@ -445,6 +445,7 @@ struct brcmf_fw {
u16 bus_nr;
void (*done)(struct device *dev, int err, const struct firmware *fw,
void *nvram_image, u32 nvram_len);
@@ -31,7 +31,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
};
static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
-@@ -478,6 +479,8 @@ static void brcmf_fw_request_nvram_done(
+@@ -479,6 +480,8 @@ static void brcmf_fw_request_nvram_done(
goto fail;
fwctx->done(fwctx->dev, 0, fwctx->code, nvram, nvram_length);
@@ -40,7 +40,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
kfree(fwctx);
return;
-@@ -485,6 +488,8 @@ fail:
+@@ -486,6 +489,8 @@ fail:
brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
release_firmware(fwctx->code);
fwctx->done(fwctx->dev, -ENOENT, NULL, NULL, 0);
@@ -49,7 +49,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
kfree(fwctx);
}
-@@ -516,6 +521,8 @@ fail:
+@@ -517,6 +522,8 @@ fail:
brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
done:
fwctx->done(fwctx->dev, ret, fw, NULL, 0);
@@ -58,7 +58,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
kfree(fwctx);
}
-@@ -527,6 +534,8 @@ int brcmf_fw_get_firmwares_pcie(struct d
+@@ -528,6 +535,8 @@ int brcmf_fw_get_firmwares_pcie(struct d
u16 domain_nr, u16 bus_nr)
{
struct brcmf_fw *fwctx;
@@ -67,7 +67,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
if (!fw_cb || !code)
-@@ -547,9 +556,17 @@ int brcmf_fw_get_firmwares_pcie(struct d
+@@ -548,9 +557,17 @@ int brcmf_fw_get_firmwares_pcie(struct d
fwctx->domain_nr = domain_nr;
fwctx->bus_nr = bus_nr;
diff --git a/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch b/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch
index c02d00966e..9b36059079 100644
--- a/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch
+++ b/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch
@@ -14,7 +14,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
-@@ -2727,6 +2727,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip
+@@ -2725,6 +2725,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip
* preference in cfg struct to apply this to
* FW later while initializing the dongle
*/
diff --git a/package/kernel/mac80211/patches/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch b/package/kernel/mac80211/patches/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch
index 0ae012cbeb..8d5dbfc733 100644
--- a/package/kernel/mac80211/patches/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch
+++ b/package/kernel/mac80211/patches/864-brcmfmac-do-not-use-internal-roaming-engine-by-default.patch
@@ -9,7 +9,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
-@@ -71,7 +71,11 @@ static int brcmf_fcmode;
+@@ -72,7 +72,11 @@ static int brcmf_fcmode;
module_param_named(fcmode, brcmf_fcmode, int, 0);
MODULE_PARM_DESC(fcmode, "Mode of firmware signalled flow control");