From nobody Wed Dec 31 05:29:32 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6F46C4167B for ; Tue, 7 Nov 2023 09:54:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233945AbjKGJyk (ORCPT ); Tue, 7 Nov 2023 04:54:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233854AbjKGJyi (ORCPT ); Tue, 7 Nov 2023 04:54:38 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0427122 for ; Tue, 7 Nov 2023 01:54:35 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507bd19eac8so7040355e87.0 for ; Tue, 07 Nov 2023 01:54:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699350874; x=1699955674; 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=JloLY/S3J4vbR80IcKlfhvbtLk/oEHP3bZQboIzjIZc=; b=sWdBRhM/t7wng6xlOylPZOEGtcorfDINLBWemTEIh0XtNaqjJLy1SdGMwyzeJEmKCU Yk4aUBBGE6l8uzfk4UYAhhG3fhGCIXjR9CN8sbVEJyeYPaokasvmIK+TpUnL5A6424SA MtoNDQMTQN97eFJV31QKImYv3jDAsCRwZhJNKQKBMFFc6zJYXvNTt8hbJpGF/ywD58vx 3sm9AC0DM5iPooCUHDvTfGne3kbd48fB8iZkXlqaJ1V2tTt6MHr2tbR+kfmFer2i6Ll7 8CSEjB5MmqegFlJMMrmLsYIzAMmOglyTYiR0JQdZBLRWR9ZIqa03r/5qyD72d9FAkj+p ev+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699350874; x=1699955674; 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=JloLY/S3J4vbR80IcKlfhvbtLk/oEHP3bZQboIzjIZc=; b=f5HLjCjD14wHPFxN4Z4+vdcLcEcJulQ5C9Ps7BSYGeQgV/3UDehuY+iA/SjdlUL4tO 9iZ6mLUG7SxYqaygrD3927JiieD8A0COFmaVlFW59X7/Va2byyv/xVr00kcG+Hc589hg jjMbs7pu9y4ANQER29EXdFCkQnVSpHNltmnZ/8kV64pfd7dAFpqbQ2zEi6mqK81wQzoy 04C2RIbXL7lfe7NwcuoVd+9VcUmTo4JyBCnbLaW4vi08ePt9gq5ADb24lX3KlYaD2jIn dBN8oCl1vgz+d/4T0xjfRopI75ZRlCbEjT5dnmBI/cXK0jye0eoh0qKVrd3gYE4FMA1b PhNw== X-Gm-Message-State: AOJu0YysD7BkVjC/jwBpVtt3cy4SvuzpiaOD8gx8bV0GzftbOVqNGnOm Iqo17HHvdk1Riw+EfZwqSk/0hg== X-Google-Smtp-Source: AGHT+IFpYjXoetaqCE4w0x17lDufaf6MMnsyuen6QOAUsAm15BkmP4tyeuBHkl/HJ06CXDK6NOBRxg== X-Received: by 2002:a05:6512:b8d:b0:509:47e1:6ebe with SMTP id b13-20020a0565120b8d00b0050947e16ebemr13946569lfv.14.1699350874094; Tue, 07 Nov 2023 01:54:34 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id m25-20020ac24ad9000000b005091314185asm296356lfp.285.2023.11.07.01.54.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:33 -0800 (PST) From: Linus Walleij Date: Tue, 07 Nov 2023 10:54:26 +0100 Subject: [PATCH net v3 1/4] net: ethernet: cortina: Fix MTU max setting MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231107-gemini-largeframe-fix-v3-1-e3803c080b75@linaro.org> References: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> In-Reply-To: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Micha=C5=82_Miros=C5=82aw?= , Vladimir Oltean , Andrew Lunn Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The RX max frame size is over 10000 for the Gemini ethernet, but the TX max frame size is actually just 2047 (0x7ff after checking the datasheet). Reflect this in what we offer to Linux, cap the MTU at the TX max frame minus ethernet headers. Use the BIT() macro for related bit flags so these TX settings are consistent. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethern= et") Reviewed-by: Andrew Lunn Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 7 ++++--- drivers/net/ethernet/cortina/gemini.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/c= ortina/gemini.c index 5423fe26b4ef..ed9701f8ad9a 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -2464,11 +2464,12 @@ static int gemini_ethernet_port_probe(struct platfo= rm_device *pdev) =20 netdev->hw_features =3D GMAC_OFFLOAD_FEATURES; netdev->features |=3D GMAC_OFFLOAD_FEATURES | NETIF_F_GRO; - /* We can handle jumbo frames up to 10236 bytes so, let's accept - * payloads of 10236 bytes minus VLAN and ethernet header + /* We can receive jumbo frames up to 10236 bytes but only + * transmit 2047 bytes so, let's accept payloads of 2047 + * bytes minus VLAN and ethernet header */ netdev->min_mtu =3D ETH_MIN_MTU; - netdev->max_mtu =3D 10236 - VLAN_ETH_HLEN; + netdev->max_mtu =3D MTU_SIZE_BIT_MASK - VLAN_ETH_HLEN; =20 port->freeq_refill =3D 0; netif_napi_add(netdev, &port->napi, gmac_napi_poll); diff --git a/drivers/net/ethernet/cortina/gemini.h b/drivers/net/ethernet/c= ortina/gemini.h index 9fdf77d5eb37..201b4efe2937 100644 --- a/drivers/net/ethernet/cortina/gemini.h +++ b/drivers/net/ethernet/cortina/gemini.h @@ -502,7 +502,7 @@ union gmac_txdesc_3 { #define SOF_BIT 0x80000000 #define EOF_BIT 0x40000000 #define EOFIE_BIT BIT(29) -#define MTU_SIZE_BIT_MASK 0x1fff +#define MTU_SIZE_BIT_MASK 0x7ff /* Max MTU 2047 bytes */ =20 /* GMAC Tx Descriptor */ struct gmac_txdesc { --=20 2.34.1 From nobody Wed Dec 31 05:29:32 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28570C4332F for ; Tue, 7 Nov 2023 09:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233976AbjKGJym (ORCPT ); Tue, 7 Nov 2023 04:54:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233829AbjKGJyj (ORCPT ); Tue, 7 Nov 2023 04:54:39 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3A8A124 for ; Tue, 7 Nov 2023 01:54:36 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-50949b7d7ffso7231669e87.0 for ; Tue, 07 Nov 2023 01:54:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699350875; x=1699955675; 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=9I/5QuNpGxNYQ0Q3gYhof8mVfyBGfSfCNnlFCET9W5g=; b=cw8sWqgK1dCbpTCOVilOsRRpFu+XGwe2A+JlBn9gIc5z+A02F1E55dCZmZVaCzjn65 tP/PZfyiXANxGB/yXYN/GUwV+cGpYsngXlhPEVRaF0BJ+drRu/8aynJKmGkgwOfzN0gF XHBmRvVWb0As33NpAdU6czRD7XoVLMV5SQXXrzGc8To8LRdGn9yaWD3BzoimO5/F7S4F FsvHHc81LGD2ZS5I7PWbWggkjq7wLDJM+n1JOuMMLQ2P4FPXLqq6z9nUrjnqT3gbp9uT AKWCYboEaQhz758ng27QcAYU8Iuv7WdvYvljrh3zybXkxpR2PDSAp/TKuTxl/9ec/OOy NBcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699350875; x=1699955675; 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=9I/5QuNpGxNYQ0Q3gYhof8mVfyBGfSfCNnlFCET9W5g=; b=UgzzwQSHdekrAHK31MtIdBYJt9twSvS6uGy5xLDzyqPtacTuWsNcLu/Tx84JM09sUn 0ZSl7S8NK8CGIpv5Zi+7N8AIOdaiHz3Qshy+K5vwCI/aZa7+cIfDE1VWI6SMss2JMNXh IhKO5BUQcAPadvJCIUian4/5tAs9kBCAe0tsq9BvwGumy2NJl4arM/CnmGjgE5A6CITC cIN93mgghDTIyZYj3HafOB1RDl1C/s9gCfHAg2UhmL9r5hsgrKyiJ+xHnaZZRSDjBVmp k6hb0IMnwTf/Pve+WyyJw/j4sda1Lt0sHKksUah5lF9fpZBMJOtZcr5HEuBNDAFHrGJR ttww== X-Gm-Message-State: AOJu0YyaJvYt+AxE/mhX9b3FtWWzAIYpJLZ0AzH9MjvMGvEipR1jujh4 g1M6HEaypK5qMDJOttmUeddAdw== X-Google-Smtp-Source: AGHT+IGlT4InGGRd4uD9B/kQKUczRMijoKcGtyPoFdZviLpDAoD/so75+M9LyQ+ioSY6DkDZzqHtaQ== X-Received: by 2002:a05:6512:358e:b0:505:6cc7:e0f7 with SMTP id m14-20020a056512358e00b005056cc7e0f7mr20581023lfr.44.1699350875084; Tue, 07 Nov 2023 01:54:35 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id m25-20020ac24ad9000000b005091314185asm296356lfp.285.2023.11.07.01.54.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:34 -0800 (PST) From: Linus Walleij Date: Tue, 07 Nov 2023 10:54:27 +0100 Subject: [PATCH net v3 2/4] net: ethernet: cortina: Fix max RX frame define MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231107-gemini-largeframe-fix-v3-2-e3803c080b75@linaro.org> References: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> In-Reply-To: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Micha=C5=82_Miros=C5=82aw?= , Vladimir Oltean , Andrew Lunn Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enumerator 3 is 1548 bytes according to the datasheet. Not 1542. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethern= et") Reviewed-by: Andrew Lunn Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 4 ++-- drivers/net/ethernet/cortina/gemini.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/c= ortina/gemini.c index ed9701f8ad9a..b21a94b4ab5c 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -432,8 +432,8 @@ static const struct gmac_max_framelen gmac_maxlens[] = =3D { .val =3D CONFIG0_MAXLEN_1536, }, { - .max_l3_len =3D 1542, - .val =3D CONFIG0_MAXLEN_1542, + .max_l3_len =3D 1548, + .val =3D CONFIG0_MAXLEN_1548, }, { .max_l3_len =3D 9212, diff --git a/drivers/net/ethernet/cortina/gemini.h b/drivers/net/ethernet/c= ortina/gemini.h index 201b4efe2937..24bb989981f2 100644 --- a/drivers/net/ethernet/cortina/gemini.h +++ b/drivers/net/ethernet/cortina/gemini.h @@ -787,7 +787,7 @@ union gmac_config0 { #define CONFIG0_MAXLEN_1536 0 #define CONFIG0_MAXLEN_1518 1 #define CONFIG0_MAXLEN_1522 2 -#define CONFIG0_MAXLEN_1542 3 +#define CONFIG0_MAXLEN_1548 3 #define CONFIG0_MAXLEN_9k 4 /* 9212 */ #define CONFIG0_MAXLEN_10k 5 /* 10236 */ #define CONFIG0_MAXLEN_1518__6 6 --=20 2.34.1 From nobody Wed Dec 31 05:29:32 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EAA5C4332F for ; Tue, 7 Nov 2023 09:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233829AbjKGJyt (ORCPT ); Tue, 7 Nov 2023 04:54:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233947AbjKGJyk (ORCPT ); Tue, 7 Nov 2023 04:54:40 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE3E0122 for ; Tue, 7 Nov 2023 01:54:37 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-507bd19eac8so7040386e87.0 for ; Tue, 07 Nov 2023 01:54:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699350876; x=1699955676; 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=7xqcp7l3sLztmXNgaaMhSUStMniJux5ggXCgPLhgfhw=; b=adFYU4MQxEKKhXpBtF7fw+thICJ5HzrvT+a7pdKXbaMYgHsw1EhSFc3jMKUj5Tu+tD CiyQZs6odu83KWCO67Y1/2RMJQEp0TOr1bjeqnrIurfnrBlttONhJzYUqzlMBdfVCg5N UGLBfCMVOlhU4TbjisXu85yPVgN+AULp/jC9vurJsl904JB/ZdZoEMi1c4gU1U3ANRL6 UjYnsHaeOoP3x/VPjpazXLV4OyoxmoZLlvpXdbfy57MyNN2ox+tSPrLsbOmP91uhbyfx KKRINZzME6aJpVnFztFQcrGYRzt64CFv4c6h6r+v0HBcfQXzHq1Z1465CYKEcTYCs8xW yajQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699350876; x=1699955676; 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=7xqcp7l3sLztmXNgaaMhSUStMniJux5ggXCgPLhgfhw=; b=P48VVSi5b6NvO+Q4dG2N7WoxgfNffld1bFcbejAhYJ9eHLMX1XpBRTuhyCzJ0y65SR vzkH/vYYYN5dkbGrf34sPJpVSDvzuXh15hKBYEz45cZAtQ2x+dCmh4L0zlsXJNotvJLc KfkDjkgATl7MviWVfq+kyUkX4uAa3mgSD9yP7USdGNZkZC/7jDBVRqP2/sqG9pNCm7TT JRrCen6ijBiY0hww3feqY5ZbvQ3+uN8CtDfAJVUZ98gIY6TJlGlt9K/Hq1+W001CWkpG EtQ/1I8oPg72dwfQeYX894iEShZ6uRZEVLujwlrlbKplX9/H7hzb+DbDU4jC/yR5OSXF Fd8A== X-Gm-Message-State: AOJu0YwSAbNYuM3E6cVpljMUusrZnIpMxZvEsQADQWN5ujMqXPjTaakF zzhE9DJ+iOrMHhXs1RXtFNX0bA== X-Google-Smtp-Source: AGHT+IEF5MBAZYuBJjtXQUrFPyFp3vNlwVPxymtsM4RhEBsU9XfIdzPTR44CE8k76aI55w2oKoPhpw== X-Received: by 2002:ac2:504d:0:b0:509:4a02:49f7 with SMTP id a13-20020ac2504d000000b005094a0249f7mr11388717lfm.44.1699350876033; Tue, 07 Nov 2023 01:54:36 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id m25-20020ac24ad9000000b005091314185asm296356lfp.285.2023.11.07.01.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:35 -0800 (PST) From: Linus Walleij Date: Tue, 07 Nov 2023 10:54:28 +0100 Subject: [PATCH net v3 3/4] net: ethernet: cortina: Handle large frames MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231107-gemini-largeframe-fix-v3-3-e3803c080b75@linaro.org> References: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> In-Reply-To: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Micha=C5=82_Miros=C5=82aw?= , Vladimir Oltean , Andrew Lunn Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Gemini ethernet controller provides hardware checksumming for frames up to 1514 bytes including ethernet headers but not FCS. If we start sending bigger frames (after first bumping up the MTU on both interfaces sending and receiveing the frames), truncated packets start to appear on the target such as in this tcpdump resulting from ping -s 1474: 23:34:17.241983 14:d6:4d:a8:3c:4f (oui Unknown) > bc:ae:c5:6b:a8:3d (oui Un= known), ethertype IPv4 (0x0800), length 1514: truncated-ip - 2 bytes missing! (tos 0x0, ttl 64, id 32653, offset 0, flags [DF], proto ICMP (1), length 15= 02) OpenWrt.lan > Fecusia: ICMP echo request, id 1672, seq 50, length 1482 If we bypass the hardware checksumming and provide a software fallback, everything starts working fine up to the max TX MTU of 2047 bytes, for example ping -s2000 192.168.1.2: 00:44:29.587598 bc:ae:c5:6b:a8:3d (oui Unknown) > 14:d6:4d:a8:3c:4f (oui Un= known), ethertype IPv4 (0x0800), length 2042: (tos 0x0, ttl 64, id 51828, offset 0, flags [none], proto ICMP (1), length = 2028) Fecusia > OpenWrt.lan: ICMP echo reply, id 1683, seq 4, length 2008 The bit enabling to bypass hardware checksum (or any of the "TSS" bits) are undocumented in the hardware reference manual. The entire hardware checksum unit appears undocumented. The conclusion that we need to use the "bypass" bit was found by trial-and-error. Since no hardware checksum will happen, we slot in a software checksum fallback. Check for the condition where we need to compute checksum on the skb with either hardware or software using =3D=3D CHECKSUM_PARTIAL instead of !=3D CHECKSUM_NONE which is an incomplete check according to . We delete the code disabling the hardware checksum for large MTU:s: this is suboptimal because it will disable hardware checksumming also on small packets which the checksumming engine can handle just fine, which is a waste of resources. On the D-Link DIR-685 router this fixes a bug on the conduit interface to the RTL8366RB DSA switch: as the switch needs to add space for its tag it increases the MTU on the conduit interface to 1504 and that means that when the router sends packages of 1500 bytes these get an extra 4 bytes of DSA tag and the transfer fails because of the erroneous hardware checksumming, affecting such basic functionality as the LuCI web interface. Suggested-by: Vladimir Oltean Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethern= et") Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 34 +++++++++++++++++++++++--------= --- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/c= ortina/gemini.c index b21a94b4ab5c..78287cfcbf63 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1145,6 +1145,7 @@ 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; =20 mtu =3D ETH_HLEN; mtu +=3D netdev->mtu; @@ -1159,9 +1160,30 @@ static int gmac_map_tx_bufs(struct net_device *netde= v, struct sk_buff *skb, word3 |=3D mtu; } =20 - if (skb->ip_summed !=3D CHECKSUM_NONE) { + if (skb->len >=3D 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. + * + * Just use software checksumming and bypass on bigger frames. + */ + if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { + ret =3D skb_checksum_help(skb); + if (ret) + return ret; + } + word1 |=3D TSS_BYPASS_BIT; + } else if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { int tcp =3D 0; =20 + /* We do not switch off the checksumming on non TCP/UDP + * frames: as is shown from tests, the checksumming engine + * is smart enough to see that a frame is not actually TCP + * or UDP and then just pass it through without any changes + * to the frame. + */ if (skb->protocol =3D=3D htons(ETH_P_IP)) { word1 |=3D TSS_IP_CHKSUM_BIT; tcp =3D ip_hdr(skb)->protocol =3D=3D IPPROTO_TCP; @@ -1978,15 +2000,6 @@ static int gmac_change_mtu(struct net_device *netdev= , int new_mtu) return 0; } =20 -static netdev_features_t gmac_fix_features(struct net_device *netdev, - netdev_features_t features) -{ - if (netdev->mtu + ETH_HLEN + VLAN_HLEN > MTU_SIZE_BIT_MASK) - features &=3D ~GMAC_OFFLOAD_FEATURES; - - return features; -} - static int gmac_set_features(struct net_device *netdev, netdev_features_t features) { @@ -2212,7 +2225,6 @@ static const struct net_device_ops gmac_351x_ops =3D { .ndo_set_mac_address =3D gmac_set_mac_address, .ndo_get_stats64 =3D gmac_get_stats64, .ndo_change_mtu =3D gmac_change_mtu, - .ndo_fix_features =3D gmac_fix_features, .ndo_set_features =3D gmac_set_features, }; =20 --=20 2.34.1 From nobody Wed Dec 31 05:29:32 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC5BCC4167B for ; Tue, 7 Nov 2023 09:54:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234052AbjKGJyw (ORCPT ); Tue, 7 Nov 2023 04:54:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbjKGJyl (ORCPT ); Tue, 7 Nov 2023 04:54:41 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42F6125 for ; Tue, 7 Nov 2023 01:54:38 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-507f1c29f25so7164466e87.1 for ; Tue, 07 Nov 2023 01:54:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699350877; x=1699955677; 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=Rfck5FY3dF9200YZ4tXULFpESCIi8VAAOTwzFmje8Pw=; b=jaqEPfOjjS8CV42CwprK1l68GnR4JdiOoJohAiH02+nt0IJs/CYUAwD0g/nF8ewjSR WzVDEbobx9Ftxyzqr4x0ruhqu54YWgU9pRfdAtKgDwoRGOp5krhn4dvWok0LdrQKU4uT +A9G+zGOGi1vq0DXOF8njAJyWvEmvBomINwbmRMXkkIcyBg4ZXQJG+BVnrwryuvMFez0 x7kkohxNP7HZ+hMGwa41bs9+Kz4DoJ8Uw7ZTVZyCeIX5TQWfLQ+DiD3ZaDFIwHj2w5Fc udelUm0nWexT3QhiFg+2rbh1CDkSFyVLw0T4ea11v+GSl+3pQVN27DHS4dCYf40AuWNS d65g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699350877; x=1699955677; 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=Rfck5FY3dF9200YZ4tXULFpESCIi8VAAOTwzFmje8Pw=; b=TAqAJkNVPlbSFRo526M1LviwrMVuvANbkmKr3r8t1kY3eSd9bxbG4YqNfGGqGqIRef acxZPwRmrf8y+29ECKwfxroKeVDFrtxeuQzs03Qry6m2hwvwAhKjTchaJsBr8qILsDm6 y+FvobgU/1BAKW1D17LG0EmNHfLGEBOMf210IYDM2RhibIqpBdbsj0jm4T2pZxMd/y1G m1yMFyJCY3fFEW/UjSUsAHpGMznFDAG6LOd3aU/sIpmxCExXmjqFYnijmcS1AcgLxzk/ FP22t7W58gm9epFD7vfwvkZC9+BRbWZcFxtYSYHeaEDzH8V5j0oAecQKlpeSjNgsl9+M 4bpQ== X-Gm-Message-State: AOJu0Yxs5DdMTp6pMldRTlXYX+b/hABu85V3QgOaahnBvk5mARtBTpCr VGbUnWIWyjXi7INVo/gTL9fvrA== X-Google-Smtp-Source: AGHT+IEBVvk5s+3+jjuHHDZToklheab9cKewXJF+TOy2czkLFGo94g0k21Br2Tt8rSSzF8K3JABtuQ== X-Received: by 2002:a05:6512:ad5:b0:501:bd43:3b9c with SMTP id n21-20020a0565120ad500b00501bd433b9cmr29893465lfu.23.1699350877142; Tue, 07 Nov 2023 01:54:37 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id m25-20020ac24ad9000000b005091314185asm296356lfp.285.2023.11.07.01.54.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:36 -0800 (PST) From: Linus Walleij Date: Tue, 07 Nov 2023 10:54:29 +0100 Subject: [PATCH net v3 4/4] net: ethernet: cortina: Checksum only TCP and UDP MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20231107-gemini-largeframe-fix-v3-4-e3803c080b75@linaro.org> References: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> In-Reply-To: <20231107-gemini-largeframe-fix-v3-0-e3803c080b75@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?q?Micha=C5=82_Miros=C5=82aw?= , Vladimir Oltean , Andrew Lunn Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is a bit odd that frames that are neither TCP or UDP (such as ICMP or ARP) are still sent to the checksumming engine, where they are clearly just ignored. Rewrite the logic slightly so that we first check if the frame is TCP or UDP, in that case bypass the checksum engine. Reported-by: Vladimir Oltean Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 35 +++++++++++++++++++++----------= ---- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/c= ortina/gemini.c index 78287cfcbf63..1bf07505653b 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1144,6 +1144,7 @@ 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; + bool tcp, udp; void *buffer; int ret; =20 @@ -1160,7 +1161,18 @@ static int gmac_map_tx_bufs(struct net_device *netde= v, struct sk_buff *skb, word3 |=3D mtu; } =20 - if (skb->len >=3D ETH_FRAME_LEN) { + /* Check if the protocol is TCP or UDP */ + tcp =3D false; + udp =3D false; + if (skb->protocol =3D=3D htons(ETH_P_IP)) { + tcp =3D ip_hdr(skb)->protocol =3D=3D IPPROTO_TCP; + udp =3D ip_hdr(skb)->protocol =3D=3D IPPROTO_UDP; + } else { /* IPv6 */ + tcp =3D ipv6_hdr(skb)->nexthdr =3D=3D IPPROTO_TCP; + udp =3D ipv6_hdr(skb)->nexthdr =3D=3D IPPROTO_UDP; + } + + if (skb->len >=3D ETH_FRAME_LEN || (!tcp && !udp)) { /* 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 @@ -1168,6 +1180,9 @@ static int gmac_map_tx_bufs(struct net_device *netdev= , struct sk_buff *skb, * overwritten by the FCS. * * Just use software checksumming and bypass on bigger frames. + * + * Bypass the checksumming engine for any protocols that are + * not TCP or UDP. */ if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { ret =3D skb_checksum_help(skb); @@ -1176,22 +1191,14 @@ static int gmac_map_tx_bufs(struct net_device *netd= ev, struct sk_buff *skb, } word1 |=3D TSS_BYPASS_BIT; } else if (skb->ip_summed =3D=3D CHECKSUM_PARTIAL) { - int tcp =3D 0; - - /* We do not switch off the checksumming on non TCP/UDP - * frames: as is shown from tests, the checksumming engine - * is smart enough to see that a frame is not actually TCP - * or UDP and then just pass it through without any changes - * to the frame. + /* If we get here we are dealing with a TCP or UDP frame + * which is small enough to be processed by the checkumming + * engine. */ - if (skb->protocol =3D=3D htons(ETH_P_IP)) { + if (skb->protocol =3D=3D htons(ETH_P_IP)) word1 |=3D TSS_IP_CHKSUM_BIT; - tcp =3D ip_hdr(skb)->protocol =3D=3D IPPROTO_TCP; - } else { /* IPv6 */ + else word1 |=3D TSS_IPV6_ENABLE_BIT; - tcp =3D ipv6_hdr(skb)->nexthdr =3D=3D IPPROTO_TCP; - } - word1 |=3D tcp ? TSS_TCP_CHKSUM_BIT : TSS_UDP_CHKSUM_BIT; } =20 --=20 2.34.1