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