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: 13445513 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 992BDC4332F for ; Sat, 4 Nov 2023 12:44:26 +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=BDeCmfHxQHloiplpq7UZ6Yg/C9vVDZLJ3e6v43UrLq4=; b=0UED33JoGhTCPp ZYhw3MRP0MpPbSkaUvt8BiLOh6P4L998dHwwaRygTmW/zIR85fr49d1EfpKU1MeWa79mkpo13deMF vOS1qp7OuYlDWhinfFeJEc9sMeYIeRMmEc4bi4UKc/Pi3e11n4nTfS3VssGxVz7Ban/Qz1tTvDtPR mbzJbkqkeK/TTiuwqK3YDzeUD1Ko1Yo9oneCXHyQ258dYqBbsLaAddb6JvBQshmq4ssNqxBrLaUQn g8CTAbeJaA5TnRzauY60BHw5UMHRN5oUpz5LY/2r7EFn3DZRjMFRceCJ+KnYIGsv6VTMn0RsY1I00 1B/8F/e99GBHqFFeITuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0L-00DPHY-0C; Sat, 04 Nov 2023 12:43:57 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0H-00DPFd-0c for linux-arm-kernel@lists.infradead.org; Sat, 04 Nov 2023 12:43:54 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-507adc3381cso3737657e87.3 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=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=9Oy6YnzrrQAU74UB/BgNy8fxjGeu1ULALolZntz7GpU=; b=tsGv15Dki+drRVKlKe3nmnU2qUVLKYL3ypQPKYK5ME5Mi7mwAfEaGi1zh3QF3n1L72 49FO2voB9OixwoftquH5IyVHmfnn/ebnY8bN+CJ9x7WAYts0C/UL6OjJZEQFsTlPvFmh 2RywV6ZUCGFdapisY8NgPZ+V29ydvHVfLfQPlf2V5oKnLt3UdyAifqpaTStLMd1ANIIq EOZvkeVCGKIQWx2yx5tPIkDsLLL4xLYNXg6s++H+DSN0B0XkQ4T/4+imCJC5/uAg+d0F 0jAeLj3dW5wFjOYg3KOBNFEK+9yf5y7sfjxxs74k9dHMcMpzdYatlmECZGLIrk/N5K5E mcUA== 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=PBRrX1Io8/Q/Mx/QiGr66rjg5uDJ/RgFKcYhayp03d1l4Z7x6MwLI4dEJHCut25wDB 5zhLQhSIg6bMLJpsztW0CbhP+YkHvpVLBJr39h9npgnXlvA3bPOMUJjlpL1XKuMMBspc lM7gBFc5VRjdlAJ59uolhws8Hgb1DYZO9AcuH1ToFk5F96CDkddz2WHypdF7crVUa6kV yStSpf07tIgS+54Qmf7H7Kl/esuEDtNvE0dv6Gjv2xDEC2tYQ4cZ6Zpbpf1bWFyVKqFl RKPZgbkm8+98bgnyc5WzrRGA9IXWPe5HEU6+G0HhcYTmyDQQAMYaQtLIfCeRyN8kuCQe NI7Q== X-Gm-Message-State: AOJu0Yz1PNplgteU4tg++dCnrRWEpFVFd0YLaGGum6WDnA1Ceqey2rEP dv1lrKhOkh4qLNwtUGpVdP+DBA== X-Google-Smtp-Source: AGHT+IGwsd6bMa0WdkB0xdWasEvDnIiyZd8prwFEb7gsYRpi9uYQ0Z3rXATmveYQoxaGQ3DQcung8A== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231104_054353_282565_72E6663E X-CRM114-Status: GOOD ( 15.80 ) 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. 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: 13445512 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 19C6BC4167B for ; Sat, 4 Nov 2023 12:44:23 +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=sB4c7iE3smcTaXdaB/TlBdt3BCZR6z+NDw1h4eV+doI=; b=fFdEgmCc4+6zdu 3sB4uW9wFYSR2mG5nSjgm3Gt4HJf0jCxkuGCXKF4y7unxvj0NJuwUmVaOE+74Qb7i0YbwTEkdJPwB 26Jf79WjNN8z7IxIsvjAgb42FlairhvKdAUmWq7eh73qeafCaRuDR5CYlPbcDES6wASbvTyhiNKFz 4ri7VhuRgjOZe5P5A4SR3r1BcywX7fT8OfUXpAnPJjw2LUWayuzjWeOzc13OEcTDennVFsvqPElYB rZX/3KGk9U26xhztS/CVIK2e9trHGQR2A2CAFvbpDF82T4c/7vE/0lt3i8OISWeQbOytmjGRdE7Js BM3K1dS0MYp2OA5YMt7g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0M-00DPHr-2n; Sat, 04 Nov 2023 12:43:58 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0H-00DPFi-2k for linux-arm-kernel@lists.infradead.org; Sat, 04 Nov 2023 12:43:55 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-507973f3b65so3867534e87.3 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=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=QWgOFAkaCrL22TdDDJiVpTuZM0XAGRWs9ieW0NKW7II=; b=VNh6to/O3HYNFMGF7yncULpFVq2uVuzjmPMLUi870wMejkKpbgzHVa9Doafzq9pUJK L6TeuR6h77r7gU9laKib76RBVxO66msgrw3mgV66vOdPVwnaXabLCMSj0FWnlxP6bfKA uQECJnVb7UhrSpM6zIgOzjxdCjXiM5Ca+3J+5PBKUzDGE2isUqPtaXdLtLu2LEoT7c5t 3jdd888h9TtoIZvjlihJBY2k77Wu+5gOalUGqQYVU0rtoF8LsqMPuYdVg8R4vGOFSeaw SdedvWbyTXD2ARQRaLk10E8NIY6/gfTJBsUXLH3JeZadVg1C3o76ixmEpF/93Xu4brG3 Xtlg== 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=VUS1GyGkAOICguK0aX5JFp28pfMS+8t53wpzKde4WZn5P0c2ljTesr7IhAso0xD6l7 UQQx2EleLOmWtt8htCIYzlGTWj3XplPjATuJODUXQAReFPB3J7akvFpcDzRW94n0BxF+ zHKBECrB8fzgECu9vcp0zerE4FtXJyCVLOZySxY80GhbzcCbDC91H9aWL2y6DQ4IUEbZ hFKEd5d9EJvL6vg3KuyPLUJZ6LP128lCGxXaf2TyQLewXNmYLwnM8fkCdo/a1jxgRWpg bhTNo5mWDSl6vwhP2bZkLfUkxt+B2SK4kqG8n/YQEpIWnHTbwNhO4x5WZS8q2I0fWi6h ETIw== X-Gm-Message-State: AOJu0Yyev1RP68SEz7GxMNRlbVphP5TRnLJ3SLyUTYYvYd6XbAUiMDD9 yvsXBF8OjY3UinnpG/OhAyl0LOXr8juXCrUtnCI= X-Google-Smtp-Source: AGHT+IE/D76DP6LP5S/bC2ZUouN5nx6tvXDeDM1odIxhJnsb2wJCBGqDcoLyl8FiiBhU1HViFRqPDQ== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231104_054353_899650_8B6B8DCA X-CRM114-Status: GOOD ( 13.89 ) 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") 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: 13445514 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 3CA4DC4332F for ; Sat, 4 Nov 2023 12:44:29 +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=EwuR7zrU760s1wlY64Tunf/sdw9aqflAfER7xGSFXN4=; b=MbUmLfGaV+s94m zQMF+i320GXRWjY8kr+T9nOyWM8mcHGx2jwRvWhAhdEg74neSYlLryKua73wmUAbJ50Emd3V0UaNw 8UWvmJQ1hneFU04tNNrAPw9Vo+I9hlXCW8KHU3HMNz+6fWPC7B/A2cLWdNRlePUcyTUyI//Ii//Wx C5Ej9LZrMA0rCtRUqwHKH/+b4Gt1aSnzGOC+JVKPDh93ev8pF7pCnxRUXYb0LLsdHS+EQCIXXuSj9 q5kcNTVl23UMMls6YGNavYd7naNIDt+Sb5rmE+ezCk/EaJ9abvWidF5iDaKV4NVzb2gqD5w5dy7G+ ck1cn4JTt7CPDW7uX4Vg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0N-00DPIb-2E; Sat, 04 Nov 2023 12:43:59 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0I-00DPGN-2e for linux-arm-kernel@lists.infradead.org; Sat, 04 Nov 2023 12:43:56 +0000 Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-5079f3f3d7aso3884420e87.1 for ; Sat, 04 Nov 2023 05:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699101833; x=1699706633; 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=vbrVElpE/LRcXL9QrTPOXjtUB0U3i3Et1aitWER/TV4=; b=qyE7Snj8Uxa/HeV7SygpBjHYg6/e4dP4BuLIsgRA4Ko/Gm1U73KdqHNAB76tPTNCxY Ozo5MTWDZnYzZG3EkzVn8Xs8T+6L4EuljZNhFh645vHQDH1t+pjrDcqLDJ0N81OOnNH2 l6WiBjrL8OteWqv95obD7LXwj+gqD5LocA879Ks/R+TN810K1QBpWlQ8APV1LhHL5tMu nIpdGMz9TY/JjDOkM7kcRI9utQXbEFT/5Y3fVlHtWerAHoV+6QcsTUzjM8Y2DuYjSxvl +/PNCukX+U/kQLHT1TZ9YLYN/sg0yf3BNLbatfO9d6u64VX7RadXfQUrXXgs+i7GVO6G I+lQ== 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=EbMAWdZSxwGM/q9dQnyyJPzSrKJwzTdfANBGAI6oW9KnWwCKZszSnJABo4qwCO2R+Y D8xlrCZ3ihab8DJKGA04zFXF8VUIyzqIxuIxmn4f69I4iBT8xBIHQKoJ+iZoPHyI3woq sRm+XAYEHUkG7JiNTS6KVO18xt3KbcWTYPRBlqfgqz7tT1W4oPWC80YdoQ9iWv8FWo0e eVvYUnISrAhUTJdvpCizcdt5vbQzpdhi754Fxr0ApFIo9HP2nkiUHodEJZf4AauR9QV6 0t8Vw9XaZBhqB+CGs7akcdlN2WX49xmahGvc0VwuLC5+HBBhJ/9FLJ5PFG1eZil9AaMH mL6Q== X-Gm-Message-State: AOJu0YwMGsUUcFTuCmEoGdEBCdUu+DZjRyQ6/+TAlkPrMMlN0tTmLBFp cKQK1P0YtkhKDDiaRD6BkX5Shw== X-Google-Smtp-Source: AGHT+IEOvtUSGS8gPMNB3spqJXMI2GzAA6fdOtLX2o73ozW/2re2ZnkjNq0X0bY0Zzh1Cl/kg6zB/Q== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231104_054354_860344_9AFAAEDB X-CRM114-Status: GOOD ( 11.41 ) 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 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: 13445511 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 98368C4167D for ; Sat, 4 Nov 2023 12:44:22 +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=SJD+Z8OEXsZCEsnVSZMhlGgkOHeJaCWbe52tIbW3dds=; b=L8So4YzT9bVBtP 03iJRSqZSqvXjdvfHmEXGsMh7lfqU06cKpK3NKXO1lXyRHbWGFIXNVY/3xxLf13mD94EOoHpMLaeT FAcRLJpqbSqOFEZdsS/ewvDu1FesfSUHrRyeBoTdPGg/fgNy39UGNu6vB5/7tQUI89walnkR0iFUh QeS6GHA1IzhGUvNuOO2MSQscmVZ9Jj2kynWOdro5WOysdqC6Aaw+UfObfOz+xKB2Xpsnl3MBYFPHP ydAI4qIDOWRYhiIyWFrenRyyOmq+1WZLO8bzDDKMGlY1HVXsR32r2r7+j4K1PsF0GNBfucCB920eG NiCBTS6k6sM3Oxo67y/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0P-00DPJL-22; Sat, 04 Nov 2023 12:44:01 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qzG0K-00DPGl-2d for linux-arm-kernel@lists.infradead.org; Sat, 04 Nov 2023 12:43:58 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2c50906f941so41700981fa.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=1699101834; x=1699706634; 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=lGuoNoybmpAHVbeBRQ0Y/xZn4w65B05owlyMy7HgTuo=; b=sOU2GMIYn/HXEIoEzcE0yWRoFQAnU+yncU3bEQ4gXykPnn7OFRki93vEXeBJGNafYi LHQkRIazvIoQZiZlK3d8Jqb/1+sshJyXZwzHYU+oNBdZgpAmWW8LjaJQysO40Qwe5wHp ce7pVsdMZzICcdsxFsGueK4FW7p/UJmgzd3AQuTjF5JBiK56WWgtI6QKlcsStvwgxvHc DOzx6fq4+dY11t2ixssERQgx9zo96410L24ddAivYTMPf7zKQaOwE8CTZ2jQPiO9Grdh fS1XHF8REnTA6sAUQ+h6INgHfN/LPqdskkeI9XatqxMafJiGk6vMMDJbkg82emYPLWyE Ya2w== 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=EHAbJ2DtU5mehNjH+DSG+bWZyqpUAiBQQolpKJAJNagt+iXT/ddLUpU6M2VDDFBl+K BhPA4kFd33mNrT+jSr1G6wG499e2S+jiFMjnTfVhtBElP9tLA7iZFhw9uB/z190m0lXs bZD0rrBRd0Mubfkp25y4TATeOH3ehxZBTtKxAKJ9GFbCiAr/1HOXLDu3S8Bel3Hp1xnt x5iawIT2BdkCCJ4S68HGjlFM2mXqx0l61a/9gltj+IpQDOLnLMVAjIALC/l4aoZqYigX cff1sUc+KYaw/cWr8QtD9ewTOqSYNHPptDcQhzD7C9cCveQtUnyeCTn8GLrYX0oM8GSI 5o7Q== X-Gm-Message-State: AOJu0YzsqUT6OtTXCHimfxLxgCufbcegKABkJiOl5iRs3+OvbetSx1D1 nt0inh7m24UjsLq5wl6u1JS4ug== X-Google-Smtp-Source: AGHT+IFM8LyKtYP3lb6rmldO2Y/K2K0eNH2873kfaHunY7CPSwdiCXkmjcn14UjlqR8YVVm6mXvm5w== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231104_054356_857034_822F24E6 X-CRM114-Status: GOOD ( 18.53 ) 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 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)) {