AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/07/03 09:04 flow patch-triage
1m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch adds Remote Management Unit (RMU) support to the Marvell 88E6xxx DSA switch driver. The changes are entirely contained within the hardware-specific `mv88e6xxx` driver and its associated DSA tagger (`tag_dsa.c`). Since the Marvell 88E6xxx is a hardware switch that cannot be emulated in virtualized environments like QEMU/GCE, and no software DSA switch (like `dsa_loop`) uses the `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA` tag protocols, these code paths are completely unreachable during fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/07/03 09:04 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 2cb0f0e540fcad29d006e35f060c508493a8d412\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Fri Jul 3 09:04:05 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/dsa/mv88e6xxx/Makefile b/drivers/net/dsa/mv88e6xxx/Makefile\nindex b0b08c6f159c65..1f3571061a5502 100644\n--- a/drivers/net/dsa/mv88e6xxx/Makefile\n+++ b/drivers/net/dsa/mv88e6xxx/Makefile\n@@ -17,6 +17,7 @@ mv88e6xxx-objs += phy.o\n mv88e6xxx-objs += port.o\n mv88e6xxx-objs += port_hidden.o\n mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += ptp.o\n+mv88e6xxx-objs += rmu.o\n mv88e6xxx-objs += serdes.o\n mv88e6xxx-objs += smi.o\n mv88e6xxx-objs += switchdev.o\ndiff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c\nindex 80b877c74513d6..3d92c59de7b5fa 100644\n--- a/drivers/net/dsa/mv88e6xxx/chip.c\n+++ b/drivers/net/dsa/mv88e6xxx/chip.c\n@@ -41,6 +41,7 @@\n #include \"phy.h\"\n #include \"port.h\"\n #include \"ptp.h\"\n+#include \"rmu.h\"\n #include \"serdes.h\"\n #include \"smi.h\"\n #include \"tcam.h\"\n@@ -48,10 +49,14 @@\n \n static void assert_reg_lock(struct mv88e6xxx_chip *chip)\n {\n+#ifdef CONFIG_LOCKDEP\n+\tlockdep_assert_held(\u0026chip-\u003ereg_lock);\n+#else\n \tif (unlikely(!mutex_is_locked(\u0026chip-\u003ereg_lock))) {\n \t\tdev_err(chip-\u003edev, \"Switch registers lock not held!\\n\");\n \t\tdump_stack();\n \t}\n+#endif\n }\n \n int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)\n@@ -60,7 +65,9 @@ int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)\n \n \tassert_reg_lock(chip);\n \n-\terr = mv88e6xxx_smi_read(chip, addr, reg, val);\n+\terr = mv88e6xxx_rmu_read(chip, addr, reg, val);\n+\tif (mv88e6xxx_rmu_can_mdio_fallback(chip, err))\n+\t\terr = mv88e6xxx_smi_read(chip, addr, reg, val);\n \tif (err)\n \t\treturn err;\n \n@@ -76,7 +83,9 @@ int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)\n \n \tassert_reg_lock(chip);\n \n-\terr = mv88e6xxx_smi_write(chip, addr, reg, val);\n+\terr = mv88e6xxx_rmu_write(chip, addr, reg, val);\n+\tif (mv88e6xxx_rmu_can_mdio_fallback(chip, err))\n+\t\terr = mv88e6xxx_smi_write(chip, addr, reg, val);\n \tif (err)\n \t\treturn err;\n \n@@ -126,8 +135,14 @@ int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,\n int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,\n \t\t       int bit, int val)\n {\n-\treturn mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),\n-\t\t\t\t   val ? BIT(bit) : 0x0000);\n+\tint err;\n+\n+\terr = mv88e6xxx_rmu_wait_bit(chip, addr, reg, bit, val);\n+\n+\tif (mv88e6xxx_rmu_can_mdio_fallback(chip, err))\n+\t\terr = mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),\n+\t\t\t\t\t  val ? BIT(bit) : 0x0000);\n+\treturn err;\n }\n \n struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)\n@@ -1322,9 +1337,9 @@ static size_t mv88e6390_stats_get_stat(struct mv88e6xxx_chip *chip, int port,\n \treturn 1;\n }\n \n-static size_t mv88e6xxx_stats_get_stat(struct mv88e6xxx_chip *chip, int port,\n-\t\t\t\t       const struct mv88e6xxx_hw_stat *stat,\n-\t\t\t\t       uint64_t *data)\n+size_t mv88e6xxx_stats_get_stat(struct mv88e6xxx_chip *chip, int port,\n+\t\t\t\tconst struct mv88e6xxx_hw_stat *stat,\n+\t\t\t\tuint64_t *data)\n {\n \tint ret = 0;\n \n@@ -1345,6 +1360,15 @@ static size_t mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,\n {\n \tconst struct mv88e6xxx_hw_stat *stat;\n \tsize_t i, j;\n+\tint err;\n+\n+\terr = mv88e6xxx_rmu_stats(chip, port, data, mv88e6xxx_hw_stats,\n+\t\t\t\t  ARRAY_SIZE(mv88e6xxx_hw_stats));\n+\tif (err \u003e 0)\n+\t\treturn err;\n+\n+\tif (!mv88e6xxx_rmu_can_mdio_fallback(chip, err))\n+\t\treturn err;\n \n \tfor (i = 0, j = 0; i \u003c ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {\n \t\tstat = \u0026mv88e6xxx_hw_stats[i];\n@@ -1671,14 +1695,6 @@ static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)\n \treturn 0;\n }\n \n-static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)\n-{\n-\tif (chip-\u003einfo-\u003eops-\u003ermu_disable)\n-\t\treturn chip-\u003einfo-\u003eops-\u003ermu_disable(chip);\n-\n-\treturn 0;\n-}\n-\n static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)\n {\n \tif (chip-\u003einfo-\u003eops-\u003epot_clear)\n@@ -4075,10 +4091,6 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)\n \tif (err)\n \t\tgoto unlock;\n \n-\terr = mv88e6xxx_rmu_setup(chip);\n-\tif (err)\n-\t\tgoto unlock;\n-\n \terr = mv88e6xxx_rsvd2cpu_setup(chip);\n \tif (err)\n \t\tgoto unlock;\n@@ -4261,6 +4273,7 @@ static const struct mv88e6xxx_ops mv88e6085_ops = {\n \t.ppu_disable = mv88e6185_g1_ppu_disable,\n \t.reset = mv88e6185_g1_reset,\n \t.rmu_disable = mv88e6085_g1_rmu_disable,\n+\t.rmu_enable = mv88e6085_g1_rmu_enable,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n \t.vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,\n \t.stu_getnext = mv88e6352_g1_stu_getnext,\n@@ -4339,6 +4352,7 @@ static const struct mv88e6xxx_ops mv88e6097_ops = {\n \t.pot_clear = mv88e6xxx_g2_pot_clear,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6085_g1_rmu_disable,\n+\t.rmu_enable = mv88e6085_g1_rmu_enable,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n \t.vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,\n \t.phylink_get_caps = mv88e6095_phylink_get_caps,\n@@ -4473,6 +4487,7 @@ static const struct mv88e6xxx_ops mv88e6141_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n@@ -4666,6 +4681,7 @@ static const struct mv88e6xxx_ops mv88e6172_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_reset,\n \t.rmu_disable = mv88e6352_g1_rmu_disable,\n+\t.rmu_enable = mv88e6352_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n@@ -4770,6 +4786,7 @@ static const struct mv88e6xxx_ops mv88e6176_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_reset,\n \t.rmu_disable = mv88e6352_g1_rmu_disable,\n+\t.rmu_enable = mv88e6352_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n@@ -4865,6 +4882,7 @@ static const struct mv88e6xxx_ops mv88e6190_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6390_g1_vtu_getnext,\n@@ -4924,6 +4942,7 @@ static const struct mv88e6xxx_ops mv88e6190x_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6390_g1_vtu_getnext,\n@@ -4981,6 +5000,7 @@ static const struct mv88e6xxx_ops mv88e6191_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6390_g1_vtu_getnext,\n@@ -5043,6 +5063,7 @@ static const struct mv88e6xxx_ops mv88e6240_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_reset,\n \t.rmu_disable = mv88e6352_g1_rmu_disable,\n+\t.rmu_enable = mv88e6352_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n@@ -5146,6 +5167,7 @@ static const struct mv88e6xxx_ops mv88e6290_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6390_g1_vtu_getnext,\n@@ -5326,6 +5348,7 @@ static const struct mv88e6xxx_ops mv88e6341_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n@@ -5484,6 +5507,7 @@ static const struct mv88e6xxx_ops mv88e6352_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_reset,\n \t.rmu_disable = mv88e6352_g1_rmu_disable,\n+\t.rmu_enable = mv88e6352_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6352_g1_vtu_getnext,\n@@ -5547,6 +5571,7 @@ static const struct mv88e6xxx_ops mv88e6390_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6390_g1_vtu_getnext,\n@@ -5611,6 +5636,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6390_g1_vtu_getnext,\n@@ -5678,6 +5704,7 @@ static const struct mv88e6xxx_ops mv88e6393x_ops = {\n \t.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,\n \t.reset = mv88e6352_g1_reset,\n \t.rmu_disable = mv88e6390_g1_rmu_disable,\n+\t.rmu_enable = mv88e6390_g1_rmu_enable,\n \t.atu_get_hash = mv88e6165_g1_atu_get_hash,\n \t.atu_set_hash = mv88e6165_g1_atu_set_hash,\n \t.vtu_getnext = mv88e6390_g1_vtu_getnext,\n@@ -7175,6 +7202,23 @@ static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,\n \treturn err_sync ? : err_pvt;\n }\n \n+static int mv88e6xxx_connect_tag_protocol(struct dsa_switch *ds,\n+\t\t\t\t\t  enum dsa_tag_protocol proto)\n+{\n+\tstruct dsa_tagger_data *tagger_data = ds-\u003etagger_data;\n+\n+\tswitch (proto) {\n+\tcase DSA_TAG_PROTO_DSA:\n+\tcase DSA_TAG_PROTO_EDSA:\n+\t\ttagger_data-\u003ermu_frame2reg = mv88e6xxx_rmu_frame2reg_handler;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EPROTONOSUPPORT;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static const struct phylink_mac_ops mv88e6xxx_phylink_mac_ops = {\n \t.mac_select_pcs\t\t= mv88e6xxx_mac_select_pcs,\n \t.mac_prepare\t\t= mv88e6xxx_mac_prepare,\n@@ -7246,6 +7290,8 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {\n \t.crosschip_lag_change\t= mv88e6xxx_crosschip_lag_change,\n \t.crosschip_lag_join\t= mv88e6xxx_crosschip_lag_join,\n \t.crosschip_lag_leave\t= mv88e6xxx_crosschip_lag_leave,\n+\t.conduit_state_change\t= mv88e6xxx_rmu_conduit_state_change,\n+\t.connect_tag_protocol\t= mv88e6xxx_connect_tag_protocol,\n };\n \n static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)\n@@ -7435,6 +7481,8 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)\n \tif (err)\n \t\tgoto out_g1_atu_prob_irq;\n \n+\tdsa_inband_init(\u0026chip-\u003ermu_inband, U8_MAX);\n+\n \terr = mv88e6xxx_register_switch(chip);\n \tif (err)\n \t\tgoto out_g1_vtu_prob_irq;\n@@ -7495,6 +7543,12 @@ static void mv88e6xxx_shutdown(struct mdio_device *mdiodev)\n \tif (!ds)\n \t\treturn;\n \n+\t/* DSA core does not call -\u003eteardown on .shutdown, so stop PTP\n+\t * polling here before the conduit goes away. Otherwise the work\n+\t * can race teardown and dereference a stale conduit-\u003edev_addr.\n+\t */\n+\tmv88e6xxx_ptp_shutdown(ds-\u003epriv);\n+\n \tdsa_switch_shutdown(ds);\n \n \tdev_set_drvdata(\u0026mdiodev-\u003edev, NULL);\ndiff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h\nindex e966e7c4cc5dea..7bbb649330d55a 100644\n--- a/drivers/net/dsa/mv88e6xxx/chip.h\n+++ b/drivers/net/dsa/mv88e6xxx/chip.h\n@@ -205,6 +205,16 @@ struct mv88e6xxx_stu_entry {\n \tu8\tstate[DSA_MAX_PORTS];\n };\n \n+struct mv88e6xxx_devlink_atu_entry {\n+\t/* The FID is scattered over multiple registers. */\n+\tu16 fid;\n+\tu16 atu_op;\n+\tu16 atu_data;\n+\tu16 atu_01;\n+\tu16 atu_23;\n+\tu16 atu_45;\n+};\n+\n struct mv88e6xxx_bus_ops;\n struct mv88e6xxx_irq_ops;\n struct mv88e6xxx_gpio_ops;\n@@ -346,6 +356,17 @@ struct mv88e6xxx_tcam {\n \tstruct list_head entries;\n };\n \n+enum mv88e6xxx_rmu_state {\n+\tMV88E6XXX_RMU_DISABLED = 0,\n+\tMV88E6XXX_RMU_ENABLED = 1,\n+\t/* Reserved: a future RMU-only mode (e.g. MV88E6XXX_RMU_ONLY_ENABLED)\n+\t * may be added here to indicate a switch operating purely via RMU\n+\t * without an MDIO bus.\n+\t */\n+};\n+\n+#define MV88E6XXX_RMU_IS_SLOW\tBIT(0)\n+\n struct mv88e6xxx_chip {\n \tconst struct mv88e6xxx_info *info;\n \n@@ -457,6 +478,15 @@ struct mv88e6xxx_chip {\n \n \t/* Global2 scratch register config data3 */\n \tu8 g2_scratch_config3;\n+\n+\t/* Remote Management Unit state. */\n+\tstruct net_device *rmu_conduit;\n+\tstruct dsa_inband rmu_inband;\n+\tenum mv88e6xxx_rmu_state rmu_state;\n+\tu8 rmu_flags;\n+\tktime_t rmu_read_latencies[16];\n+\tu32 rmu_samples;\n+\tktime_t smi_read_latency;\n };\n \n #define TCAM_MATCH_SIZE 96\n@@ -701,6 +731,7 @@ struct mv88e6xxx_ops {\n \n \t/* Remote Management Unit operations */\n \tint (*rmu_disable)(struct mv88e6xxx_chip *chip);\n+\tint (*rmu_enable)(struct mv88e6xxx_chip *chip, int port);\n \n \t/* Precision Time Protocol operations */\n \tconst struct mv88e6xxx_ptp_ops *ptp_ops;\n@@ -890,4 +921,8 @@ int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip,\n \t\t\t\t void *priv),\n \t\t       void *priv);\n \n+size_t mv88e6xxx_stats_get_stat(struct mv88e6xxx_chip *chip, int port,\n+\t\t\t\tconst struct mv88e6xxx_hw_stat *stat,\n+\t\t\t\tuint64_t *data);\n+\n #endif /* _MV88E6XXX_CHIP_H */\ndiff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c\nindex 6f034841883c6f..5c2a59d1145b8b 100644\n--- a/drivers/net/dsa/mv88e6xxx/devlink.c\n+++ b/drivers/net/dsa/mv88e6xxx/devlink.c\n@@ -6,6 +6,7 @@\n #include \"global1.h\"\n #include \"global2.h\"\n #include \"port.h\"\n+#include \"rmu.h\"\n \n static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)\n {\n@@ -307,16 +308,6 @@ static int mv88e6xxx_region_global_snapshot(struct devlink *dl,\n  * mv88e6xxx generations\n  */\n \n-struct mv88e6xxx_devlink_atu_entry {\n-\t/* The FID is scattered over multiple registers. */\n-\tu16 fid;\n-\tu16 atu_op;\n-\tu16 atu_data;\n-\tu16 atu_01;\n-\tu16 atu_23;\n-\tu16 atu_45;\n-};\n-\n static int mv88e6xxx_region_atu_snapshot_fid(struct mv88e6xxx_chip *chip,\n \t\t\t\t\t     int fid,\n \t\t\t\t\t     struct mv88e6xxx_devlink_atu_entry *table,\n@@ -369,6 +360,33 @@ static int mv88e6xxx_region_atu_snapshot_fid(struct mv88e6xxx_chip *chip,\n \treturn 0;\n }\n \n+static int mv88e6xxx_region_atu_snapshot_rmu(struct mv88e6xxx_chip *chip,\n+\t\t\t\t\t     struct mv88e6xxx_devlink_atu_entry *table,\n+\t\t\t\t\t     int *count)\n+{\n+\tunsigned int num_macs = mv88e6xxx_num_macs(chip);\n+\tu16 cont_code = 0;\n+\tint err;\n+\n+\tdo {\n+\t\tif (*count + MV88E6XXX_RMU_MAX_ATU_ENTRIES \u003e num_macs) {\n+\t\t\terr = -ERANGE;\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\terr = mv88e6xxx_rmu_dump_atu(chip, \u0026table[*count], \u0026cont_code);\n+\t\tif (err \u003c 0)\n+\t\t\tbreak;\n+\n+\t\t*count += err;\n+\t} while (cont_code != 0);\n+\n+\tif (err \u003c 0)\n+\t\t*count = 0;\n+\n+\treturn err;\n+}\n+\n static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,\n \t\t\t\t\t const struct devlink_region_ops *ops,\n \t\t\t\t\t struct netlink_ext_ack *extack,\n@@ -380,24 +398,35 @@ static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,\n \tint fid = -1, err = 0, count = 0;\n \n \ttable = kzalloc_objs(struct mv88e6xxx_devlink_atu_entry,\n-\t\t\t     mv88e6xxx_num_databases(chip));\n+\t\t\t     mv88e6xxx_num_macs(chip));\n \tif (!table)\n \t\treturn -ENOMEM;\n \n \tmv88e6xxx_reg_lock(chip);\n \n-\twhile (1) {\n-\t\tfid = find_next_bit(chip-\u003efid_bitmap, MV88E6XXX_N_FID, fid + 1);\n-\t\tif (fid == MV88E6XXX_N_FID)\n-\t\t\tbreak;\n+\terr = mv88e6xxx_region_atu_snapshot_rmu(chip, table, \u0026count);\n+\tif (err \u003e= 0) {\n+\t\t/* RMU succeeded, use its results */\n+\t\terr = 0;\n+\t} else if (!mv88e6xxx_rmu_can_mdio_fallback(chip, err)) {\n+\t\tkfree(table);\n+\t\tgoto out;\n+\t} else {\n+\t\twhile (1) {\n+\t\t\tfid = find_next_bit(chip-\u003efid_bitmap, MV88E6XXX_N_FID,\n+\t\t\t\t\t    fid + 1);\n+\t\t\tif (fid == MV88E6XXX_N_FID)\n+\t\t\t\tbreak;\n \n-\t\terr =  mv88e6xxx_region_atu_snapshot_fid(chip, fid, table,\n-\t\t\t\t\t\t\t \u0026count);\n-\t\tif (err) {\n-\t\t\tkfree(table);\n-\t\t\tgoto out;\n+\t\t\terr =  mv88e6xxx_region_atu_snapshot_fid(chip, fid,\n+\t\t\t\t\t\t\t\t table, \u0026count);\n+\t\t\tif (err) {\n+\t\t\t\tkfree(table);\n+\t\t\t\tgoto out;\n+\t\t\t}\n \t\t}\n \t}\n+\n \t*data = (u8 *)table;\n out:\n \tmv88e6xxx_reg_unlock(chip);\n@@ -776,7 +805,7 @@ int mv88e6xxx_setup_devlink_regions_global(struct dsa_switch *ds)\n \n \t\tswitch (i) {\n \t\tcase MV88E6XXX_REGION_ATU:\n-\t\t\tsize = mv88e6xxx_num_databases(chip) *\n+\t\t\tsize = mv88e6xxx_num_macs(chip) *\n \t\t\t\tsizeof(struct mv88e6xxx_devlink_atu_entry);\n \t\t\tbreak;\n \t\tcase MV88E6XXX_REGION_VTU:\ndiff --git a/drivers/net/dsa/mv88e6xxx/global1.c b/drivers/net/dsa/mv88e6xxx/global1.c\nindex 9820cd59675743..ae0b6e56281840 100644\n--- a/drivers/net/dsa/mv88e6xxx/global1.c\n+++ b/drivers/net/dsa/mv88e6xxx/global1.c\n@@ -536,18 +536,82 @@ int mv88e6085_g1_rmu_disable(struct mv88e6xxx_chip *chip)\n \t\t\t\t      MV88E6085_G1_CTL2_RM_ENABLE, 0);\n }\n \n+int mv88e6085_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port)\n+{\n+\tint val = MV88E6352_G1_CTL2_RMU_MODE_DISABLED;\n+\n+\tswitch (port) {\n+\tcase 9:\n+\t\tval = MV88E6085_G1_CTL2_RM_ENABLE;\n+\t\tbreak;\n+\tcase 10:\n+\t\tval = MV88E6085_G1_CTL2_RM_ENABLE | MV88E6085_G1_CTL2_P10RM;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\treturn mv88e6xxx_g1_ctl2_mask(chip, MV88E6085_G1_CTL2_P10RM |\n+\t\t\t\t      MV88E6085_G1_CTL2_RM_ENABLE, val);\n+}\n+\n int mv88e6352_g1_rmu_disable(struct mv88e6xxx_chip *chip)\n {\n \treturn mv88e6xxx_g1_ctl2_mask(chip, MV88E6352_G1_CTL2_RMU_MODE_MASK,\n \t\t\t\t      MV88E6352_G1_CTL2_RMU_MODE_DISABLED);\n }\n \n+int mv88e6352_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port)\n+{\n+\tint val = MV88E6352_G1_CTL2_RMU_MODE_DISABLED;\n+\n+\tswitch (port) {\n+\tcase 4:\n+\t\tval = MV88E6352_G1_CTL2_RMU_MODE_PORT_4;\n+\t\tbreak;\n+\tcase 5:\n+\t\tval = MV88E6352_G1_CTL2_RMU_MODE_PORT_5;\n+\t\tbreak;\n+\tcase 6:\n+\t\tval = MV88E6352_G1_CTL2_RMU_MODE_PORT_6;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\treturn mv88e6xxx_g1_ctl2_mask(chip, MV88E6352_G1_CTL2_RMU_MODE_MASK, val);\n+}\n+\n int mv88e6390_g1_rmu_disable(struct mv88e6xxx_chip *chip)\n {\n \treturn mv88e6xxx_g1_ctl2_mask(chip, MV88E6390_G1_CTL2_RMU_MODE_MASK,\n \t\t\t\t      MV88E6390_G1_CTL2_RMU_MODE_DISABLED);\n }\n \n+int mv88e6390_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port)\n+{\n+\tint val = MV88E6390_G1_CTL2_RMU_MODE_DISABLED;\n+\n+\tswitch (port) {\n+\tcase 0:\n+\t\tval = MV88E6390_G1_CTL2_RMU_MODE_PORT_0;\n+\t\tbreak;\n+\tcase 1:\n+\t\tval = MV88E6390_G1_CTL2_RMU_MODE_PORT_1;\n+\t\tbreak;\n+\tcase 9:\n+\t\tval = MV88E6390_G1_CTL2_RMU_MODE_PORT_9;\n+\t\tbreak;\n+\tcase 10:\n+\t\tval = MV88E6390_G1_CTL2_RMU_MODE_PORT_10;\n+\t\tbreak;\n+\tdefault:\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\treturn mv88e6xxx_g1_ctl2_mask(chip, MV88E6390_G1_CTL2_RMU_MODE_MASK, val);\n+}\n+\n int mv88e6390_g1_stats_set_histogram(struct mv88e6xxx_chip *chip)\n {\n \treturn mv88e6xxx_g1_ctl2_mask(chip, MV88E6390_G1_CTL2_HIST_MODE_MASK,\ndiff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h\nindex 3dbb7a1b8fe118..4624d1bdfc2430 100644\n--- a/drivers/net/dsa/mv88e6xxx/global1.h\n+++ b/drivers/net/dsa/mv88e6xxx/global1.h\n@@ -316,8 +316,11 @@ int mv88e6250_g1_ieee_pri_map(struct mv88e6xxx_chip *chip);\n int mv88e6185_g1_set_cascade_port(struct mv88e6xxx_chip *chip, int port);\n \n int mv88e6085_g1_rmu_disable(struct mv88e6xxx_chip *chip);\n+int mv88e6085_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port);\n int mv88e6352_g1_rmu_disable(struct mv88e6xxx_chip *chip);\n+int mv88e6352_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port);\n int mv88e6390_g1_rmu_disable(struct mv88e6xxx_chip *chip);\n+int mv88e6390_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port);\n \n int mv88e6xxx_g1_set_device_number(struct mv88e6xxx_chip *chip, int index);\n \ndiff --git a/drivers/net/dsa/mv88e6xxx/global2.c b/drivers/net/dsa/mv88e6xxx/global2.c\nindex 30a6ffa7817b08..834fdb3503f1c3 100644\n--- a/drivers/net/dsa/mv88e6xxx/global2.c\n+++ b/drivers/net/dsa/mv88e6xxx/global2.c\n@@ -855,6 +855,7 @@ static void mv88e6097_watchdog_free(struct mv88e6xxx_chip *chip)\n static int mv88e6097_watchdog_setup(struct mv88e6xxx_chip *chip)\n {\n \treturn mv88e6xxx_g2_write(chip, MV88E6352_G2_WDOG_CTL,\n+\t\t\t\t  MV88E6352_G2_WDOG_CTL_RMU_TIMEOUT |\n \t\t\t\t  MV88E6352_G2_WDOG_CTL_EGRESS_ENABLE |\n \t\t\t\t  MV88E6352_G2_WDOG_CTL_QC_ENABLE |\n \t\t\t\t  MV88E6352_G2_WDOG_CTL_SWRESET);\ndiff --git a/drivers/net/dsa/mv88e6xxx/ptp.c b/drivers/net/dsa/mv88e6xxx/ptp.c\nindex f7603573d3a984..f6ce3232d10ff5 100644\n--- a/drivers/net/dsa/mv88e6xxx/ptp.c\n+++ b/drivers/net/dsa/mv88e6xxx/ptp.c\n@@ -551,14 +551,24 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)\n \treturn 0;\n }\n \n-/* This must never be called holding the register lock */\n-void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)\n+/* Cancel any pending PTP polling work. Safe to call from .shutdown\n+ * paths where the PTP clock itself stays registered.\n+ * This must never be called holding the register lock.\n+ */\n+void mv88e6xxx_ptp_shutdown(struct mv88e6xxx_chip *chip)\n {\n \tif (chip-\u003eptp_clock) {\n \t\tcancel_delayed_work_sync(\u0026chip-\u003eoverflow_work);\n \t\tif (chip-\u003einfo-\u003eops-\u003eptp_ops-\u003eevent_work)\n \t\t\tcancel_delayed_work_sync(\u0026chip-\u003etai_event_work);\n+\t}\n+}\n \n+/* This must never be called holding the register lock */\n+void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)\n+{\n+\tif (chip-\u003eptp_clock) {\n+\t\tmv88e6xxx_ptp_shutdown(chip);\n \t\tptp_clock_unregister(chip-\u003eptp_clock);\n \t\tchip-\u003eptp_clock = NULL;\n \t}\ndiff --git a/drivers/net/dsa/mv88e6xxx/ptp.h b/drivers/net/dsa/mv88e6xxx/ptp.h\nindex 95bdddb0bf39f8..90031b05d25140 100644\n--- a/drivers/net/dsa/mv88e6xxx/ptp.h\n+++ b/drivers/net/dsa/mv88e6xxx/ptp.h\n@@ -68,6 +68,7 @@\n \n int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip);\n void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip);\n+void mv88e6xxx_ptp_shutdown(struct mv88e6xxx_chip *chip);\n \n #define ptp_to_chip(ptp) container_of(ptp, struct mv88e6xxx_chip,\t\\\n \t\t\t\t      ptp_clock_info)\n@@ -87,6 +88,10 @@ static inline void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)\n {\n }\n \n+static inline void mv88e6xxx_ptp_shutdown(struct mv88e6xxx_chip *chip)\n+{\n+}\n+\n static const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {};\n static const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {};\n static const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = {};\ndiff --git a/drivers/net/dsa/mv88e6xxx/rmu.c b/drivers/net/dsa/mv88e6xxx/rmu.c\nnew file mode 100644\nindex 00000000000000..36422039030cd0\n--- /dev/null\n+++ b/drivers/net/dsa/mv88e6xxx/rmu.c\n@@ -0,0 +1,611 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+/*\n+ * Marvell 88E6xxx Switch Remote Management Unit Support\n+ *\n+ * Copyright (c) 2022 Mattias Forsblad \u003cmattias.forsblad@gmail.com\u003e\n+ *\n+ */\n+\n+#include \u003clinux/dsa/mv88e6xxx.h\u003e\n+#include \u003cnet/dsa.h\u003e\n+#include \"chip.h\"\n+#include \"global1.h\"\n+#include \"port.h\"\n+#include \"rmu.h\"\n+\n+static const u8 mv88e6xxx_rmu_dest_addr[ETH_ALEN] = {\n+\t0x01, 0x50, 0x43, 0x00, 0x00, 0x00\n+};\n+\n+static void mv88e6xxx_rmu_create_l2(struct dsa_switch *ds,\n+\t\t\t\t    struct net_device *conduit,\n+\t\t\t\t    struct sk_buff *skb,\n+\t\t\t\t    bool edsa)\n+{\n+\tstruct dsa_tagger_data *tagger_data = ds-\u003etagger_data;\n+\tstruct ethhdr *eth;\n+\tu8 *header;\n+\n+\t/* Create RMU L2 header. */\n+\theader = skb_push(skb, 2);\n+\t/* Two bytes of EtherType, which is ignored by the switch */\n+\theader[0] = 0;\n+\theader[1] = 0;\n+\n+\t/* Ask tagger to add {E}DSA header */\n+\ttagger_data-\u003ermu_reg2frame(ds, skb);\n+\n+\t/* Insert RMU MAC destination address */\n+\teth = skb_push(skb, ETH_ALEN * 2);\n+\tmemcpy(eth-\u003eh_dest, mv88e6xxx_rmu_dest_addr, ETH_ALEN);\n+\tether_addr_copy(eth-\u003eh_source, conduit-\u003edev_addr);\n+\tskb_reset_network_header(skb);\n+}\n+\n+static void mv88e6xxx_rmu_fill_seqno(struct sk_buff *skb, u32 seqno, int offset)\n+{\n+\tu8 *dsa_header = skb-\u003edata + offset;\n+\n+\tdsa_header[3] = seqno;\n+}\n+\n+/* 2 MAC address, 2 byte Ethertype, 2 bytes padding, to DSA header */\n+static void mv88e6xxx_rmu_fill_seqno_edsa(struct sk_buff *skb, u32 seqno)\n+{\n+\tmv88e6xxx_rmu_fill_seqno(skb, seqno, ETH_ALEN * 2 + 2 + 2);\n+}\n+\n+/* 2 MAC address, to DSA header */\n+static void mv88e6xxx_rmu_fill_seqno_dsa(struct sk_buff *skb, u32 seqno)\n+{\n+\tmv88e6xxx_rmu_fill_seqno(skb, seqno, ETH_ALEN * 2);\n+}\n+\n+static int mv88e6xxx_rmu_request(struct mv88e6xxx_chip *chip,\n+\t\t\t\t const void *req, int req_len,\n+\t\t\t\t void *resp, unsigned int resp_len,\n+\t\t\t\t int timeout_ms)\n+{\n+\tstruct net_device *conduit;\n+\tstruct sk_buff *skb;\n+\tunsigned char *data;\n+\tbool edsa;\n+\n+\t/* Capture conduit once: it can be cleared concurrently when the\n+\t * conduit goes down (e.g. during reboot). Also guard against the\n+\t * conduit being torn down out from under us, in which case its\n+\t * dev_addr may already have been released.\n+\t */\n+\tconduit = READ_ONCE(chip-\u003ermu_conduit);\n+\tif (unlikely(!conduit || !conduit-\u003edev_addr)) {\n+\t\tdev_err_ratelimited(chip-\u003edev, \"RMU: conduit device unavailable\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tskb = dev_alloc_skb(req_len + EDSA_HLEN + 2 * ETH_ALEN + 2);\n+\tif (!skb)\n+\t\treturn -ENOMEM;\n+\n+\t/* Insert RMU request message */\n+\tdata = skb_put(skb, req_len);\n+\tmemcpy(data, req, req_len);\n+\n+\tedsa = chip-\u003etag_protocol == DSA_TAG_PROTO_EDSA;\n+\n+\tif (!chip-\u003eds-\u003etagger_data) {\n+\t\tkfree_skb(skb);\n+\t\treturn -EOPNOTSUPP; /* can happen on teardown */\n+\t}\n+\n+\tmv88e6xxx_rmu_create_l2(chip-\u003eds, conduit, skb, edsa);\n+\tskb-\u003edev = conduit;\n+\n+\treturn dsa_inband_request(\u0026chip-\u003ermu_inband, skb,\n+\t\t\t\t  (edsa ? mv88e6xxx_rmu_fill_seqno_edsa :\n+\t\t\t\t   mv88e6xxx_rmu_fill_seqno_dsa),\n+\t\t\t\t  resp, resp_len, timeout_ms);\n+}\n+\n+int mv88e6xxx_rmu_dump_atu(struct mv88e6xxx_chip *chip,\n+\t\t\t   struct mv88e6xxx_devlink_atu_entry *entries,\n+\t\t\t   u16 *cont_code)\n+{\n+\t__be16 req[] = {\n+\t\tMV88E6XXX_RMU_REQ_FORMAT_SOHO,\n+\t\tMV88E6XXX_RMU_REQ_PAD,\n+\t\tMV88E6XXX_RMU_REQ_CODE_ATU,\n+\t\thtons(*cont_code),\n+\t};\n+\tstruct mv88e6xxx_rmu_atu_resp resp;\n+\tint resp_len, count;\n+\tint ret, i;\n+\n+\tif (chip-\u003ermu_state == MV88E6XXX_RMU_DISABLED)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tresp_len = sizeof(resp);\n+\tret = mv88e6xxx_rmu_request(chip, req, sizeof(req),\n+\t\t\t\t    \u0026resp, resp_len,\n+\t\t\t\t    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);\n+\tif (ret \u003c 0) {\n+\t\tdev_dbg(chip-\u003edev, \"RMU: error for command DUMP_ATU %pe\\n\",\n+\t\t\tERR_PTR(ret));\n+\t\treturn ret;\n+\t}\n+\n+\t/* minimum packet length */\n+\tresp_len = sizeof(struct mv88e6xxx_rmu_header) + sizeof(__be16); /* cont_code */\n+\n+\tif (ret \u003c resp_len || (ret - resp_len) % sizeof(struct mv88e6xxx_rmu_atu_entry)) {\n+\t\tdev_err(chip-\u003edev, \"RMU: DUMP_ATU returned wrong length: rx %d expecting %zd\\n\",\n+\t\t\tret, sizeof(resp));\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tcount = (ret - resp_len) / sizeof(struct mv88e6xxx_rmu_atu_entry);\n+\n+\tif (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_ATU) {\n+\t\tdev_err(chip-\u003edev, \"RMU: DUMP_ATU returned wrong code %d\\n\",\n+\t\t\tbe16_to_cpu(resp.rmu_header.code));\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tfor (i = 0; i \u003c count; i++) {\n+\t\tconst struct mv88e6xxx_rmu_atu_entry *src = \u0026resp.entries[i];\n+\t\tstruct mv88e6xxx_devlink_atu_entry *dst = \u0026entries[i];\n+\t\tu16 tmp;\n+\n+\t\ttmp = ntohs(src-\u003estate_trunk_dpv);\n+\t\tif (!MV88E6XXX_RMU_ATU_ENTRY_STATE_GET(tmp)) {\n+\t\t\t*cont_code = 0;\n+\t\t\treturn i;\n+\t\t}\n+\n+\t\tdst-\u003eatu_data = MV88E6XXX_RMU_ATU_ENTRY_STATE_GET(tmp) \u0026 0xf;\n+\t\tif (tmp \u0026 MV88E6XXX_RMU_ATU_TRUNK)\n+\t\t\tdst-\u003eatu_data |= MV88E6XXX_G1_ATU_DATA_TRUNK;\n+\t\tdst-\u003eatu_data |= (MV88E6XXX_RMU_ATU_DPV_GET(tmp) \u0026\n+\t\t\t\t  mv88e6xxx_port_mask(chip)) \u003c\u003c 4;\n+\n+\t\ttmp = ntohs(src-\u003epri_fid);\n+\t\tdst-\u003efid = MV88E6XXX_RMU_ATU_FID_GET(tmp);\n+\t\tdst-\u003eatu_op = MV88E6XXX_G1_ATU_OP_GET_NEXT_DB;\n+\n+\t\tdst-\u003eatu_01 = ntohs(src-\u003eatu_01);\n+\t\tdst-\u003eatu_23 = ntohs(src-\u003eatu_23);\n+\t\tdst-\u003eatu_45 = ntohs(src-\u003eatu_45);\n+\t}\n+\n+\tif (i == MV88E6XXX_RMU_MAX_ATU_ENTRIES)\n+\t\t*cont_code = ntohs(resp.cont_code);\n+\telse\n+\t\t*cont_code = 0;\n+\n+\treturn i;\n+}\n+\n+int mv88e6xxx_rmu_stats(struct mv88e6xxx_chip *chip, int port,\n+\t\t\tu64 *data,\n+\t\t\tconst struct mv88e6xxx_hw_stat *hw_stats,\n+\t\t\tint num_hw_stats)\n+{\n+\t__be16 req[] = {\n+\t\tMV88E6XXX_RMU_REQ_FORMAT_SOHO,\n+\t\tMV88E6XXX_RMU_REQ_PAD,\n+\t\tMV88E6XXX_RMU_REQ_CODE_MIB,\n+\t\thtons(port),\n+\t};\n+\tconst struct mv88e6xxx_hw_stat *stat;\n+\tstruct mv88e6xxx_rmu_mib_resp resp;\n+\tint i, j, ret;\n+\tint resp_len;\n+\tu64 high;\n+\n+\tif (chip-\u003ermu_state == MV88E6XXX_RMU_DISABLED)\n+\t\treturn -EOPNOTSUPP;\n+\n+\tresp_len = sizeof(resp) - sizeof(resp.data);\n+\tif (chip-\u003einfo-\u003estats_type \u0026 STATS_TYPE_BANK0)\n+\t\tresp_len += MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN;\n+\tif (chip-\u003einfo-\u003estats_type \u0026 STATS_TYPE_PORT)\n+\t\tresp_len += MV88E6XXX_RMU_STATS_TYPE_PORT_LEN;\n+\telse if (chip-\u003einfo-\u003estats_type \u0026 STATS_TYPE_BANK1)\n+\t\tresp_len += MV88E6XXX_RMU_STATS_TYPE_DATA1_LEN;\n+\n+\tret = mv88e6xxx_rmu_request(chip, req, sizeof(req),\n+\t\t\t\t    \u0026resp, resp_len,\n+\t\t\t\t    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);\n+\tif (ret \u003c 0) {\n+\t\tdev_dbg(chip-\u003edev, \"RMU: error for command MIB %pe\\n\",\n+\t\t\tERR_PTR(ret));\n+\t\treturn ret;\n+\t}\n+\n+\tif (ret \u003c resp_len) {\n+\t\tdev_err(chip-\u003edev, \"RMU: MIB returned wrong length: rx %d expecting %d\\n\",\n+\t\t\tret, resp_len);\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tif (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_MIB) {\n+\t\tdev_err(chip-\u003edev, \"RMU: MIB returned wrong code %d\\n\",\n+\t\t\tbe16_to_cpu(resp.rmu_header.code));\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tfor (i = 0, j = 0; i \u003c num_hw_stats; i++) {\n+\t\tstat = \u0026hw_stats[i];\n+\n+\t\tif ((stat-\u003etype \u0026 chip-\u003einfo-\u003estats_type) == 0) {\n+\t\t\t/* Not available via RMU, use SMI (if available) */\n+\t\t\tj += mv88e6xxx_stats_get_stat(chip, port, stat, \u0026data[j]);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (stat-\u003etype \u0026 STATS_TYPE_PORT) {\n+\t\t\t__be16 *port = (__be16 *)resp.data;\n+\n+\t\t\tif (chip-\u003einfo-\u003estats_type \u0026 STATS_TYPE_BANK0)\n+\t\t\t\tport += MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN / 2;\n+\n+\t\t\tswitch (stat-\u003ereg) {\n+\t\t\tcase MV88E6XXX_PORT_IN_DISCARD_LO:\n+\t\t\t\tdata[j] = be16_to_cpu(port[0]) \u003c\u003c 16;\n+\t\t\t\tdata[j] |= be16_to_cpu(port[1]);\n+\t\t\t\tbreak;\n+\t\t\tcase MV88E6XXX_PORT_IN_FILTERED:\n+\t\t\t\tdata[j] = be16_to_cpu(port[3]);\n+\t\t\t\tbreak;\n+\t\t\tcase MV88E6XXX_PORT_OUT_FILTERED:\n+\t\t\t\tdata[j] = be16_to_cpu(port[5]);\n+\t\t\t\tbreak;\n+\t\t\tdefault:\n+\t\t\t\treturn -EINVAL;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (stat-\u003etype \u0026 (STATS_TYPE_BANK0 | STATS_TYPE_BANK1)) {\n+\t\t\tint reg = stat-\u003ereg;\n+\n+\t\t\tif (stat-\u003etype \u0026 STATS_TYPE_BANK1 \u0026\u0026\n+\t\t\t    (chip-\u003einfo-\u003estats_type \u0026 STATS_TYPE_BANK0))\n+\t\t\t\treg += MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN / 4;\n+\n+\t\t\tdata[j] = be32_to_cpu(resp.data[reg]);\n+\t\t\tif (stat-\u003esize == 8) {\n+\t\t\t\thigh = be32_to_cpu(resp.data[reg + 1]);\n+\t\t\t\tdata[j] |= (high \u003c\u003c 32);\n+\t\t\t}\n+\t\t}\n+\n+\t\tj++;\n+\t}\n+\n+\treturn j;\n+}\n+\n+int mv88e6xxx_rmu_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)\n+{\n+\t__be16 req[] = {\n+\t\tMV88E6XXX_RMU_REQ_FORMAT_SOHO,\n+\t\tMV88E6XXX_RMU_REQ_PAD,\n+\t\tMV88E6XXX_RMU_REQ_CODE_REG_RW,\n+\t\tMV88E6XXX_RMU_REQ_RW_0_WRITE(addr, reg),\n+\t\thtons(val),\n+\t\tMV88E6XXX_RMU_REQ_RW_0_END,\n+\t\tMV88E6XXX_RMU_REQ_RW_1_END,\n+\t};\n+\tstruct mv88e6xxx_rmu_header resp;\n+\tint resp_len;\n+\tint ret = -1;\n+\n+\tif (chip-\u003ermu_state == MV88E6XXX_RMU_DISABLED ||\n+\t    (chip-\u003ermu_flags \u0026 MV88E6XXX_RMU_IS_SLOW))\n+\t\treturn -EOPNOTSUPP;\n+\n+\tresp_len = sizeof(resp);\n+\tret = mv88e6xxx_rmu_request(chip, req, sizeof(req),\n+\t\t\t\t    \u0026resp, resp_len,\n+\t\t\t\t    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);\n+\tif (ret \u003c 0) {\n+\t\tdev_dbg(chip-\u003edev, \"RMU: error for command REQ_RW:WRITE %pe addr %d reg %d val %04x\\n\",\n+\t\t\tERR_PTR(ret), addr, reg, val);\n+\t\treturn ret;\n+\t}\n+\n+\tif (ret \u003c resp_len) {\n+\t\tdev_err(chip-\u003edev, \"RMU: write returned wrong length: rx %d expecting %d\\n\",\n+\t\t\tret, resp_len);\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tif (resp.code != MV88E6XXX_RMU_RESP_CODE_REG_RW) {\n+\t\tdev_err(chip-\u003edev, \"RMU: write returned wrong code %d\\n\",\n+\t\t\tbe16_to_cpu(resp.code));\n+\t\treturn -EPROTO;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void mv88e6xxx_rmu_read_latency(struct mv88e6xxx_chip *chip,\n+\t\t\t\t       ktime_t latency)\n+{\n+\tktime_t average = 0;\n+\tint i;\n+\n+\tif (chip-\u003ermu_samples \u003e= ARRAY_SIZE(chip-\u003ermu_read_latencies))\n+\t\treturn;\n+\n+\tchip-\u003ermu_read_latencies[chip-\u003ermu_samples++] = latency;\n+\n+\tif (chip-\u003ermu_samples == ARRAY_SIZE(chip-\u003ermu_read_latencies)) {\n+\t\tfor (i = 0; i \u003c ARRAY_SIZE(chip-\u003ermu_read_latencies); i++)\n+\t\t\taverage += chip-\u003ermu_read_latencies[i];\n+\t\taverage = average / ARRAY_SIZE(chip-\u003ermu_read_latencies);\n+\n+\t\tdev_dbg(chip-\u003edev, \"RMU %lldus, smi %lldus\\n\",\n+\t\t\tdiv_u64(average, 1000),\n+\t\t\tdiv_u64(chip-\u003esmi_read_latency, 1000));\n+\n+\t\tif (chip-\u003esmi_read_latency \u003c average)\n+\t\t\tchip-\u003ermu_flags |= MV88E6XXX_RMU_IS_SLOW;\n+\n+\t\tchip-\u003ermu_samples = U32_MAX;\n+\t}\n+}\n+\n+int mv88e6xxx_rmu_read(struct mv88e6xxx_chip *chip, int addr, int reg,\n+\t\t       u16 *val)\n+{\n+\t__be16 req[] = {\n+\t\tMV88E6XXX_RMU_REQ_FORMAT_SOHO,\n+\t\tMV88E6XXX_RMU_REQ_PAD,\n+\t\tMV88E6XXX_RMU_REQ_CODE_REG_RW,\n+\t\tMV88E6XXX_RMU_REQ_RW_0_READ(addr, reg),\n+\t\t0,\n+\t\tMV88E6XXX_RMU_REQ_RW_0_END,\n+\t\tMV88E6XXX_RMU_REQ_RW_1_END,\n+\t};\n+\tstruct mv88e6xxx_rmu_rw_resp resp;\n+\tint resp_len;\n+\tktime_t start;\n+\tint ret;\n+\n+\tif (chip-\u003ermu_state == MV88E6XXX_RMU_DISABLED ||\n+\t    (chip-\u003ermu_flags \u0026 MV88E6XXX_RMU_IS_SLOW))\n+\t\treturn -EOPNOTSUPP;\n+\n+\tstart = ktime_get();\n+\n+\tresp_len = sizeof(resp);\n+\tret = mv88e6xxx_rmu_request(chip, req, sizeof(req),\n+\t\t\t\t    \u0026resp, resp_len,\n+\t\t\t\t    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);\n+\tif (ret \u003c 0) {\n+\t\tdev_dbg(chip-\u003edev, \"RMU: error for command REQ_RW:READ %pe addr %d reg %d\\n\",\n+\t\t\tERR_PTR(ret), addr, reg);\n+\t\treturn ret;\n+\t}\n+\n+\tif (ret \u003c resp_len) {\n+\t\tdev_err(chip-\u003edev, \"RMU: read returned wrong length: rx %d expecting %d\\n\",\n+\t\t\tret, resp_len);\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tif (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_REG_RW) {\n+\t\tdev_err(chip-\u003edev, \"RMU: read returned wrong code %d\\n\",\n+\t\t\tbe16_to_cpu(resp.rmu_header.code));\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tmv88e6xxx_rmu_read_latency(chip, ktime_get() - start);\n+\n+\t*val = ntohs(resp.value);\n+\n+\treturn 0;\n+}\n+\n+int mv88e6xxx_rmu_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,\n+\t\t\t   int bit, int val)\n+{\n+\t__be16 req[] = {\n+\t\tMV88E6XXX_RMU_REQ_FORMAT_SOHO,\n+\t\tMV88E6XXX_RMU_REQ_PAD,\n+\t\tMV88E6XXX_RMU_REQ_CODE_REG_RW,\n+\t\tval ? MV88E6XXX_RMU_REQ_RW_0_WAIT_1(addr, reg) :\n+\t\tMV88E6XXX_RMU_REQ_RW_0_WAIT_0(addr, reg),\n+\t\thtons((bit \u0026 0xf) \u003c\u003c 8),\n+\t\tMV88E6XXX_RMU_REQ_RW_0_END,\n+\t\tMV88E6XXX_RMU_REQ_RW_1_END,\n+\t};\n+\tstruct mv88e6xxx_rmu_rw_resp resp;\n+\tint resp_len;\n+\tint ret = -1;\n+\n+\tif (chip-\u003ermu_state == MV88E6XXX_RMU_DISABLED ||\n+\t    (chip-\u003ermu_flags \u0026 MV88E6XXX_RMU_IS_SLOW))\n+\t\treturn -EOPNOTSUPP;\n+\n+\tresp_len = sizeof(resp);\n+\tret = mv88e6xxx_rmu_request(chip, req, sizeof(req),\n+\t\t\t\t    \u0026resp, resp_len,\n+\t\t\t\t    MV88E6XXX_RMU_WAIT_BIT_TIMEOUT_MS);\n+\tif (ret \u003c 0) {\n+\t\tdev_dbg(chip-\u003edev, \"RMU: error for command REQ_RW:WAIT %pe\\n\",\n+\t\t\tERR_PTR(ret));\n+\t\treturn ret;\n+\t}\n+\n+\tif (ret \u003c resp_len) {\n+\t\tdev_err(chip-\u003edev, \"RMU: wait on bit returned wrong length: rx %d expecting %d\\n\",\n+\t\t\tret, resp_len);\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tif (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_REG_RW) {\n+\t\tdev_err(chip-\u003edev, \"RMU: wait on bit returned wrong code %d\\n\",\n+\t\t\tbe16_to_cpu(resp.rmu_header.code));\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tif ((ntohs(resp.value) \u0026 0xff) == 0xff) {\n+\t\tdev_err(chip-\u003edev, \"RMU: wait on bit timed out\\n\");\n+\t\treturn -ETIMEDOUT;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int mv88e6xxx_rmu_get_id(struct mv88e6xxx_chip *chip)\n+{\n+\tconst __be16 req[4] = {\n+\t\tMV88E6XXX_RMU_REQ_FORMAT_GET_ID,\n+\t\tMV88E6XXX_RMU_REQ_PAD,\n+\t\tMV88E6XXX_RMU_REQ_CODE_GET_ID,\n+\t\tMV88E6XXX_RMU_REQ_DATA};\n+\tstruct mv88e6xxx_rmu_header resp;\n+\tint resp_len;\n+\tint ret = -1;\n+\n+\tresp_len = sizeof(resp);\n+\tret = mv88e6xxx_rmu_request(chip, req, sizeof(req),\n+\t\t\t\t    \u0026resp, resp_len,\n+\t\t\t\t    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);\n+\tif (ret \u003c 0) {\n+\t\tdev_dbg(chip-\u003edev, \"RMU: error for command GET_ID %pe\\n\",\n+\t\t\tERR_PTR(ret));\n+\t\treturn ret;\n+\t}\n+\n+\tif (ret \u003c resp_len) {\n+\t\tdev_err(chip-\u003edev, \"RMU: GET_ID returned wrong length: rx %d expecting %d\\n\",\n+\t\t\tret, resp_len);\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tif (resp.code != MV88E6XXX_RMU_RESP_CODE_GOT_ID) {\n+\t\tdev_dbg(chip-\u003edev, \"RMU: GET_ID returned wrong code %d\\n\",\n+\t\t\tbe16_to_cpu(resp.code));\n+\t\treturn -EPROTO;\n+\t}\n+\n+\tdev_dbg(chip-\u003edev, \"RMU: product ID %4x\\n\", be16_to_cpu(resp.prodnr));\n+\n+\treturn 0;\n+}\n+\n+void mv88e6xxx_rmu_conduit_state_change(struct dsa_switch *ds,\n+\t\t\t\t\tconst struct net_device *conduit,\n+\t\t\t\t\tbool operational)\n+{\n+\tstruct dsa_port *cpu_dp = conduit-\u003edsa_ptr;\n+\tstruct mv88e6xxx_chip *chip = ds-\u003epriv;\n+\tktime_t start;\n+\tint port;\n+\tint ret;\n+\tu16 id;\n+\n+\tport = dsa_towards_port(ds, cpu_dp-\u003eds-\u003eindex, cpu_dp-\u003eindex);\n+\n+\tmv88e6xxx_reg_lock(chip);\n+\n+\tif (operational \u0026\u0026 chip-\u003einfo-\u003eops-\u003ermu_enable) {\n+\t\tret = chip-\u003einfo-\u003eops-\u003ermu_enable(chip, port);\n+\t\tif (ret == -EOPNOTSUPP) {\n+\t\t\tdev_info(chip-\u003edev, \"RMU: not usable on this board\");\n+\t\t\tgoto out;\n+\t\t} else if (ret \u003c 0) {\n+\t\t\tdev_err(chip-\u003edev, \"RMU: unable to enable on port %d %pe\",\n+\t\t\t\tport, ERR_PTR(ret));\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tWRITE_ONCE(chip-\u003ermu_conduit, (struct net_device *)conduit);\n+\n+\t\t/* Get the device ID to prove that the RMU works */\n+\t\tret = mv88e6xxx_rmu_get_id(chip);\n+\t\tif (ret \u003c 0) {\n+\t\t\tdev_err(chip-\u003edev, \"RMU: initialization check failed %pe\",\n+\t\t\t\tERR_PTR(ret));\n+\t\t\tgoto out_disable;\n+\t\t}\n+\n+\t\tstart = ktime_get();\n+\t\tret = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID,\n+\t\t\t\t\t  \u0026id);\n+\t\tif (ret \u003c 0) {\n+\t\t\tdev_err(chip-\u003edev, \"RMU: SMI latency read failed %pe\",\n+\t\t\t\tERR_PTR(ret));\n+\t\t\tgoto out_disable;\n+\t\t}\n+\t\tchip-\u003esmi_read_latency = ktime_get() - start;\n+\t\tchip-\u003ermu_state = MV88E6XXX_RMU_ENABLED;\n+\n+\t\tdev_info(chip-\u003edev, \"RMU: enabled on port %d via conduit device %s\",\n+\t\t\t port, chip-\u003ermu_conduit-\u003ename);\n+\t} else {\n+out_disable:\n+\t\tif (chip-\u003einfo-\u003eops-\u003ermu_disable)\n+\t\t\tchip-\u003einfo-\u003eops-\u003ermu_disable(chip);\n+\n+\t\tchip-\u003ermu_state = MV88E6XXX_RMU_DISABLED;\n+\t\tWRITE_ONCE(chip-\u003ermu_conduit, NULL);\n+\t}\n+\n+out:\n+\tmv88e6xxx_reg_unlock(chip);\n+}\n+\n+void mv88e6xxx_rmu_frame2reg_handler(struct dsa_switch *ds,\n+\t\t\t\t     struct sk_buff *skb,\n+\t\t\t\t     u8 seqno)\n+{\n+\tstruct mv88e6xxx_rmu_header *rmu_header;\n+\tstruct mv88e6xxx_chip *chip = ds-\u003epriv;\n+\tstruct net_device *conduit;\n+\tunsigned char *ethhdr;\n+\tu8 expected_seqno;\n+\tint resp_len;\n+\tint err = 0;\n+\n+\t/* Check received destination MAC is the conduit MAC address */\n+\tconduit = READ_ONCE(chip-\u003ermu_conduit);\n+\tif (!conduit)\n+\t\tgoto drop;\n+\n+\tethhdr = skb_mac_header(skb);\n+\tif (!ether_addr_equal(conduit-\u003edev_addr, ethhdr)) {\n+\t\tdev_dbg_ratelimited(ds-\u003edev, \"RMU: mismatched MAC address for request: rx %pM expecting %pM\\n\",\n+\t\t\t\t    ethhdr, conduit-\u003edev_addr);\n+\t\tgoto drop;\n+\t}\n+\n+\texpected_seqno = dsa_inband_seqno(\u0026chip-\u003ermu_inband);\n+\tif (seqno != expected_seqno) {\n+\t\tdev_dbg_ratelimited(ds-\u003edev, \"RMU: mismatched seqno for request: rx %d expecting %d\\n\",\n+\t\t\t\t    seqno, expected_seqno);\n+\t\tgoto drop;\n+\t}\n+\n+\tif (skb-\u003elen \u003c 4 + sizeof(*rmu_header)) {\n+\t\tdev_dbg_ratelimited(ds-\u003edev, \"RMU: response too short (%d bytes)\\n\",\n+\t\t\t\t    skb-\u003elen);\n+\t\tdsa_inband_complete(\u0026chip-\u003ermu_inband, NULL, 0, -ETIMEDOUT);\n+\t\tgoto drop;\n+\t}\n+\n+\trmu_header = (struct mv88e6xxx_rmu_header *)(skb-\u003edata + 4);\n+\tresp_len = skb-\u003elen - 4;\n+\tif (rmu_header-\u003eformat != MV88E6XXX_RMU_RESP_FORMAT_1 \u0026\u0026\n+\t    rmu_header-\u003eformat != MV88E6XXX_RMU_RESP_FORMAT_2) {\n+\t\tdev_dbg_ratelimited(ds-\u003edev, \"RMU: invalid format: rx %d\\n\",\n+\t\t\t\t    be16_to_cpu(rmu_header-\u003eformat));\n+\t\terr = -EPROTO;\n+\t}\n+\n+\tdsa_inband_complete(\u0026chip-\u003ermu_inband, rmu_header, resp_len, err);\n+drop:\n+\treturn;\n+}\ndiff --git a/drivers/net/dsa/mv88e6xxx/rmu.h b/drivers/net/dsa/mv88e6xxx/rmu.h\nnew file mode 100644\nindex 00000000000000..3a288ff3b113ff\n--- /dev/null\n+++ b/drivers/net/dsa/mv88e6xxx/rmu.h\n@@ -0,0 +1,145 @@\n+/* SPDX-License-Identifier: GPL-2.0+ */\n+/*\n+ * Marvell 88E6xxx Switch Remote Management Unit Support\n+ *\n+ * Copyright (c) 2022 Mattias Forsblad \u003cmattias.forsblad@gmail.com\u003e\n+ *\n+ */\n+\n+#ifndef _MV88E6XXX_RMU_H_\n+#define _MV88E6XXX_RMU_H_\n+\n+#define MV88E6XXX_RMU_WAIT_TIME_MS\t\t20\n+#define MV88E6XXX_RMU_REQUEST_TIMEOUT_MS\t50\n+#define MV88E6XXX_RMU_WAIT_BIT_TIMEOUT_MS\t1000\n+\n+#define MV88E6XXX_RMU_REQ_FORMAT_GET_ID\t\thtons(0x0000)\n+#define MV88E6XXX_RMU_REQ_FORMAT_SOHO\t\thtons(0x0001)\n+#define MV88E6XXX_RMU_REQ_PAD\t\t\thtons(0x0000)\n+#define MV88E6XXX_RMU_REQ_CODE_GET_ID\t\thtons(0x0000)\n+#define MV88E6XXX_RMU_REQ_CODE_ATU\t\thtons(0x1000)\n+#define MV88E6XXX_RMU_REQ_CODE_MIB\t\thtons(0x1020)\n+#define MV88E6XXX_RMU_REQ_CODE_REG_RW\t\thtons(0x2000)\n+#define MV88E6XXX_RMU_REQ_DATA\t\t\thtons(0x0000)\n+\n+#define MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_1\t(0x7 \u003c\u003c 10)\n+#define MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_0\t(0x4 \u003c\u003c 10)\n+#define MV88E6XXX_RMU_REQ_RW_0_OP_READ\t\t(0x2 \u003c\u003c 10)\n+#define MV88E6XXX_RMU_REQ_RW_0_OP_WRITE\t\t(0x1 \u003c\u003c 10)\n+\n+#define MV88E6XXX_RMU_REQ_RW_0_READ(_addr_, _reg_)\t\t \\\n+\thtons(MV88E6XXX_RMU_REQ_RW_0_OP_READ |\t\t\t \\\n+\t      ((_addr_) \u003c\u003c 5) |\t\t\t\t\t \\\n+\t      (_reg_))\n+#define MV88E6XXX_RMU_REQ_RW_0_WRITE(_addr_, _reg_)\t\t \\\n+\thtons(MV88E6XXX_RMU_REQ_RW_0_OP_WRITE |\t\t\t \\\n+\t      ((_addr_) \u003c\u003c 5) |\t\t\t\t\t \\\n+\t      (_reg_))\n+\n+#define MV88E6XXX_RMU_REQ_RW_0_WAIT_0(_addr_, _reg_)\t\t   \\\n+\thtons(MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_0 |\t\t   \\\n+\t      ((_addr_) \u003c\u003c 5) |\t\t\t\t\t   \\\n+\t      (_reg_))\n+#define MV88E6XXX_RMU_REQ_RW_0_WAIT_1(_addr_, _reg_)\t\t   \\\n+\thtons(MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_1 |\t\t   \\\n+\t      ((_addr_) \u003c\u003c 5) |\t\t\t\t\t   \\\n+\t      (_reg_))\n+\n+#define MV88E6XXX_RMU_REQ_RW_0_END\t\thtons(0xffff)\n+#define MV88E6XXX_RMU_REQ_RW_1_END\t\thtons(0xffff)\n+\n+#define MV88E6XXX_RMU_RESP_FORMAT_1\t\thtons(0x0001)\n+#define MV88E6XXX_RMU_RESP_FORMAT_2\t\thtons(0x0002)\n+#define MV88E6XXX_RMU_RESP_CODE_GOT_ID\t\thtons(0x0000)\n+#define MV88E6XXX_RMU_RESP_CODE_ATU\t\thtons(0x1000)\n+#define MV88E6XXX_RMU_RESP_CODE_MIB\t\thtons(0x1020)\n+#define MV88E6XXX_RMU_RESP_CODE_REG_RW\t\thtons(0x2000)\n+\n+struct mv88e6xxx_rmu_header {\n+\t__be16 format;\n+\t__be16 prodnr;\n+\t__be16 code;\n+} __packed;\n+\n+struct mv88e6xxx_rmu_rw_resp {\n+\tstruct mv88e6xxx_rmu_header rmu_header;\n+\t__be16 cmd;\n+\t__be16 value;\n+\t__be16 end0;\n+\t__be16 end1;\n+} __packed;\n+\n+struct mv88e6xxx_rmu_atu_entry {\n+\t__be16 state_trunk_dpv;\n+\t__be16 atu_01;\n+\t__be16 atu_23;\n+\t__be16 atu_45;\n+\t__be16 pri_fid;\n+} __packed;\n+\n+#define MV88E6XXX_RMU_MAX_ATU_ENTRIES\t\t48\n+\n+#define MV88E6XXX_RMU_ATU_ENTRY_STATE_MASK\tGENMASK(15, 12)\n+#define MV88E6XXX_RMU_ATU_ENTRY_STATE_GET(p)\tFIELD_GET(MV88E6XXX_RMU_ATU_ENTRY_STATE_MASK, p)\n+#define MV88E6XXX_RMU_ATU_TRUNK\t\t\t0x0800\n+#define MV88E6XXX_RMU_ATU_DPV_MASK\t\tGENMASK(10, 0)\n+#define MV88E6XXX_RMU_ATU_DPV_GET(p)\t\tFIELD_GET(MV88E6XXX_RMU_ATU_DPV_MASK, p)\n+\n+#define MV88E6XXX_RMU_ATU_PRI_MASK\t\tGENMASK(14, 12)\n+#define MV88E6XXX_RMU_ATU_PRI_GET(p)\t\tFIELD_GET(MV88E6XXX_RMU_ATU_PRI_MASK, p)\n+\n+#define MV88E6XXX_RMU_ATU_FID_MASK\t\tGENMASK(11, 0)\n+#define MV88E6XXX_RMU_ATU_FID_GET(p)\t\tFIELD_GET(MV88E6XXX_RMU_ATU_FID_MASK, p)\n+\n+struct mv88e6xxx_rmu_atu_resp {\n+\tstruct mv88e6xxx_rmu_header rmu_header;\n+\tstruct mv88e6xxx_rmu_atu_entry entries[MV88E6XXX_RMU_MAX_ATU_ENTRIES];\n+\t__be16 cont_code;\n+} __packed;\n+\n+/* number of RMU MIB statistics, by type, in octets */\n+#define MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN\t128\n+#define MV88E6XXX_RMU_STATS_TYPE_PORT_LEN\t12\n+#define MV88E6XXX_RMU_STATS_TYPE_DATA1_LEN\t128\n+#define MV88E6XXX_RMU_STATS_TYPE_MAX_LEN\t(MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN + \\\n+\t\t\t\t\t\t MV88E6XXX_RMU_STATS_TYPE_DATA1_LEN)\n+\n+struct mv88e6xxx_rmu_mib_resp {\n+\tstruct mv88e6xxx_rmu_header rmu_header;\n+\t__be16 swport;\n+\t__be32 timestamp;\n+\t__be32 data[MV88E6XXX_RMU_STATS_TYPE_MAX_LEN / 4];\n+} __packed;\n+\n+struct mv88e6xxx_devlink_atu_entry;\n+\n+int mv88e6xxx_rmu_dump_atu(struct mv88e6xxx_chip *chip,\n+\t\t\t   struct mv88e6xxx_devlink_atu_entry *entries,\n+\t\t\t   u16 *cont_code);\n+int mv88e6xxx_rmu_stats(struct mv88e6xxx_chip *chip, int port,\n+\t\t\tu64 *data,\n+\t\t\tconst struct mv88e6xxx_hw_stat *hw_stats,\n+\t\t\tint num_hw_stats);\n+int mv88e6xxx_rmu_write(struct mv88e6xxx_chip *chip, int addr, int reg,\n+\t\t\tu16 val);\n+int mv88e6xxx_rmu_read(struct mv88e6xxx_chip *chip, int addr, int reg,\n+\t\t       u16 *val);\n+int mv88e6xxx_rmu_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,\n+\t\t\t   int bit, int val);\n+void mv88e6xxx_rmu_conduit_state_change(struct dsa_switch *ds,\n+\t\t\t\t\tconst struct net_device *conduit,\n+\t\t\t\t\tbool operational);\n+void mv88e6xxx_rmu_frame2reg_handler(struct dsa_switch *ds,\n+\t\t\t\t     struct sk_buff *skb,\n+\t\t\t\t     u8 seqno);\n+\n+/* RMU register access falls back to MDIO when the operation is unsupported or\n+ * times out. @chip is unused today, but threading it through here lets a future\n+ * RMU-only mode suppress the fallback without touching any of the call sites.\n+ */\n+static inline bool\n+mv88e6xxx_rmu_can_mdio_fallback(struct mv88e6xxx_chip *chip, int err)\n+{\n+\treturn err == -EOPNOTSUPP || err == -ETIMEDOUT;\n+}\n+#endif /* _MV88E6XXX_RMU_H_ */\ndiff --git a/include/linux/dsa/mv88e6xxx.h b/include/linux/dsa/mv88e6xxx.h\nindex 8c3d45eca46bdb..74a885b3bc4cb2 100644\n--- a/include/linux/dsa/mv88e6xxx.h\n+++ b/include/linux/dsa/mv88e6xxx.h\n@@ -6,6 +6,17 @@\n #define _NET_DSA_TAG_MV88E6XXX_H\n \n #include \u003clinux/if_vlan.h\u003e\n+#include \u003cnet/dsa.h\u003e\n+\n+struct dsa_tagger_data {\n+\t/* DSA frame decoded to be from the RMU */\n+\tvoid (*rmu_frame2reg)(struct dsa_switch *ds,\n+\t\t\t      struct sk_buff *skb,\n+\t\t\t      u8 seqno);\n+\t/* Add DSA header to frame to be sent to switch */\n+\tvoid (*rmu_reg2frame)(struct dsa_switch *ds,\n+\t\t\t      struct sk_buff *skb);\n+};\n \n #define MV88E6XXX_VID_STANDALONE\t0\n #define MV88E6XXX_VID_BRIDGED\t\t(VLAN_N_VID - 1)\ndiff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c\nindex d5ffee35fbb53b..a23c3279c49bd5 100644\n--- a/net/dsa/tag_dsa.c\n+++ b/net/dsa/tag_dsa.c\n@@ -201,14 +201,17 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev,\n static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,\n \t\t\t\t  u8 extra)\n {\n+\tstruct dsa_tagger_data *tagger_data;\n \tbool trap = false, trunk = false;\n \tint source_device, source_port;\n+\tstruct dsa_switch *ds;\n \tenum dsa_code code;\n \tenum dsa_cmd cmd;\n \tu8 *dsa_header;\n \n \t/* The ethertype field is part of the DSA header. */\n \tdsa_header = dsa_etype_header_pos_rx(skb);\n+\tsource_device = dsa_header[0] \u0026 0x1f;\n \n \tcmd = dsa_header[0] \u003e\u003e 6;\n \tswitch (cmd) {\n@@ -220,12 +223,20 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,\n \t\tcode = (dsa_header[1] \u0026 0x6) | ((dsa_header[2] \u003e\u003e 4) \u0026 1);\n \n \t\tswitch (code) {\n-\t\tcase DSA_CODE_FRAME2REG:\n-\t\t\t/* Remote management is not implemented yet,\n-\t\t\t * drop.\n-\t\t\t */\n+\t\tcase DSA_CODE_FRAME2REG: {\n+\t\t\tu8 seqno = dsa_header[3];\n+\n+\t\t\tds = dsa_conduit_find_switch(dev, source_device);\n+\t\t\tif (!ds) {\n+\t\t\t\tkfree_skb(skb);\n+\t\t\t\treturn NULL;\n+\t\t\t}\n+\t\t\ttagger_data = ds-\u003etagger_data;\n+\t\t\tif (likely(tagger_data \u0026\u0026 tagger_data-\u003ermu_frame2reg))\n+\t\t\t\ttagger_data-\u003ermu_frame2reg(ds, skb, seqno);\n \t\t\tkfree_skb(skb);\n \t\t\treturn NULL;\n+\t\t}\n \t\tcase DSA_CODE_ARP_MIRROR:\n \t\tcase DSA_CODE_POLICY_MIRROR:\n \t\t\t/* Mark mirrored packets to notify any upper\n@@ -256,7 +267,6 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,\n \t\treturn NULL;\n \t}\n \n-\tsource_device = dsa_header[0] \u0026 0x1f;\n \tsource_port = (dsa_header[1] \u003e\u003e 3) \u0026 0x1f;\n \n \tif (trunk) {\n@@ -331,6 +341,49 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,\n \treturn skb;\n }\n \n+static void dsa_rmu_reg2frame(struct dsa_switch *ds,\n+\t\t\t      struct sk_buff *skb)\n+{\n+\tenum dsa_cmd cmd = DSA_CMD_FROM_CPU;\n+\tu8 tag_dev = ds-\u003eindex;\n+\tu8 *dsa_header;\n+\n+\tdsa_header = skb_push(skb, DSA_HLEN);\n+\tdsa_header[0] = (cmd \u003c\u003c 6) | tag_dev;\n+\tdsa_header[1] = BIT(1) | 0x3e \u003c\u003c 2;\n+\tdsa_header[2] = 6 \u003c\u003c 5 | 0xf;\n+\tdsa_header[3] = 0; /* Sequence number is filled in later */\n+\n+\tif (ds-\u003edst-\u003etag_ops-\u003eproto == DSA_TAG_PROTO_EDSA) {\n+\t\tu8 *edsa_header = skb_push(skb, 4);\n+\n+\t\tedsa_header[0] = (ETH_P_EDSA \u003e\u003e 8) \u0026 0xff;\n+\t\tedsa_header[1] = ETH_P_EDSA \u0026 0xff;\n+\t\tedsa_header[2] = 0x00;\n+\t\tedsa_header[3] = 0x00;\n+\t}\n+}\n+\n+static int dsa_tag_connect(struct dsa_switch *ds)\n+{\n+\tstruct dsa_tagger_data *tagger_data;\n+\n+\ttagger_data = kzalloc_obj(*tagger_data, GFP_KERNEL);\n+\tif (!tagger_data)\n+\t\treturn -ENOMEM;\n+\n+\ttagger_data-\u003ermu_reg2frame = dsa_rmu_reg2frame;\n+\tds-\u003etagger_data = tagger_data;\n+\n+\treturn 0;\n+}\n+\n+static void dsa_tag_disconnect(struct dsa_switch *ds)\n+{\n+\tkfree(ds-\u003etagger_data);\n+\tds-\u003etagger_data = NULL;\n+}\n+\n #if IS_ENABLED(CONFIG_NET_DSA_TAG_DSA)\n \n static struct sk_buff *dsa_xmit(struct sk_buff *skb, struct net_device *dev)\n@@ -353,6 +406,8 @@ static const struct dsa_device_ops dsa_netdev_ops = {\n \t.proto\t  = DSA_TAG_PROTO_DSA,\n \t.xmit\t  = dsa_xmit,\n \t.rcv\t  = dsa_rcv,\n+\t.connect  = dsa_tag_connect,\n+\t.disconnect = dsa_tag_disconnect,\n \t.needed_headroom = DSA_HLEN,\n };\n \n@@ -397,6 +452,8 @@ static const struct dsa_device_ops edsa_netdev_ops = {\n \t.proto\t  = DSA_TAG_PROTO_EDSA,\n \t.xmit\t  = edsa_xmit,\n \t.rcv\t  = edsa_rcv,\n+\t.connect  = dsa_tag_connect,\n+\t.disconnect = dsa_tag_disconnect,\n \t.needed_headroom = EDSA_HLEN,\n };\n \n"
}

