Networking Solutions

QSG: High Availability with Mellanox ASAP2 Enhanced SR-IOV (VF-LAG).

Created on Apr 16, 2020 by Amir Zeidner

Introduction

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.

References

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 https://confluence.nvidia.com/download/attachments/2327172947/image2020-9-29_8-59-38.png?version=1&modificationDate=1601395178833&api=v2

Figure 2

https://confluence.nvidia.com/download/attachments/2327172947/image2020-9-29_9-0-1.png?version=1&modificationDate=1601395202180&api=v2

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

https://confluence.nvidia.com/download/attachments/2327172947/image2020-9-29_9-0-26.png?version=1&modificationDate=1601395226623&api=v2


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

https://confluence.nvidia.com/download/attachments/2327172947/image2020-9-29_9-0-44.png?version=1&modificationDate=1601395244673&api=v2

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 Mellanox firmware to support SRIOV

First install the mstflint tool:

Bash
yum install mstflint -y

Extract PFs PCI BUS slot number:

Bash
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:

Bash
## 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:

Bash
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


Note
To learn more about bond modes please refer to:

https://www.cloudibee.com/network-bonding-modes/

Supported modes are 1, 2, 4.

Configure slave interfaces

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

Bash
##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
Bash
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:

Bash
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:
Bash
## 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


Bash
### 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

Bash
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:

Bash
## 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

https://confluence.nvidia.com/download/attachments/2327172947/image2020-9-29_9-1-13.png?version=1&modificationDate=1601395273770&api=v2

  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

    XML
        <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 1.1.1.1 to the VF interface in the Guest VM.

  3. Set IP of 1.1.1.2 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:

Bash
iperf3 -s

6. Start iperf client on the iperf client server:

Bash
iperf3 -c 1.1.1.1 -P 10

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

From the guest VM hypervisor command line run:

Bash
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:

Bash
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



Unknown Attachment

Amir Zeidner

For several years, Amir has worked as a Solutions Architect primarily in the Telco space, leading advanced solutions to answer 5G, NFV, and SDN networking infrastructure 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: