RedfishDiscoverInternal.h 11 KB

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