2/1 2026/07/03 09:04 agent patch-evaluator
1m Model:
gemini-3.1-pro-preview

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch adds Remote Management Unit (RMU) support to the Marvell 88E6xxx DSA switch driver. The changes are entirely contained within the hardware-specific `mv88e6xxx` driver and its associated DSA tagger (`tag_dsa.c`). Since the Marvell 88E6xxx is a hardware switch that cannot be emulated in virtualized environments like QEMU/GCE, and no software DSA switch (like `dsa_loop`) uses the `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA` tag protocols, these code paths are completely unreachable during fuzzing.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer.
Your job is to review a provided patch series and determine
if it makes functional changes to the kernel that should be fuzzed.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively
use your code access tools to examine the actual source code and confirm any assumptions.

Return WorthFuzzing=false if the patch only contains:
- Modifications to Documentation/, Kconfig files, or code comments.
- Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints.
- Changes to numeric constants or macros that do not functionally alter execution flow.
- Code paths that are impossible to reach in virtualized environments like GCE or QEMU,
even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim).

If it modifies reachable core kernel logic, drivers, or architectures, use your code search
tools to verify the code can be executed, then return WorthFuzzing=true.

When returning WorthFuzzing=true, you MUST ALSO:
1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols.
   Avoid listing generic hot-path functions to prevent skewed test distributions.
