wifi: brcmfmac: per-vendor changes and SAE offload support
Arend van Spriel
maintainerv2 cover wifi: brcmfmac: per-vendor changes and SAE offload support
This series builds around the patch from Hector Martin which enables SAE offload for WCC vendor devices like the BCM4378.
Other patches involve exposing firmware interface layer functions to per-vendor modules and allowing per-vendor feature detection or override.
This series applies to the main branch of the wireless-next repository.
Arend van Spriel (3):
wifi: brcmfmac: export firmware interface functions
wifi: brcmfmac: add per-vendor feature detection callback
wifi: brcmfmac: move feature overrides before feature_disable
Hector Martin (1):
wifi: brcmfmac: cfg80211: Use WSEC to set SAE password
.../broadcom/brcm80211/brcmfmac/bca/core.c | 8 ++ .../broadcom/brcm80211/brcmfmac/cfg80211.c | 60 ++++----- .../broadcom/brcm80211/brcmfmac/cfg80211.h | 2 + .../broadcom/brcm80211/brcmfmac/core.c | 2 +- .../broadcom/brcm80211/brcmfmac/cyw/core.c | 28 ++++ .../broadcom/brcm80211/brcmfmac/feature.c | 11 +- .../broadcom/brcm80211/brcmfmac/fwil.c | 116 ++-------------- .../broadcom/brcm80211/brcmfmac/fwil.h | 127 +++++++++++++++--- .../broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- .../broadcom/brcm80211/brcmfmac/fwvid.h | 25 ++++ .../broadcom/brcm80211/brcmfmac/wcc/core.c | 9 ++ 11 files changed, 223 insertions(+), 167 deletions(-)
base-commit: 968509128207f122d7177ffb6ff51c9c6fa7e13d
Signature · 1 line
2.32.0
Arend van Spriel
maintainerPATCH v2 1/4 wifi: brcmfmac: export firmware interface functions
With multi-vendor support the vendor-specific module may need to use the firmware interface functions so export them using the macro BRCMF_EXPORT_SYMBOL_GPL() which exports them to driver namespace.
---
changelog
V2: address 0-day compilation failure for sparc64.
--- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 4 +- .../broadcom/brcm80211/brcmfmac/core.c | 2 +- .../broadcom/brcm80211/brcmfmac/feature.c | 2 +- .../broadcom/brcm80211/brcmfmac/fwil.c | 115 +--------------- .../broadcom/brcm80211/brcmfmac/fwil.h | 127 +++++++++++++++--- 5 files changed, 121 insertions(+), 129 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +2 -2
@@ -3081,7 +3081,7 @@ brcmf_cfg80211_get_station_ibss(struct brcmf_if *ifp,struct brcmf_scb_val_le scbval;struct brcmf_pktcnt_le pktcnt;s32 err; -u32 rate; +u32 rate =0 ;u32 rssi;/* Get the current tx rate */
@@ -7269,7 +7269,7 @@ static int brcmf_setup_wiphybands(struct brcmf_cfg80211_info *cfg)u32 nmode =0 ;u32 vhtmode =0 ;u32 bw_cap[2 ] = {WLC_BW_20MHZ_BIT ,WLC_BW_20MHZ_BIT }; -u32 rxchain; +u32 rxchain =0 ;u32 nchain;int err;s32 i;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +1 -1
@@ -691,7 +691,7 @@ static int brcmf_net_mon_open(struct net_device *ndev) {struct brcmf_if *ifp =netdev_priv (ndev);struct brcmf_pub *drvr = ifp->drvr; -u32 monitor; +u32 monitor =0 ;int err;brcmf_dbg (TRACE ,"Enter\n" );
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +1 -1
@@ -183,7 +183,7 @@ static void brcmf_feat_wlc_version_overrides(struct brcmf_pub *drv)static void brcmf_feat_iovar_int_get (struct brcmf_if *ifp,enum brcmf_feat_id id,char *name) { -u32 data; +u32 data =0 ;int err;/* we need to know firmware error */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +7 -108
155 lines not on this page · raw message
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.h +110 -17
139 lines not on this page · raw message
Signature · 1 line
2.32.0
Re: [PATCH V2 1/4] wifi: brcmfmac: export firmware interface functions
Quoted 5 lines · Arend van Spriel
With multi-vendor support the vendor-specific module may need to use the firmware interface functions so export them using the macro
BRCMF_EXPORT_SYMBOL_GPL()which exports them to driver namespace.Signed-off-by Arend van Spriel <[email protected]>
4 patches applied to wireless-next.git, thanks.
31343230abb1 wifi: brcmfmac: export firmware interface functions 14e1391b7102 wifi: brcmfmac: add per-vendor feature detection callback ba4d4726335c wifi: brcmfmac: move feature overrides before feature_disable 9f7861c56b51 wifi: brcmfmac: cfg80211: Use WSEC to set SAE password
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Arend van Spriel
maintainerPATCH v2 2/4 wifi: brcmfmac: add per-vendor feature detection callback
In reply to Arend van SprielAdding a .feat_attach() callback allowing per-vendor overrides of the driver feature flags. In this patch the callback is only provided by BCA vendor to disable SAE feature as it has not been confirmed yet. BCA chips generally do not have the in-driver supplicant (idsup) feature so they rely on NL80211_CMD_EXTERNAL_AUTH to trigger user-space authentication.
--- .../wireless/broadcom/brcm80211/brcmfmac/bca/core.c | 8 ++++++++ .../wireless/broadcom/brcm80211/brcmfmac/feature.c | 3 +++ .../net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h | 12 ++++++++++++ 3 files changed, 23 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/core.c +8 -0
@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <feature.h> #include "vops.h"
@@ -21,7 +22,14 @@ static void brcmf_bca_detach(struct brcmf_pub *drvr)pr_err ("%s: executing\n" , __func__); } +static void brcmf_bca_feat_attach (struct brcmf_if *ifp) +{ +/* SAE support not confirmed so disabling for now */ + ifp->drvr->feat_flags &= ~BIT (BRCMF_FEAT_SAE ); +} +const struct brcmf_fwvid_ops brcmf_bca_ops = { .attach = brcmf_bca_attach, .detach = brcmf_bca_detach, + .feat_attach = brcmf_bca_feat_attach, };
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +3 -0
@@ -13,6 +13,7 @@#include "debug.h" #include "fwil.h" #include "fwil_types.h" +#include "fwvid.h" #include "feature.h" #include "common.h"
@@ -339,6 +340,8 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)brcmf_feat_iovar_int_get (ifp,BRCMF_FEAT_FWSUP ,"sup_wpa" );brcmf_feat_iovar_int_get (ifp,BRCMF_FEAT_SCAN_V2 ,"scan_ver" ); +brcmf_fwvid_feat_attach (ifp); +if (drvr->settings->feature_disable) { brcmf_dbg(INFO, "Features: 0x%02x, disable: 0x%02x\n", ifp->drvr->feat_flags,
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h +12 -0
@@ -8,10 +8,12 @@#include "firmware.h" struct brcmf_pub ; +struct brcmf_if ;struct brcmf_fwvid_ops {int (*attach)(struct brcmf_pub *drvr);void (*detach)(struct brcmf_pub *drvr); +void (*feat_attach)(struct brcmf_if *ifp); };/* exported functions */
@@ -44,4 +46,14 @@ static inline void brcmf_fwvid_detach(struct brcmf_pub *drvr) brcmf_fwvid_detach_ops(drvr); } +static inline void brcmf_fwvid_feat_attach (struct brcmf_if *ifp) +{ +const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; + +if (!vops->feat_attach) +return ; + + vops->feat_attach (ifp); +} +#endif /* FWVID_H_ */
Signature · 1 line
2.32.0
Re: [PATCH V2 2/4] wifi: brcmfmac: add per-vendor feature detection callback
Hi Arend,
Quoted 6 lines
Adding a .feat_attach() callback allowing per-vendor overrides of the driver feature flags. In this patch the callback is only provided by BCA vendor to disable SAE feature as it has not been confirmed yet. BCA chips generally do not have the in-driver supplicant (idsup) feature so they rely on
NL80211_CMD_EXTERNAL_AUTHto trigger user-space authentication.
is there any way to tell if idsup is supported (firmware string or some other mechanism). The just disabling and not implementing support for external_auth is really having this stuck in WPA2 legacy world.
The whole out-dated firmware game on Raspberry Pi is already a mess.
My problem is really that WiFi 6E and WiFi 7 are essentially mandating WPA3/SAE only support as soon as you move into 6 GHz operation and the errors presented to the user are not decodable if you don’t have a good understanding on what WiFi certification mandates.
Regards
Marcel
Arend van Spriel
maintainerPATCH v2 3/4 wifi: brcmfmac: move feature overrides before feature_disable
In reply to Arend van SprielThe feature_disable option in brcmf_feat_attach() is a debugging or workaround option to disable features that cause driver issues. Hence they should be done as last step after all feature detection mechanisms have been completed.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +3 -3
@@ -340,6 +340,9 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)brcmf_feat_iovar_int_get (ifp,BRCMF_FEAT_FWSUP ,"sup_wpa" );brcmf_feat_iovar_int_get (ifp,BRCMF_FEAT_SCAN_V2 ,"scan_ver" ); +brcmf_feat_wlc_version_overrides (drvr); +brcmf_feat_firmware_overrides (drvr); +brcmf_fwvid_feat_attach (ifp);if (drvr->settings->feature_disable) {
@@ -349,9 +352,6 @@ void brcmf_feat_attach(struct brcmf_pub *drvr) ifp->drvr->feat_flags &= ~drvr->settings->feature_disable; } -brcmf_feat_wlc_version_overrides (drvr); -brcmf_feat_firmware_overrides (drvr); -/* set chip related quirks */ switch (drvr->bus_if->chip) {case BRCM_CC_43236_CHIP_ID :
Signature · 1 line
2.32.0
Arend van Spriel
maintainerPATCH v2 4/4 wifi: brcmfmac: cfg80211: Use WSEC to set SAE password
In reply to Arend van SprielFrom: Hector Martin <[email protected]>
Using the WSEC command instead of sae_password seems to be the supported mechanism on newer firmware, and also how the brcmdhd driver does it.
According to user reports [1], the sae_password codepath doesn't actually work on machines with Cypress chips anyway, so no harm in removing it.
This makes WPA3 work with iwd, or with wpa_supplicant pending a support patchset [2].
[1] https://rachelbythebay.com/w/2023/11/06/wpa3/
[2] http://lists.infradead.org/pipermail/hostap/2023-July/041653.html
--- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 56 ++++++++----------- .../broadcom/brcm80211/brcmfmac/cfg80211.h | 2 + .../broadcom/brcm80211/brcmfmac/cyw/core.c | 28 ++++++++++ .../broadcom/brcm80211/brcmfmac/fwil.c | 1 + .../broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- .../broadcom/brcm80211/brcmfmac/fwvid.h | 13 +++++ .../broadcom/brcm80211/brcmfmac/wcc/core.c | 9 +++ 7 files changed, 76 insertions(+), 35 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +22 -34
@@ -32,6 +32,7 @@#include "vendor.h" #include "bus.h" #include "common.h" +#include "fwvid.h" #define BRCMF_SCAN_IE_LEN_MAX 2048
@@ -1687,52 +1688,39 @@ static u16 brcmf_map_fw_linkdown_reason(const struct brcmf_event_msg *e)return reason; } -static int brcmf_set_pmk (struct brcmf_if *ifp,const u8 *pmk_data,u16 pmk_len) +int brcmf_set_wsec (struct brcmf_if *ifp,const u8 *key,u16 key_len,u16 flags) {struct brcmf_pub *drvr = ifp->drvr;struct brcmf_wsec_pmk_le pmk;int err; +if (key_len >sizeof (pmk.key)) { +bphy_err (drvr,"key must be less than %zu bytes\n" , +sizeof (pmk.key)); +return -EINVAL ; + } +memset (&pmk,0 ,sizeof (pmk)); -/* pass pmk directly */ - pmk.key_len =cpu_to_le16 (pmk_len); - pmk.flags =cpu_to_le16 (0 ); -memcpy (pmk.key, pmk_data, pmk_len); +/* pass key material directly */ + pmk.key_len =cpu_to_le16 (key_len); + pmk.flags =cpu_to_le16 (flags); +memcpy (pmk.key, key, key_len); -/* store psk in firmware */ +/* store key material in firmware */ err =brcmf_fil_cmd_data_set (ifp,BRCMF_C_SET_WSEC_PMK , &pmk,sizeof (pmk));if (err <0 )bphy_err (drvr,"failed to change PSK in firmware (len=%u)\n" , - pmk_len); + key_len);return err; } +BRCMF_EXPORT_SYMBOL_GPL (brcmf_set_wsec); -static int brcmf_set_sae_password (struct brcmf_if *ifp,const u8 *pwd_data, -u16 pwd_len) +static int brcmf_set_pmk (struct brcmf_if *ifp,const u8 *pmk_data,u16 pmk_len) { -struct brcmf_pub *drvr = ifp->drvr; -struct brcmf_wsec_sae_pwd_le sae_pwd; -int err; - -if (pwd_len >BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ) { -bphy_err (drvr,"sae_password must be less than %d\n" , -BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ); -return -EINVAL ; - } - - sae_pwd.key_len =cpu_to_le16 (pwd_len); -memcpy (sae_pwd.key, pwd_data, pwd_len); - - err =brcmf_fil_iovar_data_set (ifp,"sae_password" , &sae_pwd, -sizeof (sae_pwd)); -if (err <0 ) -bphy_err (drvr,"failed to set SAE password in firmware (len=%u)\n" , - pwd_len); - -return err; +return brcmf_set_wsec (ifp, pmk_data, pmk_len,0 ); } static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason,
@@ -2503,8 +2491,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,bphy_err (drvr,"failed to clean up user-space RSNE\n" ); goto done; } - err =brcmf_set_sae_password (ifp, sme->crypto.sae_pwd, - sme->crypto.sae_pwd_len); + err =brcmf_fwvid_set_sae_password (ifp, &sme->crypto);if (!err && sme->crypto.psk) err =brcmf_set_pmk (ifp, sme->crypto.psk,BRCMF_WSEC_MAX_PSK_LEN );
@@ -5252,8 +5239,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,if (crypto->sae_pwd) {brcmf_dbg (INFO ,"using SAE offload\n" ); profile->use_fwauth |=BIT (BRCMF_PROFILE_FWAUTH_SAE ); - err =brcmf_set_sae_password (ifp, crypto->sae_pwd, - crypto->sae_pwd_len); + err =brcmf_fwvid_set_sae_password (ifp, crypto);if (err <0 ) goto exit; }
@@ -5360,10 +5346,12 @@ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev,msleep (400 );if (profile->use_fwauth !=BIT (BRCMF_PROFILE_FWAUTH_NONE )) { +struct cfg80211_crypto_settings crypto = {}; +if (profile->use_fwauth &BIT (BRCMF_PROFILE_FWAUTH_PSK ))brcmf_set_pmk (ifp,NULL ,0 );if (profile->use_fwauth &BIT (BRCMF_PROFILE_FWAUTH_SAE )) -brcmf_set_sae_password (ifp,NULL ,0 ); +brcmf_fwvid_set_sae_password (ifp, &crypto); profile->use_fwauth =BIT (BRCMF_PROFILE_FWAUTH_NONE ); }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h +2 -0
@@ -468,4 +468,6 @@ void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);void brcmf_abort_scanning (struct brcmf_cfg80211_info *cfg);void brcmf_cfg80211_free_netdev (struct net_device *ndev); +int brcmf_set_wsec (struct brcmf_if *ifp,const u8 *key,u16 key_len,u16 flags); +#endif /* BRCMFMAC_CFG80211_H */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c +28 -0
@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <fwil.h> #include "vops.h"
@@ -21,7 +22,34 @@ static void brcmf_cyw_detach(struct brcmf_pub *drvr)pr_err ("%s: executing\n" , __func__); } +static int brcmf_cyw_set_sae_pwd (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +struct brcmf_pub *drvr = ifp->drvr; +struct brcmf_wsec_sae_pwd_le sae_pwd; +u16 pwd_len = crypto->sae_pwd_len; +int err; + +if (pwd_len >BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ) { +bphy_err (drvr,"sae_password must be less than %d\n" , +BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ); +return -EINVAL ; + } + + sae_pwd.key_len =cpu_to_le16 (pwd_len); +memcpy (sae_pwd.key, crypto->sae_pwd, pwd_len); + + err =brcmf_fil_iovar_data_set (ifp,"sae_password" , &sae_pwd, +sizeof (sae_pwd)); +if (err <0 ) +bphy_err (drvr,"failed to set SAE password in firmware (len=%u)\n" , + pwd_len); + +return err; +} +const struct brcmf_fwvid_ops brcmf_cyw_ops = { .attach = brcmf_cyw_attach, .detach = brcmf_cyw_detach, + .set_sae_password = brcmf_cyw_set_sae_pwd, };
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +1 -0
@@ -211,6 +211,7 @@ brcmf_fil_iovar_data_set(struct brcmf_if *ifp, const char *name, const void *datmutex_unlock (&drvr->proto_block);return err; } +BRCMF_EXPORT_SYMBOL_GPL (brcmf_fil_iovar_data_set); s32 brcmf_fil_iovar_data_get(struct brcmf_if *ifp, const char *name, void *data,
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +1 -1
@@ -584,7 +584,7 @@ struct brcmf_wsec_key_le {struct brcmf_wsec_pmk_le {__le16 key_len;__le16 flags; -u8 key[2 *BRCMF_WSEC_MAX_PSK_LEN +1 ]; +u8 key[BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ]; };/**
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h +13 -0
@@ -6,6 +6,7 @@#define FWVID_H_ #include "firmware.h" +#include "cfg80211.h" struct brcmf_pub ;struct brcmf_if ;
@@ -14,6 +15,7 @@ struct brcmf_fwvid_ops {int (*attach)(struct brcmf_pub *drvr);void (*detach)(struct brcmf_pub *drvr);void (*feat_attach)(struct brcmf_if *ifp); +int (*set_sae_password)(struct brcmf_if *ifp,struct cfg80211_crypto_settings *crypto); };/* exported functions */
@@ -56,4 +58,15 @@ static inline void brcmf_fwvid_feat_attach(struct brcmf_if *ifp) vops->feat_attach(ifp); } +static inline int brcmf_fwvid_set_sae_password (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; + +if (!vops || !vops->set_sae_password) +return -EOPNOTSUPP ; + +return vops->set_sae_password (ifp, crypto); +} +#endif /* FWVID_H_ */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/core.c +9 -0
@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <fwil.h> #include "vops.h"
@@ -21,7 +22,15 @@ static void brcmf_wcc_detach(struct brcmf_pub *drvr)pr_debug ("%s: executing\n" , __func__); } +static int brcmf_wcc_set_sae_pwd (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +return brcmf_set_wsec (ifp, crypto->sae_pwd, crypto->sae_pwd_len, +BRCMF_WSEC_PASSPHRASE ); +} +const struct brcmf_fwvid_ops brcmf_wcc_ops = { .attach = brcmf_wcc_attach, .detach = brcmf_wcc_detach, + .set_sae_password = brcmf_wcc_set_sae_pwd, };
Signature · 1 line
2.32.0
Re: [PATCH V2 4/4] wifi: brcmfmac: cfg80211: Use WSEC to set SAE password
Quoted 292 lines · Arend van Spriel
From: Hector Martin <[email protected]>
Using the WSEC command instead of
sae_passwordseems to be the supported mechanism on newer firmware, and also how the brcmdhd driver does it.According to user reports [1], the
sae_passwordcodepath doesn't actually work on machines with Cypress chips anyway, so no harm in removing it.This makes WPA3 work with iwd, or with
wpa_supplicantpending a support patchset [2].[1] https://rachelbythebay.com/w/2023/11/06/wpa3/
[2] http://lists.infradead.org/pipermail/hostap/2023-July/041653.htmlSigned-off-by Hector Martin <[email protected]>Reviewed-by Neal Gompa <[email protected]>[[email protected]: use multi-vendor framework]Signed-off-by Arend van Spriel <[email protected]>--- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 56 ++++++++----------- .../broadcom/brcm80211/brcmfmac/cfg80211.h | 2 + .../broadcom/brcm80211/brcmfmac/cyw/core.c | 28 ++++++++++ .../broadcom/brcm80211/brcmfmac/fwil.c | 1 + .../broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- .../broadcom/brcm80211/brcmfmac/fwvid.h | 13 +++++ .../broadcom/brcm80211/brcmfmac/wcc/core.c | 9 +++ 7 files changed, 76 insertions(+), 35 deletions(-)drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +22
-34@@ -32,6 +32,7 @@#include "vendor.h" #include "bus.h" #include "common.h" +#include "fwvid.h" #define BRCMF_SCAN_IE_LEN_MAX 2048@@ -1687,52 +1688,39 @@ static u16 brcmf_map_fw_linkdown_reason(const struct brcmf_event_msg *e)return reason; } -static int brcmf_set_pmk (struct brcmf_if *ifp,const u8 *pmk_data,u16 pmk_len) +int brcmf_set_wsec (struct brcmf_if *ifp,const u8 *key,u16 key_len,u16 flags) {struct brcmf_pub *drvr = ifp->drvr;struct brcmf_wsec_pmk_le pmk;int err; +if (key_len >sizeof (pmk.key)) { +bphy_err (drvr,"key must be less than %zu bytes\n" , +sizeof (pmk.key)); +return -EINVAL ; + } +memset (&pmk,0 ,sizeof (pmk)); -/* pass pmk directly */ - pmk.key_len =cpu_to_le16 (pmk_len); - pmk.flags =cpu_to_le16 (0 ); -memcpy (pmk.key, pmk_data, pmk_len); +/* pass key material directly */ + pmk.key_len =cpu_to_le16 (key_len); + pmk.flags =cpu_to_le16 (flags); +memcpy (pmk.key, key, key_len); -/* store psk in firmware */ +/* store key material in firmware */ err =brcmf_fil_cmd_data_set (ifp,BRCMF_C_SET_WSEC_PMK , &pmk,sizeof (pmk));if (err <0 )bphy_err (drvr,"failed to change PSK in firmware (len=%u)\n" , - pmk_len); + key_len);return err; } +BRCMF_EXPORT_SYMBOL_GPL (brcmf_set_wsec); -static int brcmf_set_sae_password (struct brcmf_if *ifp,const u8 *pwd_data, -u16 pwd_len) +static int brcmf_set_pmk (struct brcmf_if *ifp,const u8 *pmk_data,u16 pmk_len) { -struct brcmf_pub *drvr = ifp->drvr; -struct brcmf_wsec_sae_pwd_le sae_pwd; -int err; - -if (pwd_len >BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ) { -bphy_err (drvr,"sae_password must be less than %d\n" , -BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ); -return -EINVAL ; - } - - sae_pwd.key_len =cpu_to_le16 (pwd_len); -memcpy (sae_pwd.key, pwd_data, pwd_len); - - err =brcmf_fil_iovar_data_set (ifp,"sae_password" , &sae_pwd, -sizeof (sae_pwd)); -if (err <0 ) -bphy_err (drvr,"failed to set SAE password in firmware (len=%u)\n" , - pwd_len); - -return err; +return brcmf_set_wsec (ifp, pmk_data, pmk_len,0 ); } static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason,@@ -2503,8 +2491,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,bphy_err (drvr,"failed to clean up user-space RSNE\n" ); goto done; } - err =brcmf_set_sae_password (ifp, sme->crypto.sae_pwd, - sme->crypto.sae_pwd_len); + err =brcmf_fwvid_set_sae_password (ifp, &sme->crypto);if (!err && sme->crypto.psk) err =brcmf_set_pmk (ifp, sme->crypto.psk,BRCMF_WSEC_MAX_PSK_LEN );@@ -5252,8 +5239,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,if (crypto->sae_pwd) {brcmf_dbg (INFO ,"using SAE offload\n" ); profile->use_fwauth |=BIT (BRCMF_PROFILE_FWAUTH_SAE ); - err =brcmf_set_sae_password (ifp, crypto->sae_pwd, - crypto->sae_pwd_len); + err =brcmf_fwvid_set_sae_password (ifp, crypto);if (err <0 ) goto exit; }@@ -5360,10 +5346,12 @@ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev,msleep (400 );if (profile->use_fwauth !=BIT (BRCMF_PROFILE_FWAUTH_NONE )) { +struct cfg80211_crypto_settings crypto = {}; +if (profile->use_fwauth &BIT (BRCMF_PROFILE_FWAUTH_PSK ))brcmf_set_pmk (ifp,NULL ,0 );if (profile->use_fwauth &BIT (BRCMF_PROFILE_FWAUTH_SAE )) -brcmf_set_sae_password (ifp,NULL ,0 ); +brcmf_fwvid_set_sae_password (ifp, &crypto); profile->use_fwauth =BIT (BRCMF_PROFILE_FWAUTH_NONE ); }drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h +2
-0@@ -468,4 +468,6 @@ void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);void brcmf_abort_scanning (struct brcmf_cfg80211_info *cfg);void brcmf_cfg80211_free_netdev (struct net_device *ndev); +int brcmf_set_wsec (struct brcmf_if *ifp,const u8 *key,u16 key_len,u16 flags); +#endif /* BRCMFMAC_CFG80211_H */ drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c +28
-0@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <fwil.h> #include "vops.h" @@ -21,7 +22,34 @@ static void brcmf_cyw_detach(struct brcmf_pub *drvr)pr_err ("%s: executing\n" , __func__); } +static int brcmf_cyw_set_sae_pwd (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +struct brcmf_pub *drvr = ifp->drvr; +struct brcmf_wsec_sae_pwd_le sae_pwd; +u16 pwd_len = crypto->sae_pwd_len; +int err; + +if (pwd_len >BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ) { +bphy_err (drvr,"sae_password must be less than %d\n" , +BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ); +return -EINVAL ; + } + + sae_pwd.key_len =cpu_to_le16 (pwd_len); +memcpy (sae_pwd.key, crypto->sae_pwd, pwd_len); + + err =brcmf_fil_iovar_data_set (ifp,"sae_password" , &sae_pwd, +sizeof (sae_pwd)); +if (err <0 ) +bphy_err (drvr,"failed to set SAE password in firmware (len=%u)\n" , + pwd_len); + +return err; +} +const struct brcmf_fwvid_ops brcmf_cyw_ops = { .attach = brcmf_cyw_attach, .detach = brcmf_cyw_detach, + .set_sae_password = brcmf_cyw_set_sae_pwd, };drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +1
-0@@ -211,6 +211,7 @@ brcmf_fil_iovar_data_set(struct brcmf_if *ifp, const char *name, const void *datmutex_unlock (&drvr->proto_block);return err; } +BRCMF_EXPORT_SYMBOL_GPL (brcmf_fil_iovar_data_set); s32 brcmf_fil_iovar_data_get(struct brcmf_if *ifp, const char *name, void *data,drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +1
-1@@ -584,7 +584,7 @@ struct brcmf_wsec_key_le {struct brcmf_wsec_pmk_le {__le16 key_len;__le16 flags; -u8 key[2 *BRCMF_WSEC_MAX_PSK_LEN +1 ]; +u8 key[BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ]; };/** drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h +13
-0@@ -6,6 +6,7 @@#define FWVID_H_ #include "firmware.h" +#include "cfg80211.h" struct brcmf_pub ;struct brcmf_if ;@@ -14,6 +15,7 @@ struct brcmf_fwvid_ops {int (*attach)(struct brcmf_pub *drvr);void (*detach)(struct brcmf_pub *drvr);void (*feat_attach)(struct brcmf_if *ifp); +int (*set_sae_password)(struct brcmf_if *ifp,struct cfg80211_crypto_settings *crypto); };/* exported functions */ @@ -56,4 +58,15 @@ static inline void brcmf_fwvid_feat_attach(struct brcmf_if *ifp) vops->feat_attach(ifp); } +static inline int brcmf_fwvid_set_sae_password (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; + +if (!vops || !vops->set_sae_password) +return -EOPNOTSUPP ; + +return vops->set_sae_password (ifp, crypto); +} +#endif /* FWVID_H_ */ drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/core.c +9
-1@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <fwil.h> #include "vops.h" @@ -21,7 +22,15 @@ static void brcmf_wcc_detach(struct brcmf_pub *drvr)pr_debug ("%s: executing\n" , __func__); } +static int brcmf_wcc_set_sae_pwd (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +return brcmf_set_wsec (ifp, crypto->sae_pwd, crypto->sae_pwd_len, +BRCMF_WSEC_PASSPHRASE ); +} +const struct brcmf_fwvid_ops brcmf_wcc_ops = { .attach = brcmf_wcc_attach, .detach = brcmf_wcc_detach, + .set_sae_password = brcmf_wcc_set_sae_pwd, }; --
Quoted 2 lines
2.32.0
Though my R-b tag is there already from the previous version, this patch still looks good to me to land.
Thanks for adapting it for the multi-vendor framework. :)
--
真実はいつも一つ!/ Always, there's only one truth!
Re: [PATCH V2 4/4] wifi: brcmfmac: cfg80211: Use WSEC to set SAE password
In reply to Arend van SprielQuoted 11 lines · Arend van Spriel
From: Hector Martin <[email protected]>
Using the WSEC command instead of
sae_passwordseems to be the supported mechanism on newer firmware, and also how the brcmdhd driver does it.According to user reports [1], the
sae_passwordcodepath doesn't actually work on machines with Cypress chips anyway, so no harm in removing it.This makes WPA3 work with iwd, or with
wpa_supplicantpending a support patchset [2].
Quoted 7 lines
[1] https://rachelbythebay.com/w/2023/11/06/wpa3/
[2] http://lists.infradead.org/pipermail/hostap/2023-July/041653.htmlSigned-off-by Hector Martin <[email protected]>Reviewed-by Neal Gompa <[email protected]>[[email protected]: use multi-vendor framework]Signed-off-by Arend van Spriel <[email protected]>
Should we also update the commit message to match the code? We are not removing the Cypress codepath anymore, right?
I can do the update, just let me know what to add. Preferably something I can just copy&paste.
Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Arend van Spriel
maintainerRe: [PATCH V2 4/4] wifi: brcmfmac: cfg80211: Use WSEC to set SAE password
Quoted 9 lines · Kalle Valo
Quoted 7 lines · Arend van Spriel
From: Hector Martin <[email protected]>
Using the WSEC command instead of
sae_passwordseems to be the supported mechanism on newer firmware, and also how the brcmdhd driver does it.According to user reports [1], the
sae_passwordcodepath doesn't actually work on machines with Cypress chips anyway, so no harm in removing it.
Replace above paragraph with:
The existing firmware mechanism intended for (some) Cypress chips has been separated from the new firmware mechanism using the multi-vendor framework. Depending on the device it will select the appropriate firmware mechanism.
Regards,
Arend
Quoted 17 lines
Quoted 10 lines
This makes WPA3 work with iwd, or with
wpa_supplicantpending a support patchset [2].[1] https://rachelbythebay.com/w/2023/11/06/wpa3/
[2] http://lists.infradead.org/pipermail/hostap/2023-July/041653.htmlSigned-off-by Hector Martin <[email protected]>Reviewed-by Neal Gompa <[email protected]>[[email protected]: use multi-vendor framework]Signed-off-by Arend van Spriel <[email protected]>Should we also update the commit message to match the code? We are not removing the Cypress codepath anymore, right?
I can do the update, just let me know what to add. Preferably something I can just copy&paste.