QSG for High Availability with NVIDIA Enhanced SR-IOV with Bonding Support (VF-LAG)

Created on Apr 16, 2020 by Amir Zeidner


As of today, using SRIOV VF (Virtual Function) port attachment for virtualized workload is missing support for link aggregation.
Mellanox ASAP2 technology extends legacy SRIOV capabilities by offloading LAG (link aggregation group) functionality to the Smart Network Interface Card (SmartNIC) hardware. This means that a VM can be attached with single VF backed up by LAG implemented on the NIC level.
This guide will highlight the benefits of having offloaded LAG functionality and walk you through configuration and evaluation of offloaded LAG on a standalone Linux server.


ASAP2 Documentation

Solution Overview

There are few options to implement LAG in a virtual environment, depending on the system configuration and the performance needs:

VM attached with virtual interface (virtio) to host LAG.

This solution is appropriate for workloads and applications which do not require high performance networking.

Figure 1


Figure 2


SRIOV is a default choice for network-demanding applications. In this case, Link Aggregation is performed within VM (VM aware LAG) and only HA mode may be implemented.

SRIOV switchdev mode and ASAP2 (Accelerated Switching and Packet Processing®) are enhanced SR-IOV technologies which offload network processing from the Host and VM into the network adapter hardware.

Bond functionality is now offloaded to the NIC hardware. A single virtual function is backed by two physical bond ports.

Figure 3


Solution Logical Design

Referring to Figure 4, the two network interfaces from the NIC PFs are bounded in the hypervisor. The bond mode is reflected to all VFs of the same NIC. For example: If the BOND is, configured to LACP (Link Aggregation Control Protocol) mode then all VF LAG interfaces will share the same configuration.

To enable VF-LAG, the NIC should be in SRIOV switchdev mode. Unlike SRIOV legacy mode, switchdev mode requires a control plane to configure the steering and forwarding behavior of VFs. In this document we use OVS for this purpose. Please see OVS offload document for more details.

Figure 4


Host Configuration and Prerequisites

  • BIOS: VT-D and SRIOV enabled

  • OpenVswitch => 2.12

  • OS => RHEL 7.7

  • Kernel => 4.10

Host Deployment and Configuration

Set firmware to support SRIOV

First install the mstflint tool:


yum install mstflint -y

Extract PFs PCI BUS slot number:


lspci | grep -i mel | grep -v Virtual 61:00.0 Ethernet controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex] 61:00.1 Ethernet controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex]

Set firmware to enable SRIOV with number of desired VFs using PCI slot number taken from previous step:


## Enable SRIOV and set desired number of VFS (This example enable 4 VFs)## mstconfig -d <PF_PCI_BUS_slot_number> set SRIOV_EN=1 NUM_OF_VFS=4

Configure Linux bond

Configure the BOND interface.
This example demonstrates BOND LACP configuration:


cat << EOF > /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 ONBOOT=yes HOTPLUG=no NM_CONTROLLED=no PEERDNS=no BOOTPROTO=none BONDING_OPTS="mode=4 miimon=100 lacp_rate=1" BOOTPROTO=static EOF

Configure slave interfaces

Replace <first_interface_name>, <second_interface_name> with the respective PFs BOND slave names.


##Configure first slave## sed -i 's/\(ONBOOT=\)no/\1yes/g' /etc/sysconfig/network-scripts/ifcfg-<First_PF_interface_name> sed -i 's/\(BOOTPROTO=\)dhcp/\1none/g' /etc/sysconfig/network-scripts/ifcfg-<First_PF_interface_name>   cat << EOF >> /etc/sysconfig/network-scripts/ifcfg-<First_PF_interface_name> MASTER=bond0 SLAVE=yes EOF ##Configure second slave## sed -i 's/\(ONBOOT=\)no/\1yes/g' /etc/sysconfig/network-scripts/ifcfg-<Second_PF_interface_name> sed -i 's/\(BOOTPROTO=\)dhcp/\1none/g' /etc/sysconfig/network-scripts/ifcfg-<Second_PF_interface_name>   cat << EOF >> /etc/sysconfig/network-scripts/ifcfg-<Second_PF_interface_name> MASTER=bond0 SLAVE=yes EOF

Restart network services


systemctl restart network.service

Enable ASAP2 VF-LAG capabilities

This example uses 2 VFs per PF (it is possible to configure more).
Extract PFs PCI BUS slot number:


lspci | grep -i mel | grep -v Virtual 61:00.0 Ethernet controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex] 61:00.1 Ethernet controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex]

Enable switchdev mode per each PF bond slave interface:


