From patchwork Tue Dec 1 20:44:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943775 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE62DC64E7B for ; Tue, 1 Dec 2020 20:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D8A320679 for ; Tue, 1 Dec 2020 20:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387643AbgLAUq1 (ORCPT ); Tue, 1 Dec 2020 15:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbgLAUqZ (ORCPT ); Tue, 1 Dec 2020 15:46:25 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8881EC061A48 for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002sj-39; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002bY-2A; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 01/11] net: dsa: microchip: ksz8795: remove unused last_port variable Date: Tue, 1 Dec 2020 21:44:56 +0100 Message-Id: <20201201204506.13473-2-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The variable last_port is not used anywhere, this patch removes it. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - unchanged --- drivers/net/dsa/microchip/ksz8795.c | 1 - drivers/net/dsa/microchip/ksz_common.h | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 1e101ab56cea1..8a3d2e6072835 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1163,7 +1163,6 @@ static int ksz8795_switch_detect(struct ksz_device *dev) id2 = 0x65; } else if (id2 == CHIP_ID_94) { dev->port_cnt--; - dev->last_port = dev->port_cnt; id2 = 0x94; } id16 &= ~0xff; diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index cf866e48ff664..629700a637024 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -72,7 +72,6 @@ struct ksz_device { int reg_mib_cnt; int mib_cnt; int mib_port_cnt; - int last_port; /* ports after that not used */ phy_interface_t compat_interface; u32 regs_size; bool phy_errata_9477; From patchwork Tue Dec 1 20:44:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943783 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F899C83019 for ; Tue, 1 Dec 2020 20:46:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E457220679 for ; Tue, 1 Dec 2020 20:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729703AbgLAUqf (ORCPT ); Tue, 1 Dec 2020 15:46:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbgLAUqe (ORCPT ); Tue, 1 Dec 2020 15:46:34 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6BBDC061A4B for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002sm-39; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002bb-2l; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 02/11] net: dsa: microchip: ksz8795: remove superfluous port_cnt assignment Date: Tue, 1 Dec 2020 21:44:57 +0100 Message-Id: <20201201204506.13473-3-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The port_cnt assignment will be done again in the init function. This patch removes the previous assignment in the detect function. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - unchanged --- drivers/net/dsa/microchip/ksz8795.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 8a3d2e6072835..853a0805e08f2 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1152,7 +1152,6 @@ static int ksz8795_switch_detect(struct ksz_device *dev) dev->mib_port_cnt = TOTAL_PORT_NUM; dev->phy_port_cnt = SWITCH_PORT_NUM; - dev->port_cnt = SWITCH_PORT_NUM; if (id2 == CHIP_ID_95) { u8 val; @@ -1162,7 +1161,6 @@ static int ksz8795_switch_detect(struct ksz_device *dev) if (val & PORT_FIBER_MODE) id2 = 0x65; } else if (id2 == CHIP_ID_94) { - dev->port_cnt--; id2 = 0x94; } id16 &= ~0xff; From patchwork Tue Dec 1 20:44:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943777 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECD4CC64E7A for ; Tue, 1 Dec 2020 20:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9B268206E0 for ; Tue, 1 Dec 2020 20:46:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728633AbgLAUq1 (ORCPT ); Tue, 1 Dec 2020 15:46:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbgLAUqZ (ORCPT ); Tue, 1 Dec 2020 15:46:25 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF11C061A49 for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002so-38; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002bg-3H; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 03/11] net: dsa: microchip: ksz8795: move variable assignments from detect to init Date: Tue, 1 Dec 2020 21:44:58 +0100 Message-Id: <20201201204506.13473-4-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch moves all variable assignments to the init function. It leaves the detect function for its single purpose to detect which chip version is found. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - unchanged --- drivers/net/dsa/microchip/ksz8795.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 853a0805e08f2..1164c745ce940 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1150,9 +1150,6 @@ static int ksz8795_switch_detect(struct ksz_device *dev) (id2 != CHIP_ID_94 && id2 != CHIP_ID_95)) return -ENODEV; - dev->mib_port_cnt = TOTAL_PORT_NUM; - dev->phy_port_cnt = SWITCH_PORT_NUM; - if (id2 == CHIP_ID_95) { u8 val; @@ -1167,9 +1164,6 @@ static int ksz8795_switch_detect(struct ksz_device *dev) id16 |= id2; dev->chip_id = id16; - dev->cpu_port = dev->mib_port_cnt - 1; - dev->host_mask = BIT(dev->cpu_port); - return 0; } @@ -1244,6 +1238,12 @@ static int ksz8795_switch_init(struct ksz_device *dev) dev->reg_mib_cnt = SWITCH_COUNTER_NUM; dev->mib_cnt = TOTAL_SWITCH_COUNTER_NUM; + dev->mib_port_cnt = TOTAL_PORT_NUM; + dev->phy_port_cnt = SWITCH_PORT_NUM; + + dev->cpu_port = dev->mib_port_cnt - 1; + dev->host_mask = BIT(dev->cpu_port); + i = dev->mib_port_cnt; dev->ports = devm_kzalloc(dev->dev, sizeof(struct ksz_port) * i, GFP_KERNEL); From patchwork Tue Dec 1 20:44:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943769 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D044C83013 for ; Tue, 1 Dec 2020 20:46:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 140C1217A0 for ; Tue, 1 Dec 2020 20:46:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729471AbgLAUpz (ORCPT ); Tue, 1 Dec 2020 15:45:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727773AbgLAUpx (ORCPT ); Tue, 1 Dec 2020 15:45:53 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C501C0613CF for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002sr-37; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002bj-3n; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 04/11] net: dsa: microchip: ksz8795: use reg_mib_cnt where possible Date: Tue, 1 Dec 2020 21:44:59 +0100 Message-Id: <20201201204506.13473-5-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The extra define SWITCH_COUNTER_NUM is a copy of the KSZ8795_COUNTER_NUM define. This patch initializes reg_mib_cnt with KSZ8795_COUNTER_NUM, makes use of reg_mib_cnt everywhere instead and removes the extra define. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - unchanged --- drivers/net/dsa/microchip/ksz8795.c | 6 +++--- drivers/net/dsa/microchip/ksz8795_reg.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 1164c745ce940..04a571bde7e6a 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -125,7 +125,7 @@ static void ksz8795_r_mib_cnt(struct ksz_device *dev, int port, u16 addr, u8 check; int loop; - ctrl_addr = addr + SWITCH_COUNTER_NUM * port; + ctrl_addr = addr + dev->reg_mib_cnt * port; ctrl_addr |= IND_ACC_TABLE(TABLE_MIB | TABLE_READ); mutex_lock(&dev->alu_mutex); @@ -156,7 +156,7 @@ static void ksz8795_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, u8 check; int loop; - addr -= SWITCH_COUNTER_NUM; + addr -= dev->reg_mib_cnt; ctrl_addr = (KS_MIB_TOTAL_RX_1 - KS_MIB_TOTAL_RX_0) * port; ctrl_addr += addr + KS_MIB_TOTAL_RX_0; ctrl_addr |= IND_ACC_TABLE(TABLE_MIB | TABLE_READ); @@ -1235,7 +1235,7 @@ static int ksz8795_switch_init(struct ksz_device *dev) dev->port_mask = BIT(dev->port_cnt) - 1; dev->port_mask |= dev->host_mask; - dev->reg_mib_cnt = SWITCH_COUNTER_NUM; + dev->reg_mib_cnt = KSZ8795_COUNTER_NUM; dev->mib_cnt = TOTAL_SWITCH_COUNTER_NUM; dev->mib_port_cnt = TOTAL_PORT_NUM; diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 3a50462df8fa9..25840719b9366 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -854,7 +854,6 @@ #define KSZ8795_COUNTER_NUM 0x20 #define TOTAL_KSZ8795_COUNTER_NUM (KSZ8795_COUNTER_NUM + 4) -#define SWITCH_COUNTER_NUM KSZ8795_COUNTER_NUM #define TOTAL_SWITCH_COUNTER_NUM TOTAL_KSZ8795_COUNTER_NUM /* Common names used by other drivers */ From patchwork Tue Dec 1 20:45:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943767 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06620C8300F for ; Tue, 1 Dec 2020 20:46:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B572920679 for ; Tue, 1 Dec 2020 20:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729255AbgLAUpy (ORCPT ); Tue, 1 Dec 2020 15:45:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725971AbgLAUpx (ORCPT ); Tue, 1 Dec 2020 15:45:53 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C9C6C0613D4 for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002ss-36; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002bm-4G; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 05/11] net: dsa: microchip: ksz8795: use mib_cnt where possible Date: Tue, 1 Dec 2020 21:45:00 +0100 Message-Id: <20201201204506.13473-6-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The variable mib_cnt is assigned with TOTAL_SWITCH_COUNTER_NUM. This value can also be derived from the array size of mib_names. This patch uses this calculated value instead, removes the extra define and uses mib_cnt everywhere possible instead of the static define TOTAL_SWITCH_COUNTER_NUM. Keeping it in a separate variable instead of using ARRAY_SIZE everywhere instead makes the driver more flexible for future use of devices with different amount of counters. Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - fixed missing dev variable in ksz8795_get_strings - improved the patch description about the variables purpose --- drivers/net/dsa/microchip/ksz8795.c | 9 +++++---- drivers/net/dsa/microchip/ksz8795_reg.h | 3 --- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 04a571bde7e6a..abdfc7f4d70ca 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -23,7 +23,7 @@ static const struct { char string[ETH_GSTRING_LEN]; -} mib_names[TOTAL_SWITCH_COUNTER_NUM] = { +} mib_names[] = { { "rx_hi" }, { "rx_undersize" }, { "rx_fragments" }, @@ -654,9 +654,10 @@ static enum dsa_tag_protocol ksz8795_get_tag_protocol(struct dsa_switch *ds, static void ksz8795_get_strings(struct dsa_switch *ds, int port, u32 stringset, uint8_t *buf) { + struct ksz_device *dev = ds->priv; int i; - for (i = 0; i < TOTAL_SWITCH_COUNTER_NUM; i++) { + for (i = 0; i < dev->mib_cnt; i++) { memcpy(buf + i * ETH_GSTRING_LEN, mib_names[i].string, ETH_GSTRING_LEN); } @@ -1236,7 +1237,7 @@ static int ksz8795_switch_init(struct ksz_device *dev) dev->port_mask |= dev->host_mask; dev->reg_mib_cnt = KSZ8795_COUNTER_NUM; - dev->mib_cnt = TOTAL_SWITCH_COUNTER_NUM; + dev->mib_cnt = ARRAY_SIZE(mib_names); dev->mib_port_cnt = TOTAL_PORT_NUM; dev->phy_port_cnt = SWITCH_PORT_NUM; @@ -1254,7 +1255,7 @@ static int ksz8795_switch_init(struct ksz_device *dev) dev->ports[i].mib.counters = devm_kzalloc(dev->dev, sizeof(u64) * - (TOTAL_SWITCH_COUNTER_NUM + 1), + (dev->mib_cnt + 1), GFP_KERNEL); if (!dev->ports[i].mib.counters) return -ENOMEM; diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 25840719b9366..c131224850135 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -852,9 +852,6 @@ #define SWITCH_PORT_NUM (TOTAL_PORT_NUM - 1) #define KSZ8795_COUNTER_NUM 0x20 -#define TOTAL_KSZ8795_COUNTER_NUM (KSZ8795_COUNTER_NUM + 4) - -#define TOTAL_SWITCH_COUNTER_NUM TOTAL_KSZ8795_COUNTER_NUM /* Common names used by other drivers */ From patchwork Tue Dec 1 20:45:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943759 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D50CC64E7A for ; Tue, 1 Dec 2020 20:45:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1713217A0 for ; Tue, 1 Dec 2020 20:45:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729518AbgLAUpz (ORCPT ); Tue, 1 Dec 2020 15:45:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729173AbgLAUpx (ORCPT ); Tue, 1 Dec 2020 15:45:53 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EC79C061A04 for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002st-38; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002bp-4o; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 06/11] net: dsa: microchip: ksz8795: use phy_port_cnt where possible Date: Tue, 1 Dec 2020 21:45:01 +0100 Message-Id: <20201201204506.13473-7-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The driver is currently hard coded to SWITCH_PORT_NUM being (TOTAL_PORT_NUM - 1) which is limited to 4 user ports for the ksz8795. The phy_port_cnt is referring to its user ports. The patch removes the extra define and use the assigned variable phy_port_cnt instead so the driver can be used on different switches. Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1: - based on "[PATCH v4 04/11] net: dsa: microchip: ksz8795: use port_cnt where possible" - lore: https://lore.kernel.org/netdev/20200803054442.20089-5-m.grzeschik@pengutronix.de/ v1 -> v2: - being more precise in the patch description about its purpose --- drivers/net/dsa/microchip/ksz8795.c | 20 ++++++++++---------- drivers/net/dsa/microchip/ksz8795_reg.h | 3 --- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index abdfc7f4d70ca..ee8e82dda3142 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -418,8 +418,8 @@ static void ksz8795_r_vlan_entries(struct ksz_device *dev, u16 addr) int i; ksz8795_r_table(dev, TABLE_VLAN, addr, &data); - addr *= 4; - for (i = 0; i < 4; i++) { + addr *= dev->phy_port_cnt; + for (i = 0; i < dev->phy_port_cnt; i++) { dev->vlan_cache[addr + i].table[0] = (u16)data; data >>= VLAN_TABLE_S; } @@ -433,7 +433,7 @@ static void ksz8795_r_vlan_table(struct ksz_device *dev, u16 vid, u16 *vlan) u64 buf; data = (u16 *)&buf; - addr = vid / 4; + addr = vid / dev->phy_port_cnt; index = vid & 3; ksz8795_r_table(dev, TABLE_VLAN, addr, &buf); *vlan = data[index]; @@ -447,7 +447,7 @@ static void ksz8795_w_vlan_table(struct ksz_device *dev, u16 vid, u16 vlan) u64 buf; data = (u16 *)&buf; - addr = vid / 4; + addr = vid / dev->phy_port_cnt; index = vid & 3; ksz8795_r_table(dev, TABLE_VLAN, addr, &buf); data[index] = vlan; @@ -692,12 +692,12 @@ static void ksz8795_port_stp_state_set(struct dsa_switch *ds, int port, switch (state) { case BR_STATE_DISABLED: data |= PORT_LEARN_DISABLE; - if (port < SWITCH_PORT_NUM) + if (port < dev->phy_port_cnt) member = 0; break; case BR_STATE_LISTENING: data |= (PORT_RX_ENABLE | PORT_LEARN_DISABLE); - if (port < SWITCH_PORT_NUM && + if (port < dev->phy_port_cnt && p->stp_state == BR_STATE_DISABLED) member = dev->host_mask | p->vid_member; break; @@ -721,7 +721,7 @@ static void ksz8795_port_stp_state_set(struct dsa_switch *ds, int port, break; case BR_STATE_BLOCKING: data |= PORT_LEARN_DISABLE; - if (port < SWITCH_PORT_NUM && + if (port < dev->phy_port_cnt && p->stp_state == BR_STATE_DISABLED) member = dev->host_mask | p->vid_member; break; @@ -1006,7 +1006,7 @@ static void ksz8795_config_cpu_port(struct dsa_switch *ds) ksz8795_port_setup(dev, dev->cpu_port, true); dev->member = dev->host_mask; - for (i = 0; i < SWITCH_PORT_NUM; i++) { + for (i = 0; i < dev->phy_port_cnt; i++) { p = &dev->ports[i]; /* Initialize to non-zero so that ksz_cfg_port_member() will @@ -1017,7 +1017,7 @@ static void ksz8795_config_cpu_port(struct dsa_switch *ds) ksz8795_port_stp_state_set(ds, i, BR_STATE_DISABLED); /* Last port may be disabled. */ - if (i == dev->port_cnt) + if (i == dev->phy_port_cnt) break; p->on = 1; p->phy = 1; @@ -1240,7 +1240,7 @@ static int ksz8795_switch_init(struct ksz_device *dev) dev->mib_cnt = ARRAY_SIZE(mib_names); dev->mib_port_cnt = TOTAL_PORT_NUM; - dev->phy_port_cnt = SWITCH_PORT_NUM; + dev->phy_port_cnt = dev->port_cnt; dev->cpu_port = dev->mib_port_cnt - 1; dev->host_mask = BIT(dev->cpu_port); diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index c131224850135..6377165a236fd 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -848,9 +848,6 @@ #define TOTAL_PORT_NUM 5 -/* Host port can only be last of them. */ -#define SWITCH_PORT_NUM (TOTAL_PORT_NUM - 1) - #define KSZ8795_COUNTER_NUM 0x20 /* Common names used by other drivers */ From patchwork Tue Dec 1 20:45:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943763 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 327ADC64E7B for ; Tue, 1 Dec 2020 20:46:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF15D206E0 for ; Tue, 1 Dec 2020 20:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729533AbgLAUpz (ORCPT ); Tue, 1 Dec 2020 15:45:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729183AbgLAUpx (ORCPT ); Tue, 1 Dec 2020 15:45:53 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 836FDC061A47 for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002su-38; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002bu-5I; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 07/11] net: dsa: microchip: remove superfluous num_ports assignment Date: Tue, 1 Dec 2020 21:45:02 +0100 Message-Id: <20201201204506.13473-8-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The variable num_ports is already assigned in the init function. The drivers individual init function already handles the different purpose of port_cnt vs port_cnt + 1. This patch removes the extra assignment of the variable. Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - improved the commit message to point out that port_cnt vs port_cnt + 1 difference is already handled in init --- drivers/net/dsa/microchip/ksz8795.c | 2 -- drivers/net/dsa/microchip/ksz9477.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index ee8e82dda3142..5cb05ae08f849 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -993,8 +993,6 @@ static void ksz8795_config_cpu_port(struct dsa_switch *ds) u8 remote; int i; - ds->num_ports = dev->port_cnt + 1; - /* Switch marks the maximum frame with extra byte as oversize. */ ksz_cfg(dev, REG_SW_CTRL_2, SW_LEGAL_PACKET_DISABLE, true); ksz_cfg(dev, S_TAIL_TAG_CTRL, SW_TAIL_TAG_ENABLE, true); diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index abfd3802bb517..2119965da10ae 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -1267,8 +1267,6 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds) struct ksz_port *p; int i; - ds->num_ports = dev->port_cnt; - for (i = 0; i < dev->port_cnt; i++) { if (dsa_is_cpu_port(ds, i) && (dev->cpu_ports & (1 << i))) { phy_interface_t interface; From patchwork Tue Dec 1 20:45:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943779 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BBECC83016 for ; Tue, 1 Dec 2020 20:46:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DDCA321D42 for ; Tue, 1 Dec 2020 20:46:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729857AbgLAUqg (ORCPT ); Tue, 1 Dec 2020 15:46:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbgLAUqe (ORCPT ); Tue, 1 Dec 2020 15:46:34 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89C13C061A4C for ; Tue, 1 Dec 2020 12:45:16 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWP-0002sw-Up; Tue, 01 Dec 2020 21:45:13 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002by-5o; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 08/11] net: dsa: microchip: ksz8795: align port_cnt usage with other microchip drivers Date: Tue, 1 Dec 2020 21:45:03 +0100 Message-Id: <20201201204506.13473-9-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The ksz8795 driver is using port_cnt differently to the other microchip DSA drivers. It sets it to the external physical port count, than the whole port count (including the cpu port). This patch is aligning the variables purpose with the other microchip drivers. Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - improved comment in port_cnt assignment, rather than removing it --- drivers/net/dsa/microchip/ksz8795.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 5cb05ae08f849..96029e5a914fb 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1184,7 +1184,7 @@ static const struct ksz_chip_data ksz8795_switch_chips[] = { .num_alus = 0, .num_statics = 8, .cpu_ports = 0x10, /* can be configured as cpu port */ - .port_cnt = 4, /* total physical port count */ + .port_cnt = 5, /* total cpu and user ports */ }, { .chip_id = 0x8794, @@ -1193,7 +1193,7 @@ static const struct ksz_chip_data ksz8795_switch_chips[] = { .num_alus = 0, .num_statics = 8, .cpu_ports = 0x10, /* can be configured as cpu port */ - .port_cnt = 3, /* total physical port count */ + .port_cnt = 4, /* total cpu and user ports */ }, { .chip_id = 0x8765, @@ -1202,7 +1202,7 @@ static const struct ksz_chip_data ksz8795_switch_chips[] = { .num_alus = 0, .num_statics = 8, .cpu_ports = 0x10, /* can be configured as cpu port */ - .port_cnt = 4, /* total physical port count */ + .port_cnt = 5, /* total cpu and user ports */ }, }; @@ -1238,7 +1238,7 @@ static int ksz8795_switch_init(struct ksz_device *dev) dev->mib_cnt = ARRAY_SIZE(mib_names); dev->mib_port_cnt = TOTAL_PORT_NUM; - dev->phy_port_cnt = dev->port_cnt; + dev->phy_port_cnt = dev->port_cnt - 1; dev->cpu_port = dev->mib_port_cnt - 1; dev->host_mask = BIT(dev->cpu_port); @@ -1260,7 +1260,7 @@ static int ksz8795_switch_init(struct ksz_device *dev) } /* set the real number of ports */ - dev->ds->num_ports = dev->port_cnt + 1; + dev->ds->num_ports = dev->port_cnt; return 0; } From patchwork Tue Dec 1 20:45:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943765 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 007D5C71156 for ; Tue, 1 Dec 2020 20:46:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C92B217A0 for ; Tue, 1 Dec 2020 20:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729343AbgLAUpy (ORCPT ); Tue, 1 Dec 2020 15:45:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbgLAUpx (ORCPT ); Tue, 1 Dec 2020 15:45:53 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 743E6C0617A6 for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002sx-37; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002c1-6L; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 09/11] net: dsa: microchip: remove usage of mib_port_count Date: Tue, 1 Dec 2020 21:45:04 +0100 Message-Id: <20201201204506.13473-10-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The variable mib_port_cnt has the same meaning as port_cnt. This driver removes the extra variable and is using port_cnt everywhere instead. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - unchanged --- drivers/net/dsa/microchip/ksz8795.c | 11 +++++------ drivers/net/dsa/microchip/ksz9477.c | 12 +++++------- drivers/net/dsa/microchip/ksz_common.c | 4 ++-- drivers/net/dsa/microchip/ksz_common.h | 1 - 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 96029e5a914fb..7b5c9283712e4 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -761,7 +761,7 @@ static void ksz8795_flush_dyn_mac_table(struct ksz_device *dev, int port) } else { /* Flush all ports. */ first = 0; - cnt = dev->mib_port_cnt; + cnt = dev->port_cnt; } for (index = first; index < cnt; index++) { p = &dev->ports[index]; @@ -1237,18 +1237,17 @@ static int ksz8795_switch_init(struct ksz_device *dev) dev->reg_mib_cnt = KSZ8795_COUNTER_NUM; dev->mib_cnt = ARRAY_SIZE(mib_names); - dev->mib_port_cnt = TOTAL_PORT_NUM; dev->phy_port_cnt = dev->port_cnt - 1; - dev->cpu_port = dev->mib_port_cnt - 1; + dev->cpu_port = dev->port_cnt - 1; dev->host_mask = BIT(dev->cpu_port); - i = dev->mib_port_cnt; - dev->ports = devm_kzalloc(dev->dev, sizeof(struct ksz_port) * i, + dev->ports = devm_kzalloc(dev->dev, + dev->port_cnt * sizeof(struct ksz_port), GFP_KERNEL); if (!dev->ports) return -ENOMEM; - for (i = 0; i < dev->mib_port_cnt; i++) { + for (i = 0; i < dev->port_cnt; i++) { mutex_init(&dev->ports[i].mib.cnt_mutex); dev->ports[i].mib.counters = devm_kzalloc(dev->dev, diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c index 2119965da10ae..42e647b67abd5 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -478,7 +478,7 @@ static void ksz9477_flush_dyn_mac_table(struct ksz_device *dev, int port) SW_FLUSH_OPTION_M << SW_FLUSH_OPTION_S, SW_FLUSH_OPTION_DYN_MAC << SW_FLUSH_OPTION_S); - if (port < dev->mib_port_cnt) { + if (port < dev->port_cnt) { /* flush individual port */ ksz_pread8(dev, port, P_STP_CTRL, &data); if (!(data & PORT_LEARN_DISABLE)) @@ -1317,7 +1317,7 @@ static void ksz9477_config_cpu_port(struct dsa_switch *ds) dev->member = dev->host_mask; - for (i = 0; i < dev->mib_port_cnt; i++) { + for (i = 0; i < dev->port_cnt; i++) { if (i == dev->cpu_port) continue; p = &dev->ports[i]; @@ -1444,7 +1444,6 @@ static int ksz9477_switch_detect(struct ksz_device *dev) return ret; /* Number of ports can be reduced depending on chip. */ - dev->mib_port_cnt = TOTAL_PORT_NUM; dev->phy_port_cnt = 5; /* Default capability is gigabit capable. */ @@ -1461,7 +1460,6 @@ static int ksz9477_switch_detect(struct ksz_device *dev) /* Chip does not support gigabit. */ if (data8 & SW_QW_ABLE) dev->features &= ~GBIT_SUPPORT; - dev->mib_port_cnt = 3; dev->phy_port_cnt = 2; } else { dev_info(dev->dev, "Found KSZ9477 or compatible\n"); @@ -1564,12 +1562,12 @@ static int ksz9477_switch_init(struct ksz_device *dev) dev->reg_mib_cnt = SWITCH_COUNTER_NUM; dev->mib_cnt = TOTAL_SWITCH_COUNTER_NUM; - i = dev->mib_port_cnt; - dev->ports = devm_kzalloc(dev->dev, sizeof(struct ksz_port) * i, + dev->ports = devm_kzalloc(dev->dev, + dev->port_cnt * sizeof(struct ksz_port), GFP_KERNEL); if (!dev->ports) return -ENOMEM; - for (i = 0; i < dev->mib_port_cnt; i++) { + for (i = 0; i < dev->port_cnt; i++) { mutex_init(&dev->ports[i].mib.cnt_mutex); dev->ports[i].mib.counters = devm_kzalloc(dev->dev, diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 7002436e62b48..cf743133b0b93 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -72,7 +72,7 @@ static void ksz_mib_read_work(struct work_struct *work) struct ksz_port *p; int i; - for (i = 0; i < dev->mib_port_cnt; i++) { + for (i = 0; i < dev->port_cnt; i++) { if (dsa_is_unused_port(dev->ds, i)) continue; @@ -103,7 +103,7 @@ void ksz_init_mib_timer(struct ksz_device *dev) INIT_DELAYED_WORK(&dev->mib_read, ksz_mib_read_work); - for (i = 0; i < dev->mib_port_cnt; i++) + for (i = 0; i < dev->port_cnt; i++) dev->dev_ops->port_init_cnt(dev, i); } EXPORT_SYMBOL_GPL(ksz_init_mib_timer); diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h index 629700a637024..720f22275c844 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -71,7 +71,6 @@ struct ksz_device { int port_cnt; int reg_mib_cnt; int mib_cnt; - int mib_port_cnt; phy_interface_t compat_interface; u32 regs_size; bool phy_errata_9477; From patchwork Tue Dec 1 20:45:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943785 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACF7FC83017 for ; Tue, 1 Dec 2020 20:46:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 796C420679 for ; Tue, 1 Dec 2020 20:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729949AbgLAUqh (ORCPT ); Tue, 1 Dec 2020 15:46:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbgLAUqe (ORCPT ); Tue, 1 Dec 2020 15:46:34 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93FA8C061A4A for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002sy-37; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002c4-6p; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 10/11] net: dsa: microchip: ksz8795: use port_cnt instead of TOTOAL_PORT_NUM Date: Tue, 1 Dec 2020 21:45:05 +0100 Message-Id: <20201201204506.13473-11-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org To get the driver working with other chips using different port counts the dyn_mac_table should be flushed depending on the amount of available ports. This patch remove the extra define TOTOAL_PORT_NUM and is making use of the dynamic port_cnt variable instead. Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1: - based on "[PATCH v4 05/11] net: dsa: microchip: ksz8795: dynamica allocate memory for flush_dyn_mac_table" - lore: https://lore.kernel.org/netdev/20200803054442.20089-6-m.grzeschik@pengutronix.de/ v1 -> v2: - renamed patch to clarify the purpose - based on: https://lore.kernel.org/netdev/20201118220357.22292-11-m.grzeschik@pengutronix.de/ - using DSA_MAX_PORTS instead of dynamic kzalloc allocation - improved patch description --- drivers/net/dsa/microchip/ksz8795.c | 4 ++-- drivers/net/dsa/microchip/ksz8795_reg.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index 7b5c9283712e4..b13ac57ab8bba 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -751,11 +751,11 @@ static void ksz8795_port_stp_state_set(struct dsa_switch *ds, int port, static void ksz8795_flush_dyn_mac_table(struct ksz_device *dev, int port) { - u8 learn[TOTAL_PORT_NUM]; + u8 learn[DSA_MAX_PORTS]; int first, index, cnt; struct ksz_port *p; - if ((uint)port < TOTAL_PORT_NUM) { + if ((uint)port < dev->port_cnt) { first = port; cnt = port + 1; } else { diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 6377165a236fd..681d19ab27b89 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -846,8 +846,6 @@ #define KS_PRIO_IN_REG 4 -#define TOTAL_PORT_NUM 5 - #define KSZ8795_COUNTER_NUM 0x20 /* Common names used by other drivers */ From patchwork Tue Dec 1 20:45:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 11943761 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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B10BBC71155 for ; Tue, 1 Dec 2020 20:46:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 61046206E0 for ; Tue, 1 Dec 2020 20:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729390AbgLAUpy (ORCPT ); Tue, 1 Dec 2020 15:45:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727764AbgLAUpx (ORCPT ); Tue, 1 Dec 2020 15:45:53 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79B83C0617A7 for ; Tue, 1 Dec 2020 12:45:13 -0800 (PST) Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kkCWN-0002sz-35; Tue, 01 Dec 2020 21:45:11 +0100 Received: from mgr by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kkCWK-0002c7-7L; Tue, 01 Dec 2020 21:45:08 +0100 From: Michael Grzeschik To: netdev@vger.kernel.org Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net, kernel@pengutronix.de, matthias.schiffer@ew.tq-group.com, woojung.huh@microchip.com, UNGLinuxDriver@microchip.com Subject: [PATCH v2 11/11] net: dsa: microchip: ksz8795: use num_vlans where possible Date: Tue, 1 Dec 2020 21:45:06 +0100 Message-Id: <20201201204506.13473-12-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201204506.13473-1-m.grzeschik@pengutronix.de> References: <20201201204506.13473-1-m.grzeschik@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: netdev@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The value of the define VLAN_TABLE_ENTRIES can be derived from num_vlans. This patch is using the variable num_vlans instead and removes the extra define. Reviewed-by: Andrew Lunn Reviewed-by: Florian Fainelli Signed-off-by: Michael Grzeschik --- v1 -> v2: - unchanged --- drivers/net/dsa/microchip/ksz8795.c | 2 +- drivers/net/dsa/microchip/ksz8795_reg.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz8795.c b/drivers/net/dsa/microchip/ksz8795.c index b13ac57ab8bba..c973db101b729 100644 --- a/drivers/net/dsa/microchip/ksz8795.c +++ b/drivers/net/dsa/microchip/ksz8795.c @@ -1084,7 +1084,7 @@ static int ksz8795_setup(struct dsa_switch *ds) (BROADCAST_STORM_VALUE * BROADCAST_STORM_PROT_RATE) / 100); - for (i = 0; i < VLAN_TABLE_ENTRIES; i++) + for (i = 0; i < (dev->num_vlans / 4); i++) ksz8795_r_vlan_entries(dev, i); /* Setup STP address for STP operation. */ diff --git a/drivers/net/dsa/microchip/ksz8795_reg.h b/drivers/net/dsa/microchip/ksz8795_reg.h index 681d19ab27b89..40372047d40d8 100644 --- a/drivers/net/dsa/microchip/ksz8795_reg.h +++ b/drivers/net/dsa/microchip/ksz8795_reg.h @@ -989,7 +989,6 @@ #define TAIL_TAG_OVERRIDE BIT(6) #define TAIL_TAG_LOOKUP BIT(7) -#define VLAN_TABLE_ENTRIES (4096 / 4) #define FID_ENTRIES 128 #endif