Skip to contentSkip to conversation

Documentation: networking: Clarify switchdev devices behavior

PATCH Superseded Florian Fainelli 5 participants 9 messages Dec 12, 2018 – Dec 22, 2018

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Documentation: networking: Clarify switchdev devices behavior

This patch provides details on the expected behavior of switchdev enabled network devices when operating in a "stand alone" mode, as well as when being bridge members. This clarifies a number of things that recently came up during a bug fixing session on the b53 DSA switch driver.

---
Hi all,

Please review carefully, and let me know if you think some of the behaviors described below do not make any sense. Thanks!

 Documentation/networking/switchdev.txt | 86 ++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
Documentation/networking/switchdev.txt +86 -0
index 82236a17b5e6..8c83174b477b 100644
@@ -392,3 +392,89 @@ switchdev_trans_item_dequeue()
 
 If a transaction is aborted during "prepare" phase, switchdev code will handle
 cleanup of the queued-up objects.
+
+Switchdev enabled network device expected behavior
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Below is a set of defined behavior that switchdev enabled network device must be
+adhering to.
+
+Configuration less state
+------------------------
+
+Upon driver bring up, the network devices must be fully operational, and the
+backing driver must be configuring the network device such that it is possible
+to send and receive to this network device such that it is properly separate
+from other network devices/ports (e.g: as is frequenty with a switch ASIC). How
+this is achieved is heavily hardware dependent, but a simple solution can be to
+use per-port VLAN identifiers.
+
+The network device must be capable of running a full IP protocol stack must be
+working, including multicast, DHCP, IPv4/6, etc. If necessary, it should be
+programming the appropriate filters for VLAN, multicast, unicast etc. The
+underlying device driver must effectively be configured in a similar fashion to
+what it would do when IGMP snooping is enabled for IP multicast over these
+switchdev network devices and unsollicited multicast must be filtered as early
+as possible into the hardware.
+
+When configuring VLANs on top of the network device, all VLANs must be working,
+irrespective of the state of other network devices (e.g: other ports being part
+of a VLAN aware bridge doing ingress VID checking). See below for details.
+
+Bridged network devices
+-----------------------
+
+When a switchdev enabled network device is added as a bridge member, it should
+not be disrupting any functionality of non-bridged network devices and they
+should continue to behave as normal network devices. Depending on the bridge
+configuration knobs below, the expected behavior is documented.
+
+VLAN filtering
+~~~~~~~~~~~~~~
+
+The Linux bridge allows the configuration of a VLAN filtering mode (compile and
+run time) which must be observed by the underlying switchdev network
+device/hardware:
+
+- with VLAN filtering turned off: frames ingressing the device with a VID that
+  is not programmed into the bridge/switch's VLAN table must be forwarded.
+
+- with VLAN filtering turned on: frames ingressing the device with a VID that is
+  not programmed into the bridges/switch's VLAN table must be dropped.
+
+Non-bridged network ports of the same switch fabric must not be disturbed in any
+way, shape or form by the enabling of VLAN filtering.
+
+VLAN devices configured on top of a switchdev network device (e.g: sw0p1.100)
+which is a bridge port member must also observe the following behavior:
+
+- with VLAN filtering turned off, these VLAN devices must be fully functional
+  since the hardware is allowed VID frames
+
+- with VLAN filtering turned on, these VLAN devices are not going to be
+  functional unless the bridge's VLAN database is also configured to have that
+  VID enabled for the underlying network device/port
+  (e.g: bridge vlan add vid 100 dev sw0p1)
+
+Because VLAN filtering can be turned on/off at runtime, the switchdev driver
+must be able to re-configure the underlying hardware on the fly to honor the
+toggling of that option and behave appropriately.
+
+IGMP snooping
+~~~~~~~~~~~~~
+
+The Linux bridge allows the configuration of IGMP snooping (compile and run
+time) which must be observed by the underlying switchdev network device/hardware
+in the following way:
+
+- when IGMP snooping is turned off, multicast traffic must be flooded to all
+  switch ports within the same broadcast domain, including the CPU/management
+  port of the switch (if handled separately).
+
+- when IGMP snooping is turned on, multicast traffic must be selectively flowing
+  to the appropriate network ports and not flood the entire switch, that must
+  include the CPU/management port.
+
+Because IGMP snooping can be turned on/off at runtime, the switchdev driver must
+be able to re-configure the underlying hardware on the fly to honor the toggling
+of that option and behave appropriately.
Signature · 1 line
2.17.1
#1 lore raw

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 443

