From nobody Sun Dec 14 19:33:09 2025 Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C31915624B; Sun, 14 Dec 2025 00:41:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765672879; cv=none; b=idZ5CD64AIyE2KlCa1mefLda5AJapzb4QqeAX9n96a3i7wHpKYoAvmU7zJSnoDqE72eWXA3If2ggPcPh9WjZXgFulq+k4Lf1qzUbtuknRTzBGITfmPj9cRFzLO/hoUmanRJdB07YMSU6j08X4VVMvzmuCjEc6CJe6WNyUEwwgwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765672879; c=relaxed/simple; bh=R04H1ydlMMjan00+/dS9t0w2gtxqIx1H7KF/nLKJRYo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZOgrGyl+teokkKL7+c4+bd/lmm00LMzOLj5U/1ftWC20BTvWrSvFAPGnxSFhRtX2iHzAkIgLMIUV3t4/9qoI+IL9WxfS3PHkaJiqxtSFicnwRfn+RcLxY7mREDVGHCB+iC+yWE/wH9Xpop9GceAQSWSI7j/LsTLLp0yRasHQnZk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.99) (envelope-from ) id 1vUaAj-000000006lm-1BxC; Sun, 14 Dec 2025 00:41:13 +0000 Date: Sun, 14 Dec 2025 00:41:09 +0000 From: Daniel Golle To: Daniel Golle , Andrew Lunn , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiner Kallweit , Russell King , Simon Horman , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Frank Wunderlich , Chad Monroe , Cezary Wilmanski , Avinash Jayaraman , Bing tao Xu , Liang Xu , Juraj Povazanec , "Fanni (Fang-Yi) Chan" , "Benny (Ying-Tsan) Weng" , "Livia M. Rosu" , John Crispin Subject: [RFC PATCH v2 net-next 2/4] net: dsa: add tag formats for MxL862xx switches Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add proprietary special tag format for the MaxLinear MXL862xx family of switches. While using the same Ethertype as MaxLinear's GSW1xx swtiches, the actual tag format differs significantly, hence we need a dedicated tag driver for that. Signed-off-by: Daniel Golle --- RFC v2: make sure all tag fields are initialized MAINTAINERS | 1 + include/net/dsa.h | 2 + net/dsa/Kconfig | 7 +++ net/dsa/Makefile | 1 + net/dsa/tag_mxl862xx.c | 113 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 124 insertions(+) create mode 100644 net/dsa/tag_mxl862xx.c diff --git a/MAINTAINERS b/MAINTAINERS index c433a15d9797a..a20498cc8320b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15609,6 +15609,7 @@ M: Daniel Golle L: netdev@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/net/dsa/maxlinear,mxl862xx.yaml +F: net/dsa/tag_mxl862xx.c =20 MCAN DEVICE DRIVER M: Markus Schneider-Pargmann diff --git a/include/net/dsa.h b/include/net/dsa.h index e40cdc12f7f39..e4c2b47a2a46e 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -57,6 +57,7 @@ struct tc_action; #define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29 #define DSA_TAG_PROTO_YT921X_VALUE 30 #define DSA_TAG_PROTO_MXL_GSW1XX_VALUE 31 +#define DSA_TAG_PROTO_MXL862_VALUE 32 =20 enum dsa_tag_protocol { DSA_TAG_PROTO_NONE =3D DSA_TAG_PROTO_NONE_VALUE, @@ -91,6 +92,7 @@ enum dsa_tag_protocol { DSA_TAG_PROTO_VSC73XX_8021Q =3D DSA_TAG_PROTO_VSC73XX_8021Q_VALUE, DSA_TAG_PROTO_YT921X =3D DSA_TAG_PROTO_YT921X_VALUE, DSA_TAG_PROTO_MXL_GSW1XX =3D DSA_TAG_PROTO_MXL_GSW1XX_VALUE, + DSA_TAG_PROTO_MXL862 =3D DSA_TAG_PROTO_MXL862_VALUE, }; =20 struct dsa_switch; diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index f86b30742122f..c897d62326f5b 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig @@ -145,6 +145,13 @@ config NET_DSA_TAG_QCA Say Y or M if you want to enable support for tagging frames for the Qualcomm Atheros QCA8K switches. =20 +config NET_DSA_TAG_MXL862 + tristate "Tag driver for MxL862xx switches" + help + Say Y or M if you want to enable support for tagging frames for the + Maxlinear MxL86252 and MxL86282 switches using their native 8-byte + tagging protocol. + config NET_DSA_TAG_RTL4_A tristate "Tag driver for Realtek 4 byte protocol A tags" help diff --git a/net/dsa/Makefile b/net/dsa/Makefile index 42d173f5a7013..dbe2a742e3322 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_NET_DSA_TAG_HELLCREEK) +=3D tag_hellcreek.o obj-$(CONFIG_NET_DSA_TAG_KSZ) +=3D tag_ksz.o obj-$(CONFIG_NET_DSA_TAG_LAN9303) +=3D tag_lan9303.o obj-$(CONFIG_NET_DSA_TAG_MTK) +=3D tag_mtk.o +obj-$(CONFIG_NET_DSA_TAG_MXL862) +=3D tag_mxl862xx.o obj-$(CONFIG_NET_DSA_TAG_MXL_GSW1XX) +=3D tag_mxl-gsw1xx.o obj-$(CONFIG_NET_DSA_TAG_NONE) +=3D tag_none.o obj-$(CONFIG_NET_DSA_TAG_OCELOT) +=3D tag_ocelot.o 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 + * Copyright (C) 2024 MaxLinear Inc. + */ + +#include +#include +#include +#include +#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 =3D dsa_user_to_port(dev); + struct dsa_port *cpu_dp =3D dp->cpu_dp; + unsigned int cpu_port =3D cpu_dp->index + 1; + unsigned int usr_port =3D dp->index + 1; + __be16 *mxl862_tag; + + 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, + * 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 =3D dsa_etype_header_pos_tx(skb); + mxl862_tag[0] =3D htons(ETH_P_MXLGSW); + mxl862_tag[1] =3D 0; + mxl862_tag[2] =3D htons(usr_port + 16 - cpu_port); + mxl862_tag[3] =3D htons(FIELD_PREP(MXL862_IGP_EGP, cpu_port)); + + return skb; +} + +static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb, + struct net_device *dev) +{ + int port; + __be16 *mxl862_tag; + + if (unlikely(!pskb_may_pull(skb, MXL862_HEADER_LEN))) { + dev_warn_ratelimited(&dev->dev, "Cannot pull SKB, packet dropped\n"); + return NULL; + } + + mxl862_tag =3D dsa_etype_header_pos_rx(skb); + + if (unlikely(mxl862_tag[0] !=3D htons(ETH_P_MXLGSW))) { + dev_warn_ratelimited(&dev->dev, "Invalid special tag marker, packet drop= ped\n"); + dev_warn_ratelimited(&dev->dev, "Rx Packet Tag: %8ph\n", + mxl862_tag); + return NULL; + } + + /* Get source port information */ + port =3D FIELD_GET(MXL862_IGP_EGP, ntohs(mxl862_tag[3])); + port =3D port - 1; + skb->dev =3D dsa_conduit_find_user(dev, 0, port); + if (!skb->dev) { + dev_warn_ratelimited(&dev->dev, "Invalid source port, packet dropped\n"); + dev_warn_ratelimited(&dev->dev, "Rx Packet Tag: %8ph\n", + mxl862_tag); + return NULL; + } + + /* remove the MxL862xx special tag between the MAC addresses and the + * current ethertype field. + */ + skb_pull_rcsum(skb, MXL862_HEADER_LEN); + dsa_strip_etype_header(skb, MXL862_HEADER_LEN); + + return skb; +} + +static const struct dsa_device_ops mxl862_netdev_ops =3D { + .name =3D "mxl862", + .proto =3D DSA_TAG_PROTO_MXL862, + .xmit =3D mxl862_tag_xmit, + .rcv =3D mxl862_tag_rcv, + .needed_headroom =3D MXL862_HEADER_LEN, +}; + +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_MXL862, MXL862_NAME); +MODULE_DESCRIPTION("DSA tag driver for MaxLinear MxL862xx switches"); +MODULE_LICENSE("GPL"); + +module_dsa_tag_driver(mxl862_netdev_ops); --=20 2.52.0