image image image image image image



On This Page

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.
NVIDIA 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

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 NIC 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

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.

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

iperf3 -s

6. Start iperf client on the iperf client server:

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:

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.



Notice

This document is provided for information purposes only and shall not be regarded as a warranty of a certain functionality, condition, or quality of a product. Neither NVIDIA Corporation nor any of its direct or indirect subsidiaries and affiliates (collectively: “NVIDIA”) make any representations or warranties, expressed or implied, as to the accuracy or completeness of the information contained in this document and assumes no responsibility for any errors contained herein. NVIDIA shall have no liability for the consequences or use of such information or for any infringement of patents or other rights of third parties that may result from its use. This document is not a commitment to develop, release, or deliver any Material (defined below), code, or functionality.
NVIDIA reserves the right to make corrections, modifications, enhancements, improvements, and any other changes to this document, at any time without notice.
Customer should obtain the latest relevant information before placing orders and should verify that such information is current and complete.
NVIDIA products are sold subject to the NVIDIA standard terms and conditions of sale supplied at the time of order acknowledgement, unless otherwise agreed in an individual sales agreement signed by authorized representatives of NVIDIA and customer (“Terms of Sale”). NVIDIA hereby expressly objects to applying any customer general terms and conditions with regards to the purchase of the NVIDIA product referenced in this document. No contractual obligations are formed either directly or indirectly by this document.
NVIDIA products are not designed, authorized, or warranted to be suitable for use in medical, military, aircraft, space, or life support equipment, nor in applications where failure or malfunction of the NVIDIA product can reasonably be expected to result in personal injury, death, or property or environmental damage. NVIDIA accepts no liability for inclusion and/or use of NVIDIA products in such equipment or applications and therefore such inclusion and/or use is at customer’s own risk.
NVIDIA makes no representation or warranty that products based on this document will be suitable for any specified use. Testing of all parameters of each product is not necessarily performed by NVIDIA. It is customer’s sole responsibility to evaluate and determine the applicability of any information contained in this document, ensure the product is suitable and fit for the application planned by customer, and perform the necessary testing for the application in order to avoid a default of the application or the product. Weaknesses in customer’s product designs may affect the quality and reliability of the NVIDIA product and may result in additional or different conditions and/or requirements beyond those contained in this document. NVIDIA accepts no liability related to any default, damage, costs, or problem which may be based on or attributable to: (i) the use of the NVIDIA product in any manner that is contrary to this document or (ii) customer product designs.
No license, either expressed or implied, is granted under any NVIDIA patent right, copyright, or other NVIDIA intellectual property right under this document. Information published by NVIDIA regarding third-party products or services does not constitute a license from NVIDIA to use such products or services or a warranty or endorsement thereof. Use of such information may require a license from a third party under the patents or other intellectual property rights of the third party, or a license from NVIDIA under the patents or other intellectual property rights of NVIDIA.
Reproduction of information in this document is permissible only if approved in advance by NVIDIA in writing, reproduced without alteration and in full compliance with all applicable export laws and regulations, and accompanied by all associated conditions, limitations, and notices.
THIS DOCUMENT AND ALL NVIDIA DESIGN SPECIFICATIONS, REFERENCE BOARDS, FILES, DRAWINGS, DIAGNOSTICS, LISTS, AND OTHER DOCUMENTS (TOGETHER AND SEPARATELY, “MATERIALS”) ARE BEING PROVIDED “AS IS.” NVIDIA MAKES NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL NVIDIA BE LIABLE FOR ANY DAMAGES, INCLUDING WITHOUT LIMITATION ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF ANY USE OF THIS DOCUMENT, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Notwithstanding any damages that customer might incur for any reason whatsoever, NVIDIA’s aggregate and cumulative liability towards customer for the products described herein shall be limited in accordance with the Terms of Sale for the product.

Trademarks
NVIDIA, the NVIDIA logo, and Mellanox are trademarks and/or registered trademarks of NVIDIA Corporation and/or Mellanox Technologies Ltd. in the U.S. and in other countries. Other company and product names may be trademarks of the respective companies with which they are associated.

Copyright
© 2023 NVIDIA Corporation & affiliates. All Rights Reserved.