Upstream how to use SF kernel vdpa device
This section describes how to use VDPA device of SF auxiliary device which were configured in step by step guide.
VDPA devices are managed by vdpa management tool from the iproute2 package. Its man page provides more detailed command options.
There can be hundreds of auxiliary SF devices on the auxiliary bus. Each SF's auxiliary device contains a unique sfnum and PCI information.
Parent PCI BDF (Bus, Device, Function) and the SF number establishes a unique SF device.
Each SF's sfnum can be read using: :
$ cat /sys/bus/auxiliary/devices/mlx5_core.sf.4/sfnum
88
Load vdpa stack drivers if they are not loaded to map a VDPA device to a VM. :
$ modprobe vdpa
$ modprobe vhost_vdpa
Verify that vhost_vdpa driver is loaded. :
$ ls -l /sys/bus/vdpa/drivers
drwxr-xr-x 2 root root 0 May 19 16:54 vhost_vdpa
VDPA devices are managed by its parent management device. Each SF is management device. SF management device enables user to create corresponding vdpa device. A VDPA management device allows creating one or more types of VDPA devices such as net, block.
View the management device of the SF device: :
$ vdpa mgmtdev show
auxiliary/mlx5_core.sf.4
supported_classes net
VDPA device must be explicitly created by the user to use it. :
$ vdpa dev add name vdpa0 mgmtdev auxiliary/mlx5_core.sf.4
$ vdpa dev show
At this point VDPA device is created and located on vdpa bus. :
$ ls /sys/bus/vdpa/devices/vdpa0
A VDPA device must be bound to vhost driver to assign a VDPA device to a VM. :
$ readlink /sys/bus/vdpa/devices/vdpa0/driver
../../bus/vdpa/drivers/vhost_vdpa
When a VDPA device is attached to the vhost-vdpa driver, a vhost-vdpa character device is created. This can be found at: :: $ ls /sys/bus/vdpa/devices/vdpa0/vhost-* vhost-vdpa-0
This vhost-vdpa-0 device is located at /dev/vhost-vdpa-0. When starting a VM, /dev/vhost-vdpa-0 device should be assigned to the the VM as described below.
$ sudo x86_64-softmmu/qemu-system-x86_64 \
-hda Fedora-Cloud-Base-32-1.6.x86_64.qcow2 \
-netdev type=vhost-vdpa,vhostdev=/dev/vhost-vdpa-0,id=vhost-vdpa1 \
-device virtio-net-pci,netdev=vhost-vdpa1,mac=00:e8:ca:33:ba:05,\
disable-modern=off,page-per-vq=on \
-enable-kvm \
-nographic \
-m 4G \
-cpu host \
2>&1 | tee vm.log
If using XML file for VM configuration, user can add below entry for adding vdpa's vhost device to the VM. :
<devices>
<interface type='vdpa'>
<source dev='/dev/vhost-vdpa-0'/>
</interface>
</devices>
Once user completed the use of VDPA device, it should be deleted by specifying the vdpa device name. :
$ vdpa dev del name vdpa0