From patchwork Mon May 24 21:33:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 12277011 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 B08FFC2B9F8 for ; Mon, 24 May 2021 21:33:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F3E16140F for ; Mon, 24 May 2021 21:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233992AbhEXVfN (ORCPT ); Mon, 24 May 2021 17:35:13 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:54594 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233842AbhEXVfI (ORCPT ); Mon, 24 May 2021 17:35:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=dfikKytAvyUVSh8ZdDvtUgmiTaKRN4fTP7dHWQTgSAw=; b=HwxkJN9iuEpft17TzvJBXZuDJq KR8b5l4PwuOqn5+uG9Yd+1DNhlU4nYI8T60tT+8/tfqwNkIt5VFOAol/pnVti5olDnSfcXuOQ9a03 RoywOBhE1sW2g5QhSrgDvc4lxT9z1Vg0nBlGqrGcNjEgFSdf59U5fbTrUVsLBwveNVRw=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1llICb-00624u-Er; Mon, 24 May 2021 23:33:33 +0200 From: Andrew Lunn To: David Miller , Jakub Kicinski Cc: netdev , Florian Fainelli , Vladimir Oltean , cao88yu@gmail.com, Andrew Lunn Subject: [PATCH net 1/3] dsa: mv88e6xxx: 6161: Use chip wide MAX MTU Date: Mon, 24 May 2021 23:33:11 +0200 Message-Id: <20210524213313.1437891-2-andrew@lunn.ch> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524213313.1437891-1-andrew@lunn.ch> References: <20210524213313.1437891-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The datasheets suggests the 6161 uses a per port setting for jumbo frames. Testing has however shown this is not correct, it uses the old style chip wide MTU control. Change the ops in the 6161 structure to reflect this. Fixes: 1baf0fac10fb ("net: dsa: mv88e6xxx: Use chip-wide max frame size for MTU") Reported by: 曹煜 Signed-off-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index eca285aaf72f..cbedaee3cefd 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3638,7 +3638,6 @@ static const struct mv88e6xxx_ops mv88e6161_ops = { .port_set_ucast_flood = mv88e6352_port_set_ucast_flood, .port_set_mcast_flood = mv88e6352_port_set_mcast_flood, .port_set_ether_type = mv88e6351_port_set_ether_type, - .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, .port_pause_limit = mv88e6097_port_pause_limit, .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, @@ -3663,6 +3662,7 @@ static const struct mv88e6xxx_ops mv88e6161_ops = { .avb_ops = &mv88e6165_avb_ops, .ptp_ops = &mv88e6165_ptp_ops, .phylink_validate = mv88e6185_phylink_validate, + .set_max_frame_size = mv88e6185_g1_set_max_frame_size, }; static const struct mv88e6xxx_ops mv88e6165_ops = { From patchwork Mon May 24 21:33:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 12277007 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 AA997C2B9F7 for ; Mon, 24 May 2021 21:33:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86E3F6140F for ; Mon, 24 May 2021 21:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233981AbhEXVfK (ORCPT ); Mon, 24 May 2021 17:35:10 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:54592 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233878AbhEXVfI (ORCPT ); Mon, 24 May 2021 17:35:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=LfATR/1wuTk9YRmWgt2HgpopO+EA9nb5Ftwm2OuYlcs=; b=w47qquFPKP5LEbwJJ9lZX3rwZx 0IDjYgmcadm/sckFUQFXjiEUYTNKizzikv9frOJJ/LPNQpjNcY3DrmVk6Dgl+0HY93hXUhqUAcDnv 3YBFIgDrlAB38TtJ2OQuOgf/9+A4c//7aMPuya7LdaAPFxgH/VdJlUV+bHZBtsUBGI0Y=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1llICb-00624x-Fy; Mon, 24 May 2021 23:33:33 +0200 From: Andrew Lunn To: David Miller , Jakub Kicinski Cc: netdev , Florian Fainelli , Vladimir Oltean , cao88yu@gmail.com, Andrew Lunn Subject: [PATCH net 2/3] dsa: mv88e6xxx: Fix MTU definition Date: Mon, 24 May 2021 23:33:12 +0200 Message-Id: <20210524213313.1437891-3-andrew@lunn.ch> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524213313.1437891-1-andrew@lunn.ch> References: <20210524213313.1437891-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The MTU passed to the DSA driver is the payload size, typically 1500. However, the switch uses the frame size when applying restrictions. Adjust the MTU with the size of the Ethernet header and the frame checksum. Fixes: 1baf0fac10fb ("net: dsa: mv88e6xxx: Use chip-wide max frame size for MTU") Reported by: 曹煜 Signed-off-by: Andrew Lunn --- drivers/net/dsa/mv88e6xxx/chip.c | 12 ++++++------ drivers/net/dsa/mv88e6xxx/port.c | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index cbedaee3cefd..593dc734582e 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -2775,8 +2775,8 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) if (err) return err; - /* Port Control 2: don't force a good FCS, set the maximum frame size to - * 10240 bytes, disable 802.1q tags checking, don't discard tagged or + /* Port Control 2: don't force a good FCS, set the MTU size to + * 10222 bytes, disable 802.1q tags checking, don't discard tagged or * untagged frames on this port, do a destination address lookup on all * received packets as usual, disable ARP mirroring and don't send a * copy of all transmitted/received frames on this port to the CPU. @@ -2795,7 +2795,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) return err; if (chip->info->ops->port_set_jumbo_size) { - err = chip->info->ops->port_set_jumbo_size(chip, port, 10240); + err = chip->info->ops->port_set_jumbo_size(chip, port, 10222); if (err) return err; } @@ -2885,10 +2885,10 @@ static int mv88e6xxx_get_max_mtu(struct dsa_switch *ds, int port) struct mv88e6xxx_chip *chip = ds->priv; if (chip->info->ops->port_set_jumbo_size) - return 10240; + return 10240 - ETH_HLEN - ETH_FCS_LEN; else if (chip->info->ops->set_max_frame_size) - return 1632; - return 1522; + return 1632 - ETH_HLEN - ETH_FCS_LEN; + return 1522 - ETH_HLEN - ETH_FCS_LEN; } static int mv88e6xxx_change_mtu(struct dsa_switch *ds, int port, int new_mtu) diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index f77e2ee64a60..28664ea91244 100644 --- a/drivers/net/dsa/mv88e6xxx/port.c +++ b/drivers/net/dsa/mv88e6xxx/port.c @@ -1277,6 +1277,8 @@ int mv88e6165_port_set_jumbo_size(struct mv88e6xxx_chip *chip, int port, u16 reg; int err; + size += ETH_HLEN + ETH_FCS_LEN; + err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, ®); if (err) return err; From patchwork Mon May 24 21:33:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Lunn X-Patchwork-Id: 12277009 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=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 38398C04FF3 for ; Mon, 24 May 2021 21:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 176746140F for ; Mon, 24 May 2021 21:33:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233985AbhEXVfL (ORCPT ); Mon, 24 May 2021 17:35:11 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:54590 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233869AbhEXVfI (ORCPT ); Mon, 24 May 2021 17:35:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=RkFsi9eMCUiB30yNLMnCHAZOBrMwGA0B0YzGmZfisS4=; b=lPwxN5C23wkBgst7w/+Sc7yC1p 5R50VUhdfwiGAImuPhGsdqJ62xp8uSbTTAsO548XCft/MJI+HtutGGvNxo9kajlfHLpBLRQuuDdJS 7Kdsoi0LinmfO6Ehd2e72PnDVcit+1zkCgn1199Yh7QwQFD/mw99Tq1cvMBP64V8ka/k=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1llICb-006250-HA; Mon, 24 May 2021 23:33:33 +0200 From: Andrew Lunn To: David Miller , Jakub Kicinski Cc: netdev , Florian Fainelli , Vladimir Oltean , cao88yu@gmail.com, Andrew Lunn Subject: [PATCH net 3/3] net: dsa: Include tagger overhead when setting MTU for DSA and CPU ports Date: Mon, 24 May 2021 23:33:13 +0200 Message-Id: <20210524213313.1437891-4-andrew@lunn.ch> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524213313.1437891-1-andrew@lunn.ch> References: <20210524213313.1437891-1-andrew@lunn.ch> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Same members of the Marvell Ethernet switches impose MTU restrictions on ports used for connecting to the CPU or DSA. If the MTU is set too low, tagged frames will be discarded. Ensure the tagger overhead is included in setting the MTU for DSA and CPU ports. Fixes: 1baf0fac10fb ("net: dsa: mv88e6xxx: Use chip-wide max frame size for MTU") Reported by: 曹煜 Signed-off-by: Andrew Lunn --- net/dsa/switch.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index 9bf8e20ecdf3..48c737b0b802 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -67,14 +67,26 @@ static bool dsa_switch_mtu_match(struct dsa_switch *ds, int port, static int dsa_switch_mtu(struct dsa_switch *ds, struct dsa_notifier_mtu_info *info) { - int port, ret; + struct dsa_port *cpu_dp; + int port, ret, overhead; if (!ds->ops->port_change_mtu) return -EOPNOTSUPP; for (port = 0; port < ds->num_ports; port++) { if (dsa_switch_mtu_match(ds, port, info)) { - ret = ds->ops->port_change_mtu(ds, port, info->mtu); + overhead = 0; + if (dsa_is_cpu_port(ds, port)) { + cpu_dp = dsa_to_port(ds, port); + overhead = cpu_dp->tag_ops->overhead; + } + if (dsa_is_dsa_port(ds, port)) { + cpu_dp = dsa_to_port(ds, port)->cpu_dp; + overhead = cpu_dp->tag_ops->overhead; + } + + ret = ds->ops->port_change_mtu(ds, port, + info->mtu + overhead); if (ret) return ret; }