What can I help you with?
NVIDIA DPDK Documentation MLNX_DPDK_22.11_2310.5.1 LTS

Configuring VF to be Trusted

To support hardware offloading and software steering on VFs, the trusted mode needs to be enabled.

The procedure below is using a ConnectX-5 adapter cards (pf0) with 2 VFs.

  • In Legacy SR-IOV mode.

    1. Configure all the trusted VF using mlxreg to use software steering.

      Note

      Firmware version used must be >= xx.29.1016

      • For all trusted VFs (mt4121_pciconf0 is the MST device example):

        Copy
        Copied!
                    

        $ mlxreg -d /dev/mst/mt4121_pciconf0 --reg_name VHCA_TRUST_LEVEL --yes --set "all_vhca=0x1,trust_level=0x1"

      • For a specific VF:

        Copy
        Copied!
                    

        $ mlxreg -d /dev/mst/mt4121_pciconf0 --reg_id 0xc007 --reg_len 0x40 --indexes "0x0.0:32=<vhca id>" --yes --set "0x4.0:32=0x1"

    2. Create 2 VFs on the PF pf0 when in Legacy SR-IOV mode.

      Copy
      Copied!
                  

      $ echo 2 > /sys/class/net/pf0/device/mlx5_num_vfs

    3. Verify the VFs are created.

      Copy
      Copied!
                  

      $ lspci | grep Mellanox 82:00.0 Ethernet controller: Mellanox Technologies MT27800 Family [ConnectX-5] 82:00.1 Ethernet controller: Mellanox Technologies MT27800 Family [ConnectX-5] 82:00.2 Ethernet controller: Mellanox Technologies MT27800 Family [ConnectX-5 Virtual Function] 82:00.3 Ethernet controller: Mellanox Technologies MT27800 Family [ConnectX-5 Virtual Function]

    4. Set the VFs to be trusted for the kernel by using one of the methods below.

      1. Using sysfs file.

        Copy
        Copied!
                    

        $ echo ON | tee /sys/class/net/pf0/device/sriov/0/trust $ echo ON | tee /sys/class/net/pf0/device/sriov/1/trust

      2. Using “ip link” command.

        Copy
        Copied!
                    

        $ ip link set p0 vf 0 trust on $ ip link set p0 vf 1 trust on

    5. VFs can be attached to the VM.

  • In switchdev SR-IOV mode with bond (VF-LAG), for single port switchdev SR-IOV, the first two steps are not needed.

    1. Probe the bond module, take pf0, pf1 and mode4 for example.

      Copy
      Copied!
                  

      $ modprobe bonding miimon=100 mode=4 $ ip link add bond1 type bond miimon 100 mode 4 xmit_hash_policy layer3+4

    2. Add PFs to the bond.

      Copy
      Copied!
                  

      $ ip link set pf0 master bond1 $ ip link set pf1 master bond1

    3. Configure all the trusted VF using mlxreg to use SW steering.

      Note

      Firmware version used must be >= xx.29.1016

      1. For all trusted VFs:

        Copy
        Copied!
                    

        $ mlxreg -d /dev/mst/mt4121_pciconf0 --reg_name VHCA_TRUST_LEVEL --yes --set "all_vhca=0x1,trust_level=0x1"

      2. For a specific VF:

        Copy
        Copied!
                    

        $ mlxreg -d /dev/mst/mt4121_pciconf0 --reg_id 0xc007 --reg_len 0x40 --indexes "0x0.0:32=<vhca id>" --yes --set "0x4.0:32=0x1"

    4. Create VFs on the PFs.

      Copy
      Copied!
                  

      $ echo 2 > /sys/class/net/pf0/device/mlx5_num_vfs $ echo 2 > /sys/class/net/pf1/device/mlx5_num_vfs

    5. Unbind all the VFs.

      Copy
      Copied!
                  

      $ echo "0000:82:0Y.X" >> /sys/bus/pci/drivers/mlx5_core/unbind

    6. [Optional] Set encap to none.

      Copy
      Copied!
                  

      $ echo "none" > /sys/class/net/pf0/compat/devlink/encap $ echo "none" > /sys/class/net/pf1/compat/devlink/encap

    7. Set switchdev mode.

      Copy
      Copied!
                  

      $ echo "switchdev" > "/sys/class/net/pf0/compat/devlink/mode" $ echo "switchdev" > "/sys/class/net/pf1/compat/devlink/mode"

    8. All VFs are trusted and can be probed into the VM. If they need to be used in the hypervisor, they need to be bound.

      Note

      Firmware version used must be >= xx.29.1016

      • For all trusted VFs.

        Copy
        Copied!
                    

        $ mst start $ mlxreg -d /dev/mst/mt4121_pciconf0 --reg_id 0xc007 --reg_len 0x40 --indexes "0x0.0:32=0x80000000" --yes --set "0x4.0:32=0x1"

      • All VFs are trusted and could be probed into VM. If they need to be used in hypervisor, they need to be bound.

        Copy
        Copied!
                    

        $ echo "0000:82:0Y.X" >> /sys/bus/pci/drivers/mlx5_core/bind

  • Trusted SF's configuration for Switchdev mode.

    1. Configure the following to create SFs

      Copy
      Copied!
                  

      $ mlxconfig -d 0000:43:00.0 s PF_BAR2_ENABLE=0 PER_PF_NUM_SF=1 PF_TOTAL_SF=252 PF_SF_BAR_SIZE=10

    2. Power cycle the server.

    3. Configure the device in switchdev mode.

      Copy
      Copied!
                  

      $ devlink dev eswitch set pci/0000:43:00.0 mode switchdev

    4. Configure it back to legacy mode.

      Copy
      Copied!
                  

      $ devlink dev eswitch set pci/0000:43:00.0 mode legacy

    5. Disable encap on the PF FDB.

      Copy
      Copied!
                  

      $ echo none > /sys/class/net/pf0/compat/devlink/encap

    6. Restore the switchdev mode.

      Copy
      Copied!
                  

      $ devlink dev eswitch set pci/0000:43:00.0 mode switchdev

    7. Configure all SFs to be trusted.

      Copy
      Copied!
                  

      $ mlxreg -d /dev/mst/mt4121_pciconf0 --reg_name VHCA_TRUST_LEVEL --yes --set "all_vhca=0x1,trust_level=0x1"

    8. Alias mlxdevm to simplify the commands.

      Copy
      Copied!
                  

      $ alias mlxdevm="/opt/mellanox/iproute2/sbin/mlxdevm"

    9. Create two SFs for example.

      Copy
      Copied!
                  

      $ mlxdevm port add pci/0000:43:00.0 flavour pcisf pfnum 0 sfnum 101 $ mlxdevm port add pci/0000:43:00.0 flavour pcisf pfnum 0 sfnum 102

    10. Set the MAC address for the new SFs.

      Copy
      Copied!
                  

      $ mlxdevm port function set pci/0000:43:00.0/32768 hw_addr aa:bb:cc:09:83:04 $ mlxdevm port function set pci/0000:43:00.0/32769 hw_addr aa:bb:cc:09:83:04

    11. Activate the new SFs.

      Copy
      Copied!
                  

      $ mlxdevm port function set pci/0000:43:00.0/32768 state active $ mlxdevm port function set pci/0000:43:00.0/32769 state active

    12. If on a NVIDIA BlueField-2 DPU

      Copy
      Copied!
                  

      $ echo mlx5_core.sf.6 > /sys/bus/auxiliary/drivers/mlx5_core.sf_cfg/unbind $ echo mlx5_core.sf.6 > /sys/bus/auxiliary/drivers/mlx5_core.sf/bind

  • Trusted HPF/VF on the host for NVIDIA BlueField-2

    1. Stop the VM if it is a VF and in use.

    2. On the host side, stop the driver.

      Copy
      Copied!
                  

      $ /etc/init.d/openibd stop

    3. On the Arm side, configure the device in legacy mode.

      Copy
      Copied!
                  

      # devlink dev eswitch set pci/0000:03:00.0 mode legacy # devlink dev eswitch set pci/0000:03:00.1 mode legacy

    4. Disable encap.

      Copy
      Copied!
                  

      # echo none > /sys/class/net/p0/compat/devlink/encap # echo none > /sys/class/net/p1/compat/devlink/encap

    5. Configure the device back to switchdev mode.

      Copy
      Copied!
                  

      # devlink dev eswitch set pci/0000:03:00.0 mode switchdev # devlink dev eswitch set pci/0000:03:00.1 mode switchdev

    6. Configure the HPF to be trusted.

      Copy
      Copied!
                  

      # mlxreg -d /dev/mst/mt41686_pciconf0 --reg_name VHCA_TRUST_LEVEL --yes --set "all_vhca=0x1,trust_level=0x1" # mlxreg -d /dev/mst/mt41686_pciconf0.1 --reg_name VHCA_TRUST_LEVEL --yes --set "all_vhca=0x1,trust_level=0x1"

    7. Restart the driver on the host side.

      Copy
      Copied!
                  

      $ /etc/init.d/openibd start

    8. Start the driver and VM if it is a VF.

© Copyright 2024, NVIDIA. Last updated on Jan 9, 2025.