Intel Acceleration Stack Quick Start Guide for Intel® Programmable Acceleration Card with Intel® Arria® 10 GX FPGA

ID 683633
Date 12/04/2020
Public
Document Table of Contents

8.2. Configuring the VF Port on the Host

By default, the PF controls the AFU port. The following procedure transfers AFU control to the VF. After the transfer to VF control, applications running on the VM can access the AFU.

In a multicard system, if you want to configure the VF on only a single PCIe device, run the below command to find a device mapping for the specific PCIe device:
ls -l /sys/class/fpga/intel-fpga-dev.*
Sample output:
/sys/class/fpga/intel-fpga-dev.0 -> ../../devices/pci0000:36/0000:36:00.0/0000:37:00.0/fpga/intel-fpga-dev.0

/sys/class/fpga/intel-fpga-dev.1 -> ../../devices/pci0000:ae/0000:ae:00.0/0000:af:00.0/fpga/intel-fpga-dev.1

To target PCIe B:D.F (AF:00.0) and B:D.F (37:00.0) in the following commands, use instance id 1 and 0 instead of * respectively.

  1. Run the following three commands, individually, to export the required paths:
    export port_path=$(find /sys/class/fpga/intel-fpga-dev.* \
    -maxdepth 1 -follow -iname intel-fpga-port.*)
    export link_path=$(readlink -m /$port_path/../)
    export pci_path=$link_path/../../
  2. Release the port controlled by the PF using the fpgaport tool:
    sudo fpgaport release /dev/intel-fpga-fme.* 0
  3. Enable SR-IOV and VFs. Each VF has 1 AFU Port:
    sudo sh -c "echo 1 > $pci_path/sriov_numvfs"
  4. Find the additional device number for the VF device:
    lspci -nn | grep :09c[45]
    Sample output:
    04:00.0 Processing accelerators [1200]: Intel Corporation Device [8086:09c4]
    04:00.1 Processing accelerators [1200]: Intel Corporation Device [8086:09c5]

    lspci shows an additional device number, 09c5. This is the VF device you assign to a VM. The original bus and device numbers for the PF remains 09c4.

    Note that the Domain:Bus:Device.Function (BDF) notation for the VF device in this example is: 000:04:00.1. Replace this BDF with the appropriate BDF for your system.

  5. Load the vfio-pci driver:
    sudo modprobe vfio-pci
  6. Unbind the VF device from its driver:
    sudo sh -c "echo 0000:04:00.1 > \
    /sys/bus/pci/devices/0000:04:00.1/driver/unbind"
  7. Find the vendor and device ID for the VF device:
    lspci -n -s 04:00.1

    Sample output:

    04:00.1 1200: 8086:09c5
  8. Bind the VF to the vfio-pci driver:
    sudo sh -c "echo 8086 09c5 > \
    /sys/bus/pci/drivers/vfio-pci/new_id"