diff -Nru broadcom-sta-6.30.223.271/debian/changelog broadcom-sta-6.30.223.271/debian/changelog --- broadcom-sta-6.30.223.271/debian/changelog 2020-09-27 11:26:10.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/changelog 2021-05-04 09:11:49.000000000 +0000 @@ -1,3 +1,25 @@ +broadcom-sta (6.30.223.271-16) unstable; urgency=medium + + * Upload to unstable. + * debian/patches: + - Fix typo of patch 21. + - Previous patch 19 20 fixes old ticket (Closes: #987159). + * debian/README.source: + - Note some git repo for future reference. + + -- Roger Shimizu Tue, 04 May 2021 18:11:49 +0900 + +broadcom-sta (6.30.223.271-16~exp1) experimental; urgency=medium + + * debian/patches: + - Add 5 patches from Diego Escalante Urrelo to improve: + + power mgmt setting + + tx_power + + mac address setting + + other minor fixes + + -- Roger Shimizu Sat, 03 Oct 2020 02:25:04 +0900 + broadcom-sta (6.30.223.271-15) unstable; urgency=medium * debian/patches: diff -Nru broadcom-sta-6.30.223.271/debian/patches/18-wl-Make-sure-power_mgmt-settings-are-honored.patch broadcom-sta-6.30.223.271/debian/patches/18-wl-Make-sure-power_mgmt-settings-are-honored.patch --- broadcom-sta-6.30.223.271/debian/patches/18-wl-Make-sure-power_mgmt-settings-are-honored.patch 1970-01-01 00:00:00.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/18-wl-Make-sure-power_mgmt-settings-are-honored.patch 2021-05-04 09:11:49.000000000 +0000 @@ -0,0 +1,30 @@ +From: Diego Escalante Urrelo +Date: Thu, 23 Jul 2020 09:46:52 -0500 +Subject: wl: Make sure power_mgmt settings are honored + +The driver does *not* respect calls to set_power_mgmt() to turn power +saving off, it sets "PM_OFF" when it is asked to turn off PM by +userspace. However, it seems that unidentified circumstances will turn +PM to PM_FAST automatically again and again, disregarding user input. + +This patch uses PM_FORCE_OFF instead of PM_OFF which seems to reliably +keep PM off, no matter the circumstances. +--- + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +index 111ec5a..e81389f 100644 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +@@ -1479,7 +1479,9 @@ wl_cfg80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, + s32 pm; + s32 err = 0; + +- pm = enabled ? PM_FAST : PM_OFF; ++ /* NOTICE: Use PM_FORCE_OFF, otherwise powersaving will turn itself ++ * ON again (PM_FAST) when on battery power. */ ++ pm = enabled ? PM_FAST : PM_FORCE_OFF; + pm = htod32(pm); + WL_DBG(("power save %s\n", (pm ? "enabled" : "disabled"))); + err = wl_dev_ioctl(dev, WLC_SET_PM, &pm, sizeof(pm)); diff -Nru broadcom-sta-6.30.223.271/debian/patches/19-wl-Fix-get-set-values-for-tx_power.patch broadcom-sta-6.30.223.271/debian/patches/19-wl-Fix-get-set-values-for-tx_power.patch --- broadcom-sta-6.30.223.271/debian/patches/19-wl-Fix-get-set-values-for-tx_power.patch 1970-01-01 00:00:00.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/19-wl-Fix-get-set-values-for-tx_power.patch 2021-05-04 09:11:49.000000000 +0000 @@ -0,0 +1,117 @@ +From: Diego Escalante Urrelo +Date: Thu, 23 Jul 2020 13:11:51 -0500 +Subject: wl: Fix get/set values for tx_power + +The wl driver seems to be using an internal "qdbm" unit for the +"qtxpower" registry, where hardware power is read, and naively using +that value around the get/set cfg80211 functions. + +This 'qdBm' unit is simply (dBm * 4) and defaults to "23 *4" in +`wl_linux.c`. This equivalency is confirmed in the brcmfmac kernel +driver, which seems to be a cleaned up version of this one. + +This commit fixes getting and setting the txpower using regular +utilities like `iwconfig` or `iw`. +--- + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 26 +++++++++++++------------- + amd64/src/wl/sys/wl_linux.c | 4 ++++ + 2 files changed, 17 insertions(+), 13 deletions(-) + +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +index e81389f..fd2430e 100644 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +@@ -89,13 +89,13 @@ static s32 wl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, u + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) + static s32 + wl_cfg80211_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, +- enum nl80211_tx_power_setting type, s32 dbm); ++ enum nl80211_tx_power_setting type, s32 mbm); + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) + static s32 wl_cfg80211_set_tx_power(struct wiphy *wiphy, +- enum nl80211_tx_power_setting type, s32 dbm); ++ enum nl80211_tx_power_setting type, s32 mbm); + #else + static s32 wl_cfg80211_set_tx_power(struct wiphy *wiphy, +- enum tx_power_setting type, s32 dbm); ++ enum tx_power_setting type, s32 mbm); + #endif + + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) +@@ -1080,24 +1080,25 @@ wl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_c + #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) + static s32 + wl_cfg80211_set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, +- enum nl80211_tx_power_setting type, s32 dbm) ++ enum nl80211_tx_power_setting type, s32 mbm) + #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) + static s32 +-wl_cfg80211_set_tx_power(struct wiphy *wiphy, enum nl80211_tx_power_setting type, s32 dbm) ++wl_cfg80211_set_tx_power(struct wiphy *wiphy, enum nl80211_tx_power_setting type, s32 mbm) + #else + #define NL80211_TX_POWER_AUTOMATIC TX_POWER_AUTOMATIC + #define NL80211_TX_POWER_LIMITED TX_POWER_LIMITED + #define NL80211_TX_POWER_FIXED TX_POWER_FIXED + static s32 +-wl_cfg80211_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, s32 dbm) ++wl_cfg80211_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, s32 mbm) + #endif + { + + struct wl_cfg80211_priv *wl = wiphy_to_wl(wiphy); + struct net_device *ndev = wl_to_ndev(wl); +- u16 txpwrmw; + s32 err = 0; + s32 disable = 0; ++ s32 dbm = MBM_TO_DBM(mbm); ++ s32 qdbm = dbm * 4; + + switch (type) { + case NL80211_TX_POWER_AUTOMATIC: +@@ -1116,6 +1117,9 @@ wl_cfg80211_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, s32 db + break; + } + ++ qdbm = (qdbm > 127) ? 127 : qdbm; ++ qdbm |= WL_TXPWR_OVERRIDE; ++ + disable = WL_RADIO_SW_DISABLE << 16; + disable = htod32(disable); + err = wl_dev_ioctl(ndev, WLC_SET_RADIO, &disable, sizeof(disable)); +@@ -1124,11 +1128,7 @@ wl_cfg80211_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, s32 db + return err; + } + +- if (dbm > 0xffff) +- txpwrmw = 0xffff; +- else +- txpwrmw = (u16) dbm; +- err = wl_dev_intvar_set(ndev, "qtxpower", (s32) (bcm_mw_to_qdbm(txpwrmw))); ++ err = wl_dev_intvar_set(ndev, "qtxpower", qdbm); + if (err) { + WL_ERR(("qtxpower error (%d)\n", err)); + return err; +@@ -1156,7 +1156,7 @@ static s32 wl_cfg80211_get_tx_power(struct wiphy *wiphy, s32 *dbm) + return err; + } + result = (u8) (txpwrdbm & ~WL_TXPWR_OVERRIDE); +- *dbm = (s32) bcm_qdbm_to_mw(result); ++ *dbm = (s32) result / 4; + + return err; + } +diff --git a/amd64/src/wl/sys/wl_linux.c b/amd64/src/wl/sys/wl_linux.c +index cc01d2b..4f5e43a 100644 +--- a/amd64/src/wl/sys/wl_linux.c ++++ b/amd64/src/wl/sys/wl_linux.c +@@ -628,6 +628,10 @@ wl_attach(uint16 vendor, uint16 device, ulong regs, + + wlc_iovar_setint(wl->wlc, "scan_passive_time", 170); + ++ /* NOTICE: The driver's `qtxpower` option takes values from 0 to ++ * 127, which correspond to (dBm * 4). This seems to be a half-done ++ * implementation of their own API. The brcmfmac kernel driver ++ * confirms this. */ + wlc_iovar_setint(wl->wlc, "qtxpower", 23 * 4); + + #ifdef BCMDBG diff -Nru broadcom-sta-6.30.223.271/debian/patches/20-wl-Fix-mac-address-setting.patch broadcom-sta-6.30.223.271/debian/patches/20-wl-Fix-mac-address-setting.patch --- broadcom-sta-6.30.223.271/debian/patches/20-wl-Fix-mac-address-setting.patch 1970-01-01 00:00:00.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/20-wl-Fix-mac-address-setting.patch 2021-05-04 09:11:49.000000000 +0000 @@ -0,0 +1,51 @@ +From: Diego Escalante Urrelo +Date: Tue, 28 Jul 2020 11:19:37 -0500 +Subject: wl: Fix mac address setting + +The function was returning BCM_UNSUPPORTED (-23) when the device did not +allow for mac address changes. This however corresponds to "too many +files open" so userspace was getting conflicting info on what was +happening. Example: + + $ ip link set wlp3s0 address 3c:15:c2:cf:29:dd + RTNETLINK answers: Too many open files in system + +Now the function properly returns -EADDRNOTAVAIL instead. + +This fixes the popular error where NetworkManager is unable to connect +to wifi networks when wifi.scan-rand-mac-addr=yes (the default) or other +mac-addr options are in use (see the work around supplied by +wpasupplicant in /usr/lib/NetworkManager/conf.d/no-mac-addr-change.conf) + +Also, the function was incorrectly changing the `net_device->dev_addr` +even when the hardware had not been able to change it. +--- + amd64/src/wl/sys/wl_linux.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/amd64/src/wl/sys/wl_linux.c b/amd64/src/wl/sys/wl_linux.c +index 4f5e43a..acdac06 100644 +--- a/amd64/src/wl/sys/wl_linux.c ++++ b/amd64/src/wl/sys/wl_linux.c +@@ -1848,15 +1848,17 @@ wl_set_mac_address(struct net_device *dev, void *addr) + WL_TRACE(("wl%d: wl_set_mac_address\n", wl->pub->unit)); + + WL_LOCK(wl); +- +- bcopy(sa->sa_data, dev->dev_addr, ETHER_ADDR_LEN); + err = wlc_iovar_op(wl->wlc, "cur_etheraddr", NULL, 0, sa->sa_data, ETHER_ADDR_LEN, + IOV_SET, (WL_DEV_IF(dev))->wlcif); + WL_UNLOCK(wl); +- if (err) ++ if (err) { + WL_ERROR(("wl%d: wl_set_mac_address: error setting MAC addr override\n", + wl->pub->unit)); +- return err; ++ return OSL_ERROR(err); ++ } else { ++ bcopy(sa->sa_data, dev->dev_addr, ETHER_ADDR_LEN); ++ return 0; ++ } + } + + static void diff -Nru broadcom-sta-6.30.223.271/debian/patches/21-wl-Fix-misleading-indentation.patch broadcom-sta-6.30.223.271/debian/patches/21-wl-Fix-misleading-indentation.patch --- broadcom-sta-6.30.223.271/debian/patches/21-wl-Fix-misleading-indentation.patch 1970-01-01 00:00:00.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/21-wl-Fix-misleading-indentation.patch 2021-05-04 09:11:49.000000000 +0000 @@ -0,0 +1,52 @@ +From: Diego Escalante Urrelo +Date: Thu, 23 Jul 2020 10:30:32 -0500 +Subject: wl: Fix misleading indentation +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Mixed spaces and tabs caused a misleading indentation warning. +Tidy up to suppress the warning: + +src/wl/sys/wl_linux.c:788:2: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] + 788 | if ((val & 0x0000ff00) != 0) + | ^~ +src/wl/sys/wl_linux.c:790:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ + 790 | bar1_size = pci_resource_len(pdev, 2); + | ^~~~~~~~~ +--- + amd64/src/wl/sys/wl_linux.c | 20 +++++++++++--------- + 1 file changed, 11 insertions(+), 9 deletions(-) + +diff --git a/amd64/src/wl/sys/wl_linux.c b/amd64/src/wl/sys/wl_linux.c +index acdac06..a63cc4d 100644 +--- a/amd64/src/wl/sys/wl_linux.c ++++ b/amd64/src/wl/sys/wl_linux.c +@@ -788,16 +788,18 @@ wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) + pci_read_config_dword(pdev, 0x40, &val); + if ((val & 0x0000ff00) != 0) + pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); +- bar1_size = pci_resource_len(pdev, 2); +- #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) +- bar1_addr = (uchar *)ioremap(pci_resource_start(pdev, 2), +- bar1_size); +- #else +- bar1_addr = (uchar *)ioremap_nocache(pci_resource_start(pdev, 2), +- bar1_size); +- #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */ ++ ++ bar1_size = pci_resource_len(pdev, 2); ++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) ++ bar1_addr = (uchar *)ioremap(pci_resource_start(pdev, 2), ++ bar1_size); ++#else ++ bar1_addr = (uchar *)ioremap_nocache(pci_resource_start(pdev, 2), ++ bar1_size); ++#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) */ ++ + wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0), PCI_BUS, pdev, +- pdev->irq, bar1_addr, bar1_size); ++ pdev->irq, bar1_addr, bar1_size); + + if (!wl) + return -ENODEV; diff -Nru broadcom-sta-6.30.223.271/debian/patches/22-wl-Fix-fall-through-warnings.patch broadcom-sta-6.30.223.271/debian/patches/22-wl-Fix-fall-through-warnings.patch --- broadcom-sta-6.30.223.271/debian/patches/22-wl-Fix-fall-through-warnings.patch 1970-01-01 00:00:00.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/22-wl-Fix-fall-through-warnings.patch 2021-05-04 09:11:49.000000000 +0000 @@ -0,0 +1,34 @@ +From: Diego Escalante Urrelo +Date: Thu, 23 Jul 2020 15:51:06 -0500 +Subject: wl: Fix fall through warnings +MIME-Version: 1.0 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: 8bit + +Add a gcc special comment to solve a -Wimplicit-fallthrough warning: + +src/wl/sys/wl_cfg80211_hybrid.h:52:5: warning: this statement may fall through [-Wimplicit-fallthrough=] + 52 | if (wl_dbg_level & WL_DBG_DBG) { \ + | ^ +src/wl/sys/wl_cfg80211_hybrid.c:817:3: note: in expansion of macro ‘WL_DBG’ + 817 | WL_DBG(("network eap\n")); + | ^~~~~~ +src/wl/sys/wl_cfg80211_hybrid.c:820:2: note: here + 820 | default: + | ^~~~~~~ +--- + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +index fd2430e..195c0e4 100644 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +@@ -790,6 +790,7 @@ wl_set_auth_type(struct net_device *dev, struct cfg80211_connect_params *sme) + break; + case NL80211_AUTHTYPE_NETWORK_EAP: + WL_DBG(("network eap\n")); ++ /* falls through */ + default: + val = 2; + WL_ERR(("invalid auth type (%d)\n", sme->auth_type)); diff -Nru broadcom-sta-6.30.223.271/debian/patches/23-wl-Avoid-disconnecting-invalid-interface.patch broadcom-sta-6.30.223.271/debian/patches/23-wl-Avoid-disconnecting-invalid-interface.patch --- broadcom-sta-6.30.223.271/debian/patches/23-wl-Avoid-disconnecting-invalid-interface.patch 1970-01-01 00:00:00.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/23-wl-Avoid-disconnecting-invalid-interface.patch 2021-05-04 09:11:49.000000000 +0000 @@ -0,0 +1,33 @@ +From: Diego Escalante Urrelo +Date: Tue, 28 Jul 2020 13:59:56 -0500 +Subject: wl: Avoid disconnecting invalid interface + +Mimic brcmfmac driver and don't try to call WLC_DISASSOC on an invalid +interface. +--- + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +index 195c0e4..1801f70 100644 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +@@ -1065,14 +1065,15 @@ wl_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_c + WL_DBG(("Reason %d\n", reason_code)); + + if (wl->profile->active) { +- scbval.val = reason_code; + memcpy(&scbval.ea, &wl->bssid, ETHER_ADDR_LEN); +- scbval.val = htod32(scbval.val); +- err = wl_dev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t)); ++ scbval.val = htod32(reason_code); ++ err = wl_dev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scbval)); + if (err) { + WL_ERR(("error (%d)\n", err)); + return err; + } ++ } else { ++ return -EIO; + } + + return err; diff -Nru broadcom-sta-6.30.223.271/debian/patches/24-wl-Use-the-right-enums-for-cfg80211_get_bss.patch broadcom-sta-6.30.223.271/debian/patches/24-wl-Use-the-right-enums-for-cfg80211_get_bss.patch --- broadcom-sta-6.30.223.271/debian/patches/24-wl-Use-the-right-enums-for-cfg80211_get_bss.patch 1970-01-01 00:00:00.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/24-wl-Use-the-right-enums-for-cfg80211_get_bss.patch 2021-05-04 09:11:49.000000000 +0000 @@ -0,0 +1,22 @@ +From: Diego Escalante Urrelo +Date: Sun, 2 Aug 2020 19:54:56 -0500 +Subject: wl: Use the right enums for cfg80211_get_bss + +--- + amd64/src/wl/sys/wl_cfg80211_hybrid.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/amd64/src/wl/sys/wl_cfg80211_hybrid.c b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +index 1801f70..c4b1154 100644 +--- a/amd64/src/wl/sys/wl_cfg80211_hybrid.c ++++ b/amd64/src/wl/sys/wl_cfg80211_hybrid.c +@@ -2304,7 +2304,8 @@ static s32 wl_update_bss_info(struct wl_cfg80211_priv *wl) + + ssid = &wl->profile->ssid; + bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid, +- ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); ++ ssid->SSID, ssid->SSID_len, ++ IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY); + + rtnl_lock(); + if (!bss) { diff -Nru broadcom-sta-6.30.223.271/debian/patches/series broadcom-sta-6.30.223.271/debian/patches/series --- broadcom-sta-6.30.223.271/debian/patches/series 2020-09-27 11:26:10.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/patches/series 2021-05-04 09:11:49.000000000 +0000 @@ -15,3 +15,10 @@ 15-linux51.patch 16-linux56.patch 17-Get-rid-of-get_fs-set_fs-calls.patch +18-wl-Make-sure-power_mgmt-settings-are-honored.patch +19-wl-Fix-get-set-values-for-tx_power.patch +20-wl-Fix-mac-address-setting.patch +21-wl-Fix-misleading-indentation.patch +22-wl-Fix-fall-through-warnings.patch +23-wl-Avoid-disconnecting-invalid-interface.patch +24-wl-Use-the-right-enums-for-cfg80211_get_bss.patch diff -Nru broadcom-sta-6.30.223.271/debian/README.source broadcom-sta-6.30.223.271/debian/README.source --- broadcom-sta-6.30.223.271/debian/README.source 2020-09-27 11:26:10.000000000 +0000 +++ broadcom-sta-6.30.223.271/debian/README.source 2021-05-04 09:11:49.000000000 +0000 @@ -6,3 +6,8 @@ documented in /usr/share/doc/quilt/README.source + +Some git repo for future reference: + - https://www.archlinux.org/packages/community/x86_64/broadcom-wl + - https://pkgs.rpmfusion.org/cgit/nonfree/wl-kmod.git + - https://github.com/antoineco/broadcom-wl/tree/patch-linux4.7