diff options
author | Brijesh Singh <brijesh.singh@amd.com> | 2017-09-14 16:22:43 -0500 |
---|---|---|
committer | Laszlo Ersek <lersek@redhat.com> | 2017-09-14 23:54:10 +0200 |
commit | 891f016c1b99f2f4c982f0d027c7ff0c001bd270 (patch) | |
tree | 3d384964e781f57a9235ab2efa9ac6c5d21687d8 /OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | |
parent | 46b11f00ac704ed4a1e3c8c1c3439f914e2dfadc (diff) | |
download | edk2-891f016c1b99f2f4c982f0d027c7ff0c001bd270.tar.gz edk2-891f016c1b99f2f4c982f0d027c7ff0c001bd270.tar.bz2 edk2-891f016c1b99f2f4c982f0d027c7ff0c001bd270.zip |
OvmfPkg/VirtioNetDxe: dynamically alloc transmit header
Each network packet is submitted for transmission by pushing the head
descriptor of a two-part descriptor chain to the Available Ring of the
TX queue. VirtioNetInitTx() sets up the the descriptor chains for all
queueable packets in advance, and points all the head descriptors to the
same shared, never modified, VIRTIO_1_0_NET_REQ header object (or its
initial VIRTIO_NET_REQ sub-object, dependent on virtio version).
VirtioNetInitTx() currently uses the header object's system physical
address for populating the head descriptors.
When device is behind the IOMMU, VirtioNet driver is required to provide
the device address of VIRTIO_1_0_NET_REQ header. In this patch we
dynamically allocate the header using AllocateSharedPages() and map with
BusMasterCommonBuffer so that header can be accessed by both processor
and the device.
We map the header object for CommonBuffer operation because, in order to
stick with the current code order, we populate the head descriptors with
the header's device address first, and fill in the header itself second.
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/SnpSharedHelpers.c')
-rw-r--r-- | OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c index ee4f9ed36e..2fce8142d5 100644 --- a/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c +++ b/OvmfPkg/VirtioNetDxe/SnpSharedHelpers.c @@ -54,6 +54,13 @@ VirtioNetShutdownTx ( IN OUT VNET_DEV *Dev
)
{
+ Dev->VirtIo->UnmapSharedBuffer (Dev->VirtIo, Dev->TxSharedReqMap);
+ Dev->VirtIo->FreeSharedPages (
+ Dev->VirtIo,
+ EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)),
+ Dev->TxSharedReq
+ );
+
FreePool (Dev->TxFreeStack);
}
|