Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3989142pxb; Mon, 4 Oct 2021 14:33:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr0ZsfBhSSI2ZDJaNkXq9aEhDKzXyp7X3nL0sZOcDlnDhcwvWVsq8CS87qSMstr2rSP/7W X-Received: by 2002:a17:907:2bc2:: with SMTP id gv2mr328190ejc.433.1633383226727; Mon, 04 Oct 2021 14:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633383226; cv=none; d=google.com; s=arc-20160816; b=GyE4UCtOzm6LkXJOUhUrhBCJ5W+afwnyCGg5dfVKwSjPGxI0e2/7NEqyxVAylbYOtT t5xYaily0PX0rMvxYjM52NkollgFwKaWDYMQu+F9DqhbYa/X+cAbxT2HjaWHbCYlwuLG Pb17F82igg3jlzN3R/TBmYfLORFNUeCBmzSju4r8fjYjNnMRKZKo07vrpRNeoaWNu/Af Wrhg71fzHdRosS5hYdHLI+DZ5jgftHtw82OwXfNrAN/ygrW/g+fsAv9FRHHlTESFl7Nx jRvErDEYPFomqEw1wMMD8ALiv9E3jMUY+4pQP5n2NoFWMlynYS9+iFSGjQFA/QLRXXOS iLig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wTdI6czo7Dtt9E5pLkCKIUR/7+3YDVsMq+FOiG08CGY=; b=XEFfVXjjErWozsl+CZHFDBYPDe9lLxcq8VfkQtmMzaoZ0o1H33r5BQHrkZx51DbMXh QWCOqC+irSF8Gko2xBNKxGk47U+djvilM4+8iGqe+pXWtopLo/8whGpTOPhT7xsTWXlf ScjbC17zInYMVZAS8pdMAn/Kusx7ilZEl7Vi5abeR/oodjGqWbvnpf1JWqXc6prp9IZ3 9pkbCCTkXFD2s11IB3lElbg2DORMRtO+vY0nVoxEn4OGynYctvfTLcAqywQbhLhKtdFA 2CoqDoHTKYkieBMaNRitk8Q+W4Mg0S36jOnh+fDo/hEGiC5Hej0EG8NgzNd0CDD/99Ac kZqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="l/UXXRg+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si22800387eds.584.2021.10.04.14.33.22; Mon, 04 Oct 2021 14:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="l/UXXRg+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236873AbhJDNh6 (ORCPT + 99 others); Mon, 4 Oct 2021 09:37:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:48752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237981AbhJDNfp (ORCPT ); Mon, 4 Oct 2021 09:35:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CF48E63236; Mon, 4 Oct 2021 13:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353381; bh=tYr1UR5UVV9/l4UvwpgkGg2+Y55MDBz5RAQC9WXHaPU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l/UXXRg+Q5OPMxr1ew52G9uqBjneS30AMrvdhDMGeEdrjWqEPRSiK31J5feItLVWR TgDrRWmlVWKKx95430w/fmxKX03HZa1Rkz3oUbLJbq8pYviMW32Ng7aUwX4N6VqaTy JswZO/+cnW/Nk+7eho6JPmkwQg2hrGSIbzAOjeSA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrew Lunn , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 107/172] dsa: mv88e6xxx: Fix MTU definition Date: Mon, 4 Oct 2021 14:52:37 +0200 Message-Id: <20211004125048.440210951@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Lunn [ Upstream commit b92ce2f54c0f0ff781e914ec189c25f7bf1b1ec2 ] 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. The VLAN header also needs to be included when the frame size it per port, but not when it is global. Fixes: 1baf0fac10fb ("net: dsa: mv88e6xxx: Use chip-wide max frame size for MTU") Reported by: 曹煜 Signed-off-by: Andrew Lunn Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/mv88e6xxx/chip.c | 12 ++++++------ drivers/net/dsa/mv88e6xxx/global1.c | 2 ++ drivers/net/dsa/mv88e6xxx/port.c | 2 ++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index f99f09c50722..014950a343f4 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, 10218); 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 - VLAN_ETH_HLEN - ETH_FCS_LEN; else if (chip->info->ops->set_max_frame_size) - return 1632; - return 1522; + return 1632 - VLAN_ETH_HLEN - ETH_FCS_LEN; + return 1522 - VLAN_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/global1.c b/drivers/net/dsa/mv88e6xxx/global1.c index 815b0f681d69..5848112036b0 100644 --- a/drivers/net/dsa/mv88e6xxx/global1.c +++ b/drivers/net/dsa/mv88e6xxx/global1.c @@ -232,6 +232,8 @@ int mv88e6185_g1_set_max_frame_size(struct mv88e6xxx_chip *chip, int mtu) u16 val; int err; + mtu += ETH_HLEN + ETH_FCS_LEN; + err = mv88e6xxx_g1_read(chip, MV88E6XXX_G1_CTL1, &val); if (err) return err; diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c index f77e2ee64a60..451028c57af8 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 += VLAN_ETH_HLEN + ETH_FCS_LEN; + err = mv88e6xxx_port_read(chip, port, MV88E6XXX_PORT_CTL2, ®); if (err) return err; -- 2.33.0