Bypass网卡调研
选型
光润通的万兆Bypass网卡有x710和82599两种型号,下表是x710和82599网卡的对比:
EVB:将VEPA作为基本实现方案,将多通道技术(Multi-Channel Technology)作为扩展方案。要求将所有的虚拟机流量都引向外部的物理交换机,因此与虚拟机相关的流量监管、控制策略和管理可扩展性问题得以解决。
VEPA:传统虚拟环境下,同一物理节点的不同虚拟机之间流量发送由虚拟机直接处理了,并不会发出网口。在VEPA下,虚拟机内部之间的流量不再由本地虚拟交换机处理,而是被强制发往物理网卡外部,由网卡上联的VEPA交换机接收处理后再发送回来。
Promiscuous modes per VM:x710支持vlan、组播和单播混杂,而82599只支持组播混杂。
我们的使用场景要求网卡支持VEPA和基于vlan的混杂,所以选型定为光润通F1002EBP-V3.5 X710-BM2万兆单路双光口Bypass网卡。
光润通Bypass卡物理架构
F1002EBP双端口光纤万兆以太网旁路服务器适配器支持正常、旁路和断开模式。在正常(Normal)模式下,端口是独立的接口,而在在旁路(BYPASS)模式 下,从一个端口接收的所有数据包都将传输到相邻端口,在断开(Disconnect)模式下,适配器模拟开关/路径电缆断开。
上图是该网卡的实物图,在正常模式下,流量经过红框进入设备中,在旁路模式下,红框前的两个光纤头应该在物理上直连了,流量在红框之前就从另一个口转出,此时的网卡就如同一根光纤,在断开模式下,流量不会进入红框内,也不会从另一个口转出。
各模式逻辑架构
正常模式
此模式下,流量从端口进入设备,流量的转发由代码逻辑来决定。
旁路模式
此模式下,port 0的rx与port 1的tx连接,port 1的rx与port 0的tx相连,流量进入端口后直接从旁边端口转出。
断开模式
此模式下,网卡内部已经在物理层面断开连接,流量将不能通过网卡。
硬件实现原理
硬件层面上,要实现Bypass,主要使用的就是继电器。这些继电器连接两个Bypass网口的各个网口信号线,下图以其中一根信号线来说明继电器在其中的工作方式。当触发Bypass时,继电器内的开关将会跳到1的状态,Lan1和Lan2就导通了,当Bypass关闭后,开关就会导通到2上,这样LAN1和LAN2上的网络间通讯,就需要通过这台设备上的应用程序来实现了。
我们的应用场景
如果部署在物理机,设备异常(如出现重启、关机、死机、掉电、UPGW进程异常),将接入基站的端口和接入核心网的端口完成Bypass切换。
如果部署在虚拟机,设备异常(如出现物理机重启、物理机关机、物理机死机、物理机掉电、虚拟机重启、虚拟机关机、虚拟机死机、虚拟机掉电、UPGW进程程异常),需要将接入基站的端口流量透传到接入核心网的端口。
所以无论采用哪种方式去部署,我们最终都要做到监控UPGW状态去控制切换Bypass。
光润通网卡支持度概述
作为pf使用的支持场景
作为物理网卡使用时,可以部署在宿主机,也可以被虚拟机接管,安装驱动和命令配置方式都一样,因为支持控制物理网卡切换Bypass,所以这种方式喂狗可以在UPGW代码中实现,UPGW异常后,看门狗超时,切换Bypass。
作为vf使用的支持
作为vf使用时,可以部署在宿主机,也可以被虚拟机接管,因为不支持控制SRIOV切换Bypass,只能控制物理网卡切换Bypass,所以当vf在虚拟机时,需要在宿主机监控虚拟机中UPGW进程的状态,异常时控制物理网卡切换Bypass,当部署在宿主机时可在代码中直接添加喂狗代码。
对DPDK的支持
可以支持DPDK接口管控,管控后也可切换Bypass。
使用方法
安装驱动
解压厂家提供的驱动tar包(GRT_BYPASS_20210302.tar.gz)到指定目录下。
进入GRT_BYPASS/BP_Control目录下,先执行make再执行make install。
问题:执行make时报错如下:
解决方法:安装相关的内核软件包:
yum install kernel-devel-$(uname -r)
在GRT_BYPASS/BP_Control目录下输入bpctl_start(每次机器重启后都需要在此目录下输入),然后可输入其它命令来控制Bypass。
Bypass切换方式
通过电源触发,配置电源打开关闭时网卡的Bypass模式:
bpctl_util interface_name/pci_address/all set_bypass_pwoff on:设置电源关闭时的Bypass状态为on,可以指定对应Bypass网卡第一个端口的名字或者PCI地址来下发命令,也可以设定参数为all,让接管的所有Bypass网卡都切换为Bypass状态
bpctl_util interface_name/pci_address/all set_bypass_pwoff off:设置电源关闭时的Bypass状态为off
bpctl_util interface_name/pci_address/all set_bypass_pwup on:设置电源打开时的Bypass状态为on
bpctl_util interface_name/pci_address/all set_bypass_pwup off:设置电源打开时的Bypass状态为off
直接由命令行设置网卡的Bypass模式:
bpctl_util interface_name/pci_address/all set_bypass on:直接打开Bypass
bpctl_util interface_name/pci_address/all set_bypass off:直接关闭Bypass
设置看门狗定时器,设置喂狗:
bpctl_util interface_name/pci_address/all set_wd_exp_mode bypass:设置看门狗超时切换为Bypass状态
bpctl_util interface_name/pci_address/all set_bypass_wd timevalue:设置看门狗超时的时间
bpctl_util interface_name/pci_address/all set_wd_autoreset timevalue:设置自动喂狗模式,并设置喂狗时间
bpctl_util interface_name/pci_address/all reset_bypass_wd:自己主动去喂狗(若在代码中喂狗用此命令的接口)
命令总览
Usage: bpctl_util <if_scan|info|help> if_scan - refresh the list of network interfaces. info - print Program Information. help - print this message. bpctl_util <if_index|bus:slot.function|all> <command> [parameters] <if_index|bus:slot.function|all> - interface name, for example, eth0, bus:slot.function, for example 0b:00.0, or all for all Bypass-SD/TAP-SD Control devices <command> - bypass control command (see Commands List). Commands List: is_bypass - check if device is a Bypass/TAP controlling device get_bypass_slave - get the second port participate in the Bypass/TAP pair get_bypass_caps - obtain Bypass/TAP capabilities information get_wd_set_caps - obtain watchdog timer settings capabilities get_bypass_info - get bypass/TAP info set_bypass - set Bypass mode state get_bypass - get Bypass mode state get_bypass_change - get change of Bypass mode state from last status check set_dis_bypass - set Disable Bypass mode get_dis_bypass - get Disable Bypass mode state set_bypass_pwoff - set Bypass mode at power-off state get_bypass_pwoff - get Bypass mode at power-off state set_bypass_pwup - set Bypass mode at power-up state get_bypass_pwup - get Bypass mode at power-up state set_std_nic - set Standard NIC mode of operation get_std_nic - get Standard NIC mode settings set_bypass_wd - set watchdog state get_bypass_wd - get watchdog state get_wd_time_expire - get watchdog expired time get_wd_expire - get watchdog expired status reset_bypass_wd - reset watchdog timer set_tx - set transmit enable / disable get_tx - get transmitter state (enabled / disabled) set_tpl - set TPL enable / disable get_tpl - get TPL state (enabled / disabled) set_wait_at_pwup - set wait_at_pwup enable / disable get_wait_at_pwup - get wait_at_pwup (enabled / disabled) set_force_link_on - set force_link_on enable / disable get_force_link_on - get force_link_on (enabled / disabled) set_disc - set Disc mode state get_disc - get Disc mode state get_disc_change - get change of Disc mode state from last status check set_dis_disc - set Disable Disc mode get_dis_disc - get Disable Disc mode state set_disc_pwup - set Disc mode at power-up state get_disc_pwup - get Disc mode at power-up state set_wd_exp_mode - set adapter state when WDT expired get_wd_exp_mode - get adapter state when WDT expired set_wd_autoreset - set WDT autoreset mode get_wd_autoreset - get WDT autoreset mode set_bypass_pwoff_delay - set bypass delay time in power-off state get_bypass_pwoff_delay - get bypass delay time in power-off state set_bypass_pwup_delay - set bypass delay time in power-up state get_bypass_pwup_delay - get bypass delay time in power-up state [parameters] - set_bypass_wd command: WDT timeout interval, msec (0 for disabling WDT). set_bypass_pwup_delay/set_bypass_pwoff_delay commands: delay time interval, msec (0 for disabling delay). set_bypass/set_bypass_pwoff/set_bypass_pwup/set_dis_bypass commands: on/off for enable/disable Bypass set_std_nic command: on/off for enable/disable Standard NIC mode set_tx command: on/off for enable/disable transmit set_tpl command: on/off for enable/disable TPL set_wait_at_pwup command: on/off for enable/disable wait_at_pwup set_force_link_on command: on/off for enable/disable force_link_on set_disc/set_disc_pwup/set_dis_disc commands: on/off for enable/disable Disc set_wd_exp_mode command: bypass/tap/disc for bypass/tap/disc mode set_wd_autoreset command: WDT autoreset interval, msec (0 for disabling WDT autoreset). Example: bpctl_util eth0 set_bypass_wd 5000 bpctl_util eth0 set_bypass_pwup_delay 10000 bpctl_util all set_bypass on bpctl_util eth0 set_wd_exp_mode bypass bpctl_util 0b:00.0 set_bypass_pwup on