Re: [edk2-devel] [PATCH v3 1/5] DesignWare/DwEmmcDxe: Enabled Internal IDMAC interrupt RX/TX register

2023-11-26 Thread John Chew
On Wed, Nov 22, 2023 at 11:41 PM, Ard Biesheuvel wrote:

> 
> Please elaborate on
> what the problem is and why the changes in the patch are a suitable
> solution.

Hi Ard,

Okay sure. I will write a detailed elaboration in the next patch series.

Thank you.

Regards,

John


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111728): https://edk2.groups.io/g/devel/message/111728
Mute This Topic: https://groups.io/mt/102357268/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 2/5] DesignWare/DwEmmcDxe: Add CPU little endian option

2023-11-26 Thread John Chew
Hi Ard,

I take it this means that the IP can be synthesized in both little and big 
endian versions, right?

Yes, correct.

Is there no ID register in the hardware you can derive this information from?

Yes, in RISC-V we can determine the CPU endianness based on mstatus.MBE and 
mstatus.SBE register in M-Mode and S-Mode respectively.

However, this driver will be used for other architecture, so reading this 
register will not make sense for other architectures such as ARM and x86.

I have not seen any API to call in EDK2 in order to check for CPU endiness.

Alternatively, I can update the handling by using software checking for the CPU 
endianness as follows:

This will not use PCD to determine the CPU endianness.

I will change this handling in the coming patch series if you think it is okay.

Thank you for your time =)

Regards,

John


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111727): https://edk2.groups.io/g/devel/message/111727
Mute This Topic: https://groups.io/mt/102357273/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Optimize CoreInstallMultipleProtocolInterfaces

2023-11-26 Thread Zhi Jin
Hi @Liming Gao,

  Would you please help to review this patch? Thanks!

BRs
Zhi Jin

From: Ni, Ray 
Sent: Thursday, November 09, 2023 10:36 AM
To: Jin, Zhi ; devel@edk2.groups.io
Cc: Wang, Jian J ; Gao, Liming 
; Bi, Dandan 
Subject: Re: [PATCH 1/1] MdeModulePkg: Optimize 
CoreInstallMultipleProtocolInterfaces

Reviewed-by: Ray Ni mailto:ray...@intel.com>>

Thanks,
Ray

From: Jin, Zhi mailto:zhi@intel.com>>
Sent: Thursday, November 9, 2023 9:46 AM
To: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>>
Cc: Jin, Zhi mailto:zhi@intel.com>>; Wang, Jian J 
mailto:jian.j.w...@intel.com>>; Gao, Liming 
mailto:gaolim...@byosoft.com.cn>>; Bi, Dandan 
mailto:dandan...@intel.com>>; Ni, Ray 
mailto:ray...@intel.com>>
Subject: [PATCH 1/1] MdeModulePkg: Optimize 
CoreInstallMultipleProtocolInterfaces

CoreLocateDevicePath is used in CoreInstallMultipleProtocolInterfaces to
check if a Device Path Protocol instance with the same device path is
alreay installed.
CoreLocateDevicePath is a generic API, and would introduce some
unnecessary overhead for such usage.

The optimization is:
1. Implement IsDevicePathInstalled to loop all the Device Path
   Protocols installed and check if any of them matchs the given device
   path.
2. Replace CoreLocateDevicePath with IsDevicePathInstalled in
   CoreInstallMultipleProtocolInterfaces.

This optimization could save several seconds in PCI enumeration on a
system with many PCI devices.

Cc: Jian J Wang mailto:jian.j.w...@intel.com>>
Cc: Liming Gao mailto:gaolim...@byosoft.com.cn>>
Cc: Dandan Bi mailto:dandan...@intel.com>>
Cc: Ray Ni mailto:ray...@intel.com>>
Signed-off-by: Zhi Jin mailto:zhi@intel.com>>
---
 MdeModulePkg/Core/Dxe/Hand/Handle.c | 74 +
 1 file changed, 64 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c 
b/MdeModulePkg/Core/Dxe/Hand/Handle.c
index bd6c57843e..a08cf19bfd 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
@@ -197,6 +197,66 @@ CoreFindProtocolInterface (
   return Prot;
 }

