From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.108]) by mx.groups.io with SMTP id smtpd.web10.40200.1683165520369557336 for ; Wed, 03 May 2023 18:58:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@os.amperecomputing.com header.s=selector2 header.b=Sn1P6WQG; spf=pass (domain: os.amperecomputing.com, ip: 40.107.94.108, mailfrom: minhnguyen1@os.amperecomputing.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kqDDHuIWdOpZyL/ljK0T6SX6APbxWPIAZWZrR8gS5+BpB23qRM9tx4zI/IeuDkk0XK1zewr+GpmKpSbRFRvHXvWFhqZdaYuQOqREhCE9BO0UAh4OJY1JCjZQ92eM1i/w/t+OHRhjd8zB/tGnFPg//OpkrPpDOirzfdpdWAZGhScTXf2pKuVb09mBx/WvY6KnfjPxLCH5ukz4nGkbujkk6TcLG3OFBvP+9ZJzJTaJXX04pWDiIVIMLkkccSUF8cajTHtBK9zR677CRmJG5BN96WlBHCGveG14/6fuOfSShtquGbgPOcBSz6ubd794Hmq4W4dKmMknzLmWJYNc4dNtIg== 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=aP3BUNFW+xXGUG8IniIBvISmYemgCWzOwyBdsH+KfSk=; b=IEYwvKbB8MDMmTvcCccBv0tsnYyIh+KiUMykL8++I55Y2nsWy9ax+QZJVlfahToAUMwhsHw5zePoQtb4bAtxNnHpUroEK0bfr14edQP855/PAl97c+5lcJ3gLoxlLFFDzbnLOzR2Qnav6ytWjm2PwcmZPvvy1b/QAcvKxH/YygjTh18LDZ7oFCyUjW1a7UPROQG1YXA5W6yUYe0w21pBJ+WOzLT46hLW/rS2SXDVy3DKSRIeUMg1M9sGGGP7zoB5o0J8+E/zFQK5c64dUOMtEP35x1sa2NEclgyBL+M2EHRA7E+wZhIM4o28F/PvKoL5NZ5Xo3bTN8TeF/p/a+RJWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aP3BUNFW+xXGUG8IniIBvISmYemgCWzOwyBdsH+KfSk=; b=Sn1P6WQG/xm8aX4SsG7FdrvG+C3luLd+Xewpc5HWkGxhgZLP3C6ySjprTvQXaXfO9TSLp9SFmljxSYD2YNQ8+X7MhUMBGqPuBiuXovxeGRyIp8QHuZKROy1/2VNDKaD2i0t1XRQ4zGinhDdqU/aPSEGq6iLbqlE9s+l/8U8ExXA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ2PR01MB8049.prod.exchangelabs.com (2603:10b6:a03:4ce::10) by DM6PR01MB5978.prod.exchangelabs.com (2603:10b6:5:1df::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.22; Thu, 4 May 2023 01:58:37 +0000 Received: from SJ2PR01MB8049.prod.exchangelabs.com ([fe80::b8:5d56:7d04:223a]) by SJ2PR01MB8049.prod.exchangelabs.com ([fe80::b8:5d56:7d04:223a%3]) with mapi id 15.20.6340.030; Thu, 4 May 2023 01:58:37 +0000 From: Minh Nguyen To: devel@edk2.groups.io CC: patches@amperecomputing.com, abner.chang@amd.com, nicklew@nvidia.com, igork@ami.com, nhi@os.amperecomputing.com, Vu Nguyen , Minh Nguyen Subject: [v1 PATCH 3/5] RedfishPkg: Create RestEx child on selected interface Date: Thu, 4 May 2023 08:57:52 +0700 Message-ID: <20230504015754.1352305-4-minhnguyen1@os.amperecomputing.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230504015754.1352305-1-minhnguyen1@os.amperecomputing.com> References: <20230504015754.1352305-1-minhnguyen1@os.amperecomputing.com> X-ClientProxiedBy: SG2P153CA0037.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::6) To SJ2PR01MB8049.prod.exchangelabs.com (2603:10b6:a03:4ce::10) Return-Path: minhnguyen1@os.amperecomputing.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR01MB8049:EE_|DM6PR01MB5978:EE_ X-MS-Office365-Filtering-Correlation-Id: cc6f7047-303b-459f-88a5-08db4c43132d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PyknjffpYolCK3cOUkE+zWmZyrysU/bIFeDdvNRLqS6SbQZN4BZcZXV3fVGFDd2mEunooXA264JSUEsGG3lJ13vundQfzHXQ5PKLi4RNuL9KuLhH5RQUu5EvJyzYB6LKCb7VmUJSkBk/NQTtQu0BMZjllY77i8Xuvgh6D5ysVBdMzdRwh2jNIuX7Y8hNmKrBk7BTiP+miWTWeea6oMgoseXtaubdL8uFX05vwKiWREJ6pXWL7ynqazECxGs1quygK6gJxo2rvXEEYox9YqC14zsU2ml1I9paAuVnEvFFQrTeksTosbL0ZflFcB9mM6m7RFXlnK/MjU7C1zEwR1oOdfQPY+idju/0SNDD2Xgzfea/2hvOJcuCHPuwOggvlnZaoPT22XaKN74ojpt3z/y0ZUNJLOfEyqEbeI1nh/7xpP1ZsJulkXyjU3J+zLtorGPCSqEp193U0HerWrVTYST9ue4ggHzKL9i7uMO47vtTTvsF04TnRDs06+HJ27KP0pWJiIGn1W0twzWcu0TKeBPhUwfKmYEy+hVrhJXn4G+0v6yoV9/hd09xE6HXB4/xQ1oNcJ157OcpAU35yly72S+tSXqpwJVJolMJrreEykAvGIYV1nIHeozaOYqdviajzDdC X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR01MB8049.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(396003)(346002)(376002)(39850400004)(136003)(451199021)(8676002)(8936002)(52116002)(41300700001)(6666004)(4326008)(66946007)(66476007)(66556008)(6916009)(86362001)(38100700002)(478600001)(316002)(54906003)(38350700002)(6486002)(2906002)(2616005)(5660300002)(6512007)(6506007)(26005)(1076003)(186003)(107886003)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JPYWu84jO0rl6fRgheQOsOu0ZoBqOIhsvwIw2zUls0LGwuyXNS3Tvxrbe0AE?= =?us-ascii?Q?EyxBk3bbAt2EsA0OvuskppTy24MtDrQK7YtzPITxpe6/V4JnYRWyPpq6qeGQ?= =?us-ascii?Q?vCrcl54ICktlQ5Cyf+ds51TWj0wVjQXlxfUjtO6x4VwQ7XoZL+/SZctxujbo?= =?us-ascii?Q?zQLVlbdZ9YBsq81j9xzi/zRMBn/49O38WW8kTaV6SO1VC8na+nGYud2lqZ10?= =?us-ascii?Q?R30tWIAv5hY41CTyz8nhQMOZHV9xASAoUU1KZDPbloYWsc/qiAjjHnlNVYfc?= =?us-ascii?Q?1HoO4Lq9F1l9qlRQ0ap+aMETtyWvmeKtxGt+Y/T9OlIHtGcBWhGRceVHiDw0?= =?us-ascii?Q?FNcJ7Frjau9/C+XOxqooD5XrjKMpqVJNOeG1kxIzC9N4c9DrmLkb+xnF7DI/?= =?us-ascii?Q?tPQ1DrIWOEo+GxmnT6PyFFL9xAVuJiz5trwLWxqCMqUL/h54XxS+LEWRseSj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QZa0B6u8rgYqNbdBQVafaFt7ZD6Q9IDGGx?= =?us-ascii?Q?tKRUoakhOpmBPPAekVmtrF/G7v408UAKb88peWTIGjrASm614KkzsFjKDiwu?= =?us-ascii?Q?JJBYR365jlpT4OeMQx1TiANcCN3XMrDE5kE96e1niSzD3n23Yo82RGFUu1Zo?= =?us-ascii?Q?YIaCU29+An/2UOWzdfKssCOTI5juKG+mLxH86vMPkFkd0kjjiOZjvMDUkv7F?= =?us-ascii?Q?9FVk6MORbzhRhsfD7bPESc1SUyIIUrQPmKVnHQdsHFx8dNZl8QxeajbmtcM5?= =?us-ascii?Q?q6mMND3rH58px/tnIAELhQP5vkdW02DZd0S/I1ivqpjh?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc6f7047-303b-459f-88a5-08db4c43132d X-MS-Exchange-CrossTenant-AuthSource: SJ2PR01MB8049.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2023 01:58:37.2938 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: R/0AaJh/bF91ohhTUSMJaQsBQILueVjzfrk6y62F3+DRRM7upNuYiRA29nzm25keq/oEp+vrd+UABScWHiFN2tKiVk8VL+kyTVskj0l8thIJFCTTtYMqJueyxkYdLEDb X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB5978 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain From: Vu Nguyen When a MAC address matching interface is found, a RestEx child will be created to provide the Redfish communication on that interface. Currently, It will try to locate all RestEx binding services and choose the first satisfied instance without taking care about current selected interface. This might raise an issue on the system with multiple network devices that the RestEx child was installed on wrong interface. Signed-off-by: Minh Nguyen --- RedfishPkg/Include/Library/RestExLib.h | 3 + RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c | 153 ++++++++---------= --- RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 1 + 3 files changed, 63 insertions(+), 94 deletions(-) diff --git a/RedfishPkg/Include/Library/RestExLib.h b/RedfishPkg/Include/Li= brary/RestExLib.h index bc4e4ca6caa7..2c32c3684cf4 100644 --- a/RedfishPkg/Include/Library/RestExLib.h +++ b/RedfishPkg/Include/Library/RestExLib.h @@ -2,6 +2,7 @@ This library provides help functions for REST EX Protocol. =20 (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -20,6 +21,7 @@ This function allows the caller to create child handle for specific REST server. =20 + @param[in] Controller The controller handle used of selected = interface. @param[in] Image The image handle used to open service. @param[in] AccessMode Access mode of REST server. @param[in] ConfigType Underlying configuration to communicate= with REST server. @@ -32,6 +34,7 @@ **/ EFI_STATUS RestExLibCreateChild ( + IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode, IN EFI_REST_EX_CONFIG_TYPE ConfigType, diff --git a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c b/RedfishPkg/Li= brary/DxeRestExLib/DxeRestExLib.c index d9acad24dec1..6002be93c54e 100644 --- a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c +++ b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c @@ -2,6 +2,7 @@ This library provides help functions for REST EX Protocol. =20 (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+ Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -9,6 +10,7 @@ =20 #include #include +#include #include #include #include @@ -21,6 +23,7 @@ This function allows the caller to create child handle for specific REST server. =20 + @param[in] Controller The controller handle used of selected = interface. @param[in] Image The image handle used to open service. @param[in] AccessMode Access mode of REST server. @param[in] ConfigType Underlying configuration to communicate= with REST server. @@ -33,6 +36,7 @@ **/ EFI_STATUS RestExLibCreateChild ( + IN EFI_HANDLE Controller, IN EFI_HANDLE Image, IN EFI_REST_EX_SERVICE_ACCESS_MODE AccessMode, IN EFI_REST_EX_CONFIG_TYPE ConfigType, @@ -41,8 +45,6 @@ RestExLibCreateChild ( ) { EFI_STATUS Status; - UINTN NoBuffer; - EFI_HANDLE *Handle; EFI_HANDLE ChildHandle; EFI_REST_EX_PROTOCOL *RestEx; EFI_REST_EX_SERVICE_INFO *RestExServiceInfo; @@ -59,116 +61,79 @@ RestExLibCreateChild ( } =20 *ChildInstanceHandle =3D NULL; - // - // Locate all REST EX binding service. - // - Handle =3D NULL; - NoBuffer =3D 0; - Status =3D gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiRestExServiceBindingProtocolGuid, - NULL, - &NoBuffer, - &Handle - ); - if (EFI_ERROR (Status) && (Status !=3D EFI_BUFFER_TOO_SMALL)) { + + ChildHandle =3D NULL; + Status =3D NetLibCreateServiceChild ( + Controller, + Image, + &gEfiRestExServiceBindingProtocolGuid, + &ChildHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to create service child - %r \n", + __FUNCTION__, + Status + )); return Status; } - - Handle =3D (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffe= r); - if (Handle =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - - Status =3D gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiRestExServiceBindingProtocolGuid, + Status =3D gBS->OpenProtocol ( + ChildHandle, + &gEfiRestExProtocolGuid, + (VOID **)&RestEx, + Image, NULL, - &NoBuffer, - &Handle + EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { - FreePool (Handle); - return Status; + goto ON_ERROR; } =20 // - // Search for the proper REST EX instance. + // Get the information of REST service provided by this EFI REST EX driv= er // - while (NoBuffer !=3D 0) { - ChildHandle =3D NULL; - Status =3D NetLibCreateServiceChild ( - *(Handle + (NoBuffer - 1)), - Image, - &gEfiRestExServiceBindingProtocolGuid, - &ChildHandle - ); - if (!EFI_ERROR (Status)) { - Status =3D gBS->OpenProtocol ( - ChildHandle, - &gEfiRestExProtocolGuid, - (VOID **)&RestEx, - Image, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - // - // Get the information of REST service provided by this EFI REST EX = driver - // - Status =3D RestEx->GetService ( - RestEx, - &RestExServiceInfo - ); - if (EFI_ERROR (Status)) { - goto ON_ERROR; - } - - // - // Check REST EX property. - // - switch (ConfigType) { - case EfiRestExConfigHttp: - LenOfConfig =3D sizeof (EFI_REST_EX_HTTP_CONFIG_DATA); - break; - - case EfiRestExConfigUnspecific: - LenOfConfig =3D REST_EX_CONFIG_DATA_LEN_UNKNOWN; - break; + Status =3D RestEx->GetService ( + RestEx, + &RestExServiceInfo + ); + if (EFI_ERROR (Status)) { + goto ON_ERROR; + } + // + // Check REST EX property. + // + switch (ConfigType) { + case EfiRestExConfigHttp: + LenOfConfig =3D sizeof (EFI_REST_EX_HTTP_CONFIG_DATA); + break; =20 - default: - goto ON_ERROR; - } + case EfiRestExConfigUnspecific: + LenOfConfig =3D REST_EX_CONFIG_DATA_LEN_UNKNOWN; + break; =20 - if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMod= e !=3D AccessMode) || - (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType !=3D= ServiceType) || - (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != =3D ConfigType) || - ((LenOfConfig !=3D REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExSe= rviceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength !=3D LenOfConfig)= )) - { - goto ON_ERROR; - } - } + default: + goto ON_ERROR; + } + if (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != =3D AccessMode || + RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType !=3D Serv= iceType || + RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType !=3D Con= figType || + ((LenOfConfig !=3D REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServic= eInfo->EfiRestExServiceInfoV10.RestExConfigDataLength !=3D LenOfConfig))) { + goto ON_ERROR; + } =20 - // - // This is proper REST EX instance. - // - *ChildInstanceHandle =3D ChildHandle; - FreePool (Handle); - return EFI_SUCCESS; + // + // This is proper REST EX instance. + // + *ChildInstanceHandle =3D ChildHandle; + return EFI_SUCCESS; =20 ON_ERROR:; NetLibDestroyServiceChild ( - *(Handle + (NoBuffer - 1)), + Controller, Image, &gEfiRestExServiceBindingProtocolGuid, ChildHandle ); - NoBuffer--; - } - - FreePool (Handle); return EFI_NOT_FOUND; } diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPk= g/RedfishDiscoverDxe/RedfishDiscoverDxe.c index a247bfed9e34..dd5bdbb377e9 100644 --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c @@ -87,6 +87,7 @@ CreateRestExInstance ( EFI_STATUS Status; =20 Status =3D RestExLibCreateChild ( + Instance->NetworkInterface->OpenDriverControllerHandle, Instance->Owner, FixedPcdGetBool (PcdRedfishDiscoverAccessModeInBand) ? EfiRes= tExServiceInBandAccess : EfiRestExServiceOutOfBandAccess, EfiRestExConfigHttp, --=20 2.39.0