Implement data-driven YAML switch/port/vlan configuration #1

Merged
DataHoarder merged 1 commit from yaml-configuration into master 2021-11-12 23:24:40 +00:00
Owner

These changes allow fully featured switch configuration, their ports, and vlan mapping.

Several items are left to implement, plus routing and NAT features. CPU packet trapping is still not defined.

Here's an example of the configuration file

platform:
  # Device to match configuration against. Program will exit if model does not match
  device: "FM10840_B0"
  # Device VPD hash to match against. Use this when multiple FM10K with different serial numbers exist on system.
  #device_vpd_hash: "d3effea257d1348331a212d60d0b96ec1225c69a93c7e9fa1689b7f445c7d489"
  #device_vpd_hash: "f67978856fa13d7e2ce4f0af8971bfbe633447f91ca5791ec5add3c6860fc70d"
  configuration:
    # A preset to use, if any
    preset: "FM10840_B0_2x100G"
    #preset: "FM10840_B0_8x25G"

    # Extra configuration entries (or whole file) follow here in order
    entries:
      #- ["api.platform.config.debug", "text", "CONFIG,MOD_STATE,MOD_LED,MOD_INTR,MOD_TYPE,PLAT_LOG"]
      #- ["api.platform.lib.config.debug", "text", "I2C_RW,I2C_MUX,PORT_LED"]

      #- ["api.platform.config.switch.0.portIndex.1.ethernetMode", "text", "40GBase-SR4"]
      #- ["api.platform.config.switch.0.portIndex.2.ethernetMode", "text", "40GBase-SR4"]

      # Override 100G ports to 10G
      #- ["api.platform.config.switch.0.portIndex.1.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.2.ethernetMode", "text", "10GBase-SR"]
      # Override 25G ports to 10G
      #- ["api.platform.config.switch.0.portIndex.1.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.2.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.3.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.4.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.5.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.6.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.7.ethernetMode", "text", "10GBase-SR"]
      #- ["api.platform.config.switch.0.portIndex.8.ethernetMode", "text", "10GBase-SR"]

switch:
  attributes:
    # shared (default), per_vlan, multiple (not supported?)
    stp_mode: shared
    # lag_mode:
    vlan_learning:
      # VLAN learning mode. Values: independent (default), shared
      mode: independent
      # The VLAN to learn on when mode is shared (default 1)
      vlan: 1
    trap:
      # The 48-bit CPU MAC address (default: 0x000000000000).
      # Frames received by the switch with this destination MAC address will
      # be automatically trapped to the CPU.
      cpu_mac: 0x000000000000
      # TODO: IEEE_8021X, BPDU, LACP, GARP, IGMPV3, OTHER, MTU_VIOLATIONS


    # Broadcast flooding control. Values: forward, discard, forward_without_cpu (default), per_port
    broadcast_flooding: forward

    # Flood all multicast frames for which the multicast address is unknown on lookup to all ports including the CPU.
    # Note that the CPU will only receive unknown multicast frames on VLANs for which the CPU port is a member.
    # Multicast flooding control. Values: forward, discard, forward_without_cpu (default), per_port
    multicast_flooding: forward

    # Flood all unicast frames for which the destination address is unknown on lookup.
    # Note that the CPU will only receive unknown unicast frames on VLANs for which the CPU port is a member.
    # Unicast flooding control. Values: forward, discard, forward_without_cpu (default), per_port
    unicast_flooding: forward

# Must create vlans so they exist
vlans:
  -
    id: 1
    attributes:
      # If enabled, then a frame may be sent out the VLAN it came in on.
      # On FM10000 devices, disabling reflection on a VLAN disables switching
      # frames on this VLAN between Virtual Functions on the same PCIe port.
      reflect: true

      # A VLAN must have this attribute enabled in order for traffic ingressing on the VLAN to be routed.
      # When this attribute is disabled, ingressing traffic will only be switched at layer 2.
      # Default false
      routable: false