+/**
+  Check if the given device path is already installed
+
+  @param  DevicePathThe given device path
+
+  @retval TRUE  The device path is already installed
+  @retval FALSE The device path is not installed
+
+**/
+BOOLEAN
+IsDevicePathInstalled (
+  IN EFI_DEVICE_PATH_PROTOCOL  *DevicePath
+  )
+{
+  UINTN SourceSize;
+  UINTN Size;
+  BOOLEAN   Found;
+  LIST_ENTRY*Link;
+  PROTOCOL_ENTRY*ProtEntry;
+  PROTOCOL_INTERFACE*Prot;
+
+  if (DevicePath == NULL) {
+return FALSE;
+  }
+
+  Found = FALSE;
+  SourceSize= GetDevicePathSize (DevicePath);
+  ASSERT (SourceSize >= END_DEVICE_PATH_LENGTH);
+
+  CoreAcquireProtocolLock ();
+  //
+  // Look up the protocol entry
+  //
+  ProtEntry = CoreFindProtocolEntry (, FALSE);
+  if (ProtEntry == NULL) {
+goto Done;
+  }
+
+  for (Link = ProtEntry->Protocols.ForwardLink; Link != >Protocols; 
Link = Link->ForwardLink) {
+//
+// Loop on the DevicePathProtocol interfaces
+//
+Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, 
PROTOCOL_INTERFACE_SIGNATURE);
+
+//
+// Check if DevicePath is same as this interface
+//
+Size = GetDevicePathSize (Prot->Interface);
+ASSERT (Size >= END_DEVICE_PATH_LENGTH);
+if ((Size == SourceSize) && (CompareMem (DevicePath, Prot->Interface, Size 
- END_DEVICE_PATH_LENGTH) == 0)) {
+  Found = TRUE;
+  break;
+}
+  }
+
+Done:
+  CoreReleaseProtocolLock ();
+  return Found;
+}
+
 /**
   Removes an event from a register protocol notify list on a protocol.

@@ -517,8 +577,6 @@ CoreInstallMultipleProtocolInterfaces (
   EFI_TPL   OldTpl;
   UINTN Index;
   EFI_HANDLEOldHandle;
-  EFI_HANDLEDeviceHandle;
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;

   if (Handle == NULL) {
 return EFI_INVALID_PARAMETER;
@@ -548,14 +606,10 @@ CoreInstallMultipleProtocolInterfaces (
 //
 // Make sure you are installing on top a device path that has already been 
added.
 //
-if (CompareGuid (Protocol, )) {
-  DeviceHandle = NULL;
-  DevicePath   = Interface;
-  Status   = CoreLocateDevicePath (, 
, );
-  if (!EFI_ERROR (Status) && (DeviceHandle != NULL) && IsDevicePathEnd 
(DevicePath)) {
-Status = EFI_ALREADY_STARTED;
-continue;
-  }
+if (CompareGuid (Protocol, ) &&
+IsDevicePathInstalled (Interface)) {
+  Status = EFI_ALREADY_STARTED;
+  continue;
 }

 //
--
2.39.2


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111726): https://edk2.groups.io/g/devel/message/111726
Mute This Topic: 

[edk2-devel] [PATCH V3 8/9] RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect HI protocol record size

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

The size of structure must be minus with byte that is
occupied by the initial array.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 .../PlatformHostInterfaceBmcUsbNicLib.c   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
index c4a71226e63..a1ce2dd3d93 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
@@ -180,7 +180,7 @@ RedfishPlatformHostInterfaceProtocolData (
   HostNameLength = (UINT8)AsciiStrSize (HostNameString);
   ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD 
*)AllocateZeroPool (
   sizeof 
(MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1 +
-  sizeof 
(REDFISH_OVER_IP_PROTOCOL_DATA) +
+  sizeof 
(REDFISH_OVER_IP_PROTOCOL_DATA) - 1 +
   
HostNameLength
   );
   if (ThisProtocolRecord == NULL) {
@@ -189,7 +189,7 @@ RedfishPlatformHostInterfaceProtocolData (
   }
 
   ThisProtocolRecord->ProtocolType= 
MCHostInterfaceProtocolTypeRedfishOverIP;
-  ThisProtocolRecord->ProtocolTypeDataLen = sizeof 
(REDFISH_OVER_IP_PROTOCOL_DATA) + HostNameLength;
+  ThisProtocolRecord->ProtocolTypeDataLen = sizeof 
(REDFISH_OVER_IP_PROTOCOL_DATA) -1 + HostNameLength;
   RedfishOverIpData   = (REDFISH_OVER_IP_PROTOCOL_DATA 
*)>ProtocolTypeData[0];
   //
   // Fill up REDFISH_OVER_IP_PROTOCOL_DATA
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111725): https://edk2.groups.io/g/devel/message/111725
Mute This Topic: https://groups.io/mt/102824325/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 9/9] RedfishPkg/HostInterfaceBmcUsbNic: Fix potential memory corruption issue

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

Wrong memory allocation issue may result in memory
corruption.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 .../PlatformHostInterfaceBmcUsbNicLib.c   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
index a1ce2dd3d93..2938d54da65 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
@@ -1060,7 +1060,7 @@ IdentifyUsbNicBmcChannel (
 
   InitializeListHead (>NextInstance);
   BmcUsbNic->MacAddressSize = Snp->Mode->HwAddressSize;
-  BmcUsbNic->MacAddress = AllocateZeroPool (sizeof 
(BmcUsbNic->MacAddressSize));
+  BmcUsbNic->MacAddress = AllocatePool (BmcUsbNic->MacAddressSize);
   if (BmcUsbNic->MacAddress == NULL) {
 DEBUG ((DEBUG_ERROR, "Failed to allocate memory for HW MAC 
addresss.\n"));
 FreePool (BmcUsbNic);
@@ -1133,7 +1133,7 @@ CheckBmcUsbNicOnHandles (
 (VOID **)
 );
 if (EFI_ERROR (Status)) {
-  DEBUG ((DEBUG_ERROR, "Failed to locate device path on %d handle.\n", 
__func__, Index));
+  DEBUG ((DEBUG_ERROR, "Failed to locate device path on %d handle.\n", 
Index));
   continue;
 }
 
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111724): https://edk2.groups.io/g/devel/message/111724
Mute This Topic: https://groups.io/mt/102824324/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 6/9] RedfishPkg/RedfishDiscovery: Refine SMBIOS 42h code

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

Refine SMBIOS 42h code add mode debug message
for the error conditions.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 .../RedfishDiscoverInternal.h |  2 ++
 .../RedfishSmbiosHostInterface.c  | 20 +--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
index e27cfa76e39..de7faa4f975 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
@@ -42,6 +42,8 @@
 #define MAC_COMPARE(This, Target)  (CompareMem ((VOID *)&(This)->MacAddress, 
&(Target)->MacAddress, (This)->HwAddressSize) == 0)
 #define VALID_TCP6(Target, This)   ((Target)->IsIpv6 && 
((This)->NetworkProtocolType == ProtocolTypeTcp6))
 #define VALID_TCP4(Target, This)   (!(Target)->IsIpv6 && 
((This)->NetworkProtocolType == ProtocolTypeTcp4))
+#define REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET  
((UINT16)(UINTN)(&((SMBIOS_TABLE_TYPE42 *)0)->InterfaceTypeSpecificDataLength))
+#define REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET   
((UINT16)(UINTN)(&((REDFISH_OVER_IP_PROTOCOL_DATA 
*)0)->RedfishServiceHostnameLength))
 
 //
 // GUID definitions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
index 0d6edc7dc35..57665f367be 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
@@ -56,7 +56,7 @@ RedfishGetHostInterfaceProtocolData (
   mType42Record = (SMBIOS_TABLE_TYPE42 *)Record;
   if (mType42Record->InterfaceType == 
MCHostInterfaceTypeNetworkHostInterface) {
 ASSERT (Record->Length >= 9);
-Offset= 5;
+Offset= REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET;
 RecordTmp = (UINT8 *)Record + Offset;
 //
 // Get interface specific data length.
@@ -70,11 +70,13 @@ RedfishGetHostInterfaceProtocolData (
 //
 if ((*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) || 
(*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) {
   if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
+// According to Redfish Host Interface specification, add 
additional one byte for Device Type field.
 if (SpecificDataLen != sizeof 
(PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) {
   ASSERT (SpecificDataLen == sizeof 
(PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
   return EFI_VOLUME_CORRUPTED;
 }
   } else {
+// According to Redfish Host Interface specification, add 
additional one byte for Device Type field.
 if (SpecificDataLen != sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) 
+ 1) {
   ASSERT (SpecificDataLen == sizeof 
(USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
   return EFI_VOLUME_CORRUPTED;
@@ -105,7 +107,14 @@ RedfishGetHostInterfaceProtocolData (
 // This SMBIOS record is invalid, if the length of protocol 
specific data for
 // Redfish Over IP protocol is wrong.
 //
-if ((*(RecordTmp + 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 
1) != ProtocolLength) {
+if ((*(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + 
sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Length of protocol specific data is not match: %d != 
ProtocolLength(%d).\n",
+__func__,
+*(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + 
sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1,
+ProtocolLength
+));
   return EFI_SECURITY_VIOLATION;
 }
 
@@ -114,6 +123,13 @@ RedfishGetHostInterfaceProtocolData (
 // This SMBIOS record is invalid, if the length is smaller than 
the offset.
 //
 if (Offset > mType42Record->Hdr.Length) {
+  DEBUG ((
+DEBUG_ERROR,
+"%a: Offset (%d) > mType42Record->Hdr.Length (%d).\n",
+__func__,
+Offset,
+mType42Record->Hdr.Length
+));
   return EFI_SECURITY_VIOLATION;
 }
 
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111723): https://edk2.groups.io/g/devel/message/111723
Mute This Topic: https://groups.io/mt/102824323/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 7/9] RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect reference of MAC address pointer

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

MAC address reference is incorrect when it is
copied to Host Interface DeviceDescriptor.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 .../PlatformHostInterfaceBmcUsbNicLib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
index e5bf70cfd58..c4a71226e63 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
@@ -120,7 +120,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   InterfaceData->DeviceDescriptor.UsbDeviceV2.SerialNumberStr = 0;
   CopyMem (
 (VOID *)>DeviceDescriptor.UsbDeviceV2.MacAddress,
-(VOID *)>MacAddress,
+(VOID *)ThisInstance->MacAddress,
 sizeof (InterfaceData->DeviceDescriptor.UsbDeviceV2.MacAddress)
 );
   InterfaceData->DeviceDescriptor.UsbDeviceV2.Characteristics  
|= (UINT16)ThisInstance->CredentialBootstrapping;
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111722): https://edk2.groups.io/g/devel/message/111722
Mute This Topic: https://groups.io/mt/102824322/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 5/9] RedfishPkg/RedfishDiscovery: Add more debug message

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 28ba2d3a9fc..833ae2b969f 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -603,6 +603,27 @@ DiscoverRedfishHostInterface (
 }
 
 if (MacCompareStatus != 0) {
+  DEBUG ((DEBUG_ERROR, "%a: MAC address is not matched.\n", __func__));
+  DEBUG ((
+DEBUG_ERROR,
+"NetworkInterface: %02x %02x %02x %02x %02x %02x.\n",
+Instance->NetworkInterface->MacAddress.Addr[0],
+Instance->NetworkInterface->MacAddress.Addr[1],
+Instance->NetworkInterface->MacAddress.Addr[2],
+Instance->NetworkInterface->MacAddress.Addr[3],
+Instance->NetworkInterface->MacAddress.Addr[4],
+Instance->NetworkInterface->MacAddress.Addr[5]
+));
+  DEBUG ((
+DEBUG_ERROR,
+"Redfish Host interface: %02x %02x %02x %02x %02x %02x.\n",
+DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[0],
+DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[1],
+DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[2],
+DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[3],
+DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[4],
+DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.MacAddress[5]
+));
   return EFI_UNSUPPORTED;
 }
 
@@ -716,6 +737,8 @@ DiscoverRedfishHostInterface (
  IsHttps
  );
 }
+  } else {
+DEBUG ((DEBUG_ERROR, "%a: RedfishGetHostInterfaceProtocolData is 
failed.\n", __func__));
   }
 
   return Status;
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111721): https://edk2.groups.io/g/devel/message/111721
Mute This Topic: https://groups.io/mt/102824320/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 4/9] RedfishPkg/RedfishConfigHandler: Correct the prototype of callback function

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c 
b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c
index b421f51374d..2d0170d8861 100644
--- a/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c
+++ b/RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c
@@ -425,14 +425,14 @@ AcquireRedfishServiceOnNetworkInterfaceCallback (
   protocol interface is installed.
 
   @param[in]   EventEvent whose notification function is being invoked.
-  @param[out]  Context  Pointer to the Context buffer
+  @param[in]   Context  Pointer to the Context buffer
 
 **/
 VOID
 EFIAPI
 RedfishDiscoverProtocolInstalled (
   IN  EFI_EVENT  Event,
-  OUT VOID   *Context
+  IN  VOID   *Context
   )
 {
   EFI_STATUS  Status;
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111720): https://edk2.groups.io/g/devel/message/111720
Mute This Topic: https://groups.io/mt/102824319/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 2/9] RedfishPkg/RedfishHostInterfaceDxe: Add Redfish HI readiness notification

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

Introduce gEdkIIRedfishHostInterfaceReadyProtocolGuid
and produce it when Redfish Host Interface is installed
on system.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 RedfishPkg/RedfishPkg.dec  |  3 +++
 .../RedfishHostInterfaceDxe.inf|  3 ++-
 .../RedfishHostInterfaceDxe.c  | 18 ++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec
index 0f18865cea0..e40538247c2 100644
--- a/RedfishPkg/RedfishPkg.dec
+++ b/RedfishPkg/RedfishPkg.dec
@@ -90,6 +90,9 @@
   ## Include/Protocol/EdkIIRedfishPlatformConfig.h
   gEdkIIRedfishPlatformConfigProtocolGuid = { 0X4D94A7C7, 0X4CE4, 0X4A84, { 
0X88, 0XC1, 0X33, 0X0C, 0XD4, 0XA3, 0X47, 0X67 } }
 
+  # Redfish Host Interface ready notification protocol
+  gEdkIIRedfishHostInterfaceReadyProtocolGuid = { 0xC3F6D062, 0x3D38, 0x4EA4, 
{ 0x92, 0xB1, 0xE8, 0xF8, 0x02, 0x27, 0x63, 0xDF } }
+
 [Guids]
   gEfiRedfishPkgTokenSpaceGuid  = { 0x4fdbccb7, 0xe829, 0x4b4c, { 0x88, 
0x87, 0xb2, 0x3f, 0xd7, 0x25, 0x4b, 0x85 }}
 
diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf 
b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
index 1cdae149aad..f969e75463f 100644
--- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
+++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
@@ -43,7 +43,8 @@
   UefiLib
 
 [Protocols]
