The vhost vDPA bus driver connects the vDPA bus to the vhost subsystem and presents a vhost char gadget to userspace. The vhost-vdpa gadget could possibly be used as a community backend for VMs with the assistance of QEMU. For extra info see the next weblog.

We are going to use QEMU and a VM to arrange this setting.

what do you do when you ain’t got the hardware

Organising your setting

Making a VM

1. Obtain the most recent Fedora-Cloud-Base picture: The web site for Fedora’s Cloud Base Photos is https://alt.fedoraproject.org/cloud/. If the obtain hyperlink beneath isn’t accessible, please confer with this web site and get a brand new one:

[[email protected] ~]# wget https://obtain.fedoraproject.org/pub/fedora/linux/releases/32/Cloud/x86_64/photos/Fedora-Cloud-Base-32-1.6.x86_64.qcow2

2. Put together the qcow2 picture: Use the cleansing command set up the associated bundle and alter the password to your individual:

[[email protected] ~]# sudo virt-sysprep –root-password password:changeme –uninstall cloud-init –network –install ethtool,pciutils,kernel-modules-internal –selinux-relabel -a Fedora-Cloud-Base-32-1.6.x86_64.qcow2

Compile the kernel

For some linux distros, the vDPA kernel framework was not enabled by default, we have to obtain the linux supply code and compile it. Beneath are the steps to compile the linux kernel. (The kernel model must be 5.Four or above)

You will get extra details about the way to compile linux kernels from how-to-compile-linux-kernel. You’ll be able to skip this half in case you are acquainted with it.

[[email protected] ~]# git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
[[email protected] ~]# cd linux
[[email protected] ~]# git checkout v5.8
[[email protected] ~]# cp /boot/config-$(uname -r) .config
[[email protected] ~]# vim .config
(please confer with the observe about enabling the vDPA kernel framework)
[[email protected] ~]# make -j
[[email protected] ~]# sudo make modules_install
[[email protected] ~]# sudo make set up

And reboot to the newly put in kernel.

Word: We have to set the next strains within the .config file to allow vDPA kernel framework:

CONFIG_VIRTIO_VDPA=m
CONFIG_VDPA=y
CONFIG_VDPA_SIM=m
CONFIG_VHOST_VDPA=m

Word: Should you want to make use of make menuconfig, yow will discover these choices beneath part System Drivers, named DPA drivers, Virtio drivers and VHOST drivers as kernel 5.8.

Compile and set up QEMU

1. Obtain the qemu code: The help for vhost-vdpa backend was merged in v5.1.Zero thus you must use that model or above:

[[email protected] ~]# git clone https://github.com/qemu/qemu.git

2. Compile the qemu: Comply with the instructions beneath (see the README.rst in qemu for extra info):

[[email protected] ~]# cd qemu/
[[email protected] ~]# git checkout v5.1.0-rc3
[[email protected] ~]# mkdir construct
[[email protected] ~]# cd construct/
[[email protected] ~]#../configure –enable-vhost-vdpa –target-list=x86_64-softmmu
[[email protected] ~]# make

Configuring the host

1.  Load all of the associated kmod: It’s best to now load the kmod with the next instructions:

[[email protected] ~]# modprobe vdpa
[[email protected] ~]# modprobe vhost_vdpa
[[email protected] ~]# modprobe vdpa_sim

2. Confirm vhost_vdpa is loaded appropriately: Make sure the bus driver is certainly vhost_vdpa utilizing the next instructions:

[[email protected] ~]# ls -l /sys/bus/vdpa/drivers
drwxr-xr-x 2 root root Zero Sep 5 16:54 vhost_vdpa
#ls -l /sys/bus/vdpa/gadgets/vdpa0/
complete 0
lrwxrwxrwx. 1 root root Zero Sep 21 12:24 driver -> ../../bus/vdpa/drivers/vhost_vdpa
drwxr-xr-x. 2 root root Zero Sep 21 12:25 energy
lrwxrwxrwx. 1 root root Zero Sep 21 12:25 subsystem -> ../../bus/vdpa
-rw-r–r–. 1 root root 4096 Sep 21 12:24 uevent
drwxr-xr-x. Three root root Zero Sep 21 12:25 vhost-vdpa-0
[[email protected] ~]# ls -l /dev/ |grep vdpa
crw——- 1 root root 239, Zero Sep 5 16:54 vhost-vdpa-0