2. Identify any specific CONFIG_ options required to properly test this new/modified feature.
   Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions.
   Do not list too generic configs (we already have them enabled). Only list those that
   specifically cover the modified code. List them in the EnableConfigs output array,
   and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
For your convenience, here is the diff of the changes:
commit 2cb0f0e540fcad29d006e35f060c508493a8d412
Author: syz-cluster <triage@syzkaller.com>
Date:   Fri Jul 3 09:04:05 2026 +0000

    syz-cluster: applied patch under review

diff --git a/drivers/net/dsa/mv88e6xxx/Makefile b/drivers/net/dsa/mv88e6xxx/Makefile
index b0b08c6f159c65..1f3571061a5502 100644
--- a/drivers/net/dsa/mv88e6xxx/Makefile
+++ b/drivers/net/dsa/mv88e6xxx/Makefile
@@ -17,6 +17,7 @@ mv88e6xxx-objs += phy.o
 mv88e6xxx-objs += port.o
 mv88e6xxx-objs += port_hidden.o
 mv88e6xxx-$(CONFIG_NET_DSA_MV88E6XXX_PTP) += ptp.o
+mv88e6xxx-objs += rmu.o
 mv88e6xxx-objs += serdes.o
 mv88e6xxx-objs += smi.o
 mv88e6xxx-objs += switchdev.o
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 80b877c74513d6..3d92c59de7b5fa 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -41,6 +41,7 @@
 #include "phy.h"
 #include "port.h"
 #include "ptp.h"
+#include "rmu.h"
 #include "serdes.h"
 #include "smi.h"
 #include "tcam.h"
@@ -48,10 +49,14 @@
 
 static void assert_reg_lock(struct mv88e6xxx_chip *chip)
 {
+#ifdef CONFIG_LOCKDEP
+	lockdep_assert_held(&chip->reg_lock);
+#else
 	if (unlikely(!mutex_is_locked(&chip->reg_lock))) {
 		dev_err(chip->dev, "Switch registers lock not held!\n");
 		dump_stack();
 	}
+#endif
 }
 
 int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
@@ -60,7 +65,9 @@ int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val)
 
 	assert_reg_lock(chip);
 
-	err = mv88e6xxx_smi_read(chip, addr, reg, val);
+	err = mv88e6xxx_rmu_read(chip, addr, reg, val);
+	if (mv88e6xxx_rmu_can_mdio_fallback(chip, err))
+		err = mv88e6xxx_smi_read(chip, addr, reg, val);
 	if (err)
 		return err;
 
@@ -76,7 +83,9 @@ int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
 
 	assert_reg_lock(chip);
 
-	err = mv88e6xxx_smi_write(chip, addr, reg, val);
+	err = mv88e6xxx_rmu_write(chip, addr, reg, val);
+	if (mv88e6xxx_rmu_can_mdio_fallback(chip, err))
+		err = mv88e6xxx_smi_write(chip, addr, reg, val);
 	if (err)
 		return err;
 
@@ -126,8 +135,14 @@ int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg,
 int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
 		       int bit, int val)
 {
-	return mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
-				   val ? BIT(bit) : 0x0000);
+	int err;
+
+	err = mv88e6xxx_rmu_wait_bit(chip, addr, reg, bit, val);
+
+	if (mv88e6xxx_rmu_can_mdio_fallback(chip, err))
+		err = mv88e6xxx_wait_mask(chip, addr, reg, BIT(bit),
+					  val ? BIT(bit) : 0x0000);
+	return err;
 }
 
 struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip)
@@ -1322,9 +1337,9 @@ static size_t mv88e6390_stats_get_stat(struct mv88e6xxx_chip *chip, int port,
 	return 1;
 }
 
