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: 162358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp124860vqo; Tue, 7 Nov 2023 01:54:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGhZcT/vuS3tOp3ivfuBkxruNExUSI7dIA+mZIDLJSt/MBLmZ0BEuZlhPLYLrwbJ8FzYaKR X-Received: by 2002:a05:6830:410b:b0:6b9:bd9d:e333 with SMTP id w11-20020a056830410b00b006b9bd9de333mr37598770ott.3.1699350884430; Tue, 07 Nov 2023 01:54:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699350884; cv=none; d=google.com; s=arc-20160816; b=Nw0GvauFh8DP5mHbu2+WMdeyKA/uY9IGvXHefVo/85wYA82tePjHAkrGy/EA4ZnSYP w8lWA/ipAHSq6AwZ0pmh8Z0Ak0nUo4d/r6U89ziYNsVMgzRRYXRcvn9Rile7cE5HjsS+ G25X3o2/td+TQ3T473gdcHhtOLs5LWs/77dQ+qXXck5A6Iwt3cTP4bhjOv1zQxXXYXdS j2RwqIJ+GzVFhKu3wmaFQbj18oMCt2BdTjvZt+9WZzOannr6dssFMAjN1CHbw3RMsMmi VY8vXYb1I3ROxJWGTZvK0w+GRj1fJ1YDuDM0Lwns1XZSZVOAhMraDBLQqAtGTO02xR7P R4QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=JloLY/S3J4vbR80IcKlfhvbtLk/oEHP3bZQboIzjIZc=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=hNHCVtk+np3KOYjAzNCUrK8dlKWMCjhe6ZN3BWET8X+7OJjA57STlND9gqQN0c7w6L IA+2IHiF/SYIftJPHZu4lScN0EmPbtmeXKw+OSTrQIX6LflyPecjwkd3NYCpP2mJI1kK 41S8QVX7Ngs+U7moGKc/eAANGRifj34xxFThs2dGh8JRmNbDmp9HFncWzCaam/94H6cS CxaM5stqDu7MdU2eF5CEjn/ROrKYLQB/9SBK/1sAuZ2+oSMscCpVXnGzxeZaJcMrw+0X SO4DT/b0S6IYsGSEPBDM8vA+ibPOVd0T56/1Kh1CbXai3dCr7b0nOvD/kyp4NPYTW006 C/BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sWdBRhM/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a14-20020a056a000c8e00b006910070695fsi10555229pfv.31.2023.11.07.01.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="sWdBRhM/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 67C7780E73D8; Tue, 7 Nov 2023 01:54:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233941AbjKGJyk (ORCPT + 33 others); 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-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 07 Nov 2023 01:54:43 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781898553104402778 X-GMAIL-MSGID: 1781898553104402778 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: 162359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp124901vqo; Tue, 7 Nov 2023 01:54:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHzCr7KXMvAP7hol2Qs+HP6XVjdNq2/XG+yoU6TLTw/lpJm29oJLb/wel536S2CaieFfXjg X-Received: by 2002:a54:4e8c:0:b0:3b2:e60d:27e3 with SMTP id c12-20020a544e8c000000b003b2e60d27e3mr30635141oiy.30.1699350888955; Tue, 07 Nov 2023 01:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699350888; cv=none; d=google.com; s=arc-20160816; b=WJFavlde+YuOw8e/6qoW9rjPQNfSjfL3vEOWFnQXRcp+xjgfplG24FYI+eyOupSFwE sQc1s8Yo9fQphX4kFgFhUZk2Q4Hhaex3GC7M2P+eTHBPwIaxZE8/c4KTX442P95v61xM aIYH3JJvxEg1hlTHBDu8xEhEkrEPKCvIZFKlcZcMgoKXcx+fcOXcq+yILqD+YsWODZal tJfHcaNc1RntOGoCq1JZ6N3RxU6mhkFVxrwMLyU5BFnfvSYnkGBSgvvpMG6n0jzJEF1j VP0yBQecWgx06YAd0eQx7AEyZbGaeG60emg2m6TH6OKOqTVCXNG4eL0uFbEd2gC2qxRh i80g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=9I/5QuNpGxNYQ0Q3gYhof8mVfyBGfSfCNnlFCET9W5g=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=vWuLGiYkkD9+dAipEGJH4TzS2h51H7G0ND46wDH5EGDIZm4KbmKcK+QZ3Szv60rIjH WYssWukw73w9AQWpSnzGQm1USszWK9GUTckLXvZ3QPHwxWn/dTW5Nbpgz4Ub+BFCWNYd 6DB04Q5oRZXdxQzQd8gp/Q2/cHzKihCe8XCmMrIGbyEyRyoZwOwMSr/jkAnJf9DbeL88 ejRbXTCrJKZrk/Unlm430MhFxeIg7T6NyrvnfuuJOyi3z8JtAFgScyn+Vcb28cYztUbD LH/y+uBzBbqyehSoUjppbG1KjldCLmVu4qJ7RKrG+/6fi8b8t8HIr6v8aFCynuTcN+y+ pPVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cw8sWqgK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id h22-20020a056a00231600b006be1dd29127si705588pfh.127.2023.11.07.01.54.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cw8sWqgK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 01ECA812AD27; Tue, 7 Nov 2023 01:54:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233965AbjKGJym (ORCPT + 33 others); 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-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 07 Nov 2023 01:54:48 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781898557601931267 X-GMAIL-MSGID: 1781898557601931267 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: 162360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp124909vqo; Tue, 7 Nov 2023 01:54:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHcdmgtsKZ8mUXTSVOSE/mYEZLQKe/C5t2uyZyIiykNy1ex4FyE2oBDNwXu/Kl5AheJ2SW3 X-Received: by 2002:a05:6358:c8d:b0:168:e614:ace9 with SMTP id o13-20020a0563580c8d00b00168e614ace9mr36255159rwj.11.1699350890976; Tue, 07 Nov 2023 01:54:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699350890; cv=none; d=google.com; s=arc-20160816; b=bDmJTZrlG4YvPO72VmHyXQDiAVClnm64nkBfRXwYuwLdOwaDt5/c+aj0Ryd2eLnSuJ eU+0yznNS07nMajrTTIs9y6mxDNBbpnXC7mpNupkl4iERDMKbAZ4IzHkhkBvf2aQUgNZ DXap58/JeUeseyN7Ksm3FwnjC/C6PBb+LFWV9wiRJs9hHmeE9exWHhtCLX4vq9cHHO43 V7MspVaYJxrUI3q9b0pfRgMxPC73EABPn6Q8hOJlzidLtzWqXP4ZI86cnbkuNSWqo81q GDQ0AZXc9RVPiCECSnD7kgEm28Zem9sPSK7NPnZGBpKkADvc29rHsOW72Qzv8aklN2SA Gn9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=7xqcp7l3sLztmXNgaaMhSUStMniJux5ggXCgPLhgfhw=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=iHSZ0ah8Q7JTkjI4hWIq6PXx3EbxVBzUyu4kniqywomwg+Frxzr6CYyKfg3wSRD1yS YTxnRaOpQJMMwKeVrBdN9NjFjXPLqP2RKDyITY1i8Np8C9xM7AiENtE183+rjTV+oykp mQzYVy4f85Jguj4tBf87NMagrUqVFJwo+tiht4hk5EojpD7xuaP4VrfVaBOOf7O/grnC O6uq8tLDWo6qDRgt3zLax4PM14udhmZsnj/sgbRrEjzcwfg0vinofSrDB9dFU146zejl Z9tTeUbXPehdTn2r5sVCkxA8rX/4LID1QknFSDUZIhwzSudEymKEmio70kciNJbJJKbY 41AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=adFYU4MQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id m20-20020a634c54000000b0056513361b4fsi1724690pgl.741.2023.11.07.01.54.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=adFYU4MQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 34953812AD36; Tue, 7 Nov 2023 01:54:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234025AbjKGJys (ORCPT + 33 others); Tue, 7 Nov 2023 04:54:48 -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-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 07 Nov 2023 01:54:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781898559640650656 X-GMAIL-MSGID: 1781898559640650656 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: 162361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp124924vqo; Tue, 7 Nov 2023 01:54:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGo3TK/1erYpr4CeAWM6TIhDynmUKDV7rlsXv/QTEamnsViwQjM5YeYkws81++qovshgToR X-Received: by 2002:a05:6a20:8e08:b0:17b:62af:e63 with SMTP id y8-20020a056a208e0800b0017b62af0e63mr40122465pzj.31.1699350893764; Tue, 07 Nov 2023 01:54:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699350893; cv=none; d=google.com; s=arc-20160816; b=H9dmgwfPgm/x3ahHOCh4aTel03i6dph+vkNSt3hSGpWKXc4qmh2V6iy8v1o/IYmVVj bzl5uWXCLrplAn27y4LUBe4CjdmQss3hwkLSeOL8NvQQxzi9X9M/SvOJDZYIAefd4Rac X/sK6SvVBQnmD6aC7hf+L8pa24OoLSC2u02MZsn9grWZzeHQqY05L7pOhwBHjKthhcr+ ETxvwQ/QMS6jJukfSGmPDjUAZgYF8mpYWlFhFUeH83oVLyMTeQAEK1o6hUirySlFaAMz G8fPOnL4v82WaIbRS2rFtLSxIGIWpZCJXmXSevU7ABiFmDzxQ0V8DbEVl7aJOLyLYbdT DSqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Rfck5FY3dF9200YZ4tXULFpESCIi8VAAOTwzFmje8Pw=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=xSwAir7aKi9N8i9ltDgoUlF2LLWWLgJlWeumKYonNsaacOgYAeRVKKaY8sqJ5W95Jw mtEjTKQZKayjBq2tu/UAXsUDQsLDaB0S/d3fuhM0LxIYUA1F8zXYxII1BC/t0NZ7whg+ 2+pCW7R0x8rQElIJ6D7G3Jw65AASfGqlqcm4uyLoPSXvSiSb0UKanj2uXf/DJ5pFd3uU /Sczy55lSkIZ5rqMPnu9rNBeH1VAR0cdWGDmTmhW4ILb5pz+Jq+o9H79RYuhW7M3AxE8 t2F7igpkFo/LgWULufW19jMUNbZgJZPezAGY2Bw15zNAT5AVeRVExX2wAlP4BnSncRjt 15rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jaqEPfOj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z32-20020a634c20000000b00578a98c0687si1722131pga.99.2023.11.07.01.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 01:54:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jaqEPfOj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BE72E812AD31; Tue, 7 Nov 2023 01:54:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234005AbjKGJyv (ORCPT + 33 others); Tue, 7 Nov 2023 04:54:51 -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-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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 07 Nov 2023 01:54:52 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781898562809279387 X-GMAIL-MSGID: 1781898562809279387 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; }