From patchwork Thu Nov 9 09:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 163309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp306795vqs; Thu, 9 Nov 2023 01:03:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IET4rb4+Pl7xVviPAs3dEVBB7Sq4+HbMr7Rm8z6LzAqdtli5zN45BWlzytB4qhvBiFs7Y+H X-Received: by 2002:a9d:76d7:0:b0:6bd:a47:7bb6 with SMTP id p23-20020a9d76d7000000b006bd0a477bb6mr4526454otl.14.1699520632611; Thu, 09 Nov 2023 01:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699520632; cv=none; d=google.com; s=arc-20160816; b=aPQ8N895ObSn2CqreJjHkjdvc/wHemAR7sUGUeHvJcbc50mNtD6j/oHz2O2ZY9qgGA xcrTa+ZajhQHLpnJNhlXaAUtNvfccGIbbTcxXWWDOHaPa9iwTiYgu/licXW60Y7PzpF6 hCO4oLbb9HfMyBwJqbuw2pylJ5rBe8d+TptH79OB69UONLk0g8Oy9XjUs786UNVACsdh e6fLz4GdAVXrTtsgH7M8zuqRczN2d98FEUkqoWMN2QOYZw0EfWUUwdNKJdG6qpvEXW1J uAzSUOyXztPgJEJrzb2mNpr4VKBcTk/OkFdqTNAnR10Ob4P/efCDDo9UhfB7OA+phgko u+3g== 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=vzJIeWNq2FEaPyhEpEI6+O7cf3g+sTgw9uPY1dLEPEs=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=Gkj37odO1zQgOWzHU9YgGGQAWNSwW8VcxfNTQ99lC9xuG2J16OuR25hq/oyeGEnFZE Zzn4zIwVRVDmBKLTLfKCLXVTBjC7X5onHpVl4FHyU5//YUNC/qu4FfJd365mKP7fBY6C HsPepIehOlBIT3X/HfDZbK/3YWiwEnTErol9XCc1q8hFEu8nFxZ3Rj/2DVSHSW6Lh8iL wBtKQGHYBOIUl9BICz9pynVMe+J/yXTbAtxJya2KCCAgPQYbNs340E7YCAM53GLxymtq Mm7LMIDNtoM/scOkc6V2xLhvB7rGXS0wbnCtMijliIgrq0BXYLGL4JL7/Eu3Sb9B0ETa XKMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mYpbZa3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bz34-20020a056a02062200b005aaf19c3981si7698756pgb.329.2023.11.09.01.03.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:03:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mYpbZa3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 16FDE81E5D2C; Thu, 9 Nov 2023 01:03:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234123AbjKIJD3 (ORCPT + 32 others); Thu, 9 Nov 2023 04:03:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234116AbjKIJDV (ORCPT ); Thu, 9 Nov 2023 04:03:21 -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 E3ACA211B for ; Thu, 9 Nov 2023 01:03:16 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2c503da4fd6so6898721fa.1 for ; Thu, 09 Nov 2023 01:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699520595; x=1700125395; 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=vzJIeWNq2FEaPyhEpEI6+O7cf3g+sTgw9uPY1dLEPEs=; b=mYpbZa3vIe9EoNguaotcW/iuSHQ5nJBhgru7WF6umoDpHN8iwGyMUVIzZqeN7eSC3l bUROfxyTyv02qOd4rGh8NC+KC69rP6AUrqfKFV3nAS4z7hQulpEAySIvj2YDKQls4mlI AojGS0iRcvbzcwYkXhI/m40+2CgdjYHgCcJQBpDpurkLQGVCPZCZc5IdPJg0d+t1y9f0 RgujTfifKDufDowdBz6SUtKczS1KGL8L7QqF9lfjQH1xFJmd36RoajCR9HwiPFBrc8ue NKBDQnl6UlkdtCu2HTrURXahxmyMNTRihtRx+iwZ2j0MGLkytjexc5aCbi/1wx1Okb92 12Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699520595; x=1700125395; 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=vzJIeWNq2FEaPyhEpEI6+O7cf3g+sTgw9uPY1dLEPEs=; b=R698cSV98WV7GTDHgBpoNiZNgWZf4Jh7JevMPp5EovIToTJ486D2wojmHcSxtwNqSy drlCqX2jrRGreNThGDutnbipkhw2WWEC+4h38XMI8sONwNkmyxMlxV9E9nOak7AWg9+s lDayVuL5uOdWda/t7tjb4qF1SRmX9pJdzwKDv2GJCMxWdNkcaOaDilW7xgNx7B0UBpLZ k5EEiNX+iN7Twj2v/qhFe6XSO6k+KVVtFmnePtrPLtlIvQjB95VVEuZ5eD9BTPbPP6np Q7EQH+18gnlHg1fzE2+3PfgpQmYqmj+ihdcLek7gtY4lSpRyIbOfFfha/4OmHS7BYDxA +fEQ== X-Gm-Message-State: AOJu0Yx6Ryn3AYh7arWyrLH1Nyxm/ClZDXmnlnzLeX7nQLxvyGIOXi27 VB4m3gY0QDpn4fa1otIFrLi4TA== X-Received: by 2002:a2e:9e53:0:b0:2c5:cac:e9a3 with SMTP id g19-20020a2e9e53000000b002c50cace9a3mr3404465ljk.52.1699520594884; Thu, 09 Nov 2023 01:03:14 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id h19-20020a05651c159300b002bbacc6c523sm2212383ljq.49.2023.11.09.01.03.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:03:14 -0800 (PST) From: Linus Walleij Date: Thu, 09 Nov 2023 10:03:12 +0100 Subject: [PATCH net v4 1/3] net: ethernet: cortina: Fix max RX frame define MIME-Version: 1.0 Message-Id: <20231109-gemini-largeframe-fix-v4-1-6e611528db08@linaro.org> References: <20231109-gemini-largeframe-fix-v4-0-6e611528db08@linaro.org> In-Reply-To: <20231109-gemini-largeframe-fix-v4-0-6e611528db08@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 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 (fry.vger.email [0.0.0.0]); Thu, 09 Nov 2023 01:03:49 -0800 (PST) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782076546871121200 X-GMAIL-MSGID: 1782076546871121200 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 Reviewed-by: Vladimir Oltean --- 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 a8b9d1a3e4d5..5bdd1b252840 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 9fdf77d5eb37..99efb1155743 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 Thu Nov 9 09:03:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 163310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp306857vqs; Thu, 9 Nov 2023 01:03:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IHYKbYwCTLKTZ9u2tBx89tngHPPYXXMN4yJDsXFHmnxaiV2WpxAAmiCIdKHgLurhlVb/Vsv X-Received: by 2002:a05:6830:12c2:b0:6d4:7c93:bf00 with SMTP id a2-20020a05683012c200b006d47c93bf00mr4749177otq.23.1699520638165; Thu, 09 Nov 2023 01:03:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699520638; cv=none; d=google.com; s=arc-20160816; b=F+1EksVUVSd+EXaLAFH0jhdigs3+be886bKgy/ohbOim80uatkxohfHO6NM++yT/w5 C0WuIhD0VyYCrHIszexDAfUl2IPKLKMuct7h1vVzgDL6cwGIg/4YF9iyPxXDzpX0twgD zUfA+/j6yVaDQpPiY+0aTG0Gw2qLSuMi3tCv5gWSBgtDEWwStNLqufGBM2TGO6wgOt5D P6328kV2eun540njc2ozrxzhXe7i2facYPCJbYLNwTOKP9OCc2bSjWwge2L2qsCBzVe7 JYuWhQKjpcmgSHtO+zIcAgjL8AU4mZe4or9G8wH1GPrDhN1tw0ITsIlqENaWOjaJL+r7 DsyQ== 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=aC8LSFbrPW68Hp+zttgMH6wC0575N6ndnCuu0kvQp3U=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=UWFLSaQoYTIQDRmpWRIKsheCT6SIKoPnWKNzCi3Hk3qz046R/+NVweonh7uLjTHNd/ de3562aJvSEkqEWu+EZT8baQNzKTFkVj54En8vJg8+XG+ynzEIP186gDX1ChyobNG0oT Rg+IEDTfc3c7n91w/rqNJvmQgzeg2S2tVQQnCI7ATWcLGTnr9aNdS2i61RbCjfd+lvC8 mQ9NFQKyQSzD9Ktgl4ef7ZtQ4IpHMoPGqkexoqlVYqKI8sbtlOTrTDq6p0S/ewp/nKd3 W/g8Qm+BAC+AMpsAqNeEPyxGm9qLDPMdmD9PjWtZ4ggam/c2VljTKOPJBTB0EUJyDK6o EhpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KfIJEmWs; 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 ck27-20020a056a02091b00b005b8f6936eb4si7151708pgb.773.2023.11.09.01.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:03:58 -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=KfIJEmWs; 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 F3031801C008; Thu, 9 Nov 2023 01:03:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234119AbjKIJDb (ORCPT + 32 others); Thu, 9 Nov 2023 04:03:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234120AbjKIJDV (ORCPT ); Thu, 9 Nov 2023 04:03:21 -0500 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA0912D53 for ; Thu, 9 Nov 2023 01:03:17 -0800 (PST) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2c6efcef4eeso6758421fa.1 for ; Thu, 09 Nov 2023 01:03:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699520596; x=1700125396; 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=aC8LSFbrPW68Hp+zttgMH6wC0575N6ndnCuu0kvQp3U=; b=KfIJEmWsBKMIMPyg/8glfSplb7JaxQvUVljaU3sZZgAVJ526I66ZJ7jMcm9E0kcFPV aAUIwFNGyaUj8/ztpVsb57Rc72XGkhAhByewcD4X54XIz+COpvpw5oL37YMpRTJxaMLt 7K/gJdcf73G9j5+1I48E/6d+qMl9rG/697Y+zKUNkmEVgLNQZf1CbzcquOGLkSboFxFQ CLCGG4MSRyH3HSRTpHvjU+Z1NNzCjJHmRqqLVB8/fj1scyWQSbf77+1bQMNQppEztrsf 9ffkyATa8zM/3YyOrz4+vcipFmv2R58HFNSr1Ynx7TD3E6gl0QeN3cv+boo6BKFc9f96 L/Ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699520596; x=1700125396; 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=aC8LSFbrPW68Hp+zttgMH6wC0575N6ndnCuu0kvQp3U=; b=jUltGzZLl7th9d2GvQT7S0S3kClVR7bElSqmT9bk0syyGXG6/20eoX50hXOAlSHX6K QasyWypEFpF4HbAucwIovtUXJ0TLbrnn+ZXq8K0tc7H8akBTLXtdhjMOcrdFUCiNfwkl Lx2f62aYYKAzH10KP2c6T8fHG2BznIcKdmQ0j/wSgLkoMah89a4HplUB75FQCatmigLk Wh7ZHE2ryQp4te6P0nNDRyyvOSJMmuQWAT5t94uGL9gvV5DOmGoxdIcLj40jrIjf3egD 7DfLiLJ9uvzd4cjV7Yy5+EmLH0dZy9FfE2zULWT0znDuhq2l776LE+zGUykHnRIEHwxb 7hWg== X-Gm-Message-State: AOJu0YxpzDlSEuqk6oOQgo/ZZo1Fuaz5k8I/nwxA0e8/EJzHVZRhKrvh QTukkFl+9ygQyTYmX4RTxlCmYQ== X-Received: by 2002:a05:651c:104c:b0:2b9:f13b:6139 with SMTP id x12-20020a05651c104c00b002b9f13b6139mr4288294ljm.20.1699520595911; Thu, 09 Nov 2023 01:03:15 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id h19-20020a05651c159300b002bbacc6c523sm2212383ljq.49.2023.11.09.01.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:03:15 -0800 (PST) From: Linus Walleij Date: Thu, 09 Nov 2023 10:03:13 +0100 Subject: [PATCH net v4 2/3] net: ethernet: cortina: Handle large frames MIME-Version: 1.0 Message-Id: <20231109-gemini-largeframe-fix-v4-2-6e611528db08@linaro.org> References: <20231109-gemini-largeframe-fix-v4-0-6e611528db08@linaro.org> In-Reply-To: <20231109-gemini-largeframe-fix-v4-0-6e611528db08@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 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]); Thu, 09 Nov 2023 01:03:55 -0800 (PST) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782076552880013616 X-GMAIL-MSGID: 1782076552880013616 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 receiving 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. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") Signed-off-by: Linus Walleij Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/cortina/gemini.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 5bdd1b252840..dbbccef86516 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; From patchwork Thu Nov 9 09:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 163313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b129:0:b0:403:3b70:6f57 with SMTP id q9csp310434vqs; Thu, 9 Nov 2023 01:11:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGz7yTITppNJP9sXdlfXe3+cR9IdJ8hHhv8rx5x+nWWjhka4Z8uzF0Dr0nQfBIVQB8zll7 X-Received: by 2002:a17:90b:2b8d:b0:27d:469b:8847 with SMTP id rs13-20020a17090b2b8d00b0027d469b8847mr1655536pjb.3.1699521082949; Thu, 09 Nov 2023 01:11:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699521082; cv=none; d=google.com; s=arc-20160816; b=yr1tdICyJQPorOAWTgpMQwrtvDz4/9N+w3Nr7Pty9nzXce2dW0uTZPfo1WQZcDRK8V haULN/mir0pN1mNbopD5YJEnVQwvmr1T1HpvukwK85kmUo/26Lmj7xJMfWL7b342lMLV y+usLY0sSn23bXrIFAoieKBREMTEzX8RmjA+QUbBI0xNOSV/u7Md7UaHzsis4hOTzciM EEuvmt+e9BTz5b/d76bC3Xq0tDK0d7eL+nBFVOFyCLyfqbdCViTBMLuPEgiJ7NwwAdWd 1GZXWeepzosUE+8p14tHWnhPzLTy3lpWSmttA0pxmqcRzuvQ5oFvHM4K+jaLjqCSGtwf Hx9Q== 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=3LORq79d2KWiO2zsyhGNgwevjLWkh4YlRcW/4qVJO5g=; fh=G3jVr66/sTBxblB4VkyKBP17P5NL/3UjRtmVOzWFD40=; b=rivcSkaj8xOJO4YNG2zPQggucyLhgu+LB1NJqZNyTw4TSWRjBncl7cyymTXmVESx3P qnaUrJoUpvpxfyoMz0DY+/NdblhaccIYiDqI0AhHngtlNKYoy6NGy8a9Q6yHGAhe6uaH L1hc3oFLU4zL8fsr/aCDKoSX5cQ8LEzFngcCT0GzkrV5XeKgLTIXnPdeNHgyAptvi46c IlFwUAPw+47FeuYi7o3u5mBGJ/zK+Z+CstM19GCMJ2tlM5rQ2ZJsxdtQuL2FjfQdx2ya ecAeRqk1uyHhx7kBe1u3gKHAD303miR7I1CThWsEBfo+Fop8rc0ntLkLdrOgwE9WJ+Zc cZgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rY2x8RVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id pf9-20020a17090b1d8900b00278f81e54cdsi1357457pjb.19.2023.11.09.01.11.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:11:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rY2x8RVY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id CB7668076172; Thu, 9 Nov 2023 01:10:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbjKIJJ7 (ORCPT + 32 others); Thu, 9 Nov 2023 04:09:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjKIJJ6 (ORCPT ); Thu, 9 Nov 2023 04:09:58 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A6A9173E for ; Thu, 9 Nov 2023 01:09:56 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4083f613272so4319795e9.1 for ; Thu, 09 Nov 2023 01:09:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699520995; x=1700125795; 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=3LORq79d2KWiO2zsyhGNgwevjLWkh4YlRcW/4qVJO5g=; b=rY2x8RVYepX4L872ZaDWeeDgDzh4HRywExgN+iDPArfDhueD70nYg6JwbJw9dlIkxI EN/6IQxkCRT/Zq1xun/68LCW4d8vb59z1EmJlGyggO6usztVsoC88dKN+BcS2uYBD4J5 00JEaCGAKGVS3bVTR/S5J7nmr+RNk5idopAE6XUN/ZQeiK/KBaGtaoquVlGSBme5uEap j/JMdmMiCtaedtP4LY6d9qZO/ZOuTIygQv1IP1qa0cayiOPT8i9XjoNhya18QC0t7ThS wFI4ZlaL2yQQ5oWlQ1FpO3FOtE7kRGG/dqqfJRkAvKhxMRuOumtqrCkaKUQ1zC5ZHiPu I2mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699520995; x=1700125795; 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=3LORq79d2KWiO2zsyhGNgwevjLWkh4YlRcW/4qVJO5g=; b=QgUzuhGOG5P2LzxlXsSxLogjVL6enFHYCAkBuBf7djawUf2P2esD3p+wP/YYPhW1L3 f/2imNtbSuCLC2pIMPdKpKuci8sfmvU6WAkg4TsmAz5JRJe5kppzUGfI4RA2hI+kgHx6 HSDbHV9l+FJMgGmXG9rT5Zy5CFz7WZSe/z59JlAGMr0TnKoxGrICRQavc5HnOKhMh4b8 7EueYNs1oKiVIjgMX0GQKxc3enm47YcSBRTo+f7CrIUNidTcOlQviIAFYREABMO5+i4s T9al4jl8qRsg8xD9bgxkRmK0gFAED7XDMFRLz8jwmCpP5TPjgJSYySeQKufB1vK7R2wy nbyw== X-Gm-Message-State: AOJu0Yz87tNeCHGJ1fPlee3hftJNQ27UJbKCXd4iJYO+RI9sHxBbTrf2 a7GseukvoysbpJkNHMJ8Z39KIp+G9axc4yff+EI= X-Received: by 2002:a2e:80d6:0:b0:2c5:a21:8388 with SMTP id r22-20020a2e80d6000000b002c50a218388mr3713516ljg.29.1699520596806; Thu, 09 Nov 2023 01:03:16 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id h19-20020a05651c159300b002bbacc6c523sm2212383ljq.49.2023.11.09.01.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 01:03:16 -0800 (PST) From: Linus Walleij Date: Thu, 09 Nov 2023 10:03:14 +0100 Subject: [PATCH net v4 3/3] net: ethernet: cortina: Fix MTU max setting MIME-Version: 1.0 Message-Id: <20231109-gemini-largeframe-fix-v4-3-6e611528db08@linaro.org> References: <20231109-gemini-largeframe-fix-v4-0-6e611528db08@linaro.org> In-Reply-To: <20231109-gemini-largeframe-fix-v4-0-6e611528db08@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 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 (agentk.vger.email [0.0.0.0]); Thu, 09 Nov 2023 01:10:17 -0800 (PST) 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782077019369416307 X-GMAIL-MSGID: 1782077019369416307 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. We delete the code disabling the hardware checksum for large MTUs as netdev->mtu can no longer be larger than netdev->max_mtu meaning the if()-clause in gmac_fix_features() is never true. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") Reviewed-by: Andrew Lunn Signed-off-by: Linus Walleij Reviewed-by: Vladimir Oltean --- drivers/net/ethernet/cortina/gemini.c | 17 ++++------------- drivers/net/ethernet/cortina/gemini.h | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index dbbccef86516..636949737d72 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -2000,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) { @@ -2234,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, }; @@ -2486,11 +2476,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 99efb1155743..24bb989981f2 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 {