Configuring Kernel-Mode SR-IOV
- Add VFs to the PF network port.
- 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.
1echo 8 > /sys/class/net/enp1s0f1/device/sriov_numvfs
- Check whether the adding operation is successful.
1cat /sys/class/net/enp1s0f1/device/sriov_numvfs
- 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.
- Configure MAC addresses of the VFs.
- 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
- Verify the configuration.
1ip link show dev enp1s0f1

Each MAC address must be unique on the local server, the peer server, and the switch.
- Check the PCI port numbers of the eight VFs.
1ls -l /sys/class/net/

- Run the following commands:
- Change the network port mode.
- 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

- 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

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

The device name of the VFs has been changed from enp1s0f$ to enp1s0f1_$.
- Unbind the VFs.
- 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
Parent topic: Configuring OVS Flow Table NIC Acceleration