背景
传统virtio 半虚拟化模型
SRIOV 模型,需要单独离管理
存在的问题:
1. 无论kernel状态下还是dpdk情况下,SRIOV 口没有通过bridge直接进行管理,而是直接嵌入了eswitch
2. 这种模式叫做 legacy 模式
3. 需要为sr-iov增加软件的 representation 模型
4. representation 模型需要无缝接入ovs, tc,可以通过已有方式对硬件进行 traffic rules 下发
VF 的 representor口控制路径
VF representor口数据路径
-
VF representor 基本概念
每个net-device或者eth_dev都 represents 了 eswitch上的一个vport,包括了vf口和uplink口,数据报文可以通过host上的VF representor口上送到host中并到达vm(慢速路径), vm中发送的报文,通过VF representor口发送到host上。
representor net-device 挂接到现有的switch结构上(Bridge, TC, OVS)并且通过现有接口,就可以控制VF的数据流量,可以通过管理VF representor的链接状态管理VF的链接状态,可以通过VF representor查看VF的统计(新的NL接口)
VF representor 实现
在kernel中是一个net-device
每个vendor都有自己的实现方式
所有VF representor都在 e-switch management port 上运行,使用硬件队列queue pair,有rule 进行pair设定
应为典型的内核软件数据路径需求
收发报文
miss-rule -- 允许从SW进行rule学习
send-to-vports rules -- 当 re-injecting 报文可以bypass硬件路径
mlx5中 VF representors 实现了mlx5已太设备的功能子集
PF 作为 uplink representor
e-switch mode 管理
所有VF representor都在 e-switch management port 上运行,使用硬件队列queue pair,有rule 进行pair设定
e-switch 是通过vendor的PCI driver进行管控的
管理员使用devlink工具来管控设定e-switch mode
增加了一种switchdev模式
devlink dev eswitch set pci/0000:21:00.1 mode switchdev
与ASIC交换芯片采用的方法基本相同
软件 net-device 是switch芯片上port的 representation,并且可以进行offload
VF representors 实现了 switchdev ops,并且实现了parent ID属性
未来会支持更多的属性,更多的对象(fdb, fib)会被 SRIOV VF reps 的 switchdev 支持并且接入到swithdev的卸载模型中
PF 不是 eSWitch的管理端口,支持多个PFs、具有多个uplink的e-switch、专用非PF e-switch管理(功能)端口
在switch上建立非卸载慢速sriov
生成多个sriov VF
分配Vf给vm
设定SRIOV模式为switchdev,VF rep就会被创建
把 VF representors 加入host的软件交换机(Bridge, OVS, TC)中
但是 vf rep 的性能比SRIOV差很多
通过卸载软件switch的datapath来提高性能
通过 VF rep 卸载 TC 的datapath到e-switch
开启SRIOV,分配vf给vm,切换为switchdev模式
通过TC工具设定ingress rule到VF rep,进而设置到e-switch HW
典型rule格式:<ingress port, matching, action>
# ethtool -K enp4s0f1_0 hw-tc-offload on
# tc qdisc add dev enp4s0f1_0 ingress
# tc filter add dev enp4s0f1_0 protocol ip parent ffff: flower skip_sw src_mac e4:11:22:33:44:50 dst_mac e4:1d:2d:a5:f3:9d action mirred egress redirect dev enp4s0f1
可以匹配 l2/l3/l4 头
动作:push/pop vlan, forward (mirred redirect), drop
offload 流统计(packets, bytes, last-use),并允许老化
卸载 IP tunneling 到 eswitch
TC 支持新的 matching 和 actions 来在共享tunnel设备上卸载IP tunneling(VXLAN,GRE)
flower matching 外层豹纹头:src/dst IP 和 tunnel key
tunnel key set (encap) 动作, tunnel key release (decap) 动作
这里的卸载不太直接,涉及路由查找以确定HW net-device、neigh查找等
更多switchdev SRIOV网络功能模块
multiple uplinks (hair-pin)
卸载 SW gateways
LAG
SRIOV guest 网络的HW LAG
卸载基于路由的 flow
支持基于 L3 的 SRIOV guest 网络
legacy mode 下使能更快速的转发
FDB 卸载
结论
switchdev模式提供了SRIOV的性能和半虚拟化的灵活可配置性
为ovs卸载提供了基础,包括隧道报文的卸载。