# Definitions here share keys. First default, eth, pcie, special, cpu entries are applied, then specific port numbers
ports:
  -
    # Default port definitions, except internal
    port: default
    attributes:
      tagging:
        # Selects the port tagging mode for this port. Values (see fm_portTaggingMode struct): 8021q (default), 8021ad_customer, 8021ad_provider, pseudo1, pseudo2
        mode: 8021q
        # The port's default VLAN. Tagging rules still apply from VLAN definition. The default value is 1.
        vid: 1
        # The port's default priority (0 - 7). The default value is 0.
        priority: 0

        # The port's default second VLAN. The default value is 1.
        #vid2: 1
        # The port's default second priority (0 - 7). The default value is 0.
        #priority2: 0

        # Whether the ingress VLAN-tagged frame's VLAN fields should be replaced with the port's default VLAN fields,
        # as specified by the ''tagging.vid'', ''tagging.priority'', and ''tagging.cfi'' attributes. Default false
        #
        # Note that this attribute does not affect the selection of the internal switch priority of the frame (in the case of SWPRI being chosen from VLAN priority),
        # as SWPRI is chosen before the port's default VLAN values are applied. See ''FM_PORT_SWPRI_SOURCE'' and ''FM_PORT_SWPRI_DSCP_PREF'' for details on the selection of SWPRI.
        replace: false

        # The port's default CFI (0 - 1).  The default value is 0.
        # Also known as Drop eligible indicator (DEI). May be used separately or in conjunction with PCP to indicate frames eligible to be dropped in the presence of congestion.
        cfi: 0
        # The port's default DSCP (0 - 63). Default value is 0.
        dscp: 0
        # Defines the type of ISL tag (if any) present on frames ingressing on this port. Default on PCIe F56, others is NONE
        # Values: none, f32, f56, f64, f96, other_32, other_64, other_96
        #isl_format:
      # The port's default internal switch priority (0 - 15). Default value is 0.
      switch_priority: 0

      drop:
        # Dropping frames that incur an ingress VLAN boundary violation. Default false
        boundary_violation: false

        # Dropping of untagged frames on ingress. Default false. See notes for FM_PORT_DROP_UNTAGGED
        untagged: false

        # Dropping of tagged frames on ingress. Default false. See notes for FM_PORT_DROP_TAGGED
        tagged: false

      loopback:
        # Internal loopback control. Frames emitted from the switch fabric towards an egress port are processed all the way
        # through the Ethernet port logic, then looped back from transmit to receive at the SerDes level, complete with preamble and IFG.
        # Can only be set on eth ports. Values: off (default), tx2rx, rx2tx
        mode: off

        # Whether frames emitted out of the switch fabric toward an egress port are instead looped back into the fabric.
        # Since such frames do not touch the Ethernet port logic of the chip, they will not have a preamble, nor do they invoke an IFG.
        # The associated port logic will be put in a standby mode so that any frames received at the port will not enter the switch fabric.
        # Values: off (default), tx2rx, rx2tx
        fabric: off
        # Indicates whether loopback suppression is enabled or disabled for a port.
        # Value is either true (default) or false (default for TE ports).
        # Note that this attribute has no effect when a port is a member of a link aggregation group.
        #suppression: true



      parser:
        # How far in OSI model packets are parsed before stopping.
        # l2 (default)
        # l3 - Set to this value to enable any L3 features, such as IGMP snooping, routing, IGMP storm control and L3 ACLs.
        # l4 - Set FM_PORT_PARSER to this value to enable L4 ACLs (default for TE ports), in addition to L3 features.
        # all
        mode: l2
        #  When two VLAN tags are present and identical in a packet, then this attribute defines which one is considered as first.
        # Setting to false (default) makes VLAN1 first, VLAN2 second.
        #first_vlan2: false
        # Whether VID2 (VLAN ID in the second VLAN tag) is sent before VID1 (VLAN ID in the first VLAN tag) or after VID1.
        # Setting to true sends the VID2 first, then VID1 second.
        # Setting to false (default) sends the VID1 first, VID2 second.
        #first_vid2: false

      # A port must have this attribute enabled in order for traffic ingressing on the port to be routed.
      # When this attribute is disabled, ingressing traffic will only be switched at layer 2.
      routable: false

      # Egress updating of fields
      update:
        # Defines whether the port should decrement the TTL field on outgoing routed frames. Default true
        #ttl: true

        # Defines whether the port may modify the DSCP field on outgoing routed frames. Default true
        #dscp: true

        # Defines whether the port should modify the VLAN priority field on egress. Default false
        #vlan_priority: false

        # Defines whether the port should modify the VLAN2 priority field on egress. Default false
        #vlan2_priority: false

        # A bit mask indicating the fields that will be updated on a routed frame.
        # The mask consists of the OR of any of the following fields: DMAC, SMAC, VLAN
        # Default is [DMAC, SMAC, VLAN]
        routed: [DMAC, SMAC, VLAN]



      broadcast:
        # Whether a port is to prune flooded broadcast frames
        #pruning: false
        # Flooding control for per_port switch value. Values: forward_without_cpu, trap, forward, discard
        #flooding: forward_without_cpu

      multicast:
        # Whether a port is to prune flooded broadcast frames
        #pruning: false
        # Flooding control for per_port switch value. Values: forward_without_cpu, trap, forward, discard
        #flooding: forward_without_cpu

      unicast:
        # Whether a port is to prune flooded broadcast frames
        #pruning: false
        # Flooding control for per_port switch value. Values: forward_without_cpu, trap, forward, discard
        #flooding: forward_without_cpu

      # Indicates whether the port is an internal port in a multi-switch environment (port connects the switch to another switch).
      # Value is either FM_ENABLED or FM_DISABLED (default).
      # On FM10000, this attribute is always FM_DISABLED for PCIe ports and FM_ENABLED for TE ports.
      #internal: false

    vlans:
      -
        id: 1
        # Tag egressing frames or not
        tag: false
        # Values: disabled, listening, learning, forwarding, blocking
        stp: forwarding

  -
    # Default PCIe port definitions
    port: pcie
    attributes:
  -
    # Default port definitions
    port: [special, eth, cpu]
    attributes:
      # Learning of source addresses on this port: true (default) or false (default for PEP and TE ports).
      # Note: This attribute must be enabled for the address table security features to apply to frames received on the port.
      learning: true

  -
    # Default epl/ETH port definitions
    port: eth
    attributes:
      # Maximum frame size in bytes, ranging from 0 to 15360 for FM10000
      # For FM10000, default value for an Ethernet port is 1536 and PCIE port is 15360.
      # Note that a specified value will be rounded up to the nearest multiple of 4.
      #
      # In FM10000, frame size is computed from DMAC till the end of FCS.
      # Hence the maximum frame size is actually MTU plus size of L2 header and FCS.
      # E.g., if the non-vlan tagged netdev interface (of PCIE) on the host has MTU 15342,
      # then the corresponding Max Frame Size is 15342 + 14 (L2 header) + 4 (FCS) = 15360.
      max_frame_size: 9036

  -
    # CPU port definitions
    port: cpu
    attributes:

  -
    # Port 1 definitions. As defined on platform configuration. This should be one of the QSFP (#1?) ports
    port: 1
    attributes:

      link:
        # mode: TODO, values and autoneg here
        # optimization: # TODO, none, speed, quality, balance
      # The N-bit egress port mask to use when this port is the ingress port.
      # A one bit in the mask indicates that frames from this port can be forwarded to the port represented by the bit.
      # Each bit position corresponds to the logical port number of the egress port.
      # To allow, for example, ports 0, 1, 2, 3 to communicate here, use either raw mask value (0xf) or list form [0, 1, 2, 3]. -1 to allow all known but self
      #mask: -1


