From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 4DE6A7803CC for ; Thu, 23 Nov 2023 05:55:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=9lm0L8ZAlIguSrJw13GanwRLDzK4kNUyJIjfThSBR78=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1700718898; v=1; b=RlUko3RAxQi9/EgzNZjzEKVK2SwE4G+ZR8gQ84ZZ/YBP9q5uSSTM4rbBtT2gyTblTQmG3FN4 2dSPE35Zn6L4D/MSm0P/nFBYhLgz0E+DSxbLZJqOTaXfDmkZksXDhGCemf5a1ctwKU+oH5lW6Tw hcWUzIo+wcDiy6aqspHmeetU= X-Received: by 127.0.0.2 with SMTP id bOhnYY7687511xKXIwHkhkbd; Wed, 22 Nov 2023 21:54:58 -0800 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.52]) by mx.groups.io with SMTP id smtpd.web11.85676.1700718897235581888 for ; Wed, 22 Nov 2023 21:54:57 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jreYdVKT9NRmThURf71Tdx6GlmS6jRTvSCJq5k5kTE7zCAVcTi3cO9g9J5VZGb0dpBn7Ulp9YEL8UDRa+DWQy2YdKjCIw97AD3K2If/qX4ZTkC1m145aCOBtSX/iop58njL9Sbi/9f/pjkbaxZ0rnCiy2+QgSxXjjsBHL4/0d0PcPZgIitUU//2C0cvG2YYfs6zSiFOsDF05ITbKRjyyEz5OA4FwVCYrjhT5tgNlGKCYzD9Zyi7VNcG1x8QXVwyNMwgpkqejZx88olA1tu+Da3EmqDBPjjgDjJObX0LBStyt3MF4GdpMj8FN1MubKBjVBam4ZzpNLlSxu0EhkfhX3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CiZC5g7gHOhxRgr3I/UnVCz13d5a/iQhMcntQL1vkiI=; b=cAD7ZAxVUsLYkldcuSdQW2On4VIRSWItZNiAToy4bBQixVqczvdW509YPvA70RDj1BEwmX7k6+ecgFrcRSENWL1e3GhAPGIsa2wM9FpEDypVjfVvfbq5/Rf2oyrkz4nBqSqAiru4tGiw1+iSMvpqyvAgxxrgSMSRPySVIIQsO/B3c6HiLVeBwmvc83ODgsV5GJ6vpHjffOXdCf+LagWjumFZU2b+0APqaMSC/dZ+P4CscHxgoyo8npkAtCqgMZ6laMDGacW3QgSbZOsJvLFB/AT7wNoxzV3MCZXcwIq0AlBrzjMXLyehwy/2dPTdQkcl/vdw4v0GcTmINr80m+R0Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from DS7PR03CA0061.namprd03.prod.outlook.com (2603:10b6:5:3bb::6) by DM6PR12MB5005.namprd12.prod.outlook.com (2603:10b6:5:1be::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20; Thu, 23 Nov 2023 05:54:54 +0000 X-Received: from CY4PEPF0000E9D5.namprd05.prod.outlook.com (2603:10b6:5:3bb:cafe::9c) by DS7PR03CA0061.outlook.office365.com (2603:10b6:5:3bb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.20 via Frontend Transport; Thu, 23 Nov 2023 05:54:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D5.mail.protection.outlook.com (10.167.241.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7025.12 via Frontend Transport; Thu, 23 Nov 2023 05:54:54 +0000 X-Received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 22 Nov 2023 23:54:51 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy , Mike Maslenkin Subject: [edk2-devel] [PATCH 3/6] RedfishPkg/RedfishConfigHandler: Use Redfish HI readiness notification Date: Thu, 23 Nov 2023 13:54:29 +0800 Message-ID: <20231123055432.86-4-abner.chang@amd.com> In-Reply-To: <20231123055432.86-1-abner.chang@amd.com> References: <20231123055432.86-1-abner.chang@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D5:EE_|DM6PR12MB5005:EE_ X-MS-Office365-Filtering-Correlation-Id: 54f68bdc-cdb7-4702-78c6-08dbebe8b768 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: ubQrUJbc1AfHL7asggvOCGPPc1UwubHe1mfxYTy5NR/qzxX6QF+CtOeQ1fSBRpqvjMEi5bvBmYJYq2igptcpSkfyAD8bep7KMYkTGwwx5AETeySLDwofHH5m5zGHgp7a7WArScWpxx4V5aN27mA7lly/9Q3p98pdWdrWkyHirW0tbOdqMVALFHxrg7+ZELdaAiItC2s1geIenqgZTXHgLEDaFNf8KH/TSlsVXzYsR73Yl3yr4rV6Lp+PSB1fJGOlHOSO6tZ3Zfud6LIgZvCVvBy6YBucIohEy3q1xjWQB6akIHMoSenFSHQapjFYjWmU784xjH0MO1XVqU/qsy0fLe+u2ZqGCgAvthOu2AJKtoLaw0njEikgC4EPi4klyQvnYX/Xm3Kmiod2zty+AKjobKPvpDbEamEWw7XZHu4Z/C3mbY/hunEy4FBlY9xE1+Uf83ySlvUe4yX5s3MoxvkGl1yHLLPFoYDhHATkNps/sV24lqxSihYD2AFrNHcx/IbjAxD2YANV1MHgGjQa2eomheJDnLTt8/0OlUrkIKTJHJHv0ezZO1TrCx/3sfMGrBtup4QcuK67FOtC4CTkpNCpBt38bDPgKP5/SZN04ofsoGQLinj85wyCUAnSTH6676iPdK6MT3QJAm3hciYUGYduFuSXCi5VPc+o8D8x4PZ2Xj2ul1DKun0vJ0Zq4ur5+BR6bX/P9Alrznb0V1ZN/i8VvPQLy5tiP59XotYs+9uL19KokQjBVGNKnG/KLHNmD5zQkv641qsGH6Zp1MzYc0NykA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2023 05:54:54.3511 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54f68bdc-cdb7-4702-78c6-08dbebe8b768 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D5.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5005 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: EwQASOUH9uRhum73cTIxV1p7x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=RlUko3RA; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Abner Chang Wait until Redfish Host Interface is installed on the system then acquire Redfish service. Signed-off-by: Abner Chang Cc: Nickle Wang Cc: Igor Kulchytskyy Cc: Mike Maslenkin --- .../RedfishConfigHandlerDriver.inf | 9 +- .../RedfishConfigHandlerDriver.c | 168 ++++++++++++------ 2 files changed, 116 insertions(+), 61 deletions(-) diff --git a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf= b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf index b167c6e1ee4..aed93f570cf 100644 --- a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf +++ b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.inf @@ -46,11 +46,12 @@ UefiDriverEntryPoint =20 [Protocols] - gEfiRedfishDiscoverProtocolGuid ## CONSUMES + gEfiRedfishDiscoverProtocolGuid ## CONSUMES gEfiRestExServiceBindingProtocolGuid - gEfiRestExProtocolGuid ## CONSUMES - gEdkIIRedfishCredentialProtocolGuid ## CONSUMES - gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMES + gEfiRestExProtocolGuid ## CONSUMES + gEdkIIRedfishCredentialProtocolGuid ## CONSUMES + gEdkIIRedfishConfigHandlerProtocolGuid ## CONSUMES + gEdkIIRedfishHostInterfaceReadyProtocolGuid ## CONSUMES =20 [Guids] gEfiEventExitBootServicesGuid ## CONSUMES ## Event diff --git a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c b= /RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c index f987cc67a69..b421f51374d 100644 --- a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c +++ b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c @@ -17,11 +17,15 @@ EFI_EVENT gEfiRedfishDiscoverProtocolEvent =3D NULL; // // Variables for using RFI Redfish Discover Protocol // -VOID *gEfiRedfishDiscoverRegistration; -EFI_HANDLE gEfiRedfishDiscoverControllerHandle =3D NUL= L; -EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol =3D NUL= L; -BOOLEAN gRedfishDiscoverActivated =3D FAL= SE; -BOOLEAN gRedfishServiceDiscovered =3D FAL= SE; +VOID *gEfiRedfishDiscoverRegistration; +EFI_HANDLE gEfiRedfishDiscoverControllerHandl= e =3D NULL; +EFI_REDFISH_DISCOVER_PROTOCOL *gEfiRedfishDiscoverProtocol = =3D NULL; +BOOLEAN gRedfishDiscoverActivated = =3D FALSE; +BOOLEAN gRedfishServiceDiscovered = =3D FALSE; +EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *mNetworkInterfaces = =3D NULL; +UINTN mNumberOfNetworkInterfaces; +EFI_EVENT mEdkIIRedfishHostInterfaceReadyEve= nt; +VOID *mEdkIIRedfishHostInterfaceRegistr= ation; =20 /// /// Driver Binding Protocol instance @@ -339,6 +343,83 @@ RedfishServiceDiscoveredCallback ( FreePool (RedfishDiscoveredToken); } =20 +/** + Callback function executed when the gEdkIIRedfishHostInterfaceReadyProto= colGuid + protocol interface is installed. + + @param[in] Event Event whose notification function is being invoked= . + @param[in] Context Pointer to the Context buffer + +**/ +VOID +EFIAPI +AcquireRedfishServiceOnNetworkInterfaceCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; + UINTN NetworkInterfaceIndex; + EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; + + ThisNetworkInterface =3D mNetworkInterfaces; + // + // Loop to discover Redfish service on each network interface. + // + for (NetworkInterfaceIndex =3D 0; NetworkInterfaceIndex < mNumberOfNetwo= rkInterfaces; NetworkInterfaceIndex++) { + ThisRedfishDiscoveredToken =3D (EFI_REDFISH_DISCOVERED_TOKEN *)Allocat= eZeroPool (sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); + if (ThisRedfishDiscoveredToken =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVER= ED_TOKEN.\n", __func__)); + return; + } + + ThisRedfishDiscoveredToken->Signature =3D REDFISH_DISCOVER_TOKEN_SIGNA= TURE; + + // + // Initial this Redfish Discovered Token + // + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + RedfishServiceDiscoveredCallback, + (VOID *)ThisRedfishDiscoveredToken, + &ThisRedfishDiscoveredToken->Event + ); + if (EFI_ERROR (Status)) { + FreePool (ThisRedfishDiscoveredToken); + DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discove= red token.\n", __func__)); + return; + } + + // + // Acquire for Redfish service which is reported by + // Redfish Host Interface. + // + Status =3D gEfiRedfishDiscoverProtocol->AcquireRedfishService ( + gEfiRedfishDiscoverProtocol, + gRedfishConfigData.Image, + ThisNetworkInterface, + EFI_REDFISH_DISCOVER_HOST_INTE= RFACE, + ThisRedfishDiscoveredToken + ); + + // + // Free Redfish Discovered Token if Discover Instance was not created = and + // Redfish Service Discovered Callback event was not triggered. + // + if ((ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound =3D= =3D 0) || + EFI_ERROR (ThisRedfishDiscoveredToken->DiscoverList.RedfishInstanc= es->Status)) + { + gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); + DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", __= func__, ThisRedfishDiscoveredToken)); + FreePool (ThisRedfishDiscoveredToken); + } + + ThisNetworkInterface++; + } +} + /** Callback function executed when the EFI_REDFISH_DISCOVER_PROTOCOL protocol interface is installed. @@ -354,13 +435,10 @@ RedfishDiscoverProtocolInstalled ( OUT VOID *Context ) { - EFI_STATUS Status; - UINTN BufferSize; - EFI_HANDLE HandleBuffer; - UINTN NetworkInterfaceIndex; - EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface; - EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken; - UINTN NumberOfNetworkInterfaces; + EFI_STATUS Status; + UINTN BufferSize; + EFI_HANDLE HandleBuffer; + VOID *RedfishHostInterfaceReadyProtocol; =20 DEBUG ((DEBUG_MANAGEABILITY, "%a: New network interface is installed on = system by EFI Redfish discover driver.\n", __func__)); =20 @@ -401,67 +479,43 @@ RedfishDiscoverProtocolInstalled ( Status =3D gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList ( gEfiRedfishDiscoverProtocol, gRedfishConfigData.Image, - &NumberOfNetworkInterfaces, - &ThisNetworkInterface + &mNumberOfNetworkInterfaces, + &mNetworkInterfaces ); - if (EFI_ERROR (Status) || (NumberOfNetworkInterfaces =3D=3D 0)) { + if (EFI_ERROR (Status) || (mNumberOfNetworkInterfaces =3D=3D 0)) { DEBUG ((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n= ", __func__)); return; } =20 // - // Loop to discover Redfish service on each network interface. + // Check if Redfish Host Interface is ready or not. // - for (NetworkInterfaceIndex =3D 0; NetworkInterfaceIndex < NumberOfNetwor= kInterfaces; NetworkInterfaceIndex++) { - ThisRedfishDiscoveredToken =3D (EFI_REDFISH_DISCOVERED_TOKEN *)Allocat= eZeroPool (sizeof (EFI_REDFISH_DISCOVERED_TOKEN)); - if (ThisRedfishDiscoveredToken =3D=3D NULL) { - DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVER= ED_TOKEN.\n", __func__)); - return; - } - - ThisRedfishDiscoveredToken->Signature =3D REDFISH_DISCOVER_TOKEN_SIGNA= TURE; - - // - // Initial this Redfish Discovered Token - // + Status =3D gBS->LocateProtocol (&gEdkIIRedfishHostInterfaceReadyProtocol= Guid, NULL, &RedfishHostInterfaceReadyProtocol); + if (!EFI_ERROR (Status)) { + // Acquire Redfish service; + AcquireRedfishServiceOnNetworkInterfaceCallback ((EFI_EVENT)NULL, (VOI= D *)NULL); + } else { Status =3D gBS->CreateEvent ( EVT_NOTIFY_SIGNAL, TPL_CALLBACK, - RedfishServiceDiscoveredCallback, - (VOID *)ThisRedfishDiscoveredToken, - &ThisRedfishDiscoveredToken->Event + AcquireRedfishServiceOnNetworkInterfaceCallback, + NULL, + &mEdkIIRedfishHostInterfaceReadyEvent ); if (EFI_ERROR (Status)) { - FreePool (ThisRedfishDiscoveredToken); - DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discove= red token.\n", __func__)); + DEBUG ((DEBUG_ERROR, "%a: Failed to create event for gEdkIIRedfishHo= stInterfaceReadyProtocolGuid installation.", __func__)); return; } =20 - // - // Acquire for Redfish service which is reported by - // Redfish Host Interface. - // - Status =3D gEfiRedfishDiscoverProtocol->AcquireRedfishService ( - gEfiRedfishDiscoverProtocol, - gRedfishConfigData.Image, - ThisNetworkInterface, - EFI_REDFISH_DISCOVER_HOST_INTE= RFACE, - ThisRedfishDiscoveredToken - ); - - // - // Free Redfish Discovered Token if Discover Instance was not created = and - // Redfish Service Discovered Callback event was not triggered. - // - if ((ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound =3D= =3D 0) || - EFI_ERROR (ThisRedfishDiscoveredToken->DiscoverList.RedfishInstanc= es->Status)) - { - gBS->CloseEvent (ThisRedfishDiscoveredToken->Event); - DEBUG ((DEBUG_ERROR, "%a: Free Redfish discovered token - %x.\n", __= func__, ThisRedfishDiscoveredToken)); - FreePool (ThisRedfishDiscoveredToken); + Status =3D gBS->RegisterProtocolNotify ( + &gEdkIIRedfishHostInterfaceReadyProtocolGuid, + mEdkIIRedfishHostInterfaceReadyEvent, + &mEdkIIRedfishHostInterfaceRegistration + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installatio= n of gEdkIIRedfishHostInterfaceReadyProtocolGuid.", __func__)); + return; } - - ThisNetworkInterface++; } =20 return; --=20 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111651): https://edk2.groups.io/g/devel/message/111651 Mute This Topic: https://groups.io/mt/102762736/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-