]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/VirtioNetDxe/SnpInitialize.c
MdePkg/DxeServicesLib: remove bogus cast
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpInitialize.c
index 9621f936d2cba243a9e4aad8ad18299ba999d937..bb3b552d68d73e09fdbc5c06cc7c9a418254b0fe 100644 (file)
@@ -7,13 +7,7 @@
   Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
   Copyright (c) 2017, AMD Inc, All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials are licensed and made available\r
-  under the terms and conditions of the BSD License which accompanies this\r
-  distribution. The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
-  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -147,7 +141,8 @@ ReleaseQueue:
                            EfiSimpleNetworkInitialized state.\r
 \r
   @retval EFI_OUT_OF_RESOURCES  Failed to allocate the stack to track the heads\r
-                                of free descriptor chains.\r
+                                of free descriptor chains or failed to init\r
+                                TxBufCollection.\r
   @return                       Status codes from VIRTIO_DEVICE_PROTOCOL.\r
                                 AllocateSharedPages() or\r
                                 VirtioMapAllBytesInSharedBuffer()\r
@@ -176,6 +171,15 @@ VirtioNetInitTx (
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  Dev->TxBufCollection = OrderedCollectionInit (\r
+                           VirtioNetTxBufMapInfoCompare,\r
+                           VirtioNetTxBufDeviceAddressCompare\r
+                           );\r
+  if (Dev->TxBufCollection == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto FreeTxFreeStack;\r
+  }\r
+\r
   //\r
   // Allocate TxSharedReq header and map with BusMasterCommonBuffer so that it\r
   // can be accessed equally by both processor and device.\r
@@ -186,7 +190,7 @@ VirtioNetInitTx (
                           &TxSharedReqBuffer\r
                           );\r
   if (EFI_ERROR (Status)) {\r
-    goto FreeTxFreeStack;\r
+    goto UninitTxBufCollection;\r
   }\r
 \r
   ZeroMem (TxSharedReqBuffer, sizeof *Dev->TxSharedReq);\r
@@ -267,6 +271,10 @@ FreeTxSharedReqBuffer:
                  EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)),\r
                  TxSharedReqBuffer\r
                  );\r
+\r
+UninitTxBufCollection:\r
+  OrderedCollectionUninit (Dev->TxBufCollection);\r
+\r
 FreeTxFreeStack:\r
   FreePool (Dev->TxFreeStack);\r
 \r
@@ -548,7 +556,8 @@ VirtioNetInitialize (
   ASSERT (Dev->Snm.MediaPresentSupported ==\r
     !!(Features & VIRTIO_NET_F_STATUS));\r
 \r
-  Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_1;\r
+  Features &= VIRTIO_NET_F_MAC | VIRTIO_NET_F_STATUS | VIRTIO_F_VERSION_1 |\r
+              VIRTIO_F_IOMMU_PLATFORM;\r
 \r
   //\r
   // In virtio-1.0, feature negotiation is expected to complete before queue\r
@@ -588,7 +597,7 @@ VirtioNetInitialize (
   // step 5 -- keep only the features we want\r
   //\r
   if (Dev->VirtIo->Revision < VIRTIO_SPEC_REVISION (1, 0, 0)) {\r
-    Features &= ~(UINT64)VIRTIO_F_VERSION_1;\r
+    Features &= ~(UINT64)(VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM);\r
     Status = Dev->VirtIo->SetGuestFeatures (Dev->VirtIo, Features);\r
     if (EFI_ERROR (Status)) {\r
       goto ReleaseTxRing;\r