From: Simon Horman <horms@kernel.org>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Andrew Lunn <andrew@lunn.ch>, 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>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Frank Wunderlich <frankwu@gmx.de>,
Chad Monroe <chad@monroe.io>,
Cezary Wilmanski <cezary.wilmanski@adtran.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 RFC net-next v3 2/4] net: dsa: add tag formats for MxL862xx switches
Date: Mon, 15 Dec 2025 14:28:17 +0000 [thread overview]
Message-ID: <aUAbAWUWUyJqACoz@horms.kernel.org> (raw)
In-Reply-To: <de01f08a3c99921d439bc15eeafd94e759688554.1765757027.git.daniel@makrotopia.org>
On Mon, Dec 15, 2025 at 12:11:43AM +0000, Daniel Golle wrote:
...
> diff --git a/net/dsa/tag_mxl862xx.c b/net/dsa/tag_mxl862xx.c
> new file mode 100644
> index 0000000000000..9c5e5f90dcb63
> --- /dev/null
> +++ b/net/dsa/tag_mxl862xx.c
> @@ -0,0 +1,113 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * DSA Special Tag for MaxLinear 862xx switch chips
> + *
> + * Copyright (C) 2025 Daniel Golle <daniel@makrotopia.org>
> + * Copyright (C) 2024 MaxLinear Inc.
> + */
> +
> +#include <linux/bitops.h>
> +#include <linux/etherdevice.h>
> +#include <linux/skbuff.h>
> +#include <net/dsa.h>
> +#include "tag.h"
> +
> +#define MXL862_NAME "mxl862xx"
> +
> +/* To define the outgoing port and to discover the incoming port a special
> + * tag is used by the GSW1xx.
> + *
> + * Dest MAC Src MAC special TAG EtherType
> + * ...| 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 | 1 2 |...
> + * |<--------------->|
> + */
> +
> +#define MXL862_HEADER_LEN 8
> +
> +/* Byte 7 */
> +#define MXL862_IGP_EGP GENMASK(3, 0)
> +
> +static struct sk_buff *mxl862_tag_xmit(struct sk_buff *skb,
> + struct net_device *dev)
> +{
> + struct dsa_port *dp = dsa_user_to_port(dev);
> + struct dsa_port *cpu_dp = dp->cpu_dp;
> + unsigned int cpu_port = cpu_dp->index + 1;
> + unsigned int usr_port = dp->index + 1;
> + __be16 *mxl862_tag;
Hi Daniel,
Please arrange local variables in reverse xmas tree order.
Even if it means separating declaration and initialisation.
FWIIW, I would probably go for:
struct dsa_port *dp = dsa_user_to_port(dev);
struct dsa_port *cpu_dp = dp->cpu_dp;
unsigned int cpu_port, usr_port;
__be16 *mxl862_tag;
cpu_port = cpu_dp->index + 1;
usr_port = dp->index + 1;
> +
> + if (!skb)
> + return skb;
> +
> + /* provide additional space 'MXL862_HEADER_LEN' bytes */
> + skb_push(skb, MXL862_HEADER_LEN);
> +
> + /* shift MAC address to the beginnig of the enlarged buffer,
s/beginnig/beginning/
> + * releasing the space required for DSA tag (between MAC address and
> + * Ethertype)
> + */
> + dsa_alloc_etype_header(skb, MXL862_HEADER_LEN);
> +
> + /* special tag ingress */
> + mxl862_tag = dsa_etype_header_pos_tx(skb);
> + mxl862_tag[0] = htons(ETH_P_MXLGSW);
> + mxl862_tag[1] = 0;
> + mxl862_tag[2] = htons(usr_port + 16 - cpu_port);
> + mxl862_tag[3] = htons(FIELD_PREP(MXL862_IGP_EGP, cpu_port));
> +
> + return skb;
> +}
...
next prev parent reply other threads:[~2025-12-15 14:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 0:11 [PATCH RFC net-next v3 0/4] net: dsa: initial support for MaxLinear MxL862xx switches Daniel Golle
2025-12-15 0:11 ` [PATCH RFC net-next v3 1/4] dt-bindings: net: dsa: add bindings for MaxLinear MxL862xx Daniel Golle
2025-12-15 0:11 ` [PATCH RFC net-next v3 2/4] net: dsa: add tag formats for MxL862xx switches Daniel Golle
2025-12-15 1:46 ` Andrew Lunn
2025-12-15 14:28 ` Simon Horman [this message]
2025-12-15 0:12 ` [PATCH RFC net-next v3 3/4] net: mdio: add unlocked mdiodev C45 bus accessors Daniel Golle
2025-12-15 0:12 ` [PATCH RFC net-next v3 4/4] net: dsa: add basic initial driver for MxL862xx switches 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=aUAbAWUWUyJqACoz@horms.kernel.org \
--to=horms@kernel.org \
--cc=ajayaraman@maxlinear.com \
--cc=andrew@lunn.ch \
--cc=bxu@maxlinear.com \
--cc=cezary.wilmanski@adtran.com \
--cc=chad@monroe.io \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=fchan@maxlinear.com \
--cc=frankwu@gmx.de \
--cc=hkallweit1@gmail.com \
--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=lxu@maxlinear.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.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;
as well as URLs for NNTP newsgroup(s).