1 | /** @file
|
---|
2 | This file defines the EFI Redfish Discover Protocol interface.
|
---|
3 |
|
---|
4 | (C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
|
---|
5 | Copyright (c) 2022, AMD Incorporated. All rights reserved.
|
---|
6 | Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
---|
7 |
|
---|
8 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
9 |
|
---|
10 | **/
|
---|
11 |
|
---|
12 | #ifndef EFI_REDFISH_DISCOVER_INTERNAL_H_
|
---|
13 | #define EFI_REDFISH_DISCOVER_INTERNAL_H_
|
---|
14 |
|
---|
15 | #include <Uefi.h>
|
---|
16 |
|
---|
17 | #include <Protocol/ComponentName.h>
|
---|
18 | #include <Protocol/ComponentName2.h>
|
---|
19 | #include <Protocol/DriverBinding.h>
|
---|
20 | #include <Protocol/RedfishDiscover.h>
|
---|
21 | #include <Protocol/Smbios.h>
|
---|
22 | #include <Protocol/Tcp4.h>
|
---|
23 | #include <Protocol/Tcp6.h>
|
---|
24 |
|
---|
25 | #include <Library/BaseLib.h>
|
---|
26 | #include <Library/BaseMemoryLib.h>
|
---|
27 | #include <Library/DebugLib.h>
|
---|
28 | #include <Library/MemoryAllocationLib.h>
|
---|
29 | #include <Library/NetLib.h>
|
---|
30 | #include <Library/PrintLib.h>
|
---|
31 | #include <Library/RedfishDebugLib.h>
|
---|
32 | #include <Library/RestExLib.h>
|
---|
33 | #include <Library/UefiLib.h>
|
---|
34 | #include <Library/UefiBootServicesTableLib.h>
|
---|
35 | #include <Library/UefiDriverEntryPoint.h>
|
---|
36 |
|
---|
37 | #include <IndustryStandard/RedfishHostInterface.h>
|
---|
38 |
|
---|
39 | #define REDFISH_DISCOVER_VERSION 0x00010000
|
---|
40 | #define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY
|
---|
41 |
|
---|
42 | //
|
---|
43 | // GUID definitions
|
---|
44 | //
|
---|
45 |
|
---|
46 | #define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \
|
---|
47 | { \
|
---|
48 | 0xfbab97a4, 0x4c6a, 0xf8e8, { 0xf2, 0x25, 0x42, 0x8a, 0x80, 0x3f, 0xb6, 0xaa } \
|
---|
49 | }
|
---|
50 |
|
---|
51 | #define EFI_REDFISH_DISCOVER_TCP6_INSTANCE_GUID \
|
---|
52 | { \
|
---|
53 | 0xbe513b6d, 0x41c1, 0x96Ed, { 0x8d, 0xaf, 0x3e, 0x89, 0xc5, 0xf5, 0x02, 0x25 } \
|
---|
54 | }
|
---|
55 |
|
---|
56 | #define EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_GUID \
|
---|
57 | { \
|
---|
58 | 0xc44a6076, 0xd42a, 0x4d54, { 0x85, 0x6d, 0x98, 0x8a, 0x85, 0x8f, 0xa1, 0x11 } \
|
---|
59 | }
|
---|
60 |
|
---|
61 | extern EFI_COMPONENT_NAME_PROTOCOL gRedfishDiscoverComponentName;
|
---|
62 | extern EFI_COMPONENT_NAME2_PROTOCOL gRedfishDiscoverComponentName2;
|
---|
63 | extern EFI_UNICODE_STRING_TABLE *gRedfishDiscoverControllerNameTable;
|
---|
64 |
|
---|
65 | //
|
---|
66 | // Enumeration of network protocols
|
---|
67 | // required for the Redfish service discovery.
|
---|
68 | //
|
---|
69 | typedef enum {
|
---|
70 | ProtocolTypeTcp4 = 0, ///< Network protocol TCPv4.
|
---|
71 | ProtocolTypeTcp6, ///< Network protocol TCCv6.
|
---|
72 | ProtocolTypeRestEx, ///< REST EX over network protocol.
|
---|
73 | MaxProtocolType
|
---|
74 | } NETWORK_INTERFACE_PROTOCOL_TYPE;
|
---|
75 |
|
---|
76 | //
|
---|
77 | // Network protocol information installed on
|
---|
78 | // the network interface.
|
---|
79 | //
|
---|
80 | typedef struct {
|
---|
81 | EFI_GUID ProtocolGuid; ///< Network protocol GUID.
|
---|
82 | EFI_GUID ProtocolServiceGuid; ///< Network protocol service GUID.
|
---|
83 | UINT32 ProtocolDiscoverId; ///< The identifier installed on network protocol handle.
|
---|
84 | EFI_HANDLE ProtocolControllerHandle; ///< The controller handle on network protocol.
|
---|
85 | VOID *NetworkProtocolInterface; ///< The protocol interface of network protocol.
|
---|
86 | } REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL;
|
---|
87 |
|
---|
88 | //
|
---|
89 | // Internal structure used to maintain network
|
---|
90 | // interface properties.
|
---|
91 | //
|
---|
92 | typedef struct {
|
---|
93 | LIST_ENTRY Entry; ///< Link list entry.
|
---|
94 | EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol.
|
---|
95 | EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol.
|
---|
96 | UINTN HwAddressSize; ///< The size of network interface hardware address.
|
---|
97 | EFI_MAC_ADDRESS MacAddress; ///< MAC address of network interface.
|
---|
98 | CHAR16 *StrMacAddr; ///< String to MAC address of network interface.
|
---|
99 | BOOLEAN GotSubnetInfo; ///< Indicates sub net information is retrieved.
|
---|
100 | EFI_IP_ADDRESS SubnetAddr; ///< Subnet ID.
|
---|
101 | EFI_IP_ADDRESS SubnetMask; ///< Subnet mask (IPv4 only)
|
---|
102 | UINT8 SubnetPrefixLength; ///< Subnet prefix.
|
---|
103 | UINT16 VlanId; ///< VLAN ID
|
---|
104 | UINT32 SubnetAddrInfoIPv6Number; ///< IPv6 address info number.
|
---|
105 | EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6; ///< IPv6 address info.
|
---|
106 | //
|
---|
107 | // Network interface protocol and REST EX info.
|
---|
108 | //
|
---|
109 | UINT32 NetworkProtocolType; ///< Network protocol type. Refer to
|
---|
110 | ///< NETWORK_INTERFACE_PROTOCOL_TYPE.
|
---|
111 | REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL NetworkInterfaceProtocolInfo; ///< Network interface protocol information.
|
---|
112 | EFI_HANDLE RestExHandle; ///< REST EX handle associated with this network interface.
|
---|
113 | //
|
---|
114 | // EFI_REDFISH_DISCOVER_PROTOCOL instance installed
|
---|
115 | // on this network interface.
|
---|
116 | //
|
---|
117 | EFI_HANDLE EfiRedfishDiscoverProtocolHandle; ///< EFI_REDFISH_DISCOVER_PROTOCOL instance installed
|
---|
118 | ///< on this network interface.
|
---|
119 | } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL;
|
---|
120 |
|
---|
121 | //
|
---|
122 | // Redfish Discover Instance signature
|
---|
123 | //
|
---|
124 |
|
---|
125 | #define EFI_REDFISH_DISCOVER_DATA_SIGNATURE SIGNATURE_32 ('E', 'R', 'D', 'D')
|
---|
126 |
|
---|
127 | #define EFI_REDFISH_DISOVER_DATA_FROM_DISCOVER_PROTOCOL(a) \
|
---|
128 | CR (a, EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL, RedfishDiscoverProtocol, EFI_REDFISH_DISCOVER_DATA_SIGNATURE)
|
---|
129 |
|
---|
130 | //
|
---|
131 | // Internal structure used to maintain REST EX properties.
|
---|
132 | //
|
---|
133 | typedef struct {
|
---|
134 | LIST_ENTRY Entry; ///< Link list entry.
|
---|
135 | UINT32 Signature; ///< Instance signature.
|
---|
136 | EFI_HANDLE OpenDriverAgentHandle; ///< The agent to open network protocol.
|
---|
137 | EFI_HANDLE OpenDriverControllerHandle; ///< The controller handle to open network protocol.
|
---|
138 | EFI_HANDLE RestExChildHandle; ///< The child handle created through REST EX Service Protocol.
|
---|
139 | EFI_HANDLE RestExControllerHandle; ///< The controller handle which provide REST EX protocol.
|
---|
140 | EFI_REST_EX_PROTOCOL *RestExProtocolInterface; ///< Pointer to EFI_REST_EX_PROTOCOL.
|
---|
141 | UINT32 RestExId; ///< The identifier installed on REST EX controller handle.
|
---|
142 | UINTN NumberOfNetworkInterfaces; ///< Number of network interfaces can do Redfish service discovery.
|
---|
143 | EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *NetworkInterfaceInstances; ///< Network interface instances. It's an array of instances. The number of entries
|
---|
144 | ///< in array is indicated by NumberOfNetworkInterfaces.
|
---|
145 | EFI_REDFISH_DISCOVER_PROTOCOL RedfishDiscoverProtocol; ///< EFI_REDFISH_DISCOVER_PROTOCOL protocol.
|
---|
146 | } EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL;
|
---|
147 |
|
---|
148 | /**
|
---|
149 | This function to get subnet information.
|
---|
150 |
|
---|
151 | @param[in] ImageHandle EFI handle with this image.
|
---|
152 | @param[in] Instance Instance of Network interface.
|
---|
153 | @retval EFI_STATUS Get subnet information successfully.
|
---|
154 | @retval Otherwise Fail to get subnet information.
|
---|
155 | **/
|
---|
156 | typedef
|
---|
157 | EFI_STATUS
|
---|
158 | (EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)(
|
---|
159 | IN EFI_HANDLE ImageHandle,
|
---|
160 | IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance
|
---|
161 | );
|
---|
162 |
|
---|
163 | //
|
---|
164 | // The require network protocol matrix.
|
---|
165 | //
|
---|
166 | typedef struct {
|
---|
167 | UINT32 ProtocolType; ///< Network protocol type,
|
---|
168 | ///< Refer to NETWORK_INTERFACE_PROTOCOL_TYPE.
|
---|
169 | CHAR16 *ProtocolName; ///< Protocol name.
|
---|
170 | EFI_GUID *RequiredProtocolGuid; ///< Network protocol interface GUID.
|
---|
171 | EFI_GUID *RequiredServiceBindingProtocolGuid; ///< Network protocol service GUID.
|
---|
172 | EFI_GUID *DiscoveredProtocolGuid; ///< Protocol interface GUID use to install identifier.
|
---|
173 | EFI_REDFISH_DISCOVER_GET_SUBNET_INFO GetSubnetInfo; ///< Function of getting subnet information.
|
---|
174 | } REDFISH_DISCOVER_REQUIRED_PROTOCOL;
|
---|
175 |
|
---|
176 | //
|
---|
177 | // Link list of Redfish discover instance.
|
---|
178 | //
|
---|
179 | typedef struct {
|
---|
180 | LIST_ENTRY NextInstance; ///< Next list.
|
---|
181 | EFI_REDFISH_DISCOVERED_INSTANCE *Instance; ///< Pointer to EFI_REDFISH_DISCOVERED_INSTANCE.
|
---|
182 | } EFI_REDFISH_DISCOVERED_INTERNAL_LIST;
|
---|
183 |
|
---|
184 | //
|
---|
185 | // Internal structure of Redfish discover instance.
|
---|
186 | //
|
---|
187 | typedef struct {
|
---|
188 | LIST_ENTRY Entry; ///< Link list entry.
|
---|
189 | EFI_HANDLE Owner; ///< The owner owns this Redfish service discovery.
|
---|
190 | ///< It's the EFI image handle of driver uses
|
---|
191 | ///< EFI Redfish Discover Protocol.
|
---|
192 | EFI_REDFISH_DISCOVER_FLAG DiscoverFlags; ///< EFI_REDFISH_DISCOVER_FLAG
|
---|
193 | EFI_REDFISH_DISCOVERED_TOKEN *DiscoverToken; ///< Token used to signal when Redfish service is discovered.
|
---|
194 | EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
|
---|
195 | ///< instance used to discover Redfish service.
|
---|
196 | //
|
---|
197 | // Below for Host interface discovery.
|
---|
198 | //
|
---|
199 | BOOLEAN HostIntfValidation; ///< Indicates whether to validate Redfish Host interface.
|
---|
200 | EFI_IP_ADDRESS TargetIpAddress; ///< Target IP address reported in Redfish Host interface.
|
---|
201 | UINT8 HostAddrFormat; ///< Unknown=00h, Ipv4=01h, Ipv6=02h.
|
---|
202 | EFI_IP_ADDRESS HostIpAddress; ///< Host IP address reported in Redfish Host interface.
|
---|
203 | EFI_IP_ADDRESS HostSubnetMask; ///< Host subnet mask address reported in Redfish Host interface.
|
---|
204 | } EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE;
|
---|
205 |
|
---|
206 | /**
|
---|
207 | The function adds a new found Redfish service to internal list and
|
---|
208 | notify client.
|
---|
209 |
|
---|
210 | It simply frees the packet.
|
---|
211 |
|
---|
212 | @param[in] Instance EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE.
|
---|
213 | @param[in] RedfishVersion Redfish version.
|
---|
214 | @param[in] RedfishLocation Redfish location.
|
---|
215 | @param[in] Uuid Service UUID string.
|
---|
216 | @param[in] Os OS string.
|
---|
217 | @param[in] OsVer OS version string.
|
---|
218 | @param[in] Product Product string.
|
---|
219 | @param[in] ProductVer Product version string.
|
---|
220 | @param[in] UseHttps Redfish service requires secured connection.
|
---|
221 | @retval EFI_SUCCESS Redfish service is added to list successfully.
|
---|
222 |
|
---|
223 | **/
|
---|
224 | EFI_STATUS
|
---|
225 | AddAndSignalNewRedfishService (
|
---|
226 | IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance,
|
---|
227 | IN UINTN *RedfishVersion OPTIONAL,
|
---|
228 | IN CHAR8 *RedfishLocation OPTIONAL,
|
---|
229 | IN CHAR8 *Uuid OPTIONAL,
|
---|
230 | IN CHAR8 *Os OPTIONAL,
|
---|
231 | IN CHAR8 *OsVer OPTIONAL,
|
---|
232 | IN CHAR8 *Product OPTIONAL,
|
---|
233 | IN CHAR8 *ProductVer OPTIONAL,
|
---|
234 | IN BOOLEAN UseHttps
|
---|
235 | );
|
---|
236 |
|
---|
237 | /**
|
---|
238 | The function gets information reported in Redfish Host Interface.
|
---|
239 |
|
---|
240 | It simply frees the packet.
|
---|
241 |
|
---|
242 | @param[in] Smbios SMBIOS protocol.
|
---|
243 | @param[out] DeviceDescriptor Pointer to REDFISH_INTERFACE_DATA.
|
---|
244 | @param[out] ProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA.
|
---|
245 |
|
---|
246 | @retval EFI_SUCCESS Get host interface successfully.
|
---|
247 | @retval Otherwise Fail to tet host interface.
|
---|
248 |
|
---|
249 | **/
|
---|
250 | EFI_STATUS
|
---|
251 | RedfishGetHostInterfaceProtocolData (
|
---|
252 | IN EFI_SMBIOS_PROTOCOL *Smbios,
|
---|
253 | OUT REDFISH_INTERFACE_DATA **DeviceDescriptor,
|
---|
254 | OUT REDFISH_OVER_IP_PROTOCOL_DATA **ProtocolData
|
---|
255 | );
|
---|
256 |
|
---|
257 | extern EFI_GUID gRedfishDiscoverTcp4Instance;
|
---|
258 | extern EFI_GUID gRedfishDiscoverTcp6Instance;
|
---|
259 | extern EFI_GUID gRedfishDiscoverRestEXInstance;
|
---|
260 | #endif
|
---|