Skip to content

Commit ec5ae61

Browse files
vladimirolteandavem330
authored andcommitted
net: dsa: sja1105: save/restore VLANs using a delta commit method
Managing the VLAN table that is present in hardware will become very difficult once we add a third operating state (best_effort_vlan_filtering). That is because correct cleanup (not too little, not too much) becomes virtually impossible, when VLANs can be added from the bridge layer, from dsa_8021q for basic tagging, for cross-chip bridging, as well as retagging rules for sub-VLANs and cross-chip sub-VLANs. So we need to rethink VLAN interaction with the switch in a more scalable way. In preparation for that, use the priv->expect_dsa_8021q boolean to classify any VLAN request received through .port_vlan_add or .port_vlan_del towards either one of 2 internal lists: bridge VLANs and dsa_8021q VLANs. Then, implement a central sja1105_build_vlan_table method that creates a VLAN configuration from scratch based on the 2 lists of VLANs kept by the driver, and based on the VLAN awareness state. Currently, if we are VLAN-unaware, install the dsa_8021q VLANs, otherwise the bridge VLANs. Then, implement a delta commit procedure that identifies which VLANs from this new configuration are actually different from the config previously committed to hardware. We apply the delta through the dynamic configuration interface (we don't reset the switch). The result is that the hardware should see the exact sequence of operations as before this patch. This also helps remove the "br" argument passed to dsa_8021q_crosschip_bridge_join, which it was only using to figure out whether it should commit the configuration back to us or not, based on the VLAN awareness state of the bridge. We can simplify that, by always allowing those VLANs inside of our dsa_8021q_vlans list, and committing those to hardware when necessary. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 60b33ae commit ec5ae61

File tree

4 files changed

+393
-174
lines changed

4 files changed

+393
-174
lines changed

drivers/net/dsa/sja1105/sja1105.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,14 @@ struct sja1105_flow_block {
178178
int num_virtual_links;
179179
};
180180

181+
struct sja1105_bridge_vlan {
182+
struct list_head list;
183+
int port;
184+
u16 vid;
185+
bool pvid;
186+
bool untagged;
187+
};
188+
181189
enum sja1105_vlan_state {
182190
SJA1105_VLAN_UNAWARE,
183191
SJA1105_VLAN_FILTERING_FULL,
@@ -191,6 +199,8 @@ struct sja1105_private {
191199
struct gpio_desc *reset_gpio;
192200
struct spi_device *spidev;
193201
struct dsa_switch *ds;
202+
struct list_head dsa_8021q_vlans;
203+
struct list_head bridge_vlans;
194204
struct list_head crosschip_links;
195205
struct sja1105_flow_block flow_block;
196206
struct sja1105_port ports[SJA1105_NUM_PORTS];

0 commit comments

Comments
 (0)