-  gEfiSmbiosProtocolGuid## TO_START
+  gEfiSmbiosProtocolGuid   ## TO_START
+  gEdkIIRedfishHostInterfaceReadyProtocolGuid  ## PRODUCED
 
 [Depex]
   gEfiSmbiosProtocolGuid
diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c 
b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
index 55a66decfc8..02d5f14bd20 100644
--- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
+++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
@@ -53,7 +53,9 @@ RedfishCreateSmbiosTable42 (
   SMBIOS_TABLE_TYPE42*Type42Record;
   EFI_SMBIOS_PROTOCOL*Smbios;
   EFI_SMBIOS_HANDLE  MemArrayMappedAddrSmbiosHandle;
+  EFI_HANDLE Handle;
 
+  Handle = NULL;
   //
   // Get platform Redfish host interface device type descriptor data.
   //
@@ -226,6 +228,22 @@ RedfishCreateSmbiosTable42 (
 goto ON_EXIT;
   }
 
+  //
+  // Install Redfish Host Interface ready protocol.
+  //
+  Status = gBS->InstallProtocolInterface (
+  ,
+  ,
+  EFI_NATIVE_INTERFACE,
+  (VOID *)NULL
+  );
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "Failed to install 
gEdkIIRedfishHostInterfaceReadyProtocolGuid.\n"));
+DEBUG ((DEBUG_ERROR, "PlatformConfigHandler driver may not be triggered to 
acquire Redfish service.\n"));
+  }
+
+  // Set Status to EFI_SUCCESS that indicates SMBIOS 42 record was installed
+  // on the platform sucessfully.
   Status = EFI_SUCCESS;
 
 ON_EXIT:
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111718): https://edk2.groups.io/g/devel/message/111718
Mute This Topic: https://groups.io/mt/102824317/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH V3 3/9] RedfishPkg/RedfishConfigHandler: Use Redfish HI readiness notification

2023-11-26 Thread Chang, Abner via 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
 
 [Protocols]
-  gEfiRedfishDiscoverProtocolGuid ## CONSUMES
+  gEfiRedfishDiscoverProtocolGuid  ## CONSUMES
   gEfiRestExServiceBindingProtocolGuid
-  gEfiRestExProtocolGuid  ## CONSUMES
-  gEdkIIRedfishCredentialProtocolGuid ## CONSUMES
-  gEdkIIRedfishConfigHandlerProtocolGuid  ## CONSUMES
+  gEfiRestExProtocolGuid   ## CONSUMES
+  gEdkIIRedfishCredentialProtocolGuid  ## CONSUMES
+  gEdkIIRedfishConfigHandlerProtocolGuid   ## CONSUMES
+  gEdkIIRedfishHostInterfaceReadyProtocolGuid  ## CONSUMES
 
 [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 = NULL;
 //
 // Variables for using RFI Redfish Discover Protocol
 //
-VOID   *gEfiRedfishDiscoverRegistration;
-EFI_HANDLE gEfiRedfishDiscoverControllerHandle = NULL;
-EFI_REDFISH_DISCOVER_PROTOCOL  *gEfiRedfishDiscoverProtocol= NULL;
-BOOLEANgRedfishDiscoverActivated   = FALSE;
-BOOLEANgRedfishServiceDiscovered   = FALSE;
+VOID*gEfiRedfishDiscoverRegistration;
+EFI_HANDLE  gEfiRedfishDiscoverControllerHandle = 
NULL;
+EFI_REDFISH_DISCOVER_PROTOCOL   *gEfiRedfishDiscoverProtocol= 
NULL;
+BOOLEAN gRedfishDiscoverActivated   = 
FALSE;
+BOOLEAN gRedfishServiceDiscovered   = 
FALSE;
+EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  *mNetworkInterfaces = 
NULL;
+UINTN   mNumberOfNetworkInterfaces;
+EFI_EVENT   mEdkIIRedfishHostInterfaceReadyEvent;
+VOID
*mEdkIIRedfishHostInterfaceRegistration;
 
 ///
 /// Driver Binding Protocol instance
@@ -339,6 +343,83 @@ RedfishServiceDiscoveredCallback (
   FreePool (RedfishDiscoveredToken);
 }
 
+/**
+  Callback function executed when the 
gEdkIIRedfishHostInterfaceReadyProtocolGuid
+  protocol interface is installed.
+
+  @param[in]   EventEvent 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 = mNetworkInterfaces;
+  //
+  // Loop to discover Redfish service on each network interface.
+  //
+  for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < 
mNumberOfNetworkInterfaces; NetworkInterfaceIndex++) {
+ThisRedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN 
*)AllocateZeroPool (sizeof (EFI_REDFISH_DISCOVERED_TOKEN));
+if (ThisRedfishDiscoveredToken == NULL) {
+  DEBUG ((DEBUG_ERROR, "%a: Not enough memory for 
EFI_REDFISH_DISCOVERED_TOKEN.\n", __func__));
+  return;
+}
+
+ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
+
+//
+// Initial this Redfish Discovered Token
+//
+Status = gBS->CreateEvent (
+EVT_NOTIFY_SIGNAL,
+TPL_CALLBACK,
+RedfishServiceDiscoveredCallback,
+(VOID *)ThisRedfishDiscoveredToken,
+>Event
+);
+if (EFI_ERROR (Status)) {
+  FreePool (ThisRedfishDiscoveredToken);
+  DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered 
token.\n", __func__));
+  return;
+}
+
+//
+// Acquire for Redfish service which is reported by
+// Redfish Host Interface.
+  

[edk2-devel] [PATCH V3 1/9] RedfishPkg/BmcUsbNicLib: Update BMC USB NIC searching algorithm

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

Update BMC USB NIC searching algorithm for IPv4 only.

Signed-off-by: Abner Chang 
Co-authored-by: Mike Maslenkin 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 .../PlatformHostInterfaceBmcUsbNicLib.c   | 188 --
 1 file changed, 128 insertions(+), 60 deletions(-)

diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
index 95900579118..e5bf70cfd58 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
@@ -368,7 +368,9 @@ RetrievedBmcUsbNicInfo (
 ));
   CopyMem ((VOID *)>RedfishIpAddressIpv4, (VOID 
*)>IpAddress, sizeof (DestIpAddress->IpAddress));
   //
-  // According to UEFI spec, the IP address at BMC USB NIC host end is the 
IP address at BMC end minus 1.
+  // According to the design spec:
+  // 
https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-bmc-and-the-bmc-exposed-usb-network-device
+  // The IP address at BMC USB NIC host end is the IP address at BMC end 
minus 1.
   //
   CopyMem ((VOID *)>HostIpAddressIpv4, (VOID 
*)>IpAddress, sizeof (DestIpAddress->IpAddress));
   ThisInstance->HostIpAddressIpv4[sizeof (ThisInstance->HostIpAddressIpv4) 
- 1] -= 1;
@@ -729,8 +731,10 @@ HostInterfaceIpmiCheckMacAddress (
 
   //
   // According to design spec in Readme file under RedfishPkg.
-  // Compare the first five MAC address and
-  // the 6th MAC address.
+  // 
https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-bmc-and-the-bmc-exposed-usb-network-device
+  // Compare the first five elements of MAC address and the 6th element of 
MAC address.
+  // The 6th element of MAC address must be the 6th element of
+  // IPMI channel MAC address minus 1.
   //
   if ((IpmiLanMacAddressSize != UsbNicInfo->MacAddressSize) ||
   (CompareMem (
@@ -738,8 +742,8 @@ HostInterfaceIpmiCheckMacAddress (
  (VOID *),
  IpmiLanMacAddressSize - 1
  ) != 0) ||
-  (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] !=
-   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1) - 1)
+  ((IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] - 1) !=
+   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1))
   )
   {
 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address is not 
matched.\n"));
@@ -962,6 +966,49 @@ UsbNicSearchUsbIo (
   return EFI_NOT_FOUND;
 }
 
+/**
+  This function identifies if the USB NIC has MAC address and internet
+  protocol device path installed. (Only support IPv4)
+
+  @param[in] UsbDevicePath USB device path.
+
+  @retval EFI_SUCCESS  Yes, this is IPv4 SNP handle
+  @retval EFI_NOT_FOUNDNo, this is not IPv4 SNP handle
+
+**/
+EFI_STATUS
+IdentifyNetworkMessageDevicePath (
+  IN EFI_DEVICE_PATH_PROTOCOL  *UsbDevicePath
+  )
+{
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
+
+  DevicePath = UsbDevicePath;
+  while (TRUE) {
+DevicePath = NextDevicePathNode (DevicePath);
+if (IsDevicePathEnd (DevicePath)) {
+  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address device path is not 
found on this handle.\n"));
+  break;
+}
+
+if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType == 
MSG_MAC_ADDR_DP)) {
+  DevicePath = NextDevicePathNode (DevicePath); // Advance to next device 
path protocol.
+  if (IsDevicePathEnd (DevicePath)) {
+DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "IPv4 device path is not found 
on this handle.\n"));
+break;
+  }
+
+  if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType 
== MSG_IPv4_DP)) {
+return EFI_SUCCESS;
+  }
+
+  break;
+}
+  }
+
+  return EFI_NOT_FOUND;
+}
+
 /**
   This function identifies if the USB NIC is exposed by BMC as
   the host-BMC channel.
@@ -1025,7 +1072,7 @@ IdentifyUsbNicBmcChannel (
 (VOID *)>Mode->CurrentAddress,
 BmcUsbNic->MacAddressSize
 );
-  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address (in size %d) for this 
SNP instance:\n  ", BmcUsbNic->MacAddressSize));
+  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address (in size %d) for this 
SNP instance:\n", BmcUsbNic->MacAddressSize));
   for (Index = 0; Index < BmcUsbNic->MacAddressSize; Index++) {
 DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "%02x ", *(BmcUsbNic->MacAddress + 
Index)));
   }
@@ -1068,7 +1115,8 @@ CheckBmcUsbNicOnHandles (
   UINTN Index;
   EFI_STATUSStatus;
   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
-  BOOLEAN   GotOneUsbNIc;
+  BOOLEAN   GotBmcUsbNic;
+  CHAR16*DevicePathStr;
 
   if 

[edk2-devel] [PATCH V3 0/9] Refine BMC USB NIC discovery and Redfish service enablement

2023-11-26 Thread Chang, Abner via groups.io
From: Abner Chang 

In V3: Address Mike's comments to V2.

In V2: Send additional two patches those are missed
   in V1.

This patch set updates the algorithm of BMC USB
NIC discovery and fixes some bugs.

- Add a new protocol to trigger the notification
  of Redfish Host Interface readiness.
  This fixes the issue Redfish config handler driver
  acquires Redfish service before Redfish Host
  Interface is published.
- Add more error debug messages.
- Address some minor issues

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 

Abner Chang (9):
  RedfishPkg/BmcUsbNicLib: Update BMC USB NIC searching algorithm
  RedfishPkg/RedfishHostInterfaceDxe: Add Redfish HI readiness
notification
  RedfishPkg/RedfishConfigHandler: Use Redfish HI readiness notification
  RedfishPkg/RedfishConfigHandler: Correct the prototype of callback
function
  RedfishPkg/RedfishDiscovery: Add more debug message
  RedfishPkg/RedfishDiscovery: Refine SMBIOS 42h code
  RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect reference of MAC
address pointer
  RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect HI protocol record
size
  RedfishPkg/HostInterfaceBmcUsbNic: Fix potential memory corruption
issue

 RedfishPkg/RedfishPkg.dec |   3 +
 .../RedfishConfigHandlerDriver.inf|   9 +-
 .../RedfishHostInterfaceDxe.inf   |   3 +-
 .../RedfishDiscoverInternal.h |   2 +
 .../PlatformHostInterfaceBmcUsbNicLib.c   | 196 --
 .../RedfishConfigHandlerDriver.c  | 170 +--
 .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   |  23 ++
 .../RedfishSmbiosHostInterface.c  |  20 +-
 .../RedfishHostInterfaceDxe.c |  18 ++
 9 files changed, 315 insertions(+), 129 deletions(-)

-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111716): https://edk2.groups.io/g/devel/message/111716
Mute This Topic: https://groups.io/mt/102824306/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 8/8] RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect HI protocol record size

2023-11-26 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

> -Original Message-
> From: Mike Maslenkin 
> Sent: Monday, November 27, 2023 3:30 AM
> To: Chang, Abner 
> Cc: devel@edk2.groups.io; Nickle Wang ; Igor
> Kulchytskyy 
> Subject: Re: [PATCH V2 8/8] RedfishPkg/HostInterfaceBmcUsbNic: Fix
> incorrect HI protocol record size
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Thu, Nov 23, 2023 at 9:48 AM  wrote:
> >
> > From: Abner Chang 
> >
> > The size of structure must be minus with byte that is
> > occupied by the initial array.
> >
> > Signed-off-by: Abner Chang 
> > Cc: Nickle Wang 
> > Cc: Igor Kulchytskyy 
> > Cc: Mike Maslenkin 
> > ---
> >  .../PlatformHostInterfaceBmcUsbNicLib.c   | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> > index c4a71226e63..a1ce2dd3d93 100644
> > ---
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> > +++
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> > @@ -180,7 +180,7 @@ RedfishPlatformHostInterfaceProtocolData (
> >HostNameLength = (UINT8)AsciiStrSize (HostNameString);
> >ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD
> *)AllocateZeroPool (
> >sizeof
> (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1 +
> > -  sizeof
> (REDFISH_OVER_IP_PROTOCOL_DATA) +
> > +  sizeof
> (REDFISH_OVER_IP_PROTOCOL_DATA) - 1 +
> >
> > HostNameLength
> >);
> >if (ThisProtocolRecord == NULL) {
> > @@ -189,7 +189,7 @@ RedfishPlatformHostInterfaceProtocolData (
> >}
> >
> >ThisProtocolRecord->ProtocolType=
> MCHostInterfaceProtocolTypeRedfishOverIP;
> > -  ThisProtocolRecord->ProtocolTypeDataLen = sizeof
> (REDFISH_OVER_IP_PROTOCOL_DATA) + HostNameLength;
> > +  ThisProtocolRecord->ProtocolTypeDataLen = sizeof
> (REDFISH_OVER_IP_PROTOCOL_DATA) -1 + HostNameLength;
> >RedfishOverIpData   = 
> > (REDFISH_OVER_IP_PROTOCOL_DATA
> *)>ProtocolTypeData[0];
> >//
> >// Fill up REDFISH_OVER_IP_PROTOCOL_DATA
> > --
> > 2.37.1.windows.1
> >
> Excellent!
>
> BTW could we use zero-sized array for
> REDFISH_OVER_IP_PROTOCOL_DATA::RedfishServiceHostname?
> Alternatively, we could use "HostNameLength = (UINT8) AsciiStrLen
> (HostNameString);"  with appropriate comment, that space for \0  is
> already reserved,
Let's update this to zeroed size array in next patch to make the code easily 
read, as we have to update all other structure members those are declared as 
one byte array and remove "-1" from the code as well. You are also welcome to 
update these structures after our changes are merged to the master branch.
Thanks
Abner



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111715): https://edk2.groups.io/g/devel/message/111715
Mute This Topic: https://groups.io/mt/102763123/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 2/8] RedfishPkg/RedfishHostInterfaceDxe: Add Redfish HI readiness notification

2023-11-26 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

> -Original Message-
> From: Mike Maslenkin 
> Sent: Monday, November 27, 2023 3:36 AM
> To: Chang, Abner 
> Cc: devel@edk2.groups.io; Nickle Wang ; Igor
> Kulchytskyy 
> Subject: Re: [PATCH V2 2/8] RedfishPkg/RedfishHostInterfaceDxe: Add
> Redfish HI readiness notification
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On Thu, Nov 23, 2023 at 9:48 AM  wrote:
> >
> > From: Abner Chang 
> >
> > Introduce gEdkIIRedfishHostInterfaceReadyProtocolGuid
> > and produce it when Redfish Host Interface is installed
> > on system.
> >
> > Signed-off-by: Abner Chang 
> > Cc: Nickle Wang 
> > Cc: Igor Kulchytskyy 
> > Cc: Mike Maslenkin 
> > ---
> >  RedfishPkg/RedfishPkg.dec|  3 +++
> >  .../RedfishHostInterfaceDxe.inf  |  3 ++-
> >  .../RedfishHostInterfaceDxe.c| 16 
> >  3 files changed, 21 insertions(+), 1 deletion(-)
> >
> > diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec
> > index 0f18865cea0..e40538247c2 100644
> > --- a/RedfishPkg/RedfishPkg.dec
> > +++ b/RedfishPkg/RedfishPkg.dec
> > @@ -90,6 +90,9 @@
> >## Include/Protocol/EdkIIRedfishPlatformConfig.h
> >gEdkIIRedfishPlatformConfigProtocolGuid = { 0X4D94A7C7, 0X4CE4,
> 0X4A84, { 0X88, 0XC1, 0X33, 0X0C, 0XD4, 0XA3, 0X47, 0X67 } }
> >
> > +  # Redfish Host Interface ready notification protocol
> > +  gEdkIIRedfishHostInterfaceReadyProtocolGuid = { 0xC3F6D062, 0x3D38,
> 0x4EA4, { 0x92, 0xB1, 0xE8, 0xF8, 0x02, 0x27, 0x63, 0xDF } }
> > +
> >  [Guids]
> >gEfiRedfishPkgTokenSpaceGuid  = { 0x4fdbccb7, 0xe829, 0x4b4c, { 0x88,
> 0x87, 0xb2, 0x3f, 0xd7, 0x25, 0x4b, 0x85 }}
> >
> > diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> > index 1cdae149aad..f969e75463f 100644
> > --- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> > +++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> > @@ -43,7 +43,8 @@
> >UefiLib
> >
> >  [Protocols]
> > -  gEfiSmbiosProtocolGuid## TO_START
> > +  gEfiSmbiosProtocolGuid   ## TO_START
> > +  gEdkIIRedfishHostInterfaceReadyProtocolGuid  ## PRODUCED
> >
> >  [Depex]
> >gEfiSmbiosProtocolGuid
> > diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
> b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
> > index 55a66decfc8..94c0f9b6a92 100644
> > --- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
> > +++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
> > @@ -53,7 +53,9 @@ RedfishCreateSmbiosTable42 (
> >SMBIOS_TABLE_TYPE42*Type42Record;
> >EFI_SMBIOS_PROTOCOL*Smbios;
> >EFI_SMBIOS_HANDLE  MemArrayMappedAddrSmbiosHandle;
> > +  EFI_HANDLE Handle;
> >
> > +  Handle = NULL;
> >//
> >// Get platform Redfish host interface device type descriptor data.
> >//
> > @@ -228,6 +230,20 @@ RedfishCreateSmbiosTable42 (
> >
> >Status = EFI_SUCCESS;
> >
> > +  //
> > +  // Install Redfish Host Interface ready protocol.
> > +  //
> > +  Status = gBS->InstallProtocolInterface (
> > +  ,
> > +  ,
> > +  EFI_NATIVE_INTERFACE,
> > +  (VOID *)NULL
> > +  );
> > +  if (EFI_ERROR (Status)) {
> > +DEBUG ((DEBUG_ERROR, "Failed to install
> gEdkIIRedfishHostInterfaceReadyProtocolGuid.\n"));
> > +DEBUG ((DEBUG_ERROR, "PlatformConfigHandler driver may not be
> triggered to acquire Redfish service.\n"));
> > +  }
> > +
> >  ON_EXIT:
> >if (DeviceDescriptor != NULL) {
> >  FreePool (DeviceDescriptor);
> > --
> > 2.37.1.windows.1
> >
>
> You have clobbered explicit Status = EFI_SUCCESS;
> is it intended? Overall result of this function does not depend from
> this InstallProtocolInterface() call, SMBIOS table has been installed
> successfully.
> Looks like InstallProtocolInterface() should be added before Status
> return value set.
No, I didn’t aware this .  Move it to below the new change as SMBIOS 42 is 
installed successfully.

Thanks
Abner




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111714): https://edk2.groups.io/g/devel/message/111714
Mute This Topic: https://groups.io/mt/102763119/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 1/8] RedfishPkg/BmcUsbNicLib: Update BMC USB NIC searching algorithm

2023-11-26 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Mike, your comments will be fixed in V3 9/9.
Thanks for catching this.

Abner
> -Original Message-
> From: Mike Maslenkin 
> Sent: Monday, November 27, 2023 3:38 AM
> To: Chang, Abner 
> Cc: devel@edk2.groups.io; Nickle Wang ; Igor
> Kulchytskyy 
> Subject: Re: [PATCH V2 1/8] RedfishPkg/BmcUsbNicLib: Update BMC USB NIC
> searching algorithm
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> please find my comments below.
>
> On Thu, Nov 23, 2023 at 9:47 AM  wrote:
> >
> > From: Abner Chang 
> >
> > Update BMC USB NIC searching algorithm for IPv4 only.
> >
> > Signed-off-by: Abner Chang 
> > Cc: Nickle Wang 
> > Cc: Igor Kulchytskyy 
> > Cc: Mike Maslenkin 
> > ---
> >  .../PlatformHostInterfaceBmcUsbNicLib.c   | 188 --
> >  1 file changed, 128 insertions(+), 60 deletions(-)
> >
> > diff --git
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> > index 95900579118..e5bf70cfd58 100644
> > ---
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> > +++
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> faceBmcUsbNicLib.c
> > @@ -368,7 +368,9 @@ RetrievedBmcUsbNicInfo (
> >  ));
> >CopyMem ((VOID *)>RedfishIpAddressIpv4, (VOID
> *)>IpAddress, sizeof (DestIpAddress->IpAddress));
> >//
> > -  // According to UEFI spec, the IP address at BMC USB NIC host end is 
> > the
> IP address at BMC end minus 1.
> > +  // According to the design spec:
> > +  //
> https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-
> bmc-and-the-bmc-exposed-usb-network-device
> > +  // The IP address at BMC USB NIC host end is the IP address at BMC 
> > end
> minus 1.
> >//
> >CopyMem ((VOID *)>HostIpAddressIpv4, (VOID
> *)>IpAddress, sizeof (DestIpAddress->IpAddress));
> >ThisInstance->HostIpAddressIpv4[sizeof (ThisInstance-
> >HostIpAddressIpv4) - 1] -= 1;
> > @@ -729,8 +731,10 @@ HostInterfaceIpmiCheckMacAddress (
> >
> >//
> >// According to design spec in Readme file under RedfishPkg.
> > -  // Compare the first five MAC address and
> > -  // the 6th MAC address.
> > +  //
> https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-
> bmc-and-the-bmc-exposed-usb-network-device
> > +  // Compare the first five elements of MAC address and the 6th element
> of MAC address.
> > +  // The 6th element of MAC address must be the 6th element of
> > +  // IPMI channel MAC address minus 1.
> >//
> >if ((IpmiLanMacAddressSize != UsbNicInfo->MacAddressSize) ||
> >(CompareMem (
> > @@ -738,8 +742,8 @@ HostInterfaceIpmiCheckMacAddress (
> >   (VOID *),
> >   IpmiLanMacAddressSize - 1
> >   ) != 0) ||
> > -  (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] !=
> > -   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1) - 1)
> > +  ((IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] -
> 1) !=
> > +   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1))
> >)
> >{
> >  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address is not
> matched.\n"));
> > @@ -962,6 +966,49 @@ UsbNicSearchUsbIo (
> >return EFI_NOT_FOUND;
> >  }
> >
> > +/**
> > +  This function identifies if the USB NIC has MAC address and internet
> > +  protocol device path installed. (Only support IPv4)
> > +
> > +  @param[in] UsbDevicePath USB device path.
> > +
> > +  @retval EFI_SUCCESS  Yes, this is IPv4 SNP handle
> > +  @retval EFI_NOT_FOUNDNo, this is not IPv4 SNP handle
> > +
> > +**/
> > +EFI_STATUS
> > +IdentifyNetworkMessageDevicePath (
> > +  IN EFI_DEVICE_PATH_PROTOCOL  *UsbDevicePath
> > +  )
> > +{
> > +  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> > +
> > +  DevicePath = UsbDevicePath;
> > +  while (TRUE) {
> > +DevicePath = NextDevicePathNode (DevicePath);
> > +if (IsDevicePathEnd (DevicePath)) {
> > +  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address device path
> is not found on this handle.\n"));
> > +  break;
> > +}
> > +
> > +if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath-
> >SubType == MSG_MAC_ADDR_DP)) {
> > +  DevicePath = NextDevicePathNode (DevicePath); // Advance to next
> device path protocol.
> > +  if (IsDevicePathEnd (DevicePath)) {
> > +DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "IPv4 device path is not
> found on this handle.\n"));
> > +break;
> > +  }
> > +
> > +  if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath-
> >SubType == MSG_IPv4_DP)) {
> > +return EFI_SUCCESS;
> > +  }
> > +
> > +   

