vfio/fsl-mc: Add VFIO framework skeleton for fsl-mc devices
authorBharat Bhushan <Bharat.Bhushan@nxp.com>
Mon, 5 Oct 2020 17:36:45 +0000 (20:36 +0300)
committerAlex Williamson <alex.williamson@redhat.com>
Wed, 7 Oct 2020 20:17:33 +0000 (14:17 -0600)
commitfb1ff4c1941573aea59e4cb575dc5a723303cd70
treefaea93f24f9da6be1c32c42e7354df748645986f
parentba4f184e126b751d1bffad5897f263108befc780
vfio/fsl-mc: Add VFIO framework skeleton for fsl-mc devices

DPAA2 (Data Path Acceleration Architecture) consists in
mechanisms for processing Ethernet packets, queue management,
accelerators, etc.

The Management Complex (mc) is a hardware entity that manages the DPAA2
hardware resources. It provides an object-based abstraction for software
drivers to use the DPAA2 hardware. The MC mediates operations such as
create, discover, destroy of DPAA2 objects.
The MC provides memory-mapped I/O command interfaces (MC portals) which
DPAA2 software drivers use to operate on DPAA2 objects.

A DPRC is a container object that holds other types of DPAA2 objects.
Each object in the DPRC is a Linux device and bound to a driver.
The MC-bus driver is a platform driver (different from PCI or platform
bus). The DPRC driver does runtime management of a bus instance. It
performs the initial scan of the DPRC and handles changes in the DPRC
configuration (adding/removing objects).

All objects inside a container share the same hardware isolation
context, meaning that only an entire DPRC can be assigned to
a virtual machine.
When a container is assigned to a virtual machine, all the objects
within that container are assigned to that virtual machine.
The DPRC container assigned to the virtual machine is not allowed
to change contents (add/remove objects) by the guest. The restriction
is set by the host and enforced by the mc hardware.

The DPAA2 objects can be directly assigned to the guest. However
the MC portals (the memory mapped command interface to the MC) need
to be emulated because there are commands that configure the
interrupts and the isolation IDs which are virtual in the guest.

Example:
echo vfio-fsl-mc > /sys/bus/fsl-mc/devices/dprc.2/driver_override
echo dprc.2 > /sys/bus/fsl-mc/drivers/vfio-fsl-mc/bind

The dprc.2 is bound to the VFIO driver and all the objects within
dprc.2 are going to be bound to the VFIO driver.

This patch adds the infrastructure for VFIO support for fsl-mc
devices. Subsequent patches will add support for binding and secure
assigning these devices using VFIO.

More details about the DPAA2 objects can be found here:
Documentation/networking/device_drivers/freescale/dpaa2/overview.rst

Signed-off-by: Bharat Bhushan <Bharat.Bhushan@nxp.com>
Signed-off-by: Diana Craciun <diana.craciun@oss.nxp.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
MAINTAINERS
drivers/vfio/Kconfig
drivers/vfio/Makefile
drivers/vfio/fsl-mc/Kconfig [new file with mode: 0644]
drivers/vfio/fsl-mc/Makefile [new file with mode: 0644]
drivers/vfio/fsl-mc/vfio_fsl_mc.c [new file with mode: 0644]
drivers/vfio/fsl-mc/vfio_fsl_mc_private.h [new file with mode: 0644]
include/uapi/linux/vfio.h