Quoted 12 lines
Documentation/networking/switchdev.txt +12 -0
+VLAN filtering
+~~~~~~~~~~~~~~
+
+The Linux bridge allows the configuration of a VLAN filtering mode (compile and
+run time) which must be observed by the underlying switchdev network
+device/hardware:
+
+- with VLAN filtering turned off: frames ingressing the device with a VID that
+  is not programmed into the bridge/switch's VLAN table must be forwarded.
+
+- with VLAN filtering turned on: frames ingressing the device with a VID that is
+  not programmed into the bridges/switch's VLAN table must be dropped.

Hi Florian

i forget the details, but there are some difference between VLAN filtering being disabled at compile time, and disabled at runtime. I think the expected behaviour is the same, but the switchdev API usage is slightly different.

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 476

Quoted 3 lines

+- when IGMP snooping is turned on, multicast traffic must be selectively flowing

Documentation/networking/switchdev.txt +2 -0
+  to the appropriate network ports and not flood the entire switch, that must
+  include the CPU/management port.

224.0.0.X/32 should always be flooded, IGMP is optional for those groups in the local subnet.

Andrew

maintainer
#2 lore raw
In reply to Florian Fainelli

From: Florian Fainelli <[email protected]>
Date: Wed, 12 Dec 2018 15:09:43 -0800

Quoted 6 lines

This patch provides details on the expected behavior of switchdev enabled network devices when operating in a "stand alone" mode, as well as when being bridge members. This clarifies a number of things that recently came up during a bug fixing session on the b53 DSA switch driver.

Quoted 6 lines

---
Hi all,

Please review carefully, and let me know if you think some of the behaviors described below do not make any sense. Thanks!

Looks like Andrew had some feedback, so I'm expecting a new version of this.

#3 lore raw
In reply to Florian Fainelli
Quoted 60 lines · Florian Fainelli

This patch provides details on the expected behavior of switchdev enabled network devices when operating in a "stand alone" mode, as well as when being bridge members. This clarifies a number of things that recently came up during a bug fixing session on the b53 DSA switch driver.

---
Hi all,

Please review carefully, and let me know if you think some of the behaviors described below do not make any sense. Thanks!

 Documentation/networking/switchdev.txt | 86 ++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
Documentation/networking/switchdev.txt +36 -0
index 82236a17b5e6..8c83174b477b 100644
@@ -392,3 +392,89 @@ switchdev_trans_item_dequeue()
 
 If a transaction is aborted during "prepare" phase, switchdev code will handle
 cleanup of the queued-up objects.
+
+Switchdev enabled network device expected behavior
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Below is a set of defined behavior that switchdev enabled network device must be
+adhering to.
+
+Configuration less state
+------------------------
+
+Upon driver bring up, the network devices must be fully operational, and the
+backing driver must be configuring the network device such that it is possible
+to send and receive to this network device such that it is properly separate
+from other network devices/ports (e.g: as is frequenty with a switch ASIC). How
+this is achieved is heavily hardware dependent, but a simple solution can be to
+use per-port VLAN identifiers.
+
+The network device must be capable of running a full IP protocol stack must be
+working, including multicast, DHCP, IPv4/6, etc. If necessary, it should be
+programming the appropriate filters for VLAN, multicast, unicast etc. The
+underlying device driver must effectively be configured in a similar fashion to
+what it would do when IGMP snooping is enabled for IP multicast over these
+switchdev network devices and unsollicited multicast must be filtered as early
+as possible into the hardware.
+
+When configuring VLANs on top of the network device, all VLANs must be working,
+irrespective of the state of other network devices (e.g: other ports being part
+of a VLAN aware bridge doing ingress VID checking). See below for details.
+
+Bridged network devices
+-----------------------
+
+When a switchdev enabled network device is added as a bridge member, it should
+not be disrupting any functionality of non-bridged network devices and they
+should continue to behave as normal network devices. Depending on the bridge
+configuration knobs below, the expected behavior is documented.

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 440

