Skip to content

Commit

Permalink
net: dsa: microchip: ksz8795: Use software untagging on CPU port
Browse files Browse the repository at this point in the history
commit 9130c2d 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: e66f840 ("net: dsa: ksz: Add Microchip KSZ8795 DSA driver")
Signed-off-by: Ben Hutchings <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
[bwh: Backport to 5.10: adjust context]
Signed-off-by: Ben Hutchings <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
bwh-mind authored and gregkh committed Aug 18, 2021
1 parent 1e78179 commit 3a24e12
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion drivers/net/dsa/microchip/ksz8795.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,9 +812,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,
Expand Down Expand Up @@ -1325,6 +1327,11 @@ static int ksz8795_switch_init(struct ksz_device *dev)
/* set the real number of ports */
dev->ds->num_ports = dev->port_cnt + 1;

/* 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
*/
Expand Down

0 comments on commit 3a24e12

Please sign in to comment.