From a9dc891b65c4a27c744919ef9096dc03814ccbae Mon Sep 17 00:00:00 2001
From: Chien-Chia Chen <carella.chen@infineon.com>
Date: Thu, 18 Nov 2021 03:22:26 -0600
Subject: [PATCH] brcmfmac: support extsae with psk / 1x offloading

support sae executed in wpa_supplicant and offload 4-way handshake offload.

Signed-off-by: Chien-Chia Chen <carella.chen@infineon.com>

JIRA: SWWLAN-142424
---
 .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c   | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -2184,6 +2184,11 @@ brcmf_set_key_mgmt(struct net_device *nd
 		switch (sme->crypto.akm_suites[0]) {
 		case WLAN_AKM_SUITE_SAE:
 			val = WPA3_AUTH_SAE_PSK;
+			if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_FWSUP) &&
+				brcmf_feat_is_enabled(ifp, BRCMF_FEAT_SAE_EXT)) {
+				brcmf_dbg(INFO, "using EXTSAE with PSK offload\n");
+				profile->use_fwsup = BRCMF_PROFILE_FWSUP_PSK;
+			}
 			break;
 		case WLAN_AKM_SUITE_FT_OVER_SAE:
 			val = WPA3_AUTH_SAE_PSK | WPA2_AUTH_FT;
@@ -2486,7 +2491,8 @@ brcmf_cfg80211_connect(struct wiphy *wip
 
 	if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_FWSUP)) {
 		if (sme->crypto.psk) {
-			if (profile->use_fwsup != BRCMF_PROFILE_FWSUP_SAE) {
+			if ((profile->use_fwsup != BRCMF_PROFILE_FWSUP_SAE) &&
+				(profile->use_fwsup != BRCMF_PROFILE_FWSUP_PSK)) {
 				if (WARN_ON(profile->use_fwsup !=
 					BRCMF_PROFILE_FWSUP_NONE)) {
 					err = -EINVAL;
@@ -2510,7 +2516,8 @@ brcmf_cfg80211_connect(struct wiphy *wip
 			err = brcmf_fil_iovar_int_set(ifp, "sup_wpa", 0);
 		}
 
-		if (profile->use_fwsup == BRCMF_PROFILE_FWSUP_PSK) {
+		if ((profile->use_fwsup == BRCMF_PROFILE_FWSUP_PSK) &&
+			sme->crypto.psk) {
 			err = brcmf_set_pmk(ifp, sme->crypto.psk,
 					    BRCMF_WSEC_MAX_PSK_LEN);
 		} else if (profile->use_fwsup == BRCMF_PROFILE_FWSUP_SAE) {