Quoted 10 lines
Documentation/networking/switchdev.txt +10 -0
+
+VLAN filtering
+~~~~~~~~~~~~~~
+
+The Linux bridge allows the configuration of a VLAN filtering mode (compile and
+run time) which must be observed by the underlying switchdev network
+device/hardware:
+
+- with VLAN filtering turned off: frames ingressing the device with a VID that
+  is not programmed into the bridge/switch's VLAN table must be forwarded.

mlxsw doesn't support it. These bridges are mainly used with VLAN devices where the packets ingress the bridge untagged. When configured over physical ports, we only allow untagged packets into such a bridge.

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 443

Quoted 3 lines
Documentation/networking/switchdev.txt +3 -0
+
+- with VLAN filtering turned on: frames ingressing the device with a VID that is
+  not programmed into the bridges/switch's VLAN table must be dropped.

ack

Quoted 4 lines
Documentation/networking/switchdev.txt +4 -0
+
+Non-bridged network ports of the same switch fabric must not be disturbed in any
+way, shape or form by the enabling of VLAN filtering.
+

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 457

Quoted 10 lines
Documentation/networking/switchdev.txt +10 -0
+VLAN devices configured on top of a switchdev network device (e.g: sw0p1.100)
+which is a bridge port member must also observe the following behavior:
+
+- with VLAN filtering turned off, these VLAN devices must be fully functional
+  since the hardware is allowed VID frames
+
+- with VLAN filtering turned on, these VLAN devices are not going to be
+  functional unless the bridge's VLAN database is also configured to have that
+  VID enabled for the underlying network device/port
+  (e.g: bridge vlan add vid 100 dev sw0p1)

mlxsw forbids the enslavement of VLAN devices to VLAN-aware bridges. It doesn't really make sense to enable VLAN filtering when all the packets are untagged.

But I disagree with the comment about the underlying port. When you configured the VLAN device, it should have enabled the VLAN filters on the real device via ndo_vlan_rx_add_vid().

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 461

Quoted 4 lines
Documentation/networking/switchdev.txt +4 -0
+
+Because VLAN filtering can be turned on/off at runtime, the switchdev driver
+must be able to re-configure the underlying hardware on the fly to honor the
+toggling of that option and behave appropriately.

Please mention that switchdev drivers can refuse the operation.

#4 lore raw

Le 12/16/18 à 12:25 AM, Ido Schimmel a écrit :

Quoted 67 lines · Florian Fainelli
Quoted 66 lines

This patch provides details on the expected behavior of switchdev enabled network devices when operating in a "stand alone" mode, as well as when being bridge members. This clarifies a number of things that recently came up during a bug fixing session on the b53 DSA switch driver.

---
Hi all,

Please review carefully, and let me know if you think some of the behaviors described below do not make any sense. Thanks!

 Documentation/networking/switchdev.txt | 86 ++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
Documentation/networking/switchdev.txt +42 -0
index 82236a17b5e6..8c83174b477b 100644
@@ -392,3 +392,89 @@ switchdev_trans_item_dequeue()
 
 If a transaction is aborted during "prepare" phase, switchdev code will handle
 cleanup of the queued-up objects.
+
+Switchdev enabled network device expected behavior
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Below is a set of defined behavior that switchdev enabled network device must be
+adhering to.
+
+Configuration less state
+------------------------
+
+Upon driver bring up, the network devices must be fully operational, and the
+backing driver must be configuring the network device such that it is possible
+to send and receive to this network device such that it is properly separate
+from other network devices/ports (e.g: as is frequenty with a switch ASIC). How
+this is achieved is heavily hardware dependent, but a simple solution can be to
+use per-port VLAN identifiers.
+
+The network device must be capable of running a full IP protocol stack must be
+working, including multicast, DHCP, IPv4/6, etc. If necessary, it should be
+programming the appropriate filters for VLAN, multicast, unicast etc. The
+underlying device driver must effectively be configured in a similar fashion to
+what it would do when IGMP snooping is enabled for IP multicast over these
+switchdev network devices and unsollicited multicast must be filtered as early
+as possible into the hardware.
+
+When configuring VLANs on top of the network device, all VLANs must be working,
+irrespective of the state of other network devices (e.g: other ports being part
+of a VLAN aware bridge doing ingress VID checking). See below for details.
+
+Bridged network devices
+-----------------------
+
+When a switchdev enabled network device is added as a bridge member, it should
+not be disrupting any functionality of non-bridged network devices and they
+should continue to behave as normal network devices. Depending on the bridge
+configuration knobs below, the expected behavior is documented.
+
+VLAN filtering
+~~~~~~~~~~~~~~
+
+The Linux bridge allows the configuration of a VLAN filtering mode (compile and
+run time) which must be observed by the underlying switchdev network
Quoted 8 lines

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 440

