]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/VirtioNetDxe/SnpGetStatus.c
OvmfPkg/EnrollDefaultKeys: enroll PK/KEK1 from the Type 11 SMBIOS table
[mirror_edk2.git] / OvmfPkg / VirtioNetDxe / SnpGetStatus.c
index 4393d243a279bcdfb4fb4484ee25759cd6a94e69..333a522d503a2ff41edbe78482b10d788244f674 100644 (file)
@@ -4,15 +4,9 @@
   any.\r
 \r
   Copyright (C) 2013, Red Hat, Inc.\r
-  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2014, Intel Corporation. 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
@@ -61,11 +55,12 @@ VirtioNetGetStatus (
   OUT VOID                       **TxBuf OPTIONAL\r
   )\r
 {\r
-  VNET_DEV   *Dev;\r
-  EFI_TPL    OldTpl;\r
-  EFI_STATUS Status;\r
-  UINT16     RxCurUsed;\r
-  UINT16     TxCurUsed;\r
+  VNET_DEV             *Dev;\r
+  EFI_TPL              OldTpl;\r
+  EFI_STATUS           Status;\r
+  UINT16               RxCurUsed;\r
+  UINT16               TxCurUsed;\r
+  EFI_PHYSICAL_ADDRESS DeviceAddress;\r
 \r
   if (This == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -94,7 +89,8 @@ VirtioNetGetStatus (
     if (EFI_ERROR (Status)) {\r
       goto Exit;\r
     }\r
-    Dev->Snm.MediaPresent = !!(LinkStatus & VIRTIO_NET_S_LINK_UP);\r
+    Dev->Snm.MediaPresent =\r
+      (BOOLEAN) ((LinkStatus & VIRTIO_NET_S_LINK_UP) != 0);\r
   }\r
 \r
   //\r
@@ -140,14 +136,34 @@ VirtioNetGetStatus (
       ASSERT (DescIdx < (UINT32) (2 * Dev->TxMaxPending - 1));\r
 \r
       //\r
-      // report buffer address to caller that has been enqueued by caller\r
+      // get the device address that has been enqueued for the caller's\r
+      // transmit buffer\r
       //\r
-      *TxBuf = (VOID *)(UINTN) Dev->TxRing.Desc[DescIdx + 1].Addr;\r
+      DeviceAddress = Dev->TxRing.Desc[DescIdx + 1].Addr;\r
 \r
       //\r
       // now this descriptor can be used again to enqueue a transmit buffer\r
       //\r
       Dev->TxFreeStack[--Dev->TxCurPending] = (UINT16) DescIdx;\r
+\r
+      //\r
+      // Unmap the device address and perform the reverse mapping to find the\r
+      // caller buffer address.\r
+      //\r
+      Status = VirtioNetUnmapTxBuf (\r
+                 Dev,\r
+                 TxBuf,\r
+                 DeviceAddress\r
+                 );\r
+      if (EFI_ERROR (Status)) {\r
+        //\r
+        // VirtioNetUnmapTxBuf should never fail, if we have reached here\r
+        // that means our internal state has been corrupted\r
+        //\r
+        ASSERT (FALSE);\r
+        Status = EFI_DEVICE_ERROR;\r
+        goto Exit;\r
+      }\r
     }\r
   }\r
 \r