-static size_t mv88e6xxx_stats_get_stat(struct mv88e6xxx_chip *chip, int port,
-				       const struct mv88e6xxx_hw_stat *stat,
-				       uint64_t *data)
+size_t mv88e6xxx_stats_get_stat(struct mv88e6xxx_chip *chip, int port,
+				const struct mv88e6xxx_hw_stat *stat,
+				uint64_t *data)
 {
 	int ret = 0;
 
@@ -1345,6 +1360,15 @@ static size_t mv88e6xxx_stats_get_stats(struct mv88e6xxx_chip *chip, int port,
 {
 	const struct mv88e6xxx_hw_stat *stat;
 	size_t i, j;
+	int err;
+
+	err = mv88e6xxx_rmu_stats(chip, port, data, mv88e6xxx_hw_stats,
+				  ARRAY_SIZE(mv88e6xxx_hw_stats));
+	if (err > 0)
+		return err;
+
+	if (!mv88e6xxx_rmu_can_mdio_fallback(chip, err))
+		return err;
 
 	for (i = 0, j = 0; i < ARRAY_SIZE(mv88e6xxx_hw_stats); i++) {
 		stat = &mv88e6xxx_hw_stats[i];
@@ -1671,14 +1695,6 @@ static int mv88e6xxx_trunk_setup(struct mv88e6xxx_chip *chip)
 	return 0;
 }
 
-static int mv88e6xxx_rmu_setup(struct mv88e6xxx_chip *chip)
-{
-	if (chip->info->ops->rmu_disable)
-		return chip->info->ops->rmu_disable(chip);
-
-	return 0;
-}
-
 static int mv88e6xxx_pot_setup(struct mv88e6xxx_chip *chip)
 {
 	if (chip->info->ops->pot_clear)
@@ -4075,10 +4091,6 @@ static int mv88e6xxx_setup(struct dsa_switch *ds)
 	if (err)
 		goto unlock;
 
-	err = mv88e6xxx_rmu_setup(chip);
-	if (err)
-		goto unlock;
-
 	err = mv88e6xxx_rsvd2cpu_setup(chip);
 	if (err)
 		goto unlock;
@@ -4261,6 +4273,7 @@ static const struct mv88e6xxx_ops mv88e6085_ops = {
 	.ppu_disable = mv88e6185_g1_ppu_disable,
 	.reset = mv88e6185_g1_reset,
 	.rmu_disable = mv88e6085_g1_rmu_disable,
+	.rmu_enable = mv88e6085_g1_rmu_enable,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
 	.vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
 	.stu_getnext = mv88e6352_g1_stu_getnext,
@@ -4339,6 +4352,7 @@ static const struct mv88e6xxx_ops mv88e6097_ops = {
 	.pot_clear = mv88e6xxx_g2_pot_clear,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6085_g1_rmu_disable,
+	.rmu_enable = mv88e6085_g1_rmu_enable,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
 	.vtu_loadpurge = mv88e6352_g1_vtu_loadpurge,
 	.phylink_get_caps = mv88e6095_phylink_get_caps,
@@ -4473,6 +4487,7 @@ static const struct mv88e6xxx_ops mv88e6141_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
@@ -4666,6 +4681,7 @@ static const struct mv88e6xxx_ops mv88e6172_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_reset,
 	.rmu_disable = mv88e6352_g1_rmu_disable,
+	.rmu_enable = mv88e6352_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
@@ -4770,6 +4786,7 @@ static const struct mv88e6xxx_ops mv88e6176_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_reset,
 	.rmu_disable = mv88e6352_g1_rmu_disable,
+	.rmu_enable = mv88e6352_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
@@ -4865,6 +4882,7 @@ static const struct mv88e6xxx_ops mv88e6190_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6390_g1_vtu_getnext,
@@ -4924,6 +4942,7 @@ static const struct mv88e6xxx_ops mv88e6190x_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6390_g1_vtu_getnext,
@@ -4981,6 +5000,7 @@ static const struct mv88e6xxx_ops mv88e6191_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6390_g1_vtu_getnext,
@@ -5043,6 +5063,7 @@ static const struct mv88e6xxx_ops mv88e6240_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_reset,
 	.rmu_disable = mv88e6352_g1_rmu_disable,
+	.rmu_enable = mv88e6352_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
@@ -5146,6 +5167,7 @@ static const struct mv88e6xxx_ops mv88e6290_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6390_g1_vtu_getnext,
@@ -5326,6 +5348,7 @@ static const struct mv88e6xxx_ops mv88e6341_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
@@ -5484,6 +5507,7 @@ static const struct mv88e6xxx_ops mv88e6352_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_reset,
 	.rmu_disable = mv88e6352_g1_rmu_disable,
+	.rmu_enable = mv88e6352_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6352_g1_vtu_getnext,
@@ -5547,6 +5571,7 @@ static const struct mv88e6xxx_ops mv88e6390_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6390_g1_vtu_getnext,
@@ -5611,6 +5636,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6390_g1_vtu_getnext,
@@ -5678,6 +5704,7 @@ static const struct mv88e6xxx_ops mv88e6393x_ops = {
 	.hardware_reset_post = mv88e6xxx_g2_eeprom_wait,
 	.reset = mv88e6352_g1_reset,
 	.rmu_disable = mv88e6390_g1_rmu_disable,
+	.rmu_enable = mv88e6390_g1_rmu_enable,
 	.atu_get_hash = mv88e6165_g1_atu_get_hash,
 	.atu_set_hash = mv88e6165_g1_atu_set_hash,
 	.vtu_getnext = mv88e6390_g1_vtu_getnext,
@@ -7175,6 +7202,23 @@ static int mv88e6xxx_crosschip_lag_leave(struct dsa_switch *ds, int sw_index,
 	return err_sync ? : err_pvt;
 }
 
+static int mv88e6xxx_connect_tag_protocol(struct dsa_switch *ds,
+					  enum dsa_tag_protocol proto)
+{
+	struct dsa_tagger_data *tagger_data = ds->tagger_data;
+
+	switch (proto) {
+	case DSA_TAG_PROTO_DSA:
+	case DSA_TAG_PROTO_EDSA:
+		tagger_data->rmu_frame2reg = mv88e6xxx_rmu_frame2reg_handler;
+		break;
+	default:
+		return -EPROTONOSUPPORT;
+	}
+
+	return 0;
+}
+
 static const struct phylink_mac_ops mv88e6xxx_phylink_mac_ops = {
 	.mac_select_pcs		= mv88e6xxx_mac_select_pcs,
 	.mac_prepare		= mv88e6xxx_mac_prepare,
@@ -7246,6 +7290,8 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
 	.crosschip_lag_change	= mv88e6xxx_crosschip_lag_change,
 	.crosschip_lag_join	= mv88e6xxx_crosschip_lag_join,
 	.crosschip_lag_leave	= mv88e6xxx_crosschip_lag_leave,
+	.conduit_state_change	= mv88e6xxx_rmu_conduit_state_change,
+	.connect_tag_protocol	= mv88e6xxx_connect_tag_protocol,
 };
 
 static int mv88e6xxx_register_switch(struct mv88e6xxx_chip *chip)
@@ -7435,6 +7481,8 @@ static int mv88e6xxx_probe(struct mdio_device *mdiodev)
 	if (err)
 		goto out_g1_atu_prob_irq;
 
+	dsa_inband_init(&chip->rmu_inband, U8_MAX);
+
 	err = mv88e6xxx_register_switch(chip);
 	if (err)
 		goto out_g1_vtu_prob_irq;
@@ -7495,6 +7543,12 @@ static void mv88e6xxx_shutdown(struct mdio_device *mdiodev)
 	if (!ds)
 		return;
 
+	/* DSA core does not call ->teardown on .shutdown, so stop PTP
+	 * polling here before the conduit goes away. Otherwise the work
+	 * can race teardown and dereference a stale conduit->dev_addr.
+	 */
+	mv88e6xxx_ptp_shutdown(ds->priv);
+
 	dsa_switch_shutdown(ds);
 
 	dev_set_drvdata(&mdiodev->dev, NULL);
diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
index e966e7c4cc5dea..7bbb649330d55a 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.h
+++ b/drivers/net/dsa/mv88e6xxx/chip.h
@@ -205,6 +205,16 @@ struct mv88e6xxx_stu_entry {
 	u8	state[DSA_MAX_PORTS];
 };
 
+struct mv88e6xxx_devlink_atu_entry {
+	/* The FID is scattered over multiple registers. */
+	u16 fid;
+	u16 atu_op;
+	u16 atu_data;
+	u16 atu_01;
+	u16 atu_23;
+	u16 atu_45;
+};
+
 struct mv88e6xxx_bus_ops;
 struct mv88e6xxx_irq_ops;
 struct mv88e6xxx_gpio_ops;
@@ -346,6 +356,17 @@ struct mv88e6xxx_tcam {
 	struct list_head entries;
 };
 
+enum mv88e6xxx_rmu_state {
+	MV88E6XXX_RMU_DISABLED = 0,
+	MV88E6XXX_RMU_ENABLED = 1,
+	/* Reserved: a future RMU-only mode (e.g. MV88E6XXX_RMU_ONLY_ENABLED)
+	 * may be added here to indicate a switch operating purely via RMU
+	 * without an MDIO bus.
+	 */
+};
+
+#define MV88E6XXX_RMU_IS_SLOW	BIT(0)
+
 struct mv88e6xxx_chip {
 	const struct mv88e6xxx_info *info;
 
@@ -457,6 +478,15 @@ struct mv88e6xxx_chip {
 
 	/* Global2 scratch register config data3 */
 	u8 g2_scratch_config3;
+
+	/* Remote Management Unit state. */
+	struct net_device *rmu_conduit;
+	struct dsa_inband rmu_inband;
+	enum mv88e6xxx_rmu_state rmu_state;
+	u8 rmu_flags;
+	ktime_t rmu_read_latencies[16];
+	u32 rmu_samples;
+	ktime_t smi_read_latency;
 };
 
 #define TCAM_MATCH_SIZE 96
@@ -701,6 +731,7 @@ struct mv88e6xxx_ops {
 
 	/* Remote Management Unit operations */
 	int (*rmu_disable)(struct mv88e6xxx_chip *chip);
+	int (*rmu_enable)(struct mv88e6xxx_chip *chip, int port);
 
 	/* Precision Time Protocol operations */
 	const struct mv88e6xxx_ptp_ops *ptp_ops;
@@ -890,4 +921,8 @@ int mv88e6xxx_vtu_walk(struct mv88e6xxx_chip *chip,
 				 void *priv),
 		       void *priv);
 
+size_t mv88e6xxx_stats_get_stat(struct mv88e6xxx_chip *chip, int port,
+				const struct mv88e6xxx_hw_stat *stat,
+				uint64_t *data);
+
 #endif /* _MV88E6XXX_CHIP_H */
diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c
index 6f034841883c6f..5c2a59d1145b8b 100644
--- a/drivers/net/dsa/mv88e6xxx/devlink.c
+++ b/drivers/net/dsa/mv88e6xxx/devlink.c
@@ -6,6 +6,7 @@
 #include "global1.h"
 #include "global2.h"
 #include "port.h"
+#include "rmu.h"
 
 static int mv88e6xxx_atu_get_hash(struct mv88e6xxx_chip *chip, u8 *hash)
 {
@@ -307,16 +308,6 @@ static int mv88e6xxx_region_global_snapshot(struct devlink *dl,
  * mv88e6xxx generations
  */
 
-struct mv88e6xxx_devlink_atu_entry {
-	/* The FID is scattered over multiple registers. */
-	u16 fid;
-	u16 atu_op;
-	u16 atu_data;
-	u16 atu_01;
-	u16 atu_23;
-	u16 atu_45;
-};
-
 static int mv88e6xxx_region_atu_snapshot_fid(struct mv88e6xxx_chip *chip,
 					     int fid,
 					     struct mv88e6xxx_devlink_atu_entry *table,
@@ -369,6 +360,33 @@ static int mv88e6xxx_region_atu_snapshot_fid(struct mv88e6xxx_chip *chip,
 	return 0;
 }
 
+static int mv88e6xxx_region_atu_snapshot_rmu(struct mv88e6xxx_chip *chip,
+					     struct mv88e6xxx_devlink_atu_entry *table,
+					     int *count)
+{
+	unsigned int num_macs = mv88e6xxx_num_macs(chip);
+	u16 cont_code = 0;
+	int err;
+
+	do {
+		if (*count + MV88E6XXX_RMU_MAX_ATU_ENTRIES > num_macs) {
+			err = -ERANGE;
+			break;
+		}
+
+		err = mv88e6xxx_rmu_dump_atu(chip, &table[*count], &cont_code);
+		if (err < 0)
+			break;
+
+		*count += err;
+	} while (cont_code != 0);
+
+	if (err < 0)
+		*count = 0;
+
+	return err;
+}
+
 static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
 					 const struct devlink_region_ops *ops,
 					 struct netlink_ext_ack *extack,
@@ -380,24 +398,35 @@ static int mv88e6xxx_region_atu_snapshot(struct devlink *dl,
 	int fid = -1, err = 0, count = 0;
 
 	table = kzalloc_objs(struct mv88e6xxx_devlink_atu_entry,
-			     mv88e6xxx_num_databases(chip));
+			     mv88e6xxx_num_macs(chip));
 	if (!table)
 		return -ENOMEM;
 
 	mv88e6xxx_reg_lock(chip);
 
-	while (1) {
-		fid = find_next_bit(chip->fid_bitmap, MV88E6XXX_N_FID, fid + 1);
-		if (fid == MV88E6XXX_N_FID)
-			break;
+	err = mv88e6xxx_region_atu_snapshot_rmu(chip, table, &count);
+	if (err >= 0) {
+		/* RMU succeeded, use its results */
+		err = 0;
+	} else if (!mv88e6xxx_rmu_can_mdio_fallback(chip, err)) {
+		kfree(table);
+		goto out;
+	} else {
+		while (1) {
+			fid = find_next_bit(chip->fid_bitmap, MV88E6XXX_N_FID,
+					    fid + 1);
+			if (fid == MV88E6XXX_N_FID)
+				break;
 
-		err =  mv88e6xxx_region_atu_snapshot_fid(chip, fid, table,
-							 &count);
-		if (err) {
-			kfree(table);
-			goto out;
+			err =  mv88e6xxx_region_atu_snapshot_fid(chip, fid,
+								 table, &count);
+			if (err) {
+				kfree(table);
+				goto out;
+			}
 		}
 	}
+
 	*data = (u8 *)table;
 out:
 	mv88e6xxx_reg_unlock(chip);
@@ -776,7 +805,7 @@ int mv88e6xxx_setup_devlink_regions_global(struct dsa_switch *ds)
 
 		switch (i) {
 		case MV88E6XXX_REGION_ATU:
-			size = mv88e6xxx_num_databases(chip) *
+			size = mv88e6xxx_num_macs(chip) *
 				sizeof(struct mv88e6xxx_devlink_atu_entry);
 			break;
 		case MV88E6XXX_REGION_VTU:
diff --git a/drivers/net/dsa/mv88e6xxx/global1.c b/drivers/net/dsa/mv88e6xxx/global1.c
index 9820cd59675743..ae0b6e56281840 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.c
+++ b/drivers/net/dsa/mv88e6xxx/global1.c
@@ -536,18 +536,82 @@ int mv88e6085_g1_rmu_disable(struct mv88e6xxx_chip *chip)
 				      MV88E6085_G1_CTL2_RM_ENABLE, 0);
 }
 
+int mv88e6085_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port)
+{
+	int val = MV88E6352_G1_CTL2_RMU_MODE_DISABLED;
+
+	switch (port) {
+	case 9:
+		val = MV88E6085_G1_CTL2_RM_ENABLE;
+		break;
+	case 10:
+		val = MV88E6085_G1_CTL2_RM_ENABLE | MV88E6085_G1_CTL2_P10RM;
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return mv88e6xxx_g1_ctl2_mask(chip, MV88E6085_G1_CTL2_P10RM |
+				      MV88E6085_G1_CTL2_RM_ENABLE, val);
+}
+
 int mv88e6352_g1_rmu_disable(struct mv88e6xxx_chip *chip)
 {
 	return mv88e6xxx_g1_ctl2_mask(chip, MV88E6352_G1_CTL2_RMU_MODE_MASK,
 				      MV88E6352_G1_CTL2_RMU_MODE_DISABLED);
 }
 
+int mv88e6352_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port)
+{
+	int val = MV88E6352_G1_CTL2_RMU_MODE_DISABLED;
+
+	switch (port) {
+	case 4:
+		val = MV88E6352_G1_CTL2_RMU_MODE_PORT_4;
+		break;
+	case 5:
+		val = MV88E6352_G1_CTL2_RMU_MODE_PORT_5;
+		break;
+	case 6:
+		val = MV88E6352_G1_CTL2_RMU_MODE_PORT_6;
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return mv88e6xxx_g1_ctl2_mask(chip, MV88E6352_G1_CTL2_RMU_MODE_MASK, val);
+}
+
 int mv88e6390_g1_rmu_disable(struct mv88e6xxx_chip *chip)
 {
 	return mv88e6xxx_g1_ctl2_mask(chip, MV88E6390_G1_CTL2_RMU_MODE_MASK,
 				      MV88E6390_G1_CTL2_RMU_MODE_DISABLED);
 }
 
+int mv88e6390_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port)
+{
+	int val = MV88E6390_G1_CTL2_RMU_MODE_DISABLED;
+
+	switch (port) {
+	case 0:
+		val = MV88E6390_G1_CTL2_RMU_MODE_PORT_0;
+		break;
+	case 1:
+		val = MV88E6390_G1_CTL2_RMU_MODE_PORT_1;
+		break;
+	case 9:
+		val = MV88E6390_G1_CTL2_RMU_MODE_PORT_9;
+		break;
+	case 10:
+		val = MV88E6390_G1_CTL2_RMU_MODE_PORT_10;
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
+
+	return mv88e6xxx_g1_ctl2_mask(chip, MV88E6390_G1_CTL2_RMU_MODE_MASK, val);
+}
+
 int mv88e6390_g1_stats_set_histogram(struct mv88e6xxx_chip *chip)
 {
 	return mv88e6xxx_g1_ctl2_mask(chip, MV88E6390_G1_CTL2_HIST_MODE_MASK,
diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
index 3dbb7a1b8fe118..4624d1bdfc2430 100644
--- a/drivers/net/dsa/mv88e6xxx/global1.h
+++ b/drivers/net/dsa/mv88e6xxx/global1.h
@@ -316,8 +316,11 @@ int mv88e6250_g1_ieee_pri_map(struct mv88e6xxx_chip *chip);
 int mv88e6185_g1_set_cascade_port(struct mv88e6xxx_chip *chip, int port);
 
 int mv88e6085_g1_rmu_disable(struct mv88e6xxx_chip *chip);
+int mv88e6085_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port);
 int mv88e6352_g1_rmu_disable(struct mv88e6xxx_chip *chip);
+int mv88e6352_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port);
 int mv88e6390_g1_rmu_disable(struct mv88e6xxx_chip *chip);
+int mv88e6390_g1_rmu_enable(struct mv88e6xxx_chip *chip, int port);
 
 int mv88e6xxx_g1_set_device_number(struct mv88e6xxx_chip *chip, int index);
 
diff --git a/drivers/net/dsa/mv88e6xxx/global2.c b/drivers/net/dsa/mv88e6xxx/global2.c
index 30a6ffa7817b08..834fdb3503f1c3 100644
--- a/drivers/net/dsa/mv88e6xxx/global2.c
+++ b/drivers/net/dsa/mv88e6xxx/global2.c
@@ -855,6 +855,7 @@ static void mv88e6097_watchdog_free(struct mv88e6xxx_chip *chip)
 static int mv88e6097_watchdog_setup(struct mv88e6xxx_chip *chip)
 {
 	return mv88e6xxx_g2_write(chip, MV88E6352_G2_WDOG_CTL,
+				  MV88E6352_G2_WDOG_CTL_RMU_TIMEOUT |
 				  MV88E6352_G2_WDOG_CTL_EGRESS_ENABLE |
 				  MV88E6352_G2_WDOG_CTL_QC_ENABLE |
 				  MV88E6352_G2_WDOG_CTL_SWRESET);
diff --git a/drivers/net/dsa/mv88e6xxx/ptp.c b/drivers/net/dsa/mv88e6xxx/ptp.c
index f7603573d3a984..f6ce3232d10ff5 100644
--- a/drivers/net/dsa/mv88e6xxx/ptp.c
+++ b/drivers/net/dsa/mv88e6xxx/ptp.c
@@ -551,14 +551,24 @@ int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip)
 	return 0;
 }
 
-/* This must never be called holding the register lock */
-void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)
+/* Cancel any pending PTP polling work. Safe to call from .shutdown
+ * paths where the PTP clock itself stays registered.
+ * This must never be called holding the register lock.
+ */
+void mv88e6xxx_ptp_shutdown(struct mv88e6xxx_chip *chip)
 {
 	if (chip->ptp_clock) {
 		cancel_delayed_work_sync(&chip->overflow_work);
 		if (chip->info->ops->ptp_ops->event_work)
 			cancel_delayed_work_sync(&chip->tai_event_work);
+	}
+}
 
+/* This must never be called holding the register lock */
+void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)
+{
+	if (chip->ptp_clock) {
+		mv88e6xxx_ptp_shutdown(chip);
 		ptp_clock_unregister(chip->ptp_clock);
 		chip->ptp_clock = NULL;
 	}
diff --git a/drivers/net/dsa/mv88e6xxx/ptp.h b/drivers/net/dsa/mv88e6xxx/ptp.h
index 95bdddb0bf39f8..90031b05d25140 100644
--- a/drivers/net/dsa/mv88e6xxx/ptp.h
+++ b/drivers/net/dsa/mv88e6xxx/ptp.h
@@ -68,6 +68,7 @@
 
 int mv88e6xxx_ptp_setup(struct mv88e6xxx_chip *chip);
 void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip);
+void mv88e6xxx_ptp_shutdown(struct mv88e6xxx_chip *chip);
 
 #define ptp_to_chip(ptp) container_of(ptp, struct mv88e6xxx_chip,	\
 				      ptp_clock_info)
@@ -87,6 +88,10 @@ static inline void mv88e6xxx_ptp_free(struct mv88e6xxx_chip *chip)
 {
 }
 
+static inline void mv88e6xxx_ptp_shutdown(struct mv88e6xxx_chip *chip)
+{
+}
+
 static const struct mv88e6xxx_ptp_ops mv88e6165_ptp_ops = {};
 static const struct mv88e6xxx_ptp_ops mv88e6352_ptp_ops = {};
 static const struct mv88e6xxx_ptp_ops mv88e6390_ptp_ops = {};
diff --git a/drivers/net/dsa/mv88e6xxx/rmu.c b/drivers/net/dsa/mv88e6xxx/rmu.c
new file mode 100644
index 00000000000000..36422039030cd0
--- /dev/null
+++ b/drivers/net/dsa/mv88e6xxx/rmu.c
@@ -0,0 +1,611 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Marvell 88E6xxx Switch Remote Management Unit Support
+ *
+ * Copyright (c) 2022 Mattias Forsblad <mattias.forsblad@gmail.com>
+ *
+ */
+
+#include <linux/dsa/mv88e6xxx.h>
+#include <net/dsa.h>
+#include "chip.h"
+#include "global1.h"
+#include "port.h"
+#include "rmu.h"
+
+static const u8 mv88e6xxx_rmu_dest_addr[ETH_ALEN] = {
+	0x01, 0x50, 0x43, 0x00, 0x00, 0x00
+};
+
+static void mv88e6xxx_rmu_create_l2(struct dsa_switch *ds,
+				    struct net_device *conduit,
+				    struct sk_buff *skb,
+				    bool edsa)
+{
+	struct dsa_tagger_data *tagger_data = ds->tagger_data;
+	struct ethhdr *eth;
+	u8 *header;
+
+	/* Create RMU L2 header. */
+	header = skb_push(skb, 2);
+	/* Two bytes of EtherType, which is ignored by the switch */
+	header[0] = 0;
+	header[1] = 0;
+
+	/* Ask tagger to add {E}DSA header */
+	tagger_data->rmu_reg2frame(ds, skb);
+
+	/* Insert RMU MAC destination address */
+	eth = skb_push(skb, ETH_ALEN * 2);
+	memcpy(eth->h_dest, mv88e6xxx_rmu_dest_addr, ETH_ALEN);
+	ether_addr_copy(eth->h_source, conduit->dev_addr);
+	skb_reset_network_header(skb);
+}
+
+static void mv88e6xxx_rmu_fill_seqno(struct sk_buff *skb, u32 seqno, int offset)
+{
+	u8 *dsa_header = skb->data + offset;
+
+	dsa_header[3] = seqno;
+}
+
+/* 2 MAC address, 2 byte Ethertype, 2 bytes padding, to DSA header */
+static void mv88e6xxx_rmu_fill_seqno_edsa(struct sk_buff *skb, u32 seqno)
+{
+	mv88e6xxx_rmu_fill_seqno(skb, seqno, ETH_ALEN * 2 + 2 + 2);
+}
+
+/* 2 MAC address, to DSA header */
+static void mv88e6xxx_rmu_fill_seqno_dsa(struct sk_buff *skb, u32 seqno)
+{
+	mv88e6xxx_rmu_fill_seqno(skb, seqno, ETH_ALEN * 2);
+}
+
+static int mv88e6xxx_rmu_request(struct mv88e6xxx_chip *chip,
+				 const void *req, int req_len,
+				 void *resp, unsigned int resp_len,
+				 int timeout_ms)
+{
+	struct net_device *conduit;
+	struct sk_buff *skb;
+	unsigned char *data;
+	bool edsa;
+
+	/* Capture conduit once: it can be cleared concurrently when the
+	 * conduit goes down (e.g. during reboot). Also guard against the
+	 * conduit being torn down out from under us, in which case its
+	 * dev_addr may already have been released.
+	 */
+	conduit = READ_ONCE(chip->rmu_conduit);
+	if (unlikely(!conduit || !conduit->dev_addr)) {
+		dev_err_ratelimited(chip->dev, "RMU: conduit device unavailable");
+		return -EINVAL;
+	}
+
+	skb = dev_alloc_skb(req_len + EDSA_HLEN + 2 * ETH_ALEN + 2);
+	if (!skb)
+		return -ENOMEM;
+
+	/* Insert RMU request message */
+	data = skb_put(skb, req_len);
+	memcpy(data, req, req_len);
+
+	edsa = chip->tag_protocol == DSA_TAG_PROTO_EDSA;
+
+	if (!chip->ds->tagger_data) {
+		kfree_skb(skb);
+		return -EOPNOTSUPP; /* can happen on teardown */
+	}
+
+	mv88e6xxx_rmu_create_l2(chip->ds, conduit, skb, edsa);
+	skb->dev = conduit;
+
+	return dsa_inband_request(&chip->rmu_inband, skb,
+				  (edsa ? mv88e6xxx_rmu_fill_seqno_edsa :
+				   mv88e6xxx_rmu_fill_seqno_dsa),
+				  resp, resp_len, timeout_ms);
+}
+
+int mv88e6xxx_rmu_dump_atu(struct mv88e6xxx_chip *chip,
+			   struct mv88e6xxx_devlink_atu_entry *entries,
+			   u16 *cont_code)
+{
+	__be16 req[] = {
+		MV88E6XXX_RMU_REQ_FORMAT_SOHO,
+		MV88E6XXX_RMU_REQ_PAD,
+		MV88E6XXX_RMU_REQ_CODE_ATU,
+		htons(*cont_code),
+	};
+	struct mv88e6xxx_rmu_atu_resp resp;
+	int resp_len, count;
+	int ret, i;
+
+	if (chip->rmu_state == MV88E6XXX_RMU_DISABLED)
+		return -EOPNOTSUPP;
+
+	resp_len = sizeof(resp);
+	ret = mv88e6xxx_rmu_request(chip, req, sizeof(req),
+				    &resp, resp_len,
+				    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);
+	if (ret < 0) {
+		dev_dbg(chip->dev, "RMU: error for command DUMP_ATU %pe\n",
+			ERR_PTR(ret));
+		return ret;
+	}
+
+	/* minimum packet length */
+	resp_len = sizeof(struct mv88e6xxx_rmu_header) + sizeof(__be16); /* cont_code */
+
+	if (ret < resp_len || (ret - resp_len) % sizeof(struct mv88e6xxx_rmu_atu_entry)) {
+		dev_err(chip->dev, "RMU: DUMP_ATU returned wrong length: rx %d expecting %zd\n",
+			ret, sizeof(resp));
+		return -EPROTO;
+	}
+
+	count = (ret - resp_len) / sizeof(struct mv88e6xxx_rmu_atu_entry);
+
+	if (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_ATU) {
+		dev_err(chip->dev, "RMU: DUMP_ATU returned wrong code %d\n",
+			be16_to_cpu(resp.rmu_header.code));
+		return -EPROTO;
+	}
+
+	for (i = 0; i < count; i++) {
+		const struct mv88e6xxx_rmu_atu_entry *src = &resp.entries[i];
+		struct mv88e6xxx_devlink_atu_entry *dst = &entries[i];
+		u16 tmp;
+
+		tmp = ntohs(src->state_trunk_dpv);
+		if (!MV88E6XXX_RMU_ATU_ENTRY_STATE_GET(tmp)) {
+			*cont_code = 0;
+			return i;
+		}
+
+		dst->atu_data = MV88E6XXX_RMU_ATU_ENTRY_STATE_GET(tmp) & 0xf;
+		if (tmp & MV88E6XXX_RMU_ATU_TRUNK)
+			dst->atu_data |= MV88E6XXX_G1_ATU_DATA_TRUNK;
+		dst->atu_data |= (MV88E6XXX_RMU_ATU_DPV_GET(tmp) &
+				  mv88e6xxx_port_mask(chip)) << 4;
+
+		tmp = ntohs(src->pri_fid);
+		dst->fid = MV88E6XXX_RMU_ATU_FID_GET(tmp);
+		dst->atu_op = MV88E6XXX_G1_ATU_OP_GET_NEXT_DB;
+
+		dst->atu_01 = ntohs(src->atu_01);
+		dst->atu_23 = ntohs(src->atu_23);
+		dst->atu_45 = ntohs(src->atu_45);
+	}
+
+	if (i == MV88E6XXX_RMU_MAX_ATU_ENTRIES)
+		*cont_code = ntohs(resp.cont_code);
+	else
+		*cont_code = 0;
+
+	return i;
+}
+
+int mv88e6xxx_rmu_stats(struct mv88e6xxx_chip *chip, int port,
+			u64 *data,
+			const struct mv88e6xxx_hw_stat *hw_stats,
+			int num_hw_stats)
+{
+	__be16 req[] = {
+		MV88E6XXX_RMU_REQ_FORMAT_SOHO,
+		MV88E6XXX_RMU_REQ_PAD,
+		MV88E6XXX_RMU_REQ_CODE_MIB,
+		htons(port),
+	};
+	const struct mv88e6xxx_hw_stat *stat;
+	struct mv88e6xxx_rmu_mib_resp resp;
+	int i, j, ret;
+	int resp_len;
+	u64 high;
+
+	if (chip->rmu_state == MV88E6XXX_RMU_DISABLED)
+		return -EOPNOTSUPP;
+
+	resp_len = sizeof(resp) - sizeof(resp.data);
+	if (chip->info->stats_type & STATS_TYPE_BANK0)
+		resp_len += MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN;
+	if (chip->info->stats_type & STATS_TYPE_PORT)
+		resp_len += MV88E6XXX_RMU_STATS_TYPE_PORT_LEN;
+	else if (chip->info->stats_type & STATS_TYPE_BANK1)
+		resp_len += MV88E6XXX_RMU_STATS_TYPE_DATA1_LEN;
+
+	ret = mv88e6xxx_rmu_request(chip, req, sizeof(req),
+				    &resp, resp_len,
+				    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);
+	if (ret < 0) {
+		dev_dbg(chip->dev, "RMU: error for command MIB %pe\n",
+			ERR_PTR(ret));
+		return ret;
+	}
+
+	if (ret < resp_len) {
+		dev_err(chip->dev, "RMU: MIB returned wrong length: rx %d expecting %d\n",
+			ret, resp_len);
+		return -EPROTO;
+	}
+
+	if (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_MIB) {
+		dev_err(chip->dev, "RMU: MIB returned wrong code %d\n",
+			be16_to_cpu(resp.rmu_header.code));
+		return -EPROTO;
+	}
+
+	for (i = 0, j = 0; i < num_hw_stats; i++) {
+		stat = &hw_stats[i];
+
+		if ((stat->type & chip->info->stats_type) == 0) {
+			/* Not available via RMU, use SMI (if available) */
+			j += mv88e6xxx_stats_get_stat(chip, port, stat, &data[j]);
+			continue;
+		}
+
+		if (stat->type & STATS_TYPE_PORT) {
+			__be16 *port = (__be16 *)resp.data;
+
+			if (chip->info->stats_type & STATS_TYPE_BANK0)
+				port += MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN / 2;
+
+			switch (stat->reg) {
+			case MV88E6XXX_PORT_IN_DISCARD_LO:
+				data[j] = be16_to_cpu(port[0]) << 16;
+				data[j] |= be16_to_cpu(port[1]);
+				break;
+			case MV88E6XXX_PORT_IN_FILTERED:
+				data[j] = be16_to_cpu(port[3]);
+				break;
+			case MV88E6XXX_PORT_OUT_FILTERED:
+				data[j] = be16_to_cpu(port[5]);
+				break;
+			default:
+				return -EINVAL;
+			}
+		}
+
+		if (stat->type & (STATS_TYPE_BANK0 | STATS_TYPE_BANK1)) {
+			int reg = stat->reg;
+
+			if (stat->type & STATS_TYPE_BANK1 &&
+			    (chip->info->stats_type & STATS_TYPE_BANK0))
+				reg += MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN / 4;
+
+			data[j] = be32_to_cpu(resp.data[reg]);
+			if (stat->size == 8) {
+				high = be32_to_cpu(resp.data[reg + 1]);
+				data[j] |= (high << 32);
+			}
+		}
+
+		j++;
+	}
+
+	return j;
+}
+
+int mv88e6xxx_rmu_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val)
+{
+	__be16 req[] = {
+		MV88E6XXX_RMU_REQ_FORMAT_SOHO,
+		MV88E6XXX_RMU_REQ_PAD,
+		MV88E6XXX_RMU_REQ_CODE_REG_RW,
+		MV88E6XXX_RMU_REQ_RW_0_WRITE(addr, reg),
+		htons(val),
+		MV88E6XXX_RMU_REQ_RW_0_END,
+		MV88E6XXX_RMU_REQ_RW_1_END,
+	};
+	struct mv88e6xxx_rmu_header resp;
+	int resp_len;
+	int ret = -1;
+
+	if (chip->rmu_state == MV88E6XXX_RMU_DISABLED ||
+	    (chip->rmu_flags & MV88E6XXX_RMU_IS_SLOW))
+		return -EOPNOTSUPP;
+
+	resp_len = sizeof(resp);
+	ret = mv88e6xxx_rmu_request(chip, req, sizeof(req),
+				    &resp, resp_len,
+				    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);
+	if (ret < 0) {
+		dev_dbg(chip->dev, "RMU: error for command REQ_RW:WRITE %pe addr %d reg %d val %04x\n",
+			ERR_PTR(ret), addr, reg, val);
+		return ret;
+	}
+
+	if (ret < resp_len) {
+		dev_err(chip->dev, "RMU: write returned wrong length: rx %d expecting %d\n",
+			ret, resp_len);
+		return -EPROTO;
+	}
+
+	if (resp.code != MV88E6XXX_RMU_RESP_CODE_REG_RW) {
+		dev_err(chip->dev, "RMU: write returned wrong code %d\n",
+			be16_to_cpu(resp.code));
+		return -EPROTO;
+	}
+
+	return 0;
+}
+
+static void mv88e6xxx_rmu_read_latency(struct mv88e6xxx_chip *chip,
+				       ktime_t latency)
+{
+	ktime_t average = 0;
+	int i;
+
+	if (chip->rmu_samples >= ARRAY_SIZE(chip->rmu_read_latencies))
+		return;
+
+	chip->rmu_read_latencies[chip->rmu_samples++] = latency;
+
+	if (chip->rmu_samples == ARRAY_SIZE(chip->rmu_read_latencies)) {
+		for (i = 0; i < ARRAY_SIZE(chip->rmu_read_latencies); i++)
+			average += chip->rmu_read_latencies[i];
+		average = average / ARRAY_SIZE(chip->rmu_read_latencies);
+
+		dev_dbg(chip->dev, "RMU %lldus, smi %lldus\n",
+			div_u64(average, 1000),
+			div_u64(chip->smi_read_latency, 1000));
+
+		if (chip->smi_read_latency < average)
+			chip->rmu_flags |= MV88E6XXX_RMU_IS_SLOW;
+
+		chip->rmu_samples = U32_MAX;
+	}
+}
+
+int mv88e6xxx_rmu_read(struct mv88e6xxx_chip *chip, int addr, int reg,
+		       u16 *val)
+{
+	__be16 req[] = {
+		MV88E6XXX_RMU_REQ_FORMAT_SOHO,
+		MV88E6XXX_RMU_REQ_PAD,
+		MV88E6XXX_RMU_REQ_CODE_REG_RW,
+		MV88E6XXX_RMU_REQ_RW_0_READ(addr, reg),
+		0,
+		MV88E6XXX_RMU_REQ_RW_0_END,
+		MV88E6XXX_RMU_REQ_RW_1_END,
+	};
+	struct mv88e6xxx_rmu_rw_resp resp;
+	int resp_len;
+	ktime_t start;
+	int ret;
+
+	if (chip->rmu_state == MV88E6XXX_RMU_DISABLED ||
+	    (chip->rmu_flags & MV88E6XXX_RMU_IS_SLOW))
+		return -EOPNOTSUPP;
+
+	start = ktime_get();
+
+	resp_len = sizeof(resp);
+	ret = mv88e6xxx_rmu_request(chip, req, sizeof(req),
+				    &resp, resp_len,
+				    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);
+	if (ret < 0) {
+		dev_dbg(chip->dev, "RMU: error for command REQ_RW:READ %pe addr %d reg %d\n",
+			ERR_PTR(ret), addr, reg);
+		return ret;
+	}
+
+	if (ret < resp_len) {
+		dev_err(chip->dev, "RMU: read returned wrong length: rx %d expecting %d\n",
+			ret, resp_len);
+		return -EPROTO;
+	}
+
+	if (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_REG_RW) {
+		dev_err(chip->dev, "RMU: read returned wrong code %d\n",
+			be16_to_cpu(resp.rmu_header.code));
+		return -EPROTO;
+	}
+
+	mv88e6xxx_rmu_read_latency(chip, ktime_get() - start);
+
+	*val = ntohs(resp.value);
+
+	return 0;
+}
+
+int mv88e6xxx_rmu_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
+			   int bit, int val)
+{
+	__be16 req[] = {
+		MV88E6XXX_RMU_REQ_FORMAT_SOHO,
+		MV88E6XXX_RMU_REQ_PAD,
+		MV88E6XXX_RMU_REQ_CODE_REG_RW,
+		val ? MV88E6XXX_RMU_REQ_RW_0_WAIT_1(addr, reg) :
+		MV88E6XXX_RMU_REQ_RW_0_WAIT_0(addr, reg),
+		htons((bit & 0xf) << 8),
+		MV88E6XXX_RMU_REQ_RW_0_END,
+		MV88E6XXX_RMU_REQ_RW_1_END,
+	};
+	struct mv88e6xxx_rmu_rw_resp resp;
+	int resp_len;
+	int ret = -1;
+
+	if (chip->rmu_state == MV88E6XXX_RMU_DISABLED ||
+	    (chip->rmu_flags & MV88E6XXX_RMU_IS_SLOW))
+		return -EOPNOTSUPP;
+
+	resp_len = sizeof(resp);
+	ret = mv88e6xxx_rmu_request(chip, req, sizeof(req),
+				    &resp, resp_len,
+				    MV88E6XXX_RMU_WAIT_BIT_TIMEOUT_MS);
+	if (ret < 0) {
+		dev_dbg(chip->dev, "RMU: error for command REQ_RW:WAIT %pe\n",
+			ERR_PTR(ret));
+		return ret;
+	}
+
+	if (ret < resp_len) {
+		dev_err(chip->dev, "RMU: wait on bit returned wrong length: rx %d expecting %d\n",
+			ret, resp_len);
+		return -EPROTO;
+	}
+
+	if (resp.rmu_header.code != MV88E6XXX_RMU_RESP_CODE_REG_RW) {
+		dev_err(chip->dev, "RMU: wait on bit returned wrong code %d\n",
+			be16_to_cpu(resp.rmu_header.code));
+		return -EPROTO;
+	}
+
+	if ((ntohs(resp.value) & 0xff) == 0xff) {
+		dev_err(chip->dev, "RMU: wait on bit timed out\n");
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}
+
+static int mv88e6xxx_rmu_get_id(struct mv88e6xxx_chip *chip)
+{
+	const __be16 req[4] = {
+		MV88E6XXX_RMU_REQ_FORMAT_GET_ID,
+		MV88E6XXX_RMU_REQ_PAD,
+		MV88E6XXX_RMU_REQ_CODE_GET_ID,
+		MV88E6XXX_RMU_REQ_DATA};
+	struct mv88e6xxx_rmu_header resp;
+	int resp_len;
+	int ret = -1;
+
+	resp_len = sizeof(resp);
+	ret = mv88e6xxx_rmu_request(chip, req, sizeof(req),
+				    &resp, resp_len,
+				    MV88E6XXX_RMU_REQUEST_TIMEOUT_MS);
+	if (ret < 0) {
+		dev_dbg(chip->dev, "RMU: error for command GET_ID %pe\n",
+			ERR_PTR(ret));
+		return ret;
+	}
+
+	if (ret < resp_len) {
+		dev_err(chip->dev, "RMU: GET_ID returned wrong length: rx %d expecting %d\n",
+			ret, resp_len);
+		return -EPROTO;
+	}
+
+	if (resp.code != MV88E6XXX_RMU_RESP_CODE_GOT_ID) {
+		dev_dbg(chip->dev, "RMU: GET_ID returned wrong code %d\n",
+			be16_to_cpu(resp.code));
+		return -EPROTO;
+	}
+
+	dev_dbg(chip->dev, "RMU: product ID %4x\n", be16_to_cpu(resp.prodnr));
+
+	return 0;
+}
+
+void mv88e6xxx_rmu_conduit_state_change(struct dsa_switch *ds,
+					const struct net_device *conduit,
+					bool operational)
+{
+	struct dsa_port *cpu_dp = conduit->dsa_ptr;
+	struct mv88e6xxx_chip *chip = ds->priv;
+	ktime_t start;
+	int port;
+	int ret;
+	u16 id;
+
+	port = dsa_towards_port(ds, cpu_dp->ds->index, cpu_dp->index);
+
+	mv88e6xxx_reg_lock(chip);
+
+	if (operational && chip->info->ops->rmu_enable) {
+		ret = chip->info->ops->rmu_enable(chip, port);
+		if (ret == -EOPNOTSUPP) {
+			dev_info(chip->dev, "RMU: not usable on this board");
+			goto out;
+		} else if (ret < 0) {
+			dev_err(chip->dev, "RMU: unable to enable on port %d %pe",
+				port, ERR_PTR(ret));
+			goto out;
+		}
+
+		WRITE_ONCE(chip->rmu_conduit, (struct net_device *)conduit);
+
+		/* Get the device ID to prove that the RMU works */
+		ret = mv88e6xxx_rmu_get_id(chip);
+		if (ret < 0) {
+			dev_err(chip->dev, "RMU: initialization check failed %pe",
+				ERR_PTR(ret));
+			goto out_disable;
+		}
+
+		start = ktime_get();
+		ret = mv88e6xxx_port_read(chip, 0, MV88E6XXX_PORT_SWITCH_ID,
+					  &id);
+		if (ret < 0) {
+			dev_err(chip->dev, "RMU: SMI latency read failed %pe",
+				ERR_PTR(ret));
+			goto out_disable;
+		}
+		chip->smi_read_latency = ktime_get() - start;
+		chip->rmu_state = MV88E6XXX_RMU_ENABLED;
+
+		dev_info(chip->dev, "RMU: enabled on port %d via conduit device %s",
+			 port, chip->rmu_conduit->name);
+	} else {
+out_disable:
+		if (chip->info->ops->rmu_disable)
+			chip->info->ops->rmu_disable(chip);
+
+		chip->rmu_state = MV88E6XXX_RMU_DISABLED;
+		WRITE_ONCE(chip->rmu_conduit, NULL);
+	}
+
+out:
+	mv88e6xxx_reg_unlock(chip);
+}
+
+void mv88e6xxx_rmu_frame2reg_handler(struct dsa_switch *ds,
+				     struct sk_buff *skb,
+				     u8 seqno)
+{
+	struct mv88e6xxx_rmu_header *rmu_header;
+	struct mv88e6xxx_chip *chip = ds->priv;
+	struct net_device *conduit;
+	unsigned char *ethhdr;
+	u8 expected_seqno;
+	int resp_len;
+	int err = 0;
+
+	/* Check received destination MAC is the conduit MAC address */
+	conduit = READ_ONCE(chip->rmu_conduit);
+	if (!conduit)
+		goto drop;
+
+	ethhdr = skb_mac_header(skb);
+	if (!ether_addr_equal(conduit->dev_addr, ethhdr)) {
+		dev_dbg_ratelimited(ds->dev, "RMU: mismatched MAC address for request: rx %pM expecting %pM\n",
+				    ethhdr, conduit->dev_addr);
+		goto drop;
+	}
+
+	expected_seqno = dsa_inband_seqno(&chip->rmu_inband);
+	if (seqno != expected_seqno) {
+		dev_dbg_ratelimited(ds->dev, "RMU: mismatched seqno for request: rx %d expecting %d\n",
+				    seqno, expected_seqno);
+		goto drop;
+	}
+
+	if (skb->len < 4 + sizeof(*rmu_header)) {
+		dev_dbg_ratelimited(ds->dev, "RMU: response too short (%d bytes)\n",
+				    skb->len);
+		dsa_inband_complete(&chip->rmu_inband, NULL, 0, -ETIMEDOUT);
+		goto drop;
+	}
+
+	rmu_header = (struct mv88e6xxx_rmu_header *)(skb->data + 4);
+	resp_len = skb->len - 4;
+	if (rmu_header->format != MV88E6XXX_RMU_RESP_FORMAT_1 &&
+	    rmu_header->format != MV88E6XXX_RMU_RESP_FORMAT_2) {
+		dev_dbg_ratelimited(ds->dev, "RMU: invalid format: rx %d\n",
+				    be16_to_cpu(rmu_header->format));
+		err = -EPROTO;
+	}
+
+	dsa_inband_complete(&chip->rmu_inband, rmu_header, resp_len, err);
+drop:
+	return;
+}
diff --git a/drivers/net/dsa/mv88e6xxx/rmu.h b/drivers/net/dsa/mv88e6xxx/rmu.h
new file mode 100644
index 00000000000000..3a288ff3b113ff
--- /dev/null
+++ b/drivers/net/dsa/mv88e6xxx/rmu.h
@@ -0,0 +1,145 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Marvell 88E6xxx Switch Remote Management Unit Support
+ *
+ * Copyright (c) 2022 Mattias Forsblad <mattias.forsblad@gmail.com>
+ *
+ */
+
+#ifndef _MV88E6XXX_RMU_H_
+#define _MV88E6XXX_RMU_H_
+
+#define MV88E6XXX_RMU_WAIT_TIME_MS		20
+#define MV88E6XXX_RMU_REQUEST_TIMEOUT_MS	50
+#define MV88E6XXX_RMU_WAIT_BIT_TIMEOUT_MS	1000
+
+#define MV88E6XXX_RMU_REQ_FORMAT_GET_ID		htons(0x0000)
+#define MV88E6XXX_RMU_REQ_FORMAT_SOHO		htons(0x0001)
+#define MV88E6XXX_RMU_REQ_PAD			htons(0x0000)
+#define MV88E6XXX_RMU_REQ_CODE_GET_ID		htons(0x0000)
+#define MV88E6XXX_RMU_REQ_CODE_ATU		htons(0x1000)
+#define MV88E6XXX_RMU_REQ_CODE_MIB		htons(0x1020)
+#define MV88E6XXX_RMU_REQ_CODE_REG_RW		htons(0x2000)
+#define MV88E6XXX_RMU_REQ_DATA			htons(0x0000)
+
+#define MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_1	(0x7 << 10)
+#define MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_0	(0x4 << 10)
+#define MV88E6XXX_RMU_REQ_RW_0_OP_READ		(0x2 << 10)
+#define MV88E6XXX_RMU_REQ_RW_0_OP_WRITE		(0x1 << 10)
+
+#define MV88E6XXX_RMU_REQ_RW_0_READ(_addr_, _reg_)		 \
+	htons(MV88E6XXX_RMU_REQ_RW_0_OP_READ |			 \
+	      ((_addr_) << 5) |					 \
+	      (_reg_))
+#define MV88E6XXX_RMU_REQ_RW_0_WRITE(_addr_, _reg_)		 \
+	htons(MV88E6XXX_RMU_REQ_RW_0_OP_WRITE |			 \
+	      ((_addr_) << 5) |					 \
+	      (_reg_))
+
+#define MV88E6XXX_RMU_REQ_RW_0_WAIT_0(_addr_, _reg_)		   \
+	htons(MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_0 |		   \
+	      ((_addr_) << 5) |					   \
+	      (_reg_))
+#define MV88E6XXX_RMU_REQ_RW_0_WAIT_1(_addr_, _reg_)		   \
+	htons(MV88E6XXX_RMU_REQ_RW_0_OP_WAIT_1 |		   \
+	      ((_addr_) << 5) |					   \
+	      (_reg_))
+
+#define MV88E6XXX_RMU_REQ_RW_0_END		htons(0xffff)
+#define MV88E6XXX_RMU_REQ_RW_1_END		htons(0xffff)
+
+#define MV88E6XXX_RMU_RESP_FORMAT_1		htons(0x0001)
+#define MV88E6XXX_RMU_RESP_FORMAT_2		htons(0x0002)
+#define MV88E6XXX_RMU_RESP_CODE_GOT_ID		htons(0x0000)
+#define MV88E6XXX_RMU_RESP_CODE_ATU		htons(0x1000)
+#define MV88E6XXX_RMU_RESP_CODE_MIB		htons(0x1020)
+#define MV88E6XXX_RMU_RESP_CODE_REG_RW		htons(0x2000)
+
+struct mv88e6xxx_rmu_header {
+	__be16 format;
+	__be16 prodnr;
+	__be16 code;
+} __packed;
+
+struct mv88e6xxx_rmu_rw_resp {
+	struct mv88e6xxx_rmu_header rmu_header;
+	__be16 cmd;
+	__be16 value;
+	__be16 end0;
+	__be16 end1;
+} __packed;
+
+struct mv88e6xxx_rmu_atu_entry {
+	__be16 state_trunk_dpv;
+	__be16 atu_01;
+	__be16 atu_23;
+	__be16 atu_45;
+	__be16 pri_fid;
+} __packed;
+
+#define MV88E6XXX_RMU_MAX_ATU_ENTRIES		48
+
+#define MV88E6XXX_RMU_ATU_ENTRY_STATE_MASK	GENMASK(15, 12)
+#define MV88E6XXX_RMU_ATU_ENTRY_STATE_GET(p)	FIELD_GET(MV88E6XXX_RMU_ATU_ENTRY_STATE_MASK, p)
+#define MV88E6XXX_RMU_ATU_TRUNK			0x0800
+#define MV88E6XXX_RMU_ATU_DPV_MASK		GENMASK(10, 0)
+#define MV88E6XXX_RMU_ATU_DPV_GET(p)		FIELD_GET(MV88E6XXX_RMU_ATU_DPV_MASK, p)
+
+#define MV88E6XXX_RMU_ATU_PRI_MASK		GENMASK(14, 12)
+#define MV88E6XXX_RMU_ATU_PRI_GET(p)		FIELD_GET(MV88E6XXX_RMU_ATU_PRI_MASK, p)
+
+#define MV88E6XXX_RMU_ATU_FID_MASK		GENMASK(11, 0)
+#define MV88E6XXX_RMU_ATU_FID_GET(p)		FIELD_GET(MV88E6XXX_RMU_ATU_FID_MASK, p)
+
+struct mv88e6xxx_rmu_atu_resp {
+	struct mv88e6xxx_rmu_header rmu_header;
+	struct mv88e6xxx_rmu_atu_entry entries[MV88E6XXX_RMU_MAX_ATU_ENTRIES];
+	__be16 cont_code;
+} __packed;
+
+/* number of RMU MIB statistics, by type, in octets */
+#define MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN	128
+#define MV88E6XXX_RMU_STATS_TYPE_PORT_LEN	12
+#define MV88E6XXX_RMU_STATS_TYPE_DATA1_LEN	128
+#define MV88E6XXX_RMU_STATS_TYPE_MAX_LEN	(MV88E6XXX_RMU_STATS_TYPE_DATA0_LEN + \
+						 MV88E6XXX_RMU_STATS_TYPE_DATA1_LEN)
+
+struct mv88e6xxx_rmu_mib_resp {
+	struct mv88e6xxx_rmu_header rmu_header;
+	__be16 swport;
+	__be32 timestamp;
+	__be32 data[MV88E6XXX_RMU_STATS_TYPE_MAX_LEN / 4];
+} __packed;
+
+struct mv88e6xxx_devlink_atu_entry;
+
+int mv88e6xxx_rmu_dump_atu(struct mv88e6xxx_chip *chip,
+			   struct mv88e6xxx_devlink_atu_entry *entries,
+			   u16 *cont_code);
+int mv88e6xxx_rmu_stats(struct mv88e6xxx_chip *chip, int port,
+			u64 *data,
+			const struct mv88e6xxx_hw_stat *hw_stats,
+			int num_hw_stats);
+int mv88e6xxx_rmu_write(struct mv88e6xxx_chip *chip, int addr, int reg,
+			u16 val);
+int mv88e6xxx_rmu_read(struct mv88e6xxx_chip *chip, int addr, int reg,
+		       u16 *val);
+int mv88e6xxx_rmu_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg,
+			   int bit, int val);
+void mv88e6xxx_rmu_conduit_state_change(struct dsa_switch *ds,
+					const struct net_device *conduit,
+					bool operational);
+void mv88e6xxx_rmu_frame2reg_handler(struct dsa_switch *ds,
+				     struct sk_buff *skb,
+				     u8 seqno);
+
+/* RMU register access falls back to MDIO when the operation is unsupported or
+ * times out. @chip is unused today, but threading it through here lets a future
+ * RMU-only mode suppress the fallback without touching any of the call sites.
+ */
+static inline bool
+mv88e6xxx_rmu_can_mdio_fallback(struct mv88e6xxx_chip *chip, int err)
+{
+	return err == -EOPNOTSUPP || err == -ETIMEDOUT;
+}
+#endif /* _MV88E6XXX_RMU_H_ */
diff --git a/include/linux/dsa/mv88e6xxx.h b/include/linux/dsa/mv88e6xxx.h
index 8c3d45eca46bdb..74a885b3bc4cb2 100644
--- a/include/linux/dsa/mv88e6xxx.h
+++ b/include/linux/dsa/mv88e6xxx.h
@@ -6,6 +6,17 @@
 #define _NET_DSA_TAG_MV88E6XXX_H
 
 #include <linux/if_vlan.h>
+#include <net/dsa.h>
+
+struct dsa_tagger_data {
+	/* DSA frame decoded to be from the RMU */
+	void (*rmu_frame2reg)(struct dsa_switch *ds,
+			      struct sk_buff *skb,
+			      u8 seqno);
+	/* Add DSA header to frame to be sent to switch */
+	void (*rmu_reg2frame)(struct dsa_switch *ds,
+			      struct sk_buff *skb);
+};
 
 #define MV88E6XXX_VID_STANDALONE	0
 #define MV88E6XXX_VID_BRIDGED		(VLAN_N_VID - 1)
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c
index d5ffee35fbb53b..a23c3279c49bd5 100644
--- a/net/dsa/tag_dsa.c
+++ b/net/dsa/tag_dsa.c
@@ -201,14 +201,17 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev,
 static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,
 				  u8 extra)
 {
+	struct dsa_tagger_data *tagger_data;
 	bool trap = false, trunk = false;
 	int source_device, source_port;
+	struct dsa_switch *ds;
 	enum dsa_code code;
 	enum dsa_cmd cmd;
 	u8 *dsa_header;
 
 	/* The ethertype field is part of the DSA header. */
 	dsa_header = dsa_etype_header_pos_rx(skb);
+	source_device = dsa_header[0] & 0x1f;
 
 	cmd = dsa_header[0] >> 6;
 	switch (cmd) {
@@ -220,12 +223,20 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,
 		code = (dsa_header[1] & 0x6) | ((dsa_header[2] >> 4) & 1);
 
 		switch (code) {
-		case DSA_CODE_FRAME2REG:
-			/* Remote management is not implemented yet,
-			 * drop.
-			 */
+		case DSA_CODE_FRAME2REG: {
+			u8 seqno = dsa_header[3];
+
+			ds = dsa_conduit_find_switch(dev, source_device);
+			if (!ds) {
+				kfree_skb(skb);
+				return NULL;
+			}
+			tagger_data = ds->tagger_data;
+			if (likely(tagger_data && tagger_data->rmu_frame2reg))
+				tagger_data->rmu_frame2reg(ds, skb, seqno);
 			kfree_skb(skb);
 			return NULL;
+		}
 		case DSA_CODE_ARP_MIRROR:
 		case DSA_CODE_POLICY_MIRROR:
 			/* Mark mirrored packets to notify any upper
@@ -256,7 +267,6 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,
 		return NULL;
 	}
 
-	source_device = dsa_header[0] & 0x1f;
 	source_port = (dsa_header[1] >> 3) & 0x1f;
 
 	if (trunk) {
@@ -331,6 +341,49 @@ static struct sk_buff *dsa_rcv_ll(struct sk_buff *skb, struct net_device *dev,
 	return skb;
 }
 
+static void dsa_rmu_reg2frame(struct dsa_switch *ds,
+			      struct sk_buff *skb)
+{
+	enum dsa_cmd cmd = DSA_CMD_FROM_CPU;
+	u8 tag_dev = ds->index;
+	u8 *dsa_header;
+
+	dsa_header = skb_push(skb, DSA_HLEN);
+	dsa_header[0] = (cmd << 6) | tag_dev;
+	dsa_header[1] = BIT(1) | 0x3e << 2;
+	dsa_header[2] = 6 << 5 | 0xf;
+	dsa_header[3] = 0; /* Sequence number is filled in later */
+
+	if (ds->dst->tag_ops->proto == DSA_TAG_PROTO_EDSA) {
+		u8 *edsa_header = skb_push(skb, 4);
+
+		edsa_header[0] = (ETH_P_EDSA >> 8) & 0xff;
+		edsa_header[1] = ETH_P_EDSA & 0xff;
+		edsa_header[2] = 0x00;
+		edsa_header[3] = 0x00;
+	}
+}
+
+static int dsa_tag_connect(struct dsa_switch *ds)
+{
+	struct dsa_tagger_data *tagger_data;
+
+	tagger_data = kzalloc_obj(*tagger_data, GFP_KERNEL);
+	if (!tagger_data)
+		return -ENOMEM;
+
+	tagger_data->rmu_reg2frame = dsa_rmu_reg2frame;
+	ds->tagger_data = tagger_data;
+
+	return 0;
+}
+
+static void dsa_tag_disconnect(struct dsa_switch *ds)
+{
+	kfree(ds->tagger_data);
+	ds->tagger_data = NULL;
+}
+
 #if IS_ENABLED(CONFIG_NET_DSA_TAG_DSA)
 
 static struct sk_buff *dsa_xmit(struct sk_buff *skb, struct net_device *dev)
@@ -353,6 +406,8 @@ static const struct dsa_device_ops dsa_netdev_ops = {
 	.proto	  = DSA_TAG_PROTO_DSA,
 	.xmit	  = dsa_xmit,
 	.rcv	  = dsa_rcv,
+	.connect  = dsa_tag_connect,
+	.disconnect = dsa_tag_disconnect,
 	.needed_headroom = DSA_HLEN,
 };
 
@@ -397,6 +452,8 @@ static const struct dsa_device_ops edsa_netdev_ops = {
 	.proto	  = DSA_TAG_PROTO_EDSA,
 	.xmit	  = edsa_xmit,
 	.rcv	  = edsa_rcv,
+	.connect  = dsa_tag_connect,
+	.disconnect = dsa_tag_disconnect,
 	.needed_headroom = EDSA_HLEN,
 };
 

3/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 25887
							output: 38
							thoughts: 528
						

Thoughts:
**Analyzing the RMU Patch for the Marvell 88E6xxx DSA Driver**

Okay, so I've got this patch adding Remote Management Unit (RMU) support to the Marvell 88E6xxx DSA driver. My immediate thought is, "Functionally, does this *work*?" Seems like it does. The patch introduces `rmu.c` and touches a good number of other files like `chip.c`, `global1.c`, `devlink.c`, etc. I see the addition of the standard read/write functions and utilities (`mv88e6xxx_rmu_*`), which is what I would expect. It also seems to have modifications in `net/dsa/tag_dsa.c` to handle `DSA_CODE_FRAME2REG`. This is crucial.

Now, the important question is: "Is this *reachable* in a virtualized setting?". The Marvell 88E6xxx is a *hardware* switch chip, and those are usually hard to emulate. While full hardware switch emulation is rare, maybe there's some software emulation available. I wonder, can it be reached via netlink?

But, wait a minute, `DSA_CODE_FRAME2REG` is handled in `dsa_rcv_ll`, which is part of the DSA tagger. This is the entry point. That opens an interesting attack surface. A fuzzer could, in theory, inject packets with a DSA tag and trigger that `rmu_frame2reg` callback.

Thinking this through, `dsa_rcv_ll` is called when a packet is received on the conduit interface. So, if I create a dummy interface or a tun/tap interface and set it up as a conduit for a DSA switch, I could inject packets. This is a potential vulnerability, since it provides a way to interact with the RMU.

Can I instantiate a DSA switch without the actual hardware? Yes! There's the `dsa_loop` driver, which is a mock DSA switch. That's a huge help. Now, I need to check if `dsa_loop` uses `tag_dsa.c` or `tag_edsa.c`. I will use `grepper` and see if `dsa_loop` uses either `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA`. This will tell me which tagger it uses.



4/2 2026/07/03 09:04 tool grepper
0m Args:
{
  "Expression": "DSA_TAG_PROTO",
  "PathPrefix": "drivers/net/dsa/dsa_loop.c"
}

Results:
{
  "Output": "drivers/net/dsa/dsa_loop.c=125=static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds,\n--\ndrivers/net/dsa/dsa_loop.c-130-\ndrivers/net/dsa/dsa_loop.c:131:\treturn DSA_TAG_PROTO_NONE;\ndrivers/net/dsa/dsa_loop.c-132-}\n"
}

5/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 27099
							output: 35
							thoughts: 288
						

Thoughts:
**Analyzing the Fuzzing Coverage of `tag_dsa.c`**

Okay, so `dsa_loop` uses `DSA_TAG_PROTO_NONE`. That's not the path I'm interested in right now, so I'll put a pin in that for later. The real question is, how do we get at the juicy bits of `tag_dsa.c` through the fuzzer? My immediate thought is, can we instantiate the `mv88e6xxx` driver without actual hardware? Usually, that's a no-go, since it's an MDIO device. I have to think about MDIO mocking. I seem to recall we might be able to use something like `mdio-mockup`, or perhaps `mdio-bcm-unimac` to fake it? But hold on, I don't think `mdio-mockup` is actually a thing. It’s more like `mdio-gpio`, which doesn't solve the issue as we need to have a device to probe. Then, it hits me: the `mv88e6xxx` requires reading specific ID registers to probe successfully. Without a successful probe, the code in `rmu.c` is never even reached. That presents a serious coverage challenge.

So, the next step is to explore how to successfully probe `mv88e6xxx` by some sort of software emulation. Unless there's been some recent development, syzkaller doesn't have an I2C or MDIO emulator that fakes those specific `mv88e6xxx` registers. That seems like a dead end for now.

But wait a minute! There's another route to coverage! The `tag_dsa.c` changes are reachable if any DSA switch uses `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA`. So, let's switch gears and find out which switches in the codebase actually use those protocols. That's where I need to focus my efforts now, to find a more attainable path through the fuzzer.



6/2 2026/07/03 09:04 tool grepper
0m Args:
{
  "Expression": "DSA_TAG_PROTO_(E)?DSA",
  "PathPrefix": "drivers/net/dsa"
}

Results:
{
  "Output": "drivers/net/dsa/mv88e6xxx/chip.c=3278=static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3286-\t/* Setup CPU port mode depending on its supported tag format */\ndrivers/net/dsa/mv88e6xxx/chip.c:3287:\tif (chip-\u003etag_protocol == DSA_TAG_PROTO_DSA)\ndrivers/net/dsa/mv88e6xxx/chip.c-3288-\t\treturn mv88e6xxx_set_port_mode_dsa(chip, port);\ndrivers/net/dsa/mv88e6xxx/chip.c-3289-\ndrivers/net/dsa/mv88e6xxx/chip.c:3290:\tif (chip-\u003etag_protocol == DSA_TAG_PROTO_EDSA)\ndrivers/net/dsa/mv88e6xxx/chip.c-3291-\t\treturn mv88e6xxx_set_port_mode_edsa(chip, port);\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=6682=static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-6690-\tswitch (proto) {\ndrivers/net/dsa/mv88e6xxx/chip.c:6691:\tcase DSA_TAG_PROTO_EDSA:\ndrivers/net/dsa/mv88e6xxx/chip.c-6692-\t\tswitch (chip-\u003einfo-\u003eedsa_support) {\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-6701-\t\tbreak;\ndrivers/net/dsa/mv88e6xxx/chip.c:6702:\tcase DSA_TAG_PROTO_DSA:\ndrivers/net/dsa/mv88e6xxx/chip.c-6703-\t\tbreak;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=7205=static int mv88e6xxx_connect_tag_protocol(struct dsa_switch *ds,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-7210-\tswitch (proto) {\ndrivers/net/dsa/mv88e6xxx/chip.c:7211:\tcase DSA_TAG_PROTO_DSA:\ndrivers/net/dsa/mv88e6xxx/chip.c:7212:\tcase DSA_TAG_PROTO_EDSA:\ndrivers/net/dsa/mv88e6xxx/chip.c-7213-\t\ttagger_data-\u003ermu_frame2reg = mv88e6xxx_rmu_frame2reg_handler;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=7359=static int mv88e6xxx_probe(struct mdio_device *mdiodev)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-7424-\tif (chip-\u003einfo-\u003eedsa_support == MV88E6XXX_EDSA_SUPPORTED)\ndrivers/net/dsa/mv88e6xxx/chip.c:7425:\t\tchip-\u003etag_protocol = DSA_TAG_PROTO_EDSA;\ndrivers/net/dsa/mv88e6xxx/chip.c-7426-\telse\ndrivers/net/dsa/mv88e6xxx/chip.c:7427:\t\tchip-\u003etag_protocol = DSA_TAG_PROTO_DSA;\ndrivers/net/dsa/mv88e6xxx/chip.c-7428-\n--\ndrivers/net/dsa/mv88e6xxx/rmu.c=64=static int mv88e6xxx_rmu_request(struct mv88e6xxx_chip *chip,\n--\ndrivers/net/dsa/mv88e6xxx/rmu.c-92-\ndrivers/net/dsa/mv88e6xxx/rmu.c:93:\tedsa = chip-\u003etag_protocol == DSA_TAG_PROTO_EDSA;\ndrivers/net/dsa/mv88e6xxx/rmu.c-94-\n"
}

7/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 28988
							output: 33
							thoughts: 84
						

Thoughts:
**Analyzing DSA Tagging Protocols**

Okay, so I'm focusing on these DSA tagging protocols, `DSA_TAG_PROTO_DSA` and `DSA_TAG_PROTO_EDSA`. It seems like my initial understanding is that only the `mv88e6xxx` driver utilizes these specific protocols. I need to be sure about this assumption. Now, let's see. The recent modifications to tag handling, specifically those related to DSA protocols, are within `net/dsa/tag_dsa.c`. The question I need to answer, definitively, is whether this `tag_dsa.c` code is exclusively used by `mv88e6xxx`, or if other drivers might be invoking it as well. I have to confirm whether any other DSA-aware hardware could be using this code.



8/2 2026/07/03 09:04 tool grepper
0m Args:
{
  "Expression": "DSA_TAG_PROTO_(E)?DSA",
  "PathPrefix": "net/dsa"
}

Results:
{
  "Output": "net/dsa/tag_dsa.c=344=static void dsa_rmu_reg2frame(struct dsa_switch *ds,\n--\nnet/dsa/tag_dsa.c-356-\nnet/dsa/tag_dsa.c:357:\tif (ds-\u003edst-\u003etag_ops-\u003eproto == DSA_TAG_PROTO_EDSA) {\nnet/dsa/tag_dsa.c-358-\t\tu8 *edsa_header = skb_push(skb, 4);\n--\nnet/dsa/tag_dsa.c=404=static const struct dsa_device_ops dsa_netdev_ops = {\nnet/dsa/tag_dsa.c-405-\t.name\t  = DSA_NAME,\nnet/dsa/tag_dsa.c:406:\t.proto\t  = DSA_TAG_PROTO_DSA,\nnet/dsa/tag_dsa.c-407-\t.xmit\t  = dsa_xmit,\n--\nnet/dsa/tag_dsa.c=414=DSA_TAG_DRIVER(dsa_netdev_ops);\nnet/dsa/tag_dsa.c:415:MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_DSA, DSA_NAME);\nnet/dsa/tag_dsa.c-416-#endif\t/* CONFIG_NET_DSA_TAG_DSA */\n--\nnet/dsa/tag_dsa.c=450=static const struct dsa_device_ops edsa_netdev_ops = {\nnet/dsa/tag_dsa.c-451-\t.name\t  = EDSA_NAME,\nnet/dsa/tag_dsa.c:452:\t.proto\t  = DSA_TAG_PROTO_EDSA,\nnet/dsa/tag_dsa.c-453-\t.xmit\t  = edsa_xmit,\n--\nnet/dsa/tag_dsa.c=460=DSA_TAG_DRIVER(edsa_netdev_ops);\nnet/dsa/tag_dsa.c:461:MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_EDSA, EDSA_NAME);\nnet/dsa/tag_dsa.c-462-#endif\t/* CONFIG_NET_DSA_TAG_EDSA */\n"
}

9/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 29881
							output: 34
							thoughts: 113
						

Thoughts:
**Investigating DSA Tag Protocol Flexibility**

Okay, so the tagger here is set up to handle both `DSA_TAG_PROTO_DSA` and `DSA_TAG_PROTO_EDSA`. That's good, but it's got me thinking about the implications for fuzzing. If the fuzzer throws up a dummy network device and configures it as a DSA conduit, can it then leverage those tag protocols? The current implementation of `dsa_loop` seems to default to `DSA_TAG_PROTO_NONE`, which is a concern. Maybe, just maybe, we can manipulate the tag protocol via netlink? It's worth investigating. My next step is to determine whether or not we can change the DSA tag protocol dynamically. Let's see what the documentation and existing code have to say about that. This could be a significant vector for targeted fuzzing if it's possible.



10/2 2026/07/03 09:04 tool grepper
0m Args:
{
  "Expression": "dsa_switch_change_tag_proto",
  "PathPrefix": "net/dsa"
}

Results:
{
  "Output": "net/dsa/switch.c=853=static int dsa_switch_host_vlan_del(struct dsa_switch *ds,\n--\nnet/dsa/switch.c-872-\nnet/dsa/switch.c:873:static int dsa_switch_change_tag_proto(struct dsa_switch *ds,\nnet/dsa/switch.c-874-\t\t\t\t       struct dsa_notifier_tag_proto_info *info)\n--\nnet/dsa/switch.c=974=static int dsa_switch_event(struct notifier_block *nb,\n--\nnet/dsa/switch.c-1044-\tcase DSA_NOTIFIER_TAG_PROTO:\nnet/dsa/switch.c:1045:\t\terr = dsa_switch_change_tag_proto(ds, info);\nnet/dsa/switch.c-1046-\t\tbreak;\n"
}

11/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 30457
							output: 38
							thoughts: 48
						

Thoughts:
Okay, here's my interpretation of those thoughts, presented as my own mental process, with the bolded header as requested:

**Assessing the Tag Protocol Modification**

Right, so `DSA_NOTIFIER_TAG_PROTO` is the mechanism for modifying the tag protocol, I understand that. But hold on a second. I need to be sure the system I'm using actually *supports* this modification. I'm thinking specifically about `dsa_loop`... does it actually implement the `change_tag_protocol` switch operation? Because if it doesn't, this entire attempt will probably fail. I need to verify that level of implementation before I proceed any further.



12/2 2026/07/03 09:04 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "change_tag_protocol",
  "PathPrefix": "drivers/net/dsa/dsa_loop.c"
}

Results:
{
  "error": "no matches"
}

13/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 30700
							output: 41
							thoughts: 606
						

Thoughts:
**Analyzing the DSA Tagging Vulnerability**

Okay, so I'm thinking through this `dsa_loop` situation. It's clear that the current design prevents `dsa_loop` from changing its tagging protocol. My initial thought was to look for other software DSA switches, but it seems `dsa_loop` is the only one. Now, the potential attack vector is the fuzzer injecting packets into a `netdev` with `dsa_netdev_ops` attached. If we can't instantiate `mv88e6xxx` for a `DSA_TAG_PROTO_DSA` switch this is a dead end. We can't use device tree overlays with syzkaller, so that's out. I2C/MDIO is another avenue, but syzkaller's I2C fuzzing usually needs a device to be present or faked.

The key is this patch modifies `net/dsa/tag_dsa.c`, the DSA tagger. Diving into the `dsa_rcv_ll` function and the `DSA_CODE_FRAME2REG` case is important. If `ds` is found, `rmu_frame2reg` is called. So if `mv88e6xxx` isn't instantiated, `dsa_conduit_find_switch` will return NULL, and the packet is simply freed. The question is, can we actually reach `tag_dsa.c`? Can a user create a dummy interface and attach `dsa_netdev_ops`? No, that's not how it works; DSA taggers are attached to the conduit interface when a DSA switch tree is set up. Without a DSA switch tree, there's no conduit interface with `dsa_netdev_ops`.

Wait a minute, `dsa_loop` *does* set up a DSA switch tree! But it uses `DSA_TAG_PROTO_NONE` which means `tag_none.c` is the handler, not the DSA tagger. The next logical step is to see if we can force `dsa_loop` to use `DSA_TAG_PROTO_DSA`. I need to check `dsa_loop_get_protocol`.



14/2 2026/07/03 09:04 tool grepper
0m Args:
{
  "Expression": "dsa_loop_get_protocol",
  "PathPrefix": "drivers/net/dsa/dsa_loop.c"
}

Results:
{
  "Output": "drivers/net/dsa/dsa_loop.c=97=static int dsa_loop_setup_devlink_resources(struct dsa_switch *ds)\n--\ndrivers/net/dsa/dsa_loop.c-124-\ndrivers/net/dsa/dsa_loop.c:125:static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds,\ndrivers/net/dsa/dsa_loop.c-126-\t\t\t\t\t\t   int port,\n--\ndrivers/net/dsa/dsa_loop.c=334=static const struct dsa_switch_ops dsa_loop_driver = {\ndrivers/net/dsa/dsa_loop.c:335:\t.get_tag_protocol\t= dsa_loop_get_protocol,\ndrivers/net/dsa/dsa_loop.c-336-\t.setup\t\t\t= dsa_loop_setup,\n"
}

15/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 32071
							output: 45
							thoughts: 76
						

Thoughts:
Okay, let's see what we've got here.

**Analyzing DSA Switch Instantiation**

So, the code's returning `DSA_TAG_PROTO_NONE`. Hmm, that's not ideal. I need to figure out why and, more importantly, *how* we might be able to properly instantiate a DSA switch here. Let me consider the options. Is there any other path, any other way to get this done?

Right, let me think through the common configurations. What about `netdev_sim`? It’s a virtual network device, but does *it* have a DSA switch built in? No, that's not its purpose. Okay, scratch that. What about `mv88e6xxx`? Now we're getting somewhere. It's a very common Marvell switch. Can that be probed successfully in this setup? It needs to be probed.

Alright, let's go straight to the source. Time to dig into `mv88e6xxx_probe`. That's the function that's going to tell us what's going on with that particular switch and if there's an issue there. I need to understand that code flow completely to see if it's contributing to the `DSA_TAG_PROTO_NONE` return. This is the likely culprit and what I need to focus on next.



16/2 2026/07/03 09:04 tool grepper
0m Args:
{
  "Expression": "mv88e6xxx_probe",
  "PathPrefix": "drivers/net/dsa/mv88e6xxx/chip.c"
}

Results:
{
  "Output": "drivers/net/dsa/mv88e6xxx/chip.c=7357=static SIMPLE_DEV_PM_OPS(mv88e6xxx_pm_ops, mv88e6xxx_suspend, mv88e6xxx_resume);\ndrivers/net/dsa/mv88e6xxx/chip.c-7358-\ndrivers/net/dsa/mv88e6xxx/chip.c:7359:static int mv88e6xxx_probe(struct mdio_device *mdiodev)\ndrivers/net/dsa/mv88e6xxx/chip.c-7360-{\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=7575=static struct mdio_driver mv88e6xxx_driver = {\ndrivers/net/dsa/mv88e6xxx/chip.c:7576:\t.probe\t= mv88e6xxx_probe,\ndrivers/net/dsa/mv88e6xxx/chip.c-7577-\t.remove = mv88e6xxx_remove,\n"
}

17/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 32765
							output: 26
							thoughts: 93
						

Thoughts:
**MDIO Driver Fuzzing Strategy**

Okay, so I'm looking at this; it seems to be an MDIO driver. My initial thought is, can we actually get Syzkaller to instantiate and fuzz MDIO devices? I know there's a concept like `mdio-mockup`, right? But that's not it, is it? Ah, no, Syzkaller doesn't seem to have a generic MDIO fuzzer defined right off the bat. Hmm... Did Syzkaller provide something like `syz_mdio_bus_add_device`? I feel like I've seen something vaguely similar in the past. Nope. Okay, so scratch that line of thought. Let me switch gears, I'll quickly check the Syzkaller descriptions to see if there are *any* MDIO devices already mentioned in their data. Maybe there's something to build from, a starting point at least.



18/2 2026/07/03 09:04 tool grepper
0m Args:
{
  "Expression": "mdio",
  "PathPrefix": "net/dsa"
}

Results:
{
  "Output": "net/dsa/dsa.c=621=static int dsa_switch_setup(struct dsa_switch *ds)\n--\nnet/dsa/dsa.c-653-\tif (!ds-\u003euser_mii_bus \u0026\u0026 ds-\u003eops-\u003ephy_read) {\nnet/dsa/dsa.c:654:\t\tds-\u003euser_mii_bus = mdiobus_alloc();\nnet/dsa/dsa.c-655-\t\tif (!ds-\u003euser_mii_bus) {\n--\nnet/dsa/dsa.c-661-\nnet/dsa/dsa.c:662:\t\terr = mdiobus_register(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c-663-\t\tif (err \u003c 0)\n--\nnet/dsa/dsa.c-673-\tif (ds-\u003euser_mii_bus \u0026\u0026 ds-\u003eops-\u003ephy_read)\nnet/dsa/dsa.c:674:\t\tmdiobus_free(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c-675-teardown:\n--\nnet/dsa/dsa.c=685=static void dsa_switch_teardown(struct dsa_switch *ds)\n--\nnet/dsa/dsa.c-692-\tif (ds-\u003euser_mii_bus \u0026\u0026 ds-\u003eops-\u003ephy_read) {\nnet/dsa/dsa.c:693:\t\tmdiobus_unregister(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c:694:\t\tmdiobus_free(ds-\u003euser_mii_bus);\nnet/dsa/dsa.c-695-\t\tds-\u003euser_mii_bus = NULL;\n--\nnet/dsa/port.c-11-#include \u003clinux/notifier.h\u003e\nnet/dsa/port.c:12:#include \u003clinux/of_mdio.h\u003e\nnet/dsa/port.c-13-#include \u003clinux/of_net.h\u003e\n--\nnet/dsa/port.c=1726=static const char * const dsa_switches_apply_workarounds[] = {\n--\nnet/dsa/port.c-1796-#if IS_ENABLED(CONFIG_NET_DSA_SMSC_LAN9303_MDIO)\nnet/dsa/port.c:1797:\t\"smsc,lan9303-mdio\",\nnet/dsa/port.c-1798-#endif\n--\nnet/dsa/user.c-13-#include \u003clinux/of_net.h\u003e\nnet/dsa/user.c:14:#include \u003clinux/of_mdio.h\u003e\nnet/dsa/user.c:15:#include \u003clinux/mdio.h\u003e\nnet/dsa/user.c-16-#include \u003cnet/rtnetlink.h\u003e\n--\nnet/dsa/user.c=2637=static int dsa_user_phy_connect(struct net_device *user_dev, int addr,\n--\nnet/dsa/user.c-2642-\nnet/dsa/user.c:2643:\tuser_dev-\u003ephydev = mdiobus_get_phy(ds-\u003euser_mii_bus, addr);\nnet/dsa/user.c-2644-\tif (!user_dev-\u003ephydev) {\n"
}

19/2 2026/07/03 09:04 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 33944
							output: 32
							thoughts: 136
						

Thoughts:
**Investigating the `mv88e6xxx` Driver and Tag Protocol Manipulation**

Okay, so I'm thinking about this `mv88e6xxx` thing – right, it's a hardware driver, isn't it? Let me see… I need to figure out how to interact with its internals. Specifically, I'm trying to get at the code in `tag_dsa.c`. Could I possibly reach it through the `dsa_loop` mechanism? That seems like a logical first step.

Alright, let's explore if I can actually modify the tag protocol used by `dsa_loop`. My initial thought is to try sending an `RTM_SETLINK` message with an `IFLA_AF_SPEC` attribute, and then setting `IFLA_DSA_TAG_PROTO` within that. Wait… no, that's not going to work. `IFLA_DSA_TAG_PROTO` isn't even defined. Okay, back to the drawing board.

How *is* the tag protocol changed then? Hmm, let me see if I can find the function responsible for that. I think `dsa_switch_change_tag_proto` is the right place to look. I'll focus my research there.



20/2 2026/07/03 09:05 tool grepper
0m Args:
{
  "Expression": "DSA_NOTIFIER_TAG_PROTO",
  "PathPrefix": "net/dsa"
}

Results:
{
  "Output": "net/dsa/dsa.c=947=static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst,\n--\nnet/dsa/dsa.c-959-\tinfo.tag_ops = tag_ops;\nnet/dsa/dsa.c:960:\terr = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_CONNECT, \u0026info);\nnet/dsa/dsa.c-961-\tif (err \u0026\u0026 err != -EOPNOTSUPP)\n--\nnet/dsa/dsa.c-965-\tinfo.tag_ops = old_tag_ops;\nnet/dsa/dsa.c:966:\tdsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, \u0026info);\nnet/dsa/dsa.c-967-\n--\nnet/dsa/dsa.c-971-\tinfo.tag_ops = tag_ops;\nnet/dsa/dsa.c:972:\tdsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO_DISCONNECT, \u0026info);\nnet/dsa/dsa.c-973-\tdst-\u003etag_ops = old_tag_ops;\n--\nnet/dsa/dsa.c=982=int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,\n--\nnet/dsa/dsa.c-1007-\tinfo.tag_ops = tag_ops;\nnet/dsa/dsa.c:1008:\terr = dsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, \u0026info);\nnet/dsa/dsa.c-1009-\tif (err)\n--\nnet/dsa/dsa.c-1021-\tinfo.tag_ops = old_tag_ops;\nnet/dsa/dsa.c:1022:\tdsa_tree_notify(dst, DSA_NOTIFIER_TAG_PROTO, \u0026info);\nnet/dsa/dsa.c-1023-out_unlock:\n--\nnet/dsa/switch.c=974=static int dsa_switch_event(struct notifier_block *nb,\n--\nnet/dsa/switch.c-1043-\t\tbreak;\nnet/dsa/switch.c:1044:\tcase DSA_NOTIFIER_TAG_PROTO:\nnet/dsa/switch.c-1045-\t\terr = dsa_switch_change_tag_proto(ds, info);\nnet/dsa/switch.c-1046-\t\tbreak;\nnet/dsa/switch.c:1047:\tcase DSA_NOTIFIER_TAG_PROTO_CONNECT:\nnet/dsa/switch.c-1048-\t\terr = dsa_switch_connect_tag_proto(ds, info);\nnet/dsa/switch.c-1049-\t\tbreak;\nnet/dsa/switch.c:1050:\tcase DSA_NOTIFIER_TAG_PROTO_DISCONNECT:\nnet/dsa/switch.c-1051-\t\terr = dsa_switch_disconnect_tag_proto(ds, info);\n--\nnet/dsa/switch.h=10=enum {\n--\nnet/dsa/switch.h-31-\tDSA_NOTIFIER_MTU,\nnet/dsa/switch.h:32:\tDSA_NOTIFIER_TAG_PROTO,\nnet/dsa/switch.h:33:\tDSA_NOTIFIER_TAG_PROTO_CONNECT,\nnet/dsa/switch.h:34:\tDSA_NOTIFIER_TAG_PROTO_DISCONNECT,\nnet/dsa/switch.h-35-\tDSA_NOTIFIER_TAG_8021Q_VLAN_ADD,\n--\nnet/dsa/switch.h=92=struct dsa_notifier_mtu_info {\n--\nnet/dsa/switch.h-96-\nnet/dsa/switch.h:97:/* DSA_NOTIFIER_TAG_PROTO_* */\nnet/dsa/switch.h-98-struct dsa_notifier_tag_proto_info {\n"
}

21/2 2026/07/03 09:05 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 35436
							output: 34
							thoughts: 15
						

Thoughts:
Okay, here's my attempt at summarizing that thought process, keeping in mind I'm speaking to a fellow expert:

**Tracing the Root of the `dsa_tree_change_tag_proto` Call**

Alright, so the question is, *who* is calling `dsa_tree_change_tag_proto`?  That's the core of it, and it's where I need to start. I know this function – it’s a critical piece, likely related to tagging changes within that distributed shared array (DSA) tree structure.  So, figuring out its callers is step one for understanding its purpose and impact. I need to know the origin. Is it part of the tree maintenance, a notification system, or triggered by an external event? The answer will dictate how I investigate next.



22/2 2026/07/03 09:05 tool grepper
0m Args:
{
  "Expression": "dsa_tree_change_tag_proto",
  "PathPrefix": "net/dsa"
}

Results:
{
  "Output": "net/dsa/conduit.c=350=static ssize_t tagging_store(struct device *d, struct device_attribute *attr,\n--\nnet/dsa/conduit.c-380-\nnet/dsa/conduit.c:381:\terr = dsa_tree_change_tag_proto(cpu_dp-\u003eds-\u003edst, new_tag_ops,\nnet/dsa/conduit.c-382-\t\t\t\t\told_tag_ops);\n--\nnet/dsa/dsa.c=947=static int dsa_tree_bind_tag_proto(struct dsa_switch_tree *dst,\n--\nnet/dsa/dsa.c-981- */\nnet/dsa/dsa.c:982:int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,\nnet/dsa/dsa.c-983-\t\t\t      const struct dsa_device_ops *tag_ops,\n--\nnet/dsa/dsa.h=24=struct net_device *dsa_tree_find_first_conduit(struct dsa_switch_tree *dst);\nnet/dsa/dsa.h:25:int dsa_tree_change_tag_proto(struct dsa_switch_tree *dst,\nnet/dsa/dsa.h-26-\t\t\t      const struct dsa_device_ops *tag_ops,\n--\nnet/dsa/switch.c=873=static int dsa_switch_change_tag_proto(struct dsa_switch *ds,\n--\nnet/dsa/switch.c-900-\nnet/dsa/switch.c:901:\t\t/* rtnl_mutex is held in dsa_tree_change_tag_proto */\nnet/dsa/switch.c-902-\t\tdsa_user_change_mtu(user, user-\u003emtu);\n"
}

23/2 2026/07/03 09:05 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 36138
							output: 33
							thoughts: 137
						

Thoughts:
**Investigating Tag Protocol Flexibility**

Okay, so I'm looking at `tagging_store` within `net/dsa/conduit.c`. This is intriguing – it's suggesting that the tag protocol for DSA (Distributed Switch Architecture) can be dynamically adjusted through sysfs. That's a powerful level of configurability. I can see the command now: `echo dsa > /sys/class/net/<conduit>/dsa/tagging`.

Now, the question is, how robust is this implementation? Does `dsa_loop` allow for changing the tag protocol on the fly? Let's trace through the code. I see `dsa_tree_change_tag_proto` is the key function here. It, in turn, calls `dsa_switch_change_tag_proto`, which then calls `ds->ops->change_tag_protocol`. Ah, right, the function pointer. If `ds->ops->change_tag_protocol` is a null pointer, meaning no specific handler is provided by the driver for that particular switch, it’s going to return `-EOPNOTSUPP`. That's the expected behavior, of course, a clear indication that a driver doesn't support the requested tag protocol change. I'll need to check the drivers to see which ones implement this capability.



24/2 2026/07/03 09:05 tool grepper
0m Args:
{
  "Expression": "change_tag_protocol",
  "PathPrefix": "net/dsa/switch.c"
}

Results:
{
  "Output": "net/dsa/switch.c=873=static int dsa_switch_change_tag_proto(struct dsa_switch *ds,\n--\nnet/dsa/switch.c-879-\nnet/dsa/switch.c:880:\tif (!ds-\u003eops-\u003echange_tag_protocol)\nnet/dsa/switch.c-881-\t\treturn -EOPNOTSUPP;\n--\nnet/dsa/switch.c-884-\nnet/dsa/switch.c:885:\terr = ds-\u003eops-\u003echange_tag_protocol(ds, tag_ops-\u003eproto);\nnet/dsa/switch.c-886-\tif (err)\n"
}

25/2 2026/07/03 09:05 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 36775
							output: 30
							thoughts: 450
						

Thoughts:
**Unreachable Code in DSA and MDIO Drivers**

Okay, so it seems like `dsa_loop` is going to be a dead end. Since it doesn't implement `change_tag_protocol`, it will return `-EOPNOTSUPP`. That means I can't force the tag protocol to `dsa` or `edsa` using that path. The question is, can I reach `dsa_rcv_ll` through another route? That's the function I need to get to, since it handles receives for `DSA_TAG_PROTO_DSA` and `DSA_TAG_PROTO_EDSA`. The fuzzer could create a netdev and somehow attach `dsa_netdev_ops` to it, but that only happens when a DSA switch tree is set up. The tag protocol is ultimately defined by that tree. If the switch tree *never* uses `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA`, then `dsa_netdev_ops` will never be associated with any interface. Therefore, `dsa_rcv_ll` is unreachable.

Now, what about `mv88e6xxx`? Is there a way to instantiate that driver? I need to think about how Syzkaller operates in this context. It seems like Syzkaller doesn't have a direct method for instantiating MDIO devices unless there's a specific fuzzer tailored for that. `mv88e6xxx` is an MDIO driver after all. Can I instantiate it through sysfs, perhaps using something like `echo mv88e6085 > /sys/bus/mdio_bus/devices/...`? No, MDIO devices are usually handled during device tree setup or board code. That leaves me with `mdio-mockup`. This allows me to create MDIO buses. Does Syzkaller use `mdio-mockup`? Let me check the config. Actually, does Syzkaller have `syz_mdio_bus_add_device`? No. So it seems like this isn't a direct route.

I'm starting to think this patch might be unreachable altogether. Let's step back and check if I can even reach `mv88e6xxx` in the first place.



26/2 2026/07/03 09:05 tool grepper
0m Args:
{
  "Expression": "mv88e6xxx",
  "PathPrefix": "net/dsa"
}

Results:
{
  "Output": "net/dsa/dsa.c=64=void dsa_lag_map(struct dsa_switch_tree *dst, struct dsa_lag *lag)\n--\nnet/dsa/dsa.c-76-\t/* No IDs left, which is OK. Some drivers do not need it. The\nnet/dsa/dsa.c:77:\t * ones that do, e.g. mv88e6xxx, will discover that dsa_lag_id\nnet/dsa/dsa.c-78-\t * returns an error for this device when joining the LAG. The\n--\nnet/dsa/tag_dsa.c-38- * Uses the exact same tag format as regular DSA, but also includes a\nnet/dsa/tag_dsa.c:39: * proper ethertype field (which the mv88e6xxx driver sets to\nnet/dsa/tag_dsa.c-40- * ETH_P_EDSA/0xdada) followed by two zero bytes:\n--\nnet/dsa/tag_dsa.c-47-\nnet/dsa/tag_dsa.c:48:#include \u003clinux/dsa/mv88e6xxx.h\u003e\nnet/dsa/tag_dsa.c-49-#include \u003clinux/etherdevice.h\u003e\n"
}

27/2 2026/07/03 09:05 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 38079
							output: 33
							thoughts: 177
						

Thoughts:
**Unreachable Code in a Virtualized Environment**

Okay, so I'm looking at this code and thinking, "Aha, `mv88e6xxx`... that's a *hardware* driver." My first thought is whether there's any way to even *touch* that code within a virtualized environment. That's a fundamental problem, right? Hardware and virtual machines don't typically interact directly unless there's an elaborate emulator. And I know QEMU doesn't emulate Marvell 88E6xxx switches. So, it's pretty clear: the `mv88e6xxx` driver code, in this context, is simply unreachable. A dead end.

Then, my mind shifts to `tag_dsa.c`. It *is* part of the DSA core, but again, there are conditions. It only gets used if a switch utilizes `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA`. Knowing the landscape of emulated switches, I can't think of any that actually use those protocols. That means that file is likely just as unreachable in this virtualized scenario.

But wait, hold on. I need to be absolutely certain. Are there *any* other switches – not just emulated ones – that are designed to use `DSA_TAG_PROTO_DSA`? Gotta make sure I haven't missed something fundamental in my understanding of the system.



28/2 2026/07/03 09:05 tool grepper
0m Args:
{
  "Expression": "DSA_TAG_PROTO_DSA",
  "PathPrefix": "drivers/net/dsa"
}

Results:
{
  "Output": "drivers/net/dsa/mv88e6xxx/chip.c=3278=static int mv88e6xxx_setup_port_mode(struct mv88e6xxx_chip *chip, int port)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-3286-\t/* Setup CPU port mode depending on its supported tag format */\ndrivers/net/dsa/mv88e6xxx/chip.c:3287:\tif (chip-\u003etag_protocol == DSA_TAG_PROTO_DSA)\ndrivers/net/dsa/mv88e6xxx/chip.c-3288-\t\treturn mv88e6xxx_set_port_mode_dsa(chip, port);\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=6682=static int mv88e6xxx_change_tag_protocol(struct dsa_switch *ds,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-6701-\t\tbreak;\ndrivers/net/dsa/mv88e6xxx/chip.c:6702:\tcase DSA_TAG_PROTO_DSA:\ndrivers/net/dsa/mv88e6xxx/chip.c-6703-\t\tbreak;\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=7205=static int mv88e6xxx_connect_tag_protocol(struct dsa_switch *ds,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-7210-\tswitch (proto) {\ndrivers/net/dsa/mv88e6xxx/chip.c:7211:\tcase DSA_TAG_PROTO_DSA:\ndrivers/net/dsa/mv88e6xxx/chip.c-7212-\tcase DSA_TAG_PROTO_EDSA:\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=7359=static int mv88e6xxx_probe(struct mdio_device *mdiodev)\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-7426-\telse\ndrivers/net/dsa/mv88e6xxx/chip.c:7427:\t\tchip-\u003etag_protocol = DSA_TAG_PROTO_DSA;\ndrivers/net/dsa/mv88e6xxx/chip.c-7428-\n"
}

29/2 2026/07/03 09:05 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 39213
							output: 29
							thoughts: 239
						

Thoughts:
**My Analysis of Reachability in a Virtualized Environment**

Okay, so here's the situation as I see it. It looks like the `DSA_TAG_PROTO_DSA` tagging protocol is *only* utilized by the `mv88e6xxx` driver. Consequently, the `tag_dsa.c` file, which presumably implements that specific tag protocol, is equally tied to `mv88e6xxx`. Now, if `mv88e6xxx` itself is effectively unreachable – that is, not instantiated – then `tag_dsa.c` *must* be unreachable as well. The conclusion seems pretty straightforward: this patch, whatever it pertains to, isn't going to be hit in virtualized setups.

But, you know, it's always worth a double-check. Let's make absolutely sure there isn't some obscure way to conjure up a DSA switch using an arbitrary tagging protocol. Can we, maybe, use netlink to create a DSA switch at runtime? Hmmm, no, that doesn't seem to be the case. DSA switches are generally brought into existence through either the device tree or platform data. Ah, but wait a minute... I recall the `dsa_loop` driver is initialized through `dsa_loop_init`, which then registers a platform device. Could we perhaps register *another* platform device, perhaps one that somehow hooks into `mv88e6xxx`? No, no, `mv88e6xxx` is an MDIO driver.

So, the next thought is, can we register an MDIO device from userspace? We have `I2C_NEW_DEVICE` for I2C devices. But, what about MDIO devices? Is there a corresponding ioctl for adding MDIO devices? I'll need to look into that.



30/2 2026/07/03 09:05 tool grepper
0m Args:
{
  "Expression": "MDIO",
  "PathPrefix": "include/uapi/linux/"
}

Results:
{
  "Output": "\nFull output is too long, showing 500 out of 538 lines.\nUse more precise expression if possible.\n\ninclude/uapi/linux/ethtool.h-48- * @port: Physical connector type; one of %PORT_*\ninclude/uapi/linux/ethtool.h:49: * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not\ninclude/uapi/linux/ethtool.h-50- *\tapplicable.  For clause 45 PHYs this is the PRTAD.\n--\ninclude/uapi/linux/ethtool.h-54- *\teither %AUTONEG_DISABLE or %AUTONEG_ENABLE\ninclude/uapi/linux/ethtool.h:55: * @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO\ninclude/uapi/linux/ethtool.h-56- *\tprotocols supported by the interface; 0 if unknown.\n--\ninclude/uapi/linux/ethtool.h=129=static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)\n--\ninclude/uapi/linux/ethtool.h-138- */\ninclude/uapi/linux/ethtool.h:139:#define ETH_MDIO_SUPPORTS_C22\t1\ninclude/uapi/linux/ethtool.h-140-\n--\ninclude/uapi/linux/ethtool.h-145- */\ninclude/uapi/linux/ethtool.h:146:#define ETH_MDIO_SUPPORTS_C45\t2\ninclude/uapi/linux/ethtool.h-147-\n--\ninclude/uapi/linux/ethtool.h=2437=enum ethtool_reset_flags {\n--\ninclude/uapi/linux/ethtool.h-2479- * @port: Physical connector type; one of %PORT_*\ninclude/uapi/linux/ethtool.h:2480: * @phy_address: MDIO address of PHY (transceiver); 0 or 255 if not\ninclude/uapi/linux/ethtool.h-2481- *\tapplicable.  For clause 45 PHYs this is the PRTAD.\n--\ninclude/uapi/linux/ethtool.h-2483- *\teither %AUTONEG_DISABLE or %AUTONEG_ENABLE\ninclude/uapi/linux/ethtool.h:2484: * @mdio_support: Bitmask of %ETH_MDIO_SUPPORTS_* flags for the MDIO\ninclude/uapi/linux/ethtool.h-2485- *\tprotocols supported by the interface; 0 if unknown.\n--\ninclude/uapi/linux/mdio.h-2-/*\ninclude/uapi/linux/mdio.h:3: * linux/mdio.h: definitions for MDIO (clause 45) transceivers\ninclude/uapi/linux/mdio.h-4- * Copyright 2006-2009 Solarflare Communications Inc.\n--\ninclude/uapi/linux/mdio.h-10-\ninclude/uapi/linux/mdio.h:11:#ifndef _UAPI__LINUX_MDIO_H__\ninclude/uapi/linux/mdio.h:12:#define _UAPI__LINUX_MDIO_H__\ninclude/uapi/linux/mdio.h-13-\n--\ninclude/uapi/linux/mdio.h-16-\ninclude/uapi/linux/mdio.h:17:/* MDIO Manageable Devices (MMDs). */\ninclude/uapi/linux/mdio.h:18:#define MDIO_MMD_PMAPMD\t\t1\t/* Physical Medium Attachment/\ninclude/uapi/linux/mdio.h-19-\t\t\t\t\t * Physical Medium Dependent */\ninclude/uapi/linux/mdio.h:20:#define MDIO_MMD_WIS\t\t2\t/* WAN Interface Sublayer */\ninclude/uapi/linux/mdio.h:21:#define MDIO_MMD_PCS\t\t3\t/* Physical Coding Sublayer */\ninclude/uapi/linux/mdio.h:22:#define MDIO_MMD_PHYXS\t\t4\t/* PHY Extender Sublayer */\ninclude/uapi/linux/mdio.h:23:#define MDIO_MMD_DTEXS\t\t5\t/* DTE Extender Sublayer */\ninclude/uapi/linux/mdio.h:24:#define MDIO_MMD_TC\t\t6\t/* Transmission Convergence */\ninclude/uapi/linux/mdio.h:25:#define MDIO_MMD_AN\t\t7\t/* Auto-Negotiation */\ninclude/uapi/linux/mdio.h:26:#define MDIO_MMD_SEP_PMA1\t8\t/* Separated PMA (1) */\ninclude/uapi/linux/mdio.h:27:#define MDIO_MMD_SEP_PMA2\t9\t/* Separated PMA (2) */\ninclude/uapi/linux/mdio.h:28:#define MDIO_MMD_SEP_PMA3\t10\t/* Separated PMA (3) */\ninclude/uapi/linux/mdio.h:29:#define MDIO_MMD_SEP_PMA4\t11\t/* Separated PMA (4) */\ninclude/uapi/linux/mdio.h:30:#define MDIO_MMD_POWER_UNIT\t13\t/* PHY Power Unit */\ninclude/uapi/linux/mdio.h:31:#define MDIO_MMD_C22EXT\t\t29\t/* Clause 22 extension */\ninclude/uapi/linux/mdio.h:32:#define MDIO_MMD_VEND1\t\t30\t/* Vendor specific 1 */\ninclude/uapi/linux/mdio.h:33:#define MDIO_MMD_VEND2\t\t31\t/* Vendor specific 2 */\ninclude/uapi/linux/mdio.h-34-\ninclude/uapi/linux/mdio.h:35:/* Generic MDIO registers. */\ninclude/uapi/linux/mdio.h:36:#define MDIO_CTRL1\t\tMII_BMCR\ninclude/uapi/linux/mdio.h:37:#define MDIO_STAT1\t\tMII_BMSR\ninclude/uapi/linux/mdio.h:38:#define MDIO_DEVID1\t\tMII_PHYSID1\ninclude/uapi/linux/mdio.h:39:#define MDIO_DEVID2\t\tMII_PHYSID2\ninclude/uapi/linux/mdio.h:40:#define MDIO_SPEED\t\t4\t/* Speed ability */\ninclude/uapi/linux/mdio.h:41:#define MDIO_DEVS1\t\t5\t/* Devices in package */\ninclude/uapi/linux/mdio.h:42:#define MDIO_DEVS2\t\t6\ninclude/uapi/linux/mdio.h:43:#define MDIO_CTRL2\t\t7\t/* 10G control 2 */\ninclude/uapi/linux/mdio.h:44:#define MDIO_STAT2\t\t8\t/* 10G status 2 */\ninclude/uapi/linux/mdio.h:45:#define MDIO_PMA_TXDIS\t\t9\t/* 10G PMA/PMD transmit disable */\ninclude/uapi/linux/mdio.h:46:#define MDIO_PMA_RXDET\t\t10\t/* 10G PMA/PMD receive signal detect */\ninclude/uapi/linux/mdio.h:47:#define MDIO_PMA_EXTABLE\t11\t/* 10G PMA/PMD extended ability */\ninclude/uapi/linux/mdio.h:48:#define MDIO_PKGID1\t\t14\t/* Package identifier */\ninclude/uapi/linux/mdio.h:49:#define MDIO_PKGID2\t\t15\ninclude/uapi/linux/mdio.h:50:#define MDIO_AN_ADVERTISE\t16\t/* AN advertising (base page) */\ninclude/uapi/linux/mdio.h:51:#define MDIO_AN_LPA\t\t19\t/* AN LP abilities (base page) */\ninclude/uapi/linux/mdio.h:52:#define MDIO_PCS_EEE_ABLE\t20\t/* EEE Capability register */\ninclude/uapi/linux/mdio.h:53:#define MDIO_PCS_EEE_ABLE2\t21\t/* EEE Capability register 2 */\ninclude/uapi/linux/mdio.h:54:#define MDIO_PMA_NG_EXTABLE\t21\t/* 2.5G/5G PMA/PMD extended ability */\ninclude/uapi/linux/mdio.h:55:#define MDIO_PCS_EEE_WK_ERR\t22\t/* EEE wake error counter */\ninclude/uapi/linux/mdio.h:56:#define MDIO_PHYXS_LNSTAT\t24\t/* PHY XGXS lane state */\ninclude/uapi/linux/mdio.h:57:#define MDIO_AN_EEE_ADV\t\t60\t/* EEE advertisement */\ninclude/uapi/linux/mdio.h:58:#define MDIO_AN_EEE_LPABLE\t61\t/* EEE link partner ability */\ninclude/uapi/linux/mdio.h:59:#define MDIO_AN_EEE_ADV2\t62\t/* EEE advertisement 2 */\ninclude/uapi/linux/mdio.h:60:#define MDIO_AN_EEE_LPABLE2\t63\t/* EEE link partner ability 2 */\ninclude/uapi/linux/mdio.h:61:#define MDIO_AN_CTRL2\t\t64\t/* AN THP bypass request control */\ninclude/uapi/linux/mdio.h-62-\ninclude/uapi/linux/mdio.h-63-/* Media-dependent registers. */\ninclude/uapi/linux/mdio.h:64:#define MDIO_PMA_10GBT_SWAPPOL\t130\t/* 10GBASE-T pair swap \u0026 polarity */\ninclude/uapi/linux/mdio.h:65:#define MDIO_PMA_10GBT_TXPWR\t131\t/* 10GBASE-T TX power control */\ninclude/uapi/linux/mdio.h:66:#define MDIO_PMA_10GBT_SNR\t133\t/* 10GBASE-T SNR margin, lane A.\ninclude/uapi/linux/mdio.h-67-\t\t\t\t\t * Lanes B-D are numbered 134-136. */\ninclude/uapi/linux/mdio.h:68:#define MDIO_PMA_10GBR_FSRT_CSR\t147\t/* 10GBASE-R fast retrain status and control */\ninclude/uapi/linux/mdio.h:69:#define MDIO_PMA_10GBR_FECABLE\t170\t/* 10GBASE-R FEC ability */\ninclude/uapi/linux/mdio.h:70:#define MDIO_PMA_RSFEC_CTRL\t200\t/* RSFEC control */\ninclude/uapi/linux/mdio.h:71:#define MDIO_PMA_RSFEC_LANE_MAP\t206\t/* RSFEC lane mapping */\ninclude/uapi/linux/mdio.h:72:#define MDIO_PCS_10GBX_STAT1\t24\t/* 10GBASE-X PCS status 1 */\ninclude/uapi/linux/mdio.h:73:#define MDIO_PCS_10GBRT_STAT1\t32\t/* 10GBASE-R/-T PCS status 1 */\ninclude/uapi/linux/mdio.h:74:#define MDIO_PCS_10GBRT_STAT2\t33\t/* 10GBASE-R/-T PCS status 2 */\ninclude/uapi/linux/mdio.h:75:#define MDIO_AN_10GBT_CTRL\t32\t/* 10GBASE-T auto-negotiation control */\ninclude/uapi/linux/mdio.h:76:#define MDIO_AN_10GBT_STAT\t33\t/* 10GBASE-T auto-negotiation status */\ninclude/uapi/linux/mdio.h:77:#define MDIO_B10L_PMA_CTRL\t2294\t/* 10BASE-T1L PMA control */\ninclude/uapi/linux/mdio.h:78:#define MDIO_PMA_10T1L_STAT\t2295\t/* 10BASE-T1L PMA status */\ninclude/uapi/linux/mdio.h:79:#define MDIO_PCS_10T1L_CTRL\t2278\t/* 10BASE-T1L PCS control */\ninclude/uapi/linux/mdio.h:80:#define MDIO_PMA_PMD_BT1\t18\t/* BASE-T1 PMA/PMD extended ability */\ninclude/uapi/linux/mdio.h:81:#define MDIO_AN_T1_CTRL\t\t512\t/* BASE-T1 AN control */\ninclude/uapi/linux/mdio.h:82:#define MDIO_AN_T1_STAT\t\t513\t/* BASE-T1 AN status */\ninclude/uapi/linux/mdio.h:83:#define MDIO_AN_T1_ADV_L\t514\t/* BASE-T1 AN advertisement register [15:0] */\ninclude/uapi/linux/mdio.h:84:#define MDIO_AN_T1_ADV_M\t515\t/* BASE-T1 AN advertisement register [31:16] */\ninclude/uapi/linux/mdio.h:85:#define MDIO_AN_T1_ADV_H\t516\t/* BASE-T1 AN advertisement register [47:32] */\ninclude/uapi/linux/mdio.h:86:#define MDIO_AN_T1_LP_L\t\t517\t/* BASE-T1 AN LP Base Page ability register [15:0] */\ninclude/uapi/linux/mdio.h:87:#define MDIO_AN_T1_LP_M\t\t518\t/* BASE-T1 AN LP Base Page ability register [31:16] */\ninclude/uapi/linux/mdio.h:88:#define MDIO_AN_T1_LP_H\t\t519\t/* BASE-T1 AN LP Base Page ability register [47:32] */\ninclude/uapi/linux/mdio.h:89:#define MDIO_AN_10BT1_AN_CTRL\t526\t/* 10BASE-T1 AN control register */\ninclude/uapi/linux/mdio.h:90:#define MDIO_AN_10BT1_AN_STAT\t527\t/* 10BASE-T1 AN status register */\ninclude/uapi/linux/mdio.h:91:#define MDIO_PMA_PMD_BT1_CTRL\t2100\t/* BASE-T1 PMA/PMD control register */\ninclude/uapi/linux/mdio.h:92:#define MDIO_PCS_1000BT1_CTRL\t2304\t/* 1000BASE-T1 PCS control register */\ninclude/uapi/linux/mdio.h:93:#define MDIO_PCS_1000BT1_STAT\t2305\t/* 1000BASE-T1 PCS status register */\ninclude/uapi/linux/mdio.h-94-\ninclude/uapi/linux/mdio.h-95-/* LASI (Link Alarm Status Interrupt) registers, defined by XENPAK MSA. */\ninclude/uapi/linux/mdio.h:96:#define MDIO_PMA_LASI_RXCTRL\t0x9000\t/* RX_ALARM control */\ninclude/uapi/linux/mdio.h:97:#define MDIO_PMA_LASI_TXCTRL\t0x9001\t/* TX_ALARM control */\ninclude/uapi/linux/mdio.h:98:#define MDIO_PMA_LASI_CTRL\t0x9002\t/* LASI control */\ninclude/uapi/linux/mdio.h:99:#define MDIO_PMA_LASI_RXSTAT\t0x9003\t/* RX_ALARM status */\ninclude/uapi/linux/mdio.h:100:#define MDIO_PMA_LASI_TXSTAT\t0x9004\t/* TX_ALARM status */\ninclude/uapi/linux/mdio.h:101:#define MDIO_PMA_LASI_STAT\t0x9005\t/* LASI status */\ninclude/uapi/linux/mdio.h-102-\n--\ninclude/uapi/linux/mdio.h-104-/* Enable extended speed selection */\ninclude/uapi/linux/mdio.h:105:#define MDIO_CTRL1_SPEEDSELEXT\t\t(BMCR_SPEED1000 | BMCR_SPEED100)\ninclude/uapi/linux/mdio.h-106-/* All speed selection bits */\ninclude/uapi/linux/mdio.h:107:#define MDIO_CTRL1_SPEEDSEL\t\t(MDIO_CTRL1_SPEEDSELEXT | 0x003c)\ninclude/uapi/linux/mdio.h:108:#define MDIO_CTRL1_FULLDPLX\t\tBMCR_FULLDPLX\ninclude/uapi/linux/mdio.h:109:#define MDIO_CTRL1_LPOWER\t\tBMCR_PDOWN\ninclude/uapi/linux/mdio.h:110:#define MDIO_CTRL1_RESET\t\tBMCR_RESET\ninclude/uapi/linux/mdio.h:111:#define MDIO_PMA_CTRL1_LOOPBACK\t\t0x0001\ninclude/uapi/linux/mdio.h:112:#define MDIO_PMA_CTRL1_SPEED1000\tBMCR_SPEED1000\ninclude/uapi/linux/mdio.h:113:#define MDIO_PMA_CTRL1_SPEED100\t\tBMCR_SPEED100\ninclude/uapi/linux/mdio.h:114:#define MDIO_PCS_CTRL1_LOOPBACK\t\tBMCR_LOOPBACK\ninclude/uapi/linux/mdio.h:115:#define MDIO_PHYXS_CTRL1_LOOPBACK\tBMCR_LOOPBACK\ninclude/uapi/linux/mdio.h:116:#define MDIO_AN_CTRL1_RESTART\t\tBMCR_ANRESTART\ninclude/uapi/linux/mdio.h:117:#define MDIO_AN_CTRL1_ENABLE\t\tBMCR_ANENABLE\ninclude/uapi/linux/mdio.h:118:#define MDIO_AN_CTRL1_XNP\t\t0x2000\t/* Enable extended next page */\ninclude/uapi/linux/mdio.h:119:#define MDIO_PCS_CTRL1_CLKSTOP_EN\t0x400\t/* Stop the clock during LPI */\ninclude/uapi/linux/mdio.h-120-\ninclude/uapi/linux/mdio.h-121-/* 10 Gb/s */\ninclude/uapi/linux/mdio.h:122:#define MDIO_CTRL1_SPEED10G\t\t(MDIO_CTRL1_SPEEDSELEXT | 0x00)\ninclude/uapi/linux/mdio.h-123-/* 10PASS-TS/2BASE-TL */\ninclude/uapi/linux/mdio.h:124:#define MDIO_CTRL1_SPEED10P2B\t\t(MDIO_CTRL1_SPEEDSELEXT | 0x04)\ninclude/uapi/linux/mdio.h:125:/* Note: the MDIO_CTRL1_SPEED_XXX values for everything past 10PASS-TS/2BASE-TL\ninclude/uapi/linux/mdio.h-126- * do not match between the PCS and PMA values. Any additions past this point\n--\ninclude/uapi/linux/mdio.h-129- */\ninclude/uapi/linux/mdio.h:130:#define MDIO_CTRL1_SPEED2_5G\t\tMDIO_PMA_CTRL1_SPEED2_5G\ninclude/uapi/linux/mdio.h:131:#define MDIO_CTRL1_SPEED5G\t\tMDIO_PMA_CTRL1_SPEED5G\ninclude/uapi/linux/mdio.h-132-/* 100 Gb/s */\ninclude/uapi/linux/mdio.h:133:#define MDIO_PCS_CTRL1_SPEED100G\t(MDIO_CTRL1_SPEEDSELEXT | 0x10)\ninclude/uapi/linux/mdio.h-134-/* 25 Gb/s */\ninclude/uapi/linux/mdio.h:135:#define MDIO_PCS_CTRL1_SPEED25G\t\t(MDIO_CTRL1_SPEEDSELEXT | 0x14)\ninclude/uapi/linux/mdio.h-136-/* 50 Gb/s */\ninclude/uapi/linux/mdio.h:137:#define MDIO_PCS_CTRL1_SPEED50G\t\t(MDIO_CTRL1_SPEEDSELEXT | 0x18)\ninclude/uapi/linux/mdio.h-138-/* 2.5 Gb/s */\ninclude/uapi/linux/mdio.h:139:#define MDIO_PMA_CTRL1_SPEED2_5G\t(MDIO_CTRL1_SPEEDSELEXT | 0x18)\ninclude/uapi/linux/mdio.h-140-/* 5 Gb/s */\ninclude/uapi/linux/mdio.h:141:#define MDIO_PMA_CTRL1_SPEED5G\t\t(MDIO_CTRL1_SPEEDSELEXT | 0x1c)\ninclude/uapi/linux/mdio.h-142-\n--\ninclude/uapi/linux/mdio.h-144-/* Status register 1. */\ninclude/uapi/linux/mdio.h:145:#define MDIO_STAT1_LPOWERABLE\t\t0x0002\t/* Low-power ability */\ninclude/uapi/linux/mdio.h:146:#define MDIO_STAT1_LSTATUS\t\tBMSR_LSTATUS\ninclude/uapi/linux/mdio.h:147:#define MDIO_STAT1_FAULT\t\t0x0080\t/* Fault */\ninclude/uapi/linux/mdio.h:148:#define MDIO_PCS_STAT1_CLKSTOP_CAP\t0x0040\ninclude/uapi/linux/mdio.h:149:#define MDIO_AN_STAT1_LPABLE\t\t0x0001\t/* Link partner AN ability */\ninclude/uapi/linux/mdio.h:150:#define MDIO_AN_STAT1_ABLE\t\tBMSR_ANEGCAPABLE\ninclude/uapi/linux/mdio.h:151:#define MDIO_AN_STAT1_RFAULT\t\tBMSR_RFAULT\ninclude/uapi/linux/mdio.h:152:#define MDIO_AN_STAT1_COMPLETE\t\tBMSR_ANEGCOMPLETE\ninclude/uapi/linux/mdio.h:153:#define MDIO_AN_STAT1_PAGE\t\t0x0040\t/* Page received */\ninclude/uapi/linux/mdio.h:154:#define MDIO_AN_STAT1_XNP\t\t0x0080\t/* Extended next page status */\ninclude/uapi/linux/mdio.h-155-\ninclude/uapi/linux/mdio.h-156-/* Device Identifier 2 */\ninclude/uapi/linux/mdio.h:157:#define MDIO_DEVID2_OUI\t\t\t0xfc00\t/* OUI Portion of PHY ID */\ninclude/uapi/linux/mdio.h:158:#define MDIO_DEVID2_MODEL_NUM\t\t0x03f0\t/* Manufacturer's Model Number */\ninclude/uapi/linux/mdio.h:159:#define MDIO_DEVID2_REV_NUM\t\t0x000f\t/* Revision Number */\ninclude/uapi/linux/mdio.h-160-\ninclude/uapi/linux/mdio.h-161-/* Speed register. */\ninclude/uapi/linux/mdio.h:162:#define MDIO_SPEED_10G\t\t\t0x0001\t/* 10G capable */\ninclude/uapi/linux/mdio.h:163:#define MDIO_PMA_SPEED_2B\t\t0x0002\t/* 2BASE-TL capable */\ninclude/uapi/linux/mdio.h:164:#define MDIO_PMA_SPEED_10P\t\t0x0004\t/* 10PASS-TS capable */\ninclude/uapi/linux/mdio.h:165:#define MDIO_PMA_SPEED_1000\t\t0x0010\t/* 1000M capable */\ninclude/uapi/linux/mdio.h:166:#define MDIO_PMA_SPEED_100\t\t0x0020\t/* 100M capable */\ninclude/uapi/linux/mdio.h:167:#define MDIO_PMA_SPEED_10\t\t0x0040\t/* 10M capable */\ninclude/uapi/linux/mdio.h:168:#define MDIO_PMA_SPEED_2_5G\t\t0x2000\t/* 2.5G capable */\ninclude/uapi/linux/mdio.h:169:#define MDIO_PMA_SPEED_5G\t\t0x4000\t/* 5G capable */\ninclude/uapi/linux/mdio.h:170:#define MDIO_PCS_SPEED_10P2B\t\t0x0002\t/* 10PASS-TS/2BASE-TL capable */\ninclude/uapi/linux/mdio.h:171:#define MDIO_PCS_SPEED_2_5G\t\t0x0040\t/* 2.5G capable */\ninclude/uapi/linux/mdio.h:172:#define MDIO_PCS_SPEED_5G\t\t0x0080\t/* 5G capable */\ninclude/uapi/linux/mdio.h-173-\ninclude/uapi/linux/mdio.h-174-/* Device present registers. */\ninclude/uapi/linux/mdio.h:175:#define MDIO_DEVS_PRESENT(devad)\t(1 \u003c\u003c (devad))\ninclude/uapi/linux/mdio.h:176:#define MDIO_DEVS_C22PRESENT\t\tMDIO_DEVS_PRESENT(0)\ninclude/uapi/linux/mdio.h:177:#define MDIO_DEVS_PMAPMD\t\tMDIO_DEVS_PRESENT(MDIO_MMD_PMAPMD)\ninclude/uapi/linux/mdio.h:178:#define MDIO_DEVS_WIS\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_WIS)\ninclude/uapi/linux/mdio.h:179:#define MDIO_DEVS_PCS\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_PCS)\ninclude/uapi/linux/mdio.h:180:#define MDIO_DEVS_PHYXS\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_PHYXS)\ninclude/uapi/linux/mdio.h:181:#define MDIO_DEVS_DTEXS\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_DTEXS)\ninclude/uapi/linux/mdio.h:182:#define MDIO_DEVS_TC\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_TC)\ninclude/uapi/linux/mdio.h:183:#define MDIO_DEVS_AN\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_AN)\ninclude/uapi/linux/mdio.h:184:#define MDIO_DEVS_SEP_PMA1\t\tMDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA1)\ninclude/uapi/linux/mdio.h:185:#define MDIO_DEVS_SEP_PMA2\t\tMDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA2)\ninclude/uapi/linux/mdio.h:186:#define MDIO_DEVS_SEP_PMA3\t\tMDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA3)\ninclude/uapi/linux/mdio.h:187:#define MDIO_DEVS_SEP_PMA4\t\tMDIO_DEVS_PRESENT(MDIO_MMD_SEP_PMA4)\ninclude/uapi/linux/mdio.h:188:#define MDIO_DEVS_C22EXT\t\tMDIO_DEVS_PRESENT(MDIO_MMD_C22EXT)\ninclude/uapi/linux/mdio.h:189:#define MDIO_DEVS_VEND1\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_VEND1)\ninclude/uapi/linux/mdio.h:190:#define MDIO_DEVS_VEND2\t\t\tMDIO_DEVS_PRESENT(MDIO_MMD_VEND2)\ninclude/uapi/linux/mdio.h-191-\ninclude/uapi/linux/mdio.h-192-/* Control register 2. */\ninclude/uapi/linux/mdio.h:193:#define MDIO_PMA_CTRL2_TYPE\t\t0x000f\t/* PMA/PMD type selection */\ninclude/uapi/linux/mdio.h:194:#define MDIO_PMA_CTRL2_10GBCX4\t\t0x0000\t/* 10GBASE-CX4 type */\ninclude/uapi/linux/mdio.h:195:#define MDIO_PMA_CTRL2_10GBEW\t\t0x0001\t/* 10GBASE-EW type */\ninclude/uapi/linux/mdio.h:196:#define MDIO_PMA_CTRL2_10GBLW\t\t0x0002\t/* 10GBASE-LW type */\ninclude/uapi/linux/mdio.h:197:#define MDIO_PMA_CTRL2_10GBSW\t\t0x0003\t/* 10GBASE-SW type */\ninclude/uapi/linux/mdio.h:198:#define MDIO_PMA_CTRL2_10GBLX4\t\t0x0004\t/* 10GBASE-LX4 type */\ninclude/uapi/linux/mdio.h:199:#define MDIO_PMA_CTRL2_10GBER\t\t0x0005\t/* 10GBASE-ER type */\ninclude/uapi/linux/mdio.h:200:#define MDIO_PMA_CTRL2_10GBLR\t\t0x0006\t/* 10GBASE-LR type */\ninclude/uapi/linux/mdio.h:201:#define MDIO_PMA_CTRL2_10GBSR\t\t0x0007\t/* 10GBASE-SR type */\ninclude/uapi/linux/mdio.h:202:#define MDIO_PMA_CTRL2_10GBLRM\t\t0x0008\t/* 10GBASE-LRM type */\ninclude/uapi/linux/mdio.h:203:#define MDIO_PMA_CTRL2_10GBT\t\t0x0009\t/* 10GBASE-T type */\ninclude/uapi/linux/mdio.h:204:#define MDIO_PMA_CTRL2_10GBKX4\t\t0x000a\t/* 10GBASE-KX4 type */\ninclude/uapi/linux/mdio.h:205:#define MDIO_PMA_CTRL2_10GBKR\t\t0x000b\t/* 10GBASE-KR type */\ninclude/uapi/linux/mdio.h:206:#define MDIO_PMA_CTRL2_1000BT\t\t0x000c\t/* 1000BASE-T type */\ninclude/uapi/linux/mdio.h:207:#define MDIO_PMA_CTRL2_1000BKX\t\t0x000d\t/* 1000BASE-KX type */\ninclude/uapi/linux/mdio.h:208:#define MDIO_PMA_CTRL2_100BTX\t\t0x000e\t/* 100BASE-TX type */\ninclude/uapi/linux/mdio.h:209:#define MDIO_PMA_CTRL2_10BT\t\t0x000f\t/* 10BASE-T type */\ninclude/uapi/linux/mdio.h:210:#define MDIO_PMA_CTRL2_2_5GBT\t\t0x0030  /* 2.5GBaseT type */\ninclude/uapi/linux/mdio.h:211:#define MDIO_PMA_CTRL2_5GBT\t\t0x0031  /* 5GBaseT type */\ninclude/uapi/linux/mdio.h:212:#define MDIO_PMA_CTRL2_BASET1\t\t0x003D  /* BASE-T1 type */\ninclude/uapi/linux/mdio.h:213:#define MDIO_PCS_CTRL2_TYPE\t\t0x0003\t/* PCS type selection */\ninclude/uapi/linux/mdio.h:214:#define MDIO_PCS_CTRL2_10GBR\t\t0x0000\t/* 10GBASE-R type */\ninclude/uapi/linux/mdio.h:215:#define MDIO_PCS_CTRL2_10GBX\t\t0x0001\t/* 10GBASE-X type */\ninclude/uapi/linux/mdio.h:216:#define MDIO_PCS_CTRL2_10GBW\t\t0x0002\t/* 10GBASE-W type */\ninclude/uapi/linux/mdio.h:217:#define MDIO_PCS_CTRL2_10GBT\t\t0x0003\t/* 10GBASE-T type */\ninclude/uapi/linux/mdio.h-218-\ninclude/uapi/linux/mdio.h-219-/* Status register 2. */\ninclude/uapi/linux/mdio.h:220:#define MDIO_STAT2_RXFAULT\t\t0x0400\t/* Receive fault */\ninclude/uapi/linux/mdio.h:221:#define MDIO_STAT2_TXFAULT\t\t0x0800\t/* Transmit fault */\ninclude/uapi/linux/mdio.h:222:#define MDIO_STAT2_DEVPRST\t\t0xc000\t/* Device present */\ninclude/uapi/linux/mdio.h:223:#define MDIO_STAT2_DEVPRST_VAL\t\t0x8000\t/* Device present value */\ninclude/uapi/linux/mdio.h:224:#define MDIO_PMA_STAT2_LBABLE\t\t0x0001\t/* PMA loopback ability */\ninclude/uapi/linux/mdio.h:225:#define MDIO_PMA_STAT2_10GBEW\t\t0x0002\t/* 10GBASE-EW ability */\ninclude/uapi/linux/mdio.h:226:#define MDIO_PMA_STAT2_10GBLW\t\t0x0004\t/* 10GBASE-LW ability */\ninclude/uapi/linux/mdio.h:227:#define MDIO_PMA_STAT2_10GBSW\t\t0x0008\t/* 10GBASE-SW ability */\ninclude/uapi/linux/mdio.h:228:#define MDIO_PMA_STAT2_10GBLX4\t\t0x0010\t/* 10GBASE-LX4 ability */\ninclude/uapi/linux/mdio.h:229:#define MDIO_PMA_STAT2_10GBER\t\t0x0020\t/* 10GBASE-ER ability */\ninclude/uapi/linux/mdio.h:230:#define MDIO_PMA_STAT2_10GBLR\t\t0x0040\t/* 10GBASE-LR ability */\ninclude/uapi/linux/mdio.h:231:#define MDIO_PMA_STAT2_10GBSR\t\t0x0080\t/* 10GBASE-SR ability */\ninclude/uapi/linux/mdio.h:232:#define MDIO_PMD_STAT2_TXDISAB\t\t0x0100\t/* PMD TX disable ability */\ninclude/uapi/linux/mdio.h:233:#define MDIO_PMA_STAT2_EXTABLE\t\t0x0200\t/* Extended abilities */\ninclude/uapi/linux/mdio.h:234:#define MDIO_PMA_STAT2_RXFLTABLE\t0x1000\t/* Receive fault ability */\ninclude/uapi/linux/mdio.h:235:#define MDIO_PMA_STAT2_TXFLTABLE\t0x2000\t/* Transmit fault ability */\ninclude/uapi/linux/mdio.h:236:#define MDIO_PCS_STAT2_10GBR\t\t0x0001\t/* 10GBASE-R capable */\ninclude/uapi/linux/mdio.h:237:#define MDIO_PCS_STAT2_10GBX\t\t0x0002\t/* 10GBASE-X capable */\ninclude/uapi/linux/mdio.h:238:#define MDIO_PCS_STAT2_10GBW\t\t0x0004\t/* 10GBASE-W capable */\ninclude/uapi/linux/mdio.h:239:#define MDIO_PCS_STAT2_RXFLTABLE\t0x1000\t/* Receive fault ability */\ninclude/uapi/linux/mdio.h:240:#define MDIO_PCS_STAT2_TXFLTABLE\t0x2000\t/* Transmit fault ability */\ninclude/uapi/linux/mdio.h-241-\ninclude/uapi/linux/mdio.h-242-/* Transmit disable register. */\ninclude/uapi/linux/mdio.h:243:#define MDIO_PMD_TXDIS_GLOBAL\t\t0x0001\t/* Global PMD TX disable */\ninclude/uapi/linux/mdio.h:244:#define MDIO_PMD_TXDIS_0\t\t0x0002\t/* PMD TX disable 0 */\ninclude/uapi/linux/mdio.h:245:#define MDIO_PMD_TXDIS_1\t\t0x0004\t/* PMD TX disable 1 */\ninclude/uapi/linux/mdio.h:246:#define MDIO_PMD_TXDIS_2\t\t0x0008\t/* PMD TX disable 2 */\ninclude/uapi/linux/mdio.h:247:#define MDIO_PMD_TXDIS_3\t\t0x0010\t/* PMD TX disable 3 */\ninclude/uapi/linux/mdio.h-248-\ninclude/uapi/linux/mdio.h-249-/* Receive signal detect register. */\ninclude/uapi/linux/mdio.h:250:#define MDIO_PMD_RXDET_GLOBAL\t\t0x0001\t/* Global PMD RX signal detect */\ninclude/uapi/linux/mdio.h:251:#define MDIO_PMD_RXDET_0\t\t0x0002\t/* PMD RX signal detect 0 */\ninclude/uapi/linux/mdio.h:252:#define MDIO_PMD_RXDET_1\t\t0x0004\t/* PMD RX signal detect 1 */\ninclude/uapi/linux/mdio.h:253:#define MDIO_PMD_RXDET_2\t\t0x0008\t/* PMD RX signal detect 2 */\ninclude/uapi/linux/mdio.h:254:#define MDIO_PMD_RXDET_3\t\t0x0010\t/* PMD RX signal detect 3 */\ninclude/uapi/linux/mdio.h-255-\ninclude/uapi/linux/mdio.h-256-/* Extended abilities register. */\ninclude/uapi/linux/mdio.h:257:#define MDIO_PMA_EXTABLE_10GCX4\t\t0x0001\t/* 10GBASE-CX4 ability */\ninclude/uapi/linux/mdio.h:258:#define MDIO_PMA_EXTABLE_10GBLRM\t0x0002\t/* 10GBASE-LRM ability */\ninclude/uapi/linux/mdio.h:259:#define MDIO_PMA_EXTABLE_10GBT\t\t0x0004\t/* 10GBASE-T ability */\ninclude/uapi/linux/mdio.h:260:#define MDIO_PMA_EXTABLE_10GBKX4\t0x0008\t/* 10GBASE-KX4 ability */\ninclude/uapi/linux/mdio.h:261:#define MDIO_PMA_EXTABLE_10GBKR\t\t0x0010\t/* 10GBASE-KR ability */\ninclude/uapi/linux/mdio.h:262:#define MDIO_PMA_EXTABLE_1000BT\t\t0x0020\t/* 1000BASE-T ability */\ninclude/uapi/linux/mdio.h:263:#define MDIO_PMA_EXTABLE_1000BKX\t0x0040\t/* 1000BASE-KX ability */\ninclude/uapi/linux/mdio.h:264:#define MDIO_PMA_EXTABLE_100BTX\t\t0x0080\t/* 100BASE-TX ability */\ninclude/uapi/linux/mdio.h:265:#define MDIO_PMA_EXTABLE_10BT\t\t0x0100\t/* 10BASE-T ability */\ninclude/uapi/linux/mdio.h:266:#define MDIO_PMA_EXTABLE_BT1\t\t0x0800\t/* BASE-T1 ability */\ninclude/uapi/linux/mdio.h:267:#define MDIO_PMA_EXTABLE_NBT\t\t0x4000  /* 2.5/5GBASE-T ability */\ninclude/uapi/linux/mdio.h-268-\ninclude/uapi/linux/mdio.h-269-/* AN Clause 73 linkword */\ninclude/uapi/linux/mdio.h:270:#define MDIO_AN_C73_0_S_MASK\t\tGENMASK(4, 0)\ninclude/uapi/linux/mdio.h:271:#define MDIO_AN_C73_0_E_MASK\t\tGENMASK(9, 5)\ninclude/uapi/linux/mdio.h:272:#define MDIO_AN_C73_0_PAUSE\t\tBIT(10)\ninclude/uapi/linux/mdio.h:273:#define MDIO_AN_C73_0_ASM_DIR\t\tBIT(11)\ninclude/uapi/linux/mdio.h:274:#define MDIO_AN_C73_0_C2\t\tBIT(12)\ninclude/uapi/linux/mdio.h:275:#define MDIO_AN_C73_0_RF\t\tBIT(13)\ninclude/uapi/linux/mdio.h:276:#define MDIO_AN_C73_0_ACK\t\tBIT(14)\ninclude/uapi/linux/mdio.h:277:#define MDIO_AN_C73_0_NP\t\tBIT(15)\ninclude/uapi/linux/mdio.h:278:#define MDIO_AN_C73_1_T_MASK\t\tGENMASK(4, 0)\ninclude/uapi/linux/mdio.h:279:#define MDIO_AN_C73_1_1000BASE_KX\tBIT(5)\ninclude/uapi/linux/mdio.h:280:#define MDIO_AN_C73_1_10GBASE_KX4\tBIT(6)\ninclude/uapi/linux/mdio.h:281:#define MDIO_AN_C73_1_10GBASE_KR\tBIT(7)\ninclude/uapi/linux/mdio.h:282:#define MDIO_AN_C73_1_40GBASE_KR4\tBIT(8)\ninclude/uapi/linux/mdio.h:283:#define MDIO_AN_C73_1_40GBASE_CR4\tBIT(9)\ninclude/uapi/linux/mdio.h:284:#define MDIO_AN_C73_1_100GBASE_CR10\tBIT(10)\ninclude/uapi/linux/mdio.h:285:#define MDIO_AN_C73_1_100GBASE_KP4\tBIT(11)\ninclude/uapi/linux/mdio.h:286:#define MDIO_AN_C73_1_100GBASE_KR4\tBIT(12)\ninclude/uapi/linux/mdio.h:287:#define MDIO_AN_C73_1_100GBASE_CR4\tBIT(13)\ninclude/uapi/linux/mdio.h:288:#define MDIO_AN_C73_1_25GBASE_R_S\tBIT(14)\ninclude/uapi/linux/mdio.h:289:#define MDIO_AN_C73_1_25GBASE_R\t\tBIT(15)\ninclude/uapi/linux/mdio.h:290:#define MDIO_AN_C73_2_2500BASE_KX\tBIT(0)\ninclude/uapi/linux/mdio.h:291:#define MDIO_AN_C73_2_5GBASE_KR\t\tBIT(1)\ninclude/uapi/linux/mdio.h-292-\ninclude/uapi/linux/mdio.h-293-/* PHY XGXS lane state register. */\ninclude/uapi/linux/mdio.h:294:#define MDIO_PHYXS_LNSTAT_SYNC0\t\t0x0001\ninclude/uapi/linux/mdio.h:295:#define MDIO_PHYXS_LNSTAT_SYNC1\t\t0x0002\ninclude/uapi/linux/mdio.h:296:#define MDIO_PHYXS_LNSTAT_SYNC2\t\t0x0004\ninclude/uapi/linux/mdio.h:297:#define MDIO_PHYXS_LNSTAT_SYNC3\t\t0x0008\ninclude/uapi/linux/mdio.h:298:#define MDIO_PHYXS_LNSTAT_ALIGN\t\t0x1000\ninclude/uapi/linux/mdio.h-299-\ninclude/uapi/linux/mdio.h-300-/* PMA 10GBASE-T pair swap \u0026 polarity */\ninclude/uapi/linux/mdio.h:301:#define MDIO_PMA_10GBT_SWAPPOL_ABNX\t0x0001\t/* Pair A/B uncrossed */\ninclude/uapi/linux/mdio.h:302:#define MDIO_PMA_10GBT_SWAPPOL_CDNX\t0x0002\t/* Pair C/D uncrossed */\ninclude/uapi/linux/mdio.h:303:#define MDIO_PMA_10GBT_SWAPPOL_AREV\t0x0100\t/* Pair A polarity reversed */\ninclude/uapi/linux/mdio.h:304:#define MDIO_PMA_10GBT_SWAPPOL_BREV\t0x0200\t/* Pair B polarity reversed */\ninclude/uapi/linux/mdio.h:305:#define MDIO_PMA_10GBT_SWAPPOL_CREV\t0x0400\t/* Pair C polarity reversed */\ninclude/uapi/linux/mdio.h:306:#define MDIO_PMA_10GBT_SWAPPOL_DREV\t0x0800\t/* Pair D polarity reversed */\ninclude/uapi/linux/mdio.h-307-\ninclude/uapi/linux/mdio.h-308-/* PMA 10GBASE-T TX power register. */\ninclude/uapi/linux/mdio.h:309:#define MDIO_PMA_10GBT_TXPWR_SHORT\t0x0001\t/* Short-reach mode */\ninclude/uapi/linux/mdio.h-310-\n--\ninclude/uapi/linux/mdio.h-312-/* Value is SNR margin in dB, clamped to range [-127, 127], plus 0x8000. */\ninclude/uapi/linux/mdio.h:313:#define MDIO_PMA_10GBT_SNR_BIAS\t\t0x8000\ninclude/uapi/linux/mdio.h:314:#define MDIO_PMA_10GBT_SNR_MAX\t\t127\ninclude/uapi/linux/mdio.h-315-\ninclude/uapi/linux/mdio.h-316-/* PMA 10GBASE-R FEC ability register. */\ninclude/uapi/linux/mdio.h:317:#define MDIO_PMA_10GBR_FECABLE_ABLE\t0x0001\t/* FEC ability */\ninclude/uapi/linux/mdio.h:318:#define MDIO_PMA_10GBR_FECABLE_ERRABLE\t0x0002\t/* FEC error indic. ability */\ninclude/uapi/linux/mdio.h-319-\ninclude/uapi/linux/mdio.h-320-/* PMA 10GBASE-R Fast Retrain status and control register. */\ninclude/uapi/linux/mdio.h:321:#define MDIO_PMA_10GBR_FSRT_ENABLE\t0x0001\t/* Fast retrain enable */\ninclude/uapi/linux/mdio.h-322-\ninclude/uapi/linux/mdio.h-323-/* PCS 10GBASE-R/-T status register 1. */\ninclude/uapi/linux/mdio.h:324:#define MDIO_PCS_10GBRT_STAT1_BLKLK\t0x0001\t/* Block lock attained */\ninclude/uapi/linux/mdio.h-325-\ninclude/uapi/linux/mdio.h-326-/* PCS 10GBASE-R/-T status register 2. */\ninclude/uapi/linux/mdio.h:327:#define MDIO_PCS_10GBRT_STAT2_ERR\t0x00ff\ninclude/uapi/linux/mdio.h:328:#define MDIO_PCS_10GBRT_STAT2_BER\t0x3f00\ninclude/uapi/linux/mdio.h-329-\ninclude/uapi/linux/mdio.h-330-/* AN 10GBASE-T control register. */\ninclude/uapi/linux/mdio.h:331:#define MDIO_AN_10GBT_CTRL_ADVFSRT2_5G\t0x0020\t/* Advertise 2.5GBASE-T fast retrain */\ninclude/uapi/linux/mdio.h:332:#define MDIO_AN_10GBT_CTRL_ADV2_5G\t0x0080\t/* Advertise 2.5GBASE-T */\ninclude/uapi/linux/mdio.h:333:#define MDIO_AN_10GBT_CTRL_ADV5G\t0x0100\t/* Advertise 5GBASE-T */\ninclude/uapi/linux/mdio.h:334:#define MDIO_AN_10GBT_CTRL_ADV10G\t0x1000\t/* Advertise 10GBASE-T */\ninclude/uapi/linux/mdio.h-335-\ninclude/uapi/linux/mdio.h-336-/* AN 10GBASE-T status register. */\ninclude/uapi/linux/mdio.h:337:#define MDIO_AN_10GBT_STAT_LP2_5G\t0x0020  /* LP is 2.5GBT capable */\ninclude/uapi/linux/mdio.h:338:#define MDIO_AN_10GBT_STAT_LP5G\t\t0x0040  /* LP is 5GBT capable */\ninclude/uapi/linux/mdio.h:339:#define MDIO_AN_10GBT_STAT_LPTRR\t0x0200\t/* LP training reset req. */\ninclude/uapi/linux/mdio.h:340:#define MDIO_AN_10GBT_STAT_LPLTABLE\t0x0400\t/* LP loop timing ability */\ninclude/uapi/linux/mdio.h:341:#define MDIO_AN_10GBT_STAT_LP10G\t0x0800\t/* LP is 10GBT capable */\ninclude/uapi/linux/mdio.h:342:#define MDIO_AN_10GBT_STAT_REMOK\t0x1000\t/* Remote OK */\ninclude/uapi/linux/mdio.h:343:#define MDIO_AN_10GBT_STAT_LOCOK\t0x2000\t/* Local OK */\ninclude/uapi/linux/mdio.h:344:#define MDIO_AN_10GBT_STAT_MS\t\t0x4000\t/* Master/slave config */\ninclude/uapi/linux/mdio.h:345:#define MDIO_AN_10GBT_STAT_MSFLT\t0x8000\t/* Master/slave config fault */\ninclude/uapi/linux/mdio.h-346-\ninclude/uapi/linux/mdio.h-347-/* 10BASE-T1L PMA control */\ninclude/uapi/linux/mdio.h:348:#define MDIO_PMA_10T1L_CTRL_LB_EN\t0x0001\t/* Enable loopback mode */\ninclude/uapi/linux/mdio.h:349:#define MDIO_PMA_10T1L_CTRL_EEE_EN\t0x0400\t/* Enable EEE mode */\ninclude/uapi/linux/mdio.h:350:#define MDIO_PMA_10T1L_CTRL_LOW_POWER\t0x0800\t/* Low-power mode */\ninclude/uapi/linux/mdio.h:351:#define MDIO_PMA_10T1L_CTRL_2V4_EN\t0x1000\t/* Enable 2.4 Vpp operating mode */\ninclude/uapi/linux/mdio.h:352:#define MDIO_PMA_10T1L_CTRL_TX_DIS\t0x4000\t/* Transmit disable */\ninclude/uapi/linux/mdio.h:353:#define MDIO_PMA_10T1L_CTRL_PMA_RST\t0x8000\t/* MA reset */\ninclude/uapi/linux/mdio.h-354-\ninclude/uapi/linux/mdio.h-355-/* 10BASE-T1L PMA status register. */\ninclude/uapi/linux/mdio.h:356:#define MDIO_PMA_10T1L_STAT_LINK\t0x0001\t/* PMA receive link up */\ninclude/uapi/linux/mdio.h:357:#define MDIO_PMA_10T1L_STAT_FAULT\t0x0002\t/* Fault condition detected */\ninclude/uapi/linux/mdio.h:358:#define MDIO_PMA_10T1L_STAT_POLARITY\t0x0004\t/* Receive polarity is reversed */\ninclude/uapi/linux/mdio.h:359:#define MDIO_PMA_10T1L_STAT_RECV_FAULT\t0x0200\t/* Able to detect fault on receive path */\ninclude/uapi/linux/mdio.h:360:#define MDIO_PMA_10T1L_STAT_EEE\t\t0x0400\t/* PHY has EEE ability */\ninclude/uapi/linux/mdio.h:361:#define MDIO_PMA_10T1L_STAT_LOW_POWER\t0x0800\t/* PMA has low-power ability */\ninclude/uapi/linux/mdio.h:362:#define MDIO_PMA_10T1L_STAT_2V4_ABLE\t0x1000\t/* PHY has 2.4 Vpp operating mode ability */\ninclude/uapi/linux/mdio.h:363:#define MDIO_PMA_10T1L_STAT_LB_ABLE\t0x2000\t/* PHY has loopback ability */\ninclude/uapi/linux/mdio.h-364-\ninclude/uapi/linux/mdio.h-365-/* 10BASE-T1L PCS control register. */\ninclude/uapi/linux/mdio.h:366:#define MDIO_PCS_10T1L_CTRL_LB\t\t0x4000\t/* Enable PCS level loopback mode */\ninclude/uapi/linux/mdio.h:367:#define MDIO_PCS_10T1L_CTRL_RESET\t0x8000\t/* PCS reset */\ninclude/uapi/linux/mdio.h-368-\ninclude/uapi/linux/mdio.h-369-/* BASE-T1 PMA/PMD extended ability register. */\ninclude/uapi/linux/mdio.h:370:#define MDIO_PMA_PMD_BT1_B100_ABLE\t0x0001\t/* 100BASE-T1 Ability */\ninclude/uapi/linux/mdio.h:371:#define MDIO_PMA_PMD_BT1_B1000_ABLE\t0x0002\t/* 1000BASE-T1 Ability */\ninclude/uapi/linux/mdio.h:372:#define MDIO_PMA_PMD_BT1_B10L_ABLE\t0x0004\t/* 10BASE-T1L Ability */\ninclude/uapi/linux/mdio.h-373-\ninclude/uapi/linux/mdio.h-374-/* BASE-T1 auto-negotiation advertisement register [15:0] */\ninclude/uapi/linux/mdio.h:375:#define MDIO_AN_T1_ADV_L_PAUSE_CAP\tADVERTISE_PAUSE_CAP\ninclude/uapi/linux/mdio.h:376:#define MDIO_AN_T1_ADV_L_PAUSE_ASYM\tADVERTISE_PAUSE_ASYM\ninclude/uapi/linux/mdio.h:377:#define MDIO_AN_T1_ADV_L_FORCE_MS\t0x1000\t/* Force Master/slave Configuration */\ninclude/uapi/linux/mdio.h:378:#define MDIO_AN_T1_ADV_L_REMOTE_FAULT\tADVERTISE_RFAULT\ninclude/uapi/linux/mdio.h:379:#define MDIO_AN_T1_ADV_L_ACK\t\tADVERTISE_LPACK\ninclude/uapi/linux/mdio.h:380:#define MDIO_AN_T1_ADV_L_NEXT_PAGE_REQ\tADVERTISE_NPAGE\ninclude/uapi/linux/mdio.h-381-\ninclude/uapi/linux/mdio.h-382-/* BASE-T1 auto-negotiation advertisement register [31:16] */\ninclude/uapi/linux/mdio.h:383:#define MDIO_AN_T1_ADV_M_B10L\t\t0x4000\t/* device is compatible with 10BASE-T1L */\ninclude/uapi/linux/mdio.h:384:#define MDIO_AN_T1_ADV_M_1000BT1\t0x0080\t/* advertise 1000BASE-T1 */\ninclude/uapi/linux/mdio.h:385:#define MDIO_AN_T1_ADV_M_100BT1\t\t0x0020\t/* advertise 100BASE-T1 */\ninclude/uapi/linux/mdio.h:386:#define MDIO_AN_T1_ADV_M_MST\t\t0x0010\t/* advertise master preference */\ninclude/uapi/linux/mdio.h-387-\ninclude/uapi/linux/mdio.h-388-/* BASE-T1 auto-negotiation advertisement register [47:32] */\ninclude/uapi/linux/mdio.h:389:#define MDIO_AN_T1_ADV_H_10L_TX_HI_REQ\t0x1000\t/* 10BASE-T1L High Level Transmit Request */\ninclude/uapi/linux/mdio.h:390:#define MDIO_AN_T1_ADV_H_10L_TX_HI\t0x2000\t/* 10BASE-T1L High Level Transmit Ability */\ninclude/uapi/linux/mdio.h-391-\ninclude/uapi/linux/mdio.h-392-/* BASE-T1 AN LP Base Page ability register [15:0] */\ninclude/uapi/linux/mdio.h:393:#define MDIO_AN_T1_LP_L_PAUSE_CAP\tLPA_PAUSE_CAP\ninclude/uapi/linux/mdio.h:394:#define MDIO_AN_T1_LP_L_PAUSE_ASYM\tLPA_PAUSE_ASYM\ninclude/uapi/linux/mdio.h:395:#define MDIO_AN_T1_LP_L_FORCE_MS\t0x1000\t/* LP Force Master/slave Configuration */\ninclude/uapi/linux/mdio.h:396:#define MDIO_AN_T1_LP_L_REMOTE_FAULT\tLPA_RFAULT\ninclude/uapi/linux/mdio.h:397:#define MDIO_AN_T1_LP_L_ACK\t\tLPA_LPACK\ninclude/uapi/linux/mdio.h:398:#define MDIO_AN_T1_LP_L_NEXT_PAGE_REQ\tLPA_NPAGE\ninclude/uapi/linux/mdio.h-399-\ninclude/uapi/linux/mdio.h-400-/* BASE-T1 AN LP Base Page ability register [31:16] */\ninclude/uapi/linux/mdio.h:401:#define MDIO_AN_T1_LP_M_MST\t\t0x0010\t/* LP master preference */\ninclude/uapi/linux/mdio.h:402:#define MDIO_AN_T1_LP_M_B10L\t\t0x4000\t/* LP is compatible with 10BASE-T1L */\ninclude/uapi/linux/mdio.h-403-\ninclude/uapi/linux/mdio.h-404-/* BASE-T1 AN LP Base Page ability register [47:32] */\ninclude/uapi/linux/mdio.h:405:#define MDIO_AN_T1_LP_H_10L_TX_HI_REQ\t0x1000\t/* 10BASE-T1L High Level LP Transmit Request */\ninclude/uapi/linux/mdio.h:406:#define MDIO_AN_T1_LP_H_10L_TX_HI\t0x2000\t/* 10BASE-T1L High Level LP Transmit Ability */\ninclude/uapi/linux/mdio.h-407-\ninclude/uapi/linux/mdio.h-408-/* 10BASE-T1 AN control register */\ninclude/uapi/linux/mdio.h:409:#define MDIO_AN_10BT1_AN_CTRL_ADV_EEE_T1L\t0x4000 /* 10BASE-T1L EEE ability advertisement */\ninclude/uapi/linux/mdio.h-410-\ninclude/uapi/linux/mdio.h-411-/* 10BASE-T1 AN status register */\ninclude/uapi/linux/mdio.h:412:#define MDIO_AN_10BT1_AN_STAT_LPA_EEE_T1L\t0x4000 /* 10BASE-T1L LP EEE ability advertisement */\ninclude/uapi/linux/mdio.h-413-\ninclude/uapi/linux/mdio.h-414-/* BASE-T1 PMA/PMD control register */\ninclude/uapi/linux/mdio.h:415:#define MDIO_PMA_PMD_BT1_CTRL_STRAP\t\t0x000F /* Type selection (Strap) */\ninclude/uapi/linux/mdio.h:416:#define MDIO_PMA_PMD_BT1_CTRL_STRAP_B1000\t0x0001 /* Select 1000BASE-T1 */\ninclude/uapi/linux/mdio.h:417:#define MDIO_PMA_PMD_BT1_CTRL_CFG_MST\t\t0x4000 /* MASTER-SLAVE config value */\ninclude/uapi/linux/mdio.h-418-\ninclude/uapi/linux/mdio.h-419-/* 1000BASE-T1 PCS control register */\ninclude/uapi/linux/mdio.h:420:#define MDIO_PCS_1000BT1_CTRL_LOW_POWER\t\t0x0800 /* Low power mode */\ninclude/uapi/linux/mdio.h:421:#define MDIO_PCS_1000BT1_CTRL_DISABLE_TX\t0x4000 /* Global PMA transmit disable */\ninclude/uapi/linux/mdio.h:422:#define MDIO_PCS_1000BT1_CTRL_RESET\t\t0x8000 /* Software reset value */\ninclude/uapi/linux/mdio.h-423-\ninclude/uapi/linux/mdio.h-424-/* 1000BASE-T1 PCS status register */\ninclude/uapi/linux/mdio.h:425:#define MDIO_PCS_1000BT1_STAT_LINK\t0x0004 /* PCS Link is up */\ninclude/uapi/linux/mdio.h:426:#define MDIO_PCS_1000BT1_STAT_FAULT\t0x0080 /* There is a fault condition */\ninclude/uapi/linux/mdio.h-427-\n--\ninclude/uapi/linux/mdio.h-434- */\ninclude/uapi/linux/mdio.h:435:#define MDIO_AN_EEE_ADV_100TX\t0x0002\t/* Advertise 100TX EEE cap */\ninclude/uapi/linux/mdio.h:436:#define MDIO_AN_EEE_ADV_1000T\t0x0004\t/* Advertise 1000T EEE cap */\ninclude/uapi/linux/mdio.h-437-/* Note: the two defines above can be potentially used by the user-land\ninclude/uapi/linux/mdio.h-438- * and cannot remove them now.\ninclude/uapi/linux/mdio.h:439: * So, we define the new generic MDIO_EEE_100TX and MDIO_EEE_1000T macros\ninclude/uapi/linux/mdio.h-440- * using the previous ones (that can be considered obsolete).\ninclude/uapi/linux/mdio.h-441- */\ninclude/uapi/linux/mdio.h:442:#define MDIO_EEE_100TX\t\tMDIO_AN_EEE_ADV_100TX\t/* 100TX EEE cap */\ninclude/uapi/linux/mdio.h:443:#define MDIO_EEE_1000T\t\tMDIO_AN_EEE_ADV_1000T\t/* 1000T EEE cap */\ninclude/uapi/linux/mdio.h:444:#define MDIO_EEE_10GT\t\t0x0008\t/* 10GT EEE cap */\ninclude/uapi/linux/mdio.h:445:#define MDIO_EEE_1000KX\t\t0x0010\t/* 1000KX EEE cap */\ninclude/uapi/linux/mdio.h:446:#define MDIO_EEE_10GKX4\t\t0x0020\t/* 10G KX4 EEE cap */\ninclude/uapi/linux/mdio.h:447:#define MDIO_EEE_10GKR\t\t0x0040\t/* 10G KR EEE cap */\ninclude/uapi/linux/mdio.h:448:#define MDIO_EEE_40GR_FW\t0x0100\t/* 40G R fast wake */\ninclude/uapi/linux/mdio.h:449:#define MDIO_EEE_40GR_DS\t0x0200\t/* 40G R deep sleep */\ninclude/uapi/linux/mdio.h:450:#define MDIO_EEE_100GR_FW\t0x1000\t/* 100G R fast wake */\ninclude/uapi/linux/mdio.h:451:#define MDIO_EEE_100GR_DS\t0x2000\t/* 100G R deep sleep */\ninclude/uapi/linux/mdio.h-452-\ninclude/uapi/linux/mdio.h:453:#define MDIO_EEE_2_5GT\t\t0x0001\t/* 2.5GT EEE cap */\ninclude/uapi/linux/mdio.h:454:#define MDIO_EEE_5GT\t\t0x0002\t/* 5GT EEE cap */\ninclude/uapi/linux/mdio.h-455-\ninclude/uapi/linux/mdio.h-456-/* AN MultiGBASE-T AN control 2 */\ninclude/uapi/linux/mdio.h:457:#define MDIO_AN_THP_BP2_5GT\t0x0008\t/* 2.5GT THP bypass request */\ninclude/uapi/linux/mdio.h-458-\ninclude/uapi/linux/mdio.h-459-/* 2.5G/5G Extended abilities register. */\ninclude/uapi/linux/mdio.h:460:#define MDIO_PMA_NG_EXTABLE_2_5GBT\t0x0001\t/* 2.5GBASET ability */\ninclude/uapi/linux/mdio.h:461:#define MDIO_PMA_NG_EXTABLE_5GBT\t0x0002\t/* 5GBASET ability */\ninclude/uapi/linux/mdio.h-462-\ninclude/uapi/linux/mdio.h-463-/* LASI RX_ALARM control/status registers. */\ninclude/uapi/linux/mdio.h:464:#define MDIO_PMA_LASI_RX_PHYXSLFLT\t0x0001\t/* PHY XS RX local fault */\ninclude/uapi/linux/mdio.h:465:#define MDIO_PMA_LASI_RX_PCSLFLT\t0x0008\t/* PCS RX local fault */\ninclude/uapi/linux/mdio.h:466:#define MDIO_PMA_LASI_RX_PMALFLT\t0x0010\t/* PMA/PMD RX local fault */\ninclude/uapi/linux/mdio.h:467:#define MDIO_PMA_LASI_RX_OPTICPOWERFLT\t0x0020\t/* RX optical power fault */\ninclude/uapi/linux/mdio.h:468:#define MDIO_PMA_LASI_RX_WISLFLT\t0x0200\t/* WIS local fault */\ninclude/uapi/linux/mdio.h-469-\ninclude/uapi/linux/mdio.h-470-/* LASI TX_ALARM control/status registers. */\ninclude/uapi/linux/mdio.h:471:#define MDIO_PMA_LASI_TX_PHYXSLFLT\t0x0001\t/* PHY XS TX local fault */\ninclude/uapi/linux/mdio.h:472:#define MDIO_PMA_LASI_TX_PCSLFLT\t0x0008\t/* PCS TX local fault */\ninclude/uapi/linux/mdio.h:473:#define MDIO_PMA_LASI_TX_PMALFLT\t0x0010\t/* PMA/PMD TX local fault */\ninclude/uapi/linux/mdio.h:474:#define MDIO_PMA_LASI_TX_LASERPOWERFLT\t0x0080\t/* Laser output power fault */\ninclude/uapi/linux/mdio.h:475:#define MDIO_PMA_LASI_TX_LASERTEMPFLT\t0x0100\t/* Laser temperature fault */\ninclude/uapi/linux/mdio.h:476:#define MDIO_PMA_LASI_TX_LASERBICURRFLT\t0x0200\t/* Laser bias current fault */\ninclude/uapi/linux/mdio.h-477-\ninclude/uapi/linux/mdio.h-478-/* LASI control/status registers. */\ninclude/uapi/linux/mdio.h:479:#define MDIO_PMA_LASI_LSALARM\t\t0x0001\t/* LS_ALARM enable/status */\ninclude/uapi/linux/mdio.h:480:#define MDIO_PMA_LASI_TXALARM\t\t0x0002\t/* TX_ALARM enable/status */\ninclude/uapi/linux/mdio.h:481:#define MDIO_PMA_LASI_RXALARM\t\t0x0004\t/* RX_ALARM enable/status */\ninclude/uapi/linux/mdio.h-482-\ninclude/uapi/linux/mdio.h:483:/* Mapping between MDIO PRTAD/DEVAD and mii_ioctl_data::phy_id */\ninclude/uapi/linux/mdio.h-484-\n\n"
}

31/2 2026/07/03 09:05 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 58757
							output: 32
							thoughts: 198
						

Thoughts:
**Investigating the Missing MDIO Device Connection**

Okay, so I'm trying to figure out why I can't reach this `mv88e6xxx` device. Right, there's no direct `ioctl` to add MDIO devices, which is a problem. That immediately blocks the obvious path. So, I need to look at alternatives. My first thought is to dig into `tag_dsa.c`. It's a key part of the DSA framework, so that seems like a good place to start.

Now, my next thought - are there any *other* drivers, besides the `mv88e6xxx`, that actually *use* `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA`? I remember we did a grep already, right? And, I'm pretty sure that just the `mv88e6xxx` driver came up. Okay, that's important context.

Wait a second... a new idea just hit me. What if someone is trying to use netlink to modify the tag protocol of a DSA switch to `dsa` or `edsa`? That would be a potential point of entry! I checked `dsa_loop` and `change_tag_protocol` isn't implemented. It returns `-EOPNOTSUPP`. That's not the path either.

Okay, so, is there *any* other DSA switch that *can* be instantiated and that *allows* changing its tag protocol? I need to think this through. The obvious answer isn't working, I have to consider all the pieces of the puzzle and look for other configurations. Let's see... what about the possibility of any other *software* DSA switches? That's what I need to investigate.



32/2 2026/07/03 09:05 tool grepper
0m Args:
{
  "Expression": "dsa_switch_ops",
  "PathPrefix": "drivers/net/dsa"
}

Results:
{
  "Output": "drivers/net/dsa/b53/b53_common.c=2694=static const struct phylink_mac_ops b53_phylink_mac_ops = {\n--\ndrivers/net/dsa/b53/b53_common.c-2700-\ndrivers/net/dsa/b53/b53_common.c:2701:static const struct dsa_switch_ops b53_switch_ops = {\ndrivers/net/dsa/b53/b53_common.c-2702-\t.get_tag_protocol\t= b53_get_tag_protocol,\n--\ndrivers/net/dsa/bcm_sf2.c=1216=static const struct phylink_mac_ops bcm_sf2_phylink_mac_ops = {\n--\ndrivers/net/dsa/bcm_sf2.c-1221-\ndrivers/net/dsa/bcm_sf2.c:1222:static const struct dsa_switch_ops bcm_sf2_ops = {\ndrivers/net/dsa/bcm_sf2.c-1223-\t.get_tag_protocol\t= b53_get_tag_protocol,\n--\ndrivers/net/dsa/bcm_sf2.c=1365=static int bcm_sf2_sw_probe(struct platform_device *pdev)\n--\ndrivers/net/dsa/bcm_sf2.c-1371-\tstruct b53_platform_data *pdata;\ndrivers/net/dsa/bcm_sf2.c:1372:\tstruct dsa_switch_ops *ops;\ndrivers/net/dsa/bcm_sf2.c-1373-\tstruct device_node *ports;\n--\ndrivers/net/dsa/dsa_loop.c=326=static void dsa_loop_phylink_get_caps(struct dsa_switch *dsa, int port,\n--\ndrivers/net/dsa/dsa_loop.c-333-\ndrivers/net/dsa/dsa_loop.c:334:static const struct dsa_switch_ops dsa_loop_driver = {\ndrivers/net/dsa/dsa_loop.c-335-\t.get_tag_protocol\t= dsa_loop_get_protocol,\n--\ndrivers/net/dsa/hirschmann/hellcreek.c=1872=static int hellcreek_port_setup_tc(struct dsa_switch *ds, int port,\n--\ndrivers/net/dsa/hirschmann/hellcreek.c-1899-\ndrivers/net/dsa/hirschmann/hellcreek.c:1900:static const struct dsa_switch_ops hellcreek_ds_ops = {\ndrivers/net/dsa/hirschmann/hellcreek.c-1901-\t.devlink_info_get      = hellcreek_devlink_info_get,\n--\ndrivers/net/dsa/ks8995.c=727=static int ks8995_get_max_mtu(struct dsa_switch *ds, int port)\n--\ndrivers/net/dsa/ks8995.c-731-\ndrivers/net/dsa/ks8995.c:732:static const struct dsa_switch_ops ks8995_ds_ops = {\ndrivers/net/dsa/ks8995.c-733-\t.get_tag_protocol = ks8995_get_tag_protocol,\n--\ndrivers/net/dsa/lan9303-core.c=1376=static const struct phylink_mac_ops lan9303_phylink_mac_ops = {\n--\ndrivers/net/dsa/lan9303-core.c-1381-\ndrivers/net/dsa/lan9303-core.c:1382:static const struct dsa_switch_ops lan9303_switch_ops = {\ndrivers/net/dsa/lan9303-core.c-1383-\t.get_tag_protocol\t= lan9303_get_tag_protocol,\n--\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c=1614=static const struct phylink_mac_ops gswip_phylink_mac_ops = {\n--\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c-1622-\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c:1623:static const struct dsa_switch_ops gswip_switch_ops = {\ndrivers/net/dsa/lantiq/lantiq_gswip_common.c-1624-\t.get_tag_protocol\t= gswip_get_tag_protocol,\n--\ndrivers/net/dsa/microchip/ksz8.c=2512=const struct ksz_dev_ops ksz88xx_dev_ops = {\n--\ndrivers/net/dsa/microchip/ksz8.c-2525-\ndrivers/net/dsa/microchip/ksz8.c:2526:const struct dsa_switch_ops ksz8463_switch_ops = {\ndrivers/net/dsa/microchip/ksz8.c-2527-\t.get_tag_protocol\t= ksz8463_get_tag_protocol,\n--\ndrivers/net/dsa/microchip/ksz8.c-2572-\ndrivers/net/dsa/microchip/ksz8.c:2573:const struct dsa_switch_ops ksz87xx_switch_ops = {\ndrivers/net/dsa/microchip/ksz8.c-2574-\t.get_tag_protocol\t= ksz87xx_get_tag_protocol,\n--\ndrivers/net/dsa/microchip/ksz8.c-2622-\ndrivers/net/dsa/microchip/ksz8.c:2623:const struct dsa_switch_ops ksz88xx_switch_ops = {\ndrivers/net/dsa/microchip/ksz8.c-2624-\t.get_tag_protocol\t= ksz88xx_get_tag_protocol,\n--\ndrivers/net/dsa/microchip/ksz8.h=19=extern const struct phylink_mac_ops ksz8_phylink_mac_ops;\ndrivers/net/dsa/microchip/ksz8.h:20:extern const struct dsa_switch_ops ksz8463_switch_ops;\ndrivers/net/dsa/microchip/ksz8.h:21:extern const struct dsa_switch_ops ksz87xx_switch_ops;\ndrivers/net/dsa/microchip/ksz8.h:22:extern const struct dsa_switch_ops ksz88xx_switch_ops;\ndrivers/net/dsa/microchip/ksz8.h-23-\n--\ndrivers/net/dsa/microchip/ksz9477.c=2050=const struct ksz_dev_ops ksz9477_dev_ops = {\n--\ndrivers/net/dsa/microchip/ksz9477.c-2064-\ndrivers/net/dsa/microchip/ksz9477.c:2065:const struct dsa_switch_ops ksz9477_switch_ops = {\ndrivers/net/dsa/microchip/ksz9477.c-2066-\t.get_tag_protocol\t= ksz9477_get_tag_protocol,\n--\ndrivers/net/dsa/microchip/ksz9477.h=93=extern const struct phylink_mac_ops ksz9477_phylink_mac_ops;\ndrivers/net/dsa/microchip/ksz9477.h:94:extern const struct dsa_switch_ops ksz9477_switch_ops;\ndrivers/net/dsa/microchip/ksz9477.h-95-\n--\ndrivers/net/dsa/microchip/ksz_common.h=57=struct ksz_chip_data {\n--\ndrivers/net/dsa/microchip/ksz_common.h-75-\tconst struct ksz_dev_ops *ops;\ndrivers/net/dsa/microchip/ksz_common.h:76:\tconst struct dsa_switch_ops *switch_ops;\ndrivers/net/dsa/microchip/ksz_common.h-77-\tconst struct phylink_mac_ops *phylink_mac_ops;\n--\ndrivers/net/dsa/microchip/lan937x.h=10=extern const struct phylink_mac_ops lan937x_phylink_mac_ops;\ndrivers/net/dsa/microchip/lan937x.h:11:extern const struct dsa_switch_ops lan937x_switch_ops;\ndrivers/net/dsa/microchip/lan937x.h-12-\n--\ndrivers/net/dsa/microchip/lan937x_main.c=941=const struct ksz_dev_ops lan937x_dev_ops = {\n--\ndrivers/net/dsa/microchip/lan937x_main.c-952-\ndrivers/net/dsa/microchip/lan937x_main.c:953:const struct dsa_switch_ops lan937x_switch_ops = {\ndrivers/net/dsa/microchip/lan937x_main.c-954-\t.get_tag_protocol\t= lan937x_get_tag_protocol,\n--\ndrivers/net/dsa/mt7530.c=3322=static int mt7988_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/mt7530.c-3347-\ndrivers/net/dsa/mt7530.c:3348:static const struct dsa_switch_ops mt7530_switch_ops = {\ndrivers/net/dsa/mt7530.c-3349-\t.get_tag_protocol\t= mtk_get_tag_protocol,\n--\ndrivers/net/dsa/mv88e6060.c=250=static void mv88e6060_phylink_get_caps(struct dsa_switch *ds, int port,\n--\ndrivers/net/dsa/mv88e6060.c-293-\ndrivers/net/dsa/mv88e6060.c:294:static const struct dsa_switch_ops mv88e6060_switch_ops = {\ndrivers/net/dsa/mv88e6060.c-295-\t.get_tag_protocol = mv88e6060_get_tag_protocol,\n--\ndrivers/net/dsa/mv88e6xxx/chip.c=7222=static const struct phylink_mac_ops mv88e6xxx_phylink_mac_ops = {\n--\ndrivers/net/dsa/mv88e6xxx/chip.c-7230-\ndrivers/net/dsa/mv88e6xxx/chip.c:7231:static const struct dsa_switch_ops mv88e6xxx_switch_ops = {\ndrivers/net/dsa/mv88e6xxx/chip.c-7232-\t.get_tag_protocol\t= mv88e6xxx_get_tag_protocol,\n--\ndrivers/net/dsa/mxl862xx/mxl862xx.c=2026=static void mxl862xx_get_stats64(struct dsa_switch *ds, int port,\n--\ndrivers/net/dsa/mxl862xx/mxl862xx.c-2056-\ndrivers/net/dsa/mxl862xx/mxl862xx.c:2057:static const struct dsa_switch_ops mxl862xx_switch_ops = {\ndrivers/net/dsa/mxl862xx/mxl862xx.c-2058-\t.get_tag_protocol = mxl862xx_get_tag_protocol,\n--\ndrivers/net/dsa/netc/netc_main.c=2397=static const struct phylink_mac_ops netc_phylink_mac_ops = {\n--\ndrivers/net/dsa/netc/netc_main.c-2402-\ndrivers/net/dsa/netc/netc_main.c:2403:static const struct dsa_switch_ops netc_switch_ops = {\ndrivers/net/dsa/netc/netc_main.c-2404-\t.get_tag_protocol\t\t= netc_get_tag_protocol,\n--\ndrivers/net/dsa/ocelot/felix.c=2299=static const struct phylink_mac_ops felix_phylink_mac_ops = {\n--\ndrivers/net/dsa/ocelot/felix.c-2305-\ndrivers/net/dsa/ocelot/felix.c:2306:static const struct dsa_switch_ops felix_switch_ops = {\ndrivers/net/dsa/ocelot/felix.c-2307-\t.get_tag_protocol\t\t= felix_get_tag_protocol,\n--\ndrivers/net/dsa/qca/ar9331.c=238=struct ar9331_sw_priv {\n--\ndrivers/net/dsa/qca/ar9331.c-240-\tstruct dsa_switch ds;\ndrivers/net/dsa/qca/ar9331.c:241:\tstruct dsa_switch_ops ops;\ndrivers/net/dsa/qca/ar9331.c-242-\tstruct irq_domain *irqdomain;\n--\ndrivers/net/dsa/qca/ar9331.c=690=static const struct phylink_mac_ops ar9331_phylink_mac_ops = {\n--\ndrivers/net/dsa/qca/ar9331.c-695-\ndrivers/net/dsa/qca/ar9331.c:696:static const struct dsa_switch_ops ar9331_sw_ops = {\ndrivers/net/dsa/qca/ar9331.c-697-\t.get_tag_protocol\t= ar9331_sw_get_tag_protocol,\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c=2014=static const struct phylink_mac_ops qca8k_phylink_mac_ops = {\n--\ndrivers/net/dsa/qca/qca8k-8xxx.c-2020-\ndrivers/net/dsa/qca/qca8k-8xxx.c:2021:static const struct dsa_switch_ops qca8k_switch_ops = {\ndrivers/net/dsa/qca/qca8k-8xxx.c-2022-\t.get_tag_protocol\t= qca8k_get_tag_protocol,\n--\ndrivers/net/dsa/realtek/realtek.h=161=struct realtek_variant {\ndrivers/net/dsa/realtek/realtek.h:162:\tconst struct dsa_switch_ops *ds_ops;\ndrivers/net/dsa/realtek/realtek.h-163-\tconst struct realtek_ops *ops;\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=2660=static const struct phylink_mac_ops rtl8365mb_phylink_mac_ops = {\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-2665-\ndrivers/net/dsa/realtek/rtl8365mb_main.c:2666:static const struct dsa_switch_ops rtl8365mb_switch_ops = {\ndrivers/net/dsa/realtek/rtl8365mb_main.c-2667-\t.get_tag_protocol = rtl8365mb_get_tag_protocol,\n--\ndrivers/net/dsa/realtek/rtl8366rb.c=1782=static const struct phylink_mac_ops rtl8366rb_phylink_mac_ops = {\n--\ndrivers/net/dsa/realtek/rtl8366rb.c-1787-\ndrivers/net/dsa/realtek/rtl8366rb.c:1788:static const struct dsa_switch_ops rtl8366rb_switch_ops = {\ndrivers/net/dsa/realtek/rtl8366rb.c-1789-\t.get_tag_protocol = rtl8366_get_tag_protocol,\n--\ndrivers/net/dsa/rzn1_a5psw.c=1004=static const struct phylink_mac_ops a5psw_phylink_mac_ops = {\n--\ndrivers/net/dsa/rzn1_a5psw.c-1010-\ndrivers/net/dsa/rzn1_a5psw.c:1011:static const struct dsa_switch_ops a5psw_switch_ops = {\ndrivers/net/dsa/rzn1_a5psw.c-1012-\t.get_tag_protocol = a5psw_get_tag_protocol,\n--\ndrivers/net/dsa/sja1105/sja1105_main.c=3136=static const struct phylink_mac_ops sja1105_phylink_mac_ops = {\n--\ndrivers/net/dsa/sja1105/sja1105_main.c-3142-\ndrivers/net/dsa/sja1105/sja1105_main.c:3143:static const struct dsa_switch_ops sja1105_switch_ops = {\ndrivers/net/dsa/sja1105/sja1105_main.c-3144-\t.get_tag_protocol\t= sja1105_get_tag_protocol,\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c=2212=static const struct phylink_mac_ops vsc73xx_phylink_mac_ops = {\n--\ndrivers/net/dsa/vitesse-vsc73xx-core.c-2217-\ndrivers/net/dsa/vitesse-vsc73xx-core.c:2218:static const struct dsa_switch_ops vsc73xx_ds_ops = {\ndrivers/net/dsa/vitesse-vsc73xx-core.c-2219-\t.get_tag_protocol = vsc73xx_get_tag_protocol,\n--\ndrivers/net/dsa/xrs700x/xrs700x.c=723=static const struct phylink_mac_ops xrs700x_phylink_mac_ops = {\n--\ndrivers/net/dsa/xrs700x/xrs700x.c-728-\ndrivers/net/dsa/xrs700x/xrs700x.c:729:static const struct dsa_switch_ops xrs700x_ops = {\ndrivers/net/dsa/xrs700x/xrs700x.c-730-\t.get_tag_protocol\t= xrs700x_get_tag_protocol,\n--\ndrivers/net/dsa/yt921x.c=4792=static const struct phylink_mac_ops yt921x_phylink_mac_ops = {\n--\ndrivers/net/dsa/yt921x.c-4797-\ndrivers/net/dsa/yt921x.c:4798:static const struct dsa_switch_ops yt921x_dsa_switch_ops = {\ndrivers/net/dsa/yt921x.c-4799-\t/* mib */\n--\ndrivers/net/dsa/yt921x.c=4914=static int yt921x_mdio_probe(struct mdio_device *mdiodev)\n--\ndrivers/net/dsa/yt921x.c-4949-\tds-\u003epriv = priv;\ndrivers/net/dsa/yt921x.c:4950:\tds-\u003eops = \u0026yt921x_dsa_switch_ops;\ndrivers/net/dsa/yt921x.c-4951-\tds-\u003eageing_time_min = 1 * 5000;\n"
}

33/2 2026/07/03 09:05 llm patch-evaluator
0m Model:
gemini-3.1-pro-preview

Args:
null

Results:
null

Tokens:
							input: 64702
							output: 168
							thoughts: 968
						

Thoughts:
**Unreachable Code Analysis: Determining Fuzzing Worthiness**

Okay, let's break this down. My analysis shows that all the code modifications in this patch are, effectively, dead code in virtualized environments. I've walked through the potential pathways and found no practical way to reach the target code.

Specifically, the core issue revolves around the `mv88e6xxx` hardware switch driver. Everything here hinges on this driver and the `tag_dsa.c` code that directly supports it. However, after careful consideration, it appears I can't instantiate the `mv88e6xxx` driver in a virtualized environment. The driver expects specific MDIO hardware that I can't emulate or inject.

I investigated `dsa_loop`, which is the only software switch, and discovered it's hardcoded to a protocol that means the new RMU support in `tag_dsa.c` will never be used. I confirmed that the DSA conduit interfaces are registered by the DSA switch driver. Since the `mv88e6xxx` driver won't probe, there will be no conduit. I thoroughly checked for other possible instantiations of `mv88e6xxx`, such as PCI or USB, but no luck.

The other modifications, such as those related to `chip.c`, `global1.c`, `devlink.c`, and `ptp.c` are all specific to the `mv88e6xxx` driver, and thus equally unreachable.

In short, there's no way to trigger the added RMU support or related changes without the physical `mv88e6xxx` hardware. Therefore, these changes are not worth fuzzing in a virtualized environment. I will return `WorthFuzzing=false` and provide detailed explanation of the reasons. Then I will set the results.



34/2 2026/07/03 09:05 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch adds Remote Management Unit (RMU) support to the Marvell 88E6xxx DSA switch driver. The changes are entirely contained within the hardware-specific `mv88e6xxx` driver and its associated DSA tagger (`tag_dsa.c`). Since the Marvell 88E6xxx is a hardware switch that cannot be emulated in virtualized environments like QEMU/GCE, and no software DSA switch (like `dsa_loop`) uses the `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA` tag protocols, these code paths are completely unreachable during fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch adds Remote Management Unit (RMU) support to the Marvell 88E6xxx DSA switch driver. The changes are entirely contained within the hardware-specific `mv88e6xxx` driver and its associated DSA tagger (`tag_dsa.c`). Since the Marvell 88E6xxx is a hardware switch that cannot be emulated in virtualized environments like QEMU/GCE, and no software DSA switch (like `dsa_loop`) uses the `DSA_TAG_PROTO_DSA` or `DSA_TAG_PROTO_EDSA` tag protocols, these code paths are completely unreachable during fuzzing.",
  "WorthFuzzing": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)