Message ID | 20231031-fix-rtl8366rb-v3-1-04dfc4e7d90e@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:abcd:0:b0:403:3b70:6f57 with SMTP id f13csp65621vqx; Tue, 31 Oct 2023 15:46:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHKltHeOw85XQfsN6LFb2m7wED3PSh7QrXlvIyOItm8UZ0fWXwrfzVOB86W+Eddyk9lYVdf X-Received: by 2002:a05:6a20:e114:b0:14d:abc:73dc with SMTP id kr20-20020a056a20e11400b0014d0abc73dcmr14719049pzb.32.1698792360597; Tue, 31 Oct 2023 15:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698792360; cv=none; d=google.com; s=arc-20160816; b=wHgoA7MKqNw2QDLAb9+ZTjxoe3c+eo1yII7Zc+Gu9Mb2rBnG8nMr97oWm6J3JYZrx+ oBarkXFlTBveX00ZkDuPgHA9FCOHdJezPE0Oe5jley644QsUQjnNEe+dzzT9UuAXsNRN 6zwpAXdEZkpUzT4c5R/uGaHJjycSxqOwyaKfzDWUWdUKzcq2NwBgRjdN2oZbBfJfZwdR gfBeRMX66PzNDEKAPQD4j1+KHVGXLa01+cCUFUvS6brnVosUzOA5QEAWxLzOAsOjWpTC ujRFJRWxhCIHpgiKw9fHrLkDvPm5y848zbKLL2ki0V6RdT9M+3qDLFzSCIB+pumcw4mK 7Bzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=Soi9bdc5kWd4li1fMLa0FWIu2YUGtC28KzHNxVYSHqk=; fh=pklHnVz994PHiH/3Nw+HTH21bJPu3BMiECb2b7WfXug=; b=ntwAkpF0NNYoIgcikZP4YUf9p5vU4whA3vO2882EjaA+b/yOGlw64X0gPm3bD6mu4D I7xlhUM0pMJdq8MDeISLRb7vFW7h0520ZhZlSNh4ilrnGsMyHXQnU/oBG8vbi8QzMsUk aSkIsV4iISHSRXz6+7EBhXj5uSbOT9Kt1Dxt0N//qAVyu/NfyNLpHk8XisVPw6og89Wa UpRQ05poRYFTjzok+K5EQ4HYNyJgEbrFzl2ZsRjIqlTVYzfPPGyljnGAS9whOLwp+q4l F/YhRls4p0u8nG0j0dPG6txp8Q6k4xvMZ9Ky6mjLLgySSlebWxr+IBOuMhG5Ea7mGmRz Ohag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cVCeTWTZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id x17-20020aa79571000000b00691023321ebsi284161pfq.113.2023.10.31.15.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 15:46:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cVCeTWTZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 0B9268076482; Tue, 31 Oct 2023 15:45:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344428AbjJaWpm (ORCPT <rfc822;chrisjones.unixmen@gmail.com> + 33 others); Tue, 31 Oct 2023 18:45:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbjJaWpk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 31 Oct 2023 18:45:40 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17FD8F5 for <linux-kernel@vger.kernel.org>; Tue, 31 Oct 2023 15:45:38 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2c5056059e0so88567381fa.3 for <linux-kernel@vger.kernel.org>; Tue, 31 Oct 2023 15:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698792336; x=1699397136; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=Soi9bdc5kWd4li1fMLa0FWIu2YUGtC28KzHNxVYSHqk=; b=cVCeTWTZnL7SHP+D16KUxvBKzD/KZJD9KnuOWSuaDwiBKUsT+wf68AoVKQbwTcrSvB qTpA3oHjDvpIKMWWH5q6YeEDo1v1yXofETLkAqewYETzqwLUJgjN9BUVSiBzhsG6Yq03 d2tf2dAb+MkvfAxAbj4uv3AqEsJM+0dKj0l5yyXyh9yaWhZoFMESxn0w4WAnBsehSfA4 ahAqjJ5DSxQWo8SvkcWFtat6gkDrtVXQEcp5Bnf2HbeSGKQxed46p2Gc4B8Vvzyq3hBV kIjB7mMR7jmUCKL+WEU5LHBVYnJr7PtJfBQm5I+7Ox9SHk0caMT4kIWs61LYUI+oKqI3 sfMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698792336; x=1699397136; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Soi9bdc5kWd4li1fMLa0FWIu2YUGtC28KzHNxVYSHqk=; b=tRloBXW8LS/5oyZ67uUyT4bBxlN+fVW9zamArgvRE2rmcxfaLGs8XoitSAdzX5ZxFG x47BRjUp8jWrFnNSDvBILe3CDH+O1bqH06VRfwNkkHvzGJICr20CltYgfITcsAYrumYA AutIIVSoZi26qBdgSI0tMowor8SygaU7M/9U3HM7Xb09sYD90dNR0wdU+2ZjhVV5+Ja9 TXwhLfYwJKIBZG1XBN9fVb9KKxCid5f/IToNvOMxX0+Q2CY2zcb1XpFiVSuvLBAu3Zbd yhkfYz5gWIbvdxEGgmAhESQaaFq9xZeRJ+gFrcEfwz+u6rSlutzlhl9638NJ+l/peCYR kPDg== X-Gm-Message-State: AOJu0YzlVJu6oRc+OjL208TcjrRkR2dapDay85gJSEWhPeZCVCpYJ2Nc aezwBmPLx3TpN5ZECPaU2c3/jg== X-Received: by 2002:a05:6512:3c91:b0:507:a04c:76e8 with SMTP id h17-20020a0565123c9100b00507a04c76e8mr13028194lfv.46.1698792336166; Tue, 31 Oct 2023 15:45:36 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id i12-20020a0565123e0c00b004fb7848bacbsm39613lfv.46.2023.10.31.15.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 15:45:35 -0700 (PDT) From: Linus Walleij <linus.walleij@linaro.org> Date: Tue, 31 Oct 2023 23:45:33 +0100 Subject: [PATCH net v3] net: dsa: tag_rtl4_a: Bump min packet size MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231031-fix-rtl8366rb-v3-1-04dfc4e7d90e@linaro.org> X-B4-Tracking: v=1; b=H4sIAIyDQWUC/3WNywrCMBBFf6XM2kgeJLWu+h/iIm2mbaAkMilBK f13Q1YquLxz55y7Q0LymODa7ECYffIxlKBODYyLDTMy70oGyaUSXLZs8k9G23pRxtDAsNVycLr jYrRQmAdheai+GwTc4F6Oi09bpFfdyKJWf3RZMMGcNtp1XGulbb/6YCmeI81VleUHrvgvLguOx qDAqXWDk1/4cRxvLXtRgO8AAAA= To: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>, Vladimir Oltean <olteanv@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Luiz Angelo Daros de Luca <luizluca@gmail.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 31 Oct 2023 15:45:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781172046794056817 X-GMAIL-MSGID: 1781312898557436764 |
Series |
[net,v3] net: dsa: tag_rtl4_a: Bump min packet size
|
|
Commit Message
Linus Walleij
Oct. 31, 2023, 10:45 p.m. UTC
It was reported that the "LuCI" web UI was not working properly
with a device using the RTL8366RB switch. Disabling the egress
port tagging code made the switch work again, but this is not
a good solution as we want to be able to direct traffic to a
certain port.
It turns out that packets between 1496 and 1500 bytes are
dropped unless 4 extra blank bytes are added to the tail.
1496 is the size of a normal data frame minus the internal DSA
tag. The number is intuitive, the explanation evades me.
This is not a tail tag since frames below 1496 bytes does
not need the extra bytes.
As we completely lack datasheet or any insight into how this
switch works, this trial-and-error solution is the best we
can do. FWIW this bug may very well be the reason why Realteks
code drops are not using CPU tagging. The vendor routers using
this switch are all hardwired to disable CPU tagging and all
packets are pushed to all ports on TX. This is also the case
in the old OpenWrt driver, derived from the vendor code drops.
Modifying the MTU on the switch (one setting affecting all
ports) has no effect.
Before this patch:
PING 192.168.1.1 (192.168.1.1) 1470(1498) bytes of data.
^C
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1048ms
PING 192.168.1.1 (192.168.1.1) 1472(1500) bytes of data.
^C
--- 192.168.1.1 ping statistics ---
12 packets transmitted, 0 received, 100% packet loss, time 11267ms
After this patch:
PING 192.168.1.1 (192.168.1.1) 1470(1498) bytes of data.
1478 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.533 ms
1478 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.630 ms
PING 192.168.1.1 (192.168.1.1) 1472(1500) bytes of data.
1480 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.527 ms
1480 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.562 ms
Also LuCI starts working with the 1500 bytes frames it produces
from the HTTP server.
Fixes: 9eb8bc593a5e ("net: dsa: tag_rtl4_a: fix egress tags")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
Changes in v3:
- Do not pad out to 1518 bytes, just add 4 bytes to the
tail consistently when the package is bigger than 1496
bytes. Use a combination of __skb_pad() and __skb_put().
This works fine.
- Add tail in the first if-clause and pad to 60 bytes
in the else-clause since they are mutually exclusive.
- Edit comments and commit text.
- Link to v2: https://lore.kernel.org/r/20231030-fix-rtl8366rb-v2-1-e66e1ef7dbd2@linaro.org
Changes in v2:
- Pad packages >= 1496 bytes after some further tests
- Use more to-the-point description
- Provide ping results in the commit message
- Link to v1: https://lore.kernel.org/r/20231027-fix-rtl8366rb-v1-1-d565d905535a@linaro.org
---
net/dsa/tag_rtl4_a.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
---
base-commit: d9e164e4199bc465b3540d5fe3ffc8a9a4fc6157
change-id: 20231027-fix-rtl8366rb-e752bd5901ca
Best regards,
Comments
On Tue, Oct 31, 2023 at 11:45 PM Linus Walleij <linus.walleij@linaro.org> wrote: > It was reported that the "LuCI" web UI was not working properly > with a device using the RTL8366RB switch. Disabling the egress > port tagging code made the switch work again, but this is not > a good solution as we want to be able to direct traffic to a > certain port. Luiz is not seeing this on his ethernet controller so: pw-bot: cr (I've seen Vladmir do this, I don't know what it means, but seems to be how to hold back patches.) Yours, Linus Walleij
On 11/1/23 13:18, Linus Walleij wrote: > On Tue, Oct 31, 2023 at 11:45 PM Linus Walleij <linus.walleij@linaro.org> wrote: > >> It was reported that the "LuCI" web UI was not working properly >> with a device using the RTL8366RB switch. Disabling the egress >> port tagging code made the switch work again, but this is not >> a good solution as we want to be able to direct traffic to a >> certain port. > > Luiz is not seeing this on his ethernet controller so: > > pw-bot: cr > > (I've seen Vladmir do this, I don't know what it means, but seems > to be how to hold back patches.) Looking at drivers/net/ethernet/cortina/gemini.c, should not we account for when the MAC is used as a conduit and include the right amount of "MTU" bytes? Something like this (compile tested only): diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 5423fe26b4ef..5143f3734c3b 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -36,6 +36,7 @@ #include <linux/ethtool.h> #include <linux/tcp.h> #include <linux/u64_stats_sync.h> +#include <net/dsa.h> #include <linux/in.h> #include <linux/ip.h> @@ -1151,6 +1152,13 @@ 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 IS_ENABLED(CONFIG_NET_DSA) + if (netdev_uses_dsa(netdev)) { + const struct dsa_device_ops *ops = skb->dev->dsa_ptr->tag_ops; + mtu += ops->needed_headroom; + } +#endif + word1 = skb->len; word3 = SOF_BIT; Also, as a separate check, might be worth annotating the various descriptor words with __le32 and appropriate le32_to_cpu() and cpu_to_le32() accessors for each of those fields.
On Thu, Nov 2, 2023 at 7:43 PM Florian Fainelli <f.fainelli@gmail.com> wrote: > Looking at drivers/net/ethernet/cortina/gemini.c, should not we account > for when the MAC is used as a conduit and include the right amount of > "MTU" bytes? Something like this (compile tested only): The DSA core already fixes this by adding the tag size to the MTU of the conduit interface, so netdev->mtu is already 1504 for this switch. I found other oddities though so I'm digging into the driver! Thanks, Linus Walleij
On 11/2/23 15:09, Linus Walleij wrote: > On Thu, Nov 2, 2023 at 7:43 PM Florian Fainelli <f.fainelli@gmail.com> wrote: > >> Looking at drivers/net/ethernet/cortina/gemini.c, should not we account >> for when the MAC is used as a conduit and include the right amount of >> "MTU" bytes? Something like this (compile tested only): > > The DSA core already fixes this by adding the tag size to the MTU > of the conduit interface, so netdev->mtu is already 1504 for this > switch. > > I found other oddities though so I'm digging into the driver! Yes indeed, I forgot about that, never mind :)
On Wed, Nov 01, 2023 at 09:18:47PM +0100, Linus Walleij wrote: > On Tue, Oct 31, 2023 at 11:45 PM Linus Walleij <linus.walleij@linaro.org> wrote: > > > It was reported that the "LuCI" web UI was not working properly > > with a device using the RTL8366RB switch. Disabling the egress > > port tagging code made the switch work again, but this is not > > a good solution as we want to be able to direct traffic to a > > certain port. > > Luiz is not seeing this on his ethernet controller so: > > pw-bot: cr > > (I've seen Vladmir do this, I don't know what it means, but seems > to be how to hold back patches.) Hi Linus, In this case it may not have activated the automation, but I do see that the patch is now marked as "Changes Requested" in patchwork, so all is well. https://patchwork.kernel.org/project/netdevbpf/list/?series=798030&state=%2A FWIIW, pw-bot is (slightly) documented here: https://docs.kernel.org/process/maintainer-netdev.html#updating-patch-status
On Sat, Nov 4, 2023 at 3:10 PM Simon Horman <horms@kernel.org> wrote: > In this case it may not have activated the automation, but > I do see that the patch is now marked as "Changes Requested" > in patchwork, so all is well. Yeah, in this case it should even be pw-bot: reject because I found the real problem elsewhere. > FWIIW, pw-bot is (slightly) documented here: > > https://docs.kernel.org/process/maintainer-netdev.html#updating-patch-status Thanks, I'm getting better at it! Yours, Linus Walleij
diff --git a/net/dsa/tag_rtl4_a.c b/net/dsa/tag_rtl4_a.c index c327314b95e3..9c7f8a89cb82 100644 --- a/net/dsa/tag_rtl4_a.c +++ b/net/dsa/tag_rtl4_a.c @@ -41,9 +41,21 @@ static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb, u8 *tag; u16 out; - /* Pad out to at least 60 bytes */ - if (unlikely(__skb_put_padto(skb, ETH_ZLEN, false))) - return NULL; + /* Packets over 1496 bytes get dropped unless 4 bytes are added + * on the tail. 1496 is ETH_DATA_LEN - tag which is hardly + * a coinicidence, and the 4 bytes correspond to the tag length + * and this is hardly a coinicidence so we use these defines + * here. + */ + if (skb->len >= (ETH_DATA_LEN - RTL4_A_HDR_LEN)) { + if (unlikely(__skb_pad(skb, RTL4_A_HDR_LEN, false))) + return NULL; + __skb_put(skb, RTL4_A_HDR_LEN); + } else { + /* Pad out to at least 60 bytes */ + if (unlikely(__skb_put_padto(skb, ETH_ZLEN, false))) + return NULL; + } netdev_dbg(dev, "add realtek tag to package to port %d\n", dp->index);