3. Set the ulimit -l limitless: ulimit -l means the utmost measurement that could be locked into reminiscence. On this case we have to set it to limitless, since vhost-vDPA must lock pages for ensuring the {hardware} DMA works appropriately:

[[email protected] ~]# ulimit -l limitless

in the event you overlook to set this, it’s possible you’ll get the error message from qemu much like this:

qemu-system-x86_64: failed to jot down, fd=12, errno=14 (Dangerous tackle)
qemu-system-x86_64: vhost vdpa map fail!
qemu-system-x86_64: vhost-vdpa: DMA mapping failed, unable to proceed

4. Launch the visitor VM: The gadget /dev/vhost-vdpa-0 is the vDPA gadget we will use. This can be a easy instance of utilizing QEMU to launch a VM with vhost_vdpa:

[[email protected] ~]# sudo x86_64-softmmu/qemu-system-x86_64
-hda Fedora-Cloud-Base-32-1.6.x86_64.qcow2
-netdev kind=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 2G
-cpu host
2>&1 | tee vm.log

5. Confirm the port was created efficiently: After the visitor boots up, we will then login in to it. We must always confirm that the port has been bounded efficiently to  the virtio driver. That is for the reason that backend of the virtio_net driver is vhost_vdpa and if one thing went flawed the driving force won’t be created.

visitor login: root
Password:
Final login: Tue Sep 29 12:03:03 on ttyS0
[[email protected] ~]# ip -s hyperlink present eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT gro0
hyperlink/ether fa:46:73:e7:7d:78 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
12006996 200043 Zero Zero Zero 0
TX: bytes packets errors dropped provider collsns
12006996 200043 Zero Zero Zero 0
[[email protected] ~]# ethtool -i eth0
**driver: virtio_net**
model: 1.0.0
firmware-version:
expansion-rom-version:
bus-info: 0000:00:04.0
supports-statistics: sure
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no
[[email protected] ~]# lspci |grep 00:04.0
00:04.Zero Ethernet controller: Pink Hat, Inc. Virtio community gadget

Operating visitors with vhost_vdpa

Now that we now have a vdpa_sim port with the loopback operate. we will generate visitors utilizing pktgen to confirm it. Pktgen is a packet generator built-in with Linux kernel. For extra info please confer with the pktgen doc and pattern check script.

[[email protected] ~]# ip -s hyperlink present eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT gro0
hyperlink/ether fa:46:73:e7:7d:78 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
18013078 300081 Zero Zero Zero 0
TX: bytes packets errors dropped provider collsns
18013078 300081 Zero Zero Zero 0
[[email protected] ~]# ./pktgen_sample01_simple.sh -i eth0 -m 00:e8:ca:33:ba:05
(you will get this script from pattern check script)
[[email protected] ~]# ip -s hyperlink present eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT gro0
hyperlink/ether fa:46:73:e7:7d:78 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
24013078 400081 Zero Zero Zero 0
TX: bytes packets errors dropped provider collsns
24013078 400081 Zero Zero Zero 0

You’ll be able to see the RX packets are growing along with TX packets which implies that vdpa_sim is working as anticipated.

Use Case B: Experimenting with virtio_vdpa bus driver

Overview of the datapath

The virtio_vdpa driver is a transport implementation for kernel virtio drivers on high of vDPA bus operations. The virtio_vdpa driver will create a virtio gadget within the virtio bus. For extra info on the virtio_vdpa bus see right here.

The next diagram exhibits the datapath for virtio-vDPA utilizing a vdpa_sim (the vDPA simulator gadget):

what do you do when you ain&#8217;t got the hardware

Organising your setting

1. Load the modules

[[email protected] ~]# modprobe vdpa
[[email protected] ~]# modprobe virtio_vdpa
[[email protected] ~]# modprobe vdpa_sim

Word: if the vDPA associated modules usually are not compiled then comply with the directions in Use Case A vhost_vpda bus driver to compile them.

2. Confirm virtio_vdpa hundreds appropriately

[[email protected] ~]# lsmod |grep vdpa_sim
vdpa_sim 16384 0
vringh 28672 1 vdpa_sim
vhost_iotlb 16384 2 vdpa_sim,vringh
vdpa 16384 2 vdpa_sim,virtio_vdpa

3. Confirm the driving force is bounded to virtio-vdpa appropriately

