From mboxrd@z Thu Jan 1 00:00:00 1970 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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; } -- 2.31.1