RedfishDiscoverInternal.h 11 KB

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