2021-01-13 12:58:49

by Gilles Doffe

[permalink] [raw]
Subject: [PATCH net 5/6] net: dsa: ksz: fix wrong pvid

A logical 'or' was performed until now.
So if vlan 1 is the current pvid and vlan 20 is set as the new one,
vlan 21 is the new pvid.
This commit fixes this by setting the right mask to set the new pvid.

Signed-off-by: Gilles DOFFE <[email protected]>
---
drivers/net/dsa/microchip/ksz8795.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index b55fb2761993..44306a7e297a 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -868,8 +868,8 @@ static void ksz8795_port_vlan_add(struct dsa_switch *ds, int port,

if (new_pvid) {
ksz_pread16(dev, port, REG_PORT_CTRL_VID, &vid);
- vid &= 0xfff;
- vid |= new_pvid;
+ vid &= ~0xfff;
+ vid |= (new_pvid & 0xfff);
ksz_pwrite16(dev, port, REG_PORT_CTRL_VID, vid);
}

--
2.25.1


2021-01-13 17:25:13

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH net 5/6] net: dsa: ksz: fix wrong pvid

On 1/13/21 4:45 AM, Gilles DOFFE wrote:
> A logical 'or' was performed until now.
> So if vlan 1 is the current pvid and vlan 20 is set as the new one,
> vlan 21 is the new pvid.
> This commit fixes this by setting the right mask to set the new pvid.
>
> Signed-off-by: Gilles DOFFE <[email protected]>

Looks about right, can you provide a Fixes: tag for this change?
--
Florian

2021-01-14 01:56:23

by Vladimir Oltean

[permalink] [raw]
Subject: Re: [PATCH net 5/6] net: dsa: ksz: fix wrong pvid

On Wed, Jan 13, 2021 at 01:45:21PM +0100, Gilles DOFFE wrote:
> A logical 'or' was performed until now.
> So if vlan 1 is the current pvid and vlan 20 is set as the new one,
> vlan 21 is the new pvid.
> This commit fixes this by setting the right mask to set the new pvid.
>
> Signed-off-by: Gilles DOFFE <[email protected]>
> ---

Reviewed-by: Vladimir Oltean <[email protected]>