Example #1
0
def cleanup_devices(pci_id, device_type):
    """
    Recover devices to original driver.
    """
    if device_type == "Ethernet":
        driver_type = "igb"
    elif device_type == "Fibre":
        driver_type = "lpfc"
    devices = utils_misc.get_pci_group_by_id(pci_id, device_type)
    remove_devices_driver(devices)
    for device in devices:
        utils_misc.bind_device_driver(device, driver_type)
Example #2
0
def cleanup_devices(pci_id, device_type):
    """
    Recover devices to original driver.
    """
    if device_type == "Ethernet":
        driver_type = "igb"
    elif device_type == "Fibre":
        driver_type = "lpfc"
    devices = utils_misc.get_pci_group_by_id(pci_id, device_type)
    remove_devices_driver(devices)
    for device in devices:
        utils_misc.bind_device_driver(device, driver_type)
Example #3
0
def prepare_devices(test, pci_id, device_type, only=False):
    """
    Check whether provided pci_id is available.
    According this pci_id, get a list of devices in same iommu group.

    :param pci_id: pci device's id
    :param device_type: Ethernet or Fibre
    :param only: only the device provided will be binded.
    """
    available_type = ["Ethernet", "Fibre"]
    if device_type not in available_type:
        test.cancel("Tested device type is not supported."
                    "Available: %s" % available_type)

    # Init VFIO Controller and check whether vfio is supported.
    vfio_ctl = utils_misc.VFIOController()
    # This is devices group we classify
    devices = utils_misc.get_pci_group_by_id(pci_id, device_type)
    if len(devices) == 0:
        test.cancel("No pci device to be found.")

    # The IOMMU Group id of device we provide
    group_id = vfio_ctl.get_pci_iommu_group_id(pci_id, device_type)
    # According group id, get a group of devices system classified
    group_devices = vfio_ctl.get_iommu_group_devices(group_id)
    if only:
        # Make sure other devices is not vfio-pci driver
        cleanup_devices(pci_id, device_type)
        for device in group_devices:
            if device.count(pci_id):
                pci_id = device
                break
        group_devices = [pci_id]

    # Compare devices to decide whether going on
    if devices.sort() != group_devices.sort():
        test.cancel("Unknown pci device(%s) in %s groups: %s"
                    % (devices, device_type, group_devices))

    # Start to bind device driver to vfio-pci
    # Unbind from igb/lpfc
    if not add_devices_to_iommu_group(vfio_ctl, group_devices):
        test.error("Cannot add provided device to iommu group.")

    if not vfio_ctl.check_vfio_id(group_id):
        test.error("Cannot find create group id: %s" % group_id)
Example #4
0
def prepare_devices(pci_id, device_type, only=False):
    """
    Check whether provided pci_id is available.
    According this pci_id, get a list of devices in same iommu group.

    :param pci_id: pci device's id
    :param device_type: Ethernet or Fibre
    :param only: only the device provided will be binded.
    """
    available_type = ["Ethernet", "Fibre"]
    if device_type not in available_type:
        raise error.TestNAError("Tested device type is not supported."
                                "Available: %s" % available_type)

    # Init VFIO Controller and check whether vfio is supported.
    vfio_ctl = utils_misc.VFIOController()
    # This is devices group we classify
    devices = utils_misc.get_pci_group_by_id(pci_id, device_type)
    if len(devices) == 0:
        raise error.TestNAError("No pci device to be found.")

    # The IOMMU Group id of device we provide
    group_id = vfio_ctl.get_pci_iommu_group_id(pci_id, device_type)
    # According group id, get a group of devices system classified
    group_devices = vfio_ctl.get_iommu_group_devices(group_id)
    if only:
        # Make sure other devices is not vfio-pci driver
        cleanup_devices(pci_id, device_type)
        for device in group_devices:
            if device.count(pci_id):
                pci_id = device
                break
        group_devices = [pci_id]

    # Compare devices to decide whether going on
    if devices.sort() != group_devices.sort():
        raise error.TestNAError("Unknown pci device(%s) in %s groups: %s"
                                % (devices, device_type, group_devices))

    # Start to bind device driver to vfio-pci
    # Unbind from igb/lpfc
    if not add_devices_to_iommu_group(vfio_ctl, group_devices):
        raise error.TestError("Cannot add provided device to iommu group.")

    if not vfio_ctl.check_vfio_id(group_id):
        raise error.TestError("Cannot find create group id: %s" % group_id)