any.\r
\r
Copyright (C) 2013, Red Hat, Inc.\r
- Copyright (c) 2006 - 2010, 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
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
if (Dev->Snm.MediaPresentSupported) {\r
UINT16 LinkStatus;\r
\r
- Status = VIRTIO_CFG_READ (Dev, VhdrLinkStatus, &LinkStatus);\r
+ Status = VIRTIO_CFG_READ (Dev, LinkStatus, &LinkStatus);\r
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
MemoryFence ();\r
RxCurUsed = *Dev->RxRing.Used.Idx;\r
TxCurUsed = *Dev->TxRing.Used.Idx;\r
+ MemoryFence ();\r
\r
if (InterruptStatus != NULL) {\r
//\r
\r
UsedElemIdx = Dev->TxLastUsed++ % Dev->TxRing.QueueSize;\r
DescIdx = Dev->TxRing.Used.UsedElem[UsedElemIdx].Id;\r
- ASSERT (DescIdx < 2 * Dev->TxMaxPending - 1);\r
+ 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 *) 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