* [PATCH v4 161/161] NetworkPkg: Add WiFi profile sync protocol support [not found] <9102518d297546d349e9dcbaf9a87706ec8529e0.1664830666.git.zachary.clark-williams@intel.com> @ 2022-10-04 17:04 ` Clark-williams, Zachary [not found] ` <CO6PR11MB5601C36E75AF5A715C47ED7FC9339@CO6PR11MB5601.namprd11.prod.outlook.com> 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-10-04 17:04 UTC (permalink / raw) To: devel Cc: Zachary Clark-Williams, Maciej Rabeda, Fu Siyuan, Wu Jiaxin, Andrei Otcheretianski, Zachary Clark-Williams From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries +// +extern UINT8 mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, (StrLen (Profile->Password) + 1)); + if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send for + another connection attempt.This function should not be called more than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); + if (Nic == NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); + } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get Supported suites with status %r\n", Status)); + } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); + } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is performing a recovery boot in secure + // boot mode. The profile sync driver will manage the CA certificate, client certificate, and key + // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
[parent not found: <CO6PR11MB5601C36E75AF5A715C47ED7FC9339@CO6PR11MB5601.namprd11.prod.outlook.com>]
[parent not found: <CO1PR11MB4929BAD03309A5606C0AA851D2339@CO1PR11MB4929.namprd11.prod.outlook.com>]
* Re: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support [not found] ` <CO1PR11MB4929BAD03309A5606C0AA851D2339@CO1PR11MB4929.namprd11.prod.outlook.com> @ 2022-10-28 20:09 ` Clark-williams, Zachary 2022-10-28 20:13 ` Clark-williams, Zachary 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-10-28 20:09 UTC (permalink / raw) To: Kinney, Michael D, Rabeda, Maciej, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-10-28 20:09 ` [PATCH v4] NetworkPkg/WifiProfileSync: " Clark-williams, Zachary @ 2022-10-28 20:13 ` Clark-williams, Zachary 2022-10-31 19:31 ` Clark-williams, Zachary 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-10-28 20:13 UTC (permalink / raw) To: Kinney, Michael D, Rabeda, Maciej, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io, Fu, Siyuan, Wu, Jiaxin, Otcheretianski, Andrei ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-10-28 20:13 ` Clark-williams, Zachary @ 2022-10-31 19:31 ` Clark-williams, Zachary [not found] ` <MWHPR11MB00649E049DBD36906E8E24B288379@MWHPR11MB0064.namprd11.prod.outlook.com> 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-10-31 19:31 UTC (permalink / raw) To: Kinney, Michael D, Rabeda, Maciej, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io, 'Fu, Siyuan', Wu, Jiaxin, Otcheretianski, Andrei Cc: Alappat, Paul, Kasbekar, Saloni, Patil, Ajit ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
[parent not found: <MWHPR11MB00649E049DBD36906E8E24B288379@MWHPR11MB0064.namprd11.prod.outlook.com>]
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support [not found] ` <MWHPR11MB00649E049DBD36906E8E24B288379@MWHPR11MB0064.namprd11.prod.outlook.com> @ 2022-11-01 17:34 ` Clark-williams, Zachary 2022-11-01 17:39 ` Zimmer, Vincent 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-11-01 17:34 UTC (permalink / raw) To: Zimmer, Vincent, Rabeda, Maciej, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io, Wu, Jiaxin, Otcheretianski, Andrei Cc: Alappat, Paul, Kasbekar, Saloni, Patil, Ajit Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-11-01 17:34 ` [edk2-devel] " Clark-williams, Zachary @ 2022-11-01 17:39 ` Zimmer, Vincent 2022-11-01 17:41 ` Clark-williams, Zachary 0 siblings, 1 reply; 12+ messages in thread From: Zimmer, Vincent @ 2022-11-01 17:39 UTC (permalink / raw) To: Clark-williams, Zachary, Rabeda, Maciej, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io, Wu, Jiaxin, Otcheretianski, Andrei Cc: Alappat, Paul, Kasbekar, Saloni, Patil, Ajit That's great If these links are not already in the .h files of the patch I'd add them. Typically the uefi networking code leverages uefi spec or ietf rfc's or other public collateral. Letting folks know the background of these interfaces with a reference should help consumers IMHO Vincent -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 10:35 AM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-11-01 17:39 ` Zimmer, Vincent @ 2022-11-01 17:41 ` Clark-williams, Zachary 2022-11-02 12:35 ` Rabeda, Maciej 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-11-01 17:41 UTC (permalink / raw) To: Zimmer, Vincent, Rabeda, Maciej, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io, Wu, Jiaxin, Otcheretianski, Andrei Cc: Alappat, Paul, Kasbekar, Saloni, Patil, Ajit Great thank you Vincent, I will add them to the protocol header file and send an updated patch today. -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Tuesday, November 1, 2022 10:39 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support That's great If these links are not already in the .h files of the patch I'd add them. Typically the uefi networking code leverages uefi spec or ietf rfc's or other public collateral. Letting folks know the background of these interfaces with a reference should help consumers IMHO Vincent -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 10:35 AM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-11-01 17:41 ` Clark-williams, Zachary @ 2022-11-02 12:35 ` Rabeda, Maciej 2022-11-02 15:57 ` Clark-williams, Zachary [not found] ` <1723CFBA04C671AE.15522@groups.io> 0 siblings, 2 replies; 12+ messages in thread From: Rabeda, Maciej @ 2022-11-02 12:35 UTC (permalink / raw) To: Clark-williams, Zachary, Zimmer, Vincent, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io, Wu, Jiaxin, Otcheretianski, Andrei, Kasbekar, Saloni, Kinney, Michael D Cc: Alappat, Paul, Patil, Ajit @Kinney, Michael D With the amount of work around IPUs, I can hardly spare time (maybe 2h/week on average - including code). My time for EDK2 is currently fully allocated to: 1. https://github.com/tianocore/edk2-staging/tree/HttpProxy (@Kasbekar, Saloni) 2. NVMe-oF boot prototype under nvme.org umbrella (@Zimmer, Vincent) @Clark-williams, Zachary Your patch is non-trivial and requires understanding on my side. Based on that and the above, this will take time. -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 6:41 PM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Great thank you Vincent, I will add them to the protocol header file and send an updated patch today. -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Tuesday, November 1, 2022 10:39 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support That's great If these links are not already in the .h files of the patch I'd add them. Typically the uefi networking code leverages uefi spec or ietf rfc's or other public collateral. Letting folks know the background of these interfaces with a reference should help consumers IMHO Vincent -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 10:35 AM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited. ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-11-02 12:35 ` Rabeda, Maciej @ 2022-11-02 15:57 ` Clark-williams, Zachary [not found] ` <1723CFBA04C671AE.15522@groups.io> 1 sibling, 0 replies; 12+ messages in thread From: Clark-williams, Zachary @ 2022-11-02 15:57 UTC (permalink / raw) To: Rabeda, Maciej, Zimmer, Vincent, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, devel@edk2.groups.io, Wu, Jiaxin, Otcheretianski, Andrei, Kasbekar, Saloni, Kinney, Michael D Cc: Alappat, Paul, Patil, Ajit Hey Maciej, I can understand that and appreciate the attention you can spare for reviewing this change. If there are any peers you know who can/will want to review or have valuable input on this PR please feel free to send them an invite to review. Thanks, Zack -----Original Message----- From: Rabeda, Maciej <maciej.rabeda@intel.com> Sent: Wednesday, November 2, 2022 5:35 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support @Kinney, Michael D With the amount of work around IPUs, I can hardly spare time (maybe 2h/week on average - including code). My time for EDK2 is currently fully allocated to: 1. https://github.com/tianocore/edk2-staging/tree/HttpProxy (@Kasbekar, Saloni) 2. NVMe-oF boot prototype under nvme.org umbrella (@Zimmer, Vincent) @Clark-williams, Zachary Your patch is non-trivial and requires understanding on my side. Based on that and the above, this will take time. -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 6:41 PM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Great thank you Vincent, I will add them to the protocol header file and send an updated patch today. -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Tuesday, November 1, 2022 10:39 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support That's great If these links are not already in the .h files of the patch I'd add them. Typically the uefi networking code leverages uefi spec or ietf rfc's or other public collateral. Letting folks know the background of these interfaces with a reference should help consumers IMHO Vincent -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 10:35 AM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
[parent not found: <1723CFBA04C671AE.15522@groups.io>]
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support [not found] ` <1723CFBA04C671AE.15522@groups.io> @ 2022-12-06 18:38 ` Clark-williams, Zachary 2022-12-06 18:41 ` Clark-williams, Zachary 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-12-06 18:38 UTC (permalink / raw) To: devel@edk2.groups.io, Clark-williams, Zachary, Rabeda, Maciej, Zimmer, Vincent, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, Wu, Jiaxin, Otcheretianski, Andrei, Kasbekar, Saloni, Kinney, Michael D Cc: Alappat, Paul, Patil, Ajit Hey Maciej and All, Is there any update in ability to review this patch for Wifi Profile Sync Protocol and Wifi Connection Manager? Thank you, Zack -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Wednesday, November 2, 2022 8:58 AM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Maciej, I can understand that and appreciate the attention you can spare for reviewing this change. If there are any peers you know who can/will want to review or have valuable input on this PR please feel free to send them an invite to review. Thanks, Zack -----Original Message----- From: Rabeda, Maciej <maciej.rabeda@intel.com> Sent: Wednesday, November 2, 2022 5:35 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support @Kinney, Michael D With the amount of work around IPUs, I can hardly spare time (maybe 2h/week on average - including code). My time for EDK2 is currently fully allocated to: 1. https://github.com/tianocore/edk2-staging/tree/HttpProxy (@Kasbekar, Saloni) 2. NVMe-oF boot prototype under nvme.org umbrella (@Zimmer, Vincent) @Clark-williams, Zachary Your patch is non-trivial and requires understanding on my side. Based on that and the above, this will take time. -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 6:41 PM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Great thank you Vincent, I will add them to the protocol header file and send an updated patch today. -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Tuesday, November 1, 2022 10:39 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support That's great If these links are not already in the .h files of the patch I'd add them. Typically the uefi networking code leverages uefi spec or ietf rfc's or other public collateral. Letting folks know the background of these interfaces with a reference should help consumers IMHO Vincent -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 10:35 AM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-12-06 18:38 ` Clark-williams, Zachary @ 2022-12-06 18:41 ` Clark-williams, Zachary 2022-12-15 19:55 ` Clark-williams, Zachary 0 siblings, 1 reply; 12+ messages in thread From: Clark-williams, Zachary @ 2022-12-06 18:41 UTC (permalink / raw) To: devel@edk2.groups.io, Rabeda, Maciej, Zimmer, Vincent, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, Wu, Jiaxin, Otcheretianski, Andrei, Kasbekar, Saloni, Kinney, Michael D, Klos, Lukasz, Sulkowski, Michal Cc: Alappat, Paul, Patil, Ajit ++ Michal's coverage Michal and Lukasz -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, December 6, 2022 10:38 AM To: devel@edk2.groups.io; Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Maciej and All, Is there any update in ability to review this patch for Wifi Profile Sync Protocol and Wifi Connection Manager? Thank you, Zack -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Wednesday, November 2, 2022 8:58 AM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Maciej, I can understand that and appreciate the attention you can spare for reviewing this change. If there are any peers you know who can/will want to review or have valuable input on this PR please feel free to send them an invite to review. Thanks, Zack -----Original Message----- From: Rabeda, Maciej <maciej.rabeda@intel.com> Sent: Wednesday, November 2, 2022 5:35 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support @Kinney, Michael D With the amount of work around IPUs, I can hardly spare time (maybe 2h/week on average - including code). My time for EDK2 is currently fully allocated to: 1. https://github.com/tianocore/edk2-staging/tree/HttpProxy (@Kasbekar, Saloni) 2. NVMe-oF boot prototype under nvme.org umbrella (@Zimmer, Vincent) @Clark-williams, Zachary Your patch is non-trivial and requires understanding on my side. Based on that and the above, this will take time. -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 6:41 PM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Great thank you Vincent, I will add them to the protocol header file and send an updated patch today. -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Tuesday, November 1, 2022 10:39 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support That's great If these links are not already in the .h files of the patch I'd add them. Typically the uefi networking code leverages uefi spec or ietf rfc's or other public collateral. Letting folks know the background of these interfaces with a reference should help consumers IMHO Vincent -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 10:35 AM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support 2022-12-06 18:41 ` Clark-williams, Zachary @ 2022-12-15 19:55 ` Clark-williams, Zachary 0 siblings, 0 replies; 12+ messages in thread From: Clark-williams, Zachary @ 2022-12-15 19:55 UTC (permalink / raw) To: devel@edk2.groups.io, Rabeda, Maciej, Zimmer, Vincent, Luo, Heng, Kuo, Scottie, Kuo, Ted, Dutkiewicz, Michal, Wu, Jiaxin, Otcheretianski, Andrei, Kasbekar, Saloni, Kinney, Michael D, Klos, Lukasz, Sulkowski, Michal Cc: Alappat, Paul, Patil, Ajit Hey All, Anyone able to review the EDK2 Network Pkg patch I've submitted? The patch is below in the original email. Let me know if you'd like a fresh patch file. Thanks, Zack -----Original Message----- From: Clark-williams, Zachary Sent: Tuesday, December 6, 2022 10:42 AM To: devel@edk2.groups.io; Rabeda, Maciej <maciej.rabeda@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Klos, Lukasz <Lukasz.Klos@intel.com>; Sulkowski, Michal <michal.sulkowski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ Michal's coverage Michal and Lukasz -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, December 6, 2022 10:38 AM To: devel@edk2.groups.io; Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Maciej and All, Is there any update in ability to review this patch for Wifi Profile Sync Protocol and Wifi Connection Manager? Thank you, Zack -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Wednesday, November 2, 2022 8:58 AM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Maciej, I can understand that and appreciate the attention you can spare for reviewing this change. If there are any peers you know who can/will want to review or have valuable input on this PR please feel free to send them an invite to review. Thanks, Zack -----Original Message----- From: Rabeda, Maciej <maciej.rabeda@intel.com> Sent: Wednesday, November 2, 2022 5:35 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Zimmer, Vincent <vincent.zimmer@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support @Kinney, Michael D With the amount of work around IPUs, I can hardly spare time (maybe 2h/week on average - including code). My time for EDK2 is currently fully allocated to: 1. https://github.com/tianocore/edk2-staging/tree/HttpProxy (@Kasbekar, Saloni) 2. NVMe-oF boot prototype under nvme.org umbrella (@Zimmer, Vincent) @Clark-williams, Zachary Your patch is non-trivial and requires understanding on my side. Based on that and the above, this will take time. -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 6:41 PM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Great thank you Vincent, I will add them to the protocol header file and send an updated patch today. -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Tuesday, November 1, 2022 10:39 AM To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support That's great If these links are not already in the .h files of the patch I'd add them. Typically the uefi networking code leverages uefi spec or ietf rfc's or other public collateral. Letting folks know the background of these interfaces with a reference should help consumers IMHO Vincent -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Tuesday, November 1, 2022 10:35 AM To: Zimmer, Vincent <vincent.zimmer@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Vincent, The documentation for describing the features in the PR description can be found in the CSME documentation found on the public accessible intel link below. OCR - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm KVM - https://software.intel.com/sites/manageability/AMT_Implementation_and_Reference_Guide/default.htm?turl=WordDocuments%2Foneclickrecovery.htm Thanks, Zack -----Original Message----- From: Zimmer, Vincent <vincent.zimmer@intel.com> Sent: Monday, October 31, 2022 2:16 PM To: Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: RE: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Quick question Are the features described in " Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT." in a public document? Things like concept of profile sync? I'm guessing they are since Linux probably does the same in the intel iwl driver? Vincent -----Original Message----- From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Clark-williams, Zachary Sent: Monday, October 31, 2022 12:31 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; 'Fu, Siyuan' <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Cc: Alappat, Paul <paul.alappat@intel.com>; Kasbekar, Saloni <saloni.kasbekar@intel.com>; Patil, Ajit <ajit.patil@intel.com> Subject: Re: [edk2-devel] [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++ visibility -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:13 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io; Fu, Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com> Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support ++More for reviewal! -----Original Message----- From: Clark-williams, Zachary Sent: Friday, October 28, 2022 1:10 PM To: Kinney, Michael D <michael.d.kinney@intel.com>; Rabeda, Maciej <maciej.rabeda@intel.com>; Luo, Heng <heng.luo@intel.com>; Kuo, Scottie <scottie.kuo@intel.com>; Kuo, Ted <ted.kuo@intel.com>; Dutkiewicz, Michal <michal.dutkiewicz@intel.com>; devel@edk2.groups.io Subject: RE: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Thanks for the forward Mike! Maciej and All, If you could please review the PR below. I would like to get this review completed within the week. Thanks, Zack -----Original Message----- From: Kinney, Michael D <michael.d.kinney@intel.com> Sent: Thursday, October 27, 2022 1:09 PM To: Rabeda, Maciej <maciej.rabeda@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hi Maciej, Can you please help review these NetworkPkg changes. I am not sure if you monitor your linux.intel.com account as closely as your intel.com account. Thanks, Mike -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:33 PM To: Kinney, Michael D <michael.d.kinney@intel.com> Subject: FW: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support Hey Mike, I'm struggling to get any feedback on this PR. Do you have any suggestions to get better visibility and responses so I can get this miving? Thanks, Zack -----Original Message----- From: Clark-williams, Zachary <zachary.clark-williams@intel.com> Sent: Thursday, October 27, 2022 12:31 PM To: devel@edk2.groups.io Cc: Zachary Clark-Williams <zclarkw112@gmail.com>; Maciej Rabeda <maciej.rabeda@linux.intel.com>; Fu Siyuan <siyuan.fu@intel.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Otcheretianski, Andrei <andrei.otcheretianski@intel.com>; Clark-williams, Zachary <zachary.clark-williams@intel.com> Subject: [PATCH v4] NetworkPkg/WifiProfileSync: Add WiFi profile sync protocol support From: Zachary Clark-Williams <zclarkw112@gmail.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3845 Enables KVM and One Click Recovery WLAN capability with WiFi Profile Sync feature and protocol. Adding WiFiProfileSyncProtocol, which supports the profilesync driver operations for transferring WiFi profiles from AMT to the Supplicant. WiFiConnectionManager will check for the WifiProfileSyncProtocol and if found will operate on the premise of a One Click Recovery, or KVM flow with a Wifi profile provided by AMT. Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Cc: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Signed-off-by: Zachary Clark-Williams <zachary.clark-williams@intel.com> --- .../Protocol/WiFiProfileSyncProtocol.h | 83 ++++++++ NetworkPkg/NetworkPkg.dec | 3 + .../WifiConnectionManagerDxe.inf | 3 +- .../WifiConnectionMgrConfigNVDataStruct.h | 2 +- .../WifiConnectionMgrDriver.c | 126 ++++++++---- .../WifiConnectionMgrDxe.h | 4 +- .../WifiConnectionMgrImpl.c | 193 ++++++++++++++++-- .../WifiConnectionMgrMisc.c | 13 ++ 8 files changed, 367 insertions(+), 60 deletions(-) create mode 100644 NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h diff --git a/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h new file mode 100644 index 0000000000..e36daceabf --- /dev/null +++ b/NetworkPkg/Include/Protocol/WiFiProfileSyncProtocol.h @@ -0,0 +1,83 @@ +/** @file + WiFi profile sync protocol. Supports One Click Recovery or KVM OS +recovery + boot flow over WiFi. + + Copyright (c) 2022, Intel Corporation. All rights reserved.<BR> + + SPDX-License-Identifier: BSD-2-Clause-Patent **/ + +#ifndef WIFI_PROFILE_SYNC_PROTOCOL_H_ +#define WIFI_PROFILE_SYNC_PROTOCOL_H_ + +#include <WifiConnectionManagerDxe/WifiConnectionMgrConfig.h> + +// +// WiFi Profile Sync Protocol GUID variable. +// +extern EFI_GUID gEfiWiFiProfileSyncProtocolGuid; + +/** + Used by the WiFi connection manager to get the WiFi profile that AMT +shared + and was stored in WiFi profile protocol. Aligns the AMT WiFi profile +data to + the WiFi connection manager profile structure fo connection use. + + @param[in, out] WcmProfile WiFi Connection Manager profile structure + @param[in, out] MacAddress MAC address from AMT saved to NiC MAC address + + @retval EFI_SUCCESS Stored WiFi profile converted and returned succefully + @retval EFI_UNSUPPORTED Profile protocol sharing not supported or enabled + @retval EFI_NOT_FOUND No profiles to returned + @retval Others Error Occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_PROFILE_GET)( + IN OUT WIFI_MGR_NETWORK_PROFILE *Profile, + IN OUT EFI_80211_MAC_ADDRESS MacAddress + ); + +/** + Saves the WiFi connection status recieved by the +WiFiConnectionManager when + in a KVM OR One Click Recovery WLAN recovery flow. Input as + EFI_80211_CONNECT_NETWORK_RESULT_CODE then converted and stored as EFI_STATUS type. + + @param[in] ConnectionStatus WiFi connection attempt results +**/ +typedef +VOID +(EFIAPI *WIFI_SET_CONNECT_STATE)( + IN EFI_80211_CONNECT_NETWORK_RESULT_CODE ConnectionStatus + ); + +/** + Retrieves the stored WiFi connection status when in either KVM OR One +Click + Recovery WLAN recovery flow. + + @retval EFI_SUCCESS WiFi connection completed succesfully + @retval Others Connection failure occurred +**/ +typedef +EFI_STATUS +(EFIAPI *WIFI_GET_CONNECT_STATE)( + VOID + ); + +// +// WiFi Profile Sync Protocol structure. +// +typedef struct { + UINT32 Revision; + WIFI_SET_CONNECT_STATE WifiProfileSyncSetConnectState; + WIFI_GET_CONNECT_STATE WifiProfileSyncGetConnectState; + WIFI_PROFILE_GET WifiProfileSyncGetProfile; +} EFI_WIFI_PROFILE_SYNC_PROTOCOL; + +/** + WiFi Profile Protocol revision number. + + Revision 1: Initial version +**/ +#define EFI_WIFI_PROFILE_SYNC_PROTOCOL_REVISION 1 + +#endif // WIFI_PROFILE_SYNC_PROTOCOL_H_ diff --git a/NetworkPkg/NetworkPkg.dec b/NetworkPkg/NetworkPkg.dec index 5e43ebf8c5..53fb34c4a0 100644 --- a/NetworkPkg/NetworkPkg.dec +++ b/NetworkPkg/NetworkPkg.dec @@ -91,6 +91,9 @@ ## Include/Protocol/HttpCallback.h gEdkiiHttpCallbackProtocolGuid = {0x611114f1, 0xa37b, 0x4468, {0xa4, 0x36, 0x5b, 0xdd, 0xa1, 0x6a, 0xa2, 0x40}} + ## Include/Protocol/WiFiProfileSyncProtocol.h + gEfiWiFiProfileSyncProtocolGuid = {0x399a2b8a, 0xc267, 0x44aa, {0x9a, + 0xb4, 0x30, 0x58, 0x8c, 0xd2, 0x2d, 0xcc}} + [PcdsFixedAtBuild] ## The max attempt number will be created by iSCSI driver. # @Prompt Max attempt number. diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf index 4394b6f4bb..7e36016cf8 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionManagerDxe.inf @@ -9,7 +9,7 @@ # 2). WPA2 Personal Network # 3). EAP Networks (EAP-TLS, EAP-TTLS/MSCHAPv2 and PEAPv0/MSCHAPv2) # -# Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> +# Copyright (c) 2019 - 2022, Intel Corporation. All rights +reserved.<BR> # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -71,6 +71,7 @@ gEfiAdapterInformationProtocolGuid ## SOMETIMES_CONSUMES gEfiSupplicantProtocolGuid ## SOMETIMES_CONSUMES gEfiEapConfigurationProtocolGuid ## SOMETIMES_CONSUMES + gEfiWiFiProfileSyncProtocolGuid ## SOMETIMES_CONSUMES [Guids] gWifiConfigGuid ## PRODUCES ## GUID diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h index b5518a74d8..dcc4bf7e27 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataStruct.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrConfigNVDataS +++ truct.h @@ -25,7 +25,7 @@ #define PASSWORD_MIN_LEN 8 #define PASSWORD_MAX_LEN 63 -#define PASSWORD_STORAGE_SIZE 64 +#define PASSWORD_STORAGE_SIZE 65 #define EAP_IDENTITY_LEN 63 #define EAP_IDENTITY_SIZE 64 diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c index 67a01ca058..97ca7a9f0b 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDriver.c @@ -1,7 +1,7 @@ /** @file The driver binding protocol for the WiFi Connection Manager. - Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> + Copyright (c) 2019 - 2022, Intel Corporation. All rights + reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent @@ -39,6 +39,11 @@ EFI_GUID mWifiConfigNetworkListRefreshGuid = WIFI_CONFIG_NETWORK_LIST_REFRESH_G EFI_GUID mWifiConfigConnectFormRefreshGuid = WIFI_CONFIG_CONNECT_FORM_REFRESH_GUID; EFI_GUID mWifiConfigMainFormRefreshGuid = WIFI_CONFIG_MAIN_FORM_REFRESH_GUID; +// +// Wifi connection attempt counter for retries // extern UINT8 +mWifiConnectionCount; + /** Tests to see if this driver supports a given controller. If a child device is provided, it further tests to see if this driver supports creating a handle for the specified child device. @@ -167,8 +172,10 @@ WifiMgrDxeDriverBindingStart ( EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; EFI_SUPPLICANT_PROTOCOL *Supplicant; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; - Nic = NULL; + mWifiConnectionCount = 0; + Nic = NULL; // // Open Protocols @@ -236,47 +243,73 @@ WifiMgrDxeDriverBindingStart ( InitializeListHead (&Nic->ProfileList); // - // Record the MAC address of the incoming NIC. + // WiFi profile sync protocol installation check for OS recovery flow. // - Status = NetLibGetMacAddress ( - ControllerHandle, - (EFI_MAC_ADDRESS *)&Nic->MacAddress, - &AddressSize - ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } - - // - // Create and start the timer for the status check - // - Status = gBS->CreateEvent ( - EVT_NOTIFY_SIGNAL | EVT_TIMER, - TPL_CALLBACK, - WifiMgrOnTimerTick, - Nic, - &Nic->TickTimer + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol ); - if (EFI_ERROR (Status)) { - goto ERROR2; - } + if (!EFI_ERROR (Status)) { + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ERROR1; + } - Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); - if (EFI_ERROR (Status)) { - goto ERROR3; - } + WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (Nic->ConnectPendingNetwork != NULL) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } else { + goto ERROR1; + } + } else { + // + // Record the MAC address of the incoming NIC. + // + Status = NetLibGetMacAddress ( + ControllerHandle, + (EFI_MAC_ADDRESS *)&Nic->MacAddress, + &AddressSize + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - Nic->ConnectState = WifiMgrDisconnected; - Nic->ScanState = WifiMgrScanFinished; + // + // Create and start the timer for the status check + // + Status = gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL | EVT_TIMER, + TPL_CALLBACK, + WifiMgrOnTimerTick, + Nic, + &Nic->TickTimer + ); + if (EFI_ERROR (Status)) { + goto ERROR2; + } - OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - InsertTailList (&mPrivate->NicList, &Nic->Link); - Nic->NicIndex = mPrivate->NicCount++; - if (mPrivate->CurrentNic == NULL) { - mPrivate->CurrentNic = Nic; - } + Status = gBS->SetTimer (Nic->TickTimer, TimerPeriodic, EFI_TIMER_PERIOD_MILLISECONDS (500)); + if (EFI_ERROR (Status)) { + goto ERROR3; + } - gBS->RestoreTPL (OldTpl); + Nic->ConnectState = WifiMgrDisconnected; + Nic->ScanState = WifiMgrScanFinished; + + OldTpl = gBS->RaiseTPL (TPL_CALLBACK); + InsertTailList (&mPrivate->NicList, &Nic->Link); + Nic->NicIndex = mPrivate->NicCount++; + if (mPrivate->CurrentNic == NULL) { + mPrivate->CurrentNic = Nic; + } + + gBS->RestoreTPL (OldTpl); + } Status = gBS->InstallProtocolInterface ( &ControllerHandle, @@ -385,10 +418,11 @@ WifiMgrDxeDriverBindingStop ( IN EFI_HANDLE *ChildHandleBuffer OPTIONAL ) { - EFI_STATUS Status; - EFI_TPL OldTpl; - WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; - WIFI_MGR_DEVICE_DATA *Nic; + EFI_STATUS Status; + EFI_TPL OldTpl; + WIFI_MGR_PRIVATE_PROTOCOL *WifiMgrIdentifier; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; Status = gBS->OpenProtocol ( ControllerHandle, @@ -481,7 +515,15 @@ WifiMgrDxeDriverBindingStop ( // OldTpl = gBS->RaiseTPL (TPL_CALLBACK); - RemoveEntryList (&Nic->Link); + Status = gBS->LocateProtocol ( + &gEfiWiFiProfileSyncProtocolGuid, + NULL, + (VOID **)&WiFiProfileSyncProtocol + ); + if (EFI_ERROR (Status)) { + RemoveEntryList (&Nic->Link); + } + mPrivate->NicCount--; if (mPrivate->CurrentNic == Nic) { mPrivate->CurrentNic = NULL; diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h index 7b2e41e155..047f85dbc2 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrDxe.h @@ -47,6 +47,7 @@ #include <Protocol/SimpleNetwork.h> #include <Protocol/SimpleFileSystem.h> #include <Protocol/EapConfiguration.h> +#include <Protocol/WiFiProfileSyncProtocol.h> // // Produced Protocols @@ -73,7 +74,8 @@ // #define WIFI_MGR_DXE_VERSION 0xb -#define OUI_IEEE_80211I 0xAC0F00 +#define OUI_IEEE_80211I 0xAC0F00 +#define MAX_WIFI_CONNETION_ATTEMPTS 3 typedef enum { Ieee80211PairwiseCipherSuiteUseGroupCipherSuite = 0, diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 59bac48c42..a73ab9f710 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -19,6 +19,8 @@ EFI_EAP_TYPE mEapSecondAuthMethod[] = { EFI_EAP_TYPE_MSCHAPV2 }; +UINT8 mWifiConnectionCount = 0; + /** The callback function for scan operation. This function updates networks according to the latest scan result, and trigger UI refresh. @@ -424,18 +426,26 @@ WifiMgrConfigPassword ( return EFI_NOT_FOUND; } - AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * sizeof (UINT8)); + if (StrLen (Profile->Password) >= PASSWORD_STORAGE_SIZE) { + ASSERT (EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; + } + + AsciiPassword = AllocateZeroPool ((StrLen (Profile->Password) + 1) * + sizeof (CHAR8)); if (AsciiPassword == NULL) { return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 *)AsciiPassword, PASSWORD_STORAGE_SIZE); - Status = Supplicant->SetData ( - Supplicant, - EfiSupplicant80211PskPassword, - AsciiPassword, - (StrLen (Profile->Password) + 1) * sizeof (UINT8) - ); + Status = UnicodeStrToAsciiStrS (Profile->Password, (CHAR8 + *)AsciiPassword, (StrLen (Profile->Password) + 1)); if (!EFI_ERROR (Status)) { + Status = Supplicant->SetData ( + Supplicant, + EfiSupplicant80211PskPassword, + AsciiPassword, + (StrLen (Profile->Password) + 1) * sizeof (CHAR8) + ); + } + ZeroMem (AsciiPassword, AsciiStrLen ((CHAR8 *)AsciiPassword) + 1); FreePool (AsciiPassword); @@ -466,6 +476,7 @@ WifiMgrConfigEap ( ) { EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; EFI_EAP_TYPE EapAuthMethod; EFI_EAP_TYPE EapSecondAuthMethod; @@ -567,7 +578,13 @@ WifiMgrConfigEap ( return EFI_OUT_OF_RESOURCES; } - UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + } else { + UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); + } + Status = EapConfig->SetData ( EapConfig, EFI_EAP_TYPE_IDENTITY, @@ -892,6 +909,133 @@ WifiMgrPrepareConnection ( return EFI_SUCCESS; } +/** + Will reset NiC data, get profile from profile sync driver, and send +for + another connection attempt.This function should not be called more +than + 3 times. + + @param[in] WiFiProfileSyncProtocol The target network profile to connect. + + @retval EFI_SUCCESS The operation is completed. + @retval other Operation failure. + +**/ +EFI_STATUS +ConnectionRetry ( + IN EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol + ) +{ + EFI_STATUS Status; + WIFI_MGR_DEVICE_DATA *Nic; + EFI_WIRELESS_MAC_CONNECTION_II_PROTOCOL *Wmp; + EFI_SUPPLICANT_PROTOCOL *Supplicant; + EFI_EAP_CONFIGURATION_PROTOCOL *EapConfig; + + Nic = NULL; + + Status = gBS->LocateProtocol ( + &gEfiWiFi2ProtocolGuid, + NULL, + (VOID **)&Wmp + ); + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->LocateProtocol ( + &gEfiSupplicantProtocolGuid, + NULL, + (VOID **)&Supplicant + ); + if (EFI_ERROR (Status)) { + Supplicant = NULL; + } + + Status = gBS->LocateProtocol ( + &gEfiEapConfigurationProtocolGuid, + NULL, + (VOID **)&EapConfig + ); + if (EFI_ERROR (Status)) { + EapConfig = NULL; + } + + // + // Initialize Nic device data + // + Nic = AllocateZeroPool (sizeof (WIFI_MGR_DEVICE_DATA)); if (Nic == + NULL) { + Status = EFI_OUT_OF_RESOURCES; + return Status; + } + + Nic->Signature = WIFI_MGR_DEVICE_DATA_SIGNATURE; + Nic->Private = mPrivate; + Nic->Wmp = Wmp; + Nic->Supplicant = Supplicant; + Nic->EapConfig = EapConfig; + Nic->UserSelectedProfile = NULL; + Nic->OneTimeScanRequest = FALSE; + + if (Nic->Supplicant != NULL) { + Status = WifiMgrGetSupportedSuites (Nic); } + + if (!EFI_ERROR (Status)) { + InitializeListHead (&Nic->ProfileList); + + Nic->ConnectPendingNetwork = (WIFI_MGR_NETWORK_PROFILE *)AllocateZeroPool (sizeof (WIFI_MGR_NETWORK_PROFILE)); + if (Nic->ConnectPendingNetwork == NULL) { + Status = EFI_OUT_OF_RESOURCES; + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to allocate memory for ConnectPendingNetwork\n")); + goto ERROR; + } + + Status = WiFiProfileSyncProtocol->WifiProfileSyncGetProfile (Nic->ConnectPendingNetwork, Nic->MacAddress); + if (!EFI_ERROR (Status) && (Nic->ConnectPendingNetwork != NULL)) { + Status = WifiMgrConnectToNetwork (Nic, Nic->ConnectPendingNetwork); + if (!EFI_ERROR (Status)) { + return Status; + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get WiFi profile with status %r\n", Status)); + } + } else { + DEBUG ((DEBUG_ERROR, "[WiFi Connection Manager] Failed to get + Supported suites with status %r\n", Status)); } + + if (Nic->ConnectPendingNetwork != NULL) { + if (Nic->ConnectPendingNetwork->Network.AKMSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.AKMSuite); + } + + if (Nic->ConnectPendingNetwork->Network.CipherSuite != NULL) { + FreePool (Nic->ConnectPendingNetwork->Network.CipherSuite); + } + + FreePool (Nic->ConnectPendingNetwork); } + +ERROR: + if (Nic->Supplicant != NULL) { + if (Nic->SupportedSuites.SupportedAKMSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedAKMSuites); + } + + if (Nic->SupportedSuites.SupportedSwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedSwCipherSuites); + } + + if (Nic->SupportedSuites.SupportedHwCipherSuites != NULL) { + FreePool (Nic->SupportedSuites.SupportedHwCipherSuites); + } + } + + FreePool (Nic); + + return Status; +} + /** The callback function for connect operation. @@ -908,12 +1052,13 @@ WifiMgrOnConnectFinished ( IN VOID *Context ) { - EFI_STATUS Status; - WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; - WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; - UINT8 SecurityType; - UINT8 SSIdLen; - CHAR8 *AsciiSSId; + EFI_STATUS Status; + WIFI_MGR_MAC_CONFIG_TOKEN *ConfigToken; + WIFI_MGR_NETWORK_PROFILE *ConnectedProfile; + UINT8 SecurityType; + UINT8 SSIdLen; + CHAR8 *AsciiSSId; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; ASSERT (Context != NULL); @@ -925,6 +1070,24 @@ WifiMgrOnConnectFinished ( ASSERT (ConfigToken->Type == TokenTypeConnectNetworkToken); ASSERT (ConfigToken->Token.ConnectNetworkToken != NULL); + + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (ConfigToken->Token.ConnectNetworkToken->ResultCode); + if ((mWifiConnectionCount < MAX_WIFI_CONNETION_ATTEMPTS) && + (ConfigToken->Token.ConnectNetworkToken->ResultCode != ConnectSuccess)) + { + mWifiConnectionCount++; + gBS->CloseEvent (Event); + Status = ConnectionRetry (WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + return; + } + + WiFiProfileSyncProtocol->WifiProfileSyncSetConnectState (Status); + } + } + if (ConfigToken->Token.ConnectNetworkToken->Status != EFI_SUCCESS) { if (ConfigToken->Nic->OneTimeConnectRequest) { // diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c index 4ad5643c24..87adfc5033 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrMisc.c @@ -672,10 +672,23 @@ WifiMgrCleanProfileSecrets ( IN WIFI_MGR_NETWORK_PROFILE *Profile ) { + EFI_STATUS Status; + EFI_WIFI_PROFILE_SYNC_PROTOCOL *WiFiProfileSyncProtocol; + ZeroMem (Profile->Password, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->EapPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); ZeroMem (Profile->PrivateKeyPassword, sizeof (CHAR16) * PASSWORD_STORAGE_SIZE); + // + // When EFI WiFi profile sync protocol is found the system is + performing a recovery boot in secure // boot mode. The profile sync + driver will manage the CA certificate, client certificate, and key // data, cleaning them at exit boot services. + // + Status = gBS->LocateProtocol (&gEfiWiFiProfileSyncProtocolGuid, NULL, + (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { + return; + } + if (Profile->CACertData != NULL) { ZeroMem (Profile->CACertData, Profile->CACertSize); FreePool (Profile->CACertData); -- 2.37.3.windows.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-12-15 19:55 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <9102518d297546d349e9dcbaf9a87706ec8529e0.1664830666.git.zachary.clark-williams@intel.com> 2022-10-04 17:04 ` [PATCH v4 161/161] NetworkPkg: Add WiFi profile sync protocol support Clark-williams, Zachary [not found] ` <CO6PR11MB5601C36E75AF5A715C47ED7FC9339@CO6PR11MB5601.namprd11.prod.outlook.com> [not found] ` <CO1PR11MB4929BAD03309A5606C0AA851D2339@CO1PR11MB4929.namprd11.prod.outlook.com> 2022-10-28 20:09 ` [PATCH v4] NetworkPkg/WifiProfileSync: " Clark-williams, Zachary 2022-10-28 20:13 ` Clark-williams, Zachary 2022-10-31 19:31 ` Clark-williams, Zachary [not found] ` <MWHPR11MB00649E049DBD36906E8E24B288379@MWHPR11MB0064.namprd11.prod.outlook.com> 2022-11-01 17:34 ` [edk2-devel] " Clark-williams, Zachary 2022-11-01 17:39 ` Zimmer, Vincent 2022-11-01 17:41 ` Clark-williams, Zachary 2022-11-02 12:35 ` Rabeda, Maciej 2022-11-02 15:57 ` Clark-williams, Zachary [not found] ` <1723CFBA04C671AE.15522@groups.io> 2022-12-06 18:38 ` Clark-williams, Zachary 2022-12-06 18:41 ` Clark-williams, Zachary 2022-12-15 19:55 ` Clark-williams, Zachary
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox