From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web09.8531.1657628517413663008 for ; Tue, 12 Jul 2022 05:21:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Hr5s+JNg; spf=permerror, err=parse error for token &{10 18 %{ir}.%{v}.%{d}.spf.has.pphosted.com}: invalid domain name (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0192e24d61=nickle.wang@hpe.com) Received: from pps.filterd (m0134420.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26CCJlVT024469; Tue, 12 Jul 2022 12:21:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pps0720; bh=epMqqXjrAiDqGkO7dbuKVfZnWnWS5PSn7WlIV+HJ73Q=; b=Hr5s+JNgRbVYTv8xEBG6Ql7/Yn8GUkDEnOK0bbLnmyhy/c5ykoE3Z1f6M4QI//45st23 OKPqVpq2cTb24acnXt0SIvBagcmOkFHzgxzLJayKlpg5no/Vxyv5kuu+ba7ef8Upj1tt lD/tcpSOhEoIGtK9eJ7Qu85P9qKsxA3CJe+TfQrsG4l8xIQP/GMF0qu8VcOYYUwhttJz QheqosMEZZ7pNL6ReIJIsQk+ZgXIY0jQAKmz1bIgT0PHAf5KqWpQ5FWyhX8CBeQslGOe TMefaXXKrxcShqSNTm1godx6wFj4/SUSSo45KZrjTuJ0dBidrMNV54QfI7oeJpxa/Ffb Pw== Received: from p1lg14878.it.hpe.com (p1lg14878.it.hpe.com [16.230.97.204]) by mx0b-002e3701.pphosted.com (PPS) with ESMTPS id 3h98uw80kt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jul 2022 12:21:55 +0000 Received: from p1lg14885.dc01.its.hpecorp.net (unknown [10.119.18.236]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14878.it.hpe.com (Postfix) with ESMTPS id 741EF14790; Tue, 12 Jul 2022 12:21:55 +0000 (UTC) Received: from WAFM3XJD5N.asiapacific.hpqcorp.net (unknown [16.231.227.36]) by p1lg14885.dc01.its.hpecorp.net (Postfix) with ESMTP id 6F717802BDD; Tue, 12 Jul 2022 12:21:54 +0000 (UTC) From: "Nickle Wang" To: devel@edk2.groups.io Cc: Abner Chang , Yang Atom , Nick Ramirez Subject: [edk2-staging][PATCH 08/15] edk2-staging/RedfishClientPkg: Update Redfish feature core driver Date: Tue, 12 Jul 2022 20:21:36 +0800 Message-Id: <20220712122143.1827-9-nickle.wang@hpe.com> X-Mailer: git-send-email 2.32.0.windows.2 In-Reply-To: <20220712122143.1827-1-nickle.wang@hpe.com> References: <20220712122143.1827-1-nickle.wang@hpe.com> MIME-Version: 1.0 X-Proofpoint-GUID: rWJ_x17QGdVntqUZtlU36m5Yi9DAHbJy X-Proofpoint-ORIG-GUID: rWJ_x17QGdVntqUZtlU36m5Yi9DAHbJy X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-12_08,2022-07-12_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 lowpriorityscore=0 suspectscore=0 spamscore=0 phishscore=0 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207120048 Content-Transfer-Encoding: quoted-printable Update Redfish feature core driver to support Redfish resource with multiple parents. A resource may be presented in different resource and the link in different resource point to the same location. Also add interchange data interface in feature core driver so feature core driver can talk to feature drivers directly. Signed-off-by: Nickle Wang Cc: Abner Chang Cc: Yang Atom Cc: Nick Ramirez --- .../Include/Protocol/EdkIIRedfishFeature.h | 20 +- .../RedfishFeatureCoreDxe.c | 290 ++++++++++++++++-- .../RedfishFeatureCoreDxe.h | 20 +- .../RedfishFeatureCoreDxe.inf | 5 +- 4 files changed, 278 insertions(+), 57 deletions(-) diff --git a/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h b/Redf= ishClientPkg/Include/Protocol/EdkIIRedfishFeature.h index 036622128d..26814c8786 100644 --- a/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h +++ b/RedfishClientPkg/Include/Protocol/EdkIIRedfishFeature.h @@ -1,7 +1,7 @@ /** @file=0D This file defines the EDKII_REDFISH_FEATURE_PROTOCOL interface.=0D =0D - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -10,6 +10,8 @@ #ifndef EDKII_REDFISH_FEATURE_H_=0D #define EDKII_REDFISH_FEATURE_H_=0D =0D +#include =0D +=0D typedef struct _EDKII_REDFISH_FEATURE_PROTOCOL EDKII_REDFISH_FEATURE_PROTO= COL;=0D =0D #define EDKII_REDFISH_FEATURE_PROTOCOL_GUID \=0D @@ -23,25 +25,13 @@ typedef enum { CallbackActionMax=0D } FEATURE_CALLBACK_ACTION;=0D =0D -typedef enum {=0D - InformationTypeNone =3D 0, ///< Invalid information.=0D - InformationTypeCollectionMemberUri, ///< URI to the new created collecti= on member.=0D - InformationTypeMax=0D -} FEATURE_RETURNED_INFORMATION_TYPE;=0D -=0D -typedef struct {=0D - FEATURE_RETURNED_INFORMATION_TYPE Type;=0D -} FEATURE_RETURNED_INFORMATION;=0D -=0D /**=0D The callback function provided by Redfish Feature driver.=0D =0D @param[in] This Pointer to EDKII_REDFISH_FEATURE_PROT= OCOL instance.=0D @param[in] FeatureAction The action Redfish feature driver sho= uld take.=0D @param[in] Context The context of Redfish feature driver= .=0D - @param[in,out] InformationReturned The pointer to retrive the pointer to= =0D - FEATURE_RETURNED_INFOMATION. The memo= ry block of this=0D - information should be freed by caller= .=0D + @param[in,out] ExchangeInformation The pointer to RESOURCE_INFORMATION_E= XCHANGE.=0D =0D @retval EFI_SUCCESS Redfish feature driver callback is exec= uted successfully.=0D @retval Others Some errors happened.=0D @@ -53,7 +43,7 @@ EFI_STATUS IN EDKII_REDFISH_FEATURE_PROTOCOL *This,=0D IN FEATURE_CALLBACK_ACTION FeatureAction,=0D IN VOID *Context,=0D - IN OUT FEATURE_RETURNED_INFORMATION **InformationReturned=0D + IN OUT RESOURCE_INFORMATION_EXCHANGE *ExchangeInformation=0D );=0D /**=0D The registration function for the Redfish Feature driver.=0D diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c index 49e1cd6b60..3414f0c942 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c @@ -2,7 +2,7 @@ RedfishFeatureCoreDxe produces EdkIIRedfishFeatureCoreProtocol=0D for EDK2 Redfish Feature driver registration.=0D =0D - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -13,38 +13,188 @@ EFI_EVENT mEdkIIRedfishFeatureDriverStartupEvent;=0D REDFISH_FEATURE_STARTUP_CONTEXT mFeatureDriverStartupContext;=0D REDFISH_FEATURE_INTERNAL_DATA *ResourceUriNodeList;=0D +RESOURCE_INFORMATION_EXCHANGE *mInformationExchange;=0D +=0D +/**=0D + Setup the information to deliver to child feature/collection driver.=0D +=0D + @param[in] ThisList REDFISH_FEATURE_INTERNAL_DATA insta= nce.=0D + @param[in] ParentConfgLanguageUri Parent configure language URI.=0D +=0D +**/=0D +EFI_STATUS=0D +SetupExchangeInformationInfo (=0D + IN REDFISH_FEATURE_INTERNAL_DATA *ThisList,=0D + IN EFI_STRING ParentConfgLanguageUri=0D + )=0D +{=0D + ThisList->InformationExchange->SendInformation.ParentUri =3D (EFI_STRING= )AllocateZeroPool (MaxParentUriLength * sizeof (CHAR16));=0D + if (ThisList->InformationExchange->SendInformation.ParentUri =3D=3D NULL= ) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + ThisList->InformationExchange->SendInformation.PropertyName =3D (EFI_STR= ING)AllocateZeroPool(MaxNodeNameLength * sizeof (CHAR16));=0D + if (ThisList->InformationExchange->SendInformation.PropertyName =3D=3D N= ULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D + ThisList->InformationExchange->SendInformation.FullUri =3D (EFI_STRING)A= llocateZeroPool(MaxParentUriLength * sizeof (CHAR16));=0D + if (ThisList->InformationExchange->SendInformation.FullUri =3D=3D NULL) = {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + //=0D + // Setup property name=0D + //=0D + StrCpyS (ThisList->InformationExchange->SendInformation.PropertyName, Ma= xNodeNameLength, ThisList->NodeName);=0D +=0D + //=0D + // Setup parent config language URI=0D + //=0D + StrCpyS (ThisList->InformationExchange->SendInformation.ParentUri, MaxPa= rentUriLength, ParentConfgLanguageUri);=0D +=0D + //=0D + // Full config language URI=0D + //=0D + StrCpyS (ThisList->InformationExchange->SendInformation.FullUri,=0D + MaxParentUriLength,=0D + ThisList->InformationExchange->SendInformation.ParentUri=0D + );=0D + if (StrLen (ThisList->InformationExchange->SendInformation.FullUri) !=3D= 0) {=0D + StrCatS (ThisList->InformationExchange->SendInformation.FullUri, MaxPa= rentUriLength, L"/");=0D + }=0D + StrCatS (ThisList->InformationExchange->SendInformation.FullUri, MaxPare= ntUriLength, ThisList->InformationExchange->SendInformation.PropertyName);= =0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Destroy the exchange information.=0D +=0D + @param[in] ThisList REDFISH_FEATURE_INTERNAL_DATA instance.=0D +=0D +**/=0D +EFI_STATUS=0D +DestroryExchangeInformation (=0D + IN REDFISH_FEATURE_INTERNAL_DATA *ThisList=0D + )=0D +{=0D +=0D + if (ThisList->InformationExchange !=3D NULL) {=0D + if (ThisList->InformationExchange->SendInformation.Type =3D=3D Informa= tionTypeCollectionMemberUri) {=0D + if (ThisList->InformationExchange->SendInformation.ParentUri !=3D NU= LL) {=0D + FreePool (ThisList->InformationExchange->SendInformation.ParentUri= );=0D + ThisList->InformationExchange->SendInformation.ParentUri =3D NULL;= =0D + }=0D + if (ThisList->InformationExchange->SendInformation.PropertyName !=3D= NULL) {=0D + FreePool (ThisList->InformationExchange->SendInformation.PropertyN= ame);=0D + ThisList->InformationExchange->SendInformation.PropertyName =3D NU= LL;=0D + }=0D + if (ThisList->InformationExchange->SendInformation.FullUri !=3D NULL= ) {=0D + FreePool (ThisList->InformationExchange->SendInformation.FullUri);= =0D + ThisList->InformationExchange->SendInformation.FullUri =3D NULL;=0D + }=0D + }=0D +=0D + if (ThisList->InformationExchange->ReturnedInformation.Type =3D=3D Inf= ormationTypeCollectionMemberConfigLanguage) {=0D + DestroyConfiglanguageList (&ThisList->InformationExchange->ReturnedI= nformation.ConfigureLanguageList);=0D + }=0D +=0D + ThisList->InformationExchange->SendInformation.Type =3D InformationTyp= eNone;=0D + ThisList->InformationExchange->ReturnedInformation.Type =3D Informatio= nTypeNone;=0D +=0D + }=0D + return EFI_SUCCESS;=0D +}=0D =0D /**=0D Startup child feature drivers and it's sibing feature drivers.=0D =0D - @param[in] ThisFeatureDriverList This feature driver list.=0D - @param[in] StartupContext Start up information=0D + @param[in] ThisFeatureDriverList This feature driver list.=0D + @param[in] CurrentConfigLanguageUri The current parent configure langua= ge URI.=0D + @param[in] StartupContext Start up information=0D =0D **/=0D VOID=0D StartUpFeatureDriver (=0D IN REDFISH_FEATURE_INTERNAL_DATA *ThisFeatureDriverList,=0D + IN EFI_STRING CurrentConfigLanguageUri,=0D IN REDFISH_FEATURE_STARTUP_CONTEXT *StartupContext=0D )=0D {=0D EFI_STATUS Status;=0D + UINTN Index;=0D REDFISH_FEATURE_INTERNAL_DATA *ThisList;=0D + REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG_LIST ConfigLangList;=0D + EFI_STRING NextParentUri;=0D +=0D + NextParentUri =3D (EFI_STRING)AllocateZeroPool (MaxParentUriLength * siz= eof (CHAR16));=0D + if (NextParentUri =3D=3D NULL) {=0D + DEBUG((DEBUG_ERROR, "%a: Fail to allocate memory for parent configure = language.\n", __FUNCTION__));=0D + return;=0D + }=0D + if (CurrentConfigLanguageUri !=3D NULL) {=0D + StrCpyS(NextParentUri, MaxParentUriLength, CurrentConfigLanguageUri);= =0D + }=0D =0D ThisList =3D ThisFeatureDriverList;=0D while (TRUE) {=0D if (ThisList->Callback !=3D NULL) {=0D - Status =3D ThisList->Callback(=0D - StartupContext->This,=0D - StartupContext->Action,=0D - ThisList->Context,=0D - &ThisList->ReturnedInformation=0D - );=0D + ThisList->InformationExchange =3D mInformationExchange;=0D + Status =3D SetupExchangeInformationInfo (ThisList, NextParentUri);=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D ThisList->Callback(=0D + StartupContext->This,=0D + StartupContext->Action,=0D + ThisList->Context,=0D + ThisList->InformationExchange=0D + );=0D + }=0D if (EFI_ERROR (Status)) {=0D - DEBUG((DEBUG_ERROR, "%a: Callback to EDK2 Redfish feature driver f= ail.", __FUNCTION__));=0D + DEBUG((DEBUG_ERROR, "%a: Callback to EDK2 Redfish feature driver f= ail: %s.\n", __FUNCTION__, ThisList->InformationExchange->SendInformation.F= ullUri));=0D }=0D }=0D - if (ThisList->ChildList !=3D NULL) {=0D - StartUpFeatureDriver (ThisList->ChildList, StartupContext);=0D + if (!EFI_ERROR (Status) && ThisList->Callback !=3D NULL && ThisList->C= hildList !=3D NULL) {=0D + //=0D + // Go through child list only when the parent node is managed by fea= ture driver.=0D + //=0D + if (ThisList->Flags & REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTION) {= =0D + //=0D + // The collection driver's callback is invoked. InformationTypeCol= lectionMemberConfigLanguage=0D + // should be returned in RESOURCE_INFORMATION_RETURNED.=0D + //=0D + if (ThisList->InformationExchange->ReturnedInformation.Type =3D=3D= InformationTypeCollectionMemberConfigLanguage) {=0D + //=0D + // Copy RESOURCE_INFORMATION_RETURNED then destroy the exchange = information.=0D + //=0D + CopyConfiglanguageList (&ThisList->InformationExchange->Returned= Information.ConfigureLanguageList, &ConfigLangList);=0D + DestroryExchangeInformation(ThisList);=0D + //=0D + // Modify the collection instance according to the returned Info= rmationTypeCollectionMemberConfigLanguage.=0D + //=0D + for (Index =3D 0; Index < ConfigLangList.Count; Index ++) {=0D + StrCatS (NextParentUri, MaxParentUriLength, ThisList->NodeName= );=0D + StrCatS (NextParentUri, MaxParentUriLength, NodeIsCollectionSy= mbol);=0D + SetResourceConfigLangMemberInstance (&NextParentUri, MaxParent= UriLength, (REDFISH_FEATURE_ARRAY_TYPE_CONFIG_LANG *)&ConfigLangList.List[I= ndex]);=0D + StartUpFeatureDriver(ThisList->ChildList, NextParentUri, Start= upContext);=0D + }=0D + DestroyConfiglanguageList (&ConfigLangList);=0D + } else {=0D + DEBUG((DEBUG_ERROR, "%a: No InformationTypeCollectionMemberConfi= gLanguage of %s returned.\n", __FUNCTION__, ThisList->InformationExchange->= SendInformation.FullUri));=0D + DEBUG((DEBUG_ERROR, "%a: Redfish service maybe not connected or = the network has problems.\n", __FUNCTION__));=0D + return;=0D + }=0D + } else {=0D + StrCatS (NextParentUri, MaxParentUriLength, ThisList->NodeName);=0D + StartUpFeatureDriver(ThisList->ChildList, NextParentUri, StartupCo= ntext);=0D + }=0D + //=0D + // Restore the parent configure language URI for this level.=0D + //=0D + if (CurrentConfigLanguageUri !=3D NULL) {=0D + StrCpyS(NextParentUri, MaxParentUriLength, CurrentConfigLanguageUr= i);=0D + } else{=0D + NextParentUri [0] =3D 0;=0D + }=0D + } else {=0D + DestroryExchangeInformation (ThisList);=0D }=0D //=0D // Check sibling Redfish feature driver.=0D @@ -57,6 +207,10 @@ StartUpFeatureDriver ( //=0D ThisList =3D ThisList->SiblingList;=0D };=0D + if (NextParentUri !=3D NULL) {=0D + FreePool (NextParentUri);=0D + }=0D +=0D }=0D =0D /**=0D @@ -85,10 +239,30 @@ RedfishFeatureDriverStartup( if (ResourceUriNodeList =3D=3D NULL) {=0D return;=0D }=0D +=0D + //=0D + // Initial dispatcher variables.=0D + //=0D + mInformationExchange =3D (RESOURCE_INFORMATION_EXCHANGE *)AllocateZeroPo= ol (sizeof (RESOURCE_INFORMATION_EXCHANGE));=0D + if (mInformationExchange =3D=3D NULL) {=0D + DEBUG((DEBUG_ERROR, "%a: Fail to allocate memory for exchange informat= ion.\n", __FUNCTION__));=0D + return;=0D + }=0D +=0D + //=0D + // Signal event before doing provisioning=0D + //=0D + SignalReadyToProvisioningEvent ();=0D +=0D //=0D // Invoke the callback by the hierarchy level=0D //=0D - StartUpFeatureDriver (ResourceUriNodeList, StartupContext);=0D + StartUpFeatureDriver (ResourceUriNodeList, NULL, StartupContext);=0D +=0D + //=0D + // Signal event after provisioning finished=0D + //=0D + SignalAfterProvisioningEvent ();=0D }=0D =0D /**=0D @@ -97,6 +271,8 @@ RedfishFeatureDriverStartup( @param[in,out] PtrToNewInternalData Pointer to receive new instance of= =0D REDFISH_FEATURE_INTERNAL_DATA.=0D @param[in] NodeName Name of URI node.=0D + @param[in] NodeIsCollection TRUE means the node to add is the c= ollection node.=0D + Otherwise it is a resource node.=0D =0D @retval EFI_SUCCESS New entry is inserted successfully.=0D @retval EFI_INVALID_PARAMETER Improper given parameters.=0D @@ -106,7 +282,8 @@ RedfishFeatureDriverStartup( EFI_STATUS=0D NewInternalInstance (=0D IN OUT REDFISH_FEATURE_INTERNAL_DATA **PtrToNewInternalData,=0D - IN EFI_STRING NodeName=0D + IN EFI_STRING NodeName,=0D + IN BOOLEAN NodeIsCollection=0D )=0D {=0D REDFISH_FEATURE_INTERNAL_DATA *NewInternalData;=0D @@ -126,8 +303,7 @@ NewInternalInstance ( StrnCpyS (NewInternalData->NodeName, StrSize (NodeName), (CONST CHAR16 *= )NodeName, StrLen (NodeName));=0D NewInternalData->SiblingList =3D NULL;=0D NewInternalData->ChildList =3D NULL;=0D - if (NodeName[0] =3D=3D (UINT16)NodeIsCollectionLeftBracket &&=0D - NodeName [StrLen (NodeName) - 1] =3D=3D (UINT16)NodeIsCollectionRigh= tBracket) {=0D + if (NodeIsCollection) {=0D NewInternalData->Flags |=3D REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTIO= N;=0D }=0D *PtrToNewInternalData =3D NewInternalData;=0D @@ -138,11 +314,15 @@ NewInternalInstance ( Insert the URI node into internal data structure=0D =0D @param[in] HeadEntryToInsert The head entry to start the searchi= ng.=0D + @param[in] PrevisouEntry Previsou entry.=0D @param[in] NodeName Name of URI node.=0D + @param[in] NodeIsCollection TRUE means the node to add is the c= ollection node.=0D + Otherwise it is a resource node.=0D @param[in, out] NextNodeEntry Pointer to receive the pointer of n= ext head=0D entry for inserting the follow up n= odes.=0D The returned LIST_ENTRY is the addr= ess of=0D ChildList link list.=0D + @param[out] MatchNodeEntry The matched node entry.=0D @retval EFI_SUCCESS New entry is inserted successfully.=0D @retval EFI_INVALID_PARAMETER Improper given parameters.=0D @retval EFI_OUT_OF_RESOURCES Lack of memory for the internal data st= ructure.=0D @@ -151,8 +331,11 @@ NewInternalInstance ( EFI_STATUS=0D InsertRedfishFeatureUriNode (=0D IN REDFISH_FEATURE_INTERNAL_DATA *HeadEntryToInsert,=0D + IN REDFISH_FEATURE_INTERNAL_DATA **PrevisouEntry,=0D IN EFI_STRING NodeName,=0D - IN OUT REDFISH_FEATURE_INTERNAL_DATA **NextNodeEntry=0D + IN BOOLEAN NodeIsCollection,=0D + IN OUT REDFISH_FEATURE_INTERNAL_DATA **NextNodeEntry,=0D + OUT REDFISH_FEATURE_INTERNAL_DATA **MatchNodeEntry=0D )=0D {=0D EFI_STATUS Status;=0D @@ -160,6 +343,7 @@ InsertRedfishFeatureUriNode ( REDFISH_FEATURE_INTERNAL_DATA *ThisInternalData;=0D REDFISH_FEATURE_INTERNAL_DATA *SiblingList;=0D =0D + *MatchNodeEntry =3D NULL;=0D if (NodeName =3D=3D NULL) {=0D DEBUG((DEBUG_ERROR, "%a: Node name is NULL.\n", __FUNCTION__));=0D return EFI_INVALID_PARAMETER;=0D @@ -169,17 +353,18 @@ InsertRedfishFeatureUriNode ( return EFI_INVALID_PARAMETER;=0D }=0D =0D - if (HeadEntryToInsert =3D=3D NULL || HeadEntryToInsert->ChildList =3D=3D= NULL) {=0D - Status =3D NewInternalInstance (&NewInternalData, NodeName);=0D + if (HeadEntryToInsert =3D=3D NULL) {=0D + Status =3D NewInternalInstance (&NewInternalData, NodeName, NodeIsColl= ection);=0D if (EFI_ERROR (Status)) {=0D return Status;=0D }=0D - if (HeadEntryToInsert =3D=3D NULL) {=0D + if (HeadEntryToInsert =3D=3D NULL && ResourceUriNodeList =3D=3D NULL) = {=0D ResourceUriNodeList =3D NewInternalData;=0D } else {=0D - HeadEntryToInsert->ChildList =3D NewInternalData;=0D + (*PrevisouEntry)->ChildList =3D NewInternalData;=0D }=0D - *NextNodeEntry =3D NewInternalData;=0D + *PrevisouEntry =3D NewInternalData;=0D + *NextNodeEntry =3D NewInternalData->ChildList;=0D return EFI_SUCCESS;=0D }=0D //=0D @@ -189,22 +374,26 @@ InsertRedfishFeatureUriNode ( SiblingList =3D ThisInternalData->SiblingList;=0D while (TRUE) {=0D if (StrCmp((CONST CHAR16 *)ThisInternalData->NodeName, (CONST CHAR16 *= )NodeName) =3D=3D 0) {=0D + *MatchNodeEntry =3D ThisInternalData;=0D *NextNodeEntry =3D ThisInternalData->ChildList;=0D + *PrevisouEntry =3D ThisInternalData;=0D return EFI_SUCCESS;=0D }=0D //=0D // If sibing exist?=0D //=0D if (SiblingList =3D=3D NULL) {=0D - Status =3D NewInternalInstance (&NewInternalData, NodeName);=0D + Status =3D NewInternalInstance (&NewInternalData, NodeName, NodeIsCo= llection);=0D if (EFI_ERROR (Status)) {=0D return Status;=0D }=0D ThisInternalData->SiblingList =3D NewInternalData;=0D + *PrevisouEntry =3D NewInternalData;=0D *NextNodeEntry =3D NewInternalData->ChildList;=0D return EFI_SUCCESS;=0D }=0D - SiblingList =3D SiblingList->SiblingList;=0D + ThisInternalData =3D SiblingList;=0D + SiblingList =3D ThisInternalData->SiblingList;=0D };=0D return EFI_SUCCESS;=0D }=0D @@ -250,7 +439,12 @@ RedfishFeatureRegister ( UINTN Index;=0D UINTN AnchorIndex;=0D UINTN UriLength;=0D + BOOLEAN NewUri;=0D REDFISH_FEATURE_INTERNAL_DATA *ThisUriNode;=0D + REDFISH_FEATURE_INTERNAL_DATA *PreUriNode;=0D + REDFISH_FEATURE_INTERNAL_DATA *NewUriNode;=0D + REDFISH_FEATURE_INTERNAL_DATA *MatchNodeEntry;=0D + BOOLEAN ItsCollection;=0D =0D if (FeatureManagedUri =3D=3D NULL || Callback =3D=3D NULL) {=0D DEBUG((DEBUG_ERROR, "%a: The given parameter is invalid\n", __FUNCTION= __));=0D @@ -263,27 +457,62 @@ RedfishFeatureRegister ( Index =3D 0;=0D AnchorIndex =3D 0;=0D ThisUriNode =3D ResourceUriNodeList;=0D - do {=0D + PreUriNode =3D ResourceUriNodeList;=0D + NewUri =3D FALSE;=0D + while ((Index < UriLength)) {=0D if ((Index - AnchorIndex + 1) >=3D MaxNodeNameLength) { // Increase on= e for the NULL terminator=0D DEBUG((DEBUG_ERROR, "%a: the length of node name is >=3D MaxNodeName= Length\n", __FUNCTION__));=0D ASSERT (FALSE);=0D }=0D NodeName[Index - AnchorIndex] =3D *(FeatureManagedUri + Index);=0D - if (NodeName [Index - AnchorIndex] =3D=3D NodeSeperator || NodeName [I= ndex - AnchorIndex] =3D=3D (CHAR16)0) {=0D + if (NodeName [Index - AnchorIndex] =3D=3D NodeSeperator || NodeName [I= ndex - AnchorIndex] =3D=3D UriSeperator || NodeName [Index - AnchorIndex] = =3D=3D (CHAR16)0) {=0D + if (NodeName [Index - AnchorIndex] =3D=3D UriSeperator) {=0D + NewUri =3D TRUE;=0D + }=0D NodeName [Index - AnchorIndex] =3D 0;=0D AnchorIndex =3D Index + 1;=0D //=0D // Insert node=0D //=0D if (StrLen(NodeName) !=3D 0) {=0D - Status =3D InsertRedfishFeatureUriNode(ThisUriNode, NodeName, &Thi= sUriNode);=0D + ItsCollection =3D FALSE;=0D + if ((Index + StrLen(NodeIsCollectionSymbol)) < UriLength &&=0D + *(FeatureManagedUri + Index + 1) =3D=3D NodeIsCollectionLeftBr= acket &&=0D + *(FeatureManagedUri + Index + 2) =3D=3D NodeIsCollectionRightB= racket) {=0D + Index +=3D (StrLen(NodeIsCollectionSymbol));=0D + AnchorIndex +=3D (StrLen(NodeIsCollectionSymbol));=0D + ItsCollection =3D TRUE;=0D + if (*(FeatureManagedUri + Index) =3D=3D UriSeperator) {=0D + NewUri =3D TRUE;;=0D + }=0D + }=0D + Status =3D InsertRedfishFeatureUriNode(ThisUriNode, &PreUriNode, N= odeName, ItsCollection, &NewUriNode, &MatchNodeEntry);=0D if (EFI_ERROR (Status)) {=0D return Status;=0D }=0D + ThisUriNode =3D NewUriNode;=0D + }=0D + if (NewUri || ((Index + 1) >=3D UriLength)) {=0D + //=0D + // Setup the callabck and restart the searching for the=0D + // next URI.=0D + //=0D + if (MatchNodeEntry !=3D NULL) {=0D + MatchNodeEntry->Callback =3D Callback;=0D + MatchNodeEntry->Context =3D Context;=0D + MatchNodeEntry =3D NULL;=0D + } else {=0D + PreUriNode->Callback =3D Callback;=0D + PreUriNode->Context =3D Context;=0D + }=0D + NewUri =3D FALSE;=0D + ThisUriNode =3D ResourceUriNodeList;=0D + Index ++;=0D + continue;=0D }=0D }=0D Index ++;=0D - } while ((Index < UriLength));=0D + };=0D =0D if (ThisUriNode =3D=3D NULL) {=0D //=0D @@ -292,11 +521,6 @@ RedfishFeatureRegister ( DEBUG((DEBUG_ERROR, "%a: No URI node is added\n", __FUNCTION__));=0D return EFI_INVALID_PARAMETER;=0D }=0D - //=0D - // Add feature driver info to internal data instance.=0D - //=0D - ThisUriNode->Callback =3D Callback;=0D - ThisUriNode->Context =3D Context;=0D return EFI_SUCCESS;=0D }=0D =0D diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h= b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h index 7b1778b038..84b5e456d1 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.h @@ -1,7 +1,7 @@ /** @file=0D Definitions of RedfishFeatureCoreDxe=0D =0D - (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D + (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -16,22 +16,26 @@ #include =0D #include =0D #include =0D -#include =0D #include =0D +#include =0D +#include =0D =0D #define MaxNodeNameLength 64=0D +#define MaxParentUriLength 512=0D #define NodeSeperator L'/'=0D -#define NodeIsCollectionLeftBracket '{'=0D -#define NodeIsCollectionRightBracket '}'=0D +#define UriSeperator L';'=0D +#define NodeIsCollectionLeftBracket L'{'=0D +#define NodeIsCollectionRightBracket L'}'=0D +#define NodeIsCollectionSymbol L"/{}"=0D =0D typedef struct _REDFISH_FEATURE_INTERNAL_DATA REDFISH_FEATURE_INTERNAL_DAT= A;=0D struct _REDFISH_FEATURE_INTERNAL_DATA {=0D REDFISH_FEATURE_INTERNAL_DATA *SiblingList; ///< Next same level in hier= archy of resource URI.=0D REDFISH_FEATURE_INTERNAL_DATA *ChildList; ///< Next level in hierarchy= of resource URI.=0D - EFI_STRING NodeName; ///< Name of the node in hierarchy= of resource URI.=0D - REDFISH_FEATURE_CALLBACK Callback; ///< Callback function of Redfish = feature driver.=0D - VOID *Context; ///< Context of feature driver.=0D - FEATURE_RETURNED_INFORMATION *ReturnedInformation; ///< Information retu= rned from Redfish feature driver.=0D + EFI_STRING NodeName; ///< Name of the node in hie= rarchy of resource URI.=0D + REDFISH_FEATURE_CALLBACK Callback; ///< Callback function of Re= dfish feature driver.=0D + VOID *Context; ///< Context of feature driv= er.=0D + RESOURCE_INFORMATION_EXCHANGE *InformationExchange; ///< Information ret= urned from Redfish feature driver.=0D UINT32 Flags;=0D };=0D #define REDFISH_FEATURE_INTERNAL_DATA_IS_COLLECTION 0x00000001=0D diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.i= nf b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf index 5a2cd7fecc..ddcf991006 100644 --- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf +++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.inf @@ -3,7 +3,7 @@ # EdkIIRedfishFeatureCoreProtocol to EDK2 Redfish Feature=0D # drivers for the registration.=0D #=0D -# (C) Copyright 2021 Hewlett Packard Enterprise Development LP
=0D +# (C) Copyright 2021-2022 Hewlett Packard Enterprise Development LP
=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D ##=0D @@ -27,6 +27,7 @@ [Packages]=0D MdePkg/MdePkg.dec=0D MdeModulePkg/MdeModulePkg.dec=0D + RedfishPkg/RedfishPkg.dec=0D RedfishClientPkg/RedfishClientPkg.dec=0D =0D [LibraryClasses]=0D @@ -35,6 +36,8 @@ DebugLib=0D MemoryAllocationLib=0D PrintLib=0D + RedfishEventLib=0D + RedfishFeatureUtilityLib=0D UefiBootServicesTableLib=0D UefiDriverEntryPoint=0D UefiLib=0D --=20 2.32.0.windows.2