Quoted 4 lines
Documentation/networking/switchdev.txt +4 -0
+device/hardware:
+
+- with VLAN filtering turned off: frames ingressing the device with a VID that
+  is not programmed into the bridge/switch's VLAN table must be forwarded.

mlxsw doesn't support it. These bridges are mainly used with VLAN devices where the packets ingress the bridge untagged. When configured over physical ports, we only allow untagged packets into such a bridge.

I suppose I got confused about the meaning of VLAN filtering on a Linux bridge when offloaded to a switch, VLAN filtering turned off effectively
means: no VLAN awareness, everything untagged.

There are really many misnomers within the bridge code then, like MC_DISABLED, this really means: flood or do not flood multicast, not "disable multicast" which would be madness.

Quoted 17 lines

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 443

Quoted 4 lines
Documentation/networking/switchdev.txt +3 -0
+
+- with VLAN filtering turned on: frames ingressing the device with a VID that is
+  not programmed into the bridges/switch's VLAN table must be dropped.

ack

Quoted 10 lines
Documentation/networking/switchdev.txt +10 -0
+
+Non-bridged network ports of the same switch fabric must not be disturbed in any
+way, shape or form by the enabling of VLAN filtering.
+
+VLAN devices configured on top of a switchdev network device (e.g: sw0p1.100)
+which is a bridge port member must also observe the following behavior:
+
+- with VLAN filtering turned off, these VLAN devices must be fully functional
+  since the hardware is allowed VID frames
+
Quoted 8 lines

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 457

Quoted 4 lines
Documentation/networking/switchdev.txt +4 -0
+- with VLAN filtering turned on, these VLAN devices are not going to be
+  functional unless the bridge's VLAN database is also configured to have that
+  VID enabled for the underlying network device/port
+  (e.g: bridge vlan add vid 100 dev sw0p1)

mlxsw forbids the enslavement of VLAN devices to VLAN-aware bridges. It doesn't really make sense to enable VLAN filtering when all the packets are untagged.

Did you mean VLAN-unaware here, otherwise that would contradict the statement that VLAN-aware bridges mean everything untagged, or am I incorrectly understanding things here?

Quoted 4 lines

But I disagree with the comment about the underlying port. When you configured the VLAN device, it should have enabled the VLAN filters on the real device via ndo_vlan_rx_add_vid().

That is really why I submitted this patch, because right now I have a patch (yet to be submitted) which adds ndo_vlan_rx_{add,kill}_vid() and if the underlying device is enslaved into a bridge, I just do nothing and let the bridge control the VLAN membership, hence my comment and example here.

What you are saying is that we should have these two cases:

1) VLAN devices on top of VLAN unaware bridge: allow the VLAN device and program VLAN filter on the underlying switch port to permit VLAN tagging

2) VLAN devices on top of a VLAN aware bridge: deny the VLAN device creation and let the bridge, which is VLAN aware manage the port VLAN membership

In case 1) or 2) if the desire is to have a VLAN aware network device this can be either done through a VLAN device on top of the switch port, or through a VLAN device on top of the bridge master itself, and in either case, this amounts to doing about the same thing.

Did I get this right?

Quoted 8 lines

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 461

Quoted 5 lines
Documentation/networking/switchdev.txt +4 -0
+
+Because VLAN filtering can be turned on/off at runtime, the switchdev driver
+must be able to re-configure the underlying hardware on the fly to honor the
+toggling of that option and behave appropriately.

Please mention that switchdev drivers can refuse the operation.

Will do, thanks!

Signature · 1 line
Florian
#5 lore raw
Quoted 20 lines · Florian Fainelli

Le 12/16/18 à 12:25 AM, Ido Schimmel a écrit :

Quoted 10 lines · Florian Fainelli
Quoted 9 lines
Documentation/networking/switchdev.txt +9 -0
+Non-bridged network ports of the same switch fabric must not be disturbed in any
+way, shape or form by the enabling of VLAN filtering.
+
+VLAN devices configured on top of a switchdev network device (e.g: sw0p1.100)
+which is a bridge port member must also observe the following behavior:
+
+- with VLAN filtering turned off, these VLAN devices must be fully functional
+  since the hardware is allowed VID frames
+
Quoted 8 lines

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 457

