diff options
author | Vladimir Oltean <olteanv@gmail.com> | 2019-05-02 23:23:34 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-05-03 10:49:17 -0400 |
commit | 6666cebc5e306f49a25bd20aa8c1cb8ef8950df5 (patch) | |
tree | feac9879b812fff6394bba7c875007002847a759 /drivers/net/dsa/sja1105/sja1105_static_config.c | |
parent | ether: Add dedicated Ethertype for pseudo-802.1Q DSA tagging (diff) | |
download | linux-dev-6666cebc5e306f49a25bd20aa8c1cb8ef8950df5.tar.xz linux-dev-6666cebc5e306f49a25bd20aa8c1cb8ef8950df5.zip |
net: dsa: sja1105: Add support for VLAN operations
VLAN filtering cannot be properly disabled in SJA1105. So in order to
emulate the "no VLAN awareness" behavior (not dropping traffic that is
tagged with a VID that isn't configured on the port), we need to hack
another switch feature: programmable TPID (which is 0x8100 for 802.1Q).
We are reprogramming the TPID to a bogus value which leaves the switch
thinking that all traffic is untagged, and therefore accepts it.
Under a vlan_filtering bridge, the proper TPID of ETH_P_8021Q is
installed again, and the switch starts identifying 802.1Q-tagged
traffic.
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/dsa/sja1105/sja1105_static_config.c')
-rw-r--r-- | drivers/net/dsa/sja1105/sja1105_static_config.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/net/dsa/sja1105/sja1105_static_config.c b/drivers/net/dsa/sja1105/sja1105_static_config.c index 84ee623c6336..b3c992b0abb0 100644 --- a/drivers/net/dsa/sja1105/sja1105_static_config.c +++ b/drivers/net/dsa/sja1105/sja1105_static_config.c @@ -947,3 +947,41 @@ void sja1105_static_config_free(struct sja1105_static_config *config) } } } + +int sja1105_table_delete_entry(struct sja1105_table *table, int i) +{ + size_t entry_size = table->ops->unpacked_entry_size; + u8 *entries = table->entries; + + if (i > table->entry_count) + return -ERANGE; + + memmove(entries + i * entry_size, entries + (i + 1) * entry_size, + (table->entry_count - i) * entry_size); + + table->entry_count--; + + return 0; +} + +/* No pointers to table->entries should be kept when this is called. */ +int sja1105_table_resize(struct sja1105_table *table, size_t new_count) +{ + size_t entry_size = table->ops->unpacked_entry_size; + void *new_entries, *old_entries = table->entries; + + if (new_count > table->ops->max_entry_count) + return -ERANGE; + + new_entries = kcalloc(new_count, entry_size, GFP_KERNEL); + if (!new_entries) + return -ENOMEM; + + memcpy(new_entries, old_entries, min(new_count, table->entry_count) * + entry_size); + + table->entries = new_entries; + table->entry_count = new_count; + kfree(old_entries); + return 0; +} |