Skip to contentSkip to conversation

usertools/dpdk-devbind.py: bind NIC port to DPDK failed in vm.

dpdk-dev [email protected] 2 participants 2 messages Mar 1, 2021

lore
Share & tools
lore

[email protected]

author Reviewed-by Anatoly Burakov
#0 lore raw

https://bugs.dpdk.org/show_bug.cgi?id=644

Bug ID: 644
Summary: [dpdk-19.11.7]usertools/dpdk-devbind.py: bind NIC port
to DPDK failed in vm.
Product: DPDK
Version: 19.11
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: other
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---

DPDK version:
19.11.7-rc1(cbcd84e3304f43623efe34236f548a1bdae68ca4)
Other software versions: qemu-4.2.1
OS: Ubuntu 20.04.1 LTS/5.10.0-051000-generic
Compiler: gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) Hardware platform: Intel(R) Xeon(R) Platinum 8280M CPU @ 2.70GHz NIC hardware: fortville_spirit
NIC firmware: 5.10.0-051000-generic/8.00 0x80008b8a 1.2766.0 Test Setup
Steps to reproduce
List the steps to reproduce the issue.

#1.Bind nic port to vfio-pci on host

usertools/dpdk-devbind.py --force --bind=vfio-pci 0000:af:00.0 0000:af:00.1

#2.Start testpmd on host

x86_64-native-linuxapp-gcc/app/dpdk-testpmd -l 1,2,3,4,5,6,7,8,9,10,11,12 -n 4
-w 0000:af:00.0 --file-prefix=vhost_56195_20210225181454 --vdev
'net_vhost0,iface=/root/dpdk/vhost-net0,queues=2,client=1' --vdev 'net_vhost1,iface=/root/dpdk/vhost-net1,queues=2,client=1' -- -i --nb-cores=4 --rxq=2 --txq=2 --txd=1024 --rxd=1024
set fwd txonly
start

#3.Start vm on host

taskset -c 46,47,48,49,50,51,52,53 /home/QEMU/qemu-4.2.1/bin/qemu-system-x86_64
-name vm0 -enable-kvm -pidfile /tmp/.vm0.pid -daemonize -monitor
unix:/tmp/vm0_monitor.sock,server,nowait -netdev user,id=nttsip1,hostfwd=tcp:10.240.183.220:6000-:22 -device e1000,netdev=nttsip1 -chardev socket,id=char0,path=/root/dpdk/vhost-net0,server -netdev type=vhost-user,id=netdev0,chardev=char0,vhostforce,queues=2 -device virtio-net-pci,netdev=netdev0,mac=52:54:00:00:00:02,mrg_rxbuf=on,mq=on,vectors=6 -chardev socket,id=char1,path=/root/dpdk/vhost-net1,server -netdev type=vhost-user,id=netdev1,chardev=char1,vhostforce,queues=2 -device virtio-net-pci,netdev=netdev1,mac=52:54:00:00:00:03,mrg_rxbuf=on,mq=on,vectors=6 -cpu host -smp 8 -m 8192 -object memory-backend-file,id=mem,size=8192M,mem-path=/mnt/huge,share=on -numa node,memdev=mem -mem-prealloc -chardev socket,path=/tmp/vm0_qga0.sock,server,nowait,id=vm0_qga0 -device virtio-serial -device virtserialport,chardev=vm0_qga0,name=org.qemu.guest_agent.0 -vnc :4 -drive file=/home/image/ubuntu1910.img

#4.Bind nic to virtio in vm

echo 0000:00:04.0 > /sys/bus/pci/devices/0000\:00\:04.0/driver/unbind modprobe virtio-pci
echo 0000:00:04.0 > /sys/bus/pci/drivers/virtio-pci/bind

echo 0000:00:05.0 > /sys/bus/pci/devices/0000\:00\:05.0/driver/unbind modprobe virtio-pci
echo 0000:00:05.0 > /sys/bus/pci/drivers/virtio-pci/bind

#5.Set vm params

echo 0 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages umount awk '/hugetlbfs/ { print $2 }' /proc/mounts
awk '/hugetlbfs/ { print $2 }' /proc/mounts
mkdir -p /mnt/huge
mount -t hugetlbfs nodev /mnt/huge
cat /proc/mounts |grep hugetlbfs
rmmod vfio_pci
rmmod vfio_iommu_type1
rmmod vfio
modprobe vfio
modprobe vfio-pci
echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode

#6.Bind nic port to vfio-pci in vm

usertools/dpdk-devbind.py --force --bind=vfio-pci 0000:00:04.0 0000:00:05.0 Show the output from the previous commands.

root@ubuntuvm1910:~/dpdk# usertools/dpdk-devbind.py --force --bind=vfio-pci
0000:00:04.0 0000:00:05.0
Traceback (most recent call last):
  File "usertools/dpdk-devbind.py", line 755, in <module>
    main()
  File "usertools/dpdk-devbind.py", line 743, in main
    check_modules()
  File "usertools/dpdk-devbind.py", line 198, in check_modules
    if module_is_loaded(mod["Name"]):
  File "usertools/dpdk-devbind.py", line 177, in module_is_loaded
    release = platform.uname().release
AttributeError: 'tuple' object has no attribute 'release'
Expected Result
Explain what is the expected result in text or as an example output:

# Bind nic port to vfio-pci in vm successfully.
Regression
Is this issue a regression: (Y)

Version the regression was introduced: Specify git id if known.

Bad commit:

commit 1e794e710d186d209eb3a424f56285c9b47774f6 (HEAD)
Author: Yongxin Liu <[email protected]>
Date: Mon Nov 23 11:05:33 2020 +0800

usertools: fix binding built-in kernel driver

[ upstream commit 7a016af4aa6bd2f8425b4fb2d59e5dd19f12bceb ]

A driver can be loaded as a dynamic module or a built-in module. In commit 681a67288655 ("usertools: check if module is loaded before binding"), the script only checks modules in /sys/module/.

However, for built-in kernel driver, it only shows up in /sys/module/, if it has a version or at least one parameter. So add check for modules in /lib/modules/$(uname -r)/modules.builtin.

Fixes 681a67288655 ("usertools: check if module is loaded before binding")
Signature · 2 lines
You are receiving this mail because:
You are the assignee for the bug.
#1 lore raw
Quoted 29 lines · On Mon, Mar 01, 2021 at 01:48:49AM +0000, [email protected] wrote:

https://bugs.dpdk.org/show_bug.cgi?id=644

Bug ID: 644
Summary: [dpdk-19.11.7]usertools/dpdk-devbind.py: bind NIC port
to DPDK failed in vm.
Product: DPDK
Version: 19.11
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: other
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---

DPDK version:
19.11.7-rc1(cbcd84e3304f43623efe34236f548a1bdae68ca4)
Other software versions: qemu-4.2.1
OS: Ubuntu 20.04.1 LTS/5.10.0-051000-generic
Compiler: gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2) Hardware platform: Intel(R) Xeon(R) Platinum 8280M CPU @ 2.70GHz NIC hardware: fortville_spirit
NIC firmware: 5.10.0-051000-generic/8.00 0x80008b8a 1.2766.0 Test Setup
Steps to reproduce
List the steps to reproduce the issue.

Quoted 4 lines

#1.Bind nic port to vfio-pci on host

usertools/dpdk-devbind.py --force --bind=vfio-pci 0000:af:00.0 0000:af:00.1

Unrelated to this bug, don't use "--force" flag with dpdk-devbind unless the script won't let you unbind a port from the kernel and you are absolutely sure it is safe to do so. It should never be routinely used.

/Bruce