[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aUAbAWUWUyJqACoz@horms.kernel.org>
Date: Mon, 15 Dec 2025 14:28:17 +0000
From: Simon Horman <horms@...nel.org>
To: Daniel Golle <daniel@...rotopia.org>
Cc: Andrew Lunn <andrew@...n.ch>, Vladimir Oltean <olteanv@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Frank Wunderlich <frankwu@....de>, Chad Monroe <chad@...roe.io>,
Cezary Wilmanski <cezary.wilmanski@...ran.com>,
Avinash Jayaraman <ajayaraman@...linear.com>,
Bing tao Xu <bxu@...linear.com>, Liang Xu <lxu@...linear.com>,
Juraj Povazanec <jpovazanec@...linear.com>,
"Fanni (Fang-Yi) Chan" <fchan@...linear.com>,
"Benny (Ying-Tsan) Weng" <yweng@...linear.com>,
"Livia M. Rosu" <lrosu@...linear.com>,
John Crispin <john@...ozen.org>
Subject: Re: [PATCH RFC net-next v3 2/4] net: dsa: add tag formats for
MxL862xx switches
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@...rotopia.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;
> +}
...
Powered by blists - more mailing lists