These changes allow fully featured switch configuration, their ports, and vlan mapping. Several items are left to implement, plus routing and NAT features. CPU packet trapping is still not defined. Here's an example of the configuration file ```yml platform: # Device to match configuration against. Program will exit if model does not match device: "FM10840_B0" # Device VPD hash to match against. Use this when multiple FM10K with different serial numbers exist on system. #device_vpd_hash: "d3effea257d1348331a212d60d0b96ec1225c69a93c7e9fa1689b7f445c7d489" #device_vpd_hash: "f67978856fa13d7e2ce4f0af8971bfbe633447f91ca5791ec5add3c6860fc70d" configuration: # A preset to use, if any preset: "FM10840_B0_2x100G" #preset: "FM10840_B0_8x25G" # Extra configuration entries (or whole file) follow here in order entries: #- ["api.platform.config.debug", "text", "CONFIG,MOD_STATE,MOD_LED,MOD_INTR,MOD_TYPE,PLAT_LOG"] #- ["api.platform.lib.config.debug", "text", "I2C_RW,I2C_MUX,PORT_LED"] #- ["api.platform.config.switch.0.portIndex.1.ethernetMode", "text", "40GBase-SR4"] #- ["api.platform.config.switch.0.portIndex.2.ethernetMode", "text", "40GBase-SR4"] # Override 100G ports to 10G #- ["api.platform.config.switch.0.portIndex.1.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.2.ethernetMode", "text", "10GBase-SR"] # Override 25G ports to 10G #- ["api.platform.config.switch.0.portIndex.1.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.2.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.3.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.4.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.5.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.6.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.7.ethernetMode", "text", "10GBase-SR"] #- ["api.platform.config.switch.0.portIndex.8.ethernetMode", "text", "10GBase-SR"] switch: attributes: # shared (default), per_vlan, multiple (not supported?) stp_mode: shared # lag_mode: vlan_learning: # VLAN learning mode. Values: independent (default), shared mode: independent # The VLAN to learn on when mode is shared (default 1) vlan: 1 trap: # The 48-bit CPU MAC address (default: 0x000000000000). # Frames received by the switch with this destination MAC address will # be automatically trapped to the CPU. cpu_mac: 0x000000000000 # TODO: IEEE_8021X, BPDU, LACP, GARP, IGMPV3, OTHER, MTU_VIOLATIONS # Broadcast flooding control. Values: forward, discard, forward_without_cpu (default), per_port broadcast_flooding: forward # Flood all multicast frames for which the multicast address is unknown on lookup to all ports including the CPU. # Note that the CPU will only receive unknown multicast frames on VLANs for which the CPU port is a member. # Multicast flooding control. Values: forward, discard, forward_without_cpu (default), per_port multicast_flooding: forward # Flood all unicast frames for which the destination address is unknown on lookup. # Note that the CPU will only receive unknown unicast frames on VLANs for which the CPU port is a member. # Unicast flooding control. Values: forward, discard, forward_without_cpu (default), per_port unicast_flooding: forward # Must create vlans so they exist vlans: - id: 1 attributes: # If enabled, then a frame may be sent out the VLAN it came in on. # On FM10000 devices, disabling reflection on a VLAN disables switching # frames on this VLAN between Virtual Functions on the same PCIe port. reflect: true # A VLAN must have this attribute enabled in order for traffic ingressing on the VLAN to be routed. # When this attribute is disabled, ingressing traffic will only be switched at layer 2. # Default false routable: false # Definitions here share keys. First default, eth, pcie, special, cpu entries are applied, then specific port numbers ports: - # Default port definitions, except internal port: default attributes: tagging: # Selects the port tagging mode for this port. Values (see fm_portTaggingMode struct): 8021q (default), 8021ad_customer, 8021ad_provider, pseudo1, pseudo2 mode: 8021q # The port's default VLAN. Tagging rules still apply from VLAN definition. The default value is 1. vid: 1 # The port's default priority (0 - 7). The default value is 0. priority: 0 # The port's default second VLAN. The default value is 1. #vid2: 1 # The port's default second priority (0 - 7). The default value is 0. #priority2: 0 # Whether the ingress VLAN-tagged frame's VLAN fields should be replaced with the port's default VLAN fields, # as specified by the ''tagging.vid'', ''tagging.priority'', and ''tagging.cfi'' attributes. Default false # # Note that this attribute does not affect the selection of the internal switch priority of the frame (in the case of SWPRI being chosen from VLAN priority), # as SWPRI is chosen before the port's default VLAN values are applied. See ''FM_PORT_SWPRI_SOURCE'' and ''FM_PORT_SWPRI_DSCP_PREF'' for details on the selection of SWPRI. replace: false # The port's default CFI (0 - 1). The default value is 0. # Also known as Drop eligible indicator (DEI). May be used separately or in conjunction with PCP to indicate frames eligible to be dropped in the presence of congestion. cfi: 0 # The port's default DSCP (0 - 63). Default value is 0. dscp: 0 # Defines the type of ISL tag (if any) present on frames ingressing on this port. Default on PCIe F56, others is NONE # Values: none, f32, f56, f64, f96, other_32, other_64, other_96 #isl_format: # The port's default internal switch priority (0 - 15). Default value is 0. switch_priority: 0 drop: # Dropping frames that incur an ingress VLAN boundary violation. Default false boundary_violation: false # Dropping of untagged frames on ingress. Default false. See notes for FM_PORT_DROP_UNTAGGED untagged: false # Dropping of tagged frames on ingress. Default false. See notes for FM_PORT_DROP_TAGGED tagged: false loopback: # Internal loopback control. Frames emitted from the switch fabric towards an egress port are processed all the way # through the Ethernet port logic, then looped back from transmit to receive at the SerDes level, complete with preamble and IFG. # Can only be set on eth ports. Values: off (default), tx2rx, rx2tx mode: off # Whether frames emitted out of the switch fabric toward an egress port are instead looped back into the fabric. # Since such frames do not touch the Ethernet port logic of the chip, they will not have a preamble, nor do they invoke an IFG. # The associated port logic will be put in a standby mode so that any frames received at the port will not enter the switch fabric. # Values: off (default), tx2rx, rx2tx fabric: off # Indicates whether loopback suppression is enabled or disabled for a port. # Value is either true (default) or false (default for TE ports). # Note that this attribute has no effect when a port is a member of a link aggregation group. #suppression: true parser: # How far in OSI model packets are parsed before stopping. # l2 (default) # l3 - Set to this value to enable any L3 features, such as IGMP snooping, routing, IGMP storm control and L3 ACLs. # l4 - Set FM_PORT_PARSER to this value to enable L4 ACLs (default for TE ports), in addition to L3 features. # all mode: l2 # When two VLAN tags are present and identical in a packet, then this attribute defines which one is considered as first. # Setting to false (default) makes VLAN1 first, VLAN2 second. #first_vlan2: false # Whether VID2 (VLAN ID in the second VLAN tag) is sent before VID1 (VLAN ID in the first VLAN tag) or after VID1. # Setting to true sends the VID2 first, then VID1 second. # Setting to false (default) sends the VID1 first, VID2 second. #first_vid2: false # A port must have this attribute enabled in order for traffic ingressing on the port to be routed. # When this attribute is disabled, ingressing traffic will only be switched at layer 2. routable: false # Egress updating of fields update: # Defines whether the port should decrement the TTL field on outgoing routed frames. Default true #ttl: true # Defines whether the port may modify the DSCP field on outgoing routed frames. Default true #dscp: true # Defines whether the port should modify the VLAN priority field on egress. Default false #vlan_priority: false # Defines whether the port should modify the VLAN2 priority field on egress. Default false #vlan2_priority: false # A bit mask indicating the fields that will be updated on a routed frame. # The mask consists of the OR of any of the following fields: DMAC, SMAC, VLAN # Default is [DMAC, SMAC, VLAN] routed: [DMAC, SMAC, VLAN] broadcast: # Whether a port is to prune flooded broadcast frames #pruning: false # Flooding control for per_port switch value. Values: forward_without_cpu, trap, forward, discard #flooding: forward_without_cpu multicast: # Whether a port is to prune flooded broadcast frames #pruning: false # Flooding control for per_port switch value. Values: forward_without_cpu, trap, forward, discard #flooding: forward_without_cpu unicast: # Whether a port is to prune flooded broadcast frames #pruning: false # Flooding control for per_port switch value. Values: forward_without_cpu, trap, forward, discard #flooding: forward_without_cpu # Indicates whether the port is an internal port in a multi-switch environment (port connects the switch to another switch). # Value is either FM_ENABLED or FM_DISABLED (default). # On FM10000, this attribute is always FM_DISABLED for PCIe ports and FM_ENABLED for TE ports. #internal: false vlans: - id: 1 # Tag egressing frames or not tag: false # Values: disabled, listening, learning, forwarding, blocking stp: forwarding - # Default PCIe port definitions port: pcie attributes: - # Default port definitions port: [special, eth, cpu] attributes: # Learning of source addresses on this port: true (default) or false (default for PEP and TE ports). # Note: This attribute must be enabled for the address table security features to apply to frames received on the port. learning: true - # Default epl/ETH port definitions port: eth attributes: # Maximum frame size in bytes, ranging from 0 to 15360 for FM10000 # For FM10000, default value for an Ethernet port is 1536 and PCIE port is 15360. # Note that a specified value will be rounded up to the nearest multiple of 4. # # In FM10000, frame size is computed from DMAC till the end of FCS. # Hence the maximum frame size is actually MTU plus size of L2 header and FCS. # E.g., if the non-vlan tagged netdev interface (of PCIE) on the host has MTU 15342, # then the corresponding Max Frame Size is 15342 + 14 (L2 header) + 4 (FCS) = 15360. max_frame_size: 9036 - # CPU port definitions port: cpu attributes: - # Port 1 definitions. As defined on platform configuration. This should be one of the QSFP (#1?) ports port: 1 attributes: link: # mode: TODO, values and autoneg here # optimization: # TODO, none, speed, quality, balance # The N-bit egress port mask to use when this port is the ingress port. # A one bit in the mask indicates that frames from this port can be forwarded to the port represented by the bit. # Each bit position corresponds to the logical port number of the egress port. # To allow, for example, ports 0, 1, 2, 3 to communicate here, use either raw mask value (0xf) or list form [0, 1, 2, 3]. -1 to allow all known but self #mask: -1 ```
DataHoarder force-pushed yaml-configuration from b42a86315a to 4486bf4fbe 2021-11-12 17:55:46 +00:00 Compare
DataHoarder force-pushed yaml-configuration from 55a23e1110 to c5f0285af4 2021-11-12 22:34:45 +00:00 Compare
DataHoarder force-pushed yaml-configuration from c5f0285af4 to f5b41b9e88 2021-11-12 22:48:48 +00:00 Compare
DataHoarder force-pushed yaml-configuration from f5b41b9e88 to d5ca00c7b5 2021-11-12 22:50:14 +00:00 Compare
DataHoarder force-pushed yaml-configuration from d5ca00c7b5 to 704df5b09d 2021-11-12 23:18:18 +00:00 Compare
DataHoarder merged commit 704df5b09d into master 2021-11-12 23:24:40 +00:00
DataHoarder deleted branch yaml-configuration 2021-11-12 23:24:40 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: FM10K/fsm#1
No description provided.