From patchwork Wed Oct 4 13:42:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1843373 X-Patchwork-Delegate: hauke@hauke-m.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=t+pxYslM; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=XiYdEt1f; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S0wsK6qmXz1ypx for ; Thu, 5 Oct 2023 00:44:21 +1100 (AEDT) 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:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1xgUC1goQ79lTyldRYIyqBk8NHjIlpR0c/1oGL9nK/Y=; b=t+pxYslMhSxGWp OSEieRp2MfCpjSMB7O2DoGkGotzje6ZA0PhlpygQEcOroLnG1ng9/gV6lVXSJvY7bRHEe+DxjTrcH k/ijVdoJBrqg7kL+FV33vQ1o3xEbR1BAfEHzvsb5oli4E+ZeNgtY5psNe/fPoa7i8/Pr93uCyQ/DE 3yu1nyE5pW8ROyiq6NLZibAsr8pOXnlyjHdslqoRVgHQ7q87JK9lzSx0RCO8KF7Jyi5D5zO9iZWMS aCzGWh1ak4cnAdR+vAA3I58o7fgeICaP6+lJ3z0CC93q5GPLTN+4NsVSkrqO1HMo4d4+8s4eD76LZ UdirXC+OOk/W7OuJwkrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qo28x-0009Ai-2b; Wed, 04 Oct 2023 13:42:27 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qo28t-00099O-2Y for openwrt-devel@lists.openwrt.org; Wed, 04 Oct 2023 13:42:25 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c00df105f8so25030711fa.2 for ; Wed, 04 Oct 2023 06:42:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696426939; x=1697031739; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qFygV1nehsNp4pzQYKVPrTTLrHZuTB+kFIV5n0Mv4T0=; b=XiYdEt1feWGrVAW9DPYRqKaN+rLIp0MWw3GfWQJAqJ1jrJycGhS/cDUWcCRccxGxQ9 mfJQMDz4fhZOXT9XXbal9V+MhtT3p+aO+aJvknhbertfnNuTjjvUSuUI1QTQBiyQf92c z8rDPdtCSiPy1PJQivTeCCTwOLn/3u/QyjnuzjB+YQK4LaYFH4EPUqCmT8ohyVW4pFbJ PgArcaPFnOcFzpX81D2aFYeTVVZE8fKUEmHTdXvemOXBmvcD8Xkpl13PNAlDsGE438W/ jlC1aYOTvIzuvV6XlkgftCL/G8frhsln98YPRu3y4Q3nHK1sN4j4Lt8MDEVTNVvhFdV+ xtUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696426939; x=1697031739; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qFygV1nehsNp4pzQYKVPrTTLrHZuTB+kFIV5n0Mv4T0=; b=iI/zSklAFSW836SJZ6olmduzV3cfcTWlSwKlL98fgPArwTt/5c0OVUd+sKvAjXW4ZH jNKRn98pvBUJl38VCW/TLD7YHsKUogXtrk62jlENMidXHg7DtwUzQPj7yOpIvPL7IKgM 1NDGPSbtScJ7ueK78hN/vdGuS8k4valtANYJIoCWvENbNem/jxn/zU29AiAED0sWbWTL /5nch2Q3hOxFgr9IH5mdo0neM1DbkElgu4LSsvGtxQaf2s7Sj/3JLpyuWeBF5GtWihF8 X7XQUi1WN8IHhG6quZg77L2+7AVQfkrOjMDLQTc6OhfkbCI59pYWuLw/jO7DiOXLbgTy 5EZg== X-Gm-Message-State: AOJu0Yx2JTKRgrbiO5QOrd5/GOwY9+rqZGcSc5iRCruc6k772/gR+fHM JXBBJK4twDBdqXyvJNDrTbskhaVmizlYbgyzfpU= X-Google-Smtp-Source: AGHT+IEmvX2xC728TPjFG4UrRGynvplixf/pE46GpmEq+menUlL3q6xpoTAt1UztFG0N4Xn+S9uEjA== X-Received: by 2002:a2e:9d08:0:b0:2b9:36d5:729c with SMTP id t8-20020a2e9d08000000b002b936d5729cmr1895809lji.47.1696426938691; Wed, 04 Oct 2023 06:42:18 -0700 (PDT) Received: from Linus-Dell.lan ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id o17-20020a2e90d1000000b002bcd94f9714sm677097ljg.126.2023.10.04.06.42.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 06:42:18 -0700 (PDT) From: Linus Walleij To: openwrt-devel@lists.openwrt.org Cc: Linus Walleij , =?utf-8?q?=C3=81lvaro_Fern?= =?utf-8?q?=C3=A1ndez_Rojas?= , Jonas Gorski Subject: [PATCH v5] bmips: bcm6368-enetsw: Bump max MTU Date: Wed, 4 Oct 2023 15:42:15 +0200 Message-ID: <20231004134215.429302-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231004_064223_830723_A6FB9ADB X-CRM114-Status: GOOD ( 20.56 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The max frame size "jumbo" for this ethernet switch is 2048 bytes, excluding the VLAN headers, which is 2048 - VLAN_ETH_HLEN - VLAN_HLEN = 2048 - 18 - 4 = 2026 not Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:229 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The max frame size "jumbo" for this ethernet switch is 2048 bytes, excluding the VLAN headers, which is 2048 - VLAN_ETH_HLEN - VLAN_HLEN = 2048 - 18 - 4 = 2026 not ETH_DATA_LEN + ENETSW_TAG_SIZE = 1500 + 4 + 6 = 1510 as it is right now. The available overhead is needed when using the DSA switch with a cascaded Marvell DSA switch, which is something that exist in real products, in this case the Inteno XG6846. We need to adjust the RX buffer size to fit the new max frame size. Before this patch (on the lan1 DSA port in this case): dsa_slave_change_mtu: master->max_mtu = 9724, dev->max_mtu = 10218, DSA overhead = 8 dsa_slave_change_mtu: master = extsw, dev = lan1 dsa_slave_change_mtu: master->max_mtu = 1510, dev->max_mtu = 9724, DSA overhead = 6 dsa_slave_change_mtu: master = eth0, dev = extsw dsa_slave_change_mtu new_master_mtu 1514 > mtu_limit 1510 mdio_mux-0.1:00: nonfatal error -34 setting MTU to 1500 on port 0 My added debug prints before the nonfatal error: the first switch from the top is the Marvell switch, the second in the bcm6368-enetsw with its 1510 limit. After this patch the error is gone. OpenWrt adds a VLAN to each port so we get VLAN tags on all frames. Testing the new 2026 MTU: eth0 ext1 enp7s0 .--------. .-----------. .------. | enetsw | <-> | mv88e8152 | <-----> | host | `--------´ `-----------´ `------´ On the router: Notice that the max MTU for the ext1 switch (mv88e8152)needs to be 18 bytes less than the eth0 (enetsw). That's the VLAN overhead since OpenWrt sets up one VLAN per external port. On the host we just set the max MTU for test: Test pininging from host: PING 192.168.1.220 (192.168.1.220) 1984(2012) bytes of data. 1992 bytes from 192.168.1.220: icmp_seq=1 ttl=64 time=0.687 ms 1992 bytes from 192.168.1.220: icmp_seq=2 ttl=64 time=0.670 ms Test pinging from router: PING 192.168.1.2 (192.168.1.2): 1984 data bytes 1992 bytes from 192.168.1.2: seq=0 ttl=64 time=1.021 ms 1992 bytes from 192.168.1.2: seq=1 ttl=64 time=0.909 ms The max IP packet without headers is 1984, the outgoing ICMP packet is 1992 bytes, then 32 bytes are added up to 2048 as described below. Ping packet on router side as viewed with tcpdump: 00:15:13.516325 AF Unknown (1429722180), length 2044: 0x0000: 3d93 bcae c56b a83d 8874 03fd 0004 8100 =....k.=.t...... 0x0010: 0000 dada 0000 c020 0fff 0800 4500 07dc ............E... 0x0020: 0000 4000 4001 aef2 c0a8 0102 c0a8 01dc ..@.@........... 0x0030: 0800 43b6 0092 0001 9c4c 1c65 0000 0000 ..C......L.e.... 0x0040: 2963 0400 0000 0000 1011 1213 1415 1617 )c.............. 0x0050: 1819 1a1b 1c1d 1e1f 2021 2223 2425 2627 .........!"#$%&' 3d93 = First four bytes are the last two bytes of the destination ethernet address I don't know why the first four are missing, but it sure explains why the paket is 2044 bytes and not 2048 which is the actual max MTU. bcae c56b a83b = source ethernet address 8874 03fd 0004 = Broadcom enetsw DSA tag 8100 0000 = VLAN 802.1Q header dada 0000 c020 0fff 0800 = EDSA tag for the Marvell (outer) switch, 0800 is the ethertype obviously included in the tag Next follows the contents of the ping packet as it appears if we dump it on the DSA interface such as tcpdump -i lan1 etc, there we get the stripped out packet. At the end 4 bytes of FCS. Cc: Álvaro Fernández Rojas Cc: Jonas Gorski Signed-off-by: Linus Walleij --- ChangeLog v4->v5: - Drop the confusing ENETSW_MTU_OVERHEAD altogether after discussing with Jonas. ChangeLog v3->v4: - Adjust the RX buffer size and we can use the max "jumbo" frame size 2048. ChangeLog v2->v3: - Make a more believable case for the max MTU with tcpdump example. ChangeLog v1->v2: - Do some better research after help on IRC, did some ping tests. --- .../drivers/net/ethernet/broadcom/bcm6368-enetsw.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c index 321e95dbbb3d..aa09c1707819 100644 --- a/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c +++ b/target/linux/bmips/files/drivers/net/ethernet/broadcom/bcm6368-enetsw.c @@ -22,10 +22,10 @@ #include #include -/* MTU */ +/* The max frame size is 2048 including VLAN headers but excluding the 6 byte DSA tag */ +#define ENETSW_MAX_FRAME 2048 +#define ENETSW_MAX_MTU (ENETSW_MAX_FRAME - VLAN_ETH_HLEN - VLAN_HLEN) #define ENETSW_TAG_SIZE (6 + VLAN_HLEN) -#define ENETSW_MTU_OVERHEAD (VLAN_ETH_HLEN + VLAN_HLEN + \ - ENETSW_TAG_SIZE) #define ENETSW_FRAG_SIZE(x) (SKB_DATA_ALIGN(NET_SKB_PAD + x + \ SKB_DATA_ALIGN(sizeof(struct skb_shared_info)))) @@ -1006,7 +1006,7 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev) dev_info(dev, "random mac\n"); } - priv->rx_buf_size = ALIGN(ndev->mtu + ENETSW_MTU_OVERHEAD, + priv->rx_buf_size = ALIGN(ENETSW_MAX_FRAME, ENETSW_DMA_MAXBURST * 4); priv->rx_frag_size = ENETSW_FRAG_SIZE(priv->rx_buf_size); @@ -1067,7 +1067,7 @@ static int bcm6368_enetsw_probe(struct platform_device *pdev) ndev->netdev_ops = &bcm6368_enetsw_ops; ndev->min_mtu = ETH_ZLEN; ndev->mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE; - ndev->max_mtu = ETH_DATA_LEN + ENETSW_TAG_SIZE; + ndev->max_mtu = ENETSW_MAX_MTU; #if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0) netif_napi_add(ndev, &priv->napi, bcm6368_enetsw_poll); #else