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 5DF817803CE for ; Mon, 27 Nov 2023 05:31:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=Uw738AEY8asAOk7zsMdxrrv462i9/rf+FIutCXDBKxU=; 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=1701063097; v=1; b=FQsbtNXYWc8XfumdSYXQ93pcE4XxYcQu/FVhTFshkcmu3hiWbeFGbr1U5vMoUj1US4PnOMEE oPJAXIJ4l+ioJ1x1vdLdNhKC+FpJJdCzY8j3vlg8ZrRG2N/JHvHaCZUVwh82W/bZqbtwj5SlAYD F6cZdn3H4dPIoikw88ZrLlbY= X-Received: by 127.0.0.2 with SMTP id SpqdYY7687511xckvnmQHL6j; Sun, 26 Nov 2023 21:31:37 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.62]) by mx.groups.io with SMTP id smtpd.web10.87207.1701063096202118209 for ; Sun, 26 Nov 2023 21:31:36 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MrUCkutSYTi9I0+6WaGYk1XEVfxCF4roMj969NvOH2okjYXceGboJbAZlwJ3loT7kjTj8Z9C8yxsZhBIvsSsd2fCzG63cBJFNmqUlhNShdu5ZX6JFQLguPOkH+6reS3iOn5z+1uwe8hTjkmANflsTQdXZKSH1elytO3GHqHoy6mxmY8MIgm0PjCjVOrOFKjZyFmiHCdd+l9soIssSlcJ5sGJN7mifB97lPOnDrk5JQRHrmT01BGRs8I8yU6FdaFH9sDI8hEoCA/BXa0DuM1ze0mfFmM5mJziD74Qt4EFVVUdPOoV1oM621tZH0DwldwTx1ouRZfjU/uRM7jok0lKyA== 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=DDFTN9cofQM2p+iJtR8h27LAhZu4PpQYg+taIgvln6X4a1ePq5YD0kvW5g1Z9kscNt9YtUPqbefdxnLGtVlBPJOfB7VBEBAOJZ0fJ4J08jfyCJiEYF5ygmmp6YMdW8N+9E/Vd8dxorkRdL5+97TYvu0IYJGqBO5oJXmL/ODGk9bwqMf6JQ/bLqJmfXcqoNA5+360DHgI/9WVZzNX43AEiJmop2w/DxLP9kZiTzNwPBgXPNUfVcEEjc7AX028M/LgZPDzhJykT+VkzBWr0GN4c7c/fbgU4fNv8PyLAeSDKiCxfGC4s4bumBL66f+lVkd23SJt4HYvfizNyDa8Y6WHdg== 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 PH8PR05CA0001.namprd05.prod.outlook.com (2603:10b6:510:2cc::22) by PH7PR12MB6934.namprd12.prod.outlook.com (2603:10b6:510:1b8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Mon, 27 Nov 2023 05:31:34 +0000 X-Received: from SN1PEPF0002BA4E.namprd03.prod.outlook.com (2603:10b6:510:2cc:cafe::a4) by PH8PR05CA0001.outlook.office365.com (2603:10b6:510:2cc::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.19 via Frontend Transport; Mon, 27 Nov 2023 05:31:33 +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 SN1PEPF0002BA4E.mail.protection.outlook.com (10.167.242.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7046.17 via Frontend Transport; Mon, 27 Nov 2023 05:31:33 +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; Sun, 26 Nov 2023 23:31:32 -0600 From: "Chang, Abner via groups.io" To: CC: Nickle Wang , Igor Kulchytskyy , Mike Maslenkin Subject: [edk2-devel] [PATCH V3 3/9] RedfishPkg/RedfishConfigHandler: Use Redfish HI readiness notification Date: Mon, 27 Nov 2023 13:31:01 +0800 Message-ID: <20231127053107.1686-4-abner.chang@amd.com> In-Reply-To: <20231127053107.1686-1-abner.chang@amd.com> References: <20231127053107.1686-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: SN1PEPF0002BA4E:EE_|PH7PR12MB6934:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a5e073a-55bd-42a4-8a68-08dbef0a1e26 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: MAErGjtAniVeNUh4mJLclFLet8A6Mtuih2GYPz/yhupQ57QaSju6KHQbAxGG5P3IvHczPzcliwRHu1aM9RNvcg259uHCRWgOhUIgGgjkKObrVQ5OJwaYj3r8U1MYxIcoOAQAKzNEW0k0In45SKvI8WR3ClnbFtNPj5trH1OIQFSZCm2lmpJvNgaeql5QtK1NCU81nVpfEfh4y2xae4cwqfz/4tcVHgK5F2fyL9pMvA/yqGF55deZllFGw6KdwYJ6IY/VMZJNisU5FG/M0WLunwdtdK3foxeSSxlrQhdT38gw2newRdIAvT1Tch5wlGaDtfyomNeersqok5xZbTZOqIwEEuc+LD7M6eB4DtouEtgCNuv4C7DkoToCjS0LZQHPU8bL5XhP4v4CSG7am/GaIYgQpNomtP39yZwE4mRUHa2P07AHRpxB3L91hNR1LqeS750oiXgxji8cjGIIVEuZg+vIDQgZxdusZh7PuZqSoNQA7Z9zlClZLJtby7SA9VOcnXWGO1hKAPtPrXbA31+df+tl8B38cDuv0NQGjtRWgxzs6mhtedZAyvJD5puVzovUFzMpSSPZ9RhTMS3/FcykV9Znd/XKcqQ37UIl7Wt20X7KaHY1NGqFOuPRWD7R6H7McgYM/OwoGrefCCvtHG7Uk5SX5Kgco2NK+bNvQFZdNuTJpSaOmEeRJtXSPVmEQsjNX5j9f3Ldsc/yeTjvWqUDIMEJvo1nG4TyZIu8s0SC1COGEh60nmpITpdJP+VSbggFruEgmHPmPbK1m61VOMqBZQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Nov 2023 05:31:33.7142 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a5e073a-55bd-42a4-8a68-08dbef0a1e26 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: SN1PEPF0002BA4E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6934 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: NnTulezcOXxtGKzYzhCUzUdsx7686176AA= 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=FQsbtNXY; 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 (#111717): https://edk2.groups.io/g/devel/message/111717 Mute This Topic: https://groups.io/mt/102824316/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-