The 2 ports of my dual-port ConnectX-6 Dx card are connected to each other. My initial goal is to have 2 VMs communicating through this cable, each using a virtio net device and vDPA on the host, so that I can test vDPA.
I’ve checked the cable by isolating the 2 PFs into separate network namespaces on the host, manually assigning IP addresses and pinging between them. (When there is just a single interface in the namespace, the responses are returned to the same interface where requests came from.)
This also works for VFs, so I’ve concluded that the cable is good.
Then I’ve configured vDPA following your directions (details below), apparently successfully. VMs run and have new virtio net devices.
However, I can’t ping between them. The ‘ifstat’ command in the VMs shows Tx packet count increased by pings, but the Rx count is always 0.
It looks like the ping packets never reach the other side. Maybe this has to do with the “switchdev” mode? (If I turn it on before the “cable test” described above, then it also doesn’t work.)
On the host
systemctl stop firewalld
modprobe vhost-vdpa
devlink dev eswitch set pci/0008:00:00.0 mode switchdev
devlink dev eswitch set pci/0008:00:00.1 mode switchdev
echo 1 > /sys/class/net/ens96f0np0/device/sriov_numvfs
echo 1 > /sys/class/net/ens112f1np1/device/sriov_numvfs
sleep 1
vdpa dev add name vf00.2 mgmtdev pci/0008:00:00.2 mac 52:54:00:17:3a:61
vdpa dev add name vf10.1 mgmtdev pci/0008:00:10.1 mac 52:54:00:17:3a:62
ls -l /dev/vhost-vdpa*
crw-------. 1 root root 248, 0 Jan 7 10:11 /dev/vhost-vdpa-0
crw-------. 1 root root 248, 1 Jan 7 10:11 /dev/vhost-vdpa-1
Each VM has the following “interface” section added to the libvirt XML (I had to remove formatting, otherwise this site doesn’t show it):
interface type=“vdpa”
source dev=“/dev/vhost-vdpa-0”
mac address=‘52:54:00:17:3a:61’
model type=“virtio”
address type=“pci”
(same for the other VM, except "vhost-vdpa-1” and ‘52:54:00:17:3a:62’)
On the VMs
Each shows a new “eno1” network interface, and the MAC addresses are those specified above.
Then, as I’ve done on the host while testing the cable, put each “eno1” into a separate namespace:
ip netns add vdpa
ip link set eno1 netns vdpa
ip netns exec vdpa ip link set dev eno1 up
ip netns exec vdpa ip addr add 10.10.10.10/24 dev eno1
(same on the other VM, except 10.10.10.20)
ip netns exec vdpa ping -c2 10.10.10.20
and the other VM doesn’t see any packets.
switchdev vs legacy mode
If I omit the devlink commands switching to the switchdev mode, the packets still don’t go through. (I’ve verified that the NICs stay in “legacy” mode, via the “devlink dev eswitch show” command. Also, “port representor” interfaces then don’t show up).