diff mbox series

[net,v1,1/6] net: dsa: microchip: ksz8: fix ksz8_fdb_dump()

Message ID 20230322143130.1432106-2-o.rempel@pengutronix.de (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: dsa: microchip: ksz8: fixes for stable | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers fail 1 blamed authors not CCed: arun.ramadoss@microchip.com; 1 maintainers not CCed: arun.ramadoss@microchip.com
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 20 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Oleksij Rempel March 22, 2023, 2:31 p.m. UTC
Before this patch, the ksz8_fdb_dump() function had several issues, such
as uninitialized variables and incorrect usage of source port as a bit
mask. These problems caused inaccurate reporting of vid information and
port assignment in the bridge fdb.

Fixes: e587be759e6e ("net: dsa: microchip: update fdb add/del/dump in ksz_common")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/dsa/microchip/ksz8795.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Arun Ramadoss March 24, 2023, 4:20 a.m. UTC | #1
Hi Oleksij,

On Wed, 2023-03-22 at 15:31 +0100, Oleksij Rempel wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
> 
> Before this patch, the ksz8_fdb_dump() function had several issues,
> such
> as uninitialized variables and incorrect usage of source port as a
> bit
> mask. These problems caused inaccurate reporting of vid information
> and
> port assignment in the bridge fdb.
> 
> Fixes: e587be759e6e ("net: dsa: microchip: update fdb add/del/dump in
> ksz_common")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/dsa/microchip/ksz8795.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dsa/microchip/ksz8795.c
> b/drivers/net/dsa/microchip/ksz8795.c
> index 003b0ac2854c..3fffd5da8d3b 100644
> --- a/drivers/net/dsa/microchip/ksz8795.c
> +++ b/drivers/net/dsa/microchip/ksz8795.c
> @@ -958,15 +958,14 @@ int ksz8_fdb_dump(struct ksz_device *dev, int
> port,
>         u16 entries = 0;
>         u8 timestamp = 0;
>         u8 fid;
> -       u8 member;
> -       struct alu_struct alu;
> +       u8 src_port;
> +       u8 mac[ETH_ALEN];
> 
>         do {
> -               alu.is_static = false;
> -               ret = ksz8_r_dyn_mac_table(dev, i, alu.mac, &fid,
> &member,
> +               ret = ksz8_r_dyn_mac_table(dev, i, mac, &fid,
> &src_port,
>                                            &timestamp, &entries);
> -               if (!ret && (member & BIT(port))) {
> -                       ret = cb(alu.mac, alu.fid, alu.is_static,
> data);
> +               if (!ret && port == src_port) {

Only in KSZ9477 series, it is BIT(port). For the KSZ87xx and KSZ88xx,
it is like logic table. i.e 
00 = port 0
01 = port 1
02 = port 2

Cross Verified with the Datasheet.

Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>


> +                       ret = cb(mac, fid, false, data);
>                         if (ret)
>                                 break;
>                 }
> --
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c
index 003b0ac2854c..3fffd5da8d3b 100644
--- a/drivers/net/dsa/microchip/ksz8795.c
+++ b/drivers/net/dsa/microchip/ksz8795.c
@@ -958,15 +958,14 @@  int ksz8_fdb_dump(struct ksz_device *dev, int port,
 	u16 entries = 0;
 	u8 timestamp = 0;
 	u8 fid;
-	u8 member;
-	struct alu_struct alu;
+	u8 src_port;
+	u8 mac[ETH_ALEN];
 
 	do {
-		alu.is_static = false;
-		ret = ksz8_r_dyn_mac_table(dev, i, alu.mac, &fid, &member,
+		ret = ksz8_r_dyn_mac_table(dev, i, mac, &fid, &src_port,
 					   &timestamp, &entries);
-		if (!ret && (member & BIT(port))) {
-			ret = cb(alu.mac, alu.fid, alu.is_static, data);
+		if (!ret && port == src_port) {
+			ret = cb(mac, fid, false, data);
 			if (ret)
 				break;
 		}