From patchwork Tue Aug 16 04:26:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Ramadoss X-Patchwork-Id: 12944412 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96FCDC2BB41 for ; Tue, 16 Aug 2022 07:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232335AbiHPHi0 (ORCPT ); Tue, 16 Aug 2022 03:38:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbiHPHhp (ORCPT ); Tue, 16 Aug 2022 03:37:45 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A9AC2A607F; Mon, 15 Aug 2022 21:27:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1660624032; x=1692160032; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fdSIlNE493nsnthqOoE4vYDUbR0tqWMaglZ8U4RJbwc=; b=T5h7ajq8TKrLMg6/ugegOpQnVG1h9VLPV84ti7tlh/pxtMiy7Rxdvop0 b1qYMthChgaCUmF8aE2MYgMKa0yA3y3mHgLL5Zw6k9lu0wWaOpDXfyTec wEiNlUdK+TC8LuAQDcnJOwcXRNaGf6krX/hqf6Ym42R+s1Cyz8nfDPiv+ TxzsgIi8o7DseS2Ix+E4wlnpqere38rtpoYkx5cohq0l8a/5lJERcKcjC hhR5WzbTVZJ3EkCsr25DRCuoRCPr7Sx2yHX18Vsg8mbW2eqWtAukcoCJR N5VqPNh7RjchqQu7+mbDflaOsK7oDcQzEpOZFXGrll8uuJLI4Av3l2bEr g==; X-IronPort-AV: E=Sophos;i="5.93,240,1654585200"; d="scan'208";a="186610290" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Aug 2022 21:27:11 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Mon, 15 Aug 2022 21:27:11 -0700 Received: from CHE-LT-I17769U.microchip.com (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Mon, 15 Aug 2022 21:27:05 -0700 From: Arun Ramadoss To: , CC: Woojung Huh , , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Russell King" , Tristram Ha Subject: [PATCH net-next v2] net: dsa: microchip: ksz9477: fix fdb_dump last invalid entry Date: Tue, 16 Aug 2022 09:56:35 +0530 Message-ID: <20220816042635.7229-1-arun.ramadoss@microchip.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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: b987e98e50ab ("dsa: add DSA switch driver for Microchip KSZ9477") Signed-off-by: Arun Ramadoss --- changes in v2 - changed the fixes commit id - reduced the indentation level by using ! and continue statement drivers/net/dsa/microchip/ksz9477.c | 3 +++ 1 file changed, 3 insertions(+) base-commit: 7ebfc85e2cd7b08f518b526173e9a33b56b3913b diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 4b14d80d27ed..e4f446db0ca1 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -613,6 +613,9 @@ int ksz9477_fdb_dump(struct ksz_device *dev, int port, goto exit; } + if (!(ksz_data & ALU_VALID)) + continue; + /* read ALU table */ ksz9477_read_table(dev, alu_table);