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