Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Ben Hutchings <ben.hutchings@mind.be>
To: Woojung Huh <woojung.huh@microchip.com>, UNGLinuxDriver@microchip.com
Cc: netdev@vger.kernel.org
Subject: [PATCH net 7/7] net: dsa: microchip: ksz8795: Don't use phy_port_cnt in VLAN table lookup
Date: Tue, 10 Aug 2021 01:00:15 +0200	[thread overview]
Message-ID: <20210809230014.GH17207@cephalopod> (raw)
In-Reply-To: <20210809225753.GA17207@cephalopod>

The magic number 4 in VLAN table lookup was the number of entries we
can read and write at once.  Using phy_port_cnt here doesn't make
sense and presumably broke VLAN filtering for 3-port switches.  Change
it back to 4.

Fixes: 4ce2a984abd8 ("net: dsa: microchip: ksz8795: use phy_port_cnt ...")
Signed-off-by: Ben Hutchings <ben.hutchings@mind.be>
---
 drivers/net/dsa/microchip/ksz8795.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 891eaeb62ad0..4a6a3838418f 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -687,8 +687,8 @@ static void ksz8_r_vlan_entries(struct ksz_device *dev, u16 addr)
 	shifts = ksz8->shifts;
 
 	ksz8_r_table(dev, TABLE_VLAN, addr, &data);
-	addr *= dev->phy_port_cnt;
-	for (i = 0; i < dev->phy_port_cnt; i++) {
+	addr *= 4;
+	for (i = 0; i < 4; i++) {
 		dev->vlan_cache[addr + i].table[0] = (u16)data;
 		data >>= shifts[VLAN_TABLE];
 	}
@@ -702,7 +702,7 @@ static void ksz8_r_vlan_table(struct ksz_device *dev, u16 vid, u16 *vlan)
 	u64 buf;
 
 	data = (u16 *)&buf;
-	addr = vid / dev->phy_port_cnt;
+	addr = vid / 4;
 	index = vid & 3;
 	ksz8_r_table(dev, TABLE_VLAN, addr, &buf);
 	*vlan = data[index];
@@ -716,7 +716,7 @@ static void ksz8_w_vlan_table(struct ksz_device *dev, u16 vid, u16 vlan)
 	u64 buf;
 
 	data = (u16 *)&buf;
-	addr = vid / dev->phy_port_cnt;
+	addr = vid / 4;
 	index = vid & 3;
 	ksz8_r_table(dev, TABLE_VLAN, addr, &buf);
 	data[index] = vlan;
-- 
2.20.1

  parent reply	other threads:[~2021-08-09 23:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09 22:57 [PATCH net 0/7] ksz8795 VLAN fixes Ben Hutchings
2021-08-09 22:59 ` [PATCH net 1/7] net: dsa: microchip: Fix ksz_read64() Ben Hutchings
2021-08-09 22:59 ` [PATCH net 2/7] net: dsa: microchip: ksz8795: Fix PVID tag insertion Ben Hutchings
2021-08-09 22:59 ` [PATCH net 3/7] net: dsa: microchip: ksz8795: Reject unsupported VLAN configuration Ben Hutchings
2021-08-09 22:59 ` [PATCH net 4/7] net: dsa: microchip: ksz8795: Fix VLAN untagged flag change on deletion Ben Hutchings
2021-08-09 22:59 ` [PATCH net 5/7] net: dsa: microchip: ksz8795: Use software untagging on CPU port Ben Hutchings
2021-08-09 23:00 ` [PATCH net 6/7] net: dsa: microchip: ksz8795: Fix VLAN filtering Ben Hutchings
2021-08-09 23:00 ` Ben Hutchings [this message]
2021-08-10  0:03 ` [PATCH net 0/7] ksz8795 VLAN fixes Jakub Kicinski
2021-08-10  9:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210809230014.GH17207@cephalopod \
    --to=ben.hutchings@mind.be \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=woojung.huh@microchip.com \
    --subject='Re: [PATCH net 7/7] net: dsa: microchip: ksz8795: Don'\''t use phy_port_cnt in VLAN table lookup' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).