Quoted 4 lines

+- with VLAN filtering turned on, these VLAN devices are not going to be

Documentation/networking/switchdev.txt +3 -0
+  functional unless the bridge's VLAN database is also configured to have that
+  VID enabled for the underlying network device/port
+  (e.g: bridge vlan add vid 100 dev sw0p1)

mlxsw forbids the enslavement of VLAN devices to VLAN-aware bridges. It doesn't really make sense to enable VLAN filtering when all the packets are untagged.

Quoted 3 lines

Did you mean VLAN-unaware here, otherwise that would contradict the statement that VLAN-aware bridges mean everything untagged, or am I incorrectly understanding things here?

I meant VLAN-aware... In a VLAN-unaware bridge the VLAN is meaningless. For example, there is no filtering based on VLAN at ingress/egress and FDB entries are only searched based on MAC (VLAN is always 0). This is in contrast to a VLAN-aware bridge.

When you enslave VLAN netdevs to a bridge, the bridge sees untagged packets. The VLAN tag is pulled from the packet in Rx path and then the packet is injected to the bridge via the Rx handler configured on the VLAN netdev. Therefore, there is point in enslaving these device to a VLAN-aware bridge.

Also, mlxsw only supports a single VLAN-aware bridge. You can however, configure 1K VLAN-unaware bridges.

Quoted 10 lines
Quoted 3 lines

But I disagree with the comment about the underlying port. When you configured the VLAN device, it should have enabled the VLAN filters on the real device via ndo_vlan_rx_add_vid().

That is really why I submitted this patch, because right now I have a patch (yet to be submitted) which adds ndo_vlan_rx_{add,kill}_vid() and if the underlying device is enslaved into a bridge, I just do nothing and let the bridge control the VLAN membership, hence my comment and example here.

Quoted 4 lines

What you are saying is that we should have these two cases:

1) VLAN devices on top of VLAN unaware bridge: allow the VLAN device and program VLAN filter on the underlying switch port to permit VLAN tagging

When you say "on top" you mean enslaved to?

Quoted 3 lines

2) VLAN devices on top of a VLAN aware bridge: deny the VLAN device creation and let the bridge, which is VLAN aware manage the port VLAN membership

mlxsw does not forbid the creation of the VLAN device. It only forbids its enslavement to a VLAN-aware bridge.

Quoted 6 lines

In case 1) or 2) if the desire is to have a VLAN aware network device this can be either done through a VLAN device on top of the switch port, or through a VLAN device on top of the bridge master itself, and in either case, this amounts to doing about the same thing.

Did I get this right?

I'm saying that a VLAN-aware bridge with VIDs 10-100 (for example) is equivalent to VLAN devices with VIDs 10-100 enslaved to br10-br100, respectively. It is up to you if you want to / can support both modes. We support both, but most / all users use the VLAN-aware bridge.

#6 lore raw
Quoted 30 lines · Ido Schimmel
Quoted 20 lines · Florian Fainelli

Le 12/16/18 à 12:25 AM, Ido Schimmel a écrit :

Quoted 10 lines · Florian Fainelli
Quoted 9 lines
Documentation/networking/switchdev.txt +9 -0
+Non-bridged network ports of the same switch fabric must not be disturbed in any
+way, shape or form by the enabling of VLAN filtering.
+
+VLAN devices configured on top of a switchdev network device (e.g: sw0p1.100)
+which is a bridge port member must also observe the following behavior:
+
+- with VLAN filtering turned off, these VLAN devices must be fully functional
+  since the hardware is allowed VID frames
+
Quoted 8 lines

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 457

Quoted 4 lines

+- with VLAN filtering turned on, these VLAN devices are not going to be

Documentation/networking/switchdev.txt +3 -0
+  functional unless the bridge's VLAN database is also configured to have that
+  VID enabled for the underlying network device/port
+  (e.g: bridge vlan add vid 100 dev sw0p1)

mlxsw forbids the enslavement of VLAN devices to VLAN-aware bridges. It doesn't really make sense to enable VLAN filtering when all the packets are untagged.

Quoted 3 lines

Did you mean VLAN-unaware here, otherwise that would contradict the statement that VLAN-aware bridges mean everything untagged, or am I incorrectly understanding things here?

