From: Daniel Golle <daniel@makrotopia.org>
To: Vladimir Oltean <olteanv@gmail.com>
Cc: Hauke Mehrtens <hauke@hauke-m.de>, Andrew Lunn <andrew@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Simon Horman <horms@kernel.org>,
Russell King <linux@armlinux.org.uk>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
Andreas Schirm <andreas.schirm@siemens.com>,
Lukas Stockmann <lukas.stockmann@siemens.com>,
Alexander Sverdlin <alexander.sverdlin@siemens.com>,
Peter Christen <peter.christen@siemens.com>,
Avinash Jayaraman <ajayaraman@maxlinear.com>,
Bing tao Xu <bxu@maxlinear.com>, Liang Xu <lxu@maxlinear.com>,
Juraj Povazanec <jpovazanec@maxlinear.com>,
"Fanni (Fang-Yi) Chan" <fchan@maxlinear.com>,
"Benny (Ying-Tsan) Weng" <yweng@maxlinear.com>,
"Livia M. Rosu" <lrosu@maxlinear.com>,
John Crispin <john@phrozen.org>
Subject: Re: [PATCH net-next v3 11/12] net: dsa: add tagging driver for MaxLinear GSW1xx switch family
Date: Tue, 28 Oct 2025 17:24:18 +0000 [thread overview]
Message-ID: <aQD8QnK-bnuptPlU@makrotopia.org> (raw)
In-Reply-To: <20251028002841.zja7km3oesczrlo3@skbuf>
On Tue, Oct 28, 2025 at 02:28:41AM +0200, Vladimir Oltean wrote:
> On Sun, Oct 26, 2025 at 11:48:23PM +0000, Daniel Golle wrote:
> > Add support for a new DSA tagging protocol driver for the MaxLinear
> > GSW1xx switch family. The GSW1xx switches use a proprietary 8-byte
> > special tag inserted between the source MAC address and the EtherType
> > field to indicate the source and destination ports for frames
> > traversing the CPU port.
> >
> > Implement the tag handling logic to insert the special tag on transmit
> > and parse it on receive.
> > [...]
> > --- /dev/null
> > +++ b/net/dsa/tag_mxl-gsw1xx.c
> > [...]
> > +#define GSW1XX_TX_CLASS_SHIFT 0
> > +#define GSW1XX_TX_CLASS_MASK GENMASK(3, 0)
>
> Using FIELD_PREP() would eliminate these _SHIFT definitions and _MASK
> would also go away from the macro names.
Ack, using FIELD_PREP() and FIELD_GET() does improve readability and
I'll use that.
>
> > +
> > +/* Byte 3 */
> > +#define GSW1XX_TX_PORT_MAP_LOW_SHIFT 0
> > +#define GSW1XX_TX_PORT_MAP_LOW_MASK GENMASK(7, 0)
> > +
> > +/* Byte 4 */
> > +#define GSW1XX_TX_PORT_MAP_HIGH_SHIFT 0
> > +#define GSW1XX_TX_PORT_MAP_HIGH_MASK GENMASK(7, 0)
> > +
> > +#define GSW1XX_RX_HEADER_LEN 8
>
> Usually you use two separate macros when the lengths are not equal, and
> you set .needed_headroom to the largest value.
A single macro
#define GSW1XX_HEADER_LEN 8
will do the trick as they are anyway equal, right?
> > [...]
> > + u8 *gsw1xx_tag;
> > +
> > + /* provide additional space 'GSW1XX_TX_HEADER_LEN' bytes */
> > + skb_push(skb, GSW1XX_TX_HEADER_LEN);
> > +
> > + /* add space between MAC address and Ethertype */
> > + dsa_alloc_etype_header(skb, GSW1XX_TX_HEADER_LEN);
> > +
> > + /* special tag ingress */
> > + gsw1xx_tag = dsa_etype_header_pos_tx(skb);
> > + gsw1xx_tag[0] = 0x88;
> > + gsw1xx_tag[1] = 0xc3;
>
> Could you write this as a u16 pointer, to make it obvious to everyone
> it's an EtherType, and define the EtherType constant in
> include/uapi/linux/if_ether.h, to make it a bit more visible that it's
> in use?
Defining the EtherType in the appropriate header makes sense (even though
0x88c3 is just the default and configuration of the chip allows to set it
to anything else, or even have it omitted entirely).
Using __be16 to access the tag fields will make the whole thing
sensitive to endianess, which is a bit messy. I would prefer to keep
using u8 type and some shifting and masking of the EtherType constant
similar to how it is done in tag_dsa.c. Also note that the datasheet
describes the special tag byte-by-byte, and there is even a 16-bit field
which crosses word boundaries, GSW1XX_TX_PORT_MAP_LOW and
GSW1XX_TX_PORT_MAP_HIGH (ie. it is obvious that this wasn't intended to
be accessed as 16-bit words). So I'd rather make it easy to understand
how the tag driver matches the datasheet instead of using __be16 just
for the sake of the EtherType.
I've implemented and tested using __be16 now, and it doesn't look very
bad either, especially when skipping the PORT_MAP_HIGH/LOW part because
on the actually produced chips there anyway aren't ever more than 6
ports, so one anyway always only accesses the LOW part of the portmap.
If you like to use __be16 (like eg. the realtek taggers) I will proceed
like that in v4.
> > [...]
> > + if (gsw1xx_tag[0] != 0x88 && gsw1xx_tag[1] != 0xc3) {
> > + dev_warn_ratelimited(&dev->dev, "Dropping packet due to invalid special tag\n");
> > + dev_warn_ratelimited(&dev->dev,
> > + "Tag: 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
> > + gsw1xx_tag[0], gsw1xx_tag[1], gsw1xx_tag[2], gsw1xx_tag[3],
> > + gsw1xx_tag[4], gsw1xx_tag[5], gsw1xx_tag[6], gsw1xx_tag[7]);
>
> I think you could print the tag with %*ph, according to
> https://elixir.bootlin.com/linux/v6.17.5/source/lib/vsprintf.c#L2453
> (needs testing)
I've tested that and it works fine (looks slightly different of course due
to the missing '0x' prefix, but that doesn't matter for debugging)
> > [...]
> > + /* remove the GSW1xx special tag between MAC addresses and the current
> > + * ethertype field.
> > + */
> > + skb_pull_rcsum(skb, GSW1XX_RX_HEADER_LEN);
> > + dsa_strip_etype_header(skb, GSW1XX_RX_HEADER_LEN);
>
> You're not setting skb->offload_fwd_mark but you implement
> port_bridge_join() so you offload L2 switching. If a packet gets flooded
> from port A to the CPU and also to port B, don't you see that the
> software bridge also creates a packet copy that it sends to port B a
> second time?
No, the opposite is true. If I set
dsa_default_offload_fwd_mark(skb);
forwarding between the ports no longer works.
It can well be that this is an existing flaw in the driver, as tag_gswip.c
also doesn't set offload_fwd_mark.
next prev parent reply other threads:[~2025-10-28 17:24 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-26 23:43 [PATCH net-next v3 00/12] net: dsa: lantiq_gswip: Add support " Daniel Golle
2025-10-26 23:43 ` [PATCH net-next v3 01/12] net: dsa: lantiq_gswip: split into common and MMIO parts Daniel Golle
2025-10-27 11:37 ` Sverdlin, Alexander
2025-10-27 22:22 ` Vladimir Oltean
2025-10-26 23:44 ` [PATCH net-next v3 02/12] net: dsa: lantiq_gswip: support enable/disable learning Daniel Golle
2025-10-27 22:29 ` Vladimir Oltean
2025-10-26 23:44 ` [PATCH net-next v3 03/12] net: dsa: lantiq_gswip: support Energy Efficient Ethernet Daniel Golle
2025-10-26 23:44 ` [PATCH net-next v3 04/12] net: dsa: lantiq_gswip: set link parameters also for CPU port Daniel Golle
2025-10-27 8:03 ` Sverdlin, Alexander
2025-10-27 22:39 ` Vladimir Oltean
2025-10-26 23:44 ` [PATCH net-next v3 05/12] net: dsa: lantiq_gswip: define and use GSWIP_TABLE_MAC_BRIDGE_VAL1_VALID Daniel Golle
2025-10-27 22:47 ` Vladimir Oltean
2025-10-26 23:45 ` [PATCH net-next v3 06/12] dt-bindings: net: dsa: lantiq,gswip: add support for MII delay properties Daniel Golle
2025-10-27 23:04 ` Vladimir Oltean
2025-10-27 23:41 ` Daniel Golle
2025-10-28 1:39 ` Vladimir Oltean
2025-10-28 2:30 ` Daniel Golle
2025-10-26 23:45 ` [PATCH net-next v3 07/12] net: dsa: lantiq_gswip: allow adjusting MII delays Daniel Golle
2025-10-26 23:47 ` [PATCH net-next v3 08/12] dt-bindings: net: dsa: lantiq,gswip: add MaxLinear RMII refclk output property Daniel Golle
2025-10-27 9:41 ` Sverdlin, Alexander
2025-10-26 23:47 ` [PATCH net-next v3 09/12] net: dsa: lantiq_gswip: add vendor property to setup MII refclk output Daniel Golle
2025-10-27 11:39 ` Sverdlin, Alexander
2025-10-27 23:36 ` Vladimir Oltean
2025-10-27 23:48 ` Daniel Golle
2025-10-28 1:44 ` Vladimir Oltean
2025-10-26 23:48 ` [PATCH net-next v3 10/12] dt-bindings: net: dsa: lantiq,gswip: add support for MaxLinear GSW1xx switches Daniel Golle
2025-10-28 0:09 ` Vladimir Oltean
2025-10-28 1:27 ` Daniel Golle
2025-10-26 23:48 ` [PATCH net-next v3 11/12] net: dsa: add tagging driver for MaxLinear GSW1xx switch family Daniel Golle
2025-10-27 11:48 ` Sverdlin, Alexander
2025-10-28 0:28 ` Vladimir Oltean
2025-10-28 17:24 ` Daniel Golle [this message]
2025-10-26 23:49 ` [PATCH net-next v3 12/12] net: dsa: add " Daniel Golle
2025-10-28 1:24 ` Vladimir Oltean
2025-10-28 2:14 ` Daniel Golle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aQD8QnK-bnuptPlU@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=ajayaraman@maxlinear.com \
--cc=alexander.sverdlin@siemens.com \
--cc=andreas.schirm@siemens.com \
--cc=andrew@lunn.ch \
--cc=bxu@maxlinear.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=fchan@maxlinear.com \
--cc=hauke@hauke-m.de \
--cc=horms@kernel.org \
--cc=john@phrozen.org \
--cc=jpovazanec@maxlinear.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lrosu@maxlinear.com \
--cc=lukas.stockmann@siemens.com \
--cc=lxu@maxlinear.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=peter.christen@siemens.com \
--cc=robh@kernel.org \
--cc=yweng@maxlinear.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®