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