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: 161784 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2301735vqu; Sun, 5 Nov 2023 12:58:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9qq1V9F/lhM0+2+tKXIAsROVMr5NxvSjTZlMTeL4xNIAp61KGftGJg4/KF9cxGVS3JEFb X-Received: by 2002:a17:90a:5997:b0:280:37c3:3bcf with SMTP id l23-20020a17090a599700b0028037c33bcfmr11839054pji.13.1699217893251; Sun, 05 Nov 2023 12:58:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699217893; cv=none; d=google.com; s=arc-20160816; b=L6nVdLlrfY6kD0+ea0YCwsMjGSjEX5EtQ/VTfpK3lpobfhlOgGuWFAfyxZF2ljn4zJ VRC8YA5PR9tV6Q016j2mLoxkzNPgOKl8JkY8TMNGDQDtWvfH+aq0XdI76qjKDlNMNI9l m2qmyP1u2dTNVnf1gd6XMz4lEijxMaYsoP56qUPvwqxUGJExnkZ12jQnV9S+uQIkDAvF uMTfbmDa/Le5GO0AHP5m0D7Lo8c1Fks8hF+J7+88yo7XS3lJKgUNzyi6CdveyzYazaet MYJO6zkEinL2F6SG3RkBjwvhStWzxUvr652pejEQIE568oeV3x5leS0FYnvyntKT1t/s uKXQ== 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=gQE5Q7bSQ5CYGQU246bebUi4YlUrrbixJJSlZ4tZEQg=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=obnYQOXrxL88uw98x9afvHm4K4lHr0f/ngLk1jIgPMQv0tPBz6AMdpnW4SxK6uHvBa eYrw/cWWy5s8nJm14yBhgYyf5gaSZ9tC4MqNRt3Ub9EX6AQ9k3mg4mHNTRgf2L6tNxQ4 izV10K1kBo+whWzCykyUQZPb5gtFsHbc9UcmucgnlXdrehOCCREejpizn2Do9vp+EjAK 8feQbMG6ynoH/eTZPIYYEkU3Gu7NYVrdqgD88djqtYVPobr8TBJjrFHNUCIWEJwvb/VQ 8gVbNlnY6el8mluc/607inRFF1sRa9SNzsuVc8X6NHs3kCespyuWGMqb53s0iacGesqw i9uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eebXLP15; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id g8-20020a656cc8000000b00578c9144913si6940540pgw.364.2023.11.05.12.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:58:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eebXLP15; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 8179A806236D; Sun, 5 Nov 2023 12:58:02 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229547AbjKEU5g (ORCPT + 34 others); Sun, 5 Nov 2023 15:57:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjKEU5c (ORCPT ); Sun, 5 Nov 2023 15:57:32 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB02BEB for ; Sun, 5 Nov 2023 12:57:29 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-507ad511315so5477153e87.0 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=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=gQE5Q7bSQ5CYGQU246bebUi4YlUrrbixJJSlZ4tZEQg=; b=eebXLP15HFRHF1NnfTmdlPXcVOVbnmtE9p8dzz+IYmqFzesu1EkR+fVaXcEV5iDmYe OgiebByePomyAo9ga9txe6TlOwSPNlgoXQgeqP5GACCp9bYrQXhPdRX720MlHUkbui68 cTzw/oERVjohWz//20L7BPP9MDgBvSTM3gV3Ekz1BWhnv7F1cqq6nApigEZKm9SFbfX5 35qt0oBJ5n74RnqT8hcRD33giUNU6gZL91oYfaxDcHRUNYftLzJwix+fh+/nb0U64qNJ KQl5Cvfpk/oBhmmquYMwuSX35Y1xqmTlh/7be3SCtg88PVBM0T49LTvZy63IfKlPZSz+ Si6w== 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=U+vjpuavYR43iyXgHTV23yW2TgfTmWBCezv/j7jzVrLS/4QNNKS1nifp9/mPIaUZFK f/+UFJ24HKN3K4Jc0vjt7lE/TlkH5OeBQuWj5kfFZfJtVAzFae5Stk+coVXDt+mLEtR5 rWwMbrD4y3qpAqfOTjG82VYVEShmUXR5nM2ugdiGUWHWPYm73aGrFfu34MuSXpALJEt7 OgubK2X+VdvOHRvk60DI3g2UHfbZwSMoYdaQLJ7P2MjMZBuG1REfmYmNOpkl8n3U9Xyd vsJZ42XoFdfjw+QVZUlxJ+Y+VEpw3CCv/7PpU1lkF6rIXXuFGS6SKitDQ9+/0zy43ANA 6vtA== X-Gm-Message-State: AOJu0YxC6H1ZVcIZlp7F7FvzfM5Ml0RAbTlkSmGuiidL2GhIf0uZBt2o EgA6bmEDeo75hOo1twwxBOlWNuxgcQxhVkez+RI= 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Sun, 05 Nov 2023 12:58:02 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781759101471797032 X-GMAIL-MSGID: 1781759101471797032 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: 161782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2301682vqu; Sun, 5 Nov 2023 12:58:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHpOi4YtNPyXBznQQqE/aG1NbKkfCQW0uMTP3qnNKANcGKq18XM8f9YZNBLgejVA4YBK4kR X-Received: by 2002:a17:903:120e:b0:1cc:2518:ef02 with SMTP id l14-20020a170903120e00b001cc2518ef02mr11676739plh.14.1699217883874; Sun, 05 Nov 2023 12:58:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699217883; cv=none; d=google.com; s=arc-20160816; b=cSHsevpb7imdaS0NekZNs8inYiD96sdO0oke8M9XGoCZmyC+5Lzse+eO+oP2IXgX7V jjnixncbId3wIeH45Xcm+VsGZJulQX3dB4Lha39lFOLospW3QCw13nHXOud9XByRT3vc 7krZKgGw2RNbbrCK3e3HCwziZuW/MGmuZwAH8rJwNj46/04kwMFOmrNJO3bz736Er29Y lHiKILwBbDU/DUbsdoRiP5hKDMCwkk4LUv/pbdH+7rRtBesn0AqDzNt8PX5l+i0emMYT T9Dglqaaa1E2964ELnLeQ5qP9r/052tViotJ0FGxswKFW5nS2jG3eRRhfZubuFqkGyX9 +KtA== 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=bcXxSiBEVr+D6MNvYddK228P16vPi+4Q9OnK68yFSjygTQWcaeFv9AgN9rohUMs04w maFe8C+Upcpg/6qdl9l7IxnWmWMosT1h03XSxZ+KGIpbrmOXi6Wl5NpsihtV6e5RX8Nh jHakH9ej2fjNw64Yf5dTpuLxZQH2oacdWv4ExV2Cm3Zi/GW6rvLh2enkSvxCfbTZC3Xd MRsl6IhN8GFDDesjbLCdJetgwwEetgPg4HvcVZxRBWUlUDx0EiXDGGwzNq9eNa1pBesg RvKHErdHDYzbQioLEY2xHOF1Cg4Vo6OSG9EPgFtG05/GO7y0bsH12zgoNmIqYP7Kf0Wn UgbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R1+nq3Qj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bv130-20020a632e88000000b005b980391aacsi6159999pgb.270.2023.11.05.12.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:58:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R1+nq3Qj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 7848D809FEEB; Sun, 5 Nov 2023 12:57:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229772AbjKEU5j (ORCPT + 34 others); Sun, 5 Nov 2023 15:57:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbjKEU5e (ORCPT ); Sun, 5 Nov 2023 15:57:34 -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 67A20EB for ; Sun, 5 Nov 2023 12:57:31 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-507be298d2aso4890364e87.1 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=1699217849; x=1699822649; 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=R1+nq3Qjdg2hCgC72Qjgy15PG/WFVs4o/VMBOjsxYk/M5itwqwYMIMVRnAd22QxoGD AjpsN4tVjWcRUdYrcNYQQ0zNSdTcyMdJoQ4HZ3h3keqmXIYrrzqCg54mdJhenrqehrhv VxqWWydDyDIQCe3iJcd7g5bJCbx6u6iSepetRD3QRrlNm80ZwKK6GI/7eGlQRRFECiJ0 YWt6h003w9Mtc1bNPOkVx5spZ19e7RIjJj6j768FoelffoHexMhASRHvnADFC+Ak+n6H BXh2YrgeISmaZPy8cvgJ3WPiCB2vUwStvwtIxKkznJKdlQvOsL1gfGjIv7ZHRZ6UvYla KhVw== 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=Ley4czkyo8ptSV/ttrbZb5G6fGvTEuGzkQNLTg/jVPJoee2XHpiplbEMmiNjeBN2Yb hSa0hxbdi2tBYHRzD1CMZQjMUxjO6r5fpkJaxo5WQXxRtzRsYe+XA8KkQz6wXUS966ft 6FiJEWpI6tRqw1uNWocRmVVYahtU0KJVS/TZpPC0d6UpTnG2NLZio+7jx+vqo36eWGHx Ku6FHEgpA7JQgyF9qoO3IOVR+bJkk2J95XHuawohNfckF3bQG6T+vLgvbswFzwCUaDpq i9nCGXIb+JXnbqMxmFZz1W21QO4EJ6Bx9+PnUj53rXykZEfeWEgV08jd/16ixqm2eMYZ IeaA== X-Gm-Message-State: AOJu0YxrGsr1ztNp14yV40Pa4WbbF1B8TZrNhJoIawjyNGgYzXlbFRXu rbZMGJuU1uUWs/Jo/7haZ2tWzA== 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 12:57:56 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781759091619618190 X-GMAIL-MSGID: 1781759091619618190 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: 161783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2301720vqu; Sun, 5 Nov 2023 12:58:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGfGFs7W3Rat4ZhcemiBnBYVMicm3/jdKjXxmE5rXBCljMkPHpiRJyj8Yk0Js88LXxmq85+ X-Received: by 2002:a17:90a:7563:b0:27d:853:9109 with SMTP id q90-20020a17090a756300b0027d08539109mr25348790pjk.20.1699217889841; Sun, 05 Nov 2023 12:58:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699217889; cv=none; d=google.com; s=arc-20160816; b=JAj32+y7pJdd9Tf4qk738maSx7IQWWf4twWmekdGVEsAyCTQuNwcSOrM4WstnBSdbQ eNuY9JSHfIW1XwNHg9cfIkFMGSv4Ld4VV3pGV0vDki9hUBKKDW/s36F89U1pypSm25Cs CVXf4BLwFz5zB0x8fttJaAN8fGZbmcZ0YtN4lICrPYda7XHJiHdhvqkLR65nz2miDwHy /85IXb2Br3MLzioLvALChH3jPVpcUJtS2deoKJEABn/sp+NzfGIEwcl5LVR/jbaXiKQB XZlrJPH071/123LMgIQlt0b4KGG9mCHm/yPVyKPyaOvCrewiiACUaDhqhxJlvspoVgNI BHkA== 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=hHGg7IgOG8aP3eorgAYgy9MJBjBd5UgvuR9R9eWvihw=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=F6MsH8ZM1CGhTz1SpkRRln0mVDGKtTnkNPp/300SqAl7+wOUN55uocELrjgECmR5bE wJ5YZDLGtY+A00VtYPuhjiOoa4H+ERjsPskodsNXMpHrLASI3vHz9YWsQ4VgICYcOTkb hSMobo6l1kiAJjBxzwNaMMXfnW6GXmkKfC9G+jtm7jydqd33Oh4AO59dLaDeQl/6Ruv1 bcqVSBfwfQBsMqQWbKrL6bhEq7ijGITvn15iF3ym2cbhSS1Y/8jylfowdErTIUuM6X9k y15Ne8psvDMiKVcNRn9JWZ7HG1Rh2nOKXdic+EALRbLtj6O5FdgmJATgJZ2stZs+m+uU 1hvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u8Wy9jAN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w4-20020a17090abc0400b0027ffe28ed7asi6526897pjr.66.2023.11.05.12.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:58:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u8Wy9jAN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id C9DA18053612; Sun, 5 Nov 2023 12:58:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbjKEU5l (ORCPT + 34 others); Sun, 5 Nov 2023 15:57:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229655AbjKEU5f (ORCPT ); Sun, 5 Nov 2023 15:57:35 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D268F2 for ; Sun, 5 Nov 2023 12:57:32 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c514cbbe7eso54279311fa.1 for ; Sun, 05 Nov 2023 12:57:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699217850; x=1699822650; 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=hHGg7IgOG8aP3eorgAYgy9MJBjBd5UgvuR9R9eWvihw=; b=u8Wy9jANe9JmWn3rXVAJj1iNV1dQIxXllohcGldOr4GrLo2+dAwpct5BXSIncZGY/V IynXdgJUzzzrO6bQQ/QBdlwqCjGYq4JuQ7IMEHNfQOIfthAw9fOjYgqi3u9/j0y8Nkmu Zerox7yAGlML/hU/LfOzJ0DxroanMhajcMYIUqHDJEP7ksfV3FaYXjMVCTgaU4KEjJbT PPx3a1ceGdTx9ei7i8YcUT61pxDiWXcM3X8l5t8I6QHnMdyxS82iT7nwfMD6pHhQKnsZ 9gCXzh5QWjOcbvhR/Ma/YmRtbGeHrJ8akaujvYhe0E2oJUO3OTejjOLiNR0senP2x+IV ZUrA== 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=Ezixc6WFM2FuR+NEcIeZCj2dzV6oMP9F7y9Zhyt9ayzhpnNMgwsz9MiihJimRhdA/5 RopiLpcqinjMh1Z34Kp3h4sTRBJ3ABymISVqDB2rAkvU6mLDvryl2mDBTiDxXPv5BAA4 yoZMzSBBPrp/vE48MCiY3P7nYfY93wl6HNPhzcBWulNshCfAqQUVYDMgmW+Hx4URp8rQ wMuiaoQaOKoFUqC/9J88NS0Xt4WItH13sF5/hKKkLXaKlgHkfmh4+qM5gcxL80GHZ1zM +jzOkFsNYfbrqvX0hDaLtM+R7lm37HOX9D6stOuAfasHE0C9qqDou02Ov5s+cdaREIOI ANKA== X-Gm-Message-State: AOJu0Yyd+SKImRMfFZRUg9XaPpXVSo53v9DwoV+xwfFtLEI8VbNYBgxB S4pSbjqtCuFa1syJ0hJ8I1VLAA== 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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Sun, 05 Nov 2023 12:58:04 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781759098188992568 X-GMAIL-MSGID: 1781759098188992568 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: 161781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2301644vqu; Sun, 5 Nov 2023 12:57:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFQiIhTDH8ZEjh+5qE54hckVov3deFziYHDKKQSThM+rXBxInUXeoM+YA+HC4tQkpH7IRAR X-Received: by 2002:a05:6a20:8e12:b0:181:a784:67df with SMTP id y18-20020a056a208e1200b00181a78467dfmr11368064pzj.20.1699217874590; Sun, 05 Nov 2023 12:57:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699217874; cv=none; d=google.com; s=arc-20160816; b=ynbzpULumRvEU4ERTiHqLSctWMBKwqYrVcibUGsCAogp5TeiqAgJUMN0O2aeAK1Hqz gddOfsjPdZBSQvL0DiYoFuzEb64fnkS26MjS8+N/99qBGS5Z9OtpVNQdUxC2bR24DqGD vmGoNdtlpiWScoWSKCI93Ufa8CizZ/jN8IyplDHX9A0iPQFQj0ff+iEAjUh0dVo2LAi7 N2MDZanax33Yf7e25CiXzNVm8nuI5jK/f+uGlPthweaTBlcVjfgrFUv/xe4Ki9V/sBT0 UB82OeO1yBO4O98b9UUC/nrkijGxeAbruq4Eb5I5WqySwgBqiM5JbNaR5MsmHF77Y6tA VKYQ== 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=SkmUkmLoK96BNboao7deauYFXBoeWm6vYd1S1QHVdg4=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=DOTB/Tr17jQfHlgS0pcGkcKROgk8l1/pc4T2Gxxzl0mOCCkHTcNb7wS9bAkt5cLuMX EDGAr6x4HMmOOe1AUCOfUtHHwZ92Apn7eExAisuBPcJH7pR7eP62CUNfDPkAo+izIN9/ N1jBfZP2WOQ0acWYMOVKrHEUSsXj6Qi7QBgdh+QJSMprp74TlmAoC9Dz1Jz5E7E+foah EVFeZaQ91zjHR1c3Oio5BawRqoHPoaalrlNL4sRZz6Vap2lvJxQqJDNvvGTFt3x79v/2 Jpd5zXaHc443/qDByf8DedpAbGeWSebcwuUJEheoaHLPwwrjbtHDGSKB2gfi6JgTinNR IBWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NVrow5zP; 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 e11-20020a656bcb000000b005b9b68add7csi6652785pgw.881.2023.11.05.12.57.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Nov 2023 12:57:54 -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=NVrow5zP; 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 95B8080C247E; Sun, 5 Nov 2023 12:57:53 -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 S229811AbjKEU5n (ORCPT + 34 others); Sun, 5 Nov 2023 15:57:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229690AbjKEU5g (ORCPT ); Sun, 5 Nov 2023 15:57:36 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2ADEBE1 for ; Sun, 5 Nov 2023 12:57:33 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2c5071165d5so51621591fa.0 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=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=SkmUkmLoK96BNboao7deauYFXBoeWm6vYd1S1QHVdg4=; b=NVrow5zPhOARUcJ620qmCGf0cuZ2picFuADI/ObES/Oco0TYqjoz1pQJyywbgPD1C5 hWPzKNDAjAQoBAnTXQB9f3b2XIjSWOFdHemaGM8KUdgl/gsYa9p6tP8ZUoXDaNuTN7Pm vNYT3QpLD32izsPve5f6HGIcG3ku8VcUpYMy2QtAKBTuTqqcmBBA1K/84x2xZXlfJLG8 g5kZO/yf7dCep1JDglfPTx3qW90oaIkGqxb5whXumg/QOHu3/63p9mYGIpkqquy3niW5 yXPknZ60LFWXrqcHMlLoFovxG9N0fV+Ru1UAyx4eIlZQh4jxPyjPdqBX/F5Y3SBwlw4h Z+pQ== 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=vObtsb4s/4OVja7J8hQtiIfzvFFxXBU5VOukmdg5+SgQdvklGUiYtTXviaQK7WacGS hhIDChwuILZCG4t04K3DkYl8D1dSgAFBFn2G32EozP9xQFZRDwMsZv8xeEX6c4E+nFfj EiY4Wxo38zWkdmMACPgeKC5uLi5Amb9JoCPCpVGZhAnCTt6DZDelh5xdcM3HdsPt3+T4 90FF02RWJRZykO/RmO1FZoHl4hPuyrMKPR3e7Ym5pVlLNuVlkJIinfxhuTpF8vcMNuK4 +TqdEvckpcKPys7HJvWegMw8YPb7epyFw24F93OFaifxrpcdSx17cRRnxQd6InLfUNKp 9T6g== X-Gm-Message-State: AOJu0YxI+Txtgh14j70n/iVdaC9aLyKONF9Q7MCS49j9VCG4tvHU/M3I a7TkwBBR8dxepN7vtfmBva7gkQ== 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-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,URIBL_BLOCKED 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]); Sun, 05 Nov 2023 12:57:53 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781759082170299684 X-GMAIL-MSGID: 1781759082170299684 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)) {