[[email protected] ~]# ls -l /sys/bus/vdpa/gadgets/vdpa0/
complete 0
lrwxrwxrwx 1 root root Zero June 23 11:19 driver -> ../../bus/vdpa/drivers/virtio_vdpa
drwxr-xr-x 2 root root Zero June 23 11:19 energy
lrwxrwxrwx 1 root root Zero June 23 11:19 subsystem -> ../../bus/vdpa
-rw-r–r– 1 root root 4096 June 23 11:19 uevent
drwxr-xr-x Four root root Zero June 23 11:19 virtio0

4. Switching from a vhost_vdpa to virtio_vdpa if wanted

If in step Four you see that the interface is bounded to vhost_vdpa as an alternative of virtio_vdpa we have to change it to virtio_vdpda utilizing the next directions:

[[email protected] ~]# echo vdpa0 > /sys/bus/vdpa/drivers/vhost_vdpa/unbind
[[email protected] ~]# echo vdpa0 > /sys/bus/vdpa/drivers/virtio_vdpa/bind
[[email protected] ~]# ls -l /sys/bus/vdpa/gadgets/vdpa0/
complete 0
lrwxrwxrwx 1 root root Zero June 23 11:19 driver -> ../../bus/vdpa/drivers/virtio_vdpa
drwxr-xr-x 2 root root Zero June 23 11:19 energy
lrwxrwxrwx 1 root root Zero June 23 11:19 subsystem -> ../../bus/vdpa
-rw-r–r– 1 root root 4096 June 23 11:19 uevent
drwxr-xr-x Four root root Zero June 23 11:19 virtio0

It’s best to get the identical output for the ls command as proven on this instance.

5. Confirm the bus-info

Now we wish to verify that the whole lot is configured correctly and for that we wish to guarantee our port makes use of a bus-info of kind vdpa:

[[email protected] ~]# ip -s hyperlink present eth0
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT gro0
hyperlink/ether f6:8c:ea:ac:e6:8d brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
137438 803 Zero Zero Zero 0
TX: bytes packets errors dropped provider collsns
137438 803 Zero Zero Zero 0
[[email protected] ~]# dnf set up ethtool
[[email protected] ~]# ethtool -i eth0
driver: virtio_net
model: 1.0.0
firmware-version:
expansion-rom-version:
bus-info: vdpa0
supports-statistics: sure
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

Operating visitors on the virtio_vdpa

Now that we now have a vdpa_sim port with the loopback operate. Similar to in Use Case A: vhost-vdpa, we will generate visitors utilizing pktgen to confirm it. If the pktgen was not put in, you may set up it by following command.

[[email protected] ~]# dnf set up kernel-modules-internal

For extra info please confer with the pktgen doc and pattern check script.

Following are the instructions and the operating logs:

[[email protected] ~]# ip -s hyperlink present eth0
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT gro0
hyperlink/ether f6:8c:ea:ac:e6:8d brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
6227004 101327 Zero Zero Zero 0
TX: bytes packets errors dropped provider collsns
6227004 101327 Zero Zero Zero 0
[[email protected] ~]# ./pktgen_sample01_simple.sh -i eth0 -m 00:e8:ca:33:ba:05
(you will get this script from pattern check script)
[[email protected] ~]# ip -s hyperlink present eth0
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT gro0
hyperlink/ether f6:8c:ea:ac:e6:8d brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
12227330 201328 Zero Zero Zero 0
TX: bytes packets errors dropped provider collsns
12227330 201328 Zero Zero Zero 0

You’ll be able to see the RX packets are growing along with TX packets which implies the vdpa_sim is working as anticipated.

Abstract

On this weblog we’ve guided you on the way to arrange a vDPA testing setting with out utilizing vDPA HW. We’ve coated each the virtio_vdpa bus and the vhost_vdpa bus.

We hope this helped make these ideas extra actual and grounded them in precise Linux tooling.

To maintain up with the virtio-networking group we invite you to enroll to the virtio-networking mailing checklist. This can be a public mailing checklist, and you’ll register via the Mailman web page.

You May Also Like

Calculation Number of Days Between Two Dates

Topic: Delphi Language charlene44 wrote: 18/08/2006 at 15h08 calculation of number of…

Top Benefits of Social Media Marketing

We cannot deny the fact that when it comes to marketing, social…

World of Warcraft Classic: Some Players Use Illegal Tools to Stay Connected

Earlier this week, Blizzard released World of Warcraft Classic. The launch was,…

Crash Team Racing Bientt Back on Ps4!

Activision seems not to have finished with the remastering of the Playstation…