OvmfPkg/VirtioFsDxe: add a scatter-gather list data type
In preparation for the variously structured FUSE request/response exchanges that virtio-fs uses, introduce a scatter-gather list data type. This will let us express FUSE request-response pairs flexibly. Add a function for validating whether a (request buffer list, response buffer list) pair is well-formed, and supported by the Virtio Filesystem device's queue depth. Add another function for mapping and submitting a validated pair of scatter-gather lists to the Virtio Filesystem device. Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Philippe Mathieu-Daudé <philmd@redhat.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3097 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20201216211125.19496-6-lersek@redhat.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com> [lersek@redhat.com: suppress useless VS2019 warning about signed/unsigned comparison in VirtioFsSgListsValidate()]
This commit is contained in:
committed by
mergify[bot]
parent
eaa7115d60
commit
6578cacb46
@@ -51,6 +51,52 @@ typedef struct {
|
||||
#define VIRTIO_FS_FROM_SIMPLE_FS(SimpleFsReference) \
|
||||
CR (SimpleFsReference, VIRTIO_FS, SimpleFs, VIRTIO_FS_SIG);
|
||||
|
||||
//
|
||||
// Structure for describing a contiguous buffer, potentially mapped for Virtio
|
||||
// transfer.
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// The following fields originate from the owner of the buffer.
|
||||
//
|
||||
VOID *Buffer;
|
||||
UINTN Size;
|
||||
//
|
||||
// All of the fields below, until the end of the structure, are
|
||||
// zero-initialized when the structure is initially validated.
|
||||
//
|
||||
// Mapped, MappedAddress and Mapping are updated when the buffer is mapped
|
||||
// for VirtioOperationBusMasterRead or VirtioOperationBusMasterWrite. They
|
||||
// are again updated when the buffer is unmapped.
|
||||
//
|
||||
BOOLEAN Mapped;
|
||||
EFI_PHYSICAL_ADDRESS MappedAddress;
|
||||
VOID *Mapping;
|
||||
//
|
||||
// Transferred is updated after VirtioFlush() returns successfully:
|
||||
// - for VirtioOperationBusMasterRead, Transferred is set to Size;
|
||||
// - for VirtioOperationBusMasterWrite, Transferred is calculated from the
|
||||
// UsedLen output parameter of VirtioFlush().
|
||||
//
|
||||
UINTN Transferred;
|
||||
} VIRTIO_FS_IO_VECTOR;
|
||||
|
||||
//
|
||||
// Structure for describing a list of IO Vectors.
|
||||
//
|
||||
typedef struct {
|
||||
//
|
||||
// The following fields originate from the owner of the buffers.
|
||||
//
|
||||
VIRTIO_FS_IO_VECTOR *IoVec;
|
||||
UINTN NumVec;
|
||||
//
|
||||
// TotalSize is calculated when the scatter-gather list is initially
|
||||
// validated.
|
||||
//
|
||||
UINT32 TotalSize;
|
||||
} VIRTIO_FS_SCATTER_GATHER_LIST;
|
||||
|
||||
//
|
||||
// Initialization and helper routines for the Virtio Filesystem device.
|
||||
//
|
||||
@@ -72,6 +118,20 @@ VirtioFsExitBoot (
|
||||
IN VOID *VirtioFsAsVoid
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
VirtioFsSgListsValidate (
|
||||
IN VIRTIO_FS *VirtioFs,
|
||||
IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
|
||||
IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
VirtioFsSgListsSubmit (
|
||||
IN OUT VIRTIO_FS *VirtioFs,
|
||||
IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList,
|
||||
IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL
|
||||
);
|
||||
|
||||
//
|
||||
// EFI_SIMPLE_FILE_SYSTEM_PROTOCOL member functions for the Virtio Filesystem
|
||||
// driver.
|
||||
|
Reference in New Issue
Block a user