From patchwork Sat Nov 4 12:43:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 161583 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1625360vqu; Sat, 4 Nov 2023 05:44:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRp6FquU1poHL6CbUMORb8zd5rFvTUBx3MEHji0uamoXPCCM6pvKBE0hg6gLd2t6/hHJjc X-Received: by 2002:a17:902:6949:b0:1cc:5e1b:98b5 with SMTP id k9-20020a170902694900b001cc5e1b98b5mr13935078plt.66.1699101854281; Sat, 04 Nov 2023 05:44:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699101854; cv=none; d=google.com; s=arc-20160816; b=EaZszxxjMFW1J0Vwt2Jl7TGoejklQe0d33rlB2jxZ16areJgny0eiUaQq+NoNjRcBy zBpW7dFcGTacVxB/kmMxLN7ccnFRUBPCegdzl2J5V4/K1H4i2BqeVBaugDkhCCBX9jxo zzHD2heuxZhUv3HSeLbiV87g69kQWlPdEltAS7BLPS9JGX0PRjGawcjp4cAzUJ6ki2Qe JWzR0zt83eKTASzS3lscKifE0nEpC3hxGa2x6jziS9rlkSEG9gbpk9TxmjlJS1xO2dkn QiaxM2y/iG08wCv/7qbS33UK2/kCvAyc09R0soTHugmq0wzvrAFBQSqjJu5kPz2mz4T7 pV9g== 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=9Oy6YnzrrQAU74UB/BgNy8fxjGeu1ULALolZntz7GpU=; fh=bYuvYY+UAm+RKkoLNBZQ9/NmrCpqb49Mw9RYUbh+sKg=; b=NvhB6xQZXDSwGT23eazwJ6qvQ3G3IM/s9/5iXFyIWTl3ELt1zREvRAcdk3EYL6nyFy oYkM8T3/5SSS9bUVrcO4b1pYpRtlQIZIG2bK4eK/EUz8Wc3cHbk0+YwxdnetiCkhqVT6 K+DLcSL5W9PtcJL0tCXZMxieKsFUvH7j+9BEinxOA2uJ9OKrWSaq088qX0NjhYJYwnLx 5CZ5xuPgpmmdc2jJ1kKsQ2H43qUoGdFY2zP3mCvo/1rP95yHIYS5mv9uzGbGzNOkoV6y Ovv+WETwPSsCLz5LtRCODrj3LdyujUZbZWm9X6ZBP7nuInMerL/aN9SMH9WbGFidfHUq 8aNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bckd4k8Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id jw9-20020a170903278900b001b9ed021929si3554815plb.225.2023.11.04.05.44.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:44:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bckd4k8Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 95FC28051ABE; Sat, 4 Nov 2023 05:44:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230163AbjKDMn6 (ORCPT + 35 others); Sat, 4 Nov 2023 08:43:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231348AbjKDMn4 (ORCPT ); Sat, 4 Nov 2023 08:43:56 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E21DD62 for ; Sat, 4 Nov 2023 05:43:52 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-507cee17b00so3736721e87.2 for ; Sat, 04 Nov 2023 05:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699101830; x=1699706630; 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=9Oy6YnzrrQAU74UB/BgNy8fxjGeu1ULALolZntz7GpU=; b=bckd4k8ZwZWtVNFCjzqnJOHxFhsIXC9HPD4IS9cTYlU2EfXQ1/xY9lVF7Sm8ETRbUE g0qf51je+M0H0FQOHqDKssCUjTzO7tRiPw2ZH8V/tMrx5aclgws3a9sTdxUrd01ovi4F 21ijAT8ibZTaICo9vCVDGlAUoUwY9lpdmZSXKny6kg8oJcw9y6+Mnv3/9P9kAs4LTle1 JSQxndFOWQm5R7LwlerhD+4+l+pZv0kW3zUehWUBnITPUWsgmO6q5iMK5igaSNKUjOv7 315CGLHSqXGfxn3Mg0bjgP426dla0lKEFj/wKNN9YcWmmIebPyT8G8GC2IlIqtOsz98N 28DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699101830; x=1699706630; 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=9Oy6YnzrrQAU74UB/BgNy8fxjGeu1ULALolZntz7GpU=; b=UjmEaYFHVU+pX+h4lhw5zjFHDhkz2vErFbKW4OLTAJjKyujqzkIyxypY0ubD6l/j7u Vela6lWJCj6XWaGew/Bd6gPsGD2Ytn1G+QxA+pYfE0RWuB0DcCNCt0QBa100iAp89OCL 6olY3FMrbq8tHjuMzzaL2d07DQnTUytKxZpnmlCHRNwDXVaMvWB8aUzwgIOw2kTCEFPt kObvSa/qpIZzZ9X75z0Lluuk4gRF00ORX3W8gDyfuSg2nNQOiTs4WKd9ndNF27bobgVZ mMAWKjQu49hI8MSApPG6vjmk/FqiMxhLB2rv76zwwDVgAjjR8jippFNj8tuDJ8ArG/Lf TXlA== X-Gm-Message-State: AOJu0YyU7S+Li8vyOxNkrjZrEFtwJYXQTopny+iXpK2bcleVFQY0XUQJ 3VXFx6UX3ujMxpDVbde4FZqyFg== X-Received: by 2002:a19:f80e:0:b0:500:7f71:e46b with SMTP id a14-20020a19f80e000000b005007f71e46bmr18641913lff.1.1699101830741; Sat, 04 Nov 2023 05:43:50 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id u22-20020ac24c36000000b005093312f66fsm496100lfq.124.2023.11.04.05.43.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:43:50 -0700 (PDT) From: Linus Walleij Date: Sat, 04 Nov 2023 13:43:48 +0100 Subject: [PATCH net 1/4] net: ethernet: cortina: Fix MTU max setting MIME-Version: 1.0 Message-Id: <20231104-gemini-largeframe-fix-v1-1-9c5513f22f33@linaro.org> References: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> In-Reply-To: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Vladimir Oltean 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 agentk.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 (agentk.vger.email [0.0.0.0]); Sat, 04 Nov 2023 05:44:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781637425906956677 X-GMAIL-MSGID: 1781637425906956677 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 --- drivers/net/ethernet/cortina/gemini.c | 12 +++++++++--- drivers/net/ethernet/cortina/gemini.h | 8 ++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 5423fe26b4ef..e12d14359133 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1151,6 +1151,11 @@ 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 (mtu > MTU_SIZE_BIT_MASK) { + netdev_err(netdev, "%s: MTU too big, max size 2047 bytes, capped\n", __func__); + mtu = MTU_SIZE_BIT_MASK; + } + word1 = skb->len; word3 = SOF_BIT; @@ -2464,11 +2469,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..d7101bfcb4a0 100644 --- a/drivers/net/ethernet/cortina/gemini.h +++ b/drivers/net/ethernet/cortina/gemini.h @@ -499,10 +499,10 @@ union gmac_txdesc_3 { }; #define SOF_EOF_BIT_MASK 0x3fffffff -#define SOF_BIT 0x80000000 -#define EOF_BIT 0x40000000 -#define EOFIE_BIT BIT(29) -#define MTU_SIZE_BIT_MASK 0x1fff +#define SOF_BIT BIT(31) /* Start of Frame */ +#define EOF_BIT BIT(30) /* End of Frame */ +#define EOFIE_BIT BIT(29) /* End of Frame Interrupt Enable */ +#define MTU_SIZE_BIT_MASK 0x7ff /* Max MTU 2047 bytes */ /* GMAC Tx Descriptor */ struct gmac_txdesc { From patchwork Sat Nov 4 12:43:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 161581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1625327vqu; Sat, 4 Nov 2023 05:44:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYj052GtVXqXhskDvSZyp8JNwtfH0ZQJy+nPoQV1nUwYvTosTRio8KW1SQ32PDIvBcXdcm X-Received: by 2002:a05:6871:330f:b0:1e9:f69a:12fd with SMTP id nf15-20020a056871330f00b001e9f69a12fdmr25485113oac.58.1699101849483; Sat, 04 Nov 2023 05:44:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699101849; cv=none; d=google.com; s=arc-20160816; b=PDZdK4NjdnF/y7Cg1Y3B/+zwZnpVIwTcgcwGbVwZnfPTrlr518wgCxsZTNLzJ+sg3u rC0IzKZ2RcolbvHCQvyqqwexd8KoVJ19Y7JezaYhRa/CqKLpm8FvhD6G8DkV98IH40eD Mt50JI1l4wA4u59TaeRfIWMLrnxJSTUNVWmzGjt2CNU0PjFRVYaOSnechBvpmpS7ni/7 hkOSdbr26NBbl7zHSyEeIHLkcsZyimZK0LkmZ5o1aPoAojnG0Qlojk+g4DFNwqQfeUQk 8mP0fBXclDX0fJ5HXW/tU+J8a/EtxTvEigtzUp+i7nczvWO1S76Xts4RzQsb4mXqVyu4 YlPw== 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=QWgOFAkaCrL22TdDDJiVpTuZM0XAGRWs9ieW0NKW7II=; fh=bYuvYY+UAm+RKkoLNBZQ9/NmrCpqb49Mw9RYUbh+sKg=; b=0h64SxQ9SUZOxlXvKsa5Jf2rAj/8ofrebG/Y/WC4JJp8SJeqlJntYA/g0Jbq5ZwQap MruozX/Z73wKzBv9dur0hpMtoIjtz2l7H9Kn2cIWt+uMRPKkrL6BEv5Stn8xXhnpKbzR YvZd2afY4aZ7PqN4oN/17xYeo+JVvDyo4a8UpGeGMco1fzbIHBAwk5vWL/fngx/StbhF bPHT8jrH9iOiKP4OC9+ic8w0ci2tWnNPig1XbsAADap+BUUZ7qmYRXBMAfvT9WX4fnKo BWVHUfwP6eDLwzNIVpw+8QOlOk0msjXEMZ0DGVIZ/j0Ggyo3vJYFPqTa4aVTD+kEKtDx 4zoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fzaz3lDG; 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 by12-20020a056a02058c00b005b9b68add96si4116933pgb.470.2023.11.04.05.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:44:09 -0700 (PDT) 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=fzaz3lDG; 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 9A6638042597; Sat, 4 Nov 2023 05:44:08 -0700 (PDT) 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 S232091AbjKDMoD (ORCPT + 35 others); Sat, 4 Nov 2023 08:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231538AbjKDMn4 (ORCPT ); Sat, 4 Nov 2023 08:43:56 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F929D61 for ; Sat, 4 Nov 2023 05:43:53 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-507a62d4788so3892609e87.0 for ; Sat, 04 Nov 2023 05:43:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699101832; x=1699706632; 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=QWgOFAkaCrL22TdDDJiVpTuZM0XAGRWs9ieW0NKW7II=; b=fzaz3lDGtWmN0cUCFT7Iva7piX0heeiCfuSuxVjUKedBm5fMw95+gqlowm+R+MZyDU a17jaZu2Sv6XTm7lV2c+JzMpwpVFhpwK/rpMPPUp8is4Dgl+KS8T7k9xQu90hk6t9oM7 ++j5sJtL6YfD3+quANzBVwUZsn3LeDz9PAsLEAlKEnoM45GAG5FrQblDkUeXhx6oE2fL /X3NxBLBsyWcvYLtlAOaEw8EjoAQA75WNNP82gQsRFdHrEOqV3nglXOq3S6499pGUZOt 9uz3CKOupefq9pmCS4+H7hf61RpUq6v4x1ibGWjm2R/3NGz/d1i3quuQGJia63CqrF3f xbDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699101832; x=1699706632; 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=QWgOFAkaCrL22TdDDJiVpTuZM0XAGRWs9ieW0NKW7II=; b=SBRtmOd4Z/xTdwmGgTKnNK1Y360BpaqRDsj5m8YchdxrZ1MVz21n/+0OlntXbpFGMh YHOyuuBWUvBwYc+QwYmXE4TFUUnKQufmNjMufSfDvUsDXnOfqzMRSMqIgKhY0eOMAnhg PWolcN9l63xW/72Eht7JISICL8WCx2KPWJkBUDNmswXwmTPHl4EzTCNK+3mcXdqA0nKC ZTr2H6lG8G7kH2rkem3TS713vqz0Ra5BkAaNwcGh7SDbeKL4/bNh3i0nT3YFvJcqFp3F w/szTfnG6X1GXrJE5/7FjqRkOsrk0kk6olO5/dBZrdF6GmYOZikeDUuAD1eNjbEDDkle /xqA== X-Gm-Message-State: AOJu0YySsJXds0j8/BXjwb0ZvjnW25/WIdcWi2r/57wOAIVzPGN5Lv4W D7CS6+Oh9e/kGrLa2DW0Sac2mg== X-Received: by 2002:a05:6512:3196:b0:4fa:f96c:745f with SMTP id i22-20020a056512319600b004faf96c745fmr23906142lfe.38.1699101831782; Sat, 04 Nov 2023 05:43:51 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id u22-20020ac24c36000000b005093312f66fsm496100lfq.124.2023.11.04.05.43.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:43:51 -0700 (PDT) From: Linus Walleij Date: Sat, 04 Nov 2023 13:43:49 +0100 Subject: [PATCH net 2/4] net: ethernet: cortina: Fix max RX frame define MIME-Version: 1.0 Message-Id: <20231104-gemini-largeframe-fix-v1-2-9c5513f22f33@linaro.org> References: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> In-Reply-To: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Vladimir Oltean 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=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]); Sat, 04 Nov 2023 05:44:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781637420895676669 X-GMAIL-MSGID: 1781637420895676669 Enumerator 3 is 1548 bytes according to the datasheet. Not 1542. 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 | 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 e12d14359133..fd08f098850b 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 d7101bfcb4a0..e4b9049b6400 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 Sat Nov 4 12:43:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 161582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1625355vqu; Sat, 4 Nov 2023 05:44:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHevcOwqaWv3aL7yixTvnP75yHT3sES++RIzEOqVG/5AGj77XMCXu+su5vgNrUvJEi4ocPx X-Received: by 2002:a05:6358:c82:b0:16b:3cc0:4fa4 with SMTP id o2-20020a0563580c8200b0016b3cc04fa4mr6951876rwj.30.1699101853228; Sat, 04 Nov 2023 05:44:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699101853; cv=none; d=google.com; s=arc-20160816; b=nqegeN1bCFmhjSPGY0/NkrnwT/yyXH93lxCGQckmViiKhpkt7EkVFxxe91ySR4PQw4 J5lnD7vsqruknjru4fXKBPklL1GH2L6Z0xRHaPrjWzubOBXtLUxWgmH0a+KqX/UerEYB naNAoF2aryaaUILk1bYUsj9LvZTU57243xdUd1YikxZ12tYQG8HWmWV/KtBcNgBUrHci WhQLsQOw4AZ8NTbL1qrK7lBWcGJhrvFn1t8X8k1YeYciHHc4GW0Xk7jhVdnT5Z9OC3W7 Q1e7EEmL7tvB3Ihi2MOByPjZZKm6K7XrnI4Jwt9lgmXJxlSZ5O+DnAFG9DH4dnEVkhYI yNkg== 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=vbrVElpE/LRcXL9QrTPOXjtUB0U3i3Et1aitWER/TV4=; fh=bYuvYY+UAm+RKkoLNBZQ9/NmrCpqb49Mw9RYUbh+sKg=; b=HjarZjjcGgm6UkpFYuD2iCgE5ZJGvb6HpqWAXFMxqvUCnTz56CngOhAT6cIJaBcQhc g0CGG5CgzwzgtFDmVYYPHWorB2Tf1LFO48apRX8oAPDChJvEY2VMcA9ab8i5AghVTfJb aBYD/kTwz4sB79j6IEk8R055UkSPEskR2jRA3Le5wnbL67o+/h6DL63JXEtJNyd8S3le rc14vRwgek5kAfMf2axEyV6ZR8Ht5geWtJSxyqDkoliH46+2+vIv8MEHmF5ysO/r921z ZYWcKTEyXfRQ+YvChB9RNohj4/l/xJq3+CTknUIybYl15m9psxRb1XwSUYmeq245XmFK O+Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yy3Uh94e; 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 v64-20020a638943000000b005ad8009e304si3647031pgd.784.2023.11.04.05.44.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:44:13 -0700 (PDT) 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=yy3Uh94e; 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 538FA8040EAA; Sat, 4 Nov 2023 05:44:12 -0700 (PDT) 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 S232003AbjKDMoG (ORCPT + 35 others); Sat, 4 Nov 2023 08:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjKDMn6 (ORCPT ); Sat, 4 Nov 2023 08:43:58 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1BC1B2 for ; Sat, 4 Nov 2023 05:43:55 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5079f9675c6so3866973e87.2 for ; Sat, 04 Nov 2023 05:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699101833; x=1699706633; 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=vbrVElpE/LRcXL9QrTPOXjtUB0U3i3Et1aitWER/TV4=; b=yy3Uh94eo9ISIt7N3igeFW2Yn93KkptUPRKaRqm3tc95Hckgfob3SSvrYpMf9QyCGR /ae+NOo9o1uiKrgwVONTOQBO72lMiC6bN7n66oLerfIJ2I/pwJf4PL+f1sF4ft/CzB0q /vGTbxUE/lgnK+bCgP8P6nnnbRAfQ5vUMmbvxEbiwk7Ufef3G2Y2cwbrKgDi7uFTXeWq Tl+YJTVcdLA0SJ1cmeyRz6t7l71Mut7g0W2F1R1BkYG3Mh5t6LJAOHYgL7vq+UbZzA6B RIpTv+c4wD/6J1i/g0A9G0YrT01GB6ZUz5UeMOex12P0p0QTCWR2HYVXuPqifCHvn7NV Cm+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699101833; x=1699706633; 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=vbrVElpE/LRcXL9QrTPOXjtUB0U3i3Et1aitWER/TV4=; b=ni/9i3PpXzZP2jHCv+AUTLo1sM1xGY1AZcTAOCDrvh8ZpNM06SWurMfgGPjzB/yYIA ACHhW8E9sUr5GakJZvTtEKV9IfzJpKi9m0HjajVkWbPObRJwhxVV/yRvinIA5wc3Tg0E t2WUAzYXFtEUyQA+PUTRVjeirrrWPt2bKTxe2FwpbBxb7zFe/2QBcTgPBYA2i/05d4cG 7tppPhviY7sqICcnlAAj1pK88Y1qd3Iniz+oQiGuwY3Rn4ExbjAX5VHt8DuzrnXkDIDZ AjXBwMpcME0no1Fo1ZG0xM/aNN4zO+3mIYYMr43mpNVQFvl1j9+BRcJl1MJn+V+oDHeo doow== X-Gm-Message-State: AOJu0YzV0ZEzoJkAzz3NO1tgYTbVBDDsZYGalYrAgxh/nK/77ZXR6IHR hdy+y6kY4GjX+ml0ARTsAs56GQ== X-Received: by 2002:a05:6512:b93:b0:4fe:347d:7c4b with SMTP id b19-20020a0565120b9300b004fe347d7c4bmr23951283lfv.7.1699101833426; Sat, 04 Nov 2023 05:43:53 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id u22-20020ac24c36000000b005093312f66fsm496100lfq.124.2023.11.04.05.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:43:52 -0700 (PDT) From: Linus Walleij Date: Sat, 04 Nov 2023 13:43:50 +0100 Subject: [PATCH net 3/4] net: ethernet: cortina: Protect against oversized frames MIME-Version: 1.0 Message-Id: <20231104-gemini-largeframe-fix-v1-3-9c5513f22f33@linaro.org> References: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> In-Reply-To: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Vladimir Oltean 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]); Sat, 04 Nov 2023 05:44:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781637424460664392 X-GMAIL-MSGID: 1781637424460664392 The max size of a transfer no matter the MTU is 64KB-1 so immediately bail out if the skb exceeds that. Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet") Signed-off-by: Linus Walleij --- drivers/net/ethernet/cortina/gemini.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index fd08f098850b..23723c9c0f93 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -1156,6 +1156,12 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb, mtu = MTU_SIZE_BIT_MASK; } + 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 -EINVAL; + } + word1 = skb->len; word3 = SOF_BIT; From patchwork Sat Nov 4 12:43:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 161584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp1625559vqu; Sat, 4 Nov 2023 05:44:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7pft3LIl6QDcBM7YAaJTdk5ZUr6VE95OXvEnNEwr1NH8pA90DOAzNkWenAS2ufVlbWRgG X-Received: by 2002:a17:90b:4d12:b0:280:959c:660f with SMTP id mw18-20020a17090b4d1200b00280959c660fmr11881579pjb.27.1699101885844; Sat, 04 Nov 2023 05:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699101885; cv=none; d=google.com; s=arc-20160816; b=Z4mHpns3vRV7XZ4k8a7ThSGdqr2Q5qC39Bh1O4scDLOK2E5eKbXLGgfQOrgqLfLLuy 0Td2SpYcs4uqN21WPOyk9HhQDeZ/TXS+PlrBZe96Q3PUPbfNTn+ra+cA/iT6ZfiDTExs uCR+aQF3k3rsL57W04pxkeImhEfzl2ox8CRwRBNs9RjLm1LF83fcTRVrKa3y5f2mqI2B MNRANDvBLyMGmAVD5+XfHeVagEVP5/LIj81x99AfnbAy1Dkqlwwo2MFX7FoPbBgXnQuc H3YHMcSL7vSrrGlV0SwSnSfKjThyPkSRZZvkHtXifbK6vf3vdt5tjKDd8A2HLh/ci+n2 wFnA== 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=lGuoNoybmpAHVbeBRQ0Y/xZn4w65B05owlyMy7HgTuo=; fh=bYuvYY+UAm+RKkoLNBZQ9/NmrCpqb49Mw9RYUbh+sKg=; b=JCMilHSNdEfu+NDtvNBeNEAw9sNhOYQTG2VMIsI0xG2JdSxAEbF0Yk7rkalhdNjbks Y/I4RrkhU2EqnY9LOZOAOsj74btH+wayJyE5zgBGxNhCdUdiHnY9I91jQ56CcWcIRwim Saa+FicXtR1apn/ZT3StfuVqqFiirO9HBFDsfkpr5+a+Kt9BA+rFZIQsUjuYE5H5Vzkk l2jsuYGkSzoi9lTEvnw/KbnmtXn04U98uIttft7npXcfHLEpDwsbcIydFWQwUhVy4C+k FjNWRdmMvIZsYDUj47tQWmZx8cIDB7PH1F9E8daHTM/mz/fht88vg53wgzgKxVG00tds FH6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2xvWO4S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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. [23.128.96.32]) by mx.google.com with ESMTPS id x20-20020a17090aa39400b0027ff8a38ab2si3621599pjp.155.2023.11.04.05.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:44:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d2xvWO4S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 2B9E68051A24; Sat, 4 Nov 2023 05:44:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232210AbjKDMoI (ORCPT + 35 others); Sat, 4 Nov 2023 08:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbjKDMoA (ORCPT ); Sat, 4 Nov 2023 08:44:00 -0400 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 414B0D4C for ; Sat, 4 Nov 2023 05:43:56 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-50930f126b1so3657125e87.3 for ; Sat, 04 Nov 2023 05:43:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699101834; x=1699706634; 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=lGuoNoybmpAHVbeBRQ0Y/xZn4w65B05owlyMy7HgTuo=; b=d2xvWO4ScSw5iDGGrf5T4DdSaie2rYXL4P08TnmhPuTytCXNw16vb9TzYTpT0snlbg HJZUnMNOKFLVcUh0YZ4Qex3UDoIE5jpiUVrowLCwkJTzzJRUWhmVPq/ujbmhAAbQxogg Ppu08ekkM5OrENbvJX+0Ir5z4yeoU3evZN+YibULApcl4gAICZFaRtEr/sTBljFM2cXi BWpfe+kNA9MPS/abpXvdHQLNtkCML2QQe2gQxeHmTAzo241bRMcu8KbBwyrB/Wx4zQgO fLQWp0J96w779pogg1S8ZBPaGMY6CiY52ES1x9tThamt7ygywOrvuUUfTSJcx0JOqTJu qtfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699101834; x=1699706634; 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=lGuoNoybmpAHVbeBRQ0Y/xZn4w65B05owlyMy7HgTuo=; b=lGevPvw0t68dO6Gz2XF32/jSdsD44GuyUKwchBXJdv6bi075f3oNhPrAeCif/b592g j2/uoC4iGqRP+u/R8c5mYG2dnSRP6A3xZo7tMs8arGJAAbsPb1HbrRJpxsWVqpjiNCa6 LPrLvWYaaAiN6NlJefKqPQLBxoLfTjP+1HI/K5hiZoHPOHRyAna5ZlmJH/nnM9in972V 3BO8kmjW/POfjhBh/vJkhHNyTm+oS5/Nq07QR11ZQd8R9NUa9ucvFklQRFzYDNYd7geY 2LBWC2LTFC+k5JgIrBSTv/S9FSjIsWT6blDKlPZKcBE+zrGR9OvmyV8Du3TPPaHPV0Km TBGA== X-Gm-Message-State: AOJu0Yx3nACEaQp+zdMpvumoLRDjhouIPulnR1sg3wtyUBxPJVhfHON+ u7umiYWBp4rVbnSyNvRcLI0E3A== X-Received: by 2002:a05:6512:3f29:b0:509:62de:71c7 with SMTP id y41-20020a0565123f2900b0050962de71c7mr825163lfa.2.1699101834505; Sat, 04 Nov 2023 05:43:54 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id u22-20020ac24c36000000b005093312f66fsm496100lfq.124.2023.11.04.05.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 05:43:53 -0700 (PDT) From: Linus Walleij Date: Sat, 04 Nov 2023 13:43:51 +0100 Subject: [PATCH net 4/4] net: ethernet: cortina: Handle large frames MIME-Version: 1.0 Message-Id: <20231104-gemini-largeframe-fix-v1-4-9c5513f22f33@linaro.org> References: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> In-Reply-To: <20231104-gemini-largeframe-fix-v1-0-9c5513f22f33@linaro.org> To: Hans Ulli Kroll , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= , Vladimir Oltean 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 agentk.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 (agentk.vger.email [0.0.0.0]); Sat, 04 Nov 2023 05:44:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781637459064875353 X-GMAIL-MSGID: 1781637459064875353 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. 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 inteface. 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 23723c9c0f93..063e58639379 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; @@ -1170,7 +1171,14 @@ 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 mach a normal frame and a checksum? + * Just bypass on bigger frames. + */ + word1 |= TSS_BYPASS_BIT; + } else if (skb->ip_summed != CHECKSUM_NONE) { int tcp = 0; if (skb->protocol == htons(ETH_P_IP)) {