Re: [PATCH net v3] net: dsa: tag_rtl4_a: Bump min packet size

From: Florian Fainelli
Date: Thu Nov 02 2023 - 14:43:31 EST


On 11/1/23 13:18, Linus Walleij wrote:
On Tue, Oct 31, 2023 at 11:45 PM Linus Walleij <linus.walleij@xxxxxxxxxx> 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.
--
Florian