如何开启Mellanox SmartNIC的VF

在x86 Host上开启VF(默认legacy模式,不会生成representor)

mst start 
echo 2 > /sys/class/infiniband/mlx5_0/device/mlx5_num_vfs #申请两个VF
echo 0000:01:00.3 > /sys/bus/pci/drivers/mlx5_core/unbind #给两个VF申请不同的mac地址
ip link set enp1s0f1np1 vf 0 mac 00:22:33:44:55:66
echo 0000:01:00.3 > /sys/bus/pci/drivers/mlx5_core/bind
echo 0000:01:00.4 > /sys/bus/pci/drivers/mlx5_core/unbind
ip link set enp1s0f1np1 vf 1 mac 00:22:33:44:55:67
echo 0000:01:00.4 > /sys/bus/pci/drivers/mlx5_core/bind

将VF接入OvS(For CX6)

mst start 
echo 2 > /sys/class/infiniband/mlx5_0/device/mlx5_num_vfs #申请两个VF
echo 0000:01:00.3 > /sys/bus/pci/drivers/mlx5_core/unbind
echo 0000:01:00.4 > /sys/bus/pci/drivers/mlx5_core/unbind
echo switchdev > /sys/class/net/ens3f0/compat/devlink/mode #ens3f0是VF对应的PF,这个命令会使VF生成representor
ip link set enp1s0f1np1 vf 0 mac 00:22:33:44:55:66
ip link set enp1s0f1np1 vf 1 mac 00:22:33:44:55:67
echo 0000:01:00.3 > /sys/bus/pci/drivers/mlx5_core/bind
echo 0000:01:00.4 > /sys/bus/pci/drivers/mlx5_core/bind
ovs-vsctl add-br test 
ovs-vsctl add-port test ens3f0_1 #将VF的representor绑定给网桥即可
ovs-vsctl add-port test ens3f0_2 #将VF的representor绑定给网桥即可
ovs-vsctl add-port test ens3f0  #将PF接入OvS,这样才能将VF流量送入Ethernet

流表卸载参考:OvS HW-offload参考文档

将VF接入OvS(For BlueField-2 DPU)

  • 与CX系列智能网卡区别就在,CX6的representor在Host上,DPU的representor在Arm子系统中;
  • vf0 在Arm中对应的rep是pf0vf0, vf1在Arm中对应的rep是pf0vf1;
  • 将pf0vf0绑定给OvS即可实现互联;
  • 流表卸载参考:DPU软件文档

常见命令:

  • 重启OvS: /etc/init.d/openvswitch-switch restart
  • 开启流表卸载: ovs-vsctl --no-wait set Open_vSwitch . other_config:hw-offload=true
  • 重启Mellanox网卡驱动:/etc/init.d/openibd restart (可以在不重启主机的情况下将大多数网卡功能重置)

注意,如若VF暂时无法passthrough给Server上的KVM,也不要轻易因此修改grub,可以尝试将VF透传给docker容器定制自己的开发环境(DPDK or RDMA)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值