# PCI subsystem

## API Reference

struct PCIIOMMUOps

  callbacks structure for specific IOMMU handlers of a PCIBus

Definition

    struct PCIIOMMUOps {
      AddressSpace * (*get_address_space)(PCIBus *bus, void *opaque, int devfn);
      bool (*set_iommu_device)(PCIBus *bus, void *opaque, int devfn, HostIOMMUDevice *dev, Error **errp);
      void (*unset_iommu_device)(PCIBus *bus, void *opaque, int devfn);
    };

Members

`get_address_space`

  get the address space for a set of devices on a PCI bus.

  Mandatory callback which returns a pointer to an `AddressSpace`

  bus: the `PCIBus` being accessed.

  opaque: the data passed to pci_setup_iommu().

  devfn: device and function number

`set_iommu_device`

  attach a HostIOMMUDevice to a vIOMMU

  Optional callback, if not implemented in vIOMMU, then vIOMMU can’t retrieve host information from the associated HostIOMMUDevice.

  bus: the `PCIBus` of the PCI device.

  opaque: the data passed to pci_setup_iommu().

  devfn: device and function number of the PCI device.

  dev: the `HostIOMMUDevice` to attach.

  errp: pass an Error out only when return false

  Returns: true if HostIOMMUDevice is attached or else false with errp set.

`unset_iommu_device`

  detach a HostIOMMUDevice from a vIOMMU

  Optional callback.

  bus: the `PCIBus` of the PCI device.

  opaque: the data passed to pci_setup_iommu().

  devfn: device and function number of the PCI device.

Description

Allows to modify the behavior of some IOMMU operations of the PCI framework for a set of devices on a PCI bus.

void pci_setup_iommu(PCIBus *bus, const PCIIOMMUOps *ops, void *opaque)

  Initialize specific IOMMU handlers for a PCIBus

Parameters

`PCIBus *bus`

  the `PCIBus` being updated.

`const PCIIOMMUOps *ops`

  the `PCIIOMMUOps`

`void *opaque`

  passed to callbacks of the ops structure.

Description

Let PCI host bridges define specific operations.