From patchwork Tue Nov 7 09:54: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: 13448242 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 7CCD2C0018C for ; Tue, 7 Nov 2023 09:55:07 +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=y1NQmyjmT/qiYpP1mwzoDsx82pNFavINYWpcqlFHkyQ=; b=APY49b4NtsRqgy OnndqwU67fzc/0cglqJbIcsoNevRxGQpcXzD0m00JPFSx5wFWZJK4LhPp3NKKYQHTO9aoftwNoS1+ EaqkTCYEfSLumTt2j2A35fdoZUKfk/gWIOC+Ez6674or4XTR9+Sj+P0tmcNzEkQ9mrSOs+e+ReMVE +55xNGGvmA+ZtVldfVRf/7Odhn61jbl3n3LJULzmBXdvPK5jfyBW0VZ/KAbJwUQf/f1TQyGDlL+nu XF30/HTCnQo1cMnovAA/aqirvt6dY7xtpqTRhd977CC1z4EOT5RyMegvWJ3rA89vaRekG7b9jQv+B umMXJ2WhXzPn0dXcuhUQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0InB-000yAi-1U; Tue, 07 Nov 2023 09:54:41 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0In8-000y8D-0C for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2023 09:54:39 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-507be298d2aso7022882e87.1 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=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=JloLY/S3J4vbR80IcKlfhvbtLk/oEHP3bZQboIzjIZc=; b=W2ErXBJ2SLxQtkJNpe9jUWjxjMQhZVlOkMxxsWzOPIrUUyaeuwMl14x7m309DyJPTJ FGFgUA5RB1lFASq0R6UZLLOQhyCtMIZXtIEEg7DDQZgKU8HlqKS1AeEobZ6XuXXOVsb5 elqrLhdk/paYIKYBIqLkiSvubW4je+bB2li4QDl10TSkUFkb5zmPAQJwTlcSNq5DZUp8 +P16AxWutN5QG2Aq4/jOq+6En+SZrc7/BKJF5EE5ljxwi1u8Hc6d0zYoayEKXtg+hulr kcQoxRABQgW/vovih7Hm+W0GNNf5xsWOlCaoiviUqAVNjDC2laBJrjeNY+QR8CV3NLfT JP2w== 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=Y1MXr6kcidUW/QSt9u8jh1Vnalbh3CyyBlqoQFyGBMCgEdkNd0EY4GS+7VqlPUciGD QraqCfGsELfn3Z/GEgJfkqY5HDtJXOHjOucnRLyIF1m5EmrTzDRC6YLj0knxn3nuRo0r BH7WO7Z3yvzQDTUncMdxQnZ0pFhDrUsdO5O/QePW06BJ1rEssTffn8dZ0v+b9NWAoilL 1NTYRCeuJzNW6Mqgm/sFBe9kfp+5a8/g+KXhTp3uxz4nNnSAKQwckS07CRFZLgx+1PXh dGrrH9pDw0NmnctvsYcgFuU5J/fbvyEXuf9PGGMPdzpEGqGifcIO2jXAM+dbpvJb5F/K 6RNQ== X-Gm-Message-State: AOJu0Yxv6Ct8FUsl5W9uQPNHsQwuMSK7n7Bs8+QAKl9UDxfu9+oDu2oU YoZn3azzAj1fllMw9tzCVvOa8ZAU9AjbPiOzHRI= 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 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?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-20231107_015438_104152_09BDA626 X-CRM114-Status: GOOD ( 14.86 ) 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") 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/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 Tue Nov 7 09:54:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13448241 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 E1133C4167B for ; Tue, 7 Nov 2023 09:55:04 +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=TMXmHTFdioozI2 3B7K1/Z3N6LCZxsxlBSK88oLhR2ouRGnD6u0ZgvMKgQ9P6XZ1GG5UNuDu1eeBPgVv+6i21dmwJnds wDXq3+Qay4oWXbmnaUI9GBtsNez3sMYd4GUXiOoTc4SghsJASeA7kL20a00SmPod6Mm1TqZ1KKPmg c+oE5sZcOgOzFSRtKxA7J6UK0ttLJYB+PB8PnyZ2PE3va6dQeNKfrkUcod7SNXI4B9lpXxr1REVYj ab4tNTIKwk5ousJkpVxoLSelmjbXQAgpfV9Q/UWipAiAQYp6GOgQUwrZ7PdLYQyo7g2v1ruvT+jgO euQIK5XYH+Inb3fexaXA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0InC-000yBa-1i; Tue, 07 Nov 2023 09:54:42 +0000 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0In9-000y8F-0B for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2023 09:54:40 +0000 Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c594196344so72719591fa.3 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=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=MHK24KsvXsCmThgIzGqvCNhabqkNBjQNgw4o2ogeWoPAv6jU9lLPqRReETLt268Kvc nbvRz8pOpAdnp7DAcNiR4kOy6cYizdRP0NqLSjk3HDUDGo4IZl8zwYsvX36tE3WPBFtT Q4xy2MEd/n+qlkVdHS5rpIL/fI0u7g1/GIEb8bixyeNYh4Pkd25OP5uThuV+++Lx+dFm IvxDkqPul4zIPNoBmjU8ibyUddxwwgOObYRAtbShNVuMl4x3KuRFvEFjhvzsoVaIIM/1 cFaza30druaDoQXieIWI2+t58n6ehrzX4B9Qjn8CDmx7HTdxgbuYmyh+LEc0uHCFO5U8 li/A== 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=fF94uxhVjxuWMIwpalhH2y2BuNexB3+k8QlKFPCaQzac8vBXPYQxHqwXhRmOfgz3yD jvC5QHC0td17caGzLSQ5Ado374pJdvJqz2fyfFhOBg+2CndkuCnAPVSjKJ3zmKP0RHHO 7IFcLUUoHuV49F+U68VUItVdj2Vw6Wi6AWAWZL9iVsJAY9QsJW8sziJ6JJGuTjobbtBR HRmf1UHtig1N4Sn0gtLKV7819nFV139GbRQxyWsn6Tloviv6zrhA5gY4swx0LYXivGDS Tr+C2WEM0ByD4ivq1E0lbadZySFicdPd/FFXYgViFUVl6BXDqMJzEKpcJ+nTXIC80vVY csww== X-Gm-Message-State: AOJu0YwW1FdAD6Mas8KBI/7zT3/R2DFztIBxo+Md72hdfFoF3yPB5TVn ulLiITpr4zzszk82n0+Db//PxFRXJswDWWaJrXk= 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 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?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-20231107_015439_092073_358B04E3 X-CRM114-Status: GOOD ( 13.85 ) 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 Tue Nov 7 09:54:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13448244 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 94AB7C4332F for ; Tue, 7 Nov 2023 09:55:11 +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=fJjAXHiACcDy0iTuwbZNB9syI9o2RyBiABbAxV/ktAY=; b=B1JHfsQnnzTFTz YXU6NaItrIHbhO7GgFQ3b9OznVMkVbpy5z52HRpcJqbI+hOc5uWGWZHTLtEDC2eFzSsLBJHZjYVGk aQH0bnH0ZaFPe25zAM+3fUg7OQwRp+g0J3lsphV6Nn5Yqz6CjrxryYmHN7aHUUn2Ur4XqNJCisJhg u181BrlP4py6VbYz7RpOR+CgOyb9Gk4J5RyUKfrvHL0dEZB+U3hhIJWawgbIoZadjuzmlbMK/xtk0 n2UoMLcMhuB7DY5scEkW8h00s/UXRLxfD4PUjcxUV2QoxSt24f7m1tX8HMvf28pwy6kFYcby1loih PuMjhD+FT1wyT6ePtxNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0InD-000yC8-0r; Tue, 07 Nov 2023 09:54:43 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0In8-000y8G-3A for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2023 09:54:41 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-507adc3381cso7005898e87.3 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=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=7xqcp7l3sLztmXNgaaMhSUStMniJux5ggXCgPLhgfhw=; b=Zhxc5sgtI3rhPXi2e7xsA9iQENX21/gZsgeUQEqX4chuT6zosmxAN3G+KCt/KqlBpB GA5bUORqwmREVy/PkhtPJwdnxNrh9FqnJ+IIt/t5KFyBROQvNXWL0mWc3RB2je2cINVm kTNkNJtes8Jb1eA+9z0SmkDsHQovLFWvkXnozeqbwwAK6+RhRFsD+KVg92OqhcLjLsou I4v8VDivKEIRr7HerfJxdE7bw1abwW0siY7LaQdsK2MPd4xqlnkrF703uNCxBboD6tdT TVI3sYTV6Qc8vJAOtYp9mhYoJSOxqrk7CombUt1y3t6iuc5KSlK6Qufl9u5I2llI6KU4 yCCw== 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=fcDHBE2FgJWFYo1YHPl4gqT5B0yh5BDWF4gbmAqniP8iQuy6R0YjgFrCF0uIw1Dp6P jQVnFGB5yjsWTTkHzOsd08384p8MO3sfSSZT6ZNeR57qvJocdxVwxUaPZMRszmzrh6Bk +zKtcvkd1OdiCHaHYTpT+R7RGfnPVdV5H1QyKumicj2gpuzI2egPFC66brywA4a8IU97 T2bKctgRtOvm+R7uWUpZurBJ36ILsHLHt9TRSy++pobBz+zwJCfepHBn3UXzTxWeQVmp Ujek8GIBqjYaBA09jjVF+4Qpkkmkt8OeKbf4LP2FjQgXEKZp5iDF+Fgirn2uV0C5uLAz 2/Hw== X-Gm-Message-State: AOJu0YysfpJrbZ26U89mm3/SqDtavTSROmqJzq+O0bhLNtYiq0TAQdI/ Phg5gKli7DFAE7Ccm//O6h+3t5VG8GwH/R4RVmw= 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 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?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-20231107_015439_021502_982C38A1 X-CRM114-Status: GOOD ( 25.16 ) 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 . 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 ethernet") 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/cortina/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; mtu = ETH_HLEN; mtu += netdev->mtu; @@ -1159,9 +1160,30 @@ 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. 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 == 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; + /* 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 == htons(ETH_P_IP)) { word1 |= TSS_IP_CHKSUM_BIT; tcp = ip_hdr(skb)->protocol == IPPROTO_TCP; @@ -1978,15 +2000,6 @@ static int gmac_change_mtu(struct net_device *netdev, int new_mtu) return 0; } -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 &= ~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 = { .ndo_set_mac_address = gmac_set_mac_address, .ndo_get_stats64 = gmac_get_stats64, .ndo_change_mtu = gmac_change_mtu, - .ndo_fix_features = gmac_fix_features, .ndo_set_features = gmac_set_features, }; From patchwork Tue Nov 7 09:54:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13448243 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 5A9FCC4167D for ; Tue, 7 Nov 2023 09:55:09 +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=ArqUBPKh5arH27fi3VggO3iQsU68/UHM5F1hJvffjhk=; b=XDJtFnLQfSoiVC 5f81vzqNqdG6yiMAzejlSXmF48nF2OuHIxahl8w3OhqAWT2BEZCDhgJCG/QKim+Hbaz4xMBUJkd7l XedElTybY3EuEiS0EP3CuVESfOinSRXnsqMlmC20sa9SWayJ5UDG8CPaHhrCXR4spqDD3/E+odWOR gcygHL8JdyGU2QxjU3QWhIG0S5mrfQ+RyUlXRk/ThOOUZ7gM/R3z3s9YuKe2HWW+j7o4Y4PbnWGBy xe0sdNgYzyG1NB0XUqeb2tOCnQ4x3YX0bYvt1ULYtHGMTicyMQm07FVGkgooB4Zo7bajuAW7D8Ctr KpUllRlje/iG0r4ir1Ag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r0InB-000yAs-3A; Tue, 07 Nov 2023 09:54:41 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r0In8-000y8U-2V for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2023 09:54:40 +0000 Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50797cf5b69so7151209e87.2 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=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=Rfck5FY3dF9200YZ4tXULFpESCIi8VAAOTwzFmje8Pw=; b=MGhHfp4wUNgbUfxDQ7n4YUAyst7G6mn5yHr1XJmexDZAVpldG7wq1UXjeNKlPktjQJ F1JEwE1Lu+IlOUc65bpJVSyu5vfZd6cBc6MMtuFskn5lmwt2MogSztIR6AazwHMSWu4m TykhJHsDNhVVvhadVynQy3rLLGQ4h49YivksVO4Klf0pOjDHg8198tcUhYm22u2t01Tm AwhzoedG61258w+HK9fgw/R1CFm0rZi42bU7l38Dtxyt7DqRd0j6L/ZuxA/LzngyotUy 3k9MtlydY3kOLgtu1V2sdnFp3Yr5QW5J3AKutmSiRsb6dH9YEJS2673F9CVesYfp1zBT meYw== 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=IsIqsyKReVQMOLvW1BW1O5pBR7gg3NnM9A0h01nF/VckVKmCnWe2//Wr0G+h7YZn+m G4EPK+yE3mIIYAhLGPieC8CAexHeavXhFnqdxFLdzZ8qsYjwso1eHTYGibOX5TXPlu7E UFMISnW+i0h+RDbN/sLqb+DJnd6DIXGIZvcfcBZfKYxmt1PZIJbw/kPRdPhQf4d9cZRf UM4MXzG6vmQy+wDpYi/z1S4D2nOrxL7BemHsT4mFx7dHXehpT0SCaAbaqk1/LL+oTd4e AAC2YaGajv5PL6uQTLp3foVOnMisnUK74JBszpmmmWO26zPxqhTDDZJTYRwDzGpT6PH7 pnJw== X-Gm-Message-State: AOJu0YxZLxg2sblMQ1vBbczUrpxBObj2PguFhLMdseWIpe/yPbu8QbDw BH0OO6VJZsbQ0FxAmbo1swtbitUp1NaprFq2XSQ= 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 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?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-20231107_015438_818281_B58134CF X-CRM114-Status: GOOD ( 18.63 ) 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 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/cortina/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; @@ -1160,7 +1161,18 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, word3 |= mtu; } - if (skb->len >= ETH_FRAME_LEN) { + /* Check if the protocol is TCP or UDP */ + tcp = false; + udp = false; + if (skb->protocol == htons(ETH_P_IP)) { + tcp = ip_hdr(skb)->protocol == IPPROTO_TCP; + udp = ip_hdr(skb)->protocol == IPPROTO_UDP; + } else { /* IPv6 */ + tcp = ipv6_hdr(skb)->nexthdr == IPPROTO_TCP; + udp = ipv6_hdr(skb)->nexthdr == IPPROTO_UDP; + } + + if (skb->len >= 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 == CHECKSUM_PARTIAL) { ret = skb_checksum_help(skb); @@ -1176,22 +1191,14 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, } word1 |= TSS_BYPASS_BIT; } else if (skb->ip_summed == CHECKSUM_PARTIAL) { - int tcp = 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 == htons(ETH_P_IP)) { + if (skb->protocol == htons(ETH_P_IP)) word1 |= TSS_IP_CHKSUM_BIT; - tcp = ip_hdr(skb)->protocol == IPPROTO_TCP; - } else { /* IPv6 */ + else word1 |= TSS_IPV6_ENABLE_BIT; - tcp = ipv6_hdr(skb)->nexthdr == IPPROTO_TCP; - } - word1 |= tcp ? TSS_TCP_CHKSUM_BIT : TSS_UDP_CHKSUM_BIT; }