Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families
@ 2026-09-04  9:54 Kyle Switch
  2026-09-04  9:54 ` [PATCH net-next v5 2/6] net: dsa: motorcomm: use max_ports from series_info for port bounds checking Kyle Switch
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Kyle Switch @ 2026-09-04  9:54 UTC (permalink / raw)
  To: andrew, olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms,
	linux, netdev, linux-kernel
  Cc: ming.xu, xiaolin.xu, jianmin.wang, wei.zhang, sijia.huang

Introduce yt92xx_series_info structure to hold private
data for different switch families, replacing hardcoded
logic in probe(). This makes the driver more extensible
for future switch support.

Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>
---
 drivers/net/dsa/motorcomm/chip.c | 82 +++++++++++++++++++++++++++-----
 drivers/net/dsa/motorcomm/chip.h | 20 ++++++++
 2 files changed, 91 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index d663af010f43..557a0e07d8d7 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -4679,6 +4679,68 @@ static const struct dsa_switch_ops yt921x_dsa_switch_ops = {
 	.setup			= yt921x_dsa_setup,
 };
 
+static const struct yt92xx_series_info yt92xx_series_info_table[] = {
+	[YT921X] = {
+		.mode = YT921X,
+		.name = "YT921X",
+		.max_ports = YT921X_PORT_NUM,
+		.num_lag_ids = YT921X_LAG_NUM,
+		.ageing_time_min = 1 * 5000,
+		.ageing_time_max = U16_MAX * 5000,
+		.dscp_prio_mapping_is_global = true,
+		.assisted_learning_on_cpu_port = true,
+		.switch_ops = &yt921x_dsa_switch_ops,
+		.mac_ops = &yt921x_phylink_mac_ops
+	},
+};
+
+static const struct yt92xx_series_info *yt92xx_series_lookup_info(u32 major)
+{
+	enum yt92xx_mode mode = YT_MAX;
+	int i;
+
+	if (major == YT9215_MAJOR || major == YT9218_MAJOR)
+		mode = YT921X;
+
+	for (i = 0; i < ARRAY_SIZE(yt92xx_series_info_table); ++i)
+		if (yt92xx_series_info_table[i].mode == mode)
+			return &yt92xx_series_info_table[i];
+
+	return NULL;
+}
+
+static int yt92xx_register_switch(struct dsa_switch *ds)
+{
+	struct yt921x_priv *priv = to_yt921x_priv(ds);
+	const struct yt92xx_series_info *series_info;
+	u32 chipid;
+	u32 major;
+	int res;
+
+	res = yt921x_reg_read(priv, YT921X_CHIP_ID, &chipid);
+	if (res)
+		return res;
+
+	major = FIELD_GET(YT921X_CHIP_ID_MAJOR, chipid);
+	series_info = yt92xx_series_lookup_info(major);
+	if (!series_info)
+		return -ENODEV;
+	priv->series_info = series_info;
+
+	ds->assisted_learning_on_cpu_port =
+		priv->series_info->assisted_learning_on_cpu_port;
+	ds->dscp_prio_mapping_is_global =
+		priv->series_info->dscp_prio_mapping_is_global;
+	ds->ageing_time_min = priv->series_info->ageing_time_min;
+	ds->ageing_time_max = priv->series_info->ageing_time_max;
+	ds->num_lag_ids = priv->series_info->num_lag_ids;
+	ds->num_ports = priv->series_info->max_ports;
+	ds->ops = priv->series_info->switch_ops;
+	ds->phylink_mac_ops = priv->series_info->mac_ops;
+
+	return 0;
+}
+
 static void yt921x_mdio_shutdown(struct mdio_device *mdiodev)
 {
 	struct yt921x_priv *priv = mdiodev_get_drvdata(mdiodev);
@@ -4727,6 +4789,7 @@ static int yt921x_mdio_probe(struct mdio_device *mdiodev)
 	struct yt921x_reg_mdio *mdio;
 	struct yt921x_priv *priv;
 	struct dsa_switch *ds;
+	int res;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -4754,15 +4817,9 @@ static int yt921x_mdio_probe(struct mdio_device *mdiodev)
 
 	ds = &priv->ds;
 	ds->dev = dev;
-	ds->assisted_learning_on_cpu_port = true;
-	ds->dscp_prio_mapping_is_global = true;
-	ds->priv = priv;
-	ds->ops = &yt921x_dsa_switch_ops;
-	ds->ageing_time_min = 1 * 5000;
-	ds->ageing_time_max = U16_MAX * 5000;
-	ds->phylink_mac_ops = &yt921x_phylink_mac_ops;
-	ds->num_lag_ids = YT921X_LAG_NUM;
-	ds->num_ports = YT921X_PORT_NUM;
+	res = yt92xx_register_switch(ds);
+	if (res)
+		return res;
 
 	mdiodev_set_drvdata(mdiodev, priv);
 
@@ -4770,8 +4827,11 @@ static int yt921x_mdio_probe(struct mdio_device *mdiodev)
 }
 
 static const struct of_device_id yt921x_of_match[] = {
-	{ .compatible = "motorcomm,yt9215" },
-	{}
+	{
+		.compatible = "motorcomm,yt9215",
+		.data = &yt92xx_series_info_table[YT921X],
+	},
+	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, yt921x_of_match);
 
diff --git a/drivers/net/dsa/motorcomm/chip.h b/drivers/net/dsa/motorcomm/chip.h
index 83cd454955dd..65f9e6234678 100644
--- a/drivers/net/dsa/motorcomm/chip.h
+++ b/drivers/net/dsa/motorcomm/chip.h
@@ -960,9 +960,29 @@ struct yt921x_reg_ops {
 	int (*write)(void *context, u32 reg, u32 val);
 };
 
+enum yt92xx_mode {
+	YT921X,
+	YT922X,
+	YT_MAX,
+};
+
+struct yt92xx_series_info {
+	enum yt92xx_mode mode;
+	const char *name;
+	unsigned int max_ports;
+	unsigned int num_lag_ids;
+	unsigned int ageing_time_min;
+	unsigned int ageing_time_max;
+	u32 dscp_prio_mapping_is_global;
+	u32 assisted_learning_on_cpu_port;
+	const struct dsa_switch_ops *switch_ops;
+	const struct phylink_mac_ops *mac_ops;
+};
+
 struct yt921x_priv {
 	struct dsa_switch ds;
 
+	const struct yt92xx_series_info *series_info;
 	const struct yt921x_info *info;
 	unsigned int meter_slot_ns;
 	unsigned int port_shape_slot_ns;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next v5 2/6] net: dsa: motorcomm: use max_ports from series_info for port bounds checking
  2026-09-04  9:54 [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Kyle Switch
@ 2026-09-04  9:54 ` Kyle Switch
  2026-09-04 13:32   ` Andrew Lunn
  2026-09-04  9:54 ` [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup() Kyle Switch
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Kyle Switch @ 2026-09-04  9:54 UTC (permalink / raw)
  To: andrew, olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms,
	linux, netdev, linux-kernel
  Cc: ming.xu, xiaolin.xu, jianmin.wang, wei.zhang, sijia.huang

Replace the hardcoded YT921X_PORT_NUM macro with the per-series
max_ports field in port validation. This removes family-specific
constants from the common code path and simplifies adding new
switch families with different port counts.

No functional change for existing YT921X devices.

Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>
---
 drivers/net/dsa/motorcomm/chip.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index 557a0e07d8d7..7ae48e6636a0 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -357,7 +357,7 @@ static int yt921x_mbus_int_read(struct mii_bus *mbus, int port, int reg)
 	u16 val;
 	int res;
 
-	if (port >= YT921X_PORT_NUM)
+	if (port >= priv->series_info->max_ports)
 		return U16_MAX;
 
 	mutex_lock(&priv->reg_lock);
@@ -375,7 +375,7 @@ yt921x_mbus_int_write(struct mii_bus *mbus, int port, int reg, u16 data)
 	struct yt921x_priv *priv = mbus->priv;
 	int res;
 
-	if (port >= YT921X_PORT_NUM)
+	if (port >= priv->series_info->max_ports)
 		return -ENODEV;
 
 	mutex_lock(&priv->reg_lock);
@@ -390,6 +390,7 @@ yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp)
 {
 	struct device *dev = to_device(priv);
 	struct mii_bus *mbus;
+	u32 max_ports;
 	int res;
 
 	mbus = devm_mdiobus_alloc(dev);
@@ -402,7 +403,8 @@ yt921x_mbus_int_init(struct yt921x_priv *priv, struct device_node *mnp)
 	mbus->read = yt921x_mbus_int_read;
 	mbus->write = yt921x_mbus_int_write;
 	mbus->parent = dev;
-	mbus->phy_mask = (u32)~GENMASK(YT921X_PORT_NUM - 1, 0);
+	max_ports = priv->series_info->max_ports;
+	mbus->phy_mask = (u32)~GENMASK(max_ports - 1, 0);
 
 	res = devm_of_mdiobus_register(dev, mbus, mnp);
 	if (res)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup()
  2026-09-04  9:54 [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Kyle Switch
  2026-09-04  9:54 ` [PATCH net-next v5 2/6] net: dsa: motorcomm: use max_ports from series_info for port bounds checking Kyle Switch
@ 2026-09-04  9:54 ` Kyle Switch
  2026-09-04 13:37   ` Andrew Lunn
                     ` (2 more replies)
  2026-09-04  9:54 ` [PATCH net-next v5 4/6] net: dsa: motorcomm: introduce mib_init to control MIB polling initialization Kyle Switch
                   ` (3 subsequent siblings)
  5 siblings, 3 replies; 13+ messages in thread
From: Kyle Switch @ 2026-09-04  9:54 UTC (permalink / raw)
  To: andrew, olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms,
	linux, netdev, linux-kernel
  Cc: ming.xu, xiaolin.xu, jianmin.wang, wei.zhang, sijia.huang

Move MIB polling start from probe() to dsa_setup() so that it can
be conditionally enabled based on the actual switch family support,
avoiding attempts to enable it on unsupported switch families.

Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>
---
 drivers/net/dsa/motorcomm/chip.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index 7ae48e6636a0..f74a44048fb1 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -4553,6 +4553,14 @@ static int yt921x_dsa_setup(struct dsa_switch *ds)
 	struct device_node *child;
 	int res;
 
+	/* mib polling init */
+	for (size_t i = 0; i < ARRAY_SIZE(priv->ports); i++) {
+		struct yt921x_port *pp = &priv->ports[i];
+
+		pp->index = i;
+		INIT_DELAYED_WORK(&pp->mib_read, yt921x_poll_mib);
+	}
+
 	mutex_lock(&priv->reg_lock);
 	res = yt921x_chip_reset(priv);
 	mutex_unlock(&priv->reg_lock);
@@ -4810,13 +4818,6 @@ static int yt921x_mdio_probe(struct mdio_device *mdiodev)
 	priv->reg_ops = &yt921x_reg_ops_mdio;
 	priv->reg_ctx = mdio;
 
-	for (size_t i = 0; i < ARRAY_SIZE(priv->ports); i++) {
-		struct yt921x_port *pp = &priv->ports[i];
-
-		pp->index = i;
-		INIT_DELAYED_WORK(&pp->mib_read, yt921x_poll_mib);
-	}
-
 	ds = &priv->ds;
 	ds->dev = dev;
 	res = yt92xx_register_switch(ds);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next v5 4/6] net: dsa: motorcomm: introduce mib_init to control MIB polling initialization
  2026-09-04  9:54 [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Kyle Switch
  2026-09-04  9:54 ` [PATCH net-next v5 2/6] net: dsa: motorcomm: use max_ports from series_info for port bounds checking Kyle Switch
  2026-09-04  9:54 ` [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup() Kyle Switch
@ 2026-09-04  9:54 ` Kyle Switch
  2026-09-04 13:45   ` Andrew Lunn
  2026-09-04  9:54 ` [PATCH net-next v5 5/6] net: dsa: tag_922x: add support for Motorcomm YT922x tags Kyle Switch
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 13+ messages in thread
From: Kyle Switch @ 2026-09-04  9:54 UTC (permalink / raw)
  To: andrew, olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms,
	linux, netdev, linux-kernel
  Cc: ming.xu, xiaolin.xu, jianmin.wang, wei.zhang, sijia.huang

Add a mib_init flag to indicate whether MIB polling has been
successfully initialized. This prevents the driver from attempting
to clean up MIB-related resources on removal for switch families
that do not support MIB polling, which would otherwise trigger
errors or crashes.

Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>
---
 drivers/net/dsa/motorcomm/chip.c | 2 ++
 drivers/net/dsa/motorcomm/chip.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c
index f74a44048fb1..df5c0b995fde 100644
--- a/drivers/net/dsa/motorcomm/chip.c
+++ b/drivers/net/dsa/motorcomm/chip.c
@@ -4559,6 +4559,7 @@ static int yt921x_dsa_setup(struct dsa_switch *ds)
 
 		pp->index = i;
 		INIT_DELAYED_WORK(&pp->mib_read, yt921x_poll_mib);
+		pp->mib_init = true;
 	}
 
 	mutex_lock(&priv->reg_lock);
@@ -4771,6 +4772,7 @@ static void yt921x_mdio_remove(struct mdio_device *mdiodev)
 	for (size_t i = ARRAY_SIZE(priv->ports); i-- > 0; ) {
 		struct yt921x_port *pp = &priv->ports[i];
 
+		if (pp->mib_init)
 			disable_delayed_work_sync(&pp->mib_read);
 	}
 
diff --git a/drivers/net/dsa/motorcomm/chip.h b/drivers/net/dsa/motorcomm/chip.h
index 65f9e6234678..6c89e3d304fa 100644
--- a/drivers/net/dsa/motorcomm/chip.h
+++ b/drivers/net/dsa/motorcomm/chip.h
@@ -943,6 +943,7 @@ struct yt921x_port {
 	struct yt921x_mib mib;
 	u64 rx_frames;
 	u64 tx_frames;
+	bool mib_init;
 
 #if IS_ENABLED(CONFIG_NET_DSA_YT921X_LEDS)
 	unsigned char led_duty;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH net-next v5 5/6] net: dsa: tag_922x: add support for Motorcomm YT922x tags
  2026-09-04  9:54 [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Kyle Switch
                   ` (2 preceding siblings ...)
  2026-09-04  9:54 ` [PATCH net-next v5 4/6] net: dsa: motorcomm: introduce mib_init to control MIB polling initialization Kyle Switch
@ 2026-09-04  9:54 ` Kyle Switch
  2026-09-04 17:22   ` David Yang
  2026-09-04 13:14 ` [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Andrew Lunn
  2026-09-04 17:03 ` David Yang
  5 siblings, 1 reply; 13+ messages in thread
From: Kyle Switch @ 2026-09-04  9:54 UTC (permalink / raw)
  To: andrew, olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms,
	linux, netdev, linux-kernel
  Cc: ming.xu, xiaolin.xu, jianmin.wang, wei.zhang, sijia.huang

Add support for Motorcomm YT922x tags with 8bytes. which includes
ethertype field (default to 0x9988).

Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>
---
 include/net/dsa.h    |   2 +
 net/dsa/Kconfig      |   6 +++
 net/dsa/Makefile     |   1 +
 net/dsa/tag_yt922x.c | 112 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 121 insertions(+)
 create mode 100644 net/dsa/tag_yt922x.c

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 7507d632e7c6..0807a595aaad 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -61,6 +61,7 @@ struct tc_action;
 #define DSA_TAG_PROTO_NETC_VALUE		33
 #define DSA_TAG_PROTO_KSZ8463_VALUE		34
 #define DSA_TAG_PROTO_MT7628_VALUE		35
+#define DSA_TAG_PROTO_YT922X_VALUE		36
 
 enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NONE		= DSA_TAG_PROTO_NONE_VALUE,
@@ -99,6 +100,7 @@ enum dsa_tag_protocol {
 	DSA_TAG_PROTO_NETC		= DSA_TAG_PROTO_NETC_VALUE,
 	DSA_TAG_PROTO_KSZ8463		= DSA_TAG_PROTO_KSZ8463_VALUE,
 	DSA_TAG_PROTO_MT7628		= DSA_TAG_PROTO_MT7628_VALUE,
+	DSA_TAG_PROTO_YT922X		= DSA_TAG_PROTO_YT922X_VALUE,
 };
 
 struct dsa_switch;
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index 23b4b74004ed..0b9f8a632cf2 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -227,4 +227,10 @@ config NET_DSA_TAG_YT921X
 	  Say Y or M if you want to enable support for tagging frames for
 	  Motorcomm YT921x switches.
 
+config NET_DSA_TAG_YT922X
+	tristate "Tag driver for Motorcomm YT922x switches"
+	help
+	  Say Y or M if you want to enable support for tagging frames for
+	  Motorcomm YT922x switches.
+
 endif
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index d15bcf5c68f0..0c53f4184bdb 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -44,6 +44,7 @@ obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
 obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o
 obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o
 obj-$(CONFIG_NET_DSA_TAG_YT921X) += tag_yt921x.o
+obj-$(CONFIG_NET_DSA_TAG_YT922X) += tag_yt922x.o
 
 # for tracing framework to find trace.h
 CFLAGS_trace.o := -I$(src)
diff --git a/net/dsa/tag_yt922x.c b/net/dsa/tag_yt922x.c
new file mode 100644
index 000000000000..db1fc16d8ce7
--- /dev/null
+++ b/net/dsa/tag_yt922x.c
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Motorcomm YT922x Switch Extended CPU Port Tagging
+ *
+ * Copyright (c) 2026 Kyle switch <kyle.switch@motor-comm.com>
+ *
+ */
+
+#include <linux/etherdevice.h>
+
+#include "tag.h"
+
+#define YT922X_TAG_LEN	8
+
+/*
+ * To define the from cpu tag format 8 bytes:
+ */
+#define YT922X_TAG_NAME		"yt922x"
+#define YT922X_TAG_PORTMASK_0	BIT(15)
+#define YT922X_TAG_PORTMASK_M	GENMASK(8, 0)
+#define  YT922X_TAG_PORTS(x)		FIELD_PREP(YT922X_TAG_PORTMASK_M, ((x) >> 0x1))
+#define YT922X_TAG_FORCE_DST	BIT(9)
+#define YT922X_TAG_PRIO_M	GENMASK(12, 10)
+#define YT922X_TAG_PRIO_EN	BIT(13)
+#define  YT922X_TAG_PRIO(x)		(FIELD_PREP(YT922X_TAG_PRIO_M, (x)) | YT922X_TAG_PRIO_EN)
+#define YT922X_TAG_RX_PORT_M	GENMASK(5, 2)
+#define YT922X_TAG_RX_PRIO_M	GENMASK(15, 13)
+
+static struct sk_buff *
+yt922x_tag_xmit(struct sk_buff *skb, struct net_device *netdev)
+{
+	struct dsa_port *dp = dsa_user_to_port(netdev);
+	__be16 *tag;
+	u16 ctrl;
+
+	skb_push(skb, YT922X_TAG_LEN);
+	dsa_alloc_etype_header(skb, YT922X_TAG_LEN);
+	tag = dsa_etype_header_pos_tx(skb);
+
+	tag[0] = htons(ETH_P_YT921X);
+	if (dp->index != 0) {
+		/* Port index is not equal 0 in tag[1] */
+		ctrl = YT922X_TAG_PRIO(skb->priority) | YT922X_TAG_FORCE_DST |
+			YT922X_TAG_PORTS(dsa_xmit_port_mask(skb, netdev));
+		tag[1] = htons(ctrl);
+		tag[2] = 0;
+	} else {
+		/* Port 0 in bit15 in tag[2] */
+		ctrl = YT922X_TAG_PRIO(skb->priority) | YT922X_TAG_FORCE_DST;
+		tag[1] = htons(ctrl);
+		ctrl = YT922X_TAG_PORTMASK_0;
+		tag[2] = htons(ctrl);
+	}
+	tag[3] = 0;
+
+	return skb;
+}
+
+static struct sk_buff *
+yt922x_tag_rcv(struct sk_buff *skb, struct net_device *netdev)
+{
+	unsigned int port;
+	__be16 *tag;
+	u16 rx;
+
+	if (unlikely(!pskb_may_pull(skb, YT922X_TAG_LEN))) {
+		kfree_skb(skb);
+		return NULL;
+	}
+
+	tag = dsa_etype_header_pos_rx(skb);
+
+	if (unlikely(tag[0] != htons(ETH_P_YT921X))) {
+		dev_warn_ratelimited(&netdev->dev,
+				     "Unexpected EtherType 0x%04x\n",
+				     ntohs(tag[0]));
+		kfree_skb(skb);
+		return NULL;
+	}
+
+	/* Locate which port this is coming from */
+	rx = ntohs(tag[2]);
+	port = FIELD_GET(YT922X_TAG_RX_PORT_M, rx);
+	skb->dev = dsa_conduit_find_user(netdev, 0, port);
+	if (unlikely(!skb->dev)) {
+		dev_warn_ratelimited(&netdev->dev,
+				     "Couldn't decode source port %u\n", port);
+		kfree_skb(skb);
+		return NULL;
+	}
+
+	/* Remove tag and update checksum */
+	skb_pull_rcsum(skb, YT922X_TAG_LEN);
+	dsa_strip_etype_header(skb, YT922X_TAG_LEN);
+
+	return skb;
+}
+
+static const struct dsa_device_ops yt922x_netdev_ops = {
+	.name = YT922X_TAG_NAME,
+	.proto = DSA_TAG_PROTO_YT922X,
+	.xmit = yt922x_tag_xmit,
+	.rcv = yt922x_tag_rcv,
+	.needed_headroom = YT922X_TAG_LEN,
+};
+
+MODULE_DESCRIPTION("DSA tag driver for Motorcomm YT922x switches");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_YT922X, YT922X_TAG_NAME);
+
+module_dsa_tag_driver(yt922x_netdev_ops);
+
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families
  2026-09-04  9:54 [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Kyle Switch
                   ` (3 preceding siblings ...)
  2026-09-04  9:54 ` [PATCH net-next v5 5/6] net: dsa: tag_922x: add support for Motorcomm YT922x tags Kyle Switch
@ 2026-09-04 13:14 ` Andrew Lunn
  2026-09-04 17:03 ` David Yang
  5 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2026-09-04 13:14 UTC (permalink / raw)
  To: Kyle Switch
  Cc: olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

Yah! A small patch in a series.

But patch series should have a patch 0/X explaining what the series as
a whole does.

git format-patch --cover-letter

Take a look at all the other patch series on netdev.

>  static const struct of_device_id yt921x_of_match[] = {
> -	{ .compatible = "motorcomm,yt9215" },
> -	{}
> +	{
> +		.compatible = "motorcomm,yt9215",
> +		.data = &yt92xx_series_info_table[YT921X],
> +	},
> +	{ /* sentinel */ },

There was a patchset of 33 patches posted overnight which removes the
, after the sentinel. It would be good not to add one here.


    Andrew

---
pw-bot: cr

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 2/6] net: dsa: motorcomm: use max_ports from series_info for port bounds checking
  2026-09-04  9:54 ` [PATCH net-next v5 2/6] net: dsa: motorcomm: use max_ports from series_info for port bounds checking Kyle Switch
@ 2026-09-04 13:32   ` Andrew Lunn
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2026-09-04 13:32 UTC (permalink / raw)
  To: Kyle Switch
  Cc: olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

On Fri, Sep 04, 2026 at 05:54:12PM +0800, Kyle Switch wrote:
> Replace the hardcoded YT921X_PORT_NUM macro with the per-series
> max_ports field in port validation. This removes family-specific
> constants from the common code path and simplifies adding new
> switch families with different port counts.
> 
> No functional change for existing YT921X devices.
> 
> Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>

Did you review your own patch? Don't you think it is now a lot easier
to see this patch is correct, now that it is short, does one thing and
have a commit message focused on just this change.

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup()
  2026-09-04  9:54 ` [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup() Kyle Switch
@ 2026-09-04 13:37   ` Andrew Lunn
  2026-09-04 13:48   ` Andrew Lunn
  2026-09-04 17:13   ` David Yang
  2 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2026-09-04 13:37 UTC (permalink / raw)
  To: Kyle Switch
  Cc: olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

On Fri, Sep 04, 2026 at 05:54:13PM +0800, Kyle Switch wrote:
> Move MIB polling start from probe() to dsa_setup() so that it can
> be conditionally enabled based on the actual switch family support,
> avoiding attempts to enable it on unsupported switch families.
> 
> Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>

Much better.

I would word the commit message slightly differently, in order to make
it clear what this patch does vs a future patch.

  > Move MIB polling start from probe() to dsa_setup() so that in a
  > future patch it can be conditionally enabled based on the actual
  > switch family support, avoiding attempts to enable it on
  > unsupported switch families.

What you want to avoid is my asking, did you forget to make it
conditional?

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 4/6] net: dsa: motorcomm: introduce mib_init to control MIB polling initialization
  2026-09-04  9:54 ` [PATCH net-next v5 4/6] net: dsa: motorcomm: introduce mib_init to control MIB polling initialization Kyle Switch
@ 2026-09-04 13:45   ` Andrew Lunn
  0 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2026-09-04 13:45 UTC (permalink / raw)
  To: Kyle Switch
  Cc: olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

On Fri, Sep 04, 2026 at 05:54:14PM +0800, Kyle Switch wrote:
> Add a mib_init flag to indicate whether MIB polling has been
> successfully initialized. This prevents the driver from attempting
> to clean up MIB-related resources on removal for switch families
> that do not support MIB polling, which would otherwise trigger
> errors or crashes.

This one i'm not convinced about. At some point, you are going to make
initialisation of MIBs conditional. Why not use that condition to
control removal as well a setup? Why do you need both a conditional
and this pp->mib_init state flag?

> @@ -4771,6 +4772,7 @@ static void yt921x_mdio_remove(struct mdio_device *mdiodev)
>  	for (size_t i = ARRAY_SIZE(priv->ports); i-- > 0; ) {
>  		struct yt921x_port *pp = &priv->ports[i];
>  
> +		if (pp->mib_init)
>  			disable_delayed_work_sync(&pp->mib_read);

This looks odd. When adding an if (), you would expect the next line
to require an additional indent. Was the indentation already wrong?

    Andrew

---
pw-bot: cr

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup()
  2026-09-04  9:54 ` [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup() Kyle Switch
  2026-09-04 13:37   ` Andrew Lunn
@ 2026-09-04 13:48   ` Andrew Lunn
  2026-09-04 17:13   ` David Yang
  2 siblings, 0 replies; 13+ messages in thread
From: Andrew Lunn @ 2026-09-04 13:48 UTC (permalink / raw)
  To: Kyle Switch
  Cc: olteanv, davem, edumazet, kuba, pabeni, mmyangfl, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

On Fri, Sep 04, 2026 at 05:54:13PM +0800, Kyle Switch wrote:
> Move MIB polling start from probe() to dsa_setup()

Actually, having thread the following patches...

For every start, there is generally a stop.

You move start from probe() to dsa_setup().

Should you not move stop from remove() to dsa_teardown()?
You want to keep the driver symmetrical.

	Andrew

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families
  2026-09-04  9:54 [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Kyle Switch
                   ` (4 preceding siblings ...)
  2026-09-04 13:14 ` [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Andrew Lunn
@ 2026-09-04 17:03 ` David Yang
  5 siblings, 0 replies; 13+ messages in thread
From: David Yang @ 2026-09-04 17:03 UTC (permalink / raw)
  To: Kyle Switch
  Cc: andrew, olteanv, davem, edumazet, kuba, pabeni, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

On Fri, Sep 4, 2026 at 5:54 PM Kyle Switch <kyle.switch@motor-comm.com> wrote:
> +               .name = "YT921X",

nit: We usually stylize it with "YT921x".

> +       if (major == YT9215_MAJOR || major == YT9218_MAJOR)
> +               mode = YT921X;
> +
> +       for (i = 0; i < ARRAY_SIZE(yt92xx_series_info_table); ++i)
> +               if (yt92xx_series_info_table[i].mode == mode)
> +                       return &yt92xx_series_info_table[i];

Redundant if you use both indexed assignment and lookup routine, since
you know the index already.

>  static const struct of_device_id yt921x_of_match[] = {
> -       { .compatible = "motorcomm,yt9215" },
> -       {}
> +       {
> +               .compatible = "motorcomm,yt9215",
> +               .data = &yt92xx_series_info_table[YT921X],

Redundant if you use both runtime identification and the match data.
Also I'm concerned with early IO operations, although I didn't see any
incorrectness here.

> +enum yt92xx_mode {
> +       YT921X,
> +       YT922X,
> +       YT_MAX,
> +};

nit: Use prefix/suffix like YT92XX_MODE_YT921X or YT921X_SERIES to
avoid too broad names and future name collision.

>  struct yt921x_priv {
>         struct dsa_switch ds;
>
> +       const struct yt92xx_series_info *series_info;
>         const struct yt921x_info *info;

nit: Better to use const struct yt92xx_series *series for simplicity.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup()
  2026-09-04  9:54 ` [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup() Kyle Switch
  2026-09-04 13:37   ` Andrew Lunn
  2026-09-04 13:48   ` Andrew Lunn
@ 2026-09-04 17:13   ` David Yang
  2 siblings, 0 replies; 13+ messages in thread
From: David Yang @ 2026-09-04 17:13 UTC (permalink / raw)
  To: Kyle Switch
  Cc: andrew, olteanv, davem, edumazet, kuba, pabeni, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

On Fri, Sep 4, 2026 at 5:54 PM Kyle Switch <kyle.switch@motor-comm.com> wrote:
>
> Move MIB polling start from probe() to dsa_setup() so that it can
> be conditionally enabled based on the actual switch family support,
> avoiding attempts to enable it on unsupported switch families.
>
> Signed-off-by: Kyle Switch <kyle.switch@motor-comm.com>
> ---
>  drivers/net/dsa/motorcomm/chip.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)

I didn't see this patch being used afterwards (and patch 6 seems missing).

I'm not against the patch, but if you don't use it, please post it in
another series.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH net-next v5 5/6] net: dsa: tag_922x: add support for Motorcomm YT922x tags
  2026-09-04  9:54 ` [PATCH net-next v5 5/6] net: dsa: tag_922x: add support for Motorcomm YT922x tags Kyle Switch
@ 2026-09-04 17:22   ` David Yang
  0 siblings, 0 replies; 13+ messages in thread
From: David Yang @ 2026-09-04 17:22 UTC (permalink / raw)
  To: Kyle Switch
  Cc: andrew, olteanv, davem, edumazet, kuba, pabeni, horms, linux,
	netdev, linux-kernel, ming.xu, xiaolin.xu, jianmin.wang,
	wei.zhang, sijia.huang

On Fri, Sep 4, 2026 at 5:54 PM Kyle Switch <kyle.switch@motor-comm.com> wrote:
> +       tag[0] = htons(ETH_P_YT921X);
> +       if (dp->index != 0) {
> +               /* Port index is not equal 0 in tag[1] */
> +               ctrl = YT922X_TAG_PRIO(skb->priority) | YT922X_TAG_FORCE_DST |
> +                       YT922X_TAG_PORTS(dsa_xmit_port_mask(skb, netdev));
> +               tag[1] = htons(ctrl);
> +               tag[2] = 0;
> +       } else {
> +               /* Port 0 in bit15 in tag[2] */
> +               ctrl = YT922X_TAG_PRIO(skb->priority) | YT922X_TAG_FORCE_DST;
> +               tag[1] = htons(ctrl);
> +               ctrl = YT922X_TAG_PORTMASK_0;
> +               tag[2] = htons(ctrl);
> +       }

This does not seem correct, as dsa_xmit_port_mask() may return a port
combination, including port 0 and non-0 ports.

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-09-04 17:22 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  9:54 [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Kyle Switch
2026-09-04  9:54 ` [PATCH net-next v5 2/6] net: dsa: motorcomm: use max_ports from series_info for port bounds checking Kyle Switch
2026-09-04 13:32   ` Andrew Lunn
2026-09-04  9:54 ` [PATCH net-next v5 3/6] net: dsa: motorcomm: relocate MIB polling initialization to dsa_setup() Kyle Switch
2026-09-04 13:37   ` Andrew Lunn
2026-09-04 13:48   ` Andrew Lunn
2026-09-04 17:13   ` David Yang
2026-09-04  9:54 ` [PATCH net-next v5 4/6] net: dsa: motorcomm: introduce mib_init to control MIB polling initialization Kyle Switch
2026-09-04 13:45   ` Andrew Lunn
2026-09-04  9:54 ` [PATCH net-next v5 5/6] net: dsa: tag_922x: add support for Motorcomm YT922x tags Kyle Switch
2026-09-04 17:22   ` David Yang
2026-09-04 13:14 ` [PATCH net-next v5 1/6] net: dsa: motorcomm: refactor registration path for upcoming switch families Andrew Lunn
2026-09-04 17:03 ` David Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox