diff mbox series

[net] net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry

Message ID 20220812093411.5879-1-arun.ramadoss@microchip.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net] net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 85 this patch: 85
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 85 this patch: 85
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Arun Ramadoss Aug. 12, 2022, 9:34 a.m. UTC
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(-)


base-commit: f86d1fbbe7858884d6754534a0afbb74fc30bc26

Comments

Vladimir Oltean Aug. 14, 2022, 7:56 a.m. UTC | #1
On Fri, Aug 12, 2022 at 03:04:11PM +0530, Arun Ramadoss wrote:
> 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")

I think this should be:
Fixes: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477")
since that's when ksz9477_port_fdb_dump() was introduced, with identical
logic.

> 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) {

I wonder if you could avoid increasing the indentation level using:

		if (!(ksz_data & ALU_VALID))
			continue;

> +			/* 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
>
diff mbox series

Patch

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);