I meant VLAN-aware... In a VLAN-unaware bridge the VLAN is meaningless. For example, there is no filtering based on VLAN at ingress/egress and FDB entries are only searched based on MAC (VLAN is always 0). This is in contrast to a VLAN-aware bridge.

Quoted 5 lines

When you enslave VLAN netdevs to a bridge, the bridge sees untagged packets. The VLAN tag is pulled from the packet in Rx path and then the packet is injected to the bridge via the Rx handler configured on the VLAN netdev. Therefore, there is point in enslaving these device to a VLAN-aware bridge.

I see what you describe and that is not quite what I was talking about, see below.

Quoted 3 lines

Also, mlxsw only supports a single VLAN-aware bridge. You can however, configure 1K VLAN-unaware bridges.

OK, how do you enforce that in the driver? I was going to do something as basic as: loop around all ports that are not the one being changed by VLAN filtering attribute, if bridge device associated is non-NULL and br_vlan_enabled() returns true for that bridge and we want to turn off VLAN filtering, then this is not possible since that would break the other bridge devices we have which are VLAN filtering enabled.

Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

But I disagree with the comment about the underlying port. When you configured the VLAN device, it should have enabled the VLAN filters on the real device via ndo_vlan_rx_add_vid().

That is really why I submitted this patch, because right now I have a patch (yet to be submitted) which adds ndo_vlan_rx_{add,kill}_vid() and if the underlying device is enslaved into a bridge, I just do nothing and let the bridge control the VLAN membership, hence my comment and example here.

Quoted 6 lines
Quoted 4 lines

What you are saying is that we should have these two cases:

1) VLAN devices on top of VLAN unaware bridge: allow the VLAN device and program VLAN filter on the underlying switch port to permit VLAN tagging

When you say "on top" you mean enslaved to?

I meant to write: a VLAN device created on (top of) a switch port, and this switch port being a bridge member. The VLAN device would not be added as a bridge member (did not really think about it).

Quoted 7 lines
Quoted 4 lines

2) VLAN devices on top of a VLAN aware bridge: deny the VLAN device creation and let the bridge, which is VLAN aware manage the port VLAN membership

mlxsw does not forbid the creation of the VLAN device. It only forbids its enslavement to a VLAN-aware bridge.

That's done in mlxsw_sp_netdevice_port_vlan_event() right?

Quoted 6 lines
Quoted 6 lines

In case 1) or 2) if the desire is to have a VLAN aware network device this can be either done through a VLAN device on top of the switch port, or through a VLAN device on top of the bridge master itself, and in either case, this amounts to doing about the same thing.

Quoted 7 lines
Quoted 1 line

Did I get this right?

I'm saying that a VLAN-aware bridge with VIDs 10-100 (for example) is equivalent to VLAN devices with VIDs 10-100 enslaved to br10-br100, respectively. It is up to you if you want to / can support both modes. We support both, but most / all users use the VLAN-aware bridge.

Right, and it is also equivalent to have these two things:

- a VLAN aware bridge, adding VIDs 10-100 to sw0p1 through "bridge vlan add vid .." and creating br0.10..br0.100 devices

and:

- a VLAN aware bridge, creating sw0p1.10..sw0p1.100 (VLAN devices) while sw0p1 is a bridge port member

Signature · 1 line
Florian
#7 lore raw
Quoted 44 lines · Florian Fainelli
Quoted 30 lines · Ido Schimmel
Quoted 20 lines · Florian Fainelli

Le 12/16/18 à 12:25 AM, Ido Schimmel a écrit :

Quoted 10 lines · Florian Fainelli
Quoted 9 lines
Documentation/networking/switchdev.txt +9 -0
+Non-bridged network ports of the same switch fabric must not be disturbed in any
+way, shape or form by the enabling of VLAN filtering.
+
+VLAN devices configured on top of a switchdev network device (e.g: sw0p1.100)
+which is a bridge port member must also observe the following behavior:
+
+- with VLAN filtering turned off, these VLAN devices must be fully functional
+  since the hardware is allowed VID frames
+
Quoted 8 lines

Documentation/networking/switchdev.txt switchdev_trans_item_dequeue() · line 457

Quoted 4 lines

+- with VLAN filtering turned on, these VLAN devices are not going to be

Documentation/networking/switchdev.txt +3 -0
+  functional unless the bridge's VLAN database is also configured to have that
+  VID enabled for the underlying network device/port
+  (e.g: bridge vlan add vid 100 dev sw0p1)

