From patchwork Mon Dec 18 16:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Gantois X-Patchwork-Id: 13497256 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9219C46CD2 for ; Mon, 18 Dec 2023 16:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qPMqdsmwYk+9H5X6hvtnTk+Scr05QOqpPL2L2025NrQ=; b=hJTUZjyl1plNmr 4Szp7PtIdz8OBRgb0O5eal3off67R297pqaPA1+qPkgXvwRaCFhgS/0hqGqpy2JZF8WaPsrPMY3Rf OdTvI2wG7u04WIbiZuZa0SZVkbqf+0FDWUjvdbjN4b6PH9zs07A+n5lG6tX2+l9dlHhfBJosbbVEp y/cmf/i1p2hgPep9ZKDOtHMDtBatQFeWJCzsFNt9y/BxmgmOJKrAusjy4pJGu3rEhdw+lVcYnGDEt Lu+SD89oBamMsiAVgzKRoUiY3wrTMjLDhecDi5N27dJP6QkHGtfa7TvNXfU3hHnCAZcx+a5idj7Y/ wESBc/w+Y5az6/oyE1zw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFGP6-00BQwC-0Z; Mon, 18 Dec 2023 16:23:40 +0000 Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFGOw-00BQrC-33 for linux-arm-kernel@lists.infradead.org; Mon, 18 Dec 2023 16:23:33 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id CFBAB1C0007; Mon, 18 Dec 2023 16:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702916601; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AoIlun1JjSNLq1gPPPffdSuDW5Li447GWbbWCncLmyA=; b=Q0Y3+3YFcjvtmsjkkyZnggtOd0FqkiUMbcG+QkwGU86eOMWuPJCx1ZdkI0+78dZnUggJZ0 0st3qbEsedGVMjSWAxf1SMiDjjCWjjKkwSxGWB07hHjdqjTvhjbPcvribUtQg/VwW9/+aN dcnxHY//gbVkfAdSrwV1I8n0qp9TXl07bcArDAAEHbkM2mWDrUW9wCVhAQLKJBeLSRrmKm 7Re+IMFCv44/OIEjDEog7WGjx5i+oKRJbC4uE96YYgDW3Z9RleP7xpsVwpmG5u8iOgb8xi fkdQG8kxJmOF3gNP5nE0Vy41QhFEgrvxRU3QTFlrdjCG8KUzAThf4CS3ARNvaw== From: Romain Gantois To: Alexandre Torgue , Jose Abreu Cc: Romain Gantois , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Miquel Raynal , Maxime Chevallier , Sylvain Girard , Pascal EBERHARD , Richard Tresidder , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org Subject: [PATCH net 1/1] net: stmmac: Prevent DSA tags from breaking COE Date: Mon, 18 Dec 2023 17:23:23 +0100 Message-ID: <20231218162326.173127-2-romain.gantois@bootlin.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218162326.173127-1-romain.gantois@bootlin.com> References: <20231218162326.173127-1-romain.gantois@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: romain.gantois@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231218_082331_280736_4B657A45 X-CRM114-Status: GOOD ( 17.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some stmmac cores have Checksum Offload Engines that cannot handle DSA tags properly. These cores find the IP/TCP headers on their own and end up computing an incorrect checksum when a DSA tag is inserted between the MAC header and IP header. Add an additional check on stmmac link up so that COE is deactivated when the stmmac device is used as a DSA conduit. Add a new dma_feature flag to allow cores to signal that their COEs can't handle DSA tags on TX. Fixes: 6b2c6e4a938f ("net: stmmac: propagate feature flags to vlan") Cc: stable@vger.kernel.org Reported-by: Richard Tresidder Closes: https://lore.kernel.org/netdev/e5c6c75f-2dfa-4e50-a1fb-6bf4cdb617c2@electromag.com.au/ Reported-by: Romain Gantois Closes: https://lore.kernel.org/netdev/c57283ed-6b9b-b0e6-ee12-5655c1c54495@bootlin.com/ Signed-off-by: Romain Gantois --- drivers/net/ethernet/stmicro/stmmac/common.h | 1 + .../net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 1 + .../net/ethernet/stmicro/stmmac/stmmac_main.c | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index a381dee8b52d..1469d95e77a0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -406,6 +406,7 @@ struct dma_features { unsigned int rx_coe_type1; unsigned int rx_coe_type2; unsigned int rxfifo_over_2048; + unsigned int dsa_breaks_tx_coe; /* TX and RX number of channels */ unsigned int number_rx_channel; unsigned int number_tx_channel; diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c index daf79cdbd3ec..50686cdc3320 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c @@ -264,6 +264,7 @@ static int dwmac1000_get_hw_feature(void __iomem *ioaddr, dma_cap->number_tx_channel = (hw_cap & DMA_HW_FEAT_TXCHCNT) >> 22; /* Alternate (enhanced) DESC mode */ dma_cap->enh_desc = (hw_cap & DMA_HW_FEAT_ENHDESSEL) >> 24; + dma_cap->dsa_breaks_tx_coe = 1; return 0; } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index a9b6b383e863..733348c65e04 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "stmmac_ptp.h" #include "stmmac.h" #include "stmmac_xdp.h" @@ -993,8 +994,11 @@ static void stmmac_mac_link_up(struct phylink_config *config, int speed, int duplex, bool tx_pause, bool rx_pause) { - struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); + struct net_device *ndev = to_net_dev(config->dev); + struct stmmac_priv *priv = netdev_priv(ndev); + unsigned int tx_queue_cnt; u32 old_ctrl, ctrl; + int queue; if ((priv->plat->flags & STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP) && priv->plat->serdes_powerup) @@ -1102,6 +1106,16 @@ static void stmmac_mac_link_up(struct phylink_config *config, if (priv->plat->flags & STMMAC_FLAG_HWTSTAMP_CORRECT_LATENCY) stmmac_hwtstamp_correct_latency(priv, priv); + + /* DSA tags break COEs on some cores. Disable TX checksum + * offloading on those cores if the netdevice is a DSA conduit. + */ + if (priv->dma_cap.dsa_breaks_tx_coe && netdev_uses_dsa(ndev)) { + tx_queue_cnt = priv->plat->tx_queues_to_use; + for (queue = 0; queue < tx_queue_cnt; queue++) + priv->plat->tx_queues_cfg[queue].coe_unsupported = true; + } + } static const struct phylink_mac_ops stmmac_phylink_mac_ops = {