2 This file defines the EFI Redfish Discover Protocol interface.
4 (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef EFI_REDFISH_DISCOVER_INTERNAL_H_
11 #define EFI_REDFISH_DISCOVER_INTERNAL_H_
15 #include <Protocol/ComponentName.h>
16 #include <Protocol/ComponentName2.h>
17 #include <Protocol/DriverBinding.h>
18 #include <Protocol/RedfishDiscover.h>
19 #include <Protocol/Smbios.h>
20 #include <Protocol/Tcp4.h>
21 #include <Protocol/Tcp6.h>
23 #include <Library/BaseLib.h>
24 #include <Library/BaseMemoryLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/NetLib.h>
28 #include <Library/PrintLib.h>
29 #include <Library/RestExLib.h>
30 #include <Library/UefiLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/UefiDriverEntryPoint.h>
34 #include <IndustryStandard/RedfishHostInterface.h>
36 #define REDFISH_DISCOVER_VERSION 0x00010000
37 #define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY
43 #define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \
45 0xfbab97a4, 0x4c6a, 0xf8e8, { 0xf2, 0x25, 0x42, 0x8a, 0x80, 0x3f, 0xb6, 0xaa } \
48 #define EFI_REDFISH_DISCOVER_TCP6_INSTANCE_GUID \
50 0xbe513b6d, 0x41c1, 0x96Ed, { 0x8d, 0xaf, 0x3e, 0x89, 0xc5, 0xf5, 0x02, 0x25 } \
53 #define EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_GUID \
55 0xc44a6076, 0xd42a, 0x4d54, { 0x85, 0x6d, 0x98, 0x8a, 0x85, 0x8f, 0xa1, 0x11 } \
58 extern EFI_COMPONENT_NAME_PROTOCOL gRedfishDiscoverComponentName
;
59 extern EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2
;
60 extern EFI_UNICODE_STRING_TABLE
*gRedfishDiscoverControllerNameTable
;
63 // Enumeration of network protocols
64 // required for the Redfish service discovery.
67 ProtocolTypeTcp4
= 0, ///< Network protocol TCPv4.
68 ProtocolTypeTcp6
, ///< Network protocol TCCv6.
69 ProtocolTypeRestEx
, ///< REST EX over network protocol.
71 } NETWORK_INTERFACE_PROTOCOL_TYPE
;
74 // Network protocol information installed on
75 // the network interface.
78 EFI_GUID ProtocolGuid
; ///< Network protocol GUID.
79 EFI_GUID ProtocolServiceGuid
; ///< Network protocol service GUID.
80 UINT32 ProtocolDiscoverId
; ///< The identifier installed on network protocol handle.
81 EFI_HANDLE ProtocolControllerHandle
; ///< The controller handle on network protocol.
82 VOID
*NetworkProtocolInterface
; ///< The protocol interface of network protocol.
83 } REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL
;
86 // Internal structure used to maintain network
87 // interface properties.
90 LIST_ENTRY Entry
; ///< Link list entry.
91 EFI_HANDLE OpenDriverAgentHandle
; ///< The agent to open network protocol.
92 EFI_HANDLE OpenDriverControllerHandle
; ///< The controller handle to open network protocol.
93 UINTN HwAddressSize
; ///< The size of network interface hardware address.
94 EFI_MAC_ADDRESS MacAddress
; ///< MAC address of network interface.
95 CHAR16
*StrMacAddr
; ///< String to MAC address of network interface.
96 BOOLEAN GotSubnetInfo
; ///< Indicates sub net information is retrieved.
97 EFI_IP_ADDRESS SubnetAddr
; ///< Subnet ID.
98 EFI_IP_ADDRESS SubnetMask
; ///< Subnet mask (IPv4 only)
99 UINT8 SubnetPrefixLength
; ///< Subnet prefix.
100 UINT16 VlanId
; ///< VLAN ID
101 UINT32 SubnetAddrInfoIPv6Number
; ///< IPv6 address info number.
102 EFI_IP6_ADDRESS_INFO
*SubnetAddrInfoIPv6
; ///< IPv6 address info.
104 // Network interface protocol and REST EX infor.
106 UINT32 NetworkProtocolType
; ///< Network protocol type. Refer to
107 ///< NETWORK_INTERFACE_PROTOCOL_TYPE.
108 REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL NetworkInterfaceProtocolInfo
; ///< Network interface protocol information.
109 EFI_HANDLE RestExHandle
; ///< REST EX handle associated with this network interface.
110 } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
;
113 // Internal structure used to maintain REST EX properties.
116 LIST_ENTRY Entry
; ///< Link list entry.
117 EFI_HANDLE OpenDriverAgentHandle
; ///< The agent to open network protocol.
118 EFI_HANDLE OpenDriverControllerHandle
; ///< The controller handle to open network protocol.
119 EFI_HANDLE RestExChildHandle
; ///< The child handle created throught REST EX Service Protocol.
120 EFI_HANDLE RestExControllerHandle
; ///< The controller handle which provide REST EX protocol.
121 EFI_REST_EX_PROTOCOL
*RestExProtocolInterface
; ///< Pointer to EFI_REST_EX_PROTOCOL.
122 UINT32 RestExId
; ///< The identifier installed on REST EX controller handle.
123 } EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL
;
126 This function to get subnet information.
128 @param[in] ImageHandle EFI handle with this image.
129 @param[in] Instance Instance of Network interface.
130 @retval EFI_STATUS Get subnet information successfully.
131 @retval Otherwise Fail to get subnet information.
135 (EFIAPI
*EFI_REDFISH_DISCOVER_GET_SUBNET_INFO
)(
136 IN EFI_HANDLE ImageHandle
,
137 IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
*Instance
141 // The require network protocol matrix.
144 UINT32 ProtocolType
; ///< Network protocol type,
145 ///< Refer to NETWORK_INTERFACE_PROTOCOL_TYPE.
146 CHAR16
*ProtocolName
; ///< Protocol name.
147 EFI_GUID
*RequiredProtocolGuid
; ///< Network protocol interface GUID.
148 EFI_GUID
*RequiredServiceBindingProtocolGuid
; ///< Network protocol service GUID.
149 EFI_GUID
*DiscoveredProtocolGuid
; ///< Protocol interface GUID use to install identifier.
150 EFI_REDFISH_DISCOVER_GET_SUBNET_INFO GetSubnetInfo
; ///< Function of getting subnet information.
151 } REDFISH_DISCOVER_REQUIRED_PROTOCOL
;
154 // Link list of Redfish discover instance.
157 LIST_ENTRY NextInstance
; ///< Next list.
158 EFI_REDFISH_DISCOVERED_INSTANCE
*Instance
; ///< Pointer to EFI_REDFISH_DISCOVERED_INSTANCE.
159 } EFI_REDFISH_DISCOVERED_INTERNAL_LIST
;
162 // Internal structure of Redfish discover instance.
165 LIST_ENTRY Entry
; ///< Link list entry.
166 EFI_HANDLE Owner
; ///< The owner owns this Redfish service discovery.
167 ///< It's the EFI image handle of driver uses
168 ///< EFI Redfish Discover Protocol.
169 EFI_REDFISH_DISCOVER_FLAG DiscoverFlags
; ///< EFI_REDFISH_DISCOVER_FLAG
170 EFI_REDFISH_DISCOVERED_TOKEN
*DiscoverToken
; ///< Token used to signal when Redfish service is discovered.
171 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
*NetworkInterface
; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
172 ///< instance used to discover Redfish service.
174 // Below for Host insterface discovery.
176 BOOLEAN HostIntfValidation
; ///< Indicates whether to validate Redfish Host interface.
177 EFI_IP_ADDRESS TargetIpAddress
; ///< Target IP address reported in Redfish Host interface.
178 } EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE
;
181 The function adds a new foudn Redfish service to internal list and
184 It simply frees the packet.
186 @param[in] Instance EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE.
187 @param[in] RedfishVersion Redfish version.
188 @param[in] RedfishLocation Redfish location.
189 @param[in] Uuid Service UUID string.
190 @param[in] Os OS string.
191 @param[in] OsVer OS version string.
192 @param[in] Product Product string.
193 @param[in] ProductVer Product verison string.
194 @param[in] UseHttps Redfish service requires secured connection.
195 @retval EFI_SUCCESS Redfish service is added to list successfully.
199 AddAndSignalNewRedfishService (
200 IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE
*Instance
,
201 IN UINTN
*RedfishVersion OPTIONAL
,
202 IN CHAR8
*RedfishLocation OPTIONAL
,
203 IN CHAR8
*Uuid OPTIONAL
,
204 IN CHAR8
*Os OPTIONAL
,
205 IN CHAR8
*OsVer OPTIONAL
,
206 IN CHAR8
*Product OPTIONAL
,
207 IN CHAR8
*ProductVer OPTIONAL
,
212 The function gets information reported in Redfish Host Interface.
214 It simply frees the packet.
216 @param[in] Smbios SMBIOS protocol.
217 @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
218 @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
220 @retval EFI_SUCCESS Get host interface succesfully.
221 @retval Otherwise Fail to tet host interface.
225 RedfishGetHostInterfaceProtocolData (
226 IN EFI_SMBIOS_PROTOCOL
*Smbios
,
227 OUT REDFISH_INTERFACE_DATA
**DeviceDescriptor
,
228 OUT REDFISH_OVER_IP_PROTOCOL_DATA
**ProtocolData
231 extern EFI_GUID gRedfishDiscoverTcp4Instance
;
232 extern EFI_GUID gRedfishDiscoverTcp6Instance
;
233 extern EFI_GUID gRedfishDiscoverRestEXInstance
;