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=-8.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT 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 E1F64C43381 for ; Wed, 27 Feb 2019 22:11:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94467213A2 for ; Wed, 27 Feb 2019 22:11:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="dpMNA/G7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbfB0WLw (ORCPT ); Wed, 27 Feb 2019 17:11:52 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:39757 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729412AbfB0WLv (ORCPT ); Wed, 27 Feb 2019 17:11:51 -0500 Received: by mail-lj1-f196.google.com with SMTP id g80so15296922ljg.6 for ; Wed, 27 Feb 2019 14:11:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=YB8vlRK6v26l7rZcvhq7OzDTvSLCwqqVBxYauiJlXgo=; b=dpMNA/G7dq9rPIKfhR6s4N6iMdh8xOqSRsOXRNX1prMiqAz7UsFvT2P8qNGiMtH3o7 9ZXma4Qu52ss7ixmnYy+iBYn3hDmKufHcCT0LaK47/FcuwrYB4Yt5i4wfFCNeO0E071j fUrxPnj3TNcM14NlHkPrE4JcxYIlMsGz+/DOsHSTPPUI6XPy0y659fb2vdrs2qlBak5y KcDfBSGRWW6FRvqWLDpIWxkt6hjpSbWpFTchksmSG+YsbpBMuuSXe2BqdY8+THNhGhP6 D2pQ64S1pOmJ7sTVoUfrnBvAPScAqh6ixk3s8bxuMPcdsDF2tIbvhhMe4ZKeRPCv+lcA Pc5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=YB8vlRK6v26l7rZcvhq7OzDTvSLCwqqVBxYauiJlXgo=; b=hf+yQTMc5JeBFZPmm7JKcRT287gBFkjeOgqMuqDeGrtD1cPb9LEInH5L/rq+R9if8f tfzU1HUeznPL/GfPlzf3ECRrPGKo4sRyQozXxMo5cXLkDLFmRrqeccyTrofxFOUjJ6+h od2dNfwIFl2IODrnNbme/QQY+h6AKe2lz4DpHZrBAzQ+hL/1lTBQk3MxLUPyj5+Z0P/f 18CPQlAq4FVfyBe3ausJYPFLIEDcQuSsUdz4H3v16trPnIPC28tW9seIgXq18R21sYQx qoVgawn2adPf6Tbtah95ZaiexPZrFWg/Qgm9oHmuZUw4bTwAHOVqReLxkmhhe9B0p4od TxnQ== X-Gm-Message-State: AHQUAua8ZoSqACQUB0yvyd56pXQ4cjXYhqsh5Aijuhm5svSiLWXoH3Fo 3qZuAUo8JA0vrmrnw9C9MjnPAxI5lpE= X-Google-Smtp-Source: AHgI3IZ0lAKrevhQ9FyZ/e9m8AnXnU/37p1ZI4XyqvrKjg6y6Ri0IRFjH7Kv8Kq8hD2LwqUDtiV5oA== X-Received: by 2002:a2e:9150:: with SMTP id q16mr2800638ljg.18.1551305508579; Wed, 27 Feb 2019 14:11:48 -0800 (PST) Received: from centauri.lan (h-229-118.A785.priv.bahnhof.se. [5.150.229.118]) by smtp.gmail.com with ESMTPSA id q15sm3735338lje.89.2019.02.27.14.11.46 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 27 Feb 2019 14:11:47 -0800 (PST) Date: Wed, 27 Feb 2019 23:11:45 +0100 From: Niklas Cassel To: Greg KH Cc: stable@vger.kernel.org Subject: Re: stable backport request for stmmac DSA tag fixes Message-ID: <20190227221145.GA19221@centauri.lan> References: <20190227161911.GA18873@centauri.lan> <20190227163827.GA25138@kroah.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline In-Reply-To: <20190227163827.GA25138@kroah.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Feb 27, 2019 at 05:38:27PM +0100, Greg KH wrote: > On Wed, Feb 27, 2019 at 05:19:11PM +0100, Niklas Cassel wrote: > > Hello, > > > > I would like to request: > > > > 8cad443eacf6 ("net: stmmac: Fix reception of Broadcom switches tags") > > (was first included in v4.16) > > > > and > > > > 565020aaeebf ("net: stmmac: Disable ACS Feature for GMAC >= 4") > > (was first included in v4.17) > > This patch looks like it needs to be applied to 4.9.y as well, can you > provide a backported version? Actually, the second patch depends on the first patch, since it changes code added by the first patch, so these should be backported together. However, there was a trivial one liner conflict in v4.9 when cherry-picking the first patch, so I attached a backport. After this, the second patch applies on v4.9 without conflicts. Kind regards, Niklas > > > to be backported to linux-stable/linux-4.14.y > > > > Without these, packets will get stripped twice (corrupted) > > when using stmmac with switches that uses DSA tags. > > Both now queued up, thanks. > > greg k-h --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-net-stmmac-Fix-reception-of-Broadcom-switches-tags.patch" >From 7228f30ed3900af939fd69e807b7a35ce545efe9 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Thu, 18 Jan 2018 15:12:21 -0800 Subject: [PATCH] net: stmmac: Fix reception of Broadcom switches tags Broadcom tags inserted by Broadcom switches put a 4 byte header after the MAC SA and before the EtherType, which may look like some sort of 0 length LLC/SNAP packet (tcpdump and wireshark do think that way). With ACS enabled in stmmac the packets were truncated to 8 bytes on reception, whereas clearing this bit allowed normal reception to occur. In order to make that possible, we need to pass a net_device argument to the different core_init() functions and we are dependent on the Broadcom tagger padding packets correctly (which it now does). To be as little invasive as possible, this is only done for gmac1000 when the network device is DSA-enabled (netdev_uses_dsa() returns true). Signed-off-by: Florian Fainelli Acked-by: Giuseppe Cavallaro Signed-off-by: David S. Miller --- drivers/net/ethernet/stmicro/stmmac/common.h | 2 +- .../net/ethernet/stmicro/stmmac/dwmac1000_core.c | 12 +++++++++++- .../net/ethernet/stmicro/stmmac/dwmac100_core.c | 15 +++++++++++++-- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 12 +++++++++++- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index 6d2de4e01f6d..b35299620052 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -450,7 +450,7 @@ struct mac_device_info; /* Helpers to program the MAC core */ struct stmmac_ops { /* MAC core initialization */ - void (*core_init)(struct mac_device_info *hw, int mtu); + void (*core_init)(struct mac_device_info *hw, struct net_device *dev); /* Enable and verify that the IPC module is supported */ int (*rx_ipc)(struct mac_device_info *hw); /* Dump MAC registers */ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index 7d19029e2564..b953ea2f808f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c @@ -29,18 +29,28 @@ #include #include #include +#include #include #include "stmmac_pcs.h" #include "dwmac1000.h" -static void dwmac1000_core_init(struct mac_device_info *hw, int mtu) +static void dwmac1000_core_init(struct mac_device_info *hw, + struct net_device *dev) { void __iomem *ioaddr = hw->pcsr; u32 value = readl(ioaddr + GMAC_CONTROL); + int mtu = dev->mtu; /* Configure GMAC core */ value |= GMAC_CORE_INIT; + /* Clear ACS bit because Ethernet switch tagging formats such as + * Broadcom tags can look like invalid LLC/SNAP packets and cause the + * hardware to truncate packets on reception. + */ + if (netdev_uses_dsa(dev)) + value &= ~GMAC_CONTROL_ACS; + if (mtu > 1500) value |= GMAC_CONTROL_2K; if (mtu > 2000) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c index 6418b2e07619..3e2331d01cd2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac100_core.c @@ -29,15 +29,26 @@ *******************************************************************************/ #include +#include #include #include "dwmac100.h" -static void dwmac100_core_init(struct mac_device_info *hw, int mtu) +static void dwmac100_core_init(struct mac_device_info *hw, + struct net_device *dev) { void __iomem *ioaddr = hw->pcsr; u32 value = readl(ioaddr + MAC_CONTROL); - writel((value | MAC_CORE_INIT), ioaddr + MAC_CONTROL); + value |= MAC_CORE_INIT; + + /* Clear ASTP bit because Ethernet switch tagging formats such as + * Broadcom tags can look like invalid LLC/SNAP packets and cause the + * hardware to truncate packets on reception. + */ + if (netdev_uses_dsa(dev)) + value &= ~MAC_CONTROL_ASTP; + + writel(value, ioaddr + MAC_CONTROL); #ifdef STMMAC_VLAN_TAG_USED writel(ETH_P_8021Q, ioaddr + MAC_VLAN1); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index 51019b794be5..16b7f9ed3785 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -17,16 +17,26 @@ #include #include #include +#include #include "stmmac_pcs.h" #include "dwmac4.h" -static void dwmac4_core_init(struct mac_device_info *hw, int mtu) +static void dwmac4_core_init(struct mac_device_info *hw, + struct net_device *dev) { void __iomem *ioaddr = hw->pcsr; u32 value = readl(ioaddr + GMAC_CONFIG); + int mtu = dev->mtu; value |= GMAC_CORE_INIT; + /* Clear ACS bit because Ethernet switch tagging formats such as + * Broadcom tags can look like invalid LLC/SNAP packets and cause the + * hardware to truncate packets on reception. + */ + if (netdev_uses_dsa(dev)) + value &= ~GMAC_CONFIG_ACS; + if (mtu > 1500) value |= GMAC_CONFIG_2K; if (mtu > 2000) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 65ed02bc3ea3..602bf3f9eebf 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1716,7 +1716,7 @@ static int stmmac_hw_setup(struct net_device *dev, bool init_ptp) } /* Initialize the MAC Core */ - priv->hw->mac->core_init(priv->hw, dev->mtu); + priv->hw->mac->core_init(priv->hw, dev); ret = priv->hw->mac->rx_ipc(priv->hw); if (!ret) { -- 2.20.1 --dDRMvlgZJXvWKvBx--