Re: [edk2-devel] [PATCH v3 09/39] MdePkg: Add a new library named PeiServicesTablePointerLibReg

2023-11-26 Thread Chao Li

Hi Mike and Liming,

You opinion is very important, it will decide the direction. I will send 
the V4 this week, so can you please review the new patch of MdePkg for 
this series?



Thanks,
Chao
On 2023/11/24 19:35, Laszlo Ersek wrote:

On 11/22/23 02:47, Chao Li wrote:

Hi Laszlo,


Thanks,
Chao
On 2023/11/21 22:37, Laszlo Ersek wrote:

On 11/17/23 10:59, Chao Li wrote:

Since some ARCH or platform not require execute code on memory during
PEI phase, some values may transferred via CPU registers.

Adding PeiServcieTablePointerLibReg to allow set and get the PEI service
table pointer depend by a CPU register, this library can accommodate lot
of platforms who not require execte code on memory during PEI phase.

Adding PeiServiceTablePointerLibReg to allows setting and getting the
PEI service table pointer via CPU registers, and the library can
accommodate many platforms that do not need to execute code on memory
during the PEI phase.

The idea of this library is derived from
ArmPkg/Library/PeiServicesTablePointerLib/

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=4584

Cc: Michael D Kinney
Cc: Liming Gao
Cc: Zhiguang Liu
Cc: Leif Lindholm
Cc: Ard Biesheuvel
Cc: Sami Mujawar
Cc: Laszlo Ersek
Cc: Sunil V L
Signed-off-by: Chao Li
---
  .../Library/PeiServicesTablePointerLib.h  | 37 +++-
  .../PeiServicesTablePointer.c | 86 +++
  .../PeiServicesTablePointerLib.uni| 20 +
  .../PeiServicesTablePointerLibReg.inf | 40 +
  MdePkg/MdePkg.dsc |  1 +
  5 files changed, 180 insertions(+), 4 deletions(-)
  create mode 100644 
MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointer.c
  create mode 100644 
MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLib.uni
  create mode 100644 
MdePkg/Library/PeiServicesTablePointerLibReg/PeiServicesTablePointerLibReg.inf

In my opinion, the PeiServicesTablePointerLib class header should not be
extended with new interfaces. I understand that the generality is
attractive, but it is not put to use; only the loongarch architecture
applies the new interfaces (in the subsequent patch), and for example
the ARM code (ArmPkg/Library/PeiServicesTablePointerLib) is not reworked
in terms of these new interfaces.

This libarary have ability of accommodate more ARCH why not? I checked
the PI SPEC, all ARCH except IA32 and X64 using the register mechanism,
if this library can be approved, all of them can moved into this
libraryso that code con be reused more, I think this library is fine.

The library may be fine from a design point of view, but without
actually putting the extra generality to use, it's a waste. It's a
maintenance burden. There's a name for this anti-pattern: it is called
"speculative generality". "It might be useful down the road."

The new generality is only useful if it carries its own weight; namely,
if other platform code (aarch64, x64) is converted to it immediately, in
the same series. (I'm not asking for this series to be longer. You could
even split it up into multiple "waves" of series.) Just saying that
"could prove useful later" is a prime way to generate technical debt.


What's more, the new library interfaces, even though they are exposed in
the lib class header, are not implemented for other architectures, so
they aren't even callable on those arches.

The patch 10 in this series has added LoongArch instance of this
library, please check.

