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: 13450824 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6831C4167D for ; Thu, 9 Nov 2023 09:03:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M9Enao+zpjVJPq43LiNdWEXnUcAsW36iwR+vyTH8+hE=; b=CQB9WffQwvjABn Lb2U2z5TRqZXaRew3mb0VWt+BpUnMyYTh4QUceeTH5lq2HDChfnOwURp+YpzNGzgwQ8T/er2oDs5/ UabEq1h19CtruWC8AmTaTRHzuJ47grsnwMMjlgX1FoMr2ERSlMOQwl8LuVpve0os1dKkgCrk/VfV8 ZCSFhDDe77mnVeTq/ecle4136TQQC8RmjseeElDbxAK29tYfVO5x3eqzbcpPqeLxM4j/behWc5PRL 7FKLkOe2xWv3O4R2sNlTZMoztwVI0017FlEJQNLZmCizM3jX4ibe6j40dXc66uDus8nAUIOQydbgJ AgpLOIWvzBT435AH5llA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r10wb-005iMT-2K; Thu, 09 Nov 2023 09:03:21 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r10wY-005iJZ-0d for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 09:03:19 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c6b30acacdso6814611fa.2 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vzJIeWNq2FEaPyhEpEI6+O7cf3g+sTgw9uPY1dLEPEs=; b=JmDWX85Pojh/k3UQLFl+WnvMb1O4M0Hh+K7C0XW4XTjytGnL1rH3KCCzg3vaD8taPC txbCYBB0/u+JX/WV/cQcskBGQbWJuWfoLwQmBosjx+qExCpKxJ1h1dqlHjSBre8rdOpy AxSyOhV2ZBje6fSjxVSBk4BmZjq7rGVKrgD3YGZ8j0smTXrRumLg/NrUIsm7lFoyKDle EZkcaWJe1mL8X7qTpT6aNR//IobZ9BxQBZv5susJk4JH9jkXnDpwYW7uavXrw29iGMV6 hWtWRhDRcFvcbYdTvwZ6IFowCrjd10HHxOHK7H3Tdl+R1rUtk7YTlbFVCCnOq5BC8jIw +uWA== 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=Ejfg9+72XOoJxq5i6tRItN8jZJtuBRHBNvYAjE2vgfYtyzFa9BsjIykRjk0CCjHJLd YqTqxqgHqLdb5JSYlME/GurL01pZPCe2Qr61FNkRYfjai8DfXFjcPK7yNrjcJUV/edda nTJ2nXRFgzJS1EPBHuJ5IgVWf1+DLfz80oycjb7BR9TPrj+bXoAlCZpPvSZLYVkEnMbZ E6VF1EgP3KbK12cW47pVROBx4y6bmAt/IKqOpuXu2HcTmwWWcajEVrS9wWv0nIrGqeDk fpAd6cDWGwggJTMoHw8MQ8Olu2yZVuVpPuPzuw5e0PmROQp4wSA2oA4Sk4yu4fZxsje/ aVwQ== X-Gm-Message-State: AOJu0YwEqqDYkWDtuMr9NRIg7UTdiLp7sunGUbM7/+ivXwtap4X4yFLg +f4JZ+H6mydfO7KRNdSvbrL+Jg== X-Google-Smtp-Source: AGHT+IH0sjqNLl/veK2UKnVf2/NE7U4+3ND+oxhdQlRbHZbnIHRAFaAKtPKKAo+K3oMuEO5OM9Y+qA== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_010318_235990_E01BD878 X-CRM114-Status: GOOD ( 13.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Enumerator 3 is 1548 bytes according to the datasheet. Not 1542. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") Reviewed-by: Andrew Lunn Signed-off-by: Linus Walleij 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: 13450823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C3EB7C4332F for ; Thu, 9 Nov 2023 09:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=kZ3ws3Dicl8zCIVVQl44jY2n3fxxhe8Np5GO0RbY5s0=; b=w8GEpQgBC9EWbG Qbuu4vRt+ePqXjff+HgQNi+XIhr3M9GWteduHII0WT0mCn+yxoUesKdMduS0H0/akdy+/tdnR9WB3 aoQt/LgOmjKDkLPtiZaJNDYCa/5UkzUyshE65qakprbbQTr9FElx4vZ+NEKWTIuIJ/7GlPsY6bd5S zFdm7Un6tEjX8dxRC6srTYhiMqT0W2RJ07QN0YCP8iiovG4ECdY06tQsUhQxH+kZUzAaFti0D8iIG Y+T3rY407IFoO97VQsYqJLHBuslDCfwLBva8L1/lLxKpoDUsR/JPyhEkBevlglyaFVRBoVaNwKnA6 Sb9sOBt5lHWVW1ewl0Xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r10wc-005iMp-0u; Thu, 09 Nov 2023 09:03:22 +0000 Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r10wY-005iJs-0d for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 09:03:19 +0000 Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2c7420d5a83so3746141fa.0 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=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=aC8LSFbrPW68Hp+zttgMH6wC0575N6ndnCuu0kvQp3U=; b=XlWdp4q2uiGQ1XlnPL24xUwDfOwEwaG9cLMY5Y5ev5cKEqHbmuWApUN29qdaRt9se0 fyVu2WmzQNryYab5RfABDm3ad7yXNrK7iO1UtrJ31ri5JFSsz7uDs3LaCrQxEuU4t/HE PqTfrOw2PEYAv4WpFJ2tRWYUjDL8P2BHCaxhwWF8lEox+XsnF2DkiR6lnwpHoTZfbm4l s9eKcepzvyNyxeR/e9oW8BcJBRyWmr6j9Xve9yMg8ih2J/Y1OQTNwzra8GFpWtXmWaBm ChslPgqS+tMX59TpZag4IRe5nhgvgRWE6vy7OspCZxgjS+yvuAoQAwW5lE7R733h+ivs j85Q== 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=rtzVTVhvprF50pw/32LAJkisYfSLex2veCNnzgMS7+GVlLnqv98FZaKoeyw1W748Yt 9lpz6nMy5QIsVPTrGOoXX70d+Ssk5oIWfkPDDU50fhBuFElcP5wlmGDWGOwp+mDo+Xpo w4WZPutczbwDdhZNX/4RcHkhb780CVyUIluGuuhrGlK4hNKwshMBMEw3/HqKNUVyKi/b XpnT4RUhp0FCq79QnZNammsobgrOoed9B+bL+fwwvr+HxyS9JR20E1cxSHMsO2Umk42n ho1v1dr+f25gLl5ZlFMBiVDexVYiRNCQ8Qx9HOzHBsmV38B2En9gw/ABqvlwK+tLyYNf sdiQ== X-Gm-Message-State: AOJu0YwXv9PteGCxmhT+ZjG5uWJeLKGftIgXdY2cRq/lwpZ59lK2c54N WW/XTOj9Oc0AcaJ924VIght6XA== X-Google-Smtp-Source: AGHT+IHoDrqOJeHD3P8tw48u5vyH0Sw1wB8cwi01eZho9VrbWwPklDV2CqEV2k0vWTpPDakTgfwwRg== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_010318_235990_93B7701B X-CRM114-Status: GOOD ( 22.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Gemini ethernet controller provides hardware checksumming for frames up to 1514 bytes including ethernet headers but not FCS. If we start sending bigger frames (after first bumping up the MTU on both interfaces sending and 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: 13450825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CA71C4332F for ; Thu, 9 Nov 2023 09:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O4G6er/huQvgzBW/OEPphJLrfYZbpwmU4Vwsj7I6hAw=; b=Z+O/nwoAy5u4SS fdp/4GGURAbMYbKp2MI95dJunrVyVD+ojOK1uso5mSMtqjLiE0EPVbJpzjAaQ3qKqVdyGM/dvHHJa dThrCfAb8k6XisIBaKT9CfjbzN54E38cIF2gbvX2CrrpJ00KP6RfrGSlNm9Fe/vGHxnFBGAp8g0D5 7Qg1yXmXrImatZzS0awJ8NtT6sWNESjhMJubQ4CIM0XPwhq/p0CWk619lkmT33bYw1KjgmytxI8w1 edjoyIB4IuuBBV8X8NRE43PgA2MnK9ddcSo4nAn4WkgwiZLHIMOK0sheqnfmlgNKR5TqqO7EjQUYr x4hENM8mVAYUKEqzeqqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r10wg-005iP3-0H; Thu, 09 Nov 2023 09:03:26 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r10wY-005iK4-26 for linux-arm-kernel@lists.infradead.org; Thu, 09 Nov 2023 09:03:21 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c509d5ab43so8202951fa.0 for ; Thu, 09 Nov 2023 01:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699520597; x=1700125397; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=3LORq79d2KWiO2zsyhGNgwevjLWkh4YlRcW/4qVJO5g=; b=CHIFKcIRX2m7SUbdV7I49X9E3/C0j3FLOCHpeRb2h6Nh6lUh6Gksheoll0hfPJvxXo T0BnF18UZhGdDBLemUW+3dmCigG7HfyqfdZAK6oIpAA3Evs7x826t/mdGlqY0irLZrTH uqMJdSpP16J6jiMBKLSgwm3rsUSWbKU+RimKWmEtHrWtlYPiRFx/hir69NDEo1hlCZgW w6XuHihxWYQLQMUpWEk79xwiIxF4O45evDWxbplsBFn5rxnKk5dEx+No7uaT6HLRButp y42QIeSKeDtmjPSqiKXq1/nI6w7U6R4B+5cQLYGd3Rjp8hyAKkOnYQlQdnbLrqM1/gd2 /qUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699520597; x=1700125397; 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=REwy0MXgfbgwsBODs8OBfEYstm3rKvkqnQY5cWb2Y5hBnwApFqZie+DoLAxNH1PvA4 ezj7wvEmGHGZPp/BumR5IM1fXYtGWbbumqauAJC8hSezFZgyiMQZPBbGuEXdYkgfmJK/ X0mpFA8NUUIDgwqNzfFvyw9buQWBrbyw2/EwIeb01xWNdEqv7TwHgEU/dzO1KoazTiTs ym95FbfssFrr/7t1FbQC5EmV0UtJk+fYWwkRXqpfPZUfGNyGgkVP9z4/9MjAdOwg/8C/ OxEDgMCfW0ItzQHig9/J8CUcoK59WMdnyI+evAVHFb48a4T+SqUMoAESnab4B38kim0H v3PA== X-Gm-Message-State: AOJu0YybvyfTE47etafGQLKdUymRKxPlvhBNvlzAv6z7wZVxuEJDsauF a2wAeQrerStXO8ERnfeNl7WmYr8t9wIXYgzmYp0= X-Google-Smtp-Source: AGHT+IF2mb2GZBOKU5NXn4xWX1KfmPMioQ/7KZHFjewuwHxEgnC77hOGACXU+QAP8LrJWhu2BAZcXw== 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231109_010318_700586_2C8AFEDF X-CRM114-Status: GOOD ( 16.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The RX max frame size is over 10000 for the Gemini ethernet, but the TX max frame size is actually just 2047 (0x7ff after checking the datasheet). Reflect this in what we offer to Linux, cap the MTU at the TX max frame minus ethernet headers. 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 {