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>
This commit is contained in:
committed by
Laszlo Ersek
parent
76ad23ca82
commit
bd114d9f77
@@ -147,7 +147,8 @@ ReleaseQueue:
|
||||
EfiSimpleNetworkInitialized state.
|
||||
|
||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate the stack to track the heads
|
||||
of free descriptor chains.
|
||||
of free descriptor chains or failed to init
|
||||
TxBufCollection.
|
||||
@return Status codes from VIRTIO_DEVICE_PROTOCOL.
|
||||
AllocateSharedPages() or
|
||||
VirtioMapAllBytesInSharedBuffer()
|
||||
@@ -176,6 +177,15 @@ VirtioNetInitTx (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Dev->TxBufCollection = OrderedCollectionInit (
|
||||
VirtioNetTxBufMapInfoCompare,
|
||||
VirtioNetTxBufDeviceAddressCompare
|
||||
);
|
||||
if (Dev->TxBufCollection == NULL) {
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto FreeTxFreeStack;
|
||||
}
|
||||
|
||||
//
|
||||
// Allocate TxSharedReq header and map with BusMasterCommonBuffer so that it
|
||||
// can be accessed equally by both processor and device.
|
||||
@@ -186,7 +196,7 @@ VirtioNetInitTx (
|
||||
&TxSharedReqBuffer
|
||||
);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto FreeTxFreeStack;
|
||||
goto UninitTxBufCollection;
|
||||
}
|
||||
|
||||
ZeroMem (TxSharedReqBuffer, sizeof *Dev->TxSharedReq);
|
||||
@@ -267,6 +277,10 @@ FreeTxSharedReqBuffer:
|
||||
EFI_SIZE_TO_PAGES (sizeof *(Dev->TxSharedReq)),
|
||||
TxSharedReqBuffer
|
||||
);
|
||||
|
||||
UninitTxBufCollection:
|
||||
OrderedCollectionUninit (Dev->TxBufCollection);
|
||||
|
||||
FreeTxFreeStack:
|
||||
FreePool (Dev->TxFreeStack);
|
||||
|
||||
|
Reference in New Issue
Block a user