2 RedfishSmbiosHostInterface.c
4 Discover Redfish SMBIOS Host Interface.
6 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include "RedfishDiscoverInternal.h"
14 SMBIOS_TABLE_TYPE42
*mType42Record
;
17 The function gets information reported in Redfish Host Interface.
19 It simply frees the packet.
21 @param[in] Smbios SMBIOS protocol.
22 @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
23 @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
25 @retval EFI_SUCCESS Get host interface succesfully.
26 @retval Otherwise Fail to tet host interface.
30 RedfishGetHostInterfaceProtocolData (
31 IN EFI_SMBIOS_PROTOCOL
*Smbios
,
32 OUT REDFISH_INTERFACE_DATA
**DeviceDescriptor
,
33 OUT REDFISH_OVER_IP_PROTOCOL_DATA
**ProtocolData
37 EFI_SMBIOS_HANDLE SmbiosHandle
;
38 EFI_SMBIOS_TABLE_HEADER
*Record
;
42 UINT8 SpecificDataLen
;
44 if ((Smbios
== NULL
) || (ProtocolData
== NULL
)) {
45 return EFI_INVALID_PARAMETER
;
48 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
49 Status
= Smbios
->GetNext (Smbios
, &SmbiosHandle
, NULL
, &Record
, NULL
);
50 while (!EFI_ERROR (Status
) && SmbiosHandle
!= SMBIOS_HANDLE_PI_RESERVED
) {
51 if (Record
->Type
== SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE
) {
53 // Check Interface Type, should be Network Host Interface = 40h
55 mType42Record
= (SMBIOS_TABLE_TYPE42
*)Record
;
56 if (mType42Record
->InterfaceType
== MCHostInterfaceTypeNetworkHostInterface
) {
57 ASSERT (Record
->Length
>= 9);
59 RecordTmp
= (UINT8
*)Record
+ Offset
;
61 // Get interface specific data length.
63 SpecificDataLen
= *RecordTmp
;
65 RecordTmp
= (UINT8
*)Record
+ Offset
;
68 // Check Device Type, only PCI/PCIe Network Interface v2 is supported now.
70 if (*RecordTmp
== REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2
) {
71 ASSERT (SpecificDataLen
== sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2
) + 1);
72 *DeviceDescriptor
= (REDFISH_INTERFACE_DATA
*)RecordTmp
;
73 Offset
= Offset
+ SpecificDataLen
;
74 RecordTmp
= (UINT8
*)Record
+ Offset
;
76 // Check Protocol count. if > 1, only use the first protocol.
78 ASSERT (*RecordTmp
== 1);
80 RecordTmp
= (UINT8
*)Record
+ Offset
;
82 // Check protocol identifier.
84 if (*RecordTmp
== MCHostInterfaceProtocolTypeRedfishOverIP
) {
86 RecordTmp
= (UINT8
*)Record
+ Offset
;
87 ProtocolLength
= *RecordTmp
;
90 RecordTmp
= (UINT8
*)Record
+ Offset
;
93 // This SMBIOS record is invalid, if the length of protocol specific data for
94 // Redfish Over IP protocol is wrong.
96 if ((*(RecordTmp
+ 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA
) - 1) != ProtocolLength
) {
97 return EFI_SECURITY_VIOLATION
;
100 Offset
+= ProtocolLength
;
102 // This SMBIOS record is invalid, if the length is smaller than the offset.
104 if (Offset
> mType42Record
->Hdr
.Length
) {
105 return EFI_SECURITY_VIOLATION
;
108 *ProtocolData
= (REDFISH_OVER_IP_PROTOCOL_DATA
*)RecordTmp
;
115 Status
= Smbios
->GetNext (Smbios
, &SmbiosHandle
, NULL
, &Record
, NULL
);
118 *ProtocolData
= NULL
;
119 return EFI_NOT_FOUND
;