diff options
author | Brijesh Singh <brijesh.singh@amd.com> | 2017-09-14 16:22:45 -0500 |
---|---|---|
committer | Laszlo Ersek <lersek@redhat.com> | 2017-09-14 23:54:15 +0200 |
commit | bd114d9f776bfd26a1cf4c731429112821c9e944 (patch) | |
tree | a4775431a938806d8999fe2cffe3d2fac7caace3 /OvmfPkg/VirtioNetDxe/VirtioNet.h | |
parent | 76ad23ca82292a8fa3e9f3f8d5637f7aecbb9d69 (diff) | |
download | edk2-bd114d9f776bfd26a1cf4c731429112821c9e944.tar.gz edk2-bd114d9f776bfd26a1cf4c731429112821c9e944.tar.bz2 edk2-bd114d9f776bfd26a1cf4c731429112821c9e944.zip |
OvmfPkg/VirtioNetDxe: add Tx packet map/unmap helper functions
When device is behind IOMMU, driver is require to pass the device address
of TxBuf in the Tx VRING. The patch adds helper functions and data
structure to map and unmap the TxBuf system physical address to a device
address.
Since the TxBuf is returned back to caller from VirtioNetGetStatus() hence
we use OrderedCollection interface to save the TxBuf system physical to
device address mapping. After the TxBuf is succesfully transmitted
VirtioNetUnmapTxBuf() does the reverse lookup in OrderedCollection data
structure to get the system physical address of TxBuf for a given device
address.
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'OvmfPkg/VirtioNetDxe/VirtioNet.h')
-rw-r--r-- | OvmfPkg/VirtioNetDxe/VirtioNet.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/OvmfPkg/VirtioNetDxe/VirtioNet.h b/OvmfPkg/VirtioNetDxe/VirtioNet.h index 027f75993e..3fc88cfb79 100644 --- a/OvmfPkg/VirtioNetDxe/VirtioNet.h +++ b/OvmfPkg/VirtioNetDxe/VirtioNet.h @@ -26,6 +26,7 @@ #include <Protocol/DevicePath.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/SimpleNetwork.h>
+#include <Library/OrderedCollectionLib.h>
#define VNET_SIG SIGNATURE_32 ('V', 'N', 'E', 'T')
@@ -100,6 +101,7 @@ typedef struct { VIRTIO_1_0_NET_REQ *TxSharedReq; // VirtioNetInitTx
VOID *TxSharedReqMap; // VirtioNetInitTx
UINT16 TxLastUsed; // VirtioNetInitTx
+ ORDERED_COLLECTION *TxBufCollection; // VirtioNetInitTx
} VNET_DEV;
@@ -281,6 +283,42 @@ VirtioNetUninitRing ( );
//
+// utility functions to map caller-supplied Tx buffer system physical address
+// to a device address and vice versa
+//
+EFI_STATUS
+EFIAPI
+VirtioNetMapTxBuf (
+ IN VNET_DEV *Dev,
+ IN VOID *Buffer,
+ IN UINTN NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress
+ );
+
+EFI_STATUS
+EFIAPI
+VirtioNetUnmapTxBuf (
+ IN VNET_DEV *Dev,
+ OUT VOID **Buffer,
+ IN EFI_PHYSICAL_ADDRESS DeviceAddress
+ );
+
+INTN
+EFIAPI
+VirtioNetTxBufMapInfoCompare (
+ IN CONST VOID *UserStruct1,
+ IN CONST VOID *UserStruct2
+ );
+
+INTN
+EFIAPI
+VirtioNetTxBufDeviceAddressCompare (
+ IN CONST VOID *StandaloneKey,
+ IN CONST VOID *UserStruct
+ );
+
+
+//
// event callbacks
//
VOID
|