RedfishPlatformHostInterfaceLib.c 18 KB

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