## Flush iptable rules and enable TC offloading per PF## iptables -F ethtool -K <First_PF_interface_name> hw-tc-offload on ethtool -K <Second_PF_interface_name> hw-tc-offload on ## This example define 2 VFs per PF ## echo 0 > /sys/class/net/<First_PF_interface_name>/device/sriov_numvfs echo 0 > /sys/class/net/<Second_PF_interface_name>/device/sriov_numvfs echo 2 > /sys/class/net/<Second_PF_interface_name>/device/sriov_numvfs echo 2 > /sys/class/net/<First_PF_interface_name>/device/sriov_numvfs


### Unbind Mellanox VF's kernel driver## VFS_PCI=($(lspci | grep "Mellanox" | grep "Virtual" | cut -d " " -f 1)); for i in ${VFS_PCI[@]}; do echo "unbinding VF $i"; echo "0000:${i}" >> /sys/bus/pci/drivers/mlx5_core/unbind; done ### Set PF interfaces to switchdev mode by pointing PCI slot address number ### devlink dev eswitch set pci/0000:61:00.0 mode switchdev devlink dev eswitch set pci/0000:61:00.1 mode switchdev

Once switchdev mode is enabled, new representor ports will be present in Linux bridge.

Now it is possible to discover representor ports mapping.

First download attached map_rep.py script from this section and run it as explained here: map_rep.py


pip install tabulate python map_rep.py --port <First_PF_interface_name>     ## Sample output ## VF NUMBER REPRESENTOR PORT VF PORT VF PCI PF NAME MACHINE NAME MACHINE UUID ----------- ------------------ --------- ------------ --------- -------------------------- -------------- 0 ens2f0_0 0000:61:00.2 ens2f0 clx-host-038-01-CentOS-7.7 2 1 ens2f0_1 0000:61:00.3 ens2f0 clx-host-038-01-CentOS-7.7 2

Openvswitch settings

Add the desired representor ports to OpenVswitch bridge which represent the designated VFs:


## Bring representor ports up ## ifconfig <representor_port1_name> up ## Create OVS bridge with BOND and representor ports ## systemctl start openvswitch ovs-vsctl add-br ovs-sriov ovs-vsctl add-port ovs-sriov <representor_port1_name> ovs-vsctl add-port ovs-sriov bond0 ## Enable OVS Hardware offload and restart ## ovs-vsctl set Open_vSwitch . other_config:hw-offload=true systemctl restart openvswitch

Deployment Verification

Test deployment (figure 5) overview:

Figure 5


  1. First spawn up a guest VM with VF interface using SRIOV attachment based on VF PCI slot number.
    Here is Virsh XML section for SRIOV interface attachment of VF with PCI slot number 0000:61:01.2


    <interface type='hostdev' managed='yes'> <mac address='6a:66:2d:48:92:c3'/> <source> <address type='pci' domain='0x0000' bus='0x61' slot='0x01' function='0x2'/> </source> <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/> </interface>

  2. Set IP of to the VF interface in the Guest VM.

  3. Set IP of to the Iperf client interface which is connected to L2 switch.

  4. Make sure there is connectivity between the Iperf client to the guest VM by issuing ICMP requests.

  5. Start iperf server on the Guest VM:


iperf3 -s

6. Start iperf client on the iperf client server:


iperf3 -c -P 10

7. Validate that packets are received and transmitted on both bond slaves.

From the guest VM hypervisor command line run:


watch -d -n1 "ethtool -S <First_PF_interface_name> | grep packets | grep phy" watch -d -n1 "ethtool -S <Second_PF_interface_name> | grep packets | grep phy" ## output should look like this ## tx_packets_phy: 135555012 rx_packets_phy: 1487683

8. Fail one of the bond links and repeat step 7. You will observe packet are received and transmitted only for single bond slave.

Tearing Down VF-LAG BOND

In case user would like to teardown VF-LAG BOND it is very important to follow this sequence:

1. First teardown VFs from a VM.
2. Unbind VF drivers as follows:


VFS_PCI=($(lspci | grep "Mellanox" | grep "Virtual" | cut -d " " -f 1)); for i in ${VFS_PCI[@]}; do echo "unbinding VF $i"; echo "0000:${i}" >> /sys/bus/pci/drivers/mlx5_core/unbind; done

3. Undo steps for building VF-LAG BOND which are described in this post.

About the Author


Amir Zeidner

For the past several years, Amir has worked as a Solutions Architect primarily in the Telco space, leading advanced solutions to answer 5G, NFV, and SDN networking infrastructures requirements. Amir’s expertise in data plane acceleration technologies, such as Accelerated Switching and Network Processing (ASAP²) and DPDK, together with a deep knowledge of open source cloud-based infrastructures, allows him to promote and deliver unique end-to-end NVIDIA Networking solutions throughout the Telco world.

Last updated on Sep 12, 2023.