1 // SPDX-License-Identifier: ISC 2 /* 3 * Copyright (c) 2022 Broadcom Corporation 4 */ 5 #include <linux/errno.h> 6 #include <linux/types.h> 7 #include <core.h> 8 #include <bus.h> 9 #include <fwvid.h> 10 #include <fwil.h> 11 12 #include "vops.h" 13 14 static int brcmf_cyw_set_sae_pwd(struct brcmf_if *ifp, 15 struct cfg80211_crypto_settings *crypto) 16 { 17 struct brcmf_pub *drvr = ifp->drvr; 18 struct brcmf_wsec_sae_pwd_le sae_pwd; 19 u16 pwd_len = crypto->sae_pwd_len; 20 int err; 21 22 if (pwd_len > BRCMF_WSEC_MAX_SAE_PASSWORD_LEN) { 23 bphy_err(drvr, "sae_password must be less than %d\n", 24 BRCMF_WSEC_MAX_SAE_PASSWORD_LEN); 25 return -EINVAL; 26 } 27 28 sae_pwd.key_len = cpu_to_le16(pwd_len); 29 memcpy(sae_pwd.key, crypto->sae_pwd, pwd_len); 30 31 err = brcmf_fil_iovar_data_set(ifp, "sae_password", &sae_pwd, 32 sizeof(sae_pwd)); 33 if (err < 0) 34 bphy_err(drvr, "failed to set SAE password in firmware (len=%u)\n", 35 pwd_len); 36 37 return err; 38 } 39 40 const struct brcmf_fwvid_ops brcmf_cyw_ops = { 41 .set_sae_password = brcmf_cyw_set_sae_pwd, 42 }; 43