mlxsw forbids the enslavement of VLAN devices to VLAN-aware bridges. It doesn't really make sense to enable VLAN filtering when all the packets are untagged.

Quoted 3 lines

Did you mean VLAN-unaware here, otherwise that would contradict the statement that VLAN-aware bridges mean everything untagged, or am I incorrectly understanding things here?

I meant VLAN-aware... In a VLAN-unaware bridge the VLAN is meaningless. For example, there is no filtering based on VLAN at ingress/egress and FDB entries are only searched based on MAC (VLAN is always 0). This is in contrast to a VLAN-aware bridge.

Quoted 5 lines

When you enslave VLAN netdevs to a bridge, the bridge sees untagged packets. The VLAN tag is pulled from the packet in Rx path and then the packet is injected to the bridge via the Rx handler configured on the VLAN netdev. Therefore, there is point in enslaving these device to a VLAN-aware bridge.

I see what you describe and that is not quite what I was talking about, see below.

Quoted 3 lines

Also, mlxsw only supports a single VLAN-aware bridge. You can however, configure 1K VLAN-unaware bridges.

Quoted 6 lines

OK, how do you enforce that in the driver? I was going to do something as basic as: loop around all ports that are not the one being changed by VLAN filtering attribute, if bridge device associated is non-NULL and br_vlan_enabled() returns true for that bridge and we want to turn off VLAN filtering, then this is not possible since that would break the other bridge devices we have which are VLAN filtering enabled.

See mlxsw_sp_bridge_device_create(). We basically keep a list of bridges we care about. If one is already VLAN aware, then we fail the creation of another bridge.

Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
Quoted 5 lines

But I disagree with the comment about the underlying port. When you configured the VLAN device, it should have enabled the VLAN filters on the real device via ndo_vlan_rx_add_vid().

That is really why I submitted this patch, because right now I have a patch (yet to be submitted) which adds ndo_vlan_rx_{add,kill}_vid() and if the underlying device is enslaved into a bridge, I just do nothing and let the bridge control the VLAN membership, hence my comment and example here.

Quoted 6 lines
Quoted 4 lines

What you are saying is that we should have these two cases:

1) VLAN devices on top of VLAN unaware bridge: allow the VLAN device and program VLAN filter on the underlying switch port to permit VLAN tagging

When you say "on top" you mean enslaved to?

I meant to write: a VLAN device created on (top of) a switch port, and this switch port being a bridge member. The VLAN device would not be added as a bridge member (did not really think about it).

Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

2) VLAN devices on top of a VLAN aware bridge: deny the VLAN device creation and let the bridge, which is VLAN aware manage the port VLAN membership

mlxsw does not forbid the creation of the VLAN device. It only forbids its enslavement to a VLAN-aware bridge.

That's done in mlxsw_sp_netdevice_port_vlan_event() right?

Almost :) See mlxsw_sp_bridge_8021q_port_join()

#8 lore raw
In reply to Ido Schimmel
Quoted 6 lines · Ido Schimmel

On Wed, Dec 12, 2018 at 03:09:43PM -0800, Florian Fainelli wrote:

mlxsw doesn't support it. These bridges are mainly used with VLAN devices where the packets ingress the bridge untagged. When configured over physical ports, we only allow untagged packets into such a bridge.

There is another complication with at least some of the DSA switches, turning off VLAN filtering is a global operation, so we must deny it if we have another bridge device that spans the same switch device which is also requesting VLAN filtering to be on. Not necessarily a problem in a larger switch fabric comprised of multiple switches (the D in DSA) since they could conceptually have multiple switches each with different VLAN filtering rules but that complicates the matter significantly.

The more I think about supporting toggling VLAN filtering at runtime the less it seems to have a good return on investment:

- the bridge layer does not remove VLAN entries created while the bridge was VLAN aware, thus complicating the on to off state, since we need to make the switch port a member of all VLANs, untagged, some older switches don't have a "join all VLAN" shorthand for that so that means programming up to 4K VLAN entries...slow.

- no reasonable use case comes to mind which would not involved knowing whether a bridge should be VLAN aware ahead of time.

I am therefore convinced that adopting the mlxsw behavior wrt. VLAN filtering toggling is a good approach. Thanks!

Signature · 1 line
Florian