Rate This Document
Findability
Accuracy
Completeness
Readability

Configuring Kernel-Mode SR-IOV

  1. Add VFs to the PF network port.
    1. Run the following command to add VFs. In the command, 8 indicates the maximum number of VFs supported by the Mellanox network port queried in 4. Therefore, a maximum of eight VFs can be configured.
      1
      echo 8 > /sys/class/net/enp1s0f1/device/sriov_numvfs
      
    2. Check whether the adding operation is successful.
      1
      cat /sys/class/net/enp1s0f1/device/sriov_numvfs
      

  2. Configure MAC addresses of the VFs.
    1. Run the following commands:
      1
      2
      3
      4
      5
      6
      7
      8
      ip link set enp1s0f1 vf 0 mac e4:11:22:33:44:50
      ip link set enp1s0f1 vf 1 mac e4:11:22:33:44:51
      ip link set enp1s0f1 vf 2 mac e4:11:22:33:44:52
      ip link set enp1s0f1 vf 3 mac e4:11:22:33:44:53
      ip link set enp1s0f1 vf 4 mac e4:11:22:33:44:54
      ip link set enp1s0f1 vf 5 mac e4:11:22:33:44:55
      ip link set enp1s0f1 vf 6 mac e4:11:22:33:44:56
      ip link set enp1s0f1 vf 7 mac e4:11:22:33:44:57
      
    2. Verify the configuration.
      1
      ip link show dev enp1s0f1
      

      Each MAC address must be unique on the local server, the peer server, and the switch.

    3. Check the PCI port numbers of the eight VFs.
      1
      ls -l /sys/class/net/
      

  3. Change the network port mode.
    1. Unbind the VFs.
      1
      2
      3
      4
      5
      6
      7
      8
      echo 0000:01:01.2 > /sys/bus/pci/drivers/mlx5_core/unbind
      echo 0000:01:01.3 > /sys/bus/pci/drivers/mlx5_core/unbind
      echo 0000:01:01.4 > /sys/bus/pci/drivers/mlx5_core/unbind
      echo 0000:01:01.5 > /sys/bus/pci/drivers/mlx5_core/unbind
      echo 0000:01:01.6 > /sys/bus/pci/drivers/mlx5_core/unbind
      echo 0000:01:01.7 > /sys/bus/pci/drivers/mlx5_core/unbind
      echo 0000:01:02.0 > /sys/bus/pci/drivers/mlx5_core/unbind
      echo 0000:01:02.1 > /sys/bus/pci/drivers/mlx5_core/unbind
      

    2. On the PF, change the eSwitch mode from Legacy to SwitchDev.
      1
      2
      3
      devlink dev eswitch set pci/0000:01:00.1 mode switchdev
      echo switchdev > /sys/class/net/enp1s0f1/compat/devlink/mode
      cat /sys/class/net/enp1s0f1/compat/devlink/mode
      

    3. Check whether the device name of the Representor has been changed.
      1
      ls -l /sys/class/net/
      

      The device name of the VFs has been changed from enp1s0f$ to enp1s0f1_$.

  4. Bind the VFs.
    1
    2
    3
    4
    5
    6
    7
    8
    echo 0000:01:01.2 > /sys/bus/pci/drivers/mlx5_core/bind
    echo 0000:01:01.3 > /sys/bus/pci/drivers/mlx5_core/bind
    echo 0000:01:01.4 > /sys/bus/pci/drivers/mlx5_core/bind
    echo 0000:01:01.5 > /sys/bus/pci/drivers/mlx5_core/bind
    echo 0000:01:01.6 > /sys/bus/pci/drivers/mlx5_core/bind
    echo 0000:01:01.7 > /sys/bus/pci/drivers/mlx5_core/bind
    echo 0000:01:02.0 > /sys/bus/pci/drivers/mlx5_core/bind
    echo 0000:01:02.1 > /sys/bus/pci/drivers/mlx5_core/bind