VLAN是用来划分广播域,BCM56440支持4094个VLAN(博通后续芯片都是支持4096个VLAN),同时支持IEEE 802.1Q tagged, MAC-based, IP subnet-based, protocol-based, port-based, and flow-based VLANs。
Tagging Status Decision
每个VLAN支持一组成员端口,由VLAN表管理,每个端口可以在多个VLAN广播域。
VLAN表是一个以VLAN ID为索引的表,每个一个表项描述了VLAN广播域的属性,其中PORT_BITMAP字段是成员端口的位映射表。
BCM.0> dump chg vlan 100 1 VLAN.ipipe0[100]: <VLAN_PROFILE_PTR=1,VALID_0=1,VALID=1,STG=1,PORT_BITMAP_W1=0x1f8,PORT_BITMAP_W0=0x1e0001ff,PORT_BITMAP=0x0000000000000000000000000000000001f81e0001ff,>
BCM.0> pbmp 0x1e0001ff
0x000000000000000000000000000000000000000000000000000000001e0001ff ==> cpu,ge0-ge10,xe
BCM56440支持4个全局外层TPID,由ING_OUTER_TPID_0/1/2/3四个寄存器配置,每个端口的PORT.OUTER_TPID_ENABLE字段包含4个bit位,表示端口支持哪些外层TPID。全局内层TPID通过VLAN_CTRL.INNER_TPID字段配置,对所有端口默认生效。
BCM.0> getreg ING_OUTER_TPID_0 ING_OUTER_TPID_0.ipipe0[1][0xa001700]=0x8100: <TPID=0x8100> BCM.0> getreg ING_OUTER_TPID_1 ING_OUTER_TPID_1.ipipe0[1][0xa001800]=0x9100: <TPID=0x9100> BCM.0> getreg ING_OUTER_TPID_2 ING_OUTER_TPID_2.ipipe0[1][0xa001900]=0x88a8: <TPID=0x88a8> BCM.0> getreg ING_OUTER_TPID_3 ING_OUTER_TPID_3.ipipe0[1][0xa001a00]=0: <TPID=0> BCM.0> getreg VLAN_CTRL VLAN_CTRL.ipipe0[1][0x6000200]=0x10200000: <USE_LEARN_VID=0,LEARN_VID=0, INNER_TPID=0x8100> BCM.0> dump chg PORT 1 1 PORT.ipipe0[1]: <VT_PORT_TYPE_SELECT_2=1,VT_PORT_TYPE_SELECT=1,VT_KEY_TYPE_2=4,VT_KEY_TYPE=0xf,VT_ENABLE=1,VLAN_PROTOCOL_DATA_INDEX=1,VFP_ENABLE=1,V6L3_ENABLE=1,V4L3_ENABLE=1,TRUST_INCOMING_VID=1,SUBNET_BASED_VID_ENABLE=1,STORM_CONTROL_PTR=1,PRI_MAPPING=0xfac688,PORT_VID=0xff8,OVID=0xff8,OUTER_TPID_ENABLE=5,OAM_ENABLE=1,MPLS_ENABLE=1,MIM_TERM_ENABLE=1,MAC_BASED_VID_ENABLE=1,IPRI_MAPPING=0xfac688,INNER_TPID_ENABLE=1,ICFI_1_MAPPING=1,FP_PORT_FIELD_SEL_INDEX=1,FILTER_ENABLE=1,DATA_3=0x08000000000000080000000000,DATA_2=0x00001f58d108040000000000000000,DATA_1=0x160000002000000000040df58d1111,DATA_0=0x00114f000a800080000007fc618000,CML_FLAGS_NEW=8,CML_FLAGS_MOVE=8,CLASS_BASED_SM_ENABLE=1,CFI_1_MAPPING=1,>
对于入端口报文,按照以下策略判断报文类型:
1)Double Tagged(DT) 第12,13字节匹配任意外层TPID,第16,17字节匹配全局内层TPID;
2)Single Outer-tagged(SOT) 第12,13字节匹配任意外层TPID,第16,17字节不匹配全局内层TPID;
3)Single Inner-tagged(SIT) 第12,13字节不匹配任意外层TPID,但是匹配全局内层TPID;
4)Untagged 第12,13字节不匹配任意外层TPID且不匹配全局内层TPID。
BCM SDK API接口:
bcm_port_tpid_set() bcm_port_tpid_get()
bcm_port_tpid_add() bcm_port_tpid_delete()
bcm_port_inner_tpid_set() bcm_port_inner_tpid_get()
Ingress Filtering是BCM56440芯片的一个特性,如果使能PORT.EN_IFILTER位,会丢弃除端口所在VLAN域以外的其他VLAN tagged的报文。
VLAN Assignment
MAC地址学习和转发的VLAN通过以下配置指定:
1) Packet's tags 入端口报文携带的VLAN标签
2) VFP classifying flow based on L2/L3/L4 fields
3) VLAN translation
4) VLAN_SUBNET table
5) VLAN_PROTOCOL table
6) Default port based outer VLAN 端口默认外层VLAN
Ingress方向,报文首先匹配VFP表项,VFP表项通常用来实现灵活QinQ域,因为VFP表项在执行VLAN编辑的动作之前,可以检查报文的其他字段,如以太网类型、IP协议类型、L4端口号、目的MAC、源MAC等。VFP表项自带action,配置到VFP_POLICY_TABLE表。
如果报文没有命中VFP表项,而PORT.VT_ENABLE使能,则进一步匹配VLAN_XLATE表项。VLAN_XLATE表为Hash索引,索引的KEY值由PORT.VT_KEY_TYPE和PORT.VT_KEY_TYPE_USE_GLP决定。如果找到匹配的VLAN_XLATE表项,则从VLAN_XLATE表项中获取VLAN ID,VLAN_XLATE.TAG_ACTION_PROFILE_PTR指向ING_VLAN_TAG_ACTION_PROFILE,从中获取action,共同实现VLAN编辑。
如果PORT.VT_ENABLE使能,但是报文未命中VLAN_XLATE表项。此时,如果PORT.VT_MISS_DROP使能,则丢弃报文,否则,进入下一步处理流程。
如果没有命中VLAN_XLATE表项且报文是SIT的,则检查PORT.USE_IVID_AS_OVID,如果为1,则在后续的处理过程中,将IVID当OVID使用。
接下来,由PORT.VLAN_PRECEDENCE位决定匹配subnet表(包括VLAN_SUBNET表和VLAN_SUBNET_DATA表)和MAC表(VLAN_MAC表)的先后顺序,如果为1,则先匹配subnet表,否则,先匹配MAC表。
如果subnet表和MAC表都未命中,则匹配protocol-based VLAN表(包括VLAN_PROTOCOL表和VLAN_PROTOCOL_DATA表)。
如果protocol-based VLAN表也没有命中,则使用PORT表中的默认VLAN ID。
需要注意的是,subnet/MAC/protocol/port-based表的action都是从ING_VLAN_TAG_ACTION_PROFILE获取。
查看VLAN_XLATE/EGR_VLAN_XLATE表项时,主要关注以下字段即可:
BCM.0> dump chg vlan_xlate PORT_NUM IVID OVID NEW_IVID NEW_OVID TAG_ACTION_PROFILE_PTR VLAN_XLATE.ipipe0[96]: <TAG_ACTION_PROFILE_PTR=1,PORT_NUM=1,OVID=5,NEW_OVID=0x12c,NEW_IVID=0x14a,IVID=0xe6,> VLAN_XLATE.ipipe0[320]: <TAG_ACTION_PROFILE_PTR=1,PORT_NUM=1,OVID=5,NEW_OVID=0x12c,NEW_IVID=0xec,IVID=0x88,> VLAN_XLATE.ipipe0[544]: <TAG_ACTION_PROFILE_PTR=1,PORT_NUM=1,OVID=5,NEW_OVID=0x12c,NEW_IVID=0x135,IVID=0xd1,> VLAN_XLATE.ipipe0[768]: <TAG_ACTION_PROFILE_PTR=1,PORT_NUM=1,OVID=5,NEW_OVID=0x12c,NEW_IVID=0x123,IVID=0xbf,>
VLAN Tag Action
在Ingress方向,经过Ingress VLAN tag actions,交换机内部所有报文都会变成SOT或者DT报文。转换后的Outer VLAN ID用来进行L2/L3处理。outer VLAN ID,inner priority和packet priority可以被IFP规则更改。
在Egress方向,内外层VLAN ID可以被EGR_VLAN_XLATE和egress VLAN actions更改,因此,出口报文可以是untagged,SIT,SOT或者DT报文。每个egress端口可以配置端口级或者VLAN级的outer TPID,inner TPID则是系统级配置。内外层VLAN tag也可以被EFP规则更改。
当EGR_VLAN_CONTROL_1[egress_port].OUTER_TPID_SEL决定是从EGR_VLAN_CONTROL_1[egress_port].OUTER_TPID_INDEX还是EGR_VLAN[outer VLAN ID].OUTER_TPID_INDEX获取outer TPID索引,该索引为2bits,正向EGR_OUTER_TPID表。出口报文inner TPID由EGR_CONTROL.INNER_TPID决定。
BCM.0> getreg EGR_OUTER_TPID EGR_OUTER_TPID(0).epipe0[2][0xa000000]=0x8100: <TPID=0x8100> EGR_OUTER_TPID(1).epipe0[2][0xa000100]=0x9100: <TPID=0x9100> EGR_OUTER_TPID(2).epipe0[2][0xa000200]=0x88a8: <TPID=0x88a8> EGR_OUTER_TPID(3).epipe0[2][0xa000300]=0: <TPID=0>
VLAN Check
经过前面的处理流程之后,入端口报文被转成DT或者SOT报文,紧接着是VLAN check,即VLAN表和VAN_STG表检查,其目的是进行L2转发。
VLAN表提供了FID、L2_ENTRY_KEY_TYPE等转发信息。当SVL(Shared VLAN)特性使能时,FID被用来进行学习和转发。L2_ENTRY_KEY_TYPE配置的L2 Lookup的KEY值。
Shared VLAN
BCM56440支持IVL(Independent VLAN Learning)和SVL(Shared VLAN Learning)两种模式。IVL模式下,每个VLAN独自学习MAC生成转发表,VLAN之间不能共享转发表项。SVL模式可以通过ING_CONFIG_64寄存器配置(芯片级配置),当使能SVL模式时,通过VLAN表的FID字段(VLAN.FID_ID)将多个VLAN关联起来,所有的学习和转发都基于FID+MAC表项,而不是VID+MAC表项。组播转发如果要使用FID转发,可以通过ING_CONFIG_64.LOOKUP_L2MC_WITH_FID_ID配置。
BCM.0> getreg ING_CONFIG_64 SVL_ENABLE LOOKUP_L2MC_WITH_FID_ID ING_CONFIG_64.ipipe0[0x1180600]=0x1802080300a: <SVL_ENABLE=0,LOOKUP_L2MC_WITH_FID_ID=0>
关于FID,描述如下:
Addressing information that the device learns about a VLAN is stored in the filtering database assigned to that VLAN. Several VLANs can be assigned to the same FID to allow those VLANs to share addressing information. This enables the devices in the different VLANs to communicate with each other when the individual ports have been configured to allow communication to occur. The configuration is accomplished using the Local Management VLAN Forwarding Configuration screen. By default a VLAN is assigned to the FID that matches its VLAN ID.