Yes, I'm aware. That's not the point.

When you extend a library *class* with a new API, that means all
*clients* of the library class can stat calling that API. Which in turn
means that *all* existent instances of the library class must implement
the API as well.

Your series extends the lib class with a new API, but (IIUC) only
implements the new API in one (new) lib instance, and not in the other
(existent) instances. This has the potential to cause linkage errors,
dependent on the actual library instance that a platform DSC chooses.



I'm commenting on this patch and the subsequent patch in the series
together, as seen squashed together. NB I'm not an MdePkg maintainer, so
this is just my opinion.

So, Mike and Liming, what do your think?

(1) As noted above, the library class should not be modified.

(2) Modifying the *comments* in
"MdePkg/Include/Library/PeiServicesTablePointerLib.h" is welcome, I
think, but then we might want to add a (separate!) patch for removing
the Itanium language, as edk2 no longer supports Itanium.

(3) The PeiServicesTablePointerLibReg instance should be called
PeiServicesTablePointerLibCsrKs0 or just PeiServicesTablePointerLibKs0.

This library will be a public libray which using the reigster mechanism,
so the name like PeiServiceTablePointerLibCsrKs0 would not appropriate.

Of course that name is wrong for a generic library instance, but my
whole point is that this library instance should be loongarch-specific.

(Unless you port the existent (x64 IDT / 

Re: [edk2-devel] [PATCH v2 3/3] RedfishPkg: fix searching for the BMC-exposed USB NIC

2023-11-26 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Ok, thanks. Then we will just merge 1/3 and 2/3.

Not quite right, as maintainer has to change the label to "push" on PR then CI 
will merge it automatically. So, there must be a PR for the change.  Also for 
the CI tests.

Thanks
Abner

> -Original Message-
> From: Mike Maslenkin 
> Sent: Monday, November 27, 2023 4:41 AM
> To: Chang, Abner 
> Cc: devel@edk2.groups.io; Nickle Wang ;
> ig...@ami.com
> Subject: Re: [edk2-devel] [PATCH v2 3/3] RedfishPkg: fix searching for the
> BMC-exposed USB NIC
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> I agree with your fixes.
> This patch can be dropped from this set.
>
> BTW, do I understand correctly, PR is not required because changes are 
> trivial?
>
> Regards,
> Mike.
>
> On Thu, Nov 23, 2023 at 6:06 AM Chang, Abner 
> wrote:
> >
> > [AMD Official Use Only - General]
> >
> > Good to go. We can merge this after code freeze.
> >
> > Abner
> >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of
> Chang,
> > > Abner via groups.io
> > > Sent: Thursday, November 23, 2023 9:20 AM
> > > To: Nickle Wang ; Mike Maslenkin
> > > ; devel@edk2.groups.io
> > > Cc: ig...@ami.com
> > > Subject: Re: [edk2-devel] [PATCH v2 3/3] RedfishPkg: fix searching for the
> > > BMC-exposed USB NIC
> > >
> > > [AMD Official Use Only - General]
> > >
> > > Caution: This message originated from an External Source. Use proper
> caution
> > > when opening attachments, clicking links, or responding.
> > >
> > >
> > > [AMD Official Use Only - General]
> > >
> > > HI Nickle and Mike,
> > > I also have some fixes and revised BMC USB NIC library for searching BMC
> > > exposed NIC.
> > > Please don't not merge this patch set just for now. I will review this and
> > > compare with the changes I have.
> > >
> > > Thanks
> > > Abner
> > >
> > > > -Original Message-
> > > > From: Nickle Wang 
> > > > Sent: Thursday, November 23, 2023 8:24 AM
> > > > To: Mike Maslenkin ;
> devel@edk2.groups.io
> > > > Cc: Chang, Abner ; ig...@ami.com
> > > > Subject: RE: [PATCH v2 3/3] RedfishPkg: fix searching for the BMC-
> exposed
> > > > USB NIC
> > > >
> > > > Caution: This message originated from an External Source. Use proper
> > > caution
> > > > when opening attachments, clicking links, or responding.
> > > >
> > > >
> > > > Reviewed-by: Nickle Wang 
> > > >
> > > > Regards,
> > > > Nickle
> > > >
> > > > > -Original Message-
> > > > > From: Mike Maslenkin 
> > > > > Sent: Thursday, November 23, 2023 8:01 AM
> > > > > To: devel@edk2.groups.io
> > > > > Cc: abner.ch...@amd.com; Nickle Wang ;
> > > > > ig...@ami.com
> > > > > Subject: [PATCH v2 3/3] RedfishPkg: fix searching for the BMC-exposed
> > > USB
> > > > NIC
> > > > >
> > > > > External email: Use caution opening links or attachments
> > > > >
> > > > >
> > > > > According to RedfishPkg/Readme.md document:
> > > > > "The last byte of host-end USB NIC MAC address is the last byte of
> BMC-
> > > end
> > > > USB
> > > > > NIC MAC address minus 1."
> > > > >
> > > > > It is necessary to subtract 1 from IpmiLanChannelMacAddress.
> > > > >
> > > > > Cc: Abner Chang 
> > > > > Cc: Nickle Wang 
> > > > > Cc: Igor Kulchytskyy 
> > > > > Signed-off-by: Mike Maslenkin 
> > > > > ---
> > > > >  .../PlatformHostInterfaceBmcUsbNicLib.c   | 4 
> > > > > ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git
> > > > >
> > > >
> > >
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> > > > fac
> > > > > eBmcUsbNicLib.c
> > > > >
> > > >
> > >
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> > > > fac
> > > > > eBmcUsbNicLib.c
> > > > > index 95900579118b..20ec89d4fcb0 100644
> > > > > ---
> > > > >
> > > >
> > >
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> > > > fac
> > > > > eBmcUsbNicLib.c
> > > > > +++
> > > >
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostI
> > > > > +++ nterfaceBmcUsbNicLib.c
> > > > > @@ -738,8 +738,8 @@ HostInterfaceIpmiCheckMacAddress (
> > > > >   (VOID *),
> > > > >
> > > > >   IpmiLanMacAddressSize - 1
> > > > >
> > > > >   ) != 0) ||
> > > > >
> > > > > -  (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize -
> 1] !=
> > > > >
> > > > > -   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1) - 1)
> > > > >
> > > > > +  (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1]
> - 1
> > > > > + !=
> > > > >
> > > > > +   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1))
> > > > >
> > > > >)
> > > > >
> > > > >{
> > > > >
> > > > >  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address is
> not
> > > > > matched.\n"));
> > > > >
> > > > > --
> > > > > 2.32.0 (Apple Git-132)
> > >

[edk2-devel] [PATCH V1 1/1] SecurityPkg/DxeTpm2MeasureBootLib: Check the Integer overflow

2023-11-26 Thread sunceping
From: Ceping Sun 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4604

Fields of NumberOfPartitionEntries and SizeOfPartitionEntry in
PrimaryHeader are both UINT32. UINT32 * UINT32 produce UINT32
but it may overflow. So The result should be checked if it is
overflow.

Cc: Jiewen Yao 
Signed-off-by: Min Xu 
Signed-off-by: Ceping Sun 
---
 .../Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c| 5 +
 1 file changed, 5 insertions(+)

diff --git a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c 
b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
index 36a256a7af50..1f891ae7f216 100644
--- a/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
+++ b/SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
@@ -210,6 +210,11 @@ Tcg2MeasureGptTable (
 return EFI_BAD_BUFFER_SIZE;
   }
 
+  if (PrimaryHeader->NumberOfPartitionEntries > MAX_UINT32 / 
PrimaryHeader->SizeOfPartitionEntry) {
+DEBUG ((DEBUG_ERROR, "Overflow of 
PrimaryHeader->NumberOfPartitionEntries(%d) * 
PrimaryHeader->SizeOfPartitionEntry(%d)\n", 
PrimaryHeader->NumberOfPartitionEntries, PrimaryHeader->SizeOfPartitionEntry));
+return EFI_INVALID_PARAMETER;
+  }
+
   //
   // Read the partition entry.
   //
-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111710): https://edk2.groups.io/g/devel/message/111710
Mute This Topic: https://groups.io/mt/102820849/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Event: Tools, CI, Code base construction meeting series - Monday, November 27, 2023 #cal-reminder

2023-11-26 Thread Group Notification
*Reminder: Tools, CI, Code base construction meeting series*

*When:*
Monday, November 27, 2023
4:30pm to 5:30pm
(UTC-08:00) America/Los Angeles

*Where:*
https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZDI2ZDg4NmMtMjI1My00MzI5LWFmYjAtMGQyNjUzNTBjZGYw%40thread.v2/0?context=%7b%22Tid%22%3a%2272f988bf-86f1-41af-91ab-2d7cd011db47%22%2c%22Oid%22%3a%2223af6561-6e1c-450d-b917-d9d674eb3cb6%22%7d

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=2108597 )

*Description:*

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, 
CI, tools, and other related topics. If you are interested, have ideas/opinions 
please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft 
Teams.

MS Teams Link in following discussion: * 
https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

* tianocore/edk2: EDK II (github.com)
* tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module 
(github.com) https://github.com/tianocore/edk2-basetools
* tianocore/edk2-pytool-extensions: Extensions to the edk2 build system 
allowing for a more robust and plugin based build system and tool execution 
environment (github.com) https://github.com/tianocore/edk2-pytool-extensions
* tianocore/edk2-pytool-library: Python library package that supports UEFI 
development (github.com) https://github.com/tianocore/edk2-pytool-library

