From patchwork Sun Nov 5 20:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13446146 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 05830C4167B for ; Sun, 5 Nov 2023 20:58:00 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=weud1qIw/00DSva1Jrdu7DhqJfz+uG8I55GHm/Jtb5Q=; b=JXwDNCFgEbewRV DXvevTxU4rpCRzx6Cmue8/r97K9SgwWdrJjAKHIJznRyWOUmo1fWg+hWObKGjughHUwTu8TOcAU+A ZjhaPZ800vEBGcnOuo1OGBA5J1w77Ndzt6jlM3/OrJG8McTWAA3Ognjy9guuW0goTWWfAyOkAytxE dIIJWyVHIjBHIUnnc2duG3YvJTuih+2RbG4oucc3RF9qYUhQypVbjD32L17CjnrwCOf8xKlRa5qJw kTlGHHnCIGAM3daTEwN/ChGuqkVhq9aZTSPGYmiJXD9JTbyWOf8tgEBkXcRz1tea496D6J23OxsVx pBgRed7t00kEi7rTpbdg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBb-00FVxT-0l; Sun, 05 Nov 2023 20:57:35 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBY-00FVup-1p for linux-arm-kernel@lists.infradead.org; Sun, 05 Nov 2023 20:57:33 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-507bd644a96so5435192e87.3 for ; Sun, 05 Nov 2023 12:57:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699217848; x=1699822648; darn=lists.infradead.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=gQE5Q7bSQ5CYGQU246bebUi4YlUrrbixJJSlZ4tZEQg=; b=AmqtKjibYZ1Qc0V0FoPwPz8dIQaM3HAYN/b9s4HgPjwTPr0QiuBQqeQTb07JNYy/LG 9JJA4PiZiK1og3ibPhoX3MQRzrQzsUI4PiXDe4/47QZDow61QcQU1oxfnpAgtUqpgOQe UwHiIzOqRQXaPziPtccD8KAbc8+WXXdS2UlFcC7NejmTmSfXzU7JvLVCNV+a49K61JEa xHGZMxo/S59KjLic1lKF0AsrhbWEbVgu8nisKWMtZkKs/9HFVBgQv2Kiu6pp8brbcong jfBwhRsVOIW8CkWBuN1R0nBLR7n4FbLNtJo3cQTE02u2Jn0i5IuaS+SpW8VGcO5TtzI9 t3lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699217848; x=1699822648; 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=gQE5Q7bSQ5CYGQU246bebUi4YlUrrbixJJSlZ4tZEQg=; b=fpJDFblHff68I7W/3VVxo1rRDoZRRQgNNw4Bej9DpYeNT1PXvvL+n7uiN+iHXkDQkW xHmBsjzF8+qVD84+dM2THb/exh4++OG43FrodwTpBFrUm9vgavdOEeUehIDiBeaSIBVC z2W/o0RPEapinUBSawebyr/GfFvdg34ziOsvlOoKfNMbEoW+ZHM9tZiQqt8bc6uIMr3c SLJc3R7mVpb8dmE/2k/dg5WHBXzO9SQ9N3SkqQAM7RgFqjTV32yldGwQ5HfWgfqepXR7 q/RsbQq8/3bOTPS1ejukJkYSfWv2SBzIxPdJwX9TgOJ2sOsM4dTB/8b8lwdRIqgwQlPG bv3A== X-Gm-Message-State: AOJu0YyequDqUw8pvq5xXzhCym0E86UCopet6eUXIw5Mi7mQseaD20od pUIuPvIkNsDae1/h4qY602FdvA== X-Google-Smtp-Source: AGHT+IHOmoeKz7m5iyemJOxxs0vWx/4QhLzQOa5mtwwvMfSXkeaGjljiQd5YYPz0Pgyz9fiVyiPrlQ== X-Received: by 2002:ac2:4d07:0:b0:502:ff3b:766f with SMTP id r7-20020ac24d07000000b00502ff3b766fmr18019859lfi.6.1699217847698; Sun, 05 Nov 2023 12:57:27 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id d12-20020ac24c8c000000b00507c72697d0sm931873lfl.303.2023.11.05.12.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:57:27 -0800 (PST) From: Linus Walleij Date: Sun, 05 Nov 2023 21:57:23 +0100 Subject: [PATCH net v2 1/4] net: ethernet: cortina: Fix MTU max setting MIME-Version: 1.0 Message-Id: <20231105-gemini-largeframe-fix-v2-1-cd3a5aa6c496@linaro.org> References: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> In-Reply-To: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231105_125732_613765_3786C267 X-CRM114-Status: GOOD ( 14.51 ) 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 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 ethernet") Signed-off-by: Linus Walleij Reviewed-by: Andrew Lunn --- 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/cortina/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 platform_device *pdev) netdev->hw_features = GMAC_OFFLOAD_FEATURES; netdev->features |= 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 = ETH_MIN_MTU; - netdev->max_mtu = 10236 - VLAN_ETH_HLEN; + netdev->max_mtu = MTU_SIZE_BIT_MASK - VLAN_ETH_HLEN; port->freeq_refill = 0; netif_napi_add(netdev, &port->napi, gmac_napi_poll); diff --git a/drivers/net/ethernet/cortina/gemini.h b/drivers/net/ethernet/cortina/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 */ /* GMAC Tx Descriptor */ struct gmac_txdesc { From patchwork Sun Nov 5 20:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13446149 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 D8D5FC4167D for ; Sun, 5 Nov 2023 20:58:05 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=/g7wuehU+MYb0rbLVZ2XuzfTeRiYOD0ZOYWu98ENbjU=; b=d9bv9n4GTKtxYB Szt7tp7j8+b2lDa+WilsvfIGJ8r3m72Y1J5SixtQS976qOB2LTRHhCZhUDeQAbqqNPxBlAfIJ6RQI aOOYNREjKfgJ3KVIZUeLEBbjEZzeQTMbVSfxwue7AgiJFOqjoVBXB8JzkvdqSdo2g8BLABVKcYoWp amUrGTIitdFEmCb+FRo453sQPzh4f1cp5jq6nttjgyv3/eP6HFqdLdwGfWOnc1k+uSCXuRXMYRL2k iSHvFJchcYibOH3uawSeC3LiOg0r4xLL9chQmc3KwSE5dqv+M9FpdttbE1802s9ux0W6oEHVaI5e4 QJoEPjsSxr+m3z/FByyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBd-00FVyU-1n; Sun, 05 Nov 2023 20:57:37 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBZ-00FVv4-32 for linux-arm-kernel@lists.infradead.org; Sun, 05 Nov 2023 20:57:35 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-507cee17b00so4869385e87.2 for ; Sun, 05 Nov 2023 12:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699217849; x=1699822649; darn=lists.infradead.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=WdkpXPFIGFatU+9PkWuVxtSLtApHfMYsRgreO8zhR87kj2toTWtq0GkUZg4guw21C2 PDSyZlfb19mH89NZ5GEbM4wndewACLZOPhTk/96RTqwvcuDfiquOVnwQkht9QATdYLMV pl2Q4xo+1uK9UryYZVVG9AsBVm5ASq1gNiEqyhtm3zfJ/SMs5eH8h+5XxhmtSrvTfrXm IPhIVZEpS9kdJ35Bidv3onB8nK4hRJHdmPZ2IywfmyoSFUjl61e+SQpfdTZCjeWEfv3T 0pBSg0lgUQsBzeCqQLTsgk6lIwnQxMWZp5L/z7l0WLOE2YF08ajGDTFmv7ElDY1nMn+l 3l2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699217849; x=1699822649; 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=Zw7fZ89KHMfSiBfgqTekeDakhXfLrY8yjiZ+l+LWr0N99Yz69R5g24OzF7rP2KX7DW rPGPmXktbEoTFtCD3ZrUGCyicfZkvCnjgL+o1eMbGmPLUDUIu5zP8Z195biyAXpb6Wtd m1az2KoWOHLCFZ//BkTaFodtLEZOyrFztfC+jmaUsR2O0tblor9fIjkUNMLVi2TgRdR+ A+7QcqqSEJvjxIacCHOq+GpRSA6ViNqwUTz/N4E1u1YOnARfXDokGFKFnPDqNM71ZFxT wfUD2xIPxaimZIzD+DEoJAxH0dogzivZ6BM4VTXVUAPWkfGMOLbaUPvoGjOn6RdBr23n oArA== X-Gm-Message-State: AOJu0YxLqVbcmyGBSV90nHUcwqTzGd5XcZFiITngaA0nLnCwOkUlDPzX mi6i30vjg4jM3uFxMTz2MUNNrQ== X-Google-Smtp-Source: AGHT+IHEu2ba+AMGz02oEBnNqKcgRmT3tE+uIa+goUWOOC86KvEtoEC6fxxX+YOpDBoyi6G/5ZvToQ== X-Received: by 2002:ac2:5398:0:b0:507:9f69:e8d9 with SMTP id g24-20020ac25398000000b005079f69e8d9mr19751912lfh.49.1699217849468; Sun, 05 Nov 2023 12:57:29 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id d12-20020ac24c8c000000b00507c72697d0sm931873lfl.303.2023.11.05.12.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:57:28 -0800 (PST) From: Linus Walleij Date: Sun, 05 Nov 2023 21:57:24 +0100 Subject: [PATCH net v2 2/4] net: ethernet: cortina: Fix max RX frame define MIME-Version: 1.0 Message-Id: <20231105-gemini-largeframe-fix-v2-2-cd3a5aa6c496@linaro.org> References: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> In-Reply-To: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231105_125733_981258_301914DB X-CRM114-Status: GOOD ( 13.41 ) 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 Enumerator 3 is 1548 bytes according to the datasheet. Not 1542. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") 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/cortina/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[] = { .val = CONFIG0_MAXLEN_1536, }, { - .max_l3_len = 1542, - .val = CONFIG0_MAXLEN_1542, + .max_l3_len = 1548, + .val = CONFIG0_MAXLEN_1548, }, { .max_l3_len = 9212, diff --git a/drivers/net/ethernet/cortina/gemini.h b/drivers/net/ethernet/cortina/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 From patchwork Sun Nov 5 20:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13446147 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 765A0C4167D for ; Sun, 5 Nov 2023 20:58:01 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fUrCiyIYfdz6pt1/UCuvijoOMg3Lb81tK1tXjnVvIdo=; b=YePe4YSGioPra4 PmwRjAZpv61uZZkIevdTRC+OkG3mb2XdWFZAELI+gZZWaa7oqFQZbhZYjCzAJeEzfArN6uXaPKO8Z mvbytvKGyfc5nuCdxidyicbsihCmn2dw9ixgrWjOQuiGomi2rX0xSsIMRpfP/5fVV4FyU95wdstnU oZAbj1tAs2rXX2H4piWaIfmMCFu5oL/llZVvs88nqvPDtwudl2CdpFWoCWWPxYe/vDS///Vin1jVW 8i3ygGxNwkjfPYLHIROpVuD7UlpGz1Tkp8Z9nPazPo2bqpiySeBYRQlLjref3EzEUS2GlRGk3CKYn Iregybet1dYZUm338X6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBe-00FVyp-0G; Sun, 05 Nov 2023 20:57:38 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBa-00FVvC-0P for linux-arm-kernel@lists.infradead.org; Sun, 05 Nov 2023 20:57:35 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507a0907896so4791158e87.2 for ; Sun, 05 Nov 2023 12:57:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699217850; x=1699822650; darn=lists.infradead.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=hHGg7IgOG8aP3eorgAYgy9MJBjBd5UgvuR9R9eWvihw=; b=qDLnU3uJpkNTPCLHT+6xEp1x/HYoAErTGxuyXPNBfcWqaJiPnVaSeeWloDBfykgJ5b 0BZG7VlyIB0CxxWKZcWMDw6cI7e7TB6V0Tk39yJhttYlpUs1V3ABOW9DNq4lxm8xPUO4 pbZ0ESw+VrA+Gm6hx/ZI6m42VPKXDXjcYBFQf5JhyiRniD3Hf8qwCJNtAv0kg69e2V76 OWO3SRNzMamdzSyfmI9TN3CjXkncJjNwn5v2mHNvA8BSY5s6svdhRm1w56NcFGTAc3oV YAoJV9Taa4yjUWiDNCTF6a9UnqK/NOOlnEg1elhufOAq4360xQ1vPulWif3usxFaWwEI cYFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699217850; x=1699822650; 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=hHGg7IgOG8aP3eorgAYgy9MJBjBd5UgvuR9R9eWvihw=; b=NkfYYc+Xc13iyJUt0j+NKJW3Ib9/1VgQqCAAKRnlh8/9Ck+3zw/d5UsMr2ufSBYlLr 38MhvxcOWBXhDkAwdvjgvHypQvY3Nw72fxwFEMlu7A/Fx6qcunxWIKKoAe22Dol6VxUY AiCktuk2uFRi56sRXYVjWXSfMBDQYr7kFSiioP4uxtGnghAKxtgKeVyfAxgeN/Ul7bWg 2ULC1Fao/jeLfjpU3zOr0foQhozBHATWY6ICFEHwj5B84hHAvHaLDradB0XS9ozMSpOv 8bguqegro9wKtkl0Hh+bF7/WHb7bNwrAQ+OfN9CT4Hc6DUnbw2+fIj1bUNeKDP8v7GEw TzWA== X-Gm-Message-State: AOJu0Yy7/xxB3RQK86eRDWTGRUXkB0Wf3kZKYsbd7N1mskb/HkK3cwgE iSHS87Ij4UbqS6oQ0VIjs8Qp4g== X-Google-Smtp-Source: AGHT+IF7W3TbvSvzphWkJ38I4V5LXCkTCcll16Xd2nGcrFIOQF+dFaXj5XAglJ+flcNEhVosFX81xQ== X-Received: by 2002:a05:6512:368f:b0:506:8d2a:5654 with SMTP id d15-20020a056512368f00b005068d2a5654mr17718911lfs.28.1699217850484; Sun, 05 Nov 2023 12:57:30 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id d12-20020ac24c8c000000b00507c72697d0sm931873lfl.303.2023.11.05.12.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:57:30 -0800 (PST) From: Linus Walleij Date: Sun, 05 Nov 2023 21:57:25 +0100 Subject: [PATCH net v2 3/4] net: ethernet: cortina: Protect against oversized frames MIME-Version: 1.0 Message-Id: <20231105-gemini-largeframe-fix-v2-3-cd3a5aa6c496@linaro.org> References: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> In-Reply-To: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231105_125734_165971_ABB3DF68 X-CRM114-Status: GOOD ( 15.24 ) 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 The max size of a transfer no matter the MTU is 64KB-1 so immediately bail out if the skb exceeds that. The calling site tries to linearize the skbuff on error so return a special error code -E2BIG to indicate that this will not work in any way and bail out immediately if this happens. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index b21a94b4ab5c..576174a862a9 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1151,6 +1151,12 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, if (skb->protocol == htons(ETH_P_8021Q)) mtu += VLAN_HLEN; + if (skb->len > 65535) { + /* The field for length is only 16 bits */ + netdev_err(netdev, "%s: frame too big, max size 65535 bytes\n", __func__); + return -E2BIG; + } + word1 = skb->len; word3 = SOF_BIT; @@ -1232,6 +1238,7 @@ static netdev_tx_t gmac_start_xmit(struct sk_buff *skb, struct gmac_txq *txq; int txq_num, nfrags; union dma_rwptr rw; + int ret; if (skb->len >= 0x10000) goto out_drop_free; @@ -1269,7 +1276,11 @@ static netdev_tx_t gmac_start_xmit(struct sk_buff *skb, } } - if (gmac_map_tx_bufs(netdev, skb, txq, &w)) { + ret = gmac_map_tx_bufs(netdev, skb, txq, &w); + if (ret == -E2BIG) + goto out_drop; + if (ret) { + /* Linearize and retry */ if (skb_linearize(skb)) goto out_drop; From patchwork Sun Nov 5 20:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13446148 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 44CE7C4332F for ; Sun, 5 Nov 2023 20:58:05 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XB+WaGcfc6RG/2zzXI8Sm0FU+HpGqR+UEg+pSEdj4zo=; b=b/B9CtDBXSDQ5m bMV+wCQMV5Ra+dBstebAeY4K7V+SmuVFboH7E9GNIQQBFJbxmyvgEACI5t79u8yOCicX9EifI8E5A H9szMLlUHq+WzxXP+d7hF3Y2ByzhF6uODivT2maJ1sI07kKPnFEfsVFBhlNGtI2ZFgQlq1BHxoyaU jpqxqwwls09HDTgS4yM3U8tsdqXgb6JrQXxK8lTHBR7HN79OpFLJV26J0blf2oeDE2nd6lTFwGnP6 KryWBTJun2J7mx/E8nBeXJX6XN4qLVgXQej4dVpGlhIlet32DJZG3snQaTOQ90cw3FcNa9kuF4PDm 7/Z9EknA5ZLc1iaFFj1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBe-00FVzE-26; Sun, 05 Nov 2023 20:57:38 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzkBa-00FVvL-1G for linux-arm-kernel@lists.infradead.org; Sun, 05 Nov 2023 20:57:36 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c504a5e1deso51221401fa.2 for ; Sun, 05 Nov 2023 12:57:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699217851; x=1699822651; darn=lists.infradead.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=SkmUkmLoK96BNboao7deauYFXBoeWm6vYd1S1QHVdg4=; b=qXrxfkyHVRQ967Ei5rcqrv/PFpv5tckvaqXryoeOMFxOlwJ3NDQsI+qjMoBbpdmPBj m8i3FGkzq/p8gs/taO1dLdzmo5bnsq7oRoAOqH8L6vHEl+QwNWGHMO+nnXSyvZxA/5SN wEg2lcFBEvTOpoqKgLTZhKDbek/6HjQgzPlT3OfJPelgVBtuzhLgAwFaMQIb4T36Ru5t Xn/d++lKXwiyzSOOtWojvP8rSq+ZmNiBzjuBIuBUDVmEmKQc1ztGOfwpY4k3h/NupKX8 Zm7fMTCh1tvvHO+jpP6x69XCEKzGl0C9JR3HvEHgss69RQhAtTx/3umP4Ipv/qnf9aJO tLUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699217851; x=1699822651; 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=SkmUkmLoK96BNboao7deauYFXBoeWm6vYd1S1QHVdg4=; b=ZOfsBimnUTTzz8OmzMD47hd5t2/InKIxvmqFqDlltV3S3ZoabQXuCjDFsDVVWUBl6i 5QE24MCL4lF/UqJ672XufGqqjYT8px1//FzpACckKz7802xucUrsBoMFjblBqTQnJPpx /L6LSR6ZTSyl2E0WTZhsOxknD2wwSuYgsjMTzZOgugDq/3ZZoiM7hJSAHBTL867AMmBb EzzSI+sdsfBorD/W1Zu/Dbp8KBU/yKxj1vbjjf0ZUy2YRCGG41ksJC4bywSoOoRXJeJv 3l2BqW+lDmWZRawtaHS6MTwEGf2e4bHbg/yy3cQdOp58zUQaq2BBHlvPNrLR/1isUBWj +EgQ== X-Gm-Message-State: AOJu0YwzY6E/J3/wVnyxZORLnhQJLDaUDXpOcRuuWfLtv3ZHtYny1qK7 4APZUzUBE4ffvU7PaUpiF6RR6A== X-Google-Smtp-Source: AGHT+IEZ5yfK1828ZFfg1z0JEcil3ZmjTYmj62YIDKrrJea9QiYH64N281WrNe7UIF3CYVdtagRcqg== X-Received: by 2002:ac2:522c:0:b0:507:9dfd:f846 with SMTP id i12-20020ac2522c000000b005079dfdf846mr19156590lfl.69.1699217851479; Sun, 05 Nov 2023 12:57:31 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id d12-20020ac24c8c000000b00507c72697d0sm931873lfl.303.2023.11.05.12.57.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:57:31 -0800 (PST) From: Linus Walleij Date: Sun, 05 Nov 2023 21:57:26 +0100 Subject: [PATCH net v2 4/4] net: ethernet: cortina: Handle large frames MIME-Version: 1.0 Message-Id: <20231105-gemini-largeframe-fix-v2-4-cd3a5aa6c496@linaro.org> References: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> In-Reply-To: <20231105-gemini-largeframe-fix-v2-0-cd3a5aa6c496@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231105_125734_431276_8CDFA1D5 X-CRM114-Status: GOOD ( 19.44 ) 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 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 Unknown), ethertype IPv4 (0x0800), length 1514: truncated-ip - 2 bytes missing! (tos 0x0, ttl 64, id 32653, offset 0, flags [DF], proto ICMP (1), length 1502) 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 Unknown), 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 == CHECKSUM_PARTIAL instead of != CHECKSUM_NONE which is an incomplete check according to . 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 ethernet") Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 576174a862a9..84295c1b87e6 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; mtu = ETH_HLEN; mtu += netdev->mtu; @@ -1165,7 +1166,19 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, word3 |= mtu; } - if (skb->ip_summed != CHECKSUM_NONE) { + if (skb->len >= ETH_FRAME_LEN) { + /* Hardware offloaded checksumming isn't working on frames + * bigger than 1514 bytes. Perhaps the buffer is only 1518 + * bytes fitting a normal frame and a checksum? + * 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; if (skb->protocol == htons(ETH_P_IP)) {