RedfishPlatformHostInterfaceLib.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. /** @file
  2. PCI/PCIe network interface instace of RedfishPlatformHostInterfaceLib
  3. Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
  4. (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
  5. Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.<BR>
  6. SPDX-License-Identifier: BSD-2-Clause-Patent
  7. **/
  8. #include <Uefi.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/BaseMemoryLib.h>
  11. #include <Library/DebugLib.h>
  12. #include <Library/DevicePathLib.h>
  13. #include <Library/MemoryAllocationLib.h>
  14. #include <Library/PrintLib.h>
  15. #include <Library/RedfishHostInterfaceLib.h>
  16. #include <Library/UefiLib.h>
  17. #include <Library/UefiBootServicesTableLib.h>
  18. #include <Library/UefiRuntimeServicesTableLib.h>
  19. #include <Pcd/RestExServiceDevicePath.h>
  20. #include <Guid/GlobalVariable.h>
  21. #define VERBOSE_COLUME_SIZE (16)
  22. REDFISH_OVER_IP_PROTOCOL_DATA *mRedfishOverIpProtocolData;
  23. UINT8 mRedfishProtocolDataSize;
  24. /**
  25. Get the MAC address of NIC.
  26. @param[out] MacAddress Pointer to retrieve MAC address
  27. @retval EFI_SUCCESS MAC address is returned in MacAddress
  28. **/
  29. EFI_STATUS
  30. GetMacAddressInformation (
  31. OUT EFI_MAC_ADDRESS *MacAddress
  32. )
  33. {
  34. MAC_ADDR_DEVICE_PATH *Mac;
  35. REST_EX_SERVICE_DEVICE_PATH_DATA *RestExServiceDevicePathData;
  36. EFI_DEVICE_PATH_PROTOCOL *RestExServiceDevicePath;
  37. MAC_ADDR_DEVICE_PATH *MacAddressDevicePath;
  38. Mac = NULL;
  39. RestExServiceDevicePathData = NULL;
  40. RestExServiceDevicePath = NULL;
  41. RestExServiceDevicePathData = (REST_EX_SERVICE_DEVICE_PATH_DATA *)PcdGetPtr (PcdRedfishRestExServiceDevicePath);
  42. if ((RestExServiceDevicePathData == NULL) ||
  43. (RestExServiceDevicePathData->DevicePathNum == 0) ||
  44. !IsDevicePathValid (RestExServiceDevicePathData->DevicePath, 0))
  45. {
  46. return EFI_NOT_FOUND;
  47. }
  48. RestExServiceDevicePath = RestExServiceDevicePathData->DevicePath;
  49. if (RestExServiceDevicePathData->DevicePathMatchMode != DEVICE_PATH_MATCH_MAC_NODE) {
  50. return EFI_NOT_FOUND;
  51. }
  52. //
  53. // Find Mac DevicePath Node.
  54. //
  55. while (!IsDevicePathEnd (RestExServiceDevicePath) &&
  56. ((DevicePathType (RestExServiceDevicePath) != MESSAGING_DEVICE_PATH) ||
  57. (DevicePathSubType (RestExServiceDevicePath) != MSG_MAC_ADDR_DP)))
  58. {
  59. RestExServiceDevicePath = NextDevicePathNode (RestExServiceDevicePath);
  60. }
  61. if (!IsDevicePathEnd (RestExServiceDevicePath)) {
  62. MacAddressDevicePath = (MAC_ADDR_DEVICE_PATH *)RestExServiceDevicePath;
  63. CopyMem ((VOID *)MacAddress, (VOID *)&MacAddressDevicePath->MacAddress, sizeof (EFI_MAC_ADDRESS));
  64. return EFI_SUCCESS;
  65. }
  66. return EFI_NOT_FOUND;
  67. }
  68. /**
  69. Get platform Redfish host interface device descriptor.
  70. @param[out] DeviceType Pointer to retrieve device type.
  71. @param[out] DeviceDescriptor Pointer to retrieve REDFISH_INTERFACE_DATA, caller has to free
  72. this memory using FreePool().
  73. @retval EFI_SUCCESS Device descriptor is returned successfully in DeviceDescriptor.
  74. @retval EFI_NOT_FOUND No Redfish host interface descriptor provided on this platform.
  75. @retval Others Fail to get device descriptor.
  76. **/
  77. EFI_STATUS
  78. RedfishPlatformHostInterfaceDeviceDescriptor (
  79. OUT UINT8 *DeviceType,
  80. OUT REDFISH_INTERFACE_DATA **DeviceDescriptor
  81. )
  82. {
  83. EFI_STATUS Status;
  84. EFI_MAC_ADDRESS MacAddress;
  85. REDFISH_INTERFACE_DATA *RedfishInterfaceData;
  86. PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *ThisDeviceDescriptor;
  87. RedfishInterfaceData = AllocateZeroPool (sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
  88. if (RedfishInterfaceData == NULL) {
  89. return EFI_OUT_OF_RESOURCES;
  90. }
  91. RedfishInterfaceData->DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
  92. //
  93. // Fill up device type information.
  94. //
  95. ThisDeviceDescriptor = (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2 *)((UINT8 *)RedfishInterfaceData + 1);
  96. ThisDeviceDescriptor->Length = sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1;
  97. Status = GetMacAddressInformation (&MacAddress);
  98. if (EFI_ERROR (Status)) {
  99. FreePool (RedfishInterfaceData);
  100. return EFI_NOT_FOUND;
  101. }
  102. CopyMem ((VOID *)&ThisDeviceDescriptor->MacAddress, (VOID *)&MacAddress, sizeof (ThisDeviceDescriptor->MacAddress));
  103. *DeviceType = REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2;
  104. *DeviceDescriptor = RedfishInterfaceData;
  105. return EFI_SUCCESS;
  106. }
  107. /**
  108. Get platform Redfish host interface protocol data.
  109. Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
  110. Then continuously pass previous ProtocolRecord for retrieving the next ProtocolRecord.
  111. @param[out] ProtocolRecord Pointer to retrieve the protocol record.
  112. caller has to free the new protocol record returned from
  113. this function using FreePool().
  114. @param[in] IndexOfProtocolData The index of protocol data.
  115. @retval EFI_SUCCESS Protocol records are all returned.
  116. @retval EFI_NOT_FOUND No more protocol records.
  117. @retval Others Fail to get protocol records.
  118. **/
  119. EFI_STATUS
  120. RedfishPlatformHostInterfaceProtocolData (
  121. OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
  122. IN UINT8 IndexOfProtocolData
  123. )
  124. {
  125. MC_HOST_INTERFACE_PROTOCOL_RECORD *ThisProtocolRecord;
  126. if (mRedfishOverIpProtocolData == 0) {
  127. return EFI_NOT_FOUND;
  128. }
  129. if (IndexOfProtocolData == 0) {
  130. //
  131. // Return the first Redfish protocol data to caller. We only have
  132. // one protocol data in this case.
  133. //
  134. ThisProtocolRecord = (MC_HOST_INTERFACE_PROTOCOL_RECORD *)AllocatePool (mRedfishProtocolDataSize + sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - 1);
  135. ThisProtocolRecord->ProtocolType = MCHostInterfaceProtocolTypeRedfishOverIP;
  136. ThisProtocolRecord->ProtocolTypeDataLen = mRedfishProtocolDataSize;
  137. CopyMem ((VOID *)&ThisProtocolRecord->ProtocolTypeData, (VOID *)mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
  138. *ProtocolRecord = ThisProtocolRecord;
  139. return EFI_SUCCESS;
  140. }
  141. return EFI_NOT_FOUND;
  142. }
  143. /**
  144. Dump IPv4 address.
  145. @param[in] Ip IPv4 address
  146. **/
  147. VOID
  148. InternalDumpIp4Addr (
  149. IN EFI_IPv4_ADDRESS *Ip
  150. )
  151. {
  152. UINTN Index;
  153. for (Index = 0; Index < 4; Index++) {
  154. DEBUG ((DEBUG_VERBOSE, "%d", Ip->Addr[Index]));
  155. if (Index < 3) {
  156. DEBUG ((DEBUG_VERBOSE, "."));
  157. }
  158. }
  159. DEBUG ((DEBUG_VERBOSE, "\n"));
  160. }
  161. /**
  162. Dump IPv6 address.
  163. @param[in] Ip IPv6 address
  164. **/
  165. VOID
  166. InternalDumpIp6Addr (
  167. IN EFI_IPv6_ADDRESS *Ip
  168. )
  169. {
  170. UINTN Index;
  171. for (Index = 0; Index < 16; Index++) {
  172. if (Ip->Addr[Index] != 0) {
  173. DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
  174. }
  175. Index++;
  176. if (Index > 15) {
  177. return;
  178. }
  179. if (((Ip->Addr[Index] & 0xf0) == 0) && (Ip->Addr[Index - 1] != 0)) {
  180. DEBUG ((DEBUG_VERBOSE, "0"));
  181. }
  182. DEBUG ((DEBUG_VERBOSE, "%x", Ip->Addr[Index]));
  183. if (Index < 15) {
  184. DEBUG ((DEBUG_VERBOSE, ":"));
  185. }
  186. }
  187. DEBUG ((DEBUG_VERBOSE, "\n"));
  188. }
  189. /**
  190. Dump data
  191. @param[in] Data Pointer to data.
  192. @param[in] Size size of data to dump.
  193. **/
  194. VOID
  195. InternalDumpData (
  196. IN UINT8 *Data,
  197. IN UINTN Size
  198. )
  199. {
  200. UINTN Index;
  201. for (Index = 0; Index < Size; Index++) {
  202. DEBUG ((DEBUG_VERBOSE, "%02x ", (UINTN)Data[Index]));
  203. }
  204. }
  205. /**
  206. Dump hex data
  207. @param[in] Data Pointer to hex data.
  208. @param[in] Size size of hex data to dump.
  209. **/
  210. VOID
  211. InternalDumpHex (
  212. IN UINT8 *Data,
  213. IN UINTN Size
  214. )
  215. {
  216. UINTN Index;
  217. UINTN Count;
  218. UINTN Left;
  219. Count = Size / VERBOSE_COLUME_SIZE;
  220. Left = Size % VERBOSE_COLUME_SIZE;
  221. for (Index = 0; Index < Count; Index++) {
  222. InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, VERBOSE_COLUME_SIZE);
  223. DEBUG ((DEBUG_VERBOSE, "\n"));
  224. }
  225. if (Left != 0) {
  226. InternalDumpData (Data + Index * VERBOSE_COLUME_SIZE, Left);
  227. DEBUG ((DEBUG_VERBOSE, "\n"));
  228. }
  229. DEBUG ((DEBUG_VERBOSE, "\n"));
  230. }
  231. /**
  232. Dump Redfish over IP protocol data
  233. @param[in] RedfishProtocolData Pointer to REDFISH_OVER_IP_PROTOCOL_DATA
  234. @param[in] RedfishProtocolDataSize size of data to dump.
  235. **/
  236. VOID
  237. DumpRedfishIpProtocolData (
  238. IN REDFISH_OVER_IP_PROTOCOL_DATA *RedfishProtocolData,
  239. IN UINT8 RedfishProtocolDataSize
  240. )
  241. {
  242. CHAR16 Hostname[16];
  243. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData: \n"));
  244. InternalDumpHex ((UINT8 *)RedfishProtocolData, RedfishProtocolDataSize);
  245. DEBUG ((DEBUG_VERBOSE, "Parsing as below: \n"));
  246. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->ServiceUuid - %g\n", &(RedfishProtocolData->ServiceUuid)));
  247. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAssignmentType - %d\n", RedfishProtocolData->HostIpAssignmentType));
  248. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddressFormat - %d\n", RedfishProtocolData->HostIpAddressFormat));
  249. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpAddress: \n"));
  250. if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
  251. InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpAddress));
  252. } else {
  253. InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpAddress));
  254. }
  255. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->HostIpMask: \n"));
  256. if (RedfishProtocolData->HostIpAddressFormat == 0x01) {
  257. InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->HostIpMask));
  258. } else {
  259. InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->HostIpMask));
  260. }
  261. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpDiscoveryType - %d\n", RedfishProtocolData->RedfishServiceIpDiscoveryType));
  262. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddressFormat - %d\n", RedfishProtocolData->RedfishServiceIpAddressFormat));
  263. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpAddress: \n"));
  264. if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
  265. InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
  266. } else {
  267. InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpAddress));
  268. }
  269. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpMask: \n"));
  270. if (RedfishProtocolData->RedfishServiceIpAddressFormat == 0x01) {
  271. InternalDumpIp4Addr ((EFI_IPv4_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
  272. } else {
  273. InternalDumpIp6Addr ((EFI_IPv6_ADDRESS *)(RedfishProtocolData->RedfishServiceIpMask));
  274. }
  275. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceIpPort - %d\n", RedfishProtocolData->RedfishServiceIpPort));
  276. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceVlanId - %d\n", RedfishProtocolData->RedfishServiceVlanId));
  277. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostnameLength - %d\n", RedfishProtocolData->RedfishServiceHostnameLength));
  278. AsciiStrToUnicodeStrS ((CHAR8 *)RedfishProtocolData->RedfishServiceHostname, Hostname, sizeof (Hostname) / sizeof (Hostname[0]));
  279. DEBUG ((DEBUG_VERBOSE, "RedfishProtocolData->RedfishServiceHostname - %s\n", Hostname));
  280. }
  281. /**
  282. Get Redfish host interface protocol data from variale.
  283. @param[out] RedfishProtocolData Pointer to retrieve REDFISH_OVER_IP_PROTOCOL_DATA.
  284. @param[out] RedfishProtocolDataSize Size of REDFISH_OVER_IP_PROTOCOL_DATA.
  285. @retval EFI_SUCESS REDFISH_OVER_IP_PROTOCOL_DATA is returned successfully.
  286. **/
  287. EFI_STATUS
  288. GetRedfishRecordFromVariable (
  289. OUT REDFISH_OVER_IP_PROTOCOL_DATA **RedfishProtocolData,
  290. OUT UINT8 *RedfishProtocolDataSize
  291. )
  292. {
  293. EFI_STATUS Status;
  294. UINT8 HostIpAssignmentType;
  295. UINTN HostIpAssignmentTypeSize;
  296. EFI_IPv4_ADDRESS HostIpAddress;
  297. UINTN IPv4DataSize;
  298. EFI_IPv4_ADDRESS HostIpMask;
  299. EFI_IPv4_ADDRESS RedfishServiceIpAddress;
  300. EFI_IPv4_ADDRESS RedfishServiceIpMask;
  301. UINT16 RedfishServiceIpPort;
  302. UINTN IpPortDataSize;
  303. UINT8 HostNameSize;
  304. CHAR8 RedfishHostName[20];
  305. if ((RedfishProtocolData == NULL) || (RedfishProtocolDataSize == NULL)) {
  306. return EFI_INVALID_PARAMETER;
  307. }
  308. //
  309. // 1. Retrieve Address Information from variable.
  310. //
  311. Status = gRT->GetVariable (
  312. L"HostIpAssignmentType",
  313. &gEmuRedfishServiceGuid,
  314. NULL,
  315. &HostIpAssignmentTypeSize,
  316. &HostIpAssignmentType
  317. );
  318. if (EFI_ERROR (Status)) {
  319. DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAssignmentType - %r\n", Status));
  320. return Status;
  321. }
  322. IPv4DataSize = sizeof (EFI_IPv4_ADDRESS);
  323. if (HostIpAssignmentType == 1 ) {
  324. Status = gRT->GetVariable (
  325. L"HostIpAddress",
  326. &gEmuRedfishServiceGuid,
  327. NULL,
  328. &IPv4DataSize,
  329. &HostIpAddress
  330. );
  331. if (EFI_ERROR (Status)) {
  332. DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpAddress - %r\n", Status));
  333. return Status;
  334. }
  335. Status = gRT->GetVariable (
  336. L"HostIpMask",
  337. &gEmuRedfishServiceGuid,
  338. NULL,
  339. &IPv4DataSize,
  340. &HostIpMask
  341. );
  342. if (EFI_ERROR (Status)) {
  343. DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable HostIpMask - %r\n", Status));
  344. return Status;
  345. }
  346. }
  347. Status = gRT->GetVariable (
  348. L"RedfishServiceIpAddress",
  349. &gEmuRedfishServiceGuid,
  350. NULL,
  351. &IPv4DataSize,
  352. &RedfishServiceIpAddress
  353. );
  354. if (EFI_ERROR (Status)) {
  355. DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpAddress - %r\n", Status));
  356. return Status;
  357. }
  358. Status = gRT->GetVariable (
  359. L"RedfishServiceIpMask",
  360. &gEmuRedfishServiceGuid,
  361. NULL,
  362. &IPv4DataSize,
  363. &RedfishServiceIpMask
  364. );
  365. if (EFI_ERROR (Status)) {
  366. DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpMask - %r\n", Status));
  367. return Status;
  368. }
  369. Status = gRT->GetVariable (
  370. L"RedfishServiceIpPort",
  371. &gEmuRedfishServiceGuid,
  372. NULL,
  373. &IpPortDataSize,
  374. &RedfishServiceIpPort
  375. );
  376. if (EFI_ERROR (Status)) {
  377. DEBUG ((DEBUG_ERROR, "RedfishPlatformDxe: GetVariable RedfishServiceIpPort - %r\n", Status));
  378. return Status;
  379. }
  380. AsciiSPrint (
  381. RedfishHostName,
  382. sizeof (RedfishHostName),
  383. "%d.%d.%d.%d",
  384. RedfishServiceIpAddress.Addr[0],
  385. RedfishServiceIpAddress.Addr[1],
  386. RedfishServiceIpAddress.Addr[2],
  387. RedfishServiceIpAddress.Addr[3]
  388. );
  389. HostNameSize = (UINT8)AsciiStrLen (RedfishHostName) + 1;
  390. //
  391. // 2. Protocol Data Size.
  392. //
  393. *RedfishProtocolDataSize = sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1 + HostNameSize;
  394. //
  395. // 3. Protocol Data.
  396. //
  397. *RedfishProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)AllocateZeroPool (*RedfishProtocolDataSize);
  398. if (*RedfishProtocolData == NULL) {
  399. return EFI_OUT_OF_RESOURCES;
  400. }
  401. CopyGuid (&(*RedfishProtocolData)->ServiceUuid, &gEmuRedfishServiceGuid);
  402. (*RedfishProtocolData)->HostIpAssignmentType = HostIpAssignmentType;
  403. (*RedfishProtocolData)->HostIpAddressFormat = 1; // Only support IPv4
  404. if (HostIpAssignmentType == 1 ) {
  405. (*RedfishProtocolData)->HostIpAddress[0] = HostIpAddress.Addr[0];
  406. (*RedfishProtocolData)->HostIpAddress[1] = HostIpAddress.Addr[1];
  407. (*RedfishProtocolData)->HostIpAddress[2] = HostIpAddress.Addr[2];
  408. (*RedfishProtocolData)->HostIpAddress[3] = HostIpAddress.Addr[3];
  409. (*RedfishProtocolData)->HostIpMask[0] = HostIpMask.Addr[0];
  410. (*RedfishProtocolData)->HostIpMask[1] = HostIpMask.Addr[1];
  411. (*RedfishProtocolData)->HostIpMask[2] = HostIpMask.Addr[2];
  412. (*RedfishProtocolData)->HostIpMask[3] = HostIpMask.Addr[3];
  413. }
  414. (*RedfishProtocolData)->RedfishServiceIpDiscoveryType = 1; // Use static IP address
  415. (*RedfishProtocolData)->RedfishServiceIpAddressFormat = 1; // Only support IPv4
  416. (*RedfishProtocolData)->RedfishServiceIpAddress[0] = RedfishServiceIpAddress.Addr[0];
  417. (*RedfishProtocolData)->RedfishServiceIpAddress[1] = RedfishServiceIpAddress.Addr[1];
  418. (*RedfishProtocolData)->RedfishServiceIpAddress[2] = RedfishServiceIpAddress.Addr[2];
  419. (*RedfishProtocolData)->RedfishServiceIpAddress[3] = RedfishServiceIpAddress.Addr[3];
  420. (*RedfishProtocolData)->RedfishServiceIpMask[0] = RedfishServiceIpMask.Addr[0];
  421. (*RedfishProtocolData)->RedfishServiceIpMask[1] = RedfishServiceIpMask.Addr[1];
  422. (*RedfishProtocolData)->RedfishServiceIpMask[2] = RedfishServiceIpMask.Addr[2];
  423. (*RedfishProtocolData)->RedfishServiceIpMask[3] = RedfishServiceIpMask.Addr[3];
  424. (*RedfishProtocolData)->RedfishServiceIpPort = RedfishServiceIpPort;
  425. (*RedfishProtocolData)->RedfishServiceVlanId = 0xffffffff;
  426. (*RedfishProtocolData)->RedfishServiceHostnameLength = HostNameSize;
  427. AsciiStrCpyS ((CHAR8 *)((*RedfishProtocolData)->RedfishServiceHostname), HostNameSize, RedfishHostName);
  428. return Status;
  429. }
  430. /**
  431. Construct Redfish host interface protocol data.
  432. @param ImageHandle The image handle.
  433. @param SystemTable The system table.
  434. @retval EFI_SUCEESS Install Boot manager menu success.
  435. @retval Other Return error status.
  436. **/
  437. EFI_STATUS
  438. EFIAPI
  439. RedfishPlatformHostInterfaceConstructor (
  440. IN EFI_HANDLE ImageHandle,
  441. IN EFI_SYSTEM_TABLE *SystemTable
  442. )
  443. {
  444. EFI_STATUS Status;
  445. Status = GetRedfishRecordFromVariable (&mRedfishOverIpProtocolData, &mRedfishProtocolDataSize);
  446. DEBUG ((DEBUG_INFO, "%a: GetRedfishRecordFromVariable() - %r\n", __FUNCTION__, Status));
  447. if (!EFI_ERROR (Status)) {
  448. DumpRedfishIpProtocolData (mRedfishOverIpProtocolData, mRedfishProtocolDataSize);
  449. }
  450. return EFI_SUCCESS;
  451. }
  452. /**
  453. Get the EFI protocol GUID installed by platform library which
  454. indicates the necessary information is ready for building
  455. SMBIOS 42h record.
  456. @param[out] InformationReadinessGuid Pointer to retrive the protocol
  457. GUID.
  458. @retval EFI_SUCCESS Notification is required for building up
  459. SMBIOS type 42h record.
  460. @retval EFI_UNSUPPORTED Notification is not required for building up
  461. SMBIOS type 42h record.
  462. @retval EFI_ALREADY_STARTED Platform host information is already ready.
  463. @retval Others Other errors.
  464. **/
  465. EFI_STATUS
  466. RedfishPlatformHostInterfaceNotification (
  467. OUT EFI_GUID **InformationReadinessGuid
  468. )
  469. {
  470. return EFI_UNSUPPORTED;
  471. }