How To Configure SR-IOV for Mellanox ConnectX® 4/5 adapter cards family on ESXi 6.5/6.7 Server (Native Ethernet)

Version 15

    This post describes how to configure the Mellanox ConnectX-4/5 driver with an SR-IOV (Ethernet) for ESXi 6.7 Native driver.

    Note: Setting up a VM is out of the scope of this post.

    References

     

     

    Single Root IO Virtualization (SR-IOV)

     

    Single Root IO Virtualization (SR-IOV) is a technology that allows a physical PCIe device to present itself multiple times through the PCIe bus. This technology enables multiple virtual instances of the device with separate resources. Mellanox adapters are capable of exposing in ConnectX-4/ConnectX-5 adapter cards up to 128 virtual instances called Virtual Functions (VFs). These virtual functions can then be provisioned separately. Each VF can be seen as an addition device connected to the Physical Function. It shares the same resources with the Physical Function.

    SR-IOV is commonly used in conjunction with an SR-IOV enabled hypervisor to provide virtual machines direct hardware access to network resources hence increasing its performance.

     

    Overview

    SR-IOV configuration includes the following steps to:

    1. Enable Virtualization (SR-IOV) in the BIOS (prerequisites).
    2. Enable SR-IOV in the firmware.
    3. Enable SR-IOV in the MLNX_OFED Driver.
    4. Map the Virtual Machine (VM) to the relevant port via SR-IOV.

     

     

    Hardware and Software Requirements

    1. A server platform with an adapter card based on one of the following Mellanox Technologies’ HCA devices:

    2. Installer Privileges: The installation requires administrator privileges on the target machine.

    3. Device ID: For the latest list of device IDs, please visit Mellanox website.

     

    Prerequisites

    To set up an SR-IOV environment, the following is required:

    1. Make sure that SR-IOV is enabled in the BIOS of the specific server. Each server has different BIOS configuration options for virtualization. See HowTo Set Dell PowerEdge R730 BIOS parameters to support SR-IOV for BIOS configuration examples.
    2. Make sure to have the latest nmlx5_core native driver on the Hypervisor. Refer to Mellanox VMware driver page.
    3. Install Mellanox Firmware Tools (MFT) on ESXi server, refer to How To Install Mellanox Firmware Tools (MFT) on VMware ESXi 6.5/6.7.

     

     

    Setting Up SR-IOV

     

    Enable SR-IOV in the BIOS

    Each server has different BIOS configuration options for virtualization.

    The figures used in this section are for illustration purposes only.

    For further information, please refer to the appropriate BIOS User Manual:

     

    1. Enable "SR-IOV" in the system BIOS.

    2. Enable "Intel Virtualization Technology".

     

    Enable SR-IOV on the Firmware

    1. Enable SSH Access to ESXi server.

    2. Log into ESXi vSphere Command-Line Interface with root permissions.

    3. Run MFT and check the status.

    # /opt/mellanox/bin/mst start

    Module nmst loaded successfully

     

    # /opt/mellanox/bin/mst status

     

    MST devices:
    ------------
    mt4121_pciconf0

     

    4. Query the status of the device.

    # /opt/mellanox/bin/mlxconfig -d mt4121_pciconf0 q

     

    Device #1:

    ----------

    Device type:    ConnectX5
    Name:           N/A
    Description:    N/A
    Device:         mt4121_pciconf0

     

    Configurations:                              Current

     

     

             MEMIC_BAR_SIZE                      0

             MEMIC_SIZE_LIMIT                    _256KB(1)  

             ROCE_NEXT_PROTOCOL                  254

             NON_PREFETCHABLE_PF_BAR             False(0)

             NUM_OF_VFS                          0 

             SRIOV_EN                            False(0)       

             PF_LOG_BAR_SIZE                     5             

             VF_LOG_BAR_SIZE                     1  

             ...          

     

    5. Enable SR-IOV and set the desired number of Virtual Functions (VFs).

    • SRIOV_EN=1
    • NUM_OF_VFS=8   ; This is an example with eight VFs per port.

      # /opt/mellanox/bin/mlxconfig -d mt4121_pciconf0 set SRIOV_EN=1 NUM_OF_VFS=8

      Device #1:
      ----------

       

      Device type:    ConnectX5
      Name:           N/A
      Description:    N/A
      Device:         mt4121_pciconf0

       

      Configurations:                              Next Boot       New
               SRIOV_EN                            True(1)         True(1)
               NUM_OF_VFS                          16              8

       

      Apply new Configuration? ? (y/n) [n] : y
      Applying... Done!
      -I- Please reboot machine to load new configurations.

    Note: mlxconfig must be performed for each PCI device (adapter). In parallel, in the driver the configuration is per module, which means that it will be applicable for all adapters installed on the server.

    6. Enter Maintenance Mode the ESXi host.

    7. Reboot the server.

    Note: At this point, the VFs are not seen when using lspci. Only when SR-IOV is enabled on the driver will you be able to see them.

    # lspci -d | grep Mellanox

    0000:02:00.0 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex] [vmnic2]

    0000:02:00.1 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex] [vmnic3]

    8. Exit Maintenance Mode the ESXi host.

    9. Check if SR-IOV is enabled in the firmware.

    # /opt/mellanox/bin/mlxconfig -d mt4121_pciconf0 q

     

    Device #1:

    ----------

    Device type:    ConnectX5
    Name:           N/A
    Description:    N/A
    Device:         mt4121_pciconf0

     

    Configurations:                              Current

     

     

             MEMIC_BAR_SIZE                      0

             MEMIC_SIZE_LIMIT                    _256KB(1)  

             ROCE_NEXT_PROTOCOL                  254

             NON_PREFETCHABLE_PF_BAR             False(0)

             NUM_OF_VFS                          8 

             SRIOV_EN                            True(1)       

             PF_LOG_BAR_SIZE                     5             

             VF_LOG_BAR_SIZE                     1  

             ...          

    Enable SR-IOV on the Driver

     

    1. Get the module parameter list as follows:

    # esxcli system module parameters list -m nmlx5_core

    Name                   Type           Value  Description

    ...

     

    enable_nmlx_debug      int                   Enable debug prints

       Values : 1 - enabled, 0 - disabled

       Default: 0

    max_vfs                array of uint         Number of PCI VFs to initialize

       Values : Array of 'uint' of range 0-128, May be limited by device, 0 - disabled

       Default: 0

    ...

     

    2. Enable SR-IOV in the driver and set the max_vfs module parameter.

    # esxcli system module parameters set -m nmlx5_core -p "max_vfs=4"

    Note 1: Allow at least one more VF to be configured on the firmware (num_of_vfs) than is configured on the driver. In our example we had eight VFs configured on the firmware while four is configured on the driver (max_vfs).

    Note 2: mlxconfig must be performed for each PCI device (adapter). In parallel, in the driver the configuration is per module, which means that it will be applicable for all adapters installed on the server.

    Note 3: Changing the number of VFs is persistent.

    3. Enter Maintenance Mode the ESXi host.

    4. Reboot the server.

    5. Exit Maintenance Mode the ESXi host.

    6. Check the PCI bus and verify that you see the VFs (with the same number of VFs on each port).

    # lspci -d | grep Mellanox

    0000:02:00.0 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex] [vmnic2]

    0000:02:00.1 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex] [vmnic3]

    0000:02:00.2 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex Virtual Function] [PF_0.2.0_VF_0]

    0000:02:00.3 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex Virtual Function] [PF_0.2.0_VF_1]

    0000:02:00.4 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex Virtual Function] [PF_0.2.0_VF_2]

    0000:02:00.5 Network controller: Mellanox Technologies MT28800 Family [ConnectX-5 Ex Virtual Function] [PF_0.2.0_VF_3]

    At this point you can see four VFs and one Physical Function (PF) per port.

     

    Add Network Adapter to the VM in SR-IOV Mode

    Note 2: Make sure the VM version is Rel. 10 or above, and upgrade it if needed by accessing the Compatibility section (otherwise SR-IOV will not appear as an option in the network adapter selection).

    Note 3: Before you start, power off the VM.

    After you enable the Virtual Functions on the host, each of them becomes available as a PCI device.

    To assign Virtual Function to a Virtual Machine in the vSphere Web Client:

     

    1. Locate the Virtual Machine in the vSphere Web Client.

        1. Select a data center, folder, cluster, resource pool, or host and click the Related Objects tab.
        2. Click Virtual Machines and select the virtual machine from the list.

    2. Power off the Virtual Machine.

     

    3. Select the VM and Go to "Edit Settings".

     

     

    4. Click on Add Network adapter.

     

    5. Under Adapter Type select the SR-IOV passthrough connectivity option.

     

    6. Check the Reserve all guest memory (All locked) checkbox.

    I/O memory management unit (IOMMU) must reach all Virtual Machine memory so that the passthrough device can access the memory by using direct memory access (DMA).

     

    7.  Expand the New Network section and connect the Virtual Machine to the SRIOV net port group from the combo box at the bottom of the screen.

    The virtual NIC does not use this port group for data traffic. The port group is used to extract the networking properties, for example VLAN tagging, to apply on the data traffic.

     

    Notes: MAC Address and MTU Considerations

         1: You can leave the automatic generated MAC address (this is the default), or change it manually.

         2: The Hypervisor MTU should be higher or equal to the Guest VM, otherwise, the packets may be dropped. You may modify “Set Guest OS MTU change” to allow changing MTU from guest. This step is applicable only if this feature is supported by the driver.

    8. Power on the VM

    9. Open the VM command line (by us) and make sure that you have the interface connected.

    On the guest VM install the OS Mellanox driver (OFED, WinOF ...).

    Configure the IP Address and check Network connectivity.

     

    Troubleshooting

    1. At least one more VF must be configured on the firmware than is configured on the driver. In our example we had eight VFs configured on the firmware while four are configured on the driver.

     

    2. mlxconfig must be performed for each PCI device (adapter). In parallel, in the driver the configuration is per module, which means that it will be applicable for all adapters installed on the server.

     

    3. Make sure the VM version is Rel. 10 or above, and upgrade it if needed by accessing the Compatibility section (otherwise SR-IOV will not appear as option in network adapter selection).