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 {