MS Teams Browser Clients * 
https://docs.microsoft.com/en-us/microsoftteams/get-clients?tabs=Windows#browser-client


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111709): https://edk2.groups.io/g/devel/message/111709
Mute This Topic: https://groups.io/mt/102820702/21656
Mute #cal-reminder:https://edk2.groups.io/g/devel/mutehashtag/cal-reminder
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 3/3] RedfishPkg: fix searching for the BMC-exposed USB NIC

2023-11-26 Thread Mike Maslenkin
Hi Abner,

I agree with your fixes.
This patch can be dropped from this set.

BTW, do I understand correctly, PR is not required because changes are trivial?

Regards,
Mike.

On Thu, Nov 23, 2023 at 6:06 AM Chang, Abner  wrote:
>
> [AMD Official Use Only - General]
>
> Good to go. We can merge this after code freeze.
>
> Abner
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chang,
> > Abner via groups.io
> > Sent: Thursday, November 23, 2023 9:20 AM
> > To: Nickle Wang ; Mike Maslenkin
> > ; devel@edk2.groups.io
> > Cc: ig...@ami.com
> > Subject: Re: [edk2-devel] [PATCH v2 3/3] RedfishPkg: fix searching for the
> > BMC-exposed USB NIC
> >
> > [AMD Official Use Only - General]
> >
> > Caution: This message originated from an External Source. Use proper caution
> > when opening attachments, clicking links, or responding.
> >
> >
> > [AMD Official Use Only - General]
> >
> > HI Nickle and Mike,
> > I also have some fixes and revised BMC USB NIC library for searching BMC
> > exposed NIC.
> > Please don't not merge this patch set just for now. I will review this and
> > compare with the changes I have.
> >
> > Thanks
> > Abner
> >
> > > -Original Message-
> > > From: Nickle Wang 
> > > Sent: Thursday, November 23, 2023 8:24 AM
> > > To: Mike Maslenkin ; devel@edk2.groups.io
> > > Cc: Chang, Abner ; ig...@ami.com
> > > Subject: RE: [PATCH v2 3/3] RedfishPkg: fix searching for the BMC-exposed
> > > USB NIC
> > >
> > > Caution: This message originated from an External Source. Use proper
> > caution
> > > when opening attachments, clicking links, or responding.
> > >
> > >
> > > Reviewed-by: Nickle Wang 
> > >
> > > Regards,
> > > Nickle
> > >
> > > > -Original Message-
> > > > From: Mike Maslenkin 
> > > > Sent: Thursday, November 23, 2023 8:01 AM
> > > > To: devel@edk2.groups.io
> > > > Cc: abner.ch...@amd.com; Nickle Wang ;
> > > > ig...@ami.com
> > > > Subject: [PATCH v2 3/3] RedfishPkg: fix searching for the BMC-exposed
> > USB
> > > NIC
> > > >
> > > > External email: Use caution opening links or attachments
> > > >
> > > >
> > > > According to RedfishPkg/Readme.md document:
> > > > "The last byte of host-end USB NIC MAC address is the last byte of BMC-
> > end
> > > USB
> > > > NIC MAC address minus 1."
> > > >
> > > > It is necessary to subtract 1 from IpmiLanChannelMacAddress.
> > > >
> > > > Cc: Abner Chang 
> > > > Cc: Nickle Wang 
> > > > Cc: Igor Kulchytskyy 
> > > > Signed-off-by: Mike Maslenkin 
> > > > ---
> > > >  .../PlatformHostInterfaceBmcUsbNicLib.c   | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git
> > > >
> > >
> > a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> > > fac
> > > > eBmcUsbNicLib.c
> > > >
> > >
> > b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> > > fac
> > > > eBmcUsbNicLib.c
> > > > index 95900579118b..20ec89d4fcb0 100644
> > > > ---
> > > >
> > >
> > a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInter
> > > fac
> > > > eBmcUsbNicLib.c
> > > > +++
> > > b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostI
> > > > +++ nterfaceBmcUsbNicLib.c
> > > > @@ -738,8 +738,8 @@ HostInterfaceIpmiCheckMacAddress (
> > > >   (VOID *),
> > > >
> > > >   IpmiLanMacAddressSize - 1
> > > >
> > > >   ) != 0) ||
> > > >
> > > > -  (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] !=
> > > >
> > > > -   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1) - 1)
> > > >
> > > > +  (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] - 1
> > > > + !=
> > > >
> > > > +   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1))
> > > >
> > > >)
> > > >
> > > >{
> > > >
> > > >  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address is not
> > > > matched.\n"));
> > > >
> > > > --
> > > > 2.32.0 (Apple Git-132)
> >
> >
> >
> > 
> >
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111708): https://edk2.groups.io/g/devel/message/111708
Mute This Topic: https://groups.io/mt/102759080/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 0/8] Refine BMC USB NIC discovery and Redfish service enablement

2023-11-26 Thread Mike Maslenkin
On Thu, Nov 23, 2023 at 9:47 AM  wrote:
>
> From: Abner Chang 
>
> In V2: Send additional two patches those are missed
>in V1.
>
> This patch set updates the algorithm of BMC USB
> NIC discovery and fixes some bugs.
>
> - Add a new protocol to trigger the notification
>   of Redfish Host Interface readiness.
>   This fixes the issue Redfish config handler driver
>   acquires Redfish service before Redfish Host
>   Interface is published.
> - Add more error debug messages.
> - Address some minor issues
>
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Cc: Mike Maslenkin 
>
> Abner Chang (8):
>   RedfishPkg/BmcUsbNicLib: Update BMC USB NIC searching algorithm
>   RedfishPkg/RedfishHostInterfaceDxe: Add Redfish HI readiness
> notification
>   RedfishPkg/RedfishConfigHandler: Use Redfish HI readiness notification
>   RedfishPkg/RedfishConfigHandler: Correct the prototype of callback
> function
>   RedfishPkg/RedfishDiscovery: Add more debug message
>   RedfishPkg/RedfishDiscovery: Refine SMBIOS 42h code
>   RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect reference of MAC
> address pointer
>   RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect HI protocol record
> size
>
>  RedfishPkg/RedfishPkg.dec |   3 +
>  .../RedfishConfigHandlerDriver.inf|   9 +-
>  .../RedfishHostInterfaceDxe.inf   |   3 +-
>  .../RedfishDiscoverInternal.h |   2 +
>  .../PlatformHostInterfaceBmcUsbNicLib.c   | 194 --
>  .../RedfishConfigHandlerDriver.c  | 170 +--
>  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   |  23 +++
>  .../RedfishSmbiosHostInterface.c  |  20 +-
>  .../RedfishHostInterfaceDxe.c |  16 ++
>  9 files changed, 312 insertions(+), 128 deletions(-)
>
> --
> 2.37.1.windows.1
>

 Hi Abner!

I've checked and tested this patch set and it works for me.
Thank you for these fixes!
I have some comments for patches 1 and 2. All others look good to me.

Regards,
Mike.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111707): https://edk2.groups.io/g/devel/message/111707
Mute This Topic: https://groups.io/mt/102763116/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 1/8] RedfishPkg/BmcUsbNicLib: Update BMC USB NIC searching algorithm

2023-11-26 Thread Mike Maslenkin
Hi Abner,

please find my comments below.

