From patchwork Fri Dec 15 08:49:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13494135 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F345171AC for ; Fri, 15 Dec 2023 08:49:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="I6I02UDM" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-50bf2d9b3fdso443367e87.3 for ; Fri, 15 Dec 2023 00:49:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702630149; x=1703234949; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tDIP5QCTtf8P0jNwrKedcIPYH3ksCN20vWE4Bnd44rw=; b=I6I02UDMr/Fhm+OoXXWx7YLDjJdXA9MjJ/3e51noljM4Osw+U4jTVx1x/b51I89P1u AFuRz55z5RTMJvV3FVPMFmpIhfpAcS/HvlFGqRaH22IrqjWMgUT0M4n6s2LTLArpRZiU iupYasyDJMM3esHcgl4r4H/uxVZ43hSoqSmUtHZU0jc7u9k+2aKCe72Q1nPO5h3y8c5Y 4ym5oiroo8Q45J3boLgACi8X/UE3fkVf2EnMdGhkbTOPge0x1newTvwMBKjAXKvcIJUq I/Oue9bn5FnOeHeDjW5g/e/GC9DDBtt+gVD7QAmcbDnnRZVdPFAnrto7NfCynd6P8SvU u6hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702630149; x=1703234949; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tDIP5QCTtf8P0jNwrKedcIPYH3ksCN20vWE4Bnd44rw=; b=tygKeAJiCcHV/UuXA0lVCdKQ+emZga7q3+LU/mH5clwuxREYilmjMU64BcPxAQT74f OcqLMd60O37ICdbQKsshWe3WzEAukDnk+/txfqic6yGDSFf8ogqvkYoSIzSyrqvwEDuc bz85ahoeDOais/AyLqR5GdCVuJsrWdKzFfPjwOwXRIARXlNR1+n5Vu11F8NJBPm0xx9/ a/ftb5dJG90EJV8wd3NGOdsAZhR+yr76eiWa9Lct/5mUvgJJPsr9ybSLsssKsjIrEINp r6sX935IR8E9LxsYU688oDcf+xla7FlU+KEmPq51qy//UpLHy6Rbh3D/aw2KRI66uk0Z KdaQ== X-Gm-Message-State: AOJu0Yyhy4Ery+Q+TJzQTUsXGugcN6IjLOR+gOgecpv81inexcCviA1w OMo35wMSIHv/k2EajcAlDh+SAw== X-Google-Smtp-Source: AGHT+IENDRKlnHRXHF13iBGRuKSp9DI2yebFOYheAU6Isj+oTeC1MMr2zwyvBOWWNcdRDEWumkthdg== X-Received: by 2002:a05:6512:3588:b0:502:f2a8:d391 with SMTP id m8-20020a056512358800b00502f2a8d391mr4969717lfr.45.1702630149289; Fri, 15 Dec 2023 00:49:09 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id cf21-20020a056512281500b0050e1db15277sm166692lfb.162.2023.12.15.00.49.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 00:49:08 -0800 (PST) From: Linus Walleij Date: Fri, 15 Dec 2023 09:49:07 +0100 Subject: [PATCH net 1/2] net: ethernet: cortina: Drop software checksumming Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231215-new-gemini-ethernet-regression-v1-1-93033544be23@linaro.org> References: <20231215-new-gemini-ethernet-regression-v1-0-93033544be23@linaro.org> In-Reply-To: <20231215-new-gemini-ethernet-regression-v1-0-93033544be23@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 X-Patchwork-Delegate: kuba@kernel.org The recent change to allow large frames without hardware checksumming slotted in software checksumming in the driver if hardware could not do it. This will however upset TSO (TCP Segment Offloading). Typical error dumps includes this: skb len=2961 headroom=222 headlen=66 tailroom=0 (...) WARNING: CPU: 0 PID: 956 at net/core/dev.c:3259 skb_warn_bad_offload+0x7c/0x108 gemini-ethernet-port: caps=(0x0000010000154813, 0x00002007ffdd7889) And the packets do not go through. After investigating I drilled it down to the introduction of the software checksumming in the driver. Since the segmenting of packets will be done by the hardware this makes a bit of sense since in that case the hardware also needs to be keeping track of the checksumming. That begs the question why large TCP or UDP packets also have to bypass the checksumming (like e.g. ICMP does). If the hardware is splitting it into smaller packets per-MTU setting, and checksumming them, why is this happening then? I don't know. I know it is needed, from tests: the OpenWrt webserver uhttpd starts sending big skb:s (up to 2047 bytes, the max MTU) and above 1514 bytes it starts to fail and hang unless the bypass bit is set: the frames are not getting through. Keeping the size check but removing the software checksum makes things work again. This was probably dubious to introduce in the first place. Fixes: d4d0c5b4d279 ("net: ethernet: cortina: Handle large frames") Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 78287cfcbf63..255fcffc1579 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1145,7 +1145,6 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, dma_addr_t mapping; unsigned short mtu; void *buffer; - int ret; mtu = ETH_HLEN; mtu += netdev->mtu; @@ -1166,14 +1165,7 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, * checksum buffer is only 1518 bytes, so when the frames get * bigger they get truncated, or the last few bytes get * overwritten by the FCS. - * - * Just use software checksumming and bypass on bigger frames. */ - if (skb->ip_summed == CHECKSUM_PARTIAL) { - ret = skb_checksum_help(skb); - if (ret) - return ret; - } word1 |= TSS_BYPASS_BIT; } else if (skb->ip_summed == CHECKSUM_PARTIAL) { int tcp = 0; From patchwork Fri Dec 15 08:49:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13494136 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77F1915EBB for ; Fri, 15 Dec 2023 08:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="pQa/TMl7" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-50bf69afa99so423636e87.3 for ; Fri, 15 Dec 2023 00:49:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1702630150; x=1703234950; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=TBZx8iwY7hsa1Ukrg2VJzmYeuseJkOebEKzy3FhcaqI=; b=pQa/TMl7p0HQAymF3Fb7DraZkrmA1SdB8zVXaQCdNH1EMv9t+YMQ2OB0VzU/AQAGUp TaI2TbE0xIueTGecHQYkuDkLd68BZxXx1FNtSW7IKCHxxriXXdnWPRkXjBjJQJxFyXpr oAbV8BSQpNFUryfMfxvVKBXAoVxI/AbMUdm6C805DbtCCU8Jmw1ixg/jvN9OK7k3Lwxn K5qcJkuXRxxu79tv6FZBXNJxpxo46S3vI7lfkZR4iIh6TqKx+fbfmH+qw64TpJNdLT5i MiYEEfXZWJlsk1rLgJ0A9kTaT24Uxch6CzVNKIqFQBuB0W0DC+qKztvs6u+d7JJQt8kp UMEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702630150; x=1703234950; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TBZx8iwY7hsa1Ukrg2VJzmYeuseJkOebEKzy3FhcaqI=; b=jqtxHIT6jbFTGNeDPRInIwhWKkDWUqHx1tIGm5zcJYBg2aPk0yqguKN39diuYNU2Fj +tjxu6n48lD1nfhfCH5IICOmEK409z6NpKjc4Kc8C6ltfC2jhXhNtC+sAewl5HtRwMpO xbLRuqGuquXiJ5xZs6guWumHFpCqDHRe8f7TfzK/nhr6fgAbjgaYldb0IICZsJutBnTx H8oMaRuyjN6yxYc6wF7DI9vF44KAS08QXG4YRLyUSJ9S4v4XUEc/lJXt3HU4KzWlibVR tL9LvxBUBNhW6XCKOMRELVNI5Z+PxBQAOPsjuFzwcUcVR6GKQSTy9x890UyBPB2Uh5L6 FuhQ== X-Gm-Message-State: AOJu0YyRP2XRC/EL9Sz7gloD8nglnbT50wJUNfhtRwdnAPlrjjCIlahY 9vMi9e+O1gLqZ5aQVbLXOyYwTg== X-Google-Smtp-Source: AGHT+IG+yAHBscm/yFSM4LXd50UzMfwWopPEwRtMN1GTWsybuYIsZOvG64TdkHNDkvlQuD5loQnpSw== X-Received: by 2002:a05:6512:200a:b0:50e:4a0:f82a with SMTP id a10-20020a056512200a00b0050e04a0f82amr3166056lfb.115.1702630150566; Fri, 15 Dec 2023 00:49:10 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id cf21-20020a056512281500b0050e1db15277sm166692lfb.162.2023.12.15.00.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 00:49:09 -0800 (PST) From: Linus Walleij Date: Fri, 15 Dec 2023 09:49:08 +0100 Subject: [PATCH net 2/2] net: ethernet: cortina: Bypass checksumming engine of alien ethertypes Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231215-new-gemini-ethernet-regression-v1-2-93033544be23@linaro.org> References: <20231215-new-gemini-ethernet-regression-v1-0-93033544be23@linaro.org> In-Reply-To: <20231215-new-gemini-ethernet-regression-v1-0-93033544be23@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 X-Patchwork-Delegate: kuba@kernel.org We had workarounds were the ethernet checksumming engine would be bypassed for larger frames, this fixed devices using DSA, but regressed devices where the ethernet was connected directly to a PHY. The devices with a PHY connected directly can't handle large frames either way, with or without bypass. Looking at the size of the frame is probably just wrong. Rework the workaround such that we just bypass the checksumming engine if the ethertype inside the actual frame is something else than 0x0800 (IPv4) or 0x86dd (IPv6). These are the only frames the checksumming engine can actually handle. VLAN framing (0x8100) also works fine. We can't inspect skb->protocol because DSA frames will sometimes have a custom ethertype despite skb->protocol is e.g. 0x0800. After this both devices with direct ethernet attached such as D-Link DNS-313 and devices with a DSA switch with a custom ethertype such as D-Link DIR-685 work fine. Fixes: d4d0c5b4d279 ("net: ethernet: cortina: Handle large frames") Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 255fcffc1579..934016c8caa9 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1144,7 +1144,9 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, skb_frag_t *skb_frag; dma_addr_t mapping; unsigned short mtu; + u16 ethertype; void *buffer; + __be16 *p; mtu = ETH_HLEN; mtu += netdev->mtu; @@ -1159,12 +1161,21 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, word3 |= mtu; } - if (skb->len >= ETH_FRAME_LEN) { - /* Hardware offloaded checksumming isn't working on frames - * bigger than 1514 bytes. A hypothesis about this is that the - * checksum buffer is only 1518 bytes, so when the frames get - * bigger they get truncated, or the last few bytes get - * overwritten by the FCS. + /* Dig out the the ethertype actually in the buffer and not what the + * protocol claims to be. This is the raw data that the checksumming + * offload engine will have to deal with. + */ + p = (__be16 *)(skb->data + 2 * ETH_ALEN); + ethertype = ntohs(*p); + if (ethertype == ETH_P_8021Q) { + p += 2; /* +2 sizeof(__be16) */ + ethertype = ntohs(*p); + } + + if (ethertype != ETH_P_IP && ethertype != ETH_P_IPV6) { + /* Hardware offloaded checksumming isn't working on non-IP frames. + * This happens for example on some DSA switches using a custom + * ethertype. Just bypass the engine for those. */ word1 |= TSS_BYPASS_BIT; } else if (skb->ip_summed == CHECKSUM_PARTIAL) {