public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch net] net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry
@ 2022-08-12  9:34 Arun Ramadoss
  2022-08-14  7:56 ` Vladimir Oltean
  0 siblings, 1 reply; 2+ messages in thread
From: Arun Ramadoss @ 2022-08-12  9:34 UTC (permalink / raw)
  To: linux-kernel, netdev
  Cc: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Russell King, Tristram Ha

In the ksz9477_fdb_dump function it reads the ALU control register and
exit from the timeout loop if there is valid entry or search is
complete. After exiting the loop, it reads the alu entry and report to
the user space irrespective of entry is valid. It works till the valid
entry. If the loop exited when search is complete, it reads the alu
table. The table returns all ones and it is reported to user space. So
bridge fdb show gives ff:ff:ff:ff:ff:ff as last entry for every port.
To fix it, after exiting the loop the entry is reported only if it is
valid one.

Fixes: c2e866911e25 ("net: dsa: microchip: break KSZ9477 DSA driver into two files")
Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com>
---
 drivers/net/dsa/microchip/ksz9477.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index 4b14d80d27ed..aa961dc03ddf 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -613,15 +613,17 @@ int ksz9477_fdb_dump(struct ksz_device *dev, int port,
 			goto exit;
 		}
 
-		/* read ALU table */
-		ksz9477_read_table(dev, alu_table);
+		if (ksz_data & ALU_VALID) {
+			/* read ALU table */
+			ksz9477_read_table(dev, alu_table);
 
-		ksz9477_convert_alu(&alu, alu_table);
+			ksz9477_convert_alu(&alu, alu_table);
 
-		if (alu.port_forward & BIT(port)) {
-			ret = cb(alu.mac, alu.fid, alu.is_static, data);
-			if (ret)
-				goto exit;
+			if (alu.port_forward & BIT(port)) {
+				ret = cb(alu.mac, alu.fid, alu.is_static, data);
+				if (ret)
+					goto exit;
+			}
 		}
 	} while (ksz_data & ALU_START);
 

base-commit: f86d1fbbe7858884d6754534a0afbb74fc30bc26
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-14  7:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12  9:34 [Patch net] net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry Arun Ramadoss
2022-08-14  7:56 ` Vladimir Oltean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox