]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
net: dsa: microchip: ksz8795: Use software untagging on CPU port
authorBen Hutchings <ben.hutchings@mind.be>
Mon, 16 Aug 2021 18:09:45 +0000 (20:09 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 24 Sep 2021 09:57:30 +0000 (11:57 +0200)
BugLink: https://bugs.launchpad.net/bugs/1943756
commit 9130c2d30c17846287b803a9803106318cbe5266 upstream.

On the CPU port, we can support both tagged and untagged VLANs at the
same time by doing any necessary untagging in software rather than
hardware.  To enable that, keep the CPU port's Remove Tag flag cleared
and set the dsa_switch::untag_bridge_pvid flag.

Fixes: e66f840c08a2 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backport to 5.10: adjust context]
Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/dsa/microchip/ksz8795.c

index 9234b216213bb3aea229c7f6c496ccb4d51ecfe7..6c338653e8430498d3e532420ddec1941aea4508 100644 (file)
@@ -813,9 +813,11 @@ static bool ksz8795_port_vlan_changes_remove_tag(
        /* If a VLAN is added with untagged flag different from the
         * port's Remove Tag flag, we need to change the latter.
         * Ignore VID 0, which is always untagged.
+        * Ignore CPU port, which will always be tagged.
         */
        return untagged != p->remove_tag &&
-               !(vlan->vid_begin == 0 && vlan->vid_end == 0);
+               !(vlan->vid_begin == 0 && vlan->vid_end == 0) &&
+               port != dev->cpu_port;
 }
 
 int ksz8795_port_vlan_prepare(struct dsa_switch *ds, int port,
@@ -1330,6 +1332,11 @@ static int ksz8795_switch_init(struct ksz_device *dev)
        /* set the real number of ports */
        dev->ds->num_ports = dev->port_cnt;
 
+       /* We rely on software untagging on the CPU port, so that we
+        * can support both tagged and untagged VLANs
+        */
+       dev->ds->untag_bridge_pvid = true;
+
        /* VLAN filtering is partly controlled by the global VLAN
         * Enable flag
         */