On Thu, Nov 23, 2023 at 9:47 AM  wrote:
>
> From: Abner Chang 
>
> Update BMC USB NIC searching algorithm for IPv4 only.
>
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Cc: Mike Maslenkin 
> ---
>  .../PlatformHostInterfaceBmcUsbNicLib.c   | 188 --
>  1 file changed, 128 insertions(+), 60 deletions(-)
>
> diff --git 
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
>  
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
> index 95900579118..e5bf70cfd58 100644
> --- 
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
> +++ 
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
> @@ -368,7 +368,9 @@ RetrievedBmcUsbNicInfo (
>  ));
>CopyMem ((VOID *)>RedfishIpAddressIpv4, (VOID 
> *)>IpAddress, sizeof (DestIpAddress->IpAddress));
>//
> -  // According to UEFI spec, the IP address at BMC USB NIC host end is 
> the IP address at BMC end minus 1.
> +  // According to the design spec:
> +  // 
> https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-bmc-and-the-bmc-exposed-usb-network-device
> +  // The IP address at BMC USB NIC host end is the IP address at BMC end 
> minus 1.
>//
>CopyMem ((VOID *)>HostIpAddressIpv4, (VOID 
> *)>IpAddress, sizeof (DestIpAddress->IpAddress));
>ThisInstance->HostIpAddressIpv4[sizeof 
> (ThisInstance->HostIpAddressIpv4) - 1] -= 1;
> @@ -729,8 +731,10 @@ HostInterfaceIpmiCheckMacAddress (
>
>//
>// According to design spec in Readme file under RedfishPkg.
> -  // Compare the first five MAC address and
> -  // the 6th MAC address.
> +  // 
> https://github.com/tianocore/edk2/tree/master/RedfishPkg#platform-with-bmc-and-the-bmc-exposed-usb-network-device
> +  // Compare the first five elements of MAC address and the 6th element 
> of MAC address.
> +  // The 6th element of MAC address must be the 6th element of
> +  // IPMI channel MAC address minus 1.
>//
>if ((IpmiLanMacAddressSize != UsbNicInfo->MacAddressSize) ||
>(CompareMem (
> @@ -738,8 +742,8 @@ HostInterfaceIpmiCheckMacAddress (
>   (VOID *),
>   IpmiLanMacAddressSize - 1
>   ) != 0) ||
> -  (IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] !=
> -   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1) - 1)
> +  ((IpmiLanChannelMacAddress.Addr[IpmiLanMacAddressSize - 1] - 1) !=
> +   *(UsbNicInfo->MacAddress + IpmiLanMacAddressSize - 1))
>)
>{
>  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address is not 
> matched.\n"));
> @@ -962,6 +966,49 @@ UsbNicSearchUsbIo (
>return EFI_NOT_FOUND;
>  }
>
> +/**
> +  This function identifies if the USB NIC has MAC address and internet
> +  protocol device path installed. (Only support IPv4)
> +
> +  @param[in] UsbDevicePath USB device path.
> +
> +  @retval EFI_SUCCESS  Yes, this is IPv4 SNP handle
> +  @retval EFI_NOT_FOUNDNo, this is not IPv4 SNP handle
> +
> +**/
> +EFI_STATUS
> +IdentifyNetworkMessageDevicePath (
> +  IN EFI_DEVICE_PATH_PROTOCOL  *UsbDevicePath
> +  )
> +{
> +  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
> +
> +  DevicePath = UsbDevicePath;
> +  while (TRUE) {
> +DevicePath = NextDevicePathNode (DevicePath);
> +if (IsDevicePathEnd (DevicePath)) {
> +  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address device path is not 
> found on this handle.\n"));
> +  break;
> +}
> +
> +if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && (DevicePath->SubType 
> == MSG_MAC_ADDR_DP)) {
> +  DevicePath = NextDevicePathNode (DevicePath); // Advance to next 
> device path protocol.
> +  if (IsDevicePathEnd (DevicePath)) {
> +DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "IPv4 device path is not found 
> on this handle.\n"));
> +break;
> +  }
> +
> +  if ((DevicePath->Type == MESSAGING_DEVICE_PATH) && 
> (DevicePath->SubType == MSG_IPv4_DP)) {
> +return EFI_SUCCESS;
> +  }
> +
> +  break;
> +}
> +  }
> +
> +  return EFI_NOT_FOUND;
> +}
> +
>  /**
>This function identifies if the USB NIC is exposed by BMC as
>the host-BMC channel.
> @@ -1025,7 +1072,7 @@ IdentifyUsbNicBmcChannel (
>  (VOID *)>Mode->CurrentAddress,
>  BmcUsbNic->MacAddressSize
>  );
> -  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address (in size %d) for 
> this SNP instance:\n  ", BmcUsbNic->MacAddressSize));
> +  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "MAC address (in size %d) for 
> this SNP instance:\n", BmcUsbNic->MacAddressSize));
>for (Index = 0; Index < BmcUsbNic->MacAddressSize; Index++) {
>  DEBUG ((DEBUG_REDFISH_HOST_INTERFACE, "%02x ", *(BmcUsbNic->MacAddress + 
> Index)));
>}

Re: [edk2-devel] [PATCH V2 2/8] RedfishPkg/RedfishHostInterfaceDxe: Add Redfish HI readiness notification

2023-11-26 Thread Mike Maslenkin
On Thu, Nov 23, 2023 at 9:48 AM  wrote:
>
> From: Abner Chang 
>
> Introduce gEdkIIRedfishHostInterfaceReadyProtocolGuid
> and produce it when Redfish Host Interface is installed
> on system.
>
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Cc: Mike Maslenkin 
> ---
>  RedfishPkg/RedfishPkg.dec|  3 +++
>  .../RedfishHostInterfaceDxe.inf  |  3 ++-
>  .../RedfishHostInterfaceDxe.c| 16 
>  3 files changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/RedfishPkg/RedfishPkg.dec b/RedfishPkg/RedfishPkg.dec
> index 0f18865cea0..e40538247c2 100644
> --- a/RedfishPkg/RedfishPkg.dec
> +++ b/RedfishPkg/RedfishPkg.dec
> @@ -90,6 +90,9 @@
>## Include/Protocol/EdkIIRedfishPlatformConfig.h
>gEdkIIRedfishPlatformConfigProtocolGuid = { 0X4D94A7C7, 0X4CE4, 0X4A84, { 
> 0X88, 0XC1, 0X33, 0X0C, 0XD4, 0XA3, 0X47, 0X67 } }
>
> +  # Redfish Host Interface ready notification protocol
> +  gEdkIIRedfishHostInterfaceReadyProtocolGuid = { 0xC3F6D062, 0x3D38, 
> 0x4EA4, { 0x92, 0xB1, 0xE8, 0xF8, 0x02, 0x27, 0x63, 0xDF } }
> +
>  [Guids]
>gEfiRedfishPkgTokenSpaceGuid  = { 0x4fdbccb7, 0xe829, 0x4b4c, { 0x88, 
> 0x87, 0xb2, 0x3f, 0xd7, 0x25, 0x4b, 0x85 }}
>
> diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf 
> b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> index 1cdae149aad..f969e75463f 100644
> --- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> +++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.inf
> @@ -43,7 +43,8 @@
>UefiLib
>
>  [Protocols]
> -  gEfiSmbiosProtocolGuid## TO_START
> +  gEfiSmbiosProtocolGuid   ## TO_START
> +  gEdkIIRedfishHostInterfaceReadyProtocolGuid  ## PRODUCED
>
>  [Depex]
>gEfiSmbiosProtocolGuid
> diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c 
> b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
> index 55a66decfc8..94c0f9b6a92 100644
> --- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
> +++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
> @@ -53,7 +53,9 @@ RedfishCreateSmbiosTable42 (
>SMBIOS_TABLE_TYPE42*Type42Record;
>EFI_SMBIOS_PROTOCOL*Smbios;
>EFI_SMBIOS_HANDLE  MemArrayMappedAddrSmbiosHandle;
> +  EFI_HANDLE Handle;
>
> +  Handle = NULL;
>//
>// Get platform Redfish host interface device type descriptor data.
>//
> @@ -228,6 +230,20 @@ RedfishCreateSmbiosTable42 (
>
>Status = EFI_SUCCESS;
>
> +  //
> +  // Install Redfish Host Interface ready protocol.
> +  //
> +  Status = gBS->InstallProtocolInterface (
> +  ,
> +  ,
> +  EFI_NATIVE_INTERFACE,
> +  (VOID *)NULL
> +  );
> +  if (EFI_ERROR (Status)) {
> +DEBUG ((DEBUG_ERROR, "Failed to install 
> gEdkIIRedfishHostInterfaceReadyProtocolGuid.\n"));
> +DEBUG ((DEBUG_ERROR, "PlatformConfigHandler driver may not be triggered 
> to acquire Redfish service.\n"));
> +  }
> +
>  ON_EXIT:
>if (DeviceDescriptor != NULL) {
>  FreePool (DeviceDescriptor);
> --
> 2.37.1.windows.1
>

You have clobbered explicit Status = EFI_SUCCESS;
is it intended? Overall result of this function does not depend from
this InstallProtocolInterface() call, SMBIOS table has been installed
successfully.
Looks like InstallProtocolInterface() should be added before Status
return value set.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111705): https://edk2.groups.io/g/devel/message/111705
Mute This Topic: https://groups.io/mt/102763119/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH V2 8/8] RedfishPkg/HostInterfaceBmcUsbNic: Fix incorrect HI protocol record size

2023-11-26 Thread Mike Maslenkin
On Thu, Nov 23, 2023 at 9:48 AM  wrote:
>
> From: Abner Chang 
>
> The size of structure must be minus with byte that is
> occupied by the initial array.
>
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> Cc: Mike Maslenkin 
> ---
>  .../PlatformHostInterfaceBmcUsbNicLib.c   | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git 
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
>  
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
> index c4a71226e63..a1ce2dd3d93 100644
> --- 
> a/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
> +++ 
> b/RedfishPkg/Library/PlatformHostInterfaceBmcUsbNicLib/PlatformHostInterfaceBmcUsbNicLib.c
> @@ -180,7 +180,7 @@ RedfishPlatformHostInterfaceProtocolData (
>HostNameLength = (UINT8)AsciiStrSize (HostNameString);
>ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD 
> *)AllocateZeroPool (
>sizeof 
> (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1 +
> -  sizeof 
> (REDFISH_OVER_IP_PROTOCOL_DATA) +
> +  sizeof 
> (REDFISH_OVER_IP_PROTOCOL_DATA) - 1 +
>
> HostNameLength
>);
>if (ThisProtocolRecord == NULL) {
> @@ -189,7 +189,7 @@ RedfishPlatformHostInterfaceProtocolData (
>}
>
>ThisProtocolRecord->ProtocolType= 
> MCHostInterfaceProtocolTypeRedfishOverIP;
> -  ThisProtocolRecord->ProtocolTypeDataLen = sizeof 
> (REDFISH_OVER_IP_PROTOCOL_DATA) + HostNameLength;
> +  ThisProtocolRecord->ProtocolTypeDataLen = sizeof 
> (REDFISH_OVER_IP_PROTOCOL_DATA) -1 + HostNameLength;
>RedfishOverIpData   = 
> (REDFISH_OVER_IP_PROTOCOL_DATA *)>ProtocolTypeData[0];
>//
>// Fill up REDFISH_OVER_IP_PROTOCOL_DATA
> --
> 2.37.1.windows.1
>
Excellent!

BTW could we use zero-sized array for
REDFISH_OVER_IP_PROTOCOL_DATA::RedfishServiceHostname?
Alternatively, we could use "HostNameLength = (UINT8) AsciiStrLen
(HostNameString);"  with appropriate comment, that space for \0  is
already reserved,


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111704): https://edk2.groups.io/g/devel/message/111704
Mute This Topic: https://groups.io/mt/102763123/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-