| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/10 20:14 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch series adds support for the Realtek RTL8367S-VB Ethernet switch (family D) to the Realtek RTL8365MB DSA switch driver (drivers/net/dsa/realtek/). This driver requires a physical Realtek switch ASIC controlled via MDIO or SMI (GPIO bitbang) and instantiated through Device Tree. Because the hardware is not emulated in standard virtualized fuzzing environments (QEMU or GCE), the modified code is structurally unreachable.",
"WorthFuzzing": false
} |
| 1/1 | 2026/10/10 20:14 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 22407d15ad3a0de6fff85a5f057352aa04b58709\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Oct 10 20:14:04 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/devicetree/bindings/net/dsa/realtek.yaml b/Documentation/devicetree/bindings/net/dsa/realtek.yaml\nindex b7bb60af623ca..e330dc649adda 100644\n--- a/Documentation/devicetree/bindings/net/dsa/realtek.yaml\n+++ b/Documentation/devicetree/bindings/net/dsa/realtek.yaml\n@@ -57,7 +57,7 @@ properties:\n realtek,rtl8365mb:\n Use with models RTL8363NB, RTL8363NB-VB, RTL8363SC, RTL8363SC-VB,\n RTL8364NB, RTL8364NB-VB, RTL8365MB, RTL8366SC, RTL8367RB-VB, RTL8367S,\n- RTL8367SB, RTL8370MB, RTL8310SR\n+ RTL8367S-VB, RTL8367SB, RTL8370MB, RTL8310SR\n realtek,rtl8366rb:\n Use with models RTL8366RB, RTL8366S\n \ndiff --git a/drivers/net/dsa/realtek/rtl8365mb.h b/drivers/net/dsa/realtek/rtl8365mb.h\nnew file mode 100644\nindex 0000000000000..315de4c93c446\n--- /dev/null\n+++ b/drivers/net/dsa/realtek/rtl8365mb.h\n@@ -0,0 +1,14 @@\n+/* SPDX-License-Identifier: GPL-2.0 */\n+#ifndef _RTL8365MB_H\n+#define _RTL8365MB_H\n+\n+#include \"realtek.h\"\n+\n+enum rtl8365mb_family {\n+\tRTL8365MB_FAMILY_C,\n+\tRTL8365MB_FAMILY_D,\n+};\n+\n+enum rtl8365mb_family rtl8365mb_get_family(struct realtek_priv *priv);\n+\n+#endif /* _RTL8365MB_H */\ndiff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c\nindex da06f952a053d..c6045607ade06 100644\n--- a/drivers/net/dsa/realtek/rtl8365mb_main.c\n+++ b/drivers/net/dsa/realtek/rtl8365mb_main.c\n@@ -89,6 +89,12 @@\n * things will work out-of-the-box for other chips, and a careful review of the\n * vendor driver may be needed to expand support. The RTL8365MB-VC seems to be\n * one of the simpler chips.\n+ *\n+ * The RTL8367S-VB (chip ID 0x6642) is not part of the family listed above. It\n+ * belongs to a newer generation, which this driver calls family D. Its\n+ * registers differ in the VLAN table, the external interface speed and RGMII\n+ * configuration and the SerDes, so the code paths specific to it are selected\n+ * with rtl8365mb_get_family().\n */\n \n #include \u003clinux/bitfield.h\u003e\n@@ -97,6 +103,7 @@\n #include \u003clinux/irqdomain.h\u003e\n #include \u003clinux/mii.h\u003e\n #include \u003clinux/mutex.h\u003e\n+#include \u003clinux/workqueue.h\u003e\n #include \u003clinux/of_irq.h\u003e\n #include \u003clinux/regmap.h\u003e\n #include \u003clinux/if_bridge.h\u003e\n@@ -110,15 +117,17 @@\n #include \"rtl83xx.h\"\n #include \"rtl8365mb_l2.h\"\n #include \"rtl8365mb_vlan.h\"\n+#include \"rtl8365mb.h\"\n \n /* Family-specific data and limits */\n #define RTL8365MB_PHYADDRMAX\t\t7\n #define RTL8365MB_NUM_PHYREGS\t\t32\n #define RTL8365MB_PHYREGMAX\t\t(RTL8365MB_NUM_PHYREGS - 1)\n #define RTL8365MB_MAX_NUM_PORTS\t\t11\n-/* Valid for the whole family except RTL8370B, which has 4160 entries.\n- * RTL8370B is mentioned in vendor code but it might not even belong\n- * to the same RTL8367C family.\n+#define RTL8365MB_D_MAX_NUM_PORTS\t8\n+/* Valid for the whole RTL8367C family (and for family D, RTL8367S-VB)\n+ * except RTL8370B, which has 4160 entries. RTL8370B is mentioned in\n+ * vendor code but it might not even belong to the same RTL8367C family.\n */\n #define RTL8365MB_LEARN_LIMIT_MAX\t2112\n #define RTL8365MB_MAX_NUM_EXTINTS\t3\n@@ -283,6 +292,7 @@\n #define RTL8365MB_SDS_INDACS_CMD_BUSY_MASK\tBIT(8)\n #define RTL8365MB_SDS_INDACS_CMD_RUN_MASK\tBIT(7)\n #define RTL8365MB_SDS_INDACS_CMD_WR_MASK\tBIT(6)\n+#define RTL8365MB_SDS_INDACS_CMD_INDEX_MASK\tGENMASK(5, 0)\n #define RTL8365MB_SDS_INDACS_ADR_REG\t\t0x6601\n #define RTL8365MB_SDS_INDACS_DATA_REG\t\t0x6602\n \n@@ -296,6 +306,28 @@\n #define RTL8365MB_SDS_MISC_SGMII_SPD_MASK\t\tGENMASK(8, 7)\n #define RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK\tBIT(6)\n \n+/* Re-latch retry interval and attempt budget. Each attempt parks the\n+ * SerDes for 20 ms, so a far end that never comes up must not be retried\n+ * at this rate forever, and the interval must not be so tight that\n+ * back-to-back parks starve a link that is about to latch. The count is\n+ * reset to 1 by pcs_config() and to 0 whenever the receiver latches;\n+ * attempts start at pcs_config(), well before the far end MAC is up, so\n+ * with the interval below the budget is roughly RELATCH_MAX_TRIES seconds,\n+ * generous enough to outlast a slow conduit.\n+ */\n+#define RTL8365MB_D_SDS_RELATCH_INTERVAL\t(HZ)\n+#define RTL8365MB_D_SDS_RELATCH_MAX_TRIES\t15\n+\n+/* The SerDes stays parked until the restore write succeeds, so a failed\n+ * write is retried this many times before giving up until the next run.\n+ */\n+#define RTL8365MB_D_SDS_RESTORE_TRIES\t\t3\n+\n+/* How often a latched (or out-of-budget) SerDes is checked, and re-latched\n+ * if still down. Much slower than the re-latch interval.\n+ */\n+#define RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL\t(10 * HZ)\n+\n /* SerDes internal registers, accessed via the SDS_INDACS registers. The BMCR\n * data path reset holds BMCR_ANENABLE | BMCR_ISOLATE while toggling the\n * vendor-specific low bits from phase 1 to phase 2, which triggers a data path\n@@ -331,6 +363,27 @@\n #define RTL8365MB_SDS_OPTION_ARM_KEY\t\t0x0249\n #define RTL8365MB_SDS_OPTION_REG\t\t0x13C1\n \n+/* Family D uses the SDS13 indirect window for its MAC6 SerDes. */\n+#define RTL8365MB_D_SDS_EXT0_INDEX\t\t\t13\n+#define RTL8365MB_D_FIBER_CFG2_REG\t\t\t0x13E8\n+#define RTL8365MB_D_FIBER_CFG2_RX_DISABLE_MASK\tGENMASK(7, 6)\n+#define RTL8365MB_D_FIBER_CFG2_RX_DISABLE_SDS0\tBIT(6)\n+#define RTL8365MB_D_SDS_MISC_PA33PC_EN\t\t\tBIT(11)\n+#define RTL8365MB_D_SDS_MISC_PA12PC_EN\t\t\tBIT(10)\n+#define RTL8365MB_D_SDS_MISC_MAC6_SEL_SDS0\t\tBIT(9)\n+#define RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK\t\tGENMASK(4, 0)\n+#define RTL8365MB_D_SDS_MISC_MODE_SGMII\t\t\t0x02\n+#define RTL8365MB_D_SDS_MISC_MODE_HSGMII\t\t0x12\n+#define RTL8365MB_D_SDS_MISC_CFG_MASK\t\t\t\\\n+\t(RTL8365MB_D_SDS_MISC_PA33PC_EN |\t\t\\\n+\t RTL8365MB_D_SDS_MISC_PA12PC_EN |\t\t\\\n+\t RTL8365MB_D_SDS_MISC_MAC6_SEL_SDS0 |\t\t\\\n+\t RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK)\n+/* Shared \"disable\" encoding for both SDS_MISC's and SDS1_MISC0's\n+ * 5-bit mode fields.\n+ */\n+#define RTL8365MB_D_PORT_SDS_MODE_DISABLE\t\t0x1f\n+\n /* Embedded DW8051 microcontroller control registers. The microcontroller\n * can run firmware to manage the SerDes link, but this driver keeps it in\n * reset and disabled: phylink already performs the link management that\n@@ -343,6 +396,7 @@\n #define RTL8365MB_PORT_SPEED_10M\t0\n #define RTL8365MB_PORT_SPEED_100M\t1\n #define RTL8365MB_PORT_SPEED_1000M\t2\n+#define RTL8365MB_D_PORT_SPEED_2500M\t5\n \n /* External interface force configuration registers 0~2 */\n #define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG0\t\t0x1310 /* EXT0 */\n@@ -360,6 +414,21 @@\n #define RTL8365MB_DIGITAL_INTERFACE_FORCE_LINK_MASK\t\tBIT(4)\n #define RTL8365MB_DIGITAL_INTERFACE_FORCE_DUPLEX_MASK\t\tBIT(2)\n #define RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK\t\tGENMASK(1, 0)\n+/* Width of the FORCE_SPEED field, bits[1:0] */\n+#define RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_WIDTH\t\t2\n+\n+/* bits[13:12]; bit 13 reserved, no defined speed value uses it yet */\n+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_SPEED2_MASK\tGENMASK(13, 12)\n+\n+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_BASE\t\t0x12c0\n+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG(_port) \\\n+\t\t(RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_BASE + (_port))\n+\n+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_BASE\t\t0x12c8\n+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_EN(_port) \\\n+\t\t(RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_BASE + (_port))\n+\n+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_ALL_MASK\tGENMASK(15, 0)\n \n /* CPU port mask register - controls which ports are treated as CPU ports */\n #define RTL8365MB_CPU_PORT_MASK_REG\t0x1219\n@@ -441,6 +510,20 @@\n #define RTL8365MB_PORT_MISC_CFG_VLAN_EGRESS_MODE_MASK\t\tGENMASK(5, 4)\n #define RTL8365MB_PORT_MISC_CFG_CONGESTION_SUSTAIN_TIME_MASK\tGENMASK(3, 0)\n \n+/* EXT_TXC_DLY holds a 3-bit TX clock delay per external interface, for\n+ * RGMII ([2:0] EXT0, [5:3] EXT1, [8:6] EXT2) and separately for GMII.\n+ * Only the EXT1 RGMII field is used here, and it is cleared in RGMII\n+ * mode so that tx-internal-delay-ps is the only TX delay applied.\n+ */\n+#define RTL8365MB_D_REG_EXT_TXC_DLY\t\t\t\t0x13f9\n+#define RTL8365MB_D_EXT1_RGMII_TX_DLY_MASK\t\t\tGENMASK(5, 3)\n+\n+#define RTL8365MB_D_REG_TOP_CON0\t\t\t\t0x1d70\n+#define RTL8365MB_D_MAC7_SEL_EXT1_MASK\t\t\tBIT(13)\n+#define RTL8365MB_D_MAC4_SEL_EXT1_MASK\t\t\tBIT(12)\n+\n+#define RTL8365MB_D_REG_SDS1_MISC0\t\t\t\t0x1d78\n+\n /**\n * enum rtl8365mb_vlan_egress_mode - port VLAN egress mode\n * @RTL8365MB_VLAN_EGRESS_MODE_ORIGINAL: follow untag mask in VLAN4k table entry\n@@ -676,6 +759,21 @@ static const struct rtl8365mb_jam_tbl_entry rtl8365mb_sds_jam_hsgmii[] = {\n \t{ 0x0424, 0xD810 }, { 0x0001, 0x0F80 }, { 0x002E, 0x83F2 },\n };\n \n+/* Family D tuning tables from the Realtek vendor port API. */\n+static const struct rtl8365mb_jam_tbl_entry rtl8365mb_d_sds_jam_sgmii[] = {\n+\t{ 0x0427, 0x4E0C }, { 0x0428, 0xAA00 }, { 0x0425, 0x5189 },\n+\t{ 0x0424, 0x8414 }, { 0x0423, 0x1020 }, { 0x0410, 0x0002 },\n+\t{ 0x0484, 0x011B }, { 0x0421, 0x8E13 }, { 0x0422, 0x1140 },\n+\t{ 0x0004, 0x074F },\n+};\n+\n+static const struct rtl8365mb_jam_tbl_entry rtl8365mb_d_sds_jam_hsgmii[] = {\n+\t{ 0x0427, 0x4E0C }, { 0x0428, 0xAA00 }, { 0x0425, 0x5189 },\n+\t{ 0x0424, 0x8414 }, { 0x0423, 0x1020 }, { 0x0410, 0x0002 },\n+\t{ 0x0504, 0x051B }, { 0x0421, 0x8E13 }, { 0x0422, 0x1140 },\n+\t{ 0x0004, 0x074F },\n+};\n+\n enum rtl8365mb_phy_interface_mode {\n \tRTL8365MB_PHY_INTERFACE_MODE_INVAL = 0,\n \tRTL8365MB_PHY_INTERFACE_MODE_INTERNAL = BIT(0),\n@@ -707,6 +805,7 @@ struct rtl8365mb_extint {\n * @name: human-readable chip name\n * @chip_id: chip identifier\n * @chip_ver: chip silicon revision\n+ * @family: chip family\n * @extints: available external interfaces\n * @jam_table: chip-specific initialization jam table\n * @jam_size: size of the chip's jam table\n@@ -719,6 +818,7 @@ struct rtl8365mb_chip_info {\n \tconst char *name;\n \tu32 chip_id;\n \tu32 chip_ver;\n+\tenum rtl8365mb_family family;\n \tconst struct rtl8365mb_extint extints[RTL8365MB_MAX_NUM_EXTINTS];\n \tconst struct rtl8365mb_jam_tbl_entry *jam_table;\n \tsize_t jam_size;\n@@ -731,6 +831,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {\n \t\t.name = \"RTL8365MB-VC\",\n \t\t.chip_id = 0x6367,\n \t\t.chip_ver = 0x0040,\n+\t\t.family = RTL8365MB_FAMILY_C,\n \t\t.extints = {\n \t\t\t{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |\n \t\t\t\tPHY_INTF(RMII) | PHY_INTF(RGMII) },\n@@ -742,6 +843,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {\n \t\t.name = \"RTL8367S\",\n \t\t.chip_id = 0x6367,\n \t\t.chip_ver = 0x00A0,\n+\t\t.family = RTL8365MB_FAMILY_C,\n \t\t.extints = {\n \t\t\t{ 6, 1, PHY_INTF(SGMII) | PHY_INTF(HSGMII) },\n \t\t\t{ 7, 2, PHY_INTF(MII) | PHY_INTF(TMII) |\n@@ -754,6 +856,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {\n \t\t.name = \"RTL8367SB\",\n \t\t.chip_id = 0x6367,\n \t\t.chip_ver = 0x0010,\n+\t\t.family = RTL8365MB_FAMILY_C,\n \t\t.extints = {\n \t\t\t{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |\n \t\t\t\tPHY_INTF(RMII) | PHY_INTF(RGMII) |\n@@ -768,6 +871,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {\n \t\t.name = \"RTL8367RB-VB\",\n \t\t.chip_id = 0x6367,\n \t\t.chip_ver = 0x0020,\n+\t\t.family = RTL8365MB_FAMILY_C,\n \t\t.extints = {\n \t\t\t{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |\n \t\t\t\tPHY_INTF(RMII) | PHY_INTF(RGMII) },\n@@ -777,6 +881,19 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {\n \t\t.jam_table = rtl8365mb_init_jam_8365mb_vc,\n \t\t.jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc),\n \t},\n+\t{\n+\t\t.name = \"RTL8367S-VB\",\n+\t\t.chip_id = 0x6642,\n+\t\t.chip_ver = 0x0010,\n+\t\t.family = RTL8365MB_FAMILY_D,\n+\t\t.extints = {\n+\t\t\t{ 6, 0, PHY_INTF(SGMII) | PHY_INTF(HSGMII) },\n+\t\t\t{ 7, 1, PHY_INTF(MII) | PHY_INTF(TMII) |\n+\t\t\t\tPHY_INTF(RMII) | PHY_INTF(RGMII) },\n+\t\t},\n+\t\t.jam_table = rtl8365mb_init_jam_8365mb_vc,\n+\t\t.jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc),\n+\t},\n };\n \n enum rtl8365mb_stp_state {\n@@ -854,10 +971,16 @@ struct rtl8365mb_port {\n * @chip_info: chip-specific info about the attached switch\n * @cpu: CPU tagging and CPU port configuration for this chip\n * @mib_lock: prevent concurrent reads of MIB counters\n+ * @sds_lock: serializes access to the shared SDS_INDACS ADR/CMD/DATA window,\n+ * reachable both from phylink's PCS callbacks and from the\n+ * family D SerDes re-latch work\n * @ports: per-port data\n * @pcs: PCS for the SerDes external interface\n * @sds_supported: SerDes tuning parameters match the chip option, so the\n * SerDes interface modes can be advertised\n+ * @sds_relatch: re-latch edges and link health check (family D)\n+ * @sds_relatch_count: next attempt of the re-latch episode, 0 once latched\n+ * @sds_misc_target_val: SDS_MISC_CFG_MASK fields the re-latch work restores\n *\n * Private data for this driver.\n */\n@@ -867,13 +990,24 @@ struct rtl8365mb {\n \tconst struct rtl8365mb_chip_info *chip_info;\n \tstruct rtl8365mb_cpu cpu;\n \tstruct mutex mib_lock;\n+\tstruct mutex sds_lock;\n \tstruct rtl8365mb_port ports[RTL8365MB_MAX_NUM_PORTS];\n \tstruct phylink_pcs pcs;\n \tbool sds_supported;\n+\tstruct delayed_work sds_relatch;\n+\tunsigned int sds_relatch_count;\n+\tu32 sds_misc_target_val;\n };\n \n #define pcs_to_rtl8365mb(_pcs) container_of((_pcs), struct rtl8365mb, pcs)\n \n+enum rtl8365mb_family rtl8365mb_get_family(struct realtek_priv *priv)\n+{\n+\tstruct rtl8365mb *mb = priv-\u003echip_data;\n+\n+\treturn mb-\u003echip_info-\u003efamily;\n+}\n+\n static int rtl8365mb_phy_poll_busy(struct realtek_priv *priv)\n {\n \tu32 val;\n@@ -1164,6 +1298,7 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,\n \tstruct dsa_port *dp;\n \tint tx_delay = 0;\n \tint rx_delay = 0;\n+\tu32 data;\n \tu32 val;\n \tint ret;\n \n@@ -1233,43 +1368,88 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,\n \tif (ret)\n \t\treturn ret;\n \n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D \u0026\u0026\n+\t extint-\u003eid == 1) {\n+\t\tret = regmap_update_bits(priv-\u003emap,\n+\t\t\t\t\t RTL8365MB_D_REG_EXT_TXC_DLY,\n+\t\t\t\t\t RTL8365MB_D_EXT1_RGMII_TX_DLY_MASK, 0);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t\t/* Configure RGMII/MII mux to port 7 if UTP_PORT4 is not in\n+\t\t * RGMII mode\n+\t\t */\n+\t\tret = regmap_read(priv-\u003emap, RTL8365MB_D_REG_TOP_CON0, \u0026data);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t\tif ((data \u0026 RTL8365MB_D_MAC4_SEL_EXT1_MASK) == 0) {\n+\t\t\tret = regmap_update_bits(priv-\u003emap,\n+\t\t\t\t\t\t RTL8365MB_D_REG_TOP_CON0,\n+\t\t\t\t\t\t RTL8365MB_D_MAC7_SEL_EXT1_MASK,\n+\t\t\t\t\t\t RTL8365MB_D_MAC7_SEL_EXT1_MASK);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n+\t\tret = regmap_update_bits(priv-\u003emap,\n+\t\t\t\t\t RTL8365MB_D_REG_SDS1_MISC0,\n+\t\t\t\t\t RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK,\n+\t\t\t\t\t RTL8365MB_D_PORT_SDS_MODE_DISABLE);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n \treturn 0;\n }\n \n-static int rtl8365mb_sds_write(struct realtek_priv *priv, u16 addr, u16 data)\n+static int rtl8365mb_sds_write(struct realtek_priv *priv, u8 index,\n+\t\t\t u16 addr, u16 data)\n {\n+\tstruct rtl8365mb *mb = priv-\u003echip_data;\n \tint ret;\n \n+\tmutex_lock(\u0026mb-\u003esds_lock);\n+\n \tret = regmap_write(priv-\u003emap, RTL8365MB_SDS_INDACS_DATA_REG, data);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto out_unlock;\n \n \tret = regmap_write(priv-\u003emap, RTL8365MB_SDS_INDACS_ADR_REG, addr);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto out_unlock;\n \n \t/* The SerDes indirect access engine completes the command within the\n \t * register write transaction, so there is no need to wait or poll for\n \t * completion before the next access, matching the vendor driver.\n \t */\n-\treturn regmap_write(priv-\u003emap, RTL8365MB_SDS_INDACS_CMD_REG,\n-\t\t\t RTL8365MB_SDS_INDACS_CMD_RUN_MASK |\n-\t\t\t RTL8365MB_SDS_INDACS_CMD_WR_MASK);\n+\tret = regmap_write(priv-\u003emap, RTL8365MB_SDS_INDACS_CMD_REG,\n+\t\t\t RTL8365MB_SDS_INDACS_CMD_RUN_MASK |\n+\t\t\t RTL8365MB_SDS_INDACS_CMD_WR_MASK |\n+\t\t\t FIELD_PREP(RTL8365MB_SDS_INDACS_CMD_INDEX_MASK,\n+\t\t\t\t index));\n+\n+out_unlock:\n+\tmutex_unlock(\u0026mb-\u003esds_lock);\n+\treturn ret;\n }\n \n-static int rtl8365mb_sds_read(struct realtek_priv *priv, u16 addr, u16 *data)\n+static int rtl8365mb_sds_read(struct realtek_priv *priv, u8 index,\n+\t\t\t u16 addr, u16 *data)\n {\n+\tstruct rtl8365mb *mb = priv-\u003echip_data;\n \tu32 val;\n \tint ret;\n \n+\tmutex_lock(\u0026mb-\u003esds_lock);\n+\n \tret = regmap_write(priv-\u003emap, RTL8365MB_SDS_INDACS_ADR_REG, addr);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto out_unlock;\n \n \tret = regmap_write(priv-\u003emap, RTL8365MB_SDS_INDACS_CMD_REG,\n-\t\t\t RTL8365MB_SDS_INDACS_CMD_RUN_MASK);\n+\t\t\t RTL8365MB_SDS_INDACS_CMD_RUN_MASK |\n+\t\t\t FIELD_PREP(RTL8365MB_SDS_INDACS_CMD_INDEX_MASK,\n+\t\t\t\t index));\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto out_unlock;\n \n \t/* Wait for the indirect read to complete: the engine clears the BUSY\n \t * bit once the data register holds the result.\n@@ -1279,15 +1459,19 @@ static int rtl8365mb_sds_read(struct realtek_priv *priv, u16 addr, u16 *data)\n \t\t\t\t !(val \u0026 RTL8365MB_SDS_INDACS_CMD_BUSY_MASK),\n \t\t\t\t 10, 1000);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto out_unlock;\n \n \tret = regmap_read(priv-\u003emap, RTL8365MB_SDS_INDACS_DATA_REG, \u0026val);\n \tif (ret)\n-\t\treturn ret;\n+\t\tgoto out_unlock;\n \n \t*data = val;\n \n-\treturn 0;\n+\tret = 0;\n+\n+out_unlock:\n+\tmutex_unlock(\u0026mb-\u003esds_lock);\n+\treturn ret;\n }\n \n /* The vendor driver selects between two sets of SerDes tuning parameters based\n@@ -1307,6 +1491,14 @@ static int rtl8365mb_sds_probe_option(struct realtek_priv *priv)\n \tint ret;\n \tint i;\n \n+\t/* Family D has a fixed SDS13 programming model and does not use the\n+\t * family C option register to select its tuning table.\n+\t */\n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D) {\n+\t\tmb-\u003esds_supported = true;\n+\t\treturn 0;\n+\t}\n+\n \t/* Nothing to probe if no external interface is wired to the SerDes */\n \tfor (i = 0; i \u003c RTL8365MB_MAX_NUM_EXTINTS; i++) {\n \t\textint = \u0026mb-\u003echip_info-\u003eextints[i];\n@@ -1385,28 +1577,54 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,\n \t\t\t\tconst unsigned long *advertising,\n \t\t\t\tbool permit_pause_to_mac)\n {\n-\tconst struct rtl8365mb_jam_tbl_entry *sds_jam;\n \tconst int id = RTL8365MB_SDS_EXT_INTERFACE_ID;\n+\tconst struct rtl8365mb_jam_tbl_entry *sds_jam;\n \tstruct rtl8365mb *mb = pcs_to_rtl8365mb(pcs);\n-\tstruct realtek_priv *priv;\n+\tstruct realtek_priv *priv = mb-\u003epriv;\n \tsize_t sds_jam_size;\n-\tu32 mode;\n+\tu32 misc_mask;\n+\tu32 misc_val;\n+\tu32 sds_mode;\n+\tu8 sds_index;\n+\tbool is_d;\n \tu16 val;\n \tint ret;\n \tint i;\n \n-\tpriv = mb-\u003epriv;\n+\tis_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;\n \n+\t/* Cancel any in-flight re-latch edge before touching SDS_MISC: the\n+\t * work parks SDS_MISC and restores the target value after a sleep, so\n+\t * it could otherwise write a stale target over the new configuration.\n+\t */\n+\tif (is_d)\n+\t\tcancel_delayed_work_sync(\u0026mb-\u003esds_relatch);\n+\n+\t/* Select the appropriate tuning table and SDS mode */\n \tif (interface == PHY_INTERFACE_MODE_2500BASEX) {\n-\t\tsds_jam = rtl8365mb_sds_jam_hsgmii;\n-\t\tsds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_hsgmii);\n-\t\tmode = RTL8365MB_EXT_PORT_MODE_HSGMII;\n+\t\tif (is_d) {\n+\t\t\tsds_jam = rtl8365mb_d_sds_jam_hsgmii;\n+\t\t\tsds_jam_size = ARRAY_SIZE(rtl8365mb_d_sds_jam_hsgmii);\n+\t\t\tsds_mode = RTL8365MB_D_SDS_MISC_MODE_HSGMII;\n+\t\t} else {\n+\t\t\tsds_jam = rtl8365mb_sds_jam_hsgmii;\n+\t\t\tsds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_hsgmii);\n+\t\t\tsds_mode = RTL8365MB_EXT_PORT_MODE_HSGMII;\n+\t\t}\n \t} else {\n-\t\tsds_jam = rtl8365mb_sds_jam_sgmii;\n-\t\tsds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_sgmii);\n-\t\tmode = RTL8365MB_EXT_PORT_MODE_SGMII;\n+\t\tif (is_d) {\n+\t\t\tsds_jam = rtl8365mb_d_sds_jam_sgmii;\n+\t\t\tsds_jam_size = ARRAY_SIZE(rtl8365mb_d_sds_jam_sgmii);\n+\t\t\tsds_mode = RTL8365MB_D_SDS_MISC_MODE_SGMII;\n+\t\t} else {\n+\t\t\tsds_jam = rtl8365mb_sds_jam_sgmii;\n+\t\t\tsds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_sgmii);\n+\t\t\tsds_mode = RTL8365MB_EXT_PORT_MODE_SGMII;\n+\t\t}\n \t}\n \n+\tsds_index = is_d ? RTL8365MB_D_SDS_EXT0_INDEX : 0;\n+\n \t/* Hold the embedded DW8051 microcontroller in reset and keep it\n \t * disabled. The vendor driver loads firmware into it to manage the\n \t * SerDes link, but the firmware only duplicates work that phylink\n@@ -1435,34 +1653,55 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,\n \n \t/* Tune the SerDes with vendor-prescribed parameters */\n \tfor (i = 0; i \u003c sds_jam_size; i++) {\n-\t\tret = rtl8365mb_sds_write(priv, sds_jam[i].reg,\n-\t\t\t\t\t sds_jam[i].val);\n+\t\tret = rtl8365mb_sds_write(priv, sds_index,\n+\t\t\t\t\t sds_jam[i].reg, sds_jam[i].val);\n \t\tif (ret)\n \t\t\treturn ret;\n \t}\n \n-\t/* Mux the SerDes to MAC8 in the requested mode */\n+\t/* Family-specific post-tuning configuration */\n+\tif (is_d) {\n+\t\tret = regmap_update_bits(priv-\u003emap, RTL8365MB_D_FIBER_CFG2_REG,\n+\t\t\t\t\t RTL8365MB_D_FIBER_CFG2_RX_DISABLE_MASK,\n+\t\t\t\t\t RTL8365MB_D_FIBER_CFG2_RX_DISABLE_SDS0);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tmisc_mask = RTL8365MB_D_SDS_MISC_CFG_MASK;\n+\t\tmisc_val = RTL8365MB_D_SDS_MISC_PA33PC_EN |\n+\t\t\t RTL8365MB_D_SDS_MISC_PA12PC_EN |\n+\t\t\t RTL8365MB_D_SDS_MISC_MAC6_SEL_SDS0 | sds_mode;\n+\t} else {\n+\t\t/* Mux the SerDes to MAC8 in the requested mode */\n+\t\tmisc_mask = RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK |\n+\t\t\t RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK;\n+\t\tmisc_val = (sds_mode == RTL8365MB_EXT_PORT_MODE_SGMII) ?\n+\t\t\t RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK :\n+\t\t\t RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK;\n+\t}\n+\n \tret = regmap_update_bits(priv-\u003emap, RTL8365MB_SDS_MISC_REG,\n-\t\t\t\t RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK |\n-\t\t\t\t\t RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK,\n-\t\t\t\t mode == RTL8365MB_EXT_PORT_MODE_SGMII ?\n-\t\t\t\t\t RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK :\n-\t\t\t\t\t RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK);\n+\t\t\t\t misc_mask, misc_val);\n \tif (ret)\n \t\treturn ret;\n \n-\tval = mode \u003c\u003c RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(id);\n-\tret = regmap_update_bits(priv-\u003emap,\n-\t\t\t\t RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(id),\n-\t\t\t\t RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(id),\n-\t\t\t\t val);\n-\tif (ret)\n-\t\treturn ret;\n+\tif (is_d) {\n+\t\tWRITE_ONCE(mb-\u003esds_misc_target_val, misc_val);\n+\t} else {\n+\t\tval = sds_mode \u003c\u003c RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(id);\n+\t\tret = regmap_update_bits(priv-\u003emap,\n+\t\t\t\t\t RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(id),\n+\t\t\t\t\t RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(id),\n+\t\t\t\t\t val);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n \n \t/* Take the SerDes out of reset. The vendor driver does this only\n \t * after the SerDes mux and the interface mode are configured.\n \t */\n-\tret = rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_RESET,\n+\tret = rtl8365mb_sds_write(priv, sds_index,\n+\t\t\t\t RTL8365MB_SDS_REG_RESET,\n \t\t\t\t RTL8365MB_SDS_RESET_DEASSERT);\n \tif (ret)\n \t\treturn ret;\n@@ -1472,12 +1711,14 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,\n \t * This flushes the FIFOs and ensures a clean state for the link,\n \t * preventing silent drops and CRC errors.\n \t */\n-\tret = rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_BMCR,\n+\tret = rtl8365mb_sds_write(priv, sds_index,\n+\t\t\t\t RTL8365MB_SDS_REG_BMCR,\n \t\t\t\t RTL8365MB_SDS_BMCR_DPRST_PHASE1);\n \tif (ret)\n \t\treturn ret;\n \n-\tret = rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_BMCR,\n+\tret = rtl8365mb_sds_write(priv, sds_index,\n+\t\t\t\t RTL8365MB_SDS_REG_BMCR,\n \t\t\t\t RTL8365MB_SDS_BMCR_DPRST_PHASE2);\n \tif (ret)\n \t\treturn ret;\n@@ -1485,14 +1726,163 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,\n \t/* Keep SGMII in-band autonegotiation disabled: the link parameters are\n \t * forced from rtl8365mb_pcs_link_up() instead.\n \t */\n-\tret = rtl8365mb_sds_read(priv, RTL8365MB_SDS_REG_NWAY, \u0026val);\n+\tret = rtl8365mb_sds_read(priv, sds_index,\n+\t\t\t\t RTL8365MB_SDS_REG_NWAY, \u0026val);\n \tif (ret)\n \t\treturn ret;\n \n \tval \u0026= ~RTL8365MB_SDS_NWAY_EN_MASK;\n \tval |= RTL8365MB_SDS_NWAY_RESTART_MASK;\n \n-\treturn rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_NWAY, val);\n+\tret = rtl8365mb_sds_write(priv, sds_index,\n+\t\t\t\t RTL8365MB_SDS_REG_NWAY, val);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\t/* The re-latch edge has only been observed with HSGMII, so the work is\n+\t * only started for 2500base-x. Start a new episode and kick off the\n+\t * first attempt; see rtl8365mb_sds_relatch_work() for why this cannot\n+\t * wait for phylink to ask again.\n+\t */\n+\tif (is_d \u0026\u0026 interface == PHY_INTERFACE_MODE_2500BASEX) {\n+\t\tWRITE_ONCE(mb-\u003esds_relatch_count, 1);\n+\t\tschedule_delayed_work(\u0026mb-\u003esds_relatch, 0);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/* The family D receiver latches on a DISABLE -\u003e mode edge in SDS_MISC\n+ * rather than on the value, and only once the far-end MAC has brought up\n+ * its half of the link. No local signal predicts that (bit 8 of the SDS\n+ * link-status word does not change ahead of it), so the work cannot wait\n+ * for it, only check afterwards whether an edge took. Nor does phylink\n+ * call rtl8365mb_pcs_get_state() for a link without in-band signalling\n+ * such as the fixed-link CPU trunk (mb-\u003epcs.poll only arms phylink's own\n+ * poll for in-band links), so this cannot rely on being polled at all.\n+ * Instead, pcs_config() starts an episode and this work re-arms itself\n+ * after every edge, its next run checking whether the edge took.\n+ *\n+ * An episode is capped at RTL8365MB_D_SDS_RELATCH_MAX_TRIES edges, spaced\n+ * RTL8365MB_D_SDS_RELATCH_INTERVAL apart, so that a far end which never\n+ * comes up costs a bounded burst of 20 ms parks. The run after the last\n+ * edge only checks whether it took and reports failure; from then on one\n+ * edge is driven per RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL, so a far end\n+ * that comes up late is recovered without a reconfiguration. Once the\n+ * receiver has latched the work just polls the link at the same slow\n+ * interval; finding it down then starts a new episode, e.g. after the far\n+ * end reset its PLL without a reconfiguration.\n+ *\n+ * sds_relatch_count is the number of the next attempt of the episode: 0\n+ * while latched, 1..MAX_TRIES in budget, MAX_TRIES + 1 for the run that\n+ * only reports, and above that once out of budget.\n+ */\n+static void rtl8365mb_sds_relatch_work(struct work_struct *work)\n+{\n+\tstruct rtl8365mb *mb = container_of(to_delayed_work(work),\n+\t\t\t\t\t struct rtl8365mb, sds_relatch);\n+\tstruct realtek_priv *priv = mb-\u003epriv;\n+\tu32 park = (READ_ONCE(mb-\u003esds_misc_target_val) \u0026\n+\t\t ~RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK) |\n+\t\t RTL8365MB_D_PORT_SDS_MODE_DISABLE;\n+\tunsigned long delay = RTL8365MB_D_SDS_RELATCH_INTERVAL;\n+\tunsigned int attempts;\n+\tu16 status;\n+\tint ret;\n+\tint i;\n+\n+\t/* The condition that queued this work may already be stale by the\n+\t * time it runs (e.g. an earlier edge from a prior attempt just\n+\t * latched). Parking an already-live link would drop it for no\n+\t * reason.\n+\t */\n+\tret = rtl8365mb_sds_read(priv, RTL8365MB_D_SDS_EXT0_INDEX,\n+\t\t\t\t RTL8365MB_SDS_REG_LINK_STATUS, \u0026status);\n+\tif (ret) {\n+\t\tdev_err_ratelimited(priv-\u003edev,\n+\t\t\t\t \"failed to read SerDes link status: %pe\\n\",\n+\t\t\t\t ERR_PTR(ret));\n+\t\tgoto rearm;\n+\t}\n+\tif (status \u0026 RTL8365MB_SDS_LINK_STATUS_LINK_MASK) {\n+\t\t/* Latched: end the episode, keep watching for a later loss. */\n+\t\tWRITE_ONCE(mb-\u003esds_relatch_count, 0);\n+\t\tdelay = RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL;\n+\t\tgoto rearm;\n+\t}\n+\n+\tattempts = READ_ONCE(mb-\u003esds_relatch_count);\n+\tif (!attempts) {\n+\t\tdev_warn(priv-\u003edev,\n+\t\t\t \"SerDes link lost outside a reconfiguration; re-latching\\n\");\n+\t\tattempts = 1;\n+\t} else if (attempts == RTL8365MB_D_SDS_RELATCH_MAX_TRIES + 1) {\n+\t\t/* This run only checked whether the last in-budget edge\n+\t\t * took. The first out-of-budget edge comes one healthcheck\n+\t\t * interval from now, not on this pass.\n+\t\t */\n+\t\tWRITE_ONCE(mb-\u003esds_relatch_count, attempts + 1);\n+\t\tdev_warn(priv-\u003edev,\n+\t\t\t \"SerDes did not latch after %u re-latch attempts; still retrying every %d s\\n\",\n+\t\t\t RTL8365MB_D_SDS_RELATCH_MAX_TRIES,\n+\t\t\t RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL / HZ);\n+\t\tdelay = RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL;\n+\t\tgoto rearm;\n+\t}\n+\n+\tif (attempts \u003c= RTL8365MB_D_SDS_RELATCH_MAX_TRIES)\n+\t\tWRITE_ONCE(mb-\u003esds_relatch_count, attempts + 1);\n+\telse\n+\t\t/* Past the fast-retry budget. The receiver latches only on a\n+\t\t * DISABLE -\u003e mode edge and nothing re-runs pcs_config() for a\n+\t\t * link without in-band signalling, so keep driving one edge\n+\t\t * per interval.\n+\t\t */\n+\t\tdelay = RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL;\n+\n+\tret = regmap_update_bits(priv-\u003emap, RTL8365MB_SDS_MISC_REG,\n+\t\t\t\t RTL8365MB_D_SDS_MISC_CFG_MASK, park);\n+\tif (ret) {\n+\t\tdev_err_ratelimited(priv-\u003edev,\n+\t\t\t\t \"failed to park SDS_MISC: %pe\\n\",\n+\t\t\t\t ERR_PTR(ret));\n+\t\tgoto rearm;\n+\t}\n+\n+\tusleep_range(20000, 21000);\n+\n+\tfor (i = 0; i \u003c RTL8365MB_D_SDS_RESTORE_TRIES; i++) {\n+\t\tret = regmap_update_bits(priv-\u003emap, RTL8365MB_SDS_MISC_REG,\n+\t\t\t\t\t RTL8365MB_D_SDS_MISC_CFG_MASK,\n+\t\t\t\t\t READ_ONCE(mb-\u003esds_misc_target_val));\n+\t\tif (!ret)\n+\t\t\tbreak;\n+\t\tusleep_range(1000, 2000);\n+\t}\n+\tif (ret) {\n+\t\tdev_err_ratelimited(priv-\u003edev,\n+\t\t\t\t \"failed to restore SDS_MISC: %pe\\n\",\n+\t\t\t\t ERR_PTR(ret));\n+\t\t/* The SerDes is left parked: come back soon rather than\n+\t\t * at the (possibly 10 s) pace chosen above.\n+\t\t */\n+\t\tdelay = RTL8365MB_D_SDS_RELATCH_INTERVAL;\n+\t\tgoto rearm;\n+\t}\n+\n+\tdev_dbg(priv-\u003edev, \"SerDes re-latch edge driven (attempt %u)\\n\",\n+\t\tattempts);\n+\n+\t/* This edge may not have taken either; the next run checks. */\n+rearm:\n+\tschedule_delayed_work(\u0026mb-\u003esds_relatch, delay);\n+}\n+\n+static void rtl8365mb_sds_relatch_cancel(void *data)\n+{\n+\tstruct rtl8365mb *mb = data;\n+\n+\tcancel_delayed_work_sync(\u0026mb-\u003esds_relatch);\n }\n \n static bool rtl8365mb_interface_is_serdes(phy_interface_t interface)\n@@ -1517,10 +1907,14 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,\n {\n \tstruct rtl8365mb *mb = pcs_to_rtl8365mb(pcs);\n \tstruct realtek_priv *priv = mb-\u003epriv;\n+\tu8 sds_index = 0;\n \tu16 status;\n+\tbool is_d;\n \tu32 val;\n \tint ret;\n \n+\tis_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;\n+\n \t/* In-band autonegotiation is not implemented, so the link parameters are\n \t * forced from rtl8365mb_pcs_link_up(). The real link state must still be\n \t * read from the SerDes itself: the embedded DW8051 microcontroller that\n@@ -1528,7 +1922,11 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,\n \t * rtl8365mb_pcs_config()), so the link status register can be read\n \t * directly through the SDS_INDACS window without racing the auto-poll.\n \t */\n-\tret = rtl8365mb_sds_read(priv, RTL8365MB_SDS_REG_LINK_STATUS, \u0026status);\n+\tif (is_d)\n+\t\tsds_index = RTL8365MB_D_SDS_EXT0_INDEX;\n+\n+\tret = rtl8365mb_sds_read(priv, sds_index,\n+\t\t\t\t RTL8365MB_SDS_REG_LINK_STATUS, \u0026status);\n \tif (ret) {\n \t\tstate-\u003elink = false;\n \t\treturn;\n@@ -1539,6 +1937,13 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,\n \tif (!state-\u003elink)\n \t\treturn;\n \n+\tif (is_d) {\n+\t\tstate-\u003eduplex = DUPLEX_FULL;\n+\t\tstate-\u003espeed = state-\u003einterface == PHY_INTERFACE_MODE_2500BASEX ?\n+\t\t\t\tSPEED_2500 : SPEED_1000;\n+\t\treturn;\n+\t}\n+\n \t/* The speed and duplex are forced; read them back from the values\n \t * programmed into the SerDes MISC register.\n \t */\n@@ -1580,6 +1985,12 @@ static void rtl8365mb_pcs_link_up(struct phylink_pcs *pcs,\n \tu32 r_speed;\n \tint ret;\n \n+\t/* Family D forces the external MAC ability from mac_link_up(); its\n+\t * SDS_MISC fields do not share the family C link-force layout.\n+\t */\n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)\n+\t\treturn;\n+\n \t/* The speed field has no value for 2.5 Gbps: the rate is determined by\n \t * the HSGMII SerDes configuration, and the vendor driver programs the\n \t * 1 Gbps value here.\n@@ -1614,11 +2025,20 @@ static void rtl8365mb_pcs_link_up(struct phylink_pcs *pcs,\n \t}\n }\n \n+static void rtl8365mb_pcs_disable(struct phylink_pcs *pcs)\n+{\n+\tstruct rtl8365mb *mb = pcs_to_rtl8365mb(pcs);\n+\n+\tif (rtl8365mb_get_family(mb-\u003epriv) == RTL8365MB_FAMILY_D)\n+\t\tcancel_delayed_work_sync(\u0026mb-\u003esds_relatch);\n+}\n+\n static const struct phylink_pcs_ops rtl8365mb_pcs_ops = {\n \t.pcs_inband_caps = rtl8365mb_pcs_inband_caps,\n \t.pcs_config = rtl8365mb_pcs_config,\n \t.pcs_get_state = rtl8365mb_pcs_get_state,\n \t.pcs_link_up = rtl8365mb_pcs_link_up,\n+\t.pcs_disable = rtl8365mb_pcs_disable,\n };\n \n static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,\n@@ -1632,23 +2052,32 @@ static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,\n \tu32 r_duplex;\n \tu32 r_speed;\n \tu32 r_link;\n+\tbool is_d;\n \tint val;\n \tint ret;\n \n \tif (!extint)\n \t\treturn -ENODEV;\n \n+\tis_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;\n \tif (link) {\n \t\t/* Force the link up with the desired configuration */\n \t\tr_link = 1;\n \t\tr_rx_pause = rx_pause ? 1 : 0;\n \t\tr_tx_pause = tx_pause ? 1 : 0;\n \n-\t\t/* The speed field has no value for 2.5 Gbps: the rate is\n-\t\t * determined by the HSGMII SerDes configuration, and the\n-\t\t * vendor driver programs the 1 Gbps value here.\n-\t\t */\n-\t\tif (speed == SPEED_2500 || speed == SPEED_1000) {\n+\t\tif (speed == SPEED_2500) {\n+\t\t\tif (is_d) {\n+\t\t\t\tr_speed = RTL8365MB_D_PORT_SPEED_2500M;\n+\t\t\t} else {\n+\t\t\t\t/* The speed field has no value for 2.5 Gbps:\n+\t\t\t\t * the rate is determined by the HSGMII SerDes\n+\t\t\t\t * configuration, and the vendor driver programs\n+\t\t\t\t * the 1 Gbps value here.\n+\t\t\t\t */\n+\t\t\t\tr_speed = RTL8365MB_PORT_SPEED_1000M;\n+\t\t\t}\n+\t\t} else if (speed == SPEED_1000) {\n \t\t\tr_speed = RTL8365MB_PORT_SPEED_1000M;\n \t\t} else if (speed == SPEED_100) {\n \t\t\tr_speed = RTL8365MB_PORT_SPEED_100M;\n@@ -1678,20 +2107,44 @@ static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,\n \t\tr_duplex = 0;\n \t}\n \n-\tval = FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_EN_MASK, 1) |\n-\t FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_TXPAUSE_MASK,\n+\tval = FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_TXPAUSE_MASK,\n \t\t\t r_tx_pause) |\n \t FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_RXPAUSE_MASK,\n \t\t\t r_rx_pause) |\n \t FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_LINK_MASK, r_link) |\n \t FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_DUPLEX_MASK,\n \t\t\t r_duplex) |\n-\t FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK, r_speed);\n-\tret = regmap_write(priv-\u003emap,\n-\t\t\t RTL8365MB_DIGITAL_INTERFACE_FORCE_REG(extint-\u003eid),\n-\t\t\t val);\n-\tif (ret)\n-\t\treturn ret;\n+\t FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK,\n+\t\t\t r_speed \u0026\n+\t\t\t RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK);\n+\n+\tif (is_d) {\n+\t\t/* Speed is 3 bits on family D: bits[1:0] go into FORCE_SPEED,\n+\t\t * bit[2] goes into FORCE_SPEED2 (bit 12); only 2500M sets it,\n+\t\t * bit 13 of the field is unused.\n+\t\t */\n+\t\tval |= FIELD_PREP(RTL8365MB_D_DIGITAL_INTERFACE_FORCE_SPEED2_MASK,\n+\t\t\t\t r_speed \u003e\u003e\n+\t\t\t\t RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_WIDTH);\n+\t\tret = regmap_write(priv-\u003emap,\n+\t\t\t\t RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG(port),\n+\t\t\t\t val);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\tret = regmap_write(priv-\u003emap,\n+\t\t\t\t RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_EN(port),\n+\t\t\t\t RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_ALL_MASK);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t} else {\n+\t\tval |= FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_EN_MASK, 1);\n+\t\tret = regmap_write(priv-\u003emap,\n+\t\t\t\t RTL8365MB_DIGITAL_INTERFACE_FORCE_REG(extint-\u003eid),\n+\t\t\t\t val);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n \n \treturn 0;\n }\n@@ -1876,7 +2329,8 @@ static void rtl8365mb_phylink_mac_link_up(struct phylink_config *config,\n \t\t * rtl8365mb_pcs_link_up() because pcs_link_up() carries no\n \t\t * pause information.\n \t\t */\n-\t\tif (rtl8365mb_interface_is_serdes(interface)) {\n+\t\tif (rtl8365mb_interface_is_serdes(interface) \u0026\u0026\n+\t\t rtl8365mb_get_family(priv) != RTL8365MB_FAMILY_D) {\n \t\t\tu32 val = 0;\n \n \t\t\tif (tx_pause)\n@@ -3284,6 +3738,10 @@ static int rtl8365mb_setup(struct dsa_switch *ds)\n static void rtl8365mb_teardown(struct dsa_switch *ds)\n {\n \tstruct realtek_priv *priv = ds-\u003epriv;\n+\tstruct rtl8365mb *mb = priv-\u003echip_data;\n+\n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)\n+\t\tcancel_delayed_work_sync(\u0026mb-\u003esds_relatch);\n \n \trtl8365mb_stats_teardown(priv);\n \trtl8365mb_irq_teardown(priv);\n@@ -3349,7 +3807,28 @@ static int rtl8365mb_detect(struct realtek_priv *priv)\n \n \tdev_info(priv-\u003edev, \"found an %s switch\\n\", mb-\u003echip_info-\u003ename);\n \n-\tpriv-\u003enum_ports = RTL8365MB_MAX_NUM_PORTS;\n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)\n+\t\tpriv-\u003enum_ports = RTL8365MB_D_MAX_NUM_PORTS;\n+\telse\n+\t\tpriv-\u003enum_ports = RTL8365MB_MAX_NUM_PORTS;\n+\n+\tret = devm_mutex_init(priv-\u003edev, \u0026mb-\u003esds_lock);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D) {\n+\t\t/* Registered after sds_lock, so on release the work is\n+\t\t * cancelled before the mutex is destroyed.\n+\t\t */\n+\t\tINIT_DELAYED_WORK(\u0026mb-\u003esds_relatch,\n+\t\t\t\t rtl8365mb_sds_relatch_work);\n+\t\tret = devm_add_action_or_reset(priv-\u003edev,\n+\t\t\t\t\t rtl8365mb_sds_relatch_cancel,\n+\t\t\t\t\t mb);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\t}\n+\n \tmb-\u003epriv = priv;\n \tmb-\u003ecpu.trap_port = RTL8365MB_MAX_NUM_PORTS;\n \tmb-\u003ecpu.insert = RTL8365MB_CPU_INSERT_TO_ALL;\ndiff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c\nindex 8d49ffadce926..ccfa764b98125 100644\n--- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c\n+++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c\n@@ -44,16 +44,22 @@\n *\n * VLANMC index 0 is reserved as a neutral PVID, used for standalone ports.\n *\n+ * Everything above describes chips that have a VLAN membership configuration\n+ * table. RTL8365MB_FAMILY_D chips do not have one: their PVID is a raw 12-bit\n+ * VID in a per-port register, and no VLANMC entries are allocated.\n+ *\n */\n \n #include \"rtl8365mb_vlan.h\"\n #include \"rtl8365mb_table.h\"\n+#include \"rtl8365mb.h\"\n #include \u003clinux/if_bridge.h\u003e\n #include \u003clinux/lockdep.h\u003e\n #include \u003clinux/regmap.h\u003e\n \n /* CVLAN (i.e. VLAN4k) table entry layout, u16[3] */\n #define RTL8365MB_CVLAN_ENTRY_SIZE\t\t\t3 /* 48-bits */\n+#define RTL8365MB_D_CVLAN_ENTRY_SIZE\t\t\t2 /* 32-bits */\n #define RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK\t\tGENMASK(7, 0)\n #define RTL8365MB_CVLAN_MBR_LO_MASK\t\t\tGENMASK(7, 0)\n #define RTL8365MB_CVLAN_ENTRY_D0_UNTAG_MASK\t\tGENMASK(15, 8)\n@@ -65,6 +71,10 @@\n #define RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK\t\tGENMASK(13, 9)\n #define RTL8365MB_CVLAN_METERIDX_LO_MASK\t\tGENMASK(4, 0)\n #define RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK\t\tGENMASK(14, 14)\n+#define RTL8365MB_D_CVLAN_ENTRY_D1_SVLAN_CHK_IVL_SVL_MASK \\\n+\t\t\t\t\t\t\tGENMASK(2, 2)\n+#define RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK\t\tGENMASK(3, 3)\n+#define RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK\t\tGENMASK(1, 0)\n /* extends RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK */\n #define RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK\t\tGENMASK(2, 0)\n #define RTL8365MB_CVLAN_MBR_HI_MASK\t\t\tGENMASK(10, 8)\n@@ -113,6 +123,11 @@\n #define RTL8365MB_VLAN_PVID_CTRL_PORT_MCIDX_MASK(_p) \\\n \t\t(0x1F \u003c\u003c RTL8365MB_VLAN_PVID_CTRL_PORT_MCIDX_OFFSET(_p))\n \n+#define RTL8365MB_D_VLAN_PVID_CTRL_BASE\t\t\t0x0700\n+#define RTL8365MB_D_VLAN_PVID_CTRL_REG(port) \\\n+\t(RTL8365MB_D_VLAN_PVID_CTRL_BASE + (port))\n+#define RTL8365MB_D_VLAN_PVID_CTRL_MASK\t\t\tGENMASK(11, 0)\n+\n /* Frame type filtering registers */\n #define RTL8365MB_VLAN_ACCEPT_FRAME_TYPE_BASE\t0x07aa\n #define RTL8365MB_VLAN_ACCEPT_FRAME_TYPE_REG(port) \\\n@@ -164,7 +179,7 @@ struct rtl8365mb_vlan4k {\n * This structure is used to get/set entries in the VLAN membership\n * configuration database. This feature is largely vestigial, but\n * still needed for at least the following features:\n- * - PVID configuration\n+ * - PVID configuration (family C only, family D has no VLAN MC table)\n * - ACL configuration\n * - selection of VLAN by the CPU tag when VSEL=1, although the switch\n * can also select VLAN based on the VLAN tag if VSEL=0\n@@ -185,13 +200,16 @@ struct rtl8365mb_vlanmc {\n static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid,\n \t\t\t\t struct rtl8365mb_vlan4k *vlan4k)\n {\n+\tbool is_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;\n+\tsize_t entry_size = is_d ? RTL8365MB_D_CVLAN_ENTRY_SIZE :\n+\t\t\t\t RTL8365MB_CVLAN_ENTRY_SIZE;\n \tu16 data[RTL8365MB_CVLAN_ENTRY_SIZE];\n \tint val;\n \tint ret;\n \n \tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_CVLAN,\n \t\t\t\t RTL8365MB_TABLE_OP_READ, \u0026vid, 0, 0,\n-\t\t\t\t data, ARRAY_SIZE(data));\n+\t\t\t\t data, entry_size);\n \tif (ret)\n \t\treturn ret;\n \n@@ -199,33 +217,61 @@ static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid,\n \tmemset(vlan4k, 0, sizeof(*vlan4k));\n \tvlan4k-\u003evid = vid;\n \n+\t/* member/untag: d0[7:0]/d0[15:8] on both families. Family C\n+\t * extends these into data[2] bits [2:0]/[5:3] for its 9th-11th\n+\t * ports; family D's die has only 8 ports and no third table\n+\t * word, so data[2] does not exist there and must not be read.\n+\t */\n \tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK, data[0]);\n \tvlan4k-\u003emember = FIELD_PREP(RTL8365MB_CVLAN_MBR_LO_MASK, val);\n-\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, data[2]);\n-\tvlan4k-\u003emember |= FIELD_PREP(RTL8365MB_CVLAN_MBR_HI_MASK, val);\n+\tif (!is_d) {\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, data[2]);\n+\t\tvlan4k-\u003emember |= FIELD_PREP(RTL8365MB_CVLAN_MBR_HI_MASK, val);\n+\t}\n \n \tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D0_UNTAG_MASK, data[0]);\n \tvlan4k-\u003euntag = FIELD_PREP(RTL8365MB_CVLAN_UNTAG_LO_MASK, val);\n-\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK, data[2]);\n-\tvlan4k-\u003euntag |= FIELD_PREP(RTL8365MB_CVLAN_UNTAG_HI_MASK, val);\n-\n-\tvlan4k-\u003efid = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK, data[1]);\n-\tvlan4k-\u003epriority_en =\n-\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK, data[1]);\n-\tvlan4k-\u003epriority =\n-\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK, data[1]);\n-\tvlan4k-\u003epolicing_en =\n-\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK, data[1]);\n-\n-\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK, data[1]);\n-\tval = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);\n-\tvlan4k-\u003emeteridx = val;\n-\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK, data[2]);\n-\tval = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);\n-\tvlan4k-\u003emeteridx |= val;\n-\n-\tvlan4k-\u003eivl_en =\n-\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK, data[1]);\n+\tif (!is_d) {\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK,\n+\t\t\t\tdata[2]);\n+\t\tvlan4k-\u003euntag |= FIELD_PREP(RTL8365MB_CVLAN_UNTAG_HI_MASK, val);\n+\t}\n+\n+\tif (is_d) {\n+\t\tvlan4k-\u003efid = FIELD_GET(RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK,\n+\t\t\t\t\tdata[1]);\n+\t\t/* Family D has no priority/meter fields in this entry -\n+\t\t * left zeroed by the memset() above.\n+\t\t */\n+\t\tvlan4k-\u003eivl_en =\n+\t\t\tFIELD_GET(RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK,\n+\t\t\t\t data[1]);\n+\t} else {\n+\t\tvlan4k-\u003efid = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK,\n+\t\t\t\t\tdata[1]);\n+\t\tvlan4k-\u003epriority_en =\n+\t\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK,\n+\t\t\t\t data[1]);\n+\t\tvlan4k-\u003epriority =\n+\t\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK,\n+\t\t\t\t data[1]);\n+\t\tvlan4k-\u003epolicing_en =\n+\t\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK,\n+\t\t\t\t data[1]);\n+\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK,\n+\t\t\t\tdata[1]);\n+\t\tval = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);\n+\t\tvlan4k-\u003emeteridx = val;\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK,\n+\t\t\t\tdata[2]);\n+\t\tval = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);\n+\t\tvlan4k-\u003emeteridx |= val;\n+\n+\t\tvlan4k-\u003eivl_en =\n+\t\t\tFIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK,\n+\t\t\t\t data[1]);\n+\t}\n \n \treturn 0;\n }\n@@ -233,6 +279,9 @@ static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid,\n static int rtl8365mb_vlan_4k_write(struct realtek_priv *priv,\n \t\t\t\t const struct rtl8365mb_vlan4k *vlan4k)\n {\n+\tbool is_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;\n+\tsize_t entry_size = is_d ? RTL8365MB_D_CVLAN_ENTRY_SIZE :\n+\t\t\t\t RTL8365MB_CVLAN_ENTRY_SIZE;\n \tu16 data[RTL8365MB_CVLAN_ENTRY_SIZE] = { 0 };\n \tu16 vid;\n \tint val;\n@@ -244,36 +293,59 @@ static int rtl8365mb_vlan_4k_write(struct realtek_priv *priv,\n \tval = FIELD_GET(RTL8365MB_CVLAN_UNTAG_LO_MASK, vlan4k-\u003euntag);\n \tdata[0] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D0_UNTAG_MASK, val);\n \n-\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK, vlan4k-\u003efid);\n-\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK,\n-\t\t\t vlan4k-\u003epriority_en);\n-\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK,\n-\t\t\t vlan4k-\u003epriority);\n-\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK,\n-\t\t\t vlan4k-\u003epolicing_en);\n-\n-\t/* FIELD_* does not play nice with struct bitfield. */\n-\tval = vlan4k-\u003emeteridx;\n-\tval = FIELD_GET(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);\n-\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK, val);\n-\n-\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK,\n-\t\t\t vlan4k-\u003eivl_en);\n-\n-\tval = FIELD_GET(RTL8365MB_CVLAN_MBR_HI_MASK, vlan4k-\u003emember);\n-\tdata[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, val);\n-\n-\tval = FIELD_GET(RTL8365MB_CVLAN_UNTAG_HI_MASK, vlan4k-\u003euntag);\n-\tdata[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK, val);\n-\n-\tval = vlan4k-\u003emeteridx;\n-\tval = FIELD_GET(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);\n-\tdata[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK, val);\n+\tif (is_d) {\n+\t\t/* The chip supports both IVL and SVL, but the caller (see\n+\t\t * rtl8365mb_vlan_4k_port_set()) never requests SVL, so both\n+\t\t * IVL/SVL selector bits are forced here rather than threaded\n+\t\t * through from vlan4k-\u003eivl_en, which family C does honor.\n+\t\t */\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK,\n+\t\t\t\t 1) |\n+\t\t\t FIELD_PREP(RTL8365MB_D_CVLAN_ENTRY_D1_SVLAN_CHK_IVL_SVL_MASK,\n+\t\t\t\t 1);\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK,\n+\t\t\t\t vlan4k-\u003efid);\n+\t\t/* No priority/meter/member-untag-extension fields exist in\n+\t\t * family D's 2-word entry - data[1] and data[0] above are\n+\t\t * the whole entry, and data[2] is not part of it at all.\n+\t\t */\n+\t} else {\n+\t\tval = vlan4k-\u003efid;\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK, val);\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK,\n+\t\t\t\t vlan4k-\u003epriority_en);\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK,\n+\t\t\t\t vlan4k-\u003epriority);\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK,\n+\t\t\t\t vlan4k-\u003epolicing_en);\n+\n+\t\t/* FIELD_* does not play nice with struct bitfield. */\n+\t\tval = vlan4k-\u003emeteridx;\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK,\n+\t\t\t\t val);\n+\n+\t\tdata[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK,\n+\t\t\t\t vlan4k-\u003eivl_en);\n+\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_MBR_HI_MASK, vlan4k-\u003emember);\n+\t\tdata[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK,\n+\t\t\t\t val);\n+\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_UNTAG_HI_MASK, vlan4k-\u003euntag);\n+\t\tdata[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK,\n+\t\t\t\t val);\n+\n+\t\tval = vlan4k-\u003emeteridx;\n+\t\tval = FIELD_GET(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);\n+\t\tdata[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK,\n+\t\t\t\t val);\n+\t}\n \n \tvid = vlan4k-\u003evid;\n \treturn rtl8365mb_table_query(priv, RTL8365MB_TABLE_CVLAN,\n \t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026vid, 0, 0,\n-\t\t\t\t data, ARRAY_SIZE(data));\n+\t\t\t\t data, entry_size);\n }\n \n static int\n@@ -679,11 +751,25 @@ int rtl8365mb_vlan_port_get_pvid(struct realtek_priv *priv, int port, u16 *pvid)\n \tu8 vlanmc_idx;\n \tint ret;\n \n-\tret = rtl8365mb_vlan_get_pvid_mc(priv, port, \u0026vlanmc_idx, \u0026vlanmc);\n-\tif (ret)\n-\t\treturn ret;\n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D) {\n+\t\tu32 data;\n+\n+\t\tret = regmap_read(priv-\u003emap,\n+\t\t\t\t RTL8365MB_D_VLAN_PVID_CTRL_REG(port),\n+\t\t\t\t \u0026data);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\t*pvid = data \u0026 RTL8365MB_D_VLAN_PVID_CTRL_MASK;\n+\t} else {\n+\t\tret = rtl8365mb_vlan_get_pvid_mc(priv, port, \u0026vlanmc_idx,\n+\t\t\t\t\t\t \u0026vlanmc);\n+\t\tif (ret)\n+\t\t\treturn ret;\n+\n+\t\t*pvid = vlanmc.evid;\n+\t}\n \n-\t*pvid = vlanmc.evid;\n \treturn 0;\n }\n \n@@ -748,6 +834,68 @@ rtl8365mb_vlan_port_set_framefilter(struct realtek_priv *priv,\n \t\t\t\t val);\n }\n \n+/*\n+ * rtl8365mb_vlan_pvid_port_set_direct() - Configure a port's PVID as a raw\n+ * VID written to its dedicated register, for chip families without a\n+ * working VLAN MC table (RTL8365MB_FAMILY_D)\n+ *\n+ * Reads back the previous PVID and frame filter first so both can be\n+ * restored if enabling the new PVID fails partway through, matching\n+ * the rollback behavior of the family-C implementation below.\n+ *\n+ * Context: Can sleep. Must be called with \u0026priv-\u003evlan_lock held.\n+ * Return: 0 on success, or a negative error code on failure.\n+ */\n+static int rtl8365mb_vlan_pvid_port_set_direct(struct realtek_priv *priv,\n+\t\t\t\t\t int port, u16 vid)\n+{\n+\tenum rtl8365mb_frame_ingress prev_accepted_frame;\n+\tu32 prev_pvid;\n+\tint ret;\n+\n+\tret = regmap_read(priv-\u003emap, RTL8365MB_D_VLAN_PVID_CTRL_REG(port),\n+\t\t\t \u0026prev_pvid);\n+\tif (ret) {\n+\t\tdev_err(priv-\u003edev, \"Failed to read current PVID\\n\");\n+\t\treturn ret;\n+\t}\n+\tprev_pvid \u0026= RTL8365MB_D_VLAN_PVID_CTRL_MASK;\n+\n+\tret = rtl8365mb_vlan_port_get_framefilter(priv, port,\n+\t\t\t\t\t\t \u0026prev_accepted_frame);\n+\tif (ret) {\n+\t\tdev_err(priv-\u003edev, \"Failed to get current framefilter\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\tret = regmap_update_bits(priv-\u003emap,\n+\t\t\t\t RTL8365MB_D_VLAN_PVID_CTRL_REG(port),\n+\t\t\t\t RTL8365MB_D_VLAN_PVID_CTRL_MASK,\n+\t\t\t\t vid \u0026 RTL8365MB_D_VLAN_PVID_CTRL_MASK);\n+\tif (ret) {\n+\t\tdev_err(priv-\u003edev, \"Failed to set port PVID\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\t/* Changing accept frame is what enables PVID (if not enabled before) */\n+\tret = rtl8365mb_vlan_port_set_framefilter(priv, port,\n+\t\t\t\t\t\t RTL8365MB_FRAME_TYPE_ANY_FRAME);\n+\tif (ret) {\n+\t\tdev_err(priv-\u003edev, \"Failed to set port frame filter\\n\");\n+\t\tgoto undo_pvid_write;\n+\t}\n+\n+\treturn 0;\n+\n+undo_pvid_write:\n+\t(void)regmap_update_bits(priv-\u003emap,\n+\t\t\t\t RTL8365MB_D_VLAN_PVID_CTRL_REG(port),\n+\t\t\t\t RTL8365MB_D_VLAN_PVID_CTRL_MASK, prev_pvid);\n+\t(void)rtl8365mb_vlan_port_set_framefilter(priv, port,\n+\t\t\t\t\t\t prev_accepted_frame);\n+\treturn ret;\n+}\n+\n /*\n * rtl8365mb_vlan_pvid_port_set() - Configure a port's PVID and associated\n * VLANMC entry\n@@ -760,6 +908,9 @@ rtl8365mb_vlan_port_set_framefilter(struct realtek_priv *priv,\n * PVID. Gracefully unwinds and restores previous configuration if a hardware\n * write operation fails during execution.\n *\n+ * On RTL8365MB_FAMILY_D there is no VLANMC table: the VID is written directly\n+ * to the port's PVID register and no VLANMC entry is allocated.\n+ *\n * Context: Can sleep. Must be called with \u0026priv-\u003evlan_lock held.\n * Takes and releases \u0026priv-\u003emap_lock.\n * Return: 0 on success, or a negative error code on failure.\n@@ -777,6 +928,13 @@ int rtl8365mb_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid,\n \n \tlockdep_assert_held(\u0026priv-\u003evlan_lock);\n \n+\t/* This chip family has no VLAN MC table - PVID is a raw VID in a\n+\t * dedicated per-port register, and there is no separate membership\n+\t * table entry to allocate/track.\n+\t */\n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)\n+\t\treturn rtl8365mb_vlan_pvid_port_set_direct(priv, port, vid);\n+\n \t/* Read the old PVID exclusively to undo in case of error */\n \tret = rtl8365mb_vlan_get_pvid_mc(priv, port, \u0026prev_vlanmc_idx,\n \t\t\t\t\t \u0026prev_vlanmc);\n@@ -856,6 +1014,76 @@ int rtl8365mb_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid,\n \treturn ret;\n }\n \n+/*\n+ * rtl8365mb_vlan_pvid_port_clear_direct() - Remove a port's raw-VID PVID\n+ * configuration, for chip families without a working VLAN MC table\n+ * (RTL8365MB_FAMILY_D)\n+ *\n+ * Reads back the previous frame filter first so it can be restored if\n+ * clearing the PVID register fails.\n+ *\n+ * Context: Can sleep. Must be called with \u0026priv-\u003evlan_lock held.\n+ * Return: 0 on success, or a negative error code on failure.\n+ */\n+static int rtl8365mb_vlan_pvid_port_clear_direct(struct dsa_switch *ds,\n+\t\t\t\t\t\t int port, u16 vid)\n+{\n+\tenum rtl8365mb_frame_ingress prev_accepted_frame;\n+\tstruct realtek_priv *priv = ds-\u003epriv;\n+\tbool filtering;\n+\tu32 cur_pvid;\n+\tint ret;\n+\n+\tret = regmap_read(priv-\u003emap, RTL8365MB_D_VLAN_PVID_CTRL_REG(port),\n+\t\t\t \u0026cur_pvid);\n+\tif (ret) {\n+\t\tdev_err(priv-\u003edev, \"Failed to read current PVID\\n\");\n+\t\treturn ret;\n+\t}\n+\n+\t/* Port is not using this VID as PVID. Nothing to remove. */\n+\tif ((cur_pvid \u0026 RTL8365MB_D_VLAN_PVID_CTRL_MASK) != vid)\n+\t\treturn 0;\n+\n+\tfiltering = dsa_port_is_vlan_filtering(dsa_to_port(ds, port));\n+\n+\t/* Changing accept frame is what really removes PVID. But only do\n+\t * that if VLAN filtering is enabled.\n+\t */\n+\tif (filtering) {\n+\t\tret = rtl8365mb_vlan_port_get_framefilter(priv, port,\n+\t\t\t\t\t\t\t \u0026prev_accepted_frame);\n+\t\tif (ret) {\n+\t\t\tdev_err(priv-\u003edev,\n+\t\t\t\t\"Failed to get current framefilter\\n\");\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\tret = rtl8365mb_vlan_port_set_framefilter(\n+\t\t\tpriv, port, RTL8365MB_FRAME_TYPE_TAGGED_ONLY);\n+\t\tif (ret) {\n+\t\t\tdev_err(priv-\u003edev, \"Failed to set port frame filter\\n\");\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n+\tret = regmap_update_bits(priv-\u003emap,\n+\t\t\t\t RTL8365MB_D_VLAN_PVID_CTRL_REG(port),\n+\t\t\t\t RTL8365MB_D_VLAN_PVID_CTRL_MASK, 0);\n+\tif (ret) {\n+\t\tdev_err(priv-\u003edev, \"Failed to set port PVID to 0\\n\");\n+\t\tgoto undo_set_framefilter;\n+\t}\n+\n+\treturn 0;\n+\n+undo_set_framefilter:\n+\tif (filtering)\n+\t\t(void)rtl8365mb_vlan_port_set_framefilter(priv, port,\n+\t\t\t\t\t\t\t prev_accepted_frame);\n+\treturn ret;\n+}\n+\n /*\n * rtl8365mb_vlan_pvid_port_clear() - Remove a port's PVID configuration\n * @ds: dsa switch instance\n@@ -865,6 +1093,9 @@ int rtl8365mb_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid,\n * Resets the target port's hardware PVID allocation to 0. Cleans up and frees\n * the associated VLANMC entry if no other ports are referencing it.\n *\n+ * On RTL8365MB_FAMILY_D the port's PVID register is reset to 0 directly; there\n+ * is no VLANMC entry to free.\n+ *\n * Context: Can sleep. Must be called with \u0026priv-\u003evlan_lock held.\n * Takes and releases \u0026priv-\u003emap_lock.\n * Return: 0 on success, or a negative error code on failure.\n@@ -879,6 +1110,9 @@ int rtl8365mb_vlan_pvid_port_clear(struct dsa_switch *ds, int port, u16 vid)\n \n \tlockdep_assert_held(\u0026priv-\u003evlan_lock);\n \n+\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)\n+\t\treturn rtl8365mb_vlan_pvid_port_clear_direct(ds, port, vid);\n+\n \tret = rtl8365mb_vlan_get_pvid_mc(priv, port, \u0026vlanmc_idx,\n \t\t\t\t\t \u0026vlanmc);\n \tif (ret) {\n"
} |
| 2/1 | 2026/10/10 20:14 | agent | patch-evaluator |
1mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series adds support for the Realtek RTL8367S-VB Ethernet switch (family D) to the Realtek RTL8365MB DSA switch driver (drivers/net/dsa/realtek/). This driver requires a physical Realtek switch ASIC controlled via MDIO or SMI (GPIO bitbang) and instantiated through Device Tree. Because the hardware is not emulated in standard virtualized fuzzing environments (QEMU or GCE), the modified code is structurally unreachable.",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any '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: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 22407d15ad3a0de6fff85a5f057352aa04b58709
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Oct 10 20:14:04 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/devicetree/bindings/net/dsa/realtek.yaml b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
index b7bb60af623ca..e330dc649adda 100644
--- a/Documentation/devicetree/bindings/net/dsa/realtek.yaml
+++ b/Documentation/devicetree/bindings/net/dsa/realtek.yaml
@@ -57,7 +57,7 @@ properties:
realtek,rtl8365mb:
Use with models RTL8363NB, RTL8363NB-VB, RTL8363SC, RTL8363SC-VB,
RTL8364NB, RTL8364NB-VB, RTL8365MB, RTL8366SC, RTL8367RB-VB, RTL8367S,
- RTL8367SB, RTL8370MB, RTL8310SR
+ RTL8367S-VB, RTL8367SB, RTL8370MB, RTL8310SR
realtek,rtl8366rb:
Use with models RTL8366RB, RTL8366S
diff --git a/drivers/net/dsa/realtek/rtl8365mb.h b/drivers/net/dsa/realtek/rtl8365mb.h
new file mode 100644
index 0000000000000..315de4c93c446
--- /dev/null
+++ b/drivers/net/dsa/realtek/rtl8365mb.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _RTL8365MB_H
+#define _RTL8365MB_H
+
+#include "realtek.h"
+
+enum rtl8365mb_family {
+ RTL8365MB_FAMILY_C,
+ RTL8365MB_FAMILY_D,
+};
+
+enum rtl8365mb_family rtl8365mb_get_family(struct realtek_priv *priv);
+
+#endif /* _RTL8365MB_H */
diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
index da06f952a053d..c6045607ade06 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_main.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
@@ -89,6 +89,12 @@
* things will work out-of-the-box for other chips, and a careful review of the
* vendor driver may be needed to expand support. The RTL8365MB-VC seems to be
* one of the simpler chips.
+ *
+ * The RTL8367S-VB (chip ID 0x6642) is not part of the family listed above. It
+ * belongs to a newer generation, which this driver calls family D. Its
+ * registers differ in the VLAN table, the external interface speed and RGMII
+ * configuration and the SerDes, so the code paths specific to it are selected
+ * with rtl8365mb_get_family().
*/
#include <linux/bitfield.h>
@@ -97,6 +103,7 @@
#include <linux/irqdomain.h>
#include <linux/mii.h>
#include <linux/mutex.h>
+#include <linux/workqueue.h>
#include <linux/of_irq.h>
#include <linux/regmap.h>
#include <linux/if_bridge.h>
@@ -110,15 +117,17 @@
#include "rtl83xx.h"
#include "rtl8365mb_l2.h"
#include "rtl8365mb_vlan.h"
+#include "rtl8365mb.h"
/* Family-specific data and limits */
#define RTL8365MB_PHYADDRMAX 7
#define RTL8365MB_NUM_PHYREGS 32
#define RTL8365MB_PHYREGMAX (RTL8365MB_NUM_PHYREGS - 1)
#define RTL8365MB_MAX_NUM_PORTS 11
-/* Valid for the whole family except RTL8370B, which has 4160 entries.
- * RTL8370B is mentioned in vendor code but it might not even belong
- * to the same RTL8367C family.
+#define RTL8365MB_D_MAX_NUM_PORTS 8
+/* Valid for the whole RTL8367C family (and for family D, RTL8367S-VB)
+ * except RTL8370B, which has 4160 entries. RTL8370B is mentioned in
+ * vendor code but it might not even belong to the same RTL8367C family.
*/
#define RTL8365MB_LEARN_LIMIT_MAX 2112
#define RTL8365MB_MAX_NUM_EXTINTS 3
@@ -283,6 +292,7 @@
#define RTL8365MB_SDS_INDACS_CMD_BUSY_MASK BIT(8)
#define RTL8365MB_SDS_INDACS_CMD_RUN_MASK BIT(7)
#define RTL8365MB_SDS_INDACS_CMD_WR_MASK BIT(6)
+#define RTL8365MB_SDS_INDACS_CMD_INDEX_MASK GENMASK(5, 0)
#define RTL8365MB_SDS_INDACS_ADR_REG 0x6601
#define RTL8365MB_SDS_INDACS_DATA_REG 0x6602
@@ -296,6 +306,28 @@
#define RTL8365MB_SDS_MISC_SGMII_SPD_MASK GENMASK(8, 7)
#define RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK BIT(6)
+/* Re-latch retry interval and attempt budget. Each attempt parks the
+ * SerDes for 20 ms, so a far end that never comes up must not be retried
+ * at this rate forever, and the interval must not be so tight that
+ * back-to-back parks starve a link that is about to latch. The count is
+ * reset to 1 by pcs_config() and to 0 whenever the receiver latches;
+ * attempts start at pcs_config(), well before the far end MAC is up, so
+ * with the interval below the budget is roughly RELATCH_MAX_TRIES seconds,
+ * generous enough to outlast a slow conduit.
+ */
+#define RTL8365MB_D_SDS_RELATCH_INTERVAL (HZ)
+#define RTL8365MB_D_SDS_RELATCH_MAX_TRIES 15
+
+/* The SerDes stays parked until the restore write succeeds, so a failed
+ * write is retried this many times before giving up until the next run.
+ */
+#define RTL8365MB_D_SDS_RESTORE_TRIES 3
+
+/* How often a latched (or out-of-budget) SerDes is checked, and re-latched
+ * if still down. Much slower than the re-latch interval.
+ */
+#define RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL (10 * HZ)
+
/* SerDes internal registers, accessed via the SDS_INDACS registers. The BMCR
* data path reset holds BMCR_ANENABLE | BMCR_ISOLATE while toggling the
* vendor-specific low bits from phase 1 to phase 2, which triggers a data path
@@ -331,6 +363,27 @@
#define RTL8365MB_SDS_OPTION_ARM_KEY 0x0249
#define RTL8365MB_SDS_OPTION_REG 0x13C1
+/* Family D uses the SDS13 indirect window for its MAC6 SerDes. */
+#define RTL8365MB_D_SDS_EXT0_INDEX 13
+#define RTL8365MB_D_FIBER_CFG2_REG 0x13E8
+#define RTL8365MB_D_FIBER_CFG2_RX_DISABLE_MASK GENMASK(7, 6)
+#define RTL8365MB_D_FIBER_CFG2_RX_DISABLE_SDS0 BIT(6)
+#define RTL8365MB_D_SDS_MISC_PA33PC_EN BIT(11)
+#define RTL8365MB_D_SDS_MISC_PA12PC_EN BIT(10)
+#define RTL8365MB_D_SDS_MISC_MAC6_SEL_SDS0 BIT(9)
+#define RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK GENMASK(4, 0)
+#define RTL8365MB_D_SDS_MISC_MODE_SGMII 0x02
+#define RTL8365MB_D_SDS_MISC_MODE_HSGMII 0x12
+#define RTL8365MB_D_SDS_MISC_CFG_MASK \
+ (RTL8365MB_D_SDS_MISC_PA33PC_EN | \
+ RTL8365MB_D_SDS_MISC_PA12PC_EN | \
+ RTL8365MB_D_SDS_MISC_MAC6_SEL_SDS0 | \
+ RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK)
+/* Shared "disable" encoding for both SDS_MISC's and SDS1_MISC0's
+ * 5-bit mode fields.
+ */
+#define RTL8365MB_D_PORT_SDS_MODE_DISABLE 0x1f
+
/* Embedded DW8051 microcontroller control registers. The microcontroller
* can run firmware to manage the SerDes link, but this driver keeps it in
* reset and disabled: phylink already performs the link management that
@@ -343,6 +396,7 @@
#define RTL8365MB_PORT_SPEED_10M 0
#define RTL8365MB_PORT_SPEED_100M 1
#define RTL8365MB_PORT_SPEED_1000M 2
+#define RTL8365MB_D_PORT_SPEED_2500M 5
/* External interface force configuration registers 0~2 */
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_REG0 0x1310 /* EXT0 */
@@ -360,6 +414,21 @@
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_LINK_MASK BIT(4)
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_DUPLEX_MASK BIT(2)
#define RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK GENMASK(1, 0)
+/* Width of the FORCE_SPEED field, bits[1:0] */
+#define RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_WIDTH 2
+
+/* bits[13:12]; bit 13 reserved, no defined speed value uses it yet */
+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_SPEED2_MASK GENMASK(13, 12)
+
+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_BASE 0x12c0
+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG(_port) \
+ (RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_BASE + (_port))
+
+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_BASE 0x12c8
+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_EN(_port) \
+ (RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_BASE + (_port))
+
+#define RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_ALL_MASK GENMASK(15, 0)
/* CPU port mask register - controls which ports are treated as CPU ports */
#define RTL8365MB_CPU_PORT_MASK_REG 0x1219
@@ -441,6 +510,20 @@
#define RTL8365MB_PORT_MISC_CFG_VLAN_EGRESS_MODE_MASK GENMASK(5, 4)
#define RTL8365MB_PORT_MISC_CFG_CONGESTION_SUSTAIN_TIME_MASK GENMASK(3, 0)
+/* EXT_TXC_DLY holds a 3-bit TX clock delay per external interface, for
+ * RGMII ([2:0] EXT0, [5:3] EXT1, [8:6] EXT2) and separately for GMII.
+ * Only the EXT1 RGMII field is used here, and it is cleared in RGMII
+ * mode so that tx-internal-delay-ps is the only TX delay applied.
+ */
+#define RTL8365MB_D_REG_EXT_TXC_DLY 0x13f9
+#define RTL8365MB_D_EXT1_RGMII_TX_DLY_MASK GENMASK(5, 3)
+
+#define RTL8365MB_D_REG_TOP_CON0 0x1d70
+#define RTL8365MB_D_MAC7_SEL_EXT1_MASK BIT(13)
+#define RTL8365MB_D_MAC4_SEL_EXT1_MASK BIT(12)
+
+#define RTL8365MB_D_REG_SDS1_MISC0 0x1d78
+
/**
* enum rtl8365mb_vlan_egress_mode - port VLAN egress mode
* @RTL8365MB_VLAN_EGRESS_MODE_ORIGINAL: follow untag mask in VLAN4k table entry
@@ -676,6 +759,21 @@ static const struct rtl8365mb_jam_tbl_entry rtl8365mb_sds_jam_hsgmii[] = {
{ 0x0424, 0xD810 }, { 0x0001, 0x0F80 }, { 0x002E, 0x83F2 },
};
+/* Family D tuning tables from the Realtek vendor port API. */
+static const struct rtl8365mb_jam_tbl_entry rtl8365mb_d_sds_jam_sgmii[] = {
+ { 0x0427, 0x4E0C }, { 0x0428, 0xAA00 }, { 0x0425, 0x5189 },
+ { 0x0424, 0x8414 }, { 0x0423, 0x1020 }, { 0x0410, 0x0002 },
+ { 0x0484, 0x011B }, { 0x0421, 0x8E13 }, { 0x0422, 0x1140 },
+ { 0x0004, 0x074F },
+};
+
+static const struct rtl8365mb_jam_tbl_entry rtl8365mb_d_sds_jam_hsgmii[] = {
+ { 0x0427, 0x4E0C }, { 0x0428, 0xAA00 }, { 0x0425, 0x5189 },
+ { 0x0424, 0x8414 }, { 0x0423, 0x1020 }, { 0x0410, 0x0002 },
+ { 0x0504, 0x051B }, { 0x0421, 0x8E13 }, { 0x0422, 0x1140 },
+ { 0x0004, 0x074F },
+};
+
enum rtl8365mb_phy_interface_mode {
RTL8365MB_PHY_INTERFACE_MODE_INVAL = 0,
RTL8365MB_PHY_INTERFACE_MODE_INTERNAL = BIT(0),
@@ -707,6 +805,7 @@ struct rtl8365mb_extint {
* @name: human-readable chip name
* @chip_id: chip identifier
* @chip_ver: chip silicon revision
+ * @family: chip family
* @extints: available external interfaces
* @jam_table: chip-specific initialization jam table
* @jam_size: size of the chip's jam table
@@ -719,6 +818,7 @@ struct rtl8365mb_chip_info {
const char *name;
u32 chip_id;
u32 chip_ver;
+ enum rtl8365mb_family family;
const struct rtl8365mb_extint extints[RTL8365MB_MAX_NUM_EXTINTS];
const struct rtl8365mb_jam_tbl_entry *jam_table;
size_t jam_size;
@@ -731,6 +831,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.name = "RTL8365MB-VC",
.chip_id = 0x6367,
.chip_ver = 0x0040,
+ .family = RTL8365MB_FAMILY_C,
.extints = {
{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |
PHY_INTF(RMII) | PHY_INTF(RGMII) },
@@ -742,6 +843,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.name = "RTL8367S",
.chip_id = 0x6367,
.chip_ver = 0x00A0,
+ .family = RTL8365MB_FAMILY_C,
.extints = {
{ 6, 1, PHY_INTF(SGMII) | PHY_INTF(HSGMII) },
{ 7, 2, PHY_INTF(MII) | PHY_INTF(TMII) |
@@ -754,6 +856,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.name = "RTL8367SB",
.chip_id = 0x6367,
.chip_ver = 0x0010,
+ .family = RTL8365MB_FAMILY_C,
.extints = {
{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |
PHY_INTF(RMII) | PHY_INTF(RGMII) |
@@ -768,6 +871,7 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.name = "RTL8367RB-VB",
.chip_id = 0x6367,
.chip_ver = 0x0020,
+ .family = RTL8365MB_FAMILY_C,
.extints = {
{ 6, 1, PHY_INTF(MII) | PHY_INTF(TMII) |
PHY_INTF(RMII) | PHY_INTF(RGMII) },
@@ -777,6 +881,19 @@ static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = {
.jam_table = rtl8365mb_init_jam_8365mb_vc,
.jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc),
},
+ {
+ .name = "RTL8367S-VB",
+ .chip_id = 0x6642,
+ .chip_ver = 0x0010,
+ .family = RTL8365MB_FAMILY_D,
+ .extints = {
+ { 6, 0, PHY_INTF(SGMII) | PHY_INTF(HSGMII) },
+ { 7, 1, PHY_INTF(MII) | PHY_INTF(TMII) |
+ PHY_INTF(RMII) | PHY_INTF(RGMII) },
+ },
+ .jam_table = rtl8365mb_init_jam_8365mb_vc,
+ .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc),
+ },
};
enum rtl8365mb_stp_state {
@@ -854,10 +971,16 @@ struct rtl8365mb_port {
* @chip_info: chip-specific info about the attached switch
* @cpu: CPU tagging and CPU port configuration for this chip
* @mib_lock: prevent concurrent reads of MIB counters
+ * @sds_lock: serializes access to the shared SDS_INDACS ADR/CMD/DATA window,
+ * reachable both from phylink's PCS callbacks and from the
+ * family D SerDes re-latch work
* @ports: per-port data
* @pcs: PCS for the SerDes external interface
* @sds_supported: SerDes tuning parameters match the chip option, so the
* SerDes interface modes can be advertised
+ * @sds_relatch: re-latch edges and link health check (family D)
+ * @sds_relatch_count: next attempt of the re-latch episode, 0 once latched
+ * @sds_misc_target_val: SDS_MISC_CFG_MASK fields the re-latch work restores
*
* Private data for this driver.
*/
@@ -867,13 +990,24 @@ struct rtl8365mb {
const struct rtl8365mb_chip_info *chip_info;
struct rtl8365mb_cpu cpu;
struct mutex mib_lock;
+ struct mutex sds_lock;
struct rtl8365mb_port ports[RTL8365MB_MAX_NUM_PORTS];
struct phylink_pcs pcs;
bool sds_supported;
+ struct delayed_work sds_relatch;
+ unsigned int sds_relatch_count;
+ u32 sds_misc_target_val;
};
#define pcs_to_rtl8365mb(_pcs) container_of((_pcs), struct rtl8365mb, pcs)
+enum rtl8365mb_family rtl8365mb_get_family(struct realtek_priv *priv)
+{
+ struct rtl8365mb *mb = priv->chip_data;
+
+ return mb->chip_info->family;
+}
+
static int rtl8365mb_phy_poll_busy(struct realtek_priv *priv)
{
u32 val;
@@ -1164,6 +1298,7 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,
struct dsa_port *dp;
int tx_delay = 0;
int rx_delay = 0;
+ u32 data;
u32 val;
int ret;
@@ -1233,43 +1368,88 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,
if (ret)
return ret;
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D &&
+ extint->id == 1) {
+ ret = regmap_update_bits(priv->map,
+ RTL8365MB_D_REG_EXT_TXC_DLY,
+ RTL8365MB_D_EXT1_RGMII_TX_DLY_MASK, 0);
+ if (ret)
+ return ret;
+ /* Configure RGMII/MII mux to port 7 if UTP_PORT4 is not in
+ * RGMII mode
+ */
+ ret = regmap_read(priv->map, RTL8365MB_D_REG_TOP_CON0, &data);
+ if (ret)
+ return ret;
+ if ((data & RTL8365MB_D_MAC4_SEL_EXT1_MASK) == 0) {
+ ret = regmap_update_bits(priv->map,
+ RTL8365MB_D_REG_TOP_CON0,
+ RTL8365MB_D_MAC7_SEL_EXT1_MASK,
+ RTL8365MB_D_MAC7_SEL_EXT1_MASK);
+ if (ret)
+ return ret;
+ }
+ ret = regmap_update_bits(priv->map,
+ RTL8365MB_D_REG_SDS1_MISC0,
+ RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK,
+ RTL8365MB_D_PORT_SDS_MODE_DISABLE);
+ if (ret)
+ return ret;
+ }
+
return 0;
}
-static int rtl8365mb_sds_write(struct realtek_priv *priv, u16 addr, u16 data)
+static int rtl8365mb_sds_write(struct realtek_priv *priv, u8 index,
+ u16 addr, u16 data)
{
+ struct rtl8365mb *mb = priv->chip_data;
int ret;
+ mutex_lock(&mb->sds_lock);
+
ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_DATA_REG, data);
if (ret)
- return ret;
+ goto out_unlock;
ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_ADR_REG, addr);
if (ret)
- return ret;
+ goto out_unlock;
/* The SerDes indirect access engine completes the command within the
* register write transaction, so there is no need to wait or poll for
* completion before the next access, matching the vendor driver.
*/
- return regmap_write(priv->map, RTL8365MB_SDS_INDACS_CMD_REG,
- RTL8365MB_SDS_INDACS_CMD_RUN_MASK |
- RTL8365MB_SDS_INDACS_CMD_WR_MASK);
+ ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_CMD_REG,
+ RTL8365MB_SDS_INDACS_CMD_RUN_MASK |
+ RTL8365MB_SDS_INDACS_CMD_WR_MASK |
+ FIELD_PREP(RTL8365MB_SDS_INDACS_CMD_INDEX_MASK,
+ index));
+
+out_unlock:
+ mutex_unlock(&mb->sds_lock);
+ return ret;
}
-static int rtl8365mb_sds_read(struct realtek_priv *priv, u16 addr, u16 *data)
+static int rtl8365mb_sds_read(struct realtek_priv *priv, u8 index,
+ u16 addr, u16 *data)
{
+ struct rtl8365mb *mb = priv->chip_data;
u32 val;
int ret;
+ mutex_lock(&mb->sds_lock);
+
ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_ADR_REG, addr);
if (ret)
- return ret;
+ goto out_unlock;
ret = regmap_write(priv->map, RTL8365MB_SDS_INDACS_CMD_REG,
- RTL8365MB_SDS_INDACS_CMD_RUN_MASK);
+ RTL8365MB_SDS_INDACS_CMD_RUN_MASK |
+ FIELD_PREP(RTL8365MB_SDS_INDACS_CMD_INDEX_MASK,
+ index));
if (ret)
- return ret;
+ goto out_unlock;
/* Wait for the indirect read to complete: the engine clears the BUSY
* bit once the data register holds the result.
@@ -1279,15 +1459,19 @@ static int rtl8365mb_sds_read(struct realtek_priv *priv, u16 addr, u16 *data)
!(val & RTL8365MB_SDS_INDACS_CMD_BUSY_MASK),
10, 1000);
if (ret)
- return ret;
+ goto out_unlock;
ret = regmap_read(priv->map, RTL8365MB_SDS_INDACS_DATA_REG, &val);
if (ret)
- return ret;
+ goto out_unlock;
*data = val;
- return 0;
+ ret = 0;
+
+out_unlock:
+ mutex_unlock(&mb->sds_lock);
+ return ret;
}
/* The vendor driver selects between two sets of SerDes tuning parameters based
@@ -1307,6 +1491,14 @@ static int rtl8365mb_sds_probe_option(struct realtek_priv *priv)
int ret;
int i;
+ /* Family D has a fixed SDS13 programming model and does not use the
+ * family C option register to select its tuning table.
+ */
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D) {
+ mb->sds_supported = true;
+ return 0;
+ }
+
/* Nothing to probe if no external interface is wired to the SerDes */
for (i = 0; i < RTL8365MB_MAX_NUM_EXTINTS; i++) {
extint = &mb->chip_info->extints[i];
@@ -1385,28 +1577,54 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
const unsigned long *advertising,
bool permit_pause_to_mac)
{
- const struct rtl8365mb_jam_tbl_entry *sds_jam;
const int id = RTL8365MB_SDS_EXT_INTERFACE_ID;
+ const struct rtl8365mb_jam_tbl_entry *sds_jam;
struct rtl8365mb *mb = pcs_to_rtl8365mb(pcs);
- struct realtek_priv *priv;
+ struct realtek_priv *priv = mb->priv;
size_t sds_jam_size;
- u32 mode;
+ u32 misc_mask;
+ u32 misc_val;
+ u32 sds_mode;
+ u8 sds_index;
+ bool is_d;
u16 val;
int ret;
int i;
- priv = mb->priv;
+ is_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;
+ /* Cancel any in-flight re-latch edge before touching SDS_MISC: the
+ * work parks SDS_MISC and restores the target value after a sleep, so
+ * it could otherwise write a stale target over the new configuration.
+ */
+ if (is_d)
+ cancel_delayed_work_sync(&mb->sds_relatch);
+
+ /* Select the appropriate tuning table and SDS mode */
if (interface == PHY_INTERFACE_MODE_2500BASEX) {
- sds_jam = rtl8365mb_sds_jam_hsgmii;
- sds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_hsgmii);
- mode = RTL8365MB_EXT_PORT_MODE_HSGMII;
+ if (is_d) {
+ sds_jam = rtl8365mb_d_sds_jam_hsgmii;
+ sds_jam_size = ARRAY_SIZE(rtl8365mb_d_sds_jam_hsgmii);
+ sds_mode = RTL8365MB_D_SDS_MISC_MODE_HSGMII;
+ } else {
+ sds_jam = rtl8365mb_sds_jam_hsgmii;
+ sds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_hsgmii);
+ sds_mode = RTL8365MB_EXT_PORT_MODE_HSGMII;
+ }
} else {
- sds_jam = rtl8365mb_sds_jam_sgmii;
- sds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_sgmii);
- mode = RTL8365MB_EXT_PORT_MODE_SGMII;
+ if (is_d) {
+ sds_jam = rtl8365mb_d_sds_jam_sgmii;
+ sds_jam_size = ARRAY_SIZE(rtl8365mb_d_sds_jam_sgmii);
+ sds_mode = RTL8365MB_D_SDS_MISC_MODE_SGMII;
+ } else {
+ sds_jam = rtl8365mb_sds_jam_sgmii;
+ sds_jam_size = ARRAY_SIZE(rtl8365mb_sds_jam_sgmii);
+ sds_mode = RTL8365MB_EXT_PORT_MODE_SGMII;
+ }
}
+ sds_index = is_d ? RTL8365MB_D_SDS_EXT0_INDEX : 0;
+
/* Hold the embedded DW8051 microcontroller in reset and keep it
* disabled. The vendor driver loads firmware into it to manage the
* SerDes link, but the firmware only duplicates work that phylink
@@ -1435,34 +1653,55 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
/* Tune the SerDes with vendor-prescribed parameters */
for (i = 0; i < sds_jam_size; i++) {
- ret = rtl8365mb_sds_write(priv, sds_jam[i].reg,
- sds_jam[i].val);
+ ret = rtl8365mb_sds_write(priv, sds_index,
+ sds_jam[i].reg, sds_jam[i].val);
if (ret)
return ret;
}
- /* Mux the SerDes to MAC8 in the requested mode */
+ /* Family-specific post-tuning configuration */
+ if (is_d) {
+ ret = regmap_update_bits(priv->map, RTL8365MB_D_FIBER_CFG2_REG,
+ RTL8365MB_D_FIBER_CFG2_RX_DISABLE_MASK,
+ RTL8365MB_D_FIBER_CFG2_RX_DISABLE_SDS0);
+ if (ret)
+ return ret;
+
+ misc_mask = RTL8365MB_D_SDS_MISC_CFG_MASK;
+ misc_val = RTL8365MB_D_SDS_MISC_PA33PC_EN |
+ RTL8365MB_D_SDS_MISC_PA12PC_EN |
+ RTL8365MB_D_SDS_MISC_MAC6_SEL_SDS0 | sds_mode;
+ } else {
+ /* Mux the SerDes to MAC8 in the requested mode */
+ misc_mask = RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK |
+ RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK;
+ misc_val = (sds_mode == RTL8365MB_EXT_PORT_MODE_SGMII) ?
+ RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK :
+ RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK;
+ }
+
ret = regmap_update_bits(priv->map, RTL8365MB_SDS_MISC_REG,
- RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK |
- RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK,
- mode == RTL8365MB_EXT_PORT_MODE_SGMII ?
- RTL8365MB_SDS_MISC_MAC8_SEL_SGMII_MASK :
- RTL8365MB_SDS_MISC_MAC8_SEL_HSGMII_MASK);
+ misc_mask, misc_val);
if (ret)
return ret;
- val = mode << RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(id);
- ret = regmap_update_bits(priv->map,
- RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(id),
- RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(id),
- val);
- if (ret)
- return ret;
+ if (is_d) {
+ WRITE_ONCE(mb->sds_misc_target_val, misc_val);
+ } else {
+ val = sds_mode << RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_OFFSET(id);
+ ret = regmap_update_bits(priv->map,
+ RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(id),
+ RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(id),
+ val);
+ if (ret)
+ return ret;
+ }
/* Take the SerDes out of reset. The vendor driver does this only
* after the SerDes mux and the interface mode are configured.
*/
- ret = rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_RESET,
+ ret = rtl8365mb_sds_write(priv, sds_index,
+ RTL8365MB_SDS_REG_RESET,
RTL8365MB_SDS_RESET_DEASSERT);
if (ret)
return ret;
@@ -1472,12 +1711,14 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
* This flushes the FIFOs and ensures a clean state for the link,
* preventing silent drops and CRC errors.
*/
- ret = rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_BMCR,
+ ret = rtl8365mb_sds_write(priv, sds_index,
+ RTL8365MB_SDS_REG_BMCR,
RTL8365MB_SDS_BMCR_DPRST_PHASE1);
if (ret)
return ret;
- ret = rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_BMCR,
+ ret = rtl8365mb_sds_write(priv, sds_index,
+ RTL8365MB_SDS_REG_BMCR,
RTL8365MB_SDS_BMCR_DPRST_PHASE2);
if (ret)
return ret;
@@ -1485,14 +1726,163 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
/* Keep SGMII in-band autonegotiation disabled: the link parameters are
* forced from rtl8365mb_pcs_link_up() instead.
*/
- ret = rtl8365mb_sds_read(priv, RTL8365MB_SDS_REG_NWAY, &val);
+ ret = rtl8365mb_sds_read(priv, sds_index,
+ RTL8365MB_SDS_REG_NWAY, &val);
if (ret)
return ret;
val &= ~RTL8365MB_SDS_NWAY_EN_MASK;
val |= RTL8365MB_SDS_NWAY_RESTART_MASK;
- return rtl8365mb_sds_write(priv, RTL8365MB_SDS_REG_NWAY, val);
+ ret = rtl8365mb_sds_write(priv, sds_index,
+ RTL8365MB_SDS_REG_NWAY, val);
+ if (ret)
+ return ret;
+
+ /* The re-latch edge has only been observed with HSGMII, so the work is
+ * only started for 2500base-x. Start a new episode and kick off the
+ * first attempt; see rtl8365mb_sds_relatch_work() for why this cannot
+ * wait for phylink to ask again.
+ */
+ if (is_d && interface == PHY_INTERFACE_MODE_2500BASEX) {
+ WRITE_ONCE(mb->sds_relatch_count, 1);
+ schedule_delayed_work(&mb->sds_relatch, 0);
+ }
+
+ return 0;
+}
+
+/* The family D receiver latches on a DISABLE -> mode edge in SDS_MISC
+ * rather than on the value, and only once the far-end MAC has brought up
+ * its half of the link. No local signal predicts that (bit 8 of the SDS
+ * link-status word does not change ahead of it), so the work cannot wait
+ * for it, only check afterwards whether an edge took. Nor does phylink
+ * call rtl8365mb_pcs_get_state() for a link without in-band signalling
+ * such as the fixed-link CPU trunk (mb->pcs.poll only arms phylink's own
+ * poll for in-band links), so this cannot rely on being polled at all.
+ * Instead, pcs_config() starts an episode and this work re-arms itself
+ * after every edge, its next run checking whether the edge took.
+ *
+ * An episode is capped at RTL8365MB_D_SDS_RELATCH_MAX_TRIES edges, spaced
+ * RTL8365MB_D_SDS_RELATCH_INTERVAL apart, so that a far end which never
+ * comes up costs a bounded burst of 20 ms parks. The run after the last
+ * edge only checks whether it took and reports failure; from then on one
+ * edge is driven per RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL, so a far end
+ * that comes up late is recovered without a reconfiguration. Once the
+ * receiver has latched the work just polls the link at the same slow
+ * interval; finding it down then starts a new episode, e.g. after the far
+ * end reset its PLL without a reconfiguration.
+ *
+ * sds_relatch_count is the number of the next attempt of the episode: 0
+ * while latched, 1..MAX_TRIES in budget, MAX_TRIES + 1 for the run that
+ * only reports, and above that once out of budget.
+ */
+static void rtl8365mb_sds_relatch_work(struct work_struct *work)
+{
+ struct rtl8365mb *mb = container_of(to_delayed_work(work),
+ struct rtl8365mb, sds_relatch);
+ struct realtek_priv *priv = mb->priv;
+ u32 park = (READ_ONCE(mb->sds_misc_target_val) &
+ ~RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK) |
+ RTL8365MB_D_PORT_SDS_MODE_DISABLE;
+ unsigned long delay = RTL8365MB_D_SDS_RELATCH_INTERVAL;
+ unsigned int attempts;
+ u16 status;
+ int ret;
+ int i;
+
+ /* The condition that queued this work may already be stale by the
+ * time it runs (e.g. an earlier edge from a prior attempt just
+ * latched). Parking an already-live link would drop it for no
+ * reason.
+ */
+ ret = rtl8365mb_sds_read(priv, RTL8365MB_D_SDS_EXT0_INDEX,
+ RTL8365MB_SDS_REG_LINK_STATUS, &status);
+ if (ret) {
+ dev_err_ratelimited(priv->dev,
+ "failed to read SerDes link status: %pe\n",
+ ERR_PTR(ret));
+ goto rearm;
+ }
+ if (status & RTL8365MB_SDS_LINK_STATUS_LINK_MASK) {
+ /* Latched: end the episode, keep watching for a later loss. */
+ WRITE_ONCE(mb->sds_relatch_count, 0);
+ delay = RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL;
+ goto rearm;
+ }
+
+ attempts = READ_ONCE(mb->sds_relatch_count);
+ if (!attempts) {
+ dev_warn(priv->dev,
+ "SerDes link lost outside a reconfiguration; re-latching\n");
+ attempts = 1;
+ } else if (attempts == RTL8365MB_D_SDS_RELATCH_MAX_TRIES + 1) {
+ /* This run only checked whether the last in-budget edge
+ * took. The first out-of-budget edge comes one healthcheck
+ * interval from now, not on this pass.
+ */
+ WRITE_ONCE(mb->sds_relatch_count, attempts + 1);
+ dev_warn(priv->dev,
+ "SerDes did not latch after %u re-latch attempts; still retrying every %d s\n",
+ RTL8365MB_D_SDS_RELATCH_MAX_TRIES,
+ RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL / HZ);
+ delay = RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL;
+ goto rearm;
+ }
+
+ if (attempts <= RTL8365MB_D_SDS_RELATCH_MAX_TRIES)
+ WRITE_ONCE(mb->sds_relatch_count, attempts + 1);
+ else
+ /* Past the fast-retry budget. The receiver latches only on a
+ * DISABLE -> mode edge and nothing re-runs pcs_config() for a
+ * link without in-band signalling, so keep driving one edge
+ * per interval.
+ */
+ delay = RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL;
+
+ ret = regmap_update_bits(priv->map, RTL8365MB_SDS_MISC_REG,
+ RTL8365MB_D_SDS_MISC_CFG_MASK, park);
+ if (ret) {
+ dev_err_ratelimited(priv->dev,
+ "failed to park SDS_MISC: %pe\n",
+ ERR_PTR(ret));
+ goto rearm;
+ }
+
+ usleep_range(20000, 21000);
+
+ for (i = 0; i < RTL8365MB_D_SDS_RESTORE_TRIES; i++) {
+ ret = regmap_update_bits(priv->map, RTL8365MB_SDS_MISC_REG,
+ RTL8365MB_D_SDS_MISC_CFG_MASK,
+ READ_ONCE(mb->sds_misc_target_val));
+ if (!ret)
+ break;
+ usleep_range(1000, 2000);
+ }
+ if (ret) {
+ dev_err_ratelimited(priv->dev,
+ "failed to restore SDS_MISC: %pe\n",
+ ERR_PTR(ret));
+ /* The SerDes is left parked: come back soon rather than
+ * at the (possibly 10 s) pace chosen above.
+ */
+ delay = RTL8365MB_D_SDS_RELATCH_INTERVAL;
+ goto rearm;
+ }
+
+ dev_dbg(priv->dev, "SerDes re-latch edge driven (attempt %u)\n",
+ attempts);
+
+ /* This edge may not have taken either; the next run checks. */
+rearm:
+ schedule_delayed_work(&mb->sds_relatch, delay);
+}
+
+static void rtl8365mb_sds_relatch_cancel(void *data)
+{
+ struct rtl8365mb *mb = data;
+
+ cancel_delayed_work_sync(&mb->sds_relatch);
}
static bool rtl8365mb_interface_is_serdes(phy_interface_t interface)
@@ -1517,10 +1907,14 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,
{
struct rtl8365mb *mb = pcs_to_rtl8365mb(pcs);
struct realtek_priv *priv = mb->priv;
+ u8 sds_index = 0;
u16 status;
+ bool is_d;
u32 val;
int ret;
+ is_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;
+
/* In-band autonegotiation is not implemented, so the link parameters are
* forced from rtl8365mb_pcs_link_up(). The real link state must still be
* read from the SerDes itself: the embedded DW8051 microcontroller that
@@ -1528,7 +1922,11 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,
* rtl8365mb_pcs_config()), so the link status register can be read
* directly through the SDS_INDACS window without racing the auto-poll.
*/
- ret = rtl8365mb_sds_read(priv, RTL8365MB_SDS_REG_LINK_STATUS, &status);
+ if (is_d)
+ sds_index = RTL8365MB_D_SDS_EXT0_INDEX;
+
+ ret = rtl8365mb_sds_read(priv, sds_index,
+ RTL8365MB_SDS_REG_LINK_STATUS, &status);
if (ret) {
state->link = false;
return;
@@ -1539,6 +1937,13 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,
if (!state->link)
return;
+ if (is_d) {
+ state->duplex = DUPLEX_FULL;
+ state->speed = state->interface == PHY_INTERFACE_MODE_2500BASEX ?
+ SPEED_2500 : SPEED_1000;
+ return;
+ }
+
/* The speed and duplex are forced; read them back from the values
* programmed into the SerDes MISC register.
*/
@@ -1580,6 +1985,12 @@ static void rtl8365mb_pcs_link_up(struct phylink_pcs *pcs,
u32 r_speed;
int ret;
+ /* Family D forces the external MAC ability from mac_link_up(); its
+ * SDS_MISC fields do not share the family C link-force layout.
+ */
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)
+ return;
+
/* The speed field has no value for 2.5 Gbps: the rate is determined by
* the HSGMII SerDes configuration, and the vendor driver programs the
* 1 Gbps value here.
@@ -1614,11 +2025,20 @@ static void rtl8365mb_pcs_link_up(struct phylink_pcs *pcs,
}
}
+static void rtl8365mb_pcs_disable(struct phylink_pcs *pcs)
+{
+ struct rtl8365mb *mb = pcs_to_rtl8365mb(pcs);
+
+ if (rtl8365mb_get_family(mb->priv) == RTL8365MB_FAMILY_D)
+ cancel_delayed_work_sync(&mb->sds_relatch);
+}
+
static const struct phylink_pcs_ops rtl8365mb_pcs_ops = {
.pcs_inband_caps = rtl8365mb_pcs_inband_caps,
.pcs_config = rtl8365mb_pcs_config,
.pcs_get_state = rtl8365mb_pcs_get_state,
.pcs_link_up = rtl8365mb_pcs_link_up,
+ .pcs_disable = rtl8365mb_pcs_disable,
};
static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,
@@ -1632,23 +2052,32 @@ static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,
u32 r_duplex;
u32 r_speed;
u32 r_link;
+ bool is_d;
int val;
int ret;
if (!extint)
return -ENODEV;
+ is_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;
if (link) {
/* Force the link up with the desired configuration */
r_link = 1;
r_rx_pause = rx_pause ? 1 : 0;
r_tx_pause = tx_pause ? 1 : 0;
- /* The speed field has no value for 2.5 Gbps: the rate is
- * determined by the HSGMII SerDes configuration, and the
- * vendor driver programs the 1 Gbps value here.
- */
- if (speed == SPEED_2500 || speed == SPEED_1000) {
+ if (speed == SPEED_2500) {
+ if (is_d) {
+ r_speed = RTL8365MB_D_PORT_SPEED_2500M;
+ } else {
+ /* The speed field has no value for 2.5 Gbps:
+ * the rate is determined by the HSGMII SerDes
+ * configuration, and the vendor driver programs
+ * the 1 Gbps value here.
+ */
+ r_speed = RTL8365MB_PORT_SPEED_1000M;
+ }
+ } else if (speed == SPEED_1000) {
r_speed = RTL8365MB_PORT_SPEED_1000M;
} else if (speed == SPEED_100) {
r_speed = RTL8365MB_PORT_SPEED_100M;
@@ -1678,20 +2107,44 @@ static int rtl8365mb_ext_config_forcemode(struct realtek_priv *priv, int port,
r_duplex = 0;
}
- val = FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_EN_MASK, 1) |
- FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_TXPAUSE_MASK,
+ val = FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_TXPAUSE_MASK,
r_tx_pause) |
FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_RXPAUSE_MASK,
r_rx_pause) |
FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_LINK_MASK, r_link) |
FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_DUPLEX_MASK,
r_duplex) |
- FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK, r_speed);
- ret = regmap_write(priv->map,
- RTL8365MB_DIGITAL_INTERFACE_FORCE_REG(extint->id),
- val);
- if (ret)
- return ret;
+ FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK,
+ r_speed &
+ RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_MASK);
+
+ if (is_d) {
+ /* Speed is 3 bits on family D: bits[1:0] go into FORCE_SPEED,
+ * bit[2] goes into FORCE_SPEED2 (bit 12); only 2500M sets it,
+ * bit 13 of the field is unused.
+ */
+ val |= FIELD_PREP(RTL8365MB_D_DIGITAL_INTERFACE_FORCE_SPEED2_MASK,
+ r_speed >>
+ RTL8365MB_DIGITAL_INTERFACE_FORCE_SPEED_WIDTH);
+ ret = regmap_write(priv->map,
+ RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG(port),
+ val);
+ if (ret)
+ return ret;
+
+ ret = regmap_write(priv->map,
+ RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_EN(port),
+ RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_ALL_MASK);
+ if (ret)
+ return ret;
+ } else {
+ val |= FIELD_PREP(RTL8365MB_DIGITAL_INTERFACE_FORCE_EN_MASK, 1);
+ ret = regmap_write(priv->map,
+ RTL8365MB_DIGITAL_INTERFACE_FORCE_REG(extint->id),
+ val);
+ if (ret)
+ return ret;
+ }
return 0;
}
@@ -1876,7 +2329,8 @@ static void rtl8365mb_phylink_mac_link_up(struct phylink_config *config,
* rtl8365mb_pcs_link_up() because pcs_link_up() carries no
* pause information.
*/
- if (rtl8365mb_interface_is_serdes(interface)) {
+ if (rtl8365mb_interface_is_serdes(interface) &&
+ rtl8365mb_get_family(priv) != RTL8365MB_FAMILY_D) {
u32 val = 0;
if (tx_pause)
@@ -3284,6 +3738,10 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
static void rtl8365mb_teardown(struct dsa_switch *ds)
{
struct realtek_priv *priv = ds->priv;
+ struct rtl8365mb *mb = priv->chip_data;
+
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)
+ cancel_delayed_work_sync(&mb->sds_relatch);
rtl8365mb_stats_teardown(priv);
rtl8365mb_irq_teardown(priv);
@@ -3349,7 +3807,28 @@ static int rtl8365mb_detect(struct realtek_priv *priv)
dev_info(priv->dev, "found an %s switch\n", mb->chip_info->name);
- priv->num_ports = RTL8365MB_MAX_NUM_PORTS;
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)
+ priv->num_ports = RTL8365MB_D_MAX_NUM_PORTS;
+ else
+ priv->num_ports = RTL8365MB_MAX_NUM_PORTS;
+
+ ret = devm_mutex_init(priv->dev, &mb->sds_lock);
+ if (ret)
+ return ret;
+
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D) {
+ /* Registered after sds_lock, so on release the work is
+ * cancelled before the mutex is destroyed.
+ */
+ INIT_DELAYED_WORK(&mb->sds_relatch,
+ rtl8365mb_sds_relatch_work);
+ ret = devm_add_action_or_reset(priv->dev,
+ rtl8365mb_sds_relatch_cancel,
+ mb);
+ if (ret)
+ return ret;
+ }
+
mb->priv = priv;
mb->cpu.trap_port = RTL8365MB_MAX_NUM_PORTS;
mb->cpu.insert = RTL8365MB_CPU_INSERT_TO_ALL;
diff --git a/drivers/net/dsa/realtek/rtl8365mb_vlan.c b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
index 8d49ffadce926..ccfa764b98125 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_vlan.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_vlan.c
@@ -44,16 +44,22 @@
*
* VLANMC index 0 is reserved as a neutral PVID, used for standalone ports.
*
+ * Everything above describes chips that have a VLAN membership configuration
+ * table. RTL8365MB_FAMILY_D chips do not have one: their PVID is a raw 12-bit
+ * VID in a per-port register, and no VLANMC entries are allocated.
+ *
*/
#include "rtl8365mb_vlan.h"
#include "rtl8365mb_table.h"
+#include "rtl8365mb.h"
#include <linux/if_bridge.h>
#include <linux/lockdep.h>
#include <linux/regmap.h>
/* CVLAN (i.e. VLAN4k) table entry layout, u16[3] */
#define RTL8365MB_CVLAN_ENTRY_SIZE 3 /* 48-bits */
+#define RTL8365MB_D_CVLAN_ENTRY_SIZE 2 /* 32-bits */
#define RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK GENMASK(7, 0)
#define RTL8365MB_CVLAN_MBR_LO_MASK GENMASK(7, 0)
#define RTL8365MB_CVLAN_ENTRY_D0_UNTAG_MASK GENMASK(15, 8)
@@ -65,6 +71,10 @@
#define RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK GENMASK(13, 9)
#define RTL8365MB_CVLAN_METERIDX_LO_MASK GENMASK(4, 0)
#define RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK GENMASK(14, 14)
+#define RTL8365MB_D_CVLAN_ENTRY_D1_SVLAN_CHK_IVL_SVL_MASK \
+ GENMASK(2, 2)
+#define RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK GENMASK(3, 3)
+#define RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK GENMASK(1, 0)
/* extends RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK */
#define RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK GENMASK(2, 0)
#define RTL8365MB_CVLAN_MBR_HI_MASK GENMASK(10, 8)
@@ -113,6 +123,11 @@
#define RTL8365MB_VLAN_PVID_CTRL_PORT_MCIDX_MASK(_p) \
(0x1F << RTL8365MB_VLAN_PVID_CTRL_PORT_MCIDX_OFFSET(_p))
+#define RTL8365MB_D_VLAN_PVID_CTRL_BASE 0x0700
+#define RTL8365MB_D_VLAN_PVID_CTRL_REG(port) \
+ (RTL8365MB_D_VLAN_PVID_CTRL_BASE + (port))
+#define RTL8365MB_D_VLAN_PVID_CTRL_MASK GENMASK(11, 0)
+
/* Frame type filtering registers */
#define RTL8365MB_VLAN_ACCEPT_FRAME_TYPE_BASE 0x07aa
#define RTL8365MB_VLAN_ACCEPT_FRAME_TYPE_REG(port) \
@@ -164,7 +179,7 @@ struct rtl8365mb_vlan4k {
* This structure is used to get/set entries in the VLAN membership
* configuration database. This feature is largely vestigial, but
* still needed for at least the following features:
- * - PVID configuration
+ * - PVID configuration (family C only, family D has no VLAN MC table)
* - ACL configuration
* - selection of VLAN by the CPU tag when VSEL=1, although the switch
* can also select VLAN based on the VLAN tag if VSEL=0
@@ -185,13 +200,16 @@ struct rtl8365mb_vlanmc {
static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid,
struct rtl8365mb_vlan4k *vlan4k)
{
+ bool is_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;
+ size_t entry_size = is_d ? RTL8365MB_D_CVLAN_ENTRY_SIZE :
+ RTL8365MB_CVLAN_ENTRY_SIZE;
u16 data[RTL8365MB_CVLAN_ENTRY_SIZE];
int val;
int ret;
ret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_CVLAN,
RTL8365MB_TABLE_OP_READ, &vid, 0, 0,
- data, ARRAY_SIZE(data));
+ data, entry_size);
if (ret)
return ret;
@@ -199,33 +217,61 @@ static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid,
memset(vlan4k, 0, sizeof(*vlan4k));
vlan4k->vid = vid;
+ /* member/untag: d0[7:0]/d0[15:8] on both families. Family C
+ * extends these into data[2] bits [2:0]/[5:3] for its 9th-11th
+ * ports; family D's die has only 8 ports and no third table
+ * word, so data[2] does not exist there and must not be read.
+ */
val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK, data[0]);
vlan4k->member = FIELD_PREP(RTL8365MB_CVLAN_MBR_LO_MASK, val);
- val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, data[2]);
- vlan4k->member |= FIELD_PREP(RTL8365MB_CVLAN_MBR_HI_MASK, val);
+ if (!is_d) {
+ val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, data[2]);
+ vlan4k->member |= FIELD_PREP(RTL8365MB_CVLAN_MBR_HI_MASK, val);
+ }
val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D0_UNTAG_MASK, data[0]);
vlan4k->untag = FIELD_PREP(RTL8365MB_CVLAN_UNTAG_LO_MASK, val);
- val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK, data[2]);
- vlan4k->untag |= FIELD_PREP(RTL8365MB_CVLAN_UNTAG_HI_MASK, val);
-
- vlan4k->fid = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK, data[1]);
- vlan4k->priority_en =
- FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK, data[1]);
- vlan4k->priority =
- FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK, data[1]);
- vlan4k->policing_en =
- FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK, data[1]);
-
- val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK, data[1]);
- val = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);
- vlan4k->meteridx = val;
- val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK, data[2]);
- val = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);
- vlan4k->meteridx |= val;
-
- vlan4k->ivl_en =
- FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK, data[1]);
+ if (!is_d) {
+ val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK,
+ data[2]);
+ vlan4k->untag |= FIELD_PREP(RTL8365MB_CVLAN_UNTAG_HI_MASK, val);
+ }
+
+ if (is_d) {
+ vlan4k->fid = FIELD_GET(RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK,
+ data[1]);
+ /* Family D has no priority/meter fields in this entry -
+ * left zeroed by the memset() above.
+ */
+ vlan4k->ivl_en =
+ FIELD_GET(RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK,
+ data[1]);
+ } else {
+ vlan4k->fid = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK,
+ data[1]);
+ vlan4k->priority_en =
+ FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK,
+ data[1]);
+ vlan4k->priority =
+ FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK,
+ data[1]);
+ vlan4k->policing_en =
+ FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK,
+ data[1]);
+
+ val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK,
+ data[1]);
+ val = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);
+ vlan4k->meteridx = val;
+ val = FIELD_GET(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK,
+ data[2]);
+ val = FIELD_PREP(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);
+ vlan4k->meteridx |= val;
+
+ vlan4k->ivl_en =
+ FIELD_GET(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK,
+ data[1]);
+ }
return 0;
}
@@ -233,6 +279,9 @@ static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid,
static int rtl8365mb_vlan_4k_write(struct realtek_priv *priv,
const struct rtl8365mb_vlan4k *vlan4k)
{
+ bool is_d = rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D;
+ size_t entry_size = is_d ? RTL8365MB_D_CVLAN_ENTRY_SIZE :
+ RTL8365MB_CVLAN_ENTRY_SIZE;
u16 data[RTL8365MB_CVLAN_ENTRY_SIZE] = { 0 };
u16 vid;
int val;
@@ -244,36 +293,59 @@ static int rtl8365mb_vlan_4k_write(struct realtek_priv *priv,
val = FIELD_GET(RTL8365MB_CVLAN_UNTAG_LO_MASK, vlan4k->untag);
data[0] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D0_UNTAG_MASK, val);
- data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK, vlan4k->fid);
- data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK,
- vlan4k->priority_en);
- data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK,
- vlan4k->priority);
- data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK,
- vlan4k->policing_en);
-
- /* FIELD_* does not play nice with struct bitfield. */
- val = vlan4k->meteridx;
- val = FIELD_GET(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);
- data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK, val);
-
- data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK,
- vlan4k->ivl_en);
-
- val = FIELD_GET(RTL8365MB_CVLAN_MBR_HI_MASK, vlan4k->member);
- data[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK, val);
-
- val = FIELD_GET(RTL8365MB_CVLAN_UNTAG_HI_MASK, vlan4k->untag);
- data[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK, val);
-
- val = vlan4k->meteridx;
- val = FIELD_GET(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);
- data[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK, val);
+ if (is_d) {
+ /* The chip supports both IVL and SVL, but the caller (see
+ * rtl8365mb_vlan_4k_port_set()) never requests SVL, so both
+ * IVL/SVL selector bits are forced here rather than threaded
+ * through from vlan4k->ivl_en, which family C does honor.
+ */
+ data[1] |= FIELD_PREP(RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK,
+ 1) |
+ FIELD_PREP(RTL8365MB_D_CVLAN_ENTRY_D1_SVLAN_CHK_IVL_SVL_MASK,
+ 1);
+ data[1] |= FIELD_PREP(RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK,
+ vlan4k->fid);
+ /* No priority/meter/member-untag-extension fields exist in
+ * family D's 2-word entry - data[1] and data[0] above are
+ * the whole entry, and data[2] is not part of it at all.
+ */
+ } else {
+ val = vlan4k->fid;
+ data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_FID_MASK, val);
+ data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPEN_MASK,
+ vlan4k->priority_en);
+ data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_VBPRI_MASK,
+ vlan4k->priority);
+ data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_ENVLANPOL_MASK,
+ vlan4k->policing_en);
+
+ /* FIELD_* does not play nice with struct bitfield. */
+ val = vlan4k->meteridx;
+ val = FIELD_GET(RTL8365MB_CVLAN_METERIDX_LO_MASK, val);
+ data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_METERIDX_MASK,
+ val);
+
+ data[1] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D1_IVL_SVL_MASK,
+ vlan4k->ivl_en);
+
+ val = FIELD_GET(RTL8365MB_CVLAN_MBR_HI_MASK, vlan4k->member);
+ data[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_MBR_EXT_MASK,
+ val);
+
+ val = FIELD_GET(RTL8365MB_CVLAN_UNTAG_HI_MASK, vlan4k->untag);
+ data[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_UNTAG_EXT_MASK,
+ val);
+
+ val = vlan4k->meteridx;
+ val = FIELD_GET(RTL8365MB_CVLAN_METERIDX_HI_MASK, val);
+ data[2] |= FIELD_PREP(RTL8365MB_CVLAN_ENTRY_D2_METERIDX_EXT_MASK,
+ val);
+ }
vid = vlan4k->vid;
return rtl8365mb_table_query(priv, RTL8365MB_TABLE_CVLAN,
RTL8365MB_TABLE_OP_WRITE, &vid, 0, 0,
- data, ARRAY_SIZE(data));
+ data, entry_size);
}
static int
@@ -679,11 +751,25 @@ int rtl8365mb_vlan_port_get_pvid(struct realtek_priv *priv, int port, u16 *pvid)
u8 vlanmc_idx;
int ret;
- ret = rtl8365mb_vlan_get_pvid_mc(priv, port, &vlanmc_idx, &vlanmc);
- if (ret)
- return ret;
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D) {
+ u32 data;
+
+ ret = regmap_read(priv->map,
+ RTL8365MB_D_VLAN_PVID_CTRL_REG(port),
+ &data);
+ if (ret)
+ return ret;
+
+ *pvid = data & RTL8365MB_D_VLAN_PVID_CTRL_MASK;
+ } else {
+ ret = rtl8365mb_vlan_get_pvid_mc(priv, port, &vlanmc_idx,
+ &vlanmc);
+ if (ret)
+ return ret;
+
+ *pvid = vlanmc.evid;
+ }
- *pvid = vlanmc.evid;
return 0;
}
@@ -748,6 +834,68 @@ rtl8365mb_vlan_port_set_framefilter(struct realtek_priv *priv,
val);
}
+/*
+ * rtl8365mb_vlan_pvid_port_set_direct() - Configure a port's PVID as a raw
+ * VID written to its dedicated register, for chip families without a
+ * working VLAN MC table (RTL8365MB_FAMILY_D)
+ *
+ * Reads back the previous PVID and frame filter first so both can be
+ * restored if enabling the new PVID fails partway through, matching
+ * the rollback behavior of the family-C implementation below.
+ *
+ * Context: Can sleep. Must be called with &priv->vlan_lock held.
+ * Return: 0 on success, or a negative error code on failure.
+ */
+static int rtl8365mb_vlan_pvid_port_set_direct(struct realtek_priv *priv,
+ int port, u16 vid)
+{
+ enum rtl8365mb_frame_ingress prev_accepted_frame;
+ u32 prev_pvid;
+ int ret;
+
+ ret = regmap_read(priv->map, RTL8365MB_D_VLAN_PVID_CTRL_REG(port),
+ &prev_pvid);
+ if (ret) {
+ dev_err(priv->dev, "Failed to read current PVID\n");
+ return ret;
+ }
+ prev_pvid &= RTL8365MB_D_VLAN_PVID_CTRL_MASK;
+
+ ret = rtl8365mb_vlan_port_get_framefilter(priv, port,
+ &prev_accepted_frame);
+ if (ret) {
+ dev_err(priv->dev, "Failed to get current framefilter\n");
+ return ret;
+ }
+
+ ret = regmap_update_bits(priv->map,
+ RTL8365MB_D_VLAN_PVID_CTRL_REG(port),
+ RTL8365MB_D_VLAN_PVID_CTRL_MASK,
+ vid & RTL8365MB_D_VLAN_PVID_CTRL_MASK);
+ if (ret) {
+ dev_err(priv->dev, "Failed to set port PVID\n");
+ return ret;
+ }
+
+ /* Changing accept frame is what enables PVID (if not enabled before) */
+ ret = rtl8365mb_vlan_port_set_framefilter(priv, port,
+ RTL8365MB_FRAME_TYPE_ANY_FRAME);
+ if (ret) {
+ dev_err(priv->dev, "Failed to set port frame filter\n");
+ goto undo_pvid_write;
+ }
+
+ return 0;
+
+undo_pvid_write:
+ (void)regmap_update_bits(priv->map,
+ RTL8365MB_D_VLAN_PVID_CTRL_REG(port),
+ RTL8365MB_D_VLAN_PVID_CTRL_MASK, prev_pvid);
+ (void)rtl8365mb_vlan_port_set_framefilter(priv, port,
+ prev_accepted_frame);
+ return ret;
+}
+
/*
* rtl8365mb_vlan_pvid_port_set() - Configure a port's PVID and associated
* VLANMC entry
@@ -760,6 +908,9 @@ rtl8365mb_vlan_port_set_framefilter(struct realtek_priv *priv,
* PVID. Gracefully unwinds and restores previous configuration if a hardware
* write operation fails during execution.
*
+ * On RTL8365MB_FAMILY_D there is no VLANMC table: the VID is written directly
+ * to the port's PVID register and no VLANMC entry is allocated.
+ *
* Context: Can sleep. Must be called with &priv->vlan_lock held.
* Takes and releases &priv->map_lock.
* Return: 0 on success, or a negative error code on failure.
@@ -777,6 +928,13 @@ int rtl8365mb_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid,
lockdep_assert_held(&priv->vlan_lock);
+ /* This chip family has no VLAN MC table - PVID is a raw VID in a
+ * dedicated per-port register, and there is no separate membership
+ * table entry to allocate/track.
+ */
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)
+ return rtl8365mb_vlan_pvid_port_set_direct(priv, port, vid);
+
/* Read the old PVID exclusively to undo in case of error */
ret = rtl8365mb_vlan_get_pvid_mc(priv, port, &prev_vlanmc_idx,
&prev_vlanmc);
@@ -856,6 +1014,76 @@ int rtl8365mb_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid,
return ret;
}
+/*
+ * rtl8365mb_vlan_pvid_port_clear_direct() - Remove a port's raw-VID PVID
+ * configuration, for chip families without a working VLAN MC table
+ * (RTL8365MB_FAMILY_D)
+ *
+ * Reads back the previous frame filter first so it can be restored if
+ * clearing the PVID register fails.
+ *
+ * Context: Can sleep. Must be called with &priv->vlan_lock held.
+ * Return: 0 on success, or a negative error code on failure.
+ */
+static int rtl8365mb_vlan_pvid_port_clear_direct(struct dsa_switch *ds,
+ int port, u16 vid)
+{
+ enum rtl8365mb_frame_ingress prev_accepted_frame;
+ struct realtek_priv *priv = ds->priv;
+ bool filtering;
+ u32 cur_pvid;
+ int ret;
+
+ ret = regmap_read(priv->map, RTL8365MB_D_VLAN_PVID_CTRL_REG(port),
+ &cur_pvid);
+ if (ret) {
+ dev_err(priv->dev, "Failed to read current PVID\n");
+ return ret;
+ }
+
+ /* Port is not using this VID as PVID. Nothing to remove. */
+ if ((cur_pvid & RTL8365MB_D_VLAN_PVID_CTRL_MASK) != vid)
+ return 0;
+
+ filtering = dsa_port_is_vlan_filtering(dsa_to_port(ds, port));
+
+ /* Changing accept frame is what really removes PVID. But only do
+ * that if VLAN filtering is enabled.
+ */
+ if (filtering) {
+ ret = rtl8365mb_vlan_port_get_framefilter(priv, port,
+ &prev_accepted_frame);
+ if (ret) {
+ dev_err(priv->dev,
+ "Failed to get current framefilter\n");
+ return ret;
+ }
+
+ ret = rtl8365mb_vlan_port_set_framefilter(
+ priv, port, RTL8365MB_FRAME_TYPE_TAGGED_ONLY);
+ if (ret) {
+ dev_err(priv->dev, "Failed to set port frame filter\n");
+ return ret;
+ }
+ }
+
+ ret = regmap_update_bits(priv->map,
+ RTL8365MB_D_VLAN_PVID_CTRL_REG(port),
+ RTL8365MB_D_VLAN_PVID_CTRL_MASK, 0);
+ if (ret) {
+ dev_err(priv->dev, "Failed to set port PVID to 0\n");
+ goto undo_set_framefilter;
+ }
+
+ return 0;
+
+undo_set_framefilter:
+ if (filtering)
+ (void)rtl8365mb_vlan_port_set_framefilter(priv, port,
+ prev_accepted_frame);
+ return ret;
+}
+
/*
* rtl8365mb_vlan_pvid_port_clear() - Remove a port's PVID configuration
* @ds: dsa switch instance
@@ -865,6 +1093,9 @@ int rtl8365mb_vlan_pvid_port_set(struct dsa_switch *ds, int port, u16 vid,
* Resets the target port's hardware PVID allocation to 0. Cleans up and frees
* the associated VLANMC entry if no other ports are referencing it.
*
+ * On RTL8365MB_FAMILY_D the port's PVID register is reset to 0 directly; there
+ * is no VLANMC entry to free.
+ *
* Context: Can sleep. Must be called with &priv->vlan_lock held.
* Takes and releases &priv->map_lock.
* Return: 0 on success, or a negative error code on failure.
@@ -879,6 +1110,9 @@ int rtl8365mb_vlan_pvid_port_clear(struct dsa_switch *ds, int port, u16 vid)
lockdep_assert_held(&priv->vlan_lock);
+ if (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)
+ return rtl8365mb_vlan_pvid_port_clear_direct(ds, port, vid);
+
ret = rtl8365mb_vlan_get_pvid_mc(priv, port, &vlanmc_idx,
&vlanmc);
if (ret) {
|
| 3/2 | 2026/10/10 20:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27151 output: 45 thoughts: 205 Thoughts: **Analyzing the Realtek DSA Patch** Okay, let's dive into this patch. My initial thought is to meticulously break down the changes, starting with a granular examination of the modified files. I see the changes touch four files specifically: `Documentation/devicetree/bindings/net/dsa/realtek.yaml`, `drivers/net/dsa/realtek/rtl8365mb.h` (new!), `drivers/net/dsa/realtek/rtl8365mb_main.c`, and `drivers/net/dsa/realtek/rtl8365mb_vlan.c`. The fact that `rtl8365mb.h` is a new file instantly flags that something significant is happening with the RTL8365MB, the specific Realtek DSA switch we're dealing with. The path `drivers/net/dsa/realtek/` clearly indicates this relates to the Realtek Distributed Switch Architecture driver, and confirms we're working with the rtl8365mb. I'll need to figure out the driver instantiation method, so next, I need to see how the driver is hooked up. I know I can check the Kconfig, so let's use `grepper` and see how it's instantiated and on which bus it attaches. That will illuminate the context of these changes. |
| 4/2 | 2026/10/10 20:14 | tool | grepper |
0mArgs:{
"Expression": "NET_DSA_REALTEK|RTL8365MB",
"PathPrefixes": [
"drivers/net/dsa/realtek"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 2818 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (13 files in total):\ndrivers/net/dsa/realtek/Kconfig:14\ndrivers/net/dsa/realtek/Makefile:6\ndrivers/net/dsa/realtek/realtek-mdio.h:3\ndrivers/net/dsa/realtek/realtek-smi.h:3\ndrivers/net/dsa/realtek/rtl8365mb.h:5\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:190\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:3\ndrivers/net/dsa/realtek/rtl8365mb_main.c:818\ndrivers/net/dsa/realtek/rtl8365mb_table.c:56\ndrivers/net/dsa/realtek/rtl8365mb_table.h:41\ndrivers/net/dsa/realtek/rtl8365mb_vlan.c:180\ndrivers/net/dsa/realtek/rtl8365mb_vlan.h:6\ndrivers/net/dsa/realtek/rtl8366rb.h:2\n\ndrivers/net/dsa/realtek/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/net/dsa/realtek/Kconfig:2:menuconfig NET_DSA_REALTEK\ndrivers/net/dsa/realtek/Kconfig-3-\ttristate \"Realtek Ethernet switch family support\"\n--\ndrivers/net/dsa/realtek/Kconfig-15-\ndrivers/net/dsa/realtek/Kconfig:16:if NET_DSA_REALTEK\ndrivers/net/dsa/realtek/Kconfig-17-\ndrivers/net/dsa/realtek/Kconfig:18:config NET_DSA_REALTEK_MDIO\ndrivers/net/dsa/realtek/Kconfig-19-\tbool \"Realtek MDIO interface support\"\n--\ndrivers/net/dsa/realtek/Kconfig-24-\ndrivers/net/dsa/realtek/Kconfig:25:config NET_DSA_REALTEK_SMI\ndrivers/net/dsa/realtek/Kconfig-26-\tbool \"Realtek SMI interface support\"\n--\ndrivers/net/dsa/realtek/Kconfig-31-\ndrivers/net/dsa/realtek/Kconfig:32:config NET_DSA_REALTEK_RTL8365MB\ndrivers/net/dsa/realtek/Kconfig:33:\ttristate \"Realtek RTL8365MB switch driver\"\ndrivers/net/dsa/realtek/Kconfig:34:\tdepends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO\ndrivers/net/dsa/realtek/Kconfig-35-\tselect NET_DSA_TAG_RTL8_4\ndrivers/net/dsa/realtek/Kconfig-36-\thelp\ndrivers/net/dsa/realtek/Kconfig:37:\t Select to enable support for Realtek RTL8365MB-VC and RTL8367S.\ndrivers/net/dsa/realtek/Kconfig-38-\ndrivers/net/dsa/realtek/Kconfig:39:config NET_DSA_REALTEK_RTL8366RB\ndrivers/net/dsa/realtek/Kconfig-40-\ttristate \"Realtek RTL8366RB switch driver\"\ndrivers/net/dsa/realtek/Kconfig:41:\tdepends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO\ndrivers/net/dsa/realtek/Kconfig-42-\tselect NET_DSA_TAG_RTL4_A\n--\ndrivers/net/dsa/realtek/Kconfig-45-\ndrivers/net/dsa/realtek/Kconfig:46:config NET_DSA_REALTEK_RTL8366RB_LEDS\ndrivers/net/dsa/realtek/Kconfig-47-\tbool\ndrivers/net/dsa/realtek/Kconfig:48:\tdepends on (LEDS_CLASS=y || LEDS_CLASS=NET_DSA_REALTEK_RTL8366RB)\ndrivers/net/dsa/realtek/Kconfig:49:\tdepends on NET_DSA_REALTEK_RTL8366RB\ndrivers/net/dsa/realtek/Kconfig:50:\tdefault NET_DSA_REALTEK_RTL8366RB\ndrivers/net/dsa/realtek/Kconfig-51-\n--\ndrivers/net/dsa/realtek/Makefile-1-# SPDX-License-Identifier: GPL-2.0\ndrivers/net/dsa/realtek/Makefile:2:obj-$(CONFIG_NET_DSA_REALTEK)\t\t+= realtek_dsa.o\ndrivers/net/dsa/realtek/Makefile-3-realtek_dsa-objs\t\t\t:= rtl83xx.o\ndrivers/net/dsa/realtek/Makefile-4-\ndrivers/net/dsa/realtek/Makefile:5:ifdef CONFIG_NET_DSA_REALTEK_MDIO\ndrivers/net/dsa/realtek/Makefile-6-realtek_dsa-objs += realtek-mdio.o\ndrivers/net/dsa/realtek/Makefile=7=endif\ndrivers/net/dsa/realtek/Makefile-8-\ndrivers/net/dsa/realtek/Makefile:9:ifdef CONFIG_NET_DSA_REALTEK_SMI\ndrivers/net/dsa/realtek/Makefile-10-realtek_dsa-objs += realtek-smi.o\ndrivers/net/dsa/realtek/Makefile=11=endif\ndrivers/net/dsa/realtek/Makefile-12-\ndrivers/net/dsa/realtek/Makefile:13:obj-$(CONFIG_NET_DSA_REALTEK_RTL8366RB) += rtl8366.o\ndrivers/net/dsa/realtek/Makefile-14-rtl8366-objs \t\t\t\t:= rtl8366-core.o rtl8366rb.o\ndrivers/net/dsa/realtek/Makefile:15:ifdef CONFIG_NET_DSA_REALTEK_RTL8366RB_LEDS\ndrivers/net/dsa/realtek/Makefile-16-rtl8366-objs \t\t\t\t+= rtl8366rb-leds.o\ndrivers/net/dsa/realtek/Makefile=17=endif\ndrivers/net/dsa/realtek/Makefile:18:obj-$(CONFIG_NET_DSA_REALTEK_RTL8365MB) += rtl8365mb.o\ndrivers/net/dsa/realtek/Makefile-19-rtl8365mb-objs := rtl8365mb_main.o \\\n--\ndrivers/net/dsa/realtek/realtek-mdio.h-5-\ndrivers/net/dsa/realtek/realtek-mdio.h:6:#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_MDIO)\ndrivers/net/dsa/realtek/realtek-mdio.h-7-\n--\ndrivers/net/dsa/realtek/realtek-mdio.h=20=void realtek_mdio_shutdown(struct mdio_device *mdiodev);\ndrivers/net/dsa/realtek/realtek-mdio.h-21-\ndrivers/net/dsa/realtek/realtek-mdio.h:22:#else /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_MDIO) */\ndrivers/net/dsa/realtek/realtek-mdio.h-23-\n--\ndrivers/net/dsa/realtek/realtek-mdio.h=42=static inline void realtek_mdio_shutdown(struct mdio_device *mdiodev)\n--\ndrivers/net/dsa/realtek/realtek-mdio.h-45-\ndrivers/net/dsa/realtek/realtek-mdio.h:46:#endif /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_MDIO) */\ndrivers/net/dsa/realtek/realtek-mdio.h-47-\n--\ndrivers/net/dsa/realtek/realtek-smi.h-5-\ndrivers/net/dsa/realtek/realtek-smi.h:6:#if IS_ENABLED(CONFIG_NET_DSA_REALTEK_SMI)\ndrivers/net/dsa/realtek/realtek-smi.h-7-\n--\ndrivers/net/dsa/realtek/realtek-smi.h=20=void realtek_smi_shutdown(struct platform_device *pdev);\ndrivers/net/dsa/realtek/realtek-smi.h-21-\ndrivers/net/dsa/realtek/realtek-smi.h:22:#else /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_SMI) */\ndrivers/net/dsa/realtek/realtek-smi.h-23-\n--\ndrivers/net/dsa/realtek/realtek-smi.h=42=static inline void realtek_smi_shutdown(struct platform_device *pdev)\n--\ndrivers/net/dsa/realtek/realtek-smi.h-45-\ndrivers/net/dsa/realtek/realtek-smi.h:46:#endif /* IS_ENABLED(CONFIG_NET_DSA_REALTEK_SMI) */\ndrivers/net/dsa/realtek/realtek-smi.h-47-\n--\ndrivers/net/dsa/realtek/rtl8365mb.h-1-/* SPDX-License-Identifier: GPL-2.0 */\ndrivers/net/dsa/realtek/rtl8365mb.h:2:#ifndef _RTL8365MB_H\ndrivers/net/dsa/realtek/rtl8365mb.h:3:#define _RTL8365MB_H\ndrivers/net/dsa/realtek/rtl8365mb.h-4-\n--\ndrivers/net/dsa/realtek/rtl8365mb.h=7=enum rtl8365mb_family {\ndrivers/net/dsa/realtek/rtl8365mb.h:8:\tRTL8365MB_FAMILY_C,\ndrivers/net/dsa/realtek/rtl8365mb.h:9:\tRTL8365MB_FAMILY_D,\ndrivers/net/dsa/realtek/rtl8365mb.h-10-};\n--\ndrivers/net/dsa/realtek/rtl8365mb.h=12=enum rtl8365mb_family rtl8365mb_get_family(struct realtek_priv *priv);\ndrivers/net/dsa/realtek/rtl8365mb.h-13-\ndrivers/net/dsa/realtek/rtl8365mb.h:14:#endif /* _RTL8365MB_H */\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-12-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:13:#define RTL8365MB_L2_ENTRY_SIZE\t\t\t6\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-14-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:15:#define RTL8365MB_L2_UC_D0_MAC5_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:16:#define RTL8365MB_L2_UC_D0_MAC4_MSK\t\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:17:#define RTL8365MB_L2_UC_D1_MAC3_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:18:#define RTL8365MB_L2_UC_D1_MAC2_MSK\t\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:19:#define RTL8365MB_L2_UC_D2_MAC1_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:20:#define RTL8365MB_L2_UC_D2_MAC0_MSK\t\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:21:#define RTL8365MB_L2_UC_D3_VID_MSK\t\tGENMASK(11, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:22:#define RTL8365MB_L2_UC_D3_IVL_MSK\t\tGENMASK(13, 13)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:23:#define RTL8365MB_L2_UC_D3_PORT_EXT_MSK\tGENMASK(15, 15)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:24:#define RTL8365MB_L2_UC_PORT_HI_MSK\t\tGENMASK(3, 3)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:25:#define RTL8365MB_L2_UC_D4_EFID_MSK\t\tGENMASK(2, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:26:#define RTL8365MB_L2_UC_D4_FID_MSK\t\tGENMASK(6, 3)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:27:#define RTL8365MB_L2_UC_D4_SA_PRI_MSK\t\tGENMASK(7, 7)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:28:#define RTL8365MB_L2_UC_D4_PORT_MSK\t\tGENMASK(10, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:29:#define RTL8365MB_L2_UC_PORT_LO_MSK\t\tGENMASK(2, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:30:#define RTL8365MB_L2_UC_D4_AGE_MSK\t\tGENMASK(13, 11)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:31:#define RTL8365MB_L2_UC_D4_AUTH_MSK\t\tGENMASK(14, 14)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:32:#define RTL8365MB_L2_UC_D4_SA_BLOCK_MSK\tGENMASK(15, 15)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-33-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:34:#define RTL8365MB_L2_UC_D5_DA_BLOCK_MSK\tGENMASK(0, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:35:#define RTL8365MB_L2_UC_D5_PRIORITY_MSK\tGENMASK(3, 1)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:36:#define RTL8365MB_L2_UC_D5_FWD_PRI_MSK\t\tGENMASK(4, 4)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:37:#define RTL8365MB_L2_UC_D5_STATIC_MSK\t\tGENMASK(5, 5)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-38-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:39:#define RTL8365MB_L2_MC_D0_MAC5_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:40:#define RTL8365MB_L2_MC_D0_MAC4_MSK\t\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:41:#define RTL8365MB_L2_MC_D1_MAC3_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:42:#define RTL8365MB_L2_MC_D1_MAC2_MSK\t\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:43:#define RTL8365MB_L2_MC_D2_MAC1_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:44:#define RTL8365MB_L2_MC_D2_MAC0_MSK\t\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:45:#define RTL8365MB_L2_MC_D3_VID_MSK\t\tGENMASK(11, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:46:#define RTL8365MB_L2_MC_D3_IVL_MSK\t\tGENMASK(13, 13)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:47:#define RTL8365MB_L2_MC_D3_MBR_HI1_MSK\t\tGENMASK(15, 14)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:48:#define RTL8365MB_L2_MC_MBR_HI1_MSK\t\tGENMASK(9, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-49-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:50:#define RTL8365MB_L2_MC_D4_MBR_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:51:#define RTL8365MB_L2_MC_MBR_LO_MSK\t\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:52:#define RTL8365MB_L2_MC_D4_IGMPIDX_MSK\t\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-53-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:54:#define RTL8365MB_L2_MC_D5_IGMP_ASIC_MSK\tGENMASK(0, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:55:#define RTL8365MB_L2_MC_D5_PRIORITY_MSK\tGENMASK(3, 1)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:56:#define RTL8365MB_L2_MC_D5_FWD_PRI_MSK\t\tGENMASK(4, 4)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:57:#define RTL8365MB_L2_MC_D5_STATIC_MSK\t\tGENMASK(5, 5)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:58:#define RTL8365MB_L2_MC_D5_MBR_HI2_MSK\t\tGENMASK(7, 7)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:59:#define RTL8365MB_L2_MC_MBR_HI2_MSK\t\tGENMASK(10, 10)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-60-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-64- */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:65:#define RTL8365MB_L2_FLUSH_PORT_REG\t\t0x0A36\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:66:#define RTL8365MB_L2_FLUSH_PORT_MSK_MSK\tGENMASK(7, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:67:#define RTL8365MB_L2_FLUSH_PORT_BUSY_MSK\tGENMASK(15, 8)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-68-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:69:#define RTL8365MB_L2_FLUSH_PORT_EXT_REG\t\t0x0A35\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:70:#define RTL8365MB_L2_FLUSH_PORT_EXT_MSK_MSK\tGENMASK(2, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:71:#define RTL8365MB_L2_FLUSH_PORT_EXT_BUSY_MSK\tGENMASK(5, 3)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-72-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:73:#define RTL8365MB_L2_FLUSH_CTRL1_REG\t\t0x0A37\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:74:#define RTL8365MB_L2_FLUSH_CTRL1_VID_MSK\tGENMASK(11, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:75:#define RTL8365MB_L2_FLUSH_CTRL1_FID_MSK\tGENMASK(15, 12)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-76-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:77:#define RTL8365MB_L2_FLUSH_CTRL2_REG\t\t0x0A38\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:78:#define RTL8365MB_L2_FLUSH_CTRL2_MODE_MSK\tGENMASK(1, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:79:#define RTL8365MB_L2_FLUSH_CTRL2_MODE_PORT\t0\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:80:#define RTL8365MB_L2_FLUSH_CTRL2_MODE_PORT_VID 1\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:81:#define RTL8365MB_L2_FLUSH_CTRL2_MODE_PORT_FID 2\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:82:#define RTL8365MB_L2_FLUSH_CTRL2_TYPE_MSK\tGENMASK(2, 2)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:83:#define RTL8365MB_L2_FLUSH_CTRL2_TYPE_DYNAMIC\t0\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:84:#define RTL8365MB_L2_FLUSH_CTRL2_TYPE_BOTH\t1\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-85-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-88- */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:89:#define RTL8365MB_L2_FLUSH_CTRL3_REG\t\t0x0A39\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:90:#define RTL8365MB_L2_FLUSH_CTRL3_MSK\t\tGENMASK(0, 0)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-91-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c=134=static void rtl8365mb_l2_data_to_uc(const u16 *data, struct rtl8365mb_l2_uc *uc)\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-137-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:138:\tuc-\u003ekey.mac_addr[5] = FIELD_GET(RTL8365MB_L2_UC_D0_MAC5_MSK, data[0]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:139:\tuc-\u003ekey.mac_addr[4] = FIELD_GET(RTL8365MB_L2_UC_D0_MAC4_MSK, data[0]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:140:\tuc-\u003ekey.mac_addr[3] = FIELD_GET(RTL8365MB_L2_UC_D1_MAC3_MSK, data[1]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:141:\tuc-\u003ekey.mac_addr[2] = FIELD_GET(RTL8365MB_L2_UC_D1_MAC2_MSK, data[1]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:142:\tuc-\u003ekey.mac_addr[1] = FIELD_GET(RTL8365MB_L2_UC_D2_MAC1_MSK, data[2]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:143:\tuc-\u003ekey.mac_addr[0] = FIELD_GET(RTL8365MB_L2_UC_D2_MAC0_MSK, data[2]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:144:\tuc-\u003ekey.efid = FIELD_GET(RTL8365MB_L2_UC_D4_EFID_MSK, data[4]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:145:\tuc-\u003ekey.vid = FIELD_GET(RTL8365MB_L2_UC_D3_VID_MSK, data[3]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:146:\tuc-\u003ekey.ivl = FIELD_GET(RTL8365MB_L2_UC_D3_IVL_MSK, data[3]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:147:\tuc-\u003ekey.fid = FIELD_GET(RTL8365MB_L2_UC_D4_FID_MSK, data[4]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:148:\tuc-\u003eage = FIELD_GET(RTL8365MB_L2_UC_D4_AGE_MSK, data[4]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:149:\tuc-\u003eauth = FIELD_GET(RTL8365MB_L2_UC_D4_AUTH_MSK, data[4]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-150-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:151:\tval = FIELD_GET(RTL8365MB_L2_UC_D4_PORT_MSK, data[4]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:152:\tuc-\u003eport = FIELD_PREP(RTL8365MB_L2_UC_PORT_LO_MSK, val);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:153:\tval = FIELD_GET(RTL8365MB_L2_UC_D3_PORT_EXT_MSK, data[3]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:154:\tuc-\u003eport |= FIELD_PREP(RTL8365MB_L2_UC_PORT_HI_MSK, val);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-155-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:156:\tuc-\u003esa_pri = FIELD_GET(RTL8365MB_L2_UC_D4_SA_PRI_MSK, data[4]);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:157:\tuc-\u003efwd_pri = FIELD_GET(RTL8365MB_L2_UC_D5_FWD_PRI_MSK, data[5]);\n\n"
} |
| 5/2 | 2026/10/10 20:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35596 output: 44 thoughts: 55 Thoughts: Okay, let's dive into this. **Investigating the `NET_DSA_REALTEK_RTL8365MB` Probe and Hardware** Right, so I need to understand how the `NET_DSA_REALTEK_RTL8365MB` driver gets its claws into the hardware. First, I'll start with the probing mechanism. Where does the magic happen? I need to find out *exactly* what triggers this driver to spring to life. From there, I need to look at what specific hardware this thing is supposed to be running on. Time to go hunting for some code. My instinct is telling me that looking in `realtek-mdio.c` and `realtek-smi.c` is the right place to begin. Those seem like the likely candidates for the Realtek interface definitions. Let's see what clues they have in the probe function. |
| 6/2 | 2026/10/10 20:14 | tool | grepper |
0mArgs:{
"Expression": "module_platform_driver|module_mdio_driver|probe",
"PathPrefixes": [
"drivers/net/dsa/realtek"
]
}Results: {
"Output": "drivers/net/dsa/realtek/realtek-mdio.c=104=static const struct realtek_interface_info realtek_mdio_info = {\n--\ndrivers/net/dsa/realtek/realtek-mdio.c-109-/**\ndrivers/net/dsa/realtek/realtek-mdio.c:110: * realtek_mdio_probe() - Probe a platform device for an MDIO-connected switch\ndrivers/net/dsa/realtek/realtek-mdio.c:111: * @mdiodev: mdio_device to probe on.\ndrivers/net/dsa/realtek/realtek-mdio.c-112- *\ndrivers/net/dsa/realtek/realtek-mdio.c:113: * This function should be used as the .probe in an mdio_driver. After\ndrivers/net/dsa/realtek/realtek-mdio.c:114: * calling the common probe function for both interfaces, it initializes the\ndrivers/net/dsa/realtek/realtek-mdio.c-115- * values specific for MDIO-connected devices. Finally, it calls a common\n--\ndrivers/net/dsa/realtek/realtek-mdio.c-120- */\ndrivers/net/dsa/realtek/realtek-mdio.c:121:int realtek_mdio_probe(struct mdio_device *mdiodev)\ndrivers/net/dsa/realtek/realtek-mdio.c-122-{\n--\ndrivers/net/dsa/realtek/realtek-mdio.c-126-\ndrivers/net/dsa/realtek/realtek-mdio.c:127:\tpriv = rtl83xx_probe(dev, \u0026realtek_mdio_info);\ndrivers/net/dsa/realtek/realtek-mdio.c-128-\tif (IS_ERR(priv))\n--\ndrivers/net/dsa/realtek/realtek-mdio.c-142-}\ndrivers/net/dsa/realtek/realtek-mdio.c:143:EXPORT_SYMBOL_NS_GPL(realtek_mdio_probe, \"REALTEK_DSA\");\ndrivers/net/dsa/realtek/realtek-mdio.c-144-\n--\ndrivers/net/dsa/realtek/realtek-mdio.h=13=static inline void realtek_mdio_driver_unregister(struct mdio_driver *drv)\n--\ndrivers/net/dsa/realtek/realtek-mdio.h-17-\ndrivers/net/dsa/realtek/realtek-mdio.h:18:int realtek_mdio_probe(struct mdio_device *mdiodev);\ndrivers/net/dsa/realtek/realtek-mdio.h-19-void realtek_mdio_remove(struct mdio_device *mdiodev);\n--\ndrivers/net/dsa/realtek/realtek-mdio.h=29=static inline void realtek_mdio_driver_unregister(struct mdio_driver *drv)\n--\ndrivers/net/dsa/realtek/realtek-mdio.h-32-\ndrivers/net/dsa/realtek/realtek-mdio.h:33:static inline int realtek_mdio_probe(struct mdio_device *mdiodev)\ndrivers/net/dsa/realtek/realtek-mdio.h-34-{\n--\ndrivers/net/dsa/realtek/realtek-smi.c=314=static const struct realtek_interface_info realtek_smi_info = {\n--\ndrivers/net/dsa/realtek/realtek-smi.c-319-/**\ndrivers/net/dsa/realtek/realtek-smi.c:320: * realtek_smi_probe() - Probe a platform device for an SMI-connected switch\ndrivers/net/dsa/realtek/realtek-smi.c:321: * @pdev: platform_device to probe on.\ndrivers/net/dsa/realtek/realtek-smi.c-322- *\ndrivers/net/dsa/realtek/realtek-smi.c:323: * This function should be used as the .probe in a platform_driver. After\ndrivers/net/dsa/realtek/realtek-smi.c:324: * calling the common probe function for both interfaces, it initializes the\ndrivers/net/dsa/realtek/realtek-smi.c-325- * values specific for SMI-connected devices. Finally, it calls a common\n--\ndrivers/net/dsa/realtek/realtek-smi.c-330- */\ndrivers/net/dsa/realtek/realtek-smi.c:331:int realtek_smi_probe(struct platform_device *pdev)\ndrivers/net/dsa/realtek/realtek-smi.c-332-{\n--\ndrivers/net/dsa/realtek/realtek-smi.c-336-\ndrivers/net/dsa/realtek/realtek-smi.c:337:\tpriv = rtl83xx_probe(dev, \u0026realtek_smi_info);\ndrivers/net/dsa/realtek/realtek-smi.c-338-\tif (IS_ERR(priv))\n--\ndrivers/net/dsa/realtek/realtek-smi.c-363-}\ndrivers/net/dsa/realtek/realtek-smi.c:364:EXPORT_SYMBOL_NS_GPL(realtek_smi_probe, \"REALTEK_DSA\");\ndrivers/net/dsa/realtek/realtek-smi.c-365-\n--\ndrivers/net/dsa/realtek/realtek-smi.h=13=static inline void realtek_smi_driver_unregister(struct platform_driver *drv)\n--\ndrivers/net/dsa/realtek/realtek-smi.h-17-\ndrivers/net/dsa/realtek/realtek-smi.h:18:int realtek_smi_probe(struct platform_device *pdev);\ndrivers/net/dsa/realtek/realtek-smi.h-19-void realtek_smi_remove(struct platform_device *pdev);\n--\ndrivers/net/dsa/realtek/realtek-smi.h=29=static inline void realtek_smi_driver_unregister(struct platform_driver *drv)\n--\ndrivers/net/dsa/realtek/realtek-smi.h-32-\ndrivers/net/dsa/realtek/realtek-smi.h:33:static inline int realtek_smi_probe(struct platform_device *pdev)\ndrivers/net/dsa/realtek/realtek-smi.h-34-{\n--\ndrivers/net/dsa/realtek/realtek.h=165=struct realtek_variant {\n--\ndrivers/net/dsa/realtek/realtek.h-172-\tsize_t chip_data_sz;\ndrivers/net/dsa/realtek/realtek.h:173:\t/* Regulator supplies to enable at probe, or NULL */\ndrivers/net/dsa/realtek/realtek.h-174-\tconst char *const *supplies;\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=731=static const struct rtl8365mb_jam_tbl_entry rtl8365mb_init_jam_common[] = {\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-741- * option, which is what RTL8367S parts seen so far report. See\ndrivers/net/dsa/realtek/rtl8365mb_main.c:742: * rtl8365mb_sds_probe_option().\ndrivers/net/dsa/realtek/rtl8365mb_main.c-743- */\ndrivers/net/dsa/realtek/rtl8365mb_main.c=744=static const struct rtl8365mb_jam_tbl_entry rtl8365mb_sds_jam_sgmii[] = {\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-753- * option, which is what RTL8367S parts seen so far report. See\ndrivers/net/dsa/realtek/rtl8365mb_main.c:754: * rtl8365mb_sds_probe_option().\ndrivers/net/dsa/realtek/rtl8365mb_main.c-755- */\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=1434=static int rtl8365mb_sds_read(struct realtek_priv *priv, u8 index,\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-1480- * variant for option 0 uses different tuning values that cannot be verified,\ndrivers/net/dsa/realtek/rtl8365mb_main.c:1481: * so probe the option once at setup and only advertise the SerDes interface\ndrivers/net/dsa/realtek/rtl8365mb_main.c-1482- * modes when the tuning parameters are known to match, so that an unsupported\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-1485- */\ndrivers/net/dsa/realtek/rtl8365mb_main.c:1486:static int rtl8365mb_sds_probe_option(struct realtek_priv *priv)\ndrivers/net/dsa/realtek/rtl8365mb_main.c-1487-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-1501-\ndrivers/net/dsa/realtek/rtl8365mb_main.c:1502:\t/* Nothing to probe if no external interface is wired to the SerDes */\ndrivers/net/dsa/realtek/rtl8365mb_main.c-1503-\tfor (i = 0; i \u003c RTL8365MB_MAX_NUM_EXTINTS; i++) {\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=3229=static int rtl8365mb_irq_map(struct irq_domain *domain, unsigned int irq,\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3237-\tirq_set_nested_thread(irq, 1);\ndrivers/net/dsa/realtek/rtl8365mb_main.c:3238:\tirq_set_noprobe(irq);\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3239-\tirq_set_parent(irq, mb-\u003eirq);\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=3275=static int rtl8365mb_irq_setup(struct realtek_priv *priv)\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3299-\t\t} else {\ndrivers/net/dsa/realtek/rtl8365mb_main.c:3300:\t\t\tret = dev_err_probe(priv-\u003edev, irq,\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3301-\t\t\t\t\t \"failed to get parent irq\\n\");\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=3536=static int rtl8365mb_setup(struct dsa_switch *ds)\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3563-\ndrivers/net/dsa/realtek/rtl8365mb_main.c:3564:\tret = rtl8365mb_sds_probe_option(priv);\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3565-\tif (ret) {\ndrivers/net/dsa/realtek/rtl8365mb_main.c:3566:\t\tdev_err(priv-\u003edev, \"failed to probe SerDes chip option: %pe\\n\",\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3567-\t\t\tERR_PTR(ret));\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=3973=static struct platform_driver rtl8365mb_smi_driver = {\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3977-\t},\ndrivers/net/dsa/realtek/rtl8365mb_main.c:3978:\t.probe = realtek_smi_probe,\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3979-\t.remove = realtek_smi_remove,\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c=3983=static struct mdio_driver rtl8365mb_mdio_driver = {\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3987-\t},\ndrivers/net/dsa/realtek/rtl8365mb_main.c:3988:\t.probe = realtek_mdio_probe,\ndrivers/net/dsa/realtek/rtl8365mb_main.c-3989-\t.remove = realtek_mdio_remove,\n--\ndrivers/net/dsa/realtek/rtl8366rb.c=470=static int rtl8366rb_irq_map(struct irq_domain *domain, unsigned int irq,\n--\ndrivers/net/dsa/realtek/rtl8366rb.c-475-\tirq_set_nested_thread(irq, 1);\ndrivers/net/dsa/realtek/rtl8366rb.c:476:\tirq_set_noprobe(irq);\ndrivers/net/dsa/realtek/rtl8366rb.c-477-\n--\ndrivers/net/dsa/realtek/rtl8366rb.c=1846=static struct platform_driver rtl8366rb_smi_driver = {\n--\ndrivers/net/dsa/realtek/rtl8366rb.c-1850-\t},\ndrivers/net/dsa/realtek/rtl8366rb.c:1851:\t.probe = realtek_smi_probe,\ndrivers/net/dsa/realtek/rtl8366rb.c-1852-\t.remove = realtek_smi_remove,\n--\ndrivers/net/dsa/realtek/rtl8366rb.c=1856=static struct mdio_driver rtl8366rb_mdio_driver = {\n--\ndrivers/net/dsa/realtek/rtl8366rb.c-1860-\t},\ndrivers/net/dsa/realtek/rtl8366rb.c:1861:\t.probe = realtek_mdio_probe,\ndrivers/net/dsa/realtek/rtl8366rb.c-1862-\t.remove = realtek_mdio_remove,\n--\ndrivers/net/dsa/realtek/rtl83xx.c=135=EXPORT_SYMBOL_NS_GPL(rtl83xx_setup_user_mdio, \"REALTEK_DSA\");\n--\ndrivers/net/dsa/realtek/rtl83xx.c-137-/**\ndrivers/net/dsa/realtek/rtl83xx.c:138: * rtl83xx_probe() - probe a Realtek switch\ndrivers/net/dsa/realtek/rtl83xx.c:139: * @dev: the device being probed\ndrivers/net/dsa/realtek/rtl83xx.c-140- * @interface_info: specific management interface info.\n--\ndrivers/net/dsa/realtek/rtl83xx.c=151=struct realtek_priv *\ndrivers/net/dsa/realtek/rtl83xx.c:152:rtl83xx_probe(struct device *dev,\ndrivers/net/dsa/realtek/rtl83xx.c-153-\t const struct realtek_interface_info *interface_info)\n--\ndrivers/net/dsa/realtek/rtl83xx.c-225-\t\tif (ret)\ndrivers/net/dsa/realtek/rtl83xx.c:226:\t\t\treturn dev_err_ptr_probe(dev, ret, \"failed to enable supplies\\n\");\ndrivers/net/dsa/realtek/rtl83xx.c-227-\t}\n--\ndrivers/net/dsa/realtek/rtl83xx.c-230-\tif (IS_ERR(priv-\u003ereset_ctl))\ndrivers/net/dsa/realtek/rtl83xx.c:231:\t\treturn dev_err_cast_probe(dev, priv-\u003ereset_ctl,\ndrivers/net/dsa/realtek/rtl83xx.c-232-\t\t\t\t\t \"failed to get reset control\\n\");\n--\ndrivers/net/dsa/realtek/rtl83xx.c-235-\tif (IS_ERR(priv-\u003ereset))\ndrivers/net/dsa/realtek/rtl83xx.c:236:\t\treturn dev_err_cast_probe(dev, priv-\u003ereset, \"failed to get RESET GPIO\\n\");\ndrivers/net/dsa/realtek/rtl83xx.c-237-\n--\ndrivers/net/dsa/realtek/rtl83xx.c-255-}\ndrivers/net/dsa/realtek/rtl83xx.c:256:EXPORT_SYMBOL_NS_GPL(rtl83xx_probe, \"REALTEK_DSA\");\ndrivers/net/dsa/realtek/rtl83xx.c-257-\n--\ndrivers/net/dsa/realtek/rtl83xx.c=268=int rtl83xx_register_switch(struct realtek_priv *priv)\n--\ndrivers/net/dsa/realtek/rtl83xx.c-274-\tif (ret) {\ndrivers/net/dsa/realtek/rtl83xx.c:275:\t\tdev_err_probe(priv-\u003edev, ret, \"unable to detect switch\\n\");\ndrivers/net/dsa/realtek/rtl83xx.c-276-\t\treturn ret;\n--\ndrivers/net/dsa/realtek/rtl83xx.c-286-\tif (ret) {\ndrivers/net/dsa/realtek/rtl83xx.c:287:\t\tdev_err_probe(priv-\u003edev, ret, \"unable to register switch\\n\");\ndrivers/net/dsa/realtek/rtl83xx.c-288-\t\treturn ret;\n--\ndrivers/net/dsa/realtek/rtl83xx.h=14=struct realtek_priv *\ndrivers/net/dsa/realtek/rtl83xx.h:15:rtl83xx_probe(struct device *dev,\ndrivers/net/dsa/realtek/rtl83xx.h-16-\t const struct realtek_interface_info *interface_info);\n"
} |
| 7/2 | 2026/10/10 20:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40866 output: 49 thoughts: 54 Thoughts: Here's my analysis of what I'm seeing: **Analyzing rtl8365mb Device Matching** Alright, let's dive in. My immediate task is to understand what hardware devices are being associated with the `rtl8365mb` driver. I need to figure out which specific devices this driver is designed to work with, which informs my understanding of the system's architecture. To do that, I'm zeroing in on the relevant code. Specifically, lines 3970 through 4000 of `drivers/net/dsa/realtek/rtl8365mb_main.c` are where the device matching logic likely resides. This is the section where the driver declares which hardware identifiers it's prepared to handle. I'll need to examine this code block closely to decode the matching criteria—be it vendor IDs, device IDs, or some other hardware descriptor—used to establish the driver-device connection. My goal is a concise but complete picture of the devices this driver natively supports. |
| 8/2 | 2026/10/10 20:14 | tool | read-file |
0mArgs:{
"File": "drivers/net/dsa/realtek/rtl8365mb_main.c",
"FirstLine": 3960,
"LineCount": 50
}Results: {
"Contents": "3960:\t\t.cmd_read = 0xb9,\n3961:\t\t.cmd_write = 0xb8,\n3962:\t\t.chip_data_sz = sizeof(struct rtl8365mb),\n3963:\t\t.supplies = rtl8365mb_supplies,\n3964:\t\t.num_supplies = ARRAY_SIZE(rtl8365mb_supplies),\n3965:\t};\n3966:\t\n3967:\tstatic const struct of_device_id rtl8365mb_of_match[] = {\n3968:\t\t{ .compatible = \"realtek,rtl8365mb\", .data = \u0026rtl8365mb_variant, },\n3969:\t\t{ /* sentinel */ }\n3970:\t};\n3971:\tMODULE_DEVICE_TABLE(of, rtl8365mb_of_match);\n3972:\t\n3973:\tstatic struct platform_driver rtl8365mb_smi_driver = {\n3974:\t\t.driver = {\n3975:\t\t\t.name = \"rtl8365mb-smi\",\n3976:\t\t\t.of_match_table = rtl8365mb_of_match,\n3977:\t\t},\n3978:\t\t.probe = realtek_smi_probe,\n3979:\t\t.remove = realtek_smi_remove,\n3980:\t\t.shutdown = realtek_smi_shutdown,\n3981:\t};\n3982:\t\n3983:\tstatic struct mdio_driver rtl8365mb_mdio_driver = {\n3984:\t\t.mdiodrv.driver = {\n3985:\t\t\t.name = \"rtl8365mb-mdio\",\n3986:\t\t\t.of_match_table = rtl8365mb_of_match,\n3987:\t\t},\n3988:\t\t.probe = realtek_mdio_probe,\n3989:\t\t.remove = realtek_mdio_remove,\n3990:\t\t.shutdown = realtek_mdio_shutdown,\n3991:\t};\n3992:\t\n3993:\tstatic int rtl8365mb_init(void)\n3994:\t{\n3995:\t\tint ret;\n3996:\t\n3997:\t\tret = realtek_mdio_driver_register(\u0026rtl8365mb_mdio_driver);\n3998:\t\tif (ret)\n3999:\t\t\treturn ret;\n4000:\t\n4001:\t\tret = realtek_smi_driver_register(\u0026rtl8365mb_smi_driver);\n4002:\t\tif (ret) {\n4003:\t\t\trealtek_mdio_driver_unregister(\u0026rtl8365mb_mdio_driver);\n4004:\t\t\treturn ret;\n4005:\t\t}\n4006:\t\n4007:\t\treturn 0;\n4008:\t}\n4009:\tmodule_init(rtl8365mb_init);\n"
} |
| 9/2 | 2026/10/10 20:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42005 output: 34 thoughts: 416 Thoughts: **My Assessment of the Fuzzing Feasibility** Okay, let's break this down. First, I need to understand this driver – it's an Ethernet switch driver, using the DSA architecture. It interacts either with an MDIO bus or the SMI interface, which is a Realtek-specific way of managing it over GPIO. Both of these rely on Device Tree, which is good to know (`of_match_table = rtl8365mb_of_match`). The key question is, are these hardware components emulated in my test environment? Specifically, since I'm running in an x86_64 or amd64 virtual environment like QEMU or Google Compute Engine, is there an emulated MDIO bus, a functioning Device Tree, or a simulated Realtek DSA switch? If not, it's a non-starter. Now, let's go back and check that specific section of the instructions. The rules for returning `WorthFuzzing=false` are very specific. I see that “Structurally unreachable hardware” is one of them. The examples mention PCIe switches, SmartNICs, GPU drivers (like mlxsw, pds_core, qed, ionic, amdgpu) which require physical cards not emulated in standard QEMU. That's a good comparison. So, *can* DSA drivers or Realtek switches be emulated or instantiated? If not, this is likely in the "structurally unreachable hardware" category and I should set `WorthFuzzing=false`. I need to investigate further. Can syzkaller or QEMU even *probe* or *mock* DSA drivers? Or, can DSA switches be instantiated through netlink, configfs, sysfs, or platform device creation? I need to know if I can create the necessary infrastructure from userspace. Can I create a platform device or an MDIO device from userspace, or can this driver be probed? Alright, let's dig into the `drivers/net/dsa/` directory and see how DSA devices are actually created and managed. This is where I'll find my answers. |
| 10/2 | 2026/10/10 20:14 | tool | grepper |
0mArgs:{
"Expression": "rtl8365mb",
"PathPrefixes": [
"drivers/",
"net/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 1940 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (11 files in total):\ndrivers/net/dsa/realtek/Makefile:6\ndrivers/net/dsa/realtek/realtek.h:1\ndrivers/net/dsa/realtek/rtl8365mb.h:2\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:41\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:7\ndrivers/net/dsa/realtek/rtl8365mb_main.c:421\ndrivers/net/dsa/realtek/rtl8365mb_table.c:12\ndrivers/net/dsa/realtek/rtl8365mb_table.h:15\ndrivers/net/dsa/realtek/rtl8365mb_vlan.c:101\ndrivers/net/dsa/realtek/rtl8365mb_vlan.h:11\ndrivers/net/phy/realtek/realtek_main.c:6\n\ndrivers/net/dsa/realtek/Makefile=17=endif\ndrivers/net/dsa/realtek/Makefile:18:obj-$(CONFIG_NET_DSA_REALTEK_RTL8365MB) += rtl8365mb.o\ndrivers/net/dsa/realtek/Makefile:19:rtl8365mb-objs := rtl8365mb_main.o \\\ndrivers/net/dsa/realtek/Makefile:20:\t\t rtl8365mb_table.o \\\ndrivers/net/dsa/realtek/Makefile:21:\t\t rtl8365mb_vlan.o \\\ndrivers/net/dsa/realtek/Makefile:22:\t\t rtl8365mb_l2.o \\\ndrivers/net/dsa/realtek/Makefile:23:# end of rtl8365mb-objs\n--\ndrivers/net/dsa/realtek/realtek.h=197=extern const struct realtek_variant rtl8366rb_variant;\ndrivers/net/dsa/realtek/realtek.h:198:extern const struct realtek_variant rtl8365mb_variant;\ndrivers/net/dsa/realtek/realtek.h-199-\n--\ndrivers/net/dsa/realtek/rtl8365mb.h-6-\ndrivers/net/dsa/realtek/rtl8365mb.h:7:enum rtl8365mb_family {\ndrivers/net/dsa/realtek/rtl8365mb.h-8-\tRTL8365MB_FAMILY_C,\n--\ndrivers/net/dsa/realtek/rtl8365mb.h-11-\ndrivers/net/dsa/realtek/rtl8365mb.h:12:enum rtl8365mb_family rtl8365mb_get_family(struct realtek_priv *priv);\ndrivers/net/dsa/realtek/rtl8365mb.h-13-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-1-// SPDX-License-Identifier: GPL-2.0\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:2:/* Forwarding and multicast database interface for the rtl8365mb switch family\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-3- *\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-8-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:9:#include \"rtl8365mb_l2.h\"\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:10:#include \"rtl8365mb_table.h\"\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-11-#include \u003clinux/regmap.h\u003e\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-91-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:92:struct rtl8365mb_l2_uc_key {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-93-\tu8 mac_addr[ETH_ALEN];\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-99-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:100:struct rtl8365mb_l2_uc {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:101:\tstruct rtl8365mb_l2_uc_key key;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-102-\tu8 port;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-113-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:114:struct rtl8365mb_l2_mc_key {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-115-\tu8 mac_addr[ETH_ALEN];\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-122-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:123:struct rtl8365mb_l2_mc {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:124:\tstruct rtl8365mb_l2_mc_key key;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-125-\tu16 member;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-133-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:134:static void rtl8365mb_l2_data_to_uc(const u16 *data, struct rtl8365mb_l2_uc *uc)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-135-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-163-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:164:static void rtl8365mb_l2_uc_to_data(const struct rtl8365mb_l2_uc *uc, u16 *data)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-165-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-202-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:203:static void rtl8365mb_l2_data_to_mc(const u16 *data, struct rtl8365mb_l2_mc *mc)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-204-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-230-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:231:static void rtl8365mb_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc, u16 *data)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-232-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-261-/*\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:262: * rtl8365mb_l2_get_next_uc() - get the next Unicast L2 entry\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-263- * @priv: realtek_priv pointer\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-281- **/\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:282:int rtl8365mb_l2_get_next_uc(struct realtek_priv *priv, u16 *addr, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-283-\t\t\t struct realtek_fdb_entry *entry)\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-285-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:286:\tstruct rtl8365mb_l2_uc uc;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-287-\tint ret;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-288-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:289:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-290-\t\t\t\t RTL8365MB_TABLE_OP_READ, addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-295-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:296:\trtl8365mb_l2_data_to_uc(data, \u0026uc);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-297-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-304-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:305:int rtl8365mb_l2_add_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-306-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-309-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:310:\tstruct rtl8365mb_l2_uc uc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-311-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-328-\tuc.age = 1;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:329:\trtl8365mb_l2_uc_to_data(\u0026uc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-330-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-331-\t/* add the new entry or update an existing one */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:332:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-333-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-344-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:345:int rtl8365mb_l2_del_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-346-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-349-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:350:\tstruct rtl8365mb_l2_uc uc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-351-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-360-\tuc.age = 0;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:361:\trtl8365mb_l2_uc_to_data(\u0026uc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-362-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-367-\t */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:368:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-369-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-383-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:384:int rtl8365mb_l2_flush(struct realtek_priv *priv, int port, u16 vid)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-385-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-448-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:449:int rtl8365mb_l2_add_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-450-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-453-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:454:\tstruct rtl8365mb_l2_mc mc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-455-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-465-\tmc.is_static = 1;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:466:\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-467-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-468-\t/* First look for an existing entry (to get existing port members) */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:469:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-470-\t\t\t\t RTL8365MB_TABLE_OP_READ, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-474-\t\t/* There is already an entry... */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:475:\t\trtl8365mb_l2_data_to_mc(data, \u0026mc);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-476-\t\tdev_dbg(priv-\u003edev,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-489-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:490:\t\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-491-\t} else if (ret == -ENOENT) {\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-507-\t/* add the new entry or update an existing one */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:508:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-509-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-519-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:520:int rtl8365mb_l2_del_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-521-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-524-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:525:\tstruct rtl8365mb_l2_mc mc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-526-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-531-\tmc.key.ivl = true;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:532:\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-533-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-534-\t/* First look for an existing entry (to get existing port members) */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:535:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-536-\t\t\t\t RTL8365MB_TABLE_OP_READ, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-549-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:550:\trtl8365mb_l2_data_to_mc(data, \u0026mc);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-551-\tdev_dbg(priv-\u003edev,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-567-\t}\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:568:\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-569-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-570-\t/* update the existing entry. */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:571:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-572-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-1-/* SPDX-License-Identifier: GPL-2.0 */\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:2:/* Forwarding and multicast database interface for the rtl8365mb switch family\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-3- *\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-14-\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:15:int rtl8365mb_l2_get_next_uc(struct realtek_priv *priv, u16 *addr, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-16-\t\t\t struct realtek_fdb_entry *entry);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:17:int rtl8365mb_l2_add_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-18-\t\t\tconst unsigned char addr[static ETH_ALEN],\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-19-\t\t\tu16 efid, u16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:20:int rtl8365mb_l2_del_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-21-\t\t\tconst unsigned char addr[static ETH_ALEN],\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-22-\t\t\tu16 efid, u16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:23:int rtl8365mb_l2_flush(struct realtek_priv *priv, int port, u16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-24-\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:25:int rtl8365mb_l2_add_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-26-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-27-\t\t\tu16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:28:int rtl8365mb_l2_del_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-29-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-64- * require the rtl8367d vendor driver. With all this uncertainty, the driver has\ndrivers/net/dsa/realtek/rtl8365mb_main.c:65: * been modestly named rtl8365mb. Future implementors may wish to rename things\ndrivers/net/dsa/realtek/rtl8365mb_main.c-66- * accordingly.\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-96- * configuration and the SerDes, so the code paths specific to it are selected\ndrivers/net/dsa/realtek/rtl8365mb_main.c:97: * with rtl8365mb_get_family().\ndrivers/net/dsa/realtek/rtl8365mb_main.c-98- */\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-117-#include \"rtl83xx.h\"\n\n"
} |
| 11/2 | 2026/10/10 20:14 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 49501 output: 45 thoughts: 69 Thoughts: Here's my analysis of this probe process: **Diving into Realtek Device Probing** Okay, so I need to understand how the system's detecting and initializing these Realtek switches – specifically, anything using the `rtl83xx` family, or using the `realtek_smi` and `realtek_mdio` drivers. My initial thought is to trace the probe function calls. I'll need to scrutinize the `realtek-smi.c` and `realtek-mdio.c` source files. My primary focus is pinpointing the `realtek_smi_probe` and `realtek_mdio_probe` functions, respectively, and then map how the system is calling them. I need to see *how* these probes are being triggered, what data they are taking in, and what they are doing. This will give me the most complete overview. |
| 12/2 | 2026/10/10 20:15 | tool | read-file |
0mArgs:{
"File": "drivers/net/dsa/realtek/realtek-smi.c",
"FirstLine": 315,
"LineCount": 55
}Results: {
"Contents": " 315:\t\t.reg_read = realtek_smi_read,\n 316:\t\t.reg_write = realtek_smi_write,\n 317:\t};\n 318:\t\n 319:\t/**\n 320:\t * realtek_smi_probe() - Probe a platform device for an SMI-connected switch\n 321:\t * @pdev: platform_device to probe on.\n 322:\t *\n 323:\t * This function should be used as the .probe in a platform_driver. After\n 324:\t * calling the common probe function for both interfaces, it initializes the\n 325:\t * values specific for SMI-connected devices. Finally, it calls a common\n 326:\t * function to register the DSA switch.\n 327:\t *\n 328:\t * Context: Can sleep. Takes and releases priv-\u003emap_lock.\n 329:\t * Return: Returns 0 on success, a negative error on failure.\n 330:\t */\n 331:\tint realtek_smi_probe(struct platform_device *pdev)\n 332:\t{\n 333:\t\tstruct device *dev = \u0026pdev-\u003edev;\n 334:\t\tstruct realtek_priv *priv;\n 335:\t\tint ret;\n 336:\t\n 337:\t\tpriv = rtl83xx_probe(dev, \u0026realtek_smi_info);\n 338:\t\tif (IS_ERR(priv))\n 339:\t\t\treturn PTR_ERR(priv);\n 340:\t\n 341:\t\t/* Fetch MDIO pins */\n 342:\t\tpriv-\u003emdc = devm_gpiod_get_optional(dev, \"mdc\", GPIOD_OUT_LOW);\n 343:\t\tif (IS_ERR(priv-\u003emdc)) {\n 344:\t\t\trtl83xx_remove(priv);\n 345:\t\t\treturn PTR_ERR(priv-\u003emdc);\n 346:\t\t}\n 347:\t\n 348:\t\tpriv-\u003emdio = devm_gpiod_get_optional(dev, \"mdio\", GPIOD_OUT_LOW);\n 349:\t\tif (IS_ERR(priv-\u003emdio)) {\n 350:\t\t\trtl83xx_remove(priv);\n 351:\t\t\treturn PTR_ERR(priv-\u003emdio);\n 352:\t\t}\n 353:\t\n 354:\t\tpriv-\u003ewrite_reg_noack = realtek_smi_write_reg_noack;\n 355:\t\n 356:\t\tret = rtl83xx_register_switch(priv);\n 357:\t\tif (ret) {\n 358:\t\t\trtl83xx_remove(priv);\n 359:\t\t\treturn ret;\n 360:\t\t}\n 361:\t\n 362:\t\treturn 0;\n 363:\t}\n 364:\tEXPORT_SYMBOL_NS_GPL(realtek_smi_probe, \"REALTEK_DSA\");\n 365:\t\n 366:\t/**\n 367:\t * realtek_smi_remove() - Remove the driver of a SMI-connected switch\n 368:\t * @pdev: platform_device to be removed.\n 369:\t *\n"
} |
| 13/2 | 2026/10/10 20:15 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 50669 output: 44 thoughts: 42 Thoughts: Here's my summary, as if I were thinking these thoughts: **Examining the Realtek Switch Driver Initialization** Okay, time to dig into the Realtek switch driver. I need to refresh my memory on how this initialization process works. Let's start by scrutinizing the `rtl83xx_probe` function. I want to see how the driver actually gets attached to the device – what resources it claims, how it sets up the initial hardware state, and if there are any obvious gotchas in the probe sequence itself. Then, I'll move on to `rtl83xx_register_switch`. This is where the DSA (Distributed Switch Architecture) aspects come into play. I'll need to understand how the switch is integrated into the DSA framework, how it's represented as a network device, and how the various control and data paths are established. I'll pay close attention to the order of operations in both functions, to make sure there aren't any potential race conditions or resource conflicts. Good, methodical approach is key here. Let's see what we've got in `drivers/net/dsa/realtek/rtl83xx.c`. |
| 14/2 | 2026/10/10 20:15 | tool | read-file |
0mArgs:{
"File": "drivers/net/dsa/realtek/rtl83xx.c",
"FirstLine": 145,
"LineCount": 80
}Results: {
"Contents": " 145:\t * Context: Can sleep.\n 146:\t * Return: Pointer to the realtek_priv or ERR_PTR() in case of failure.\n 147:\t *\n 148:\t * The realtek_priv pointer does not need to be freed as it is controlled by\n 149:\t * devres.\n 150:\t */\n 151:\tstruct realtek_priv *\n 152:\trtl83xx_probe(struct device *dev,\n 153:\t\t const struct realtek_interface_info *interface_info)\n 154:\t{\n 155:\t\tconst struct realtek_variant *var;\n 156:\t\tstruct realtek_priv *priv;\n 157:\t\tstruct regmap_config rc = {\n 158:\t\t\t.reg_bits = 10, /* A4..A0 R4..R0 */\n 159:\t\t\t.val_bits = 16,\n 160:\t\t\t.reg_stride = 1,\n 161:\t\t\t.max_register = 0xffff,\n 162:\t\t\t.reg_format_endian = REGMAP_ENDIAN_BIG,\n 163:\t\t\t.reg_read = interface_info-\u003ereg_read,\n 164:\t\t\t.reg_write = interface_info-\u003ereg_write,\n 165:\t\t\t.cache_type = REGCACHE_NONE,\n 166:\t\t\t.lock = rtl83xx_lock,\n 167:\t\t\t.unlock = rtl83xx_unlock,\n 168:\t\t};\n 169:\t\tint ret;\n 170:\t\n 171:\t\tvar = of_device_get_match_data(dev);\n 172:\t\tif (!var)\n 173:\t\t\treturn ERR_PTR(-EINVAL);\n 174:\t\n 175:\t\tpriv = devm_kzalloc(dev, size_add(sizeof(*priv), var-\u003echip_data_sz),\n 176:\t\t\t\t GFP_KERNEL);\n 177:\t\tif (!priv)\n 178:\t\t\treturn ERR_PTR(-ENOMEM);\n 179:\t\n 180:\t\tret = devm_mutex_init(dev, \u0026priv-\u003emap_lock);\n 181:\t\tif (ret)\n 182:\t\t\treturn ERR_PTR(ret);\n 183:\t\n 184:\t\tret = devm_mutex_init(dev, \u0026priv-\u003evlan_lock);\n 185:\t\tif (ret)\n 186:\t\t\treturn ERR_PTR(ret);\n 187:\t\n 188:\t\tret = devm_mutex_init(dev, \u0026priv-\u003el2_lock);\n 189:\t\tif (ret)\n 190:\t\t\treturn ERR_PTR(ret);\n 191:\t\n 192:\t\trc.lock_arg = priv;\n 193:\t\tpriv-\u003emap = devm_regmap_init(dev, NULL, priv, \u0026rc);\n 194:\t\tif (IS_ERR(priv-\u003emap)) {\n 195:\t\t\tret = PTR_ERR(priv-\u003emap);\n 196:\t\t\tdev_err(dev, \"regmap init failed: %d\\n\", ret);\n 197:\t\t\treturn ERR_PTR(ret);\n 198:\t\t}\n 199:\t\n 200:\t\trc.disable_locking = true;\n 201:\t\tpriv-\u003emap_nolock = devm_regmap_init(dev, NULL, priv, \u0026rc);\n 202:\t\tif (IS_ERR(priv-\u003emap_nolock)) {\n 203:\t\t\tret = PTR_ERR(priv-\u003emap_nolock);\n 204:\t\t\tdev_err(dev, \"regmap init failed: %d\\n\", ret);\n 205:\t\t\treturn ERR_PTR(ret);\n 206:\t\t}\n 207:\t\n 208:\t\t/* Link forward and backward */\n 209:\t\tpriv-\u003edev = dev;\n 210:\t\tpriv-\u003evariant = var;\n 211:\t\tpriv-\u003eops = var-\u003eops;\n 212:\t\tpriv-\u003echip_data = (void *)priv + sizeof(*priv);\n 213:\t\n 214:\t\tspin_lock_init(\u0026priv-\u003elock);\n 215:\t\n 216:\t\tpriv-\u003eleds_disabled = of_property_read_bool(dev-\u003eof_node,\n 217:\t\t\t\t\t\t\t \"realtek,disable-leds\");\n 218:\t\n 219:\t\t/* Enable the supplies before the reset line is requested and driven,\n 220:\t\t * so the chip is powered before its pins are driven.\n 221:\t\t */\n 222:\t\tif (var-\u003enum_supplies) {\n 223:\t\t\tret = devm_regulator_bulk_get_enable(dev, var-\u003enum_supplies,\n 224:\t\t\t\t\t\t\t var-\u003esupplies);\n"
} |
| 15/2 | 2026/10/10 20:15 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 52276 output: 44 thoughts: 52 Thoughts: Here's my analysis of the provided code snippets, keeping in mind my expertise: **Diving into Device Tree Matching and Switch Registration** Okay, so I'm seeing a classic Device Tree lookup in the `var = of_device_get_match_data(dev);` line. This is the initial step for extracting board/device-specific data associated with a specific device tree node. If the Device Tree entry doesn't have a matching entry, then `var` will be `NULL`, and the code defensively returns an error. No surprises there; standard error handling. This `var` is likely where the specific configuration parameters or pointers to more detailed device information resides. Then, there's `dev->of_node`. This is the fundamental link to the Device Tree itself. I'd expect this pointer to be passed to various helper functions, for things like getting properties, looking up child nodes, and traversing the Device Tree structure. This is how the driver discovers its hardware configuration. Finally, the `rtl83xx_register_switch` function. Based on the name, this is probably where the main registration of the switch happens. I'd imagine that this function does a lot of important things, like: * **Initialization**: Setting up the internal data structures specific to the switch. * **Resource Allocation**: Acquiring and configuring necessary memory or hardware resources. * **IRQ Setup**: Handling and registering interrupt handlers. * **Device Driver Linking**: Making the switch accessible through the kernel's device model, by adding a device node. The `of_device_get_match_data()` call and the Device Tree node `dev->of_node` are almost certainly going to be critical inside this `rtl83xx_register_switch` function. It's the place where the data discovered from the Device Tree will get translated into the initialization parameters and hardware configuration for the switch. I'd expect the code to extract properties and use them to configure the switch registers, enable certain features, and set up the relevant I/O mapping. This looks like a solid starting point for a well-structured driver. |
| 16/2 | 2026/10/10 20:15 | tool | read-file |
0mArgs:{
"File": "drivers/net/dsa/realtek/rtl83xx.c",
"FirstLine": 265,
"LineCount": 45
}Results: {
"Contents": " 265:\t * Context: Can sleep. Takes and releases priv-\u003emap_lock.\n 266:\t * Return: 0 on success, negative value for failure.\n 267:\t */\n 268:\tint rtl83xx_register_switch(struct realtek_priv *priv)\n 269:\t{\n 270:\t\tstruct dsa_switch *ds = \u0026priv-\u003eds;\n 271:\t\tint ret;\n 272:\t\n 273:\t\tret = priv-\u003eops-\u003edetect(priv);\n 274:\t\tif (ret) {\n 275:\t\t\tdev_err_probe(priv-\u003edev, ret, \"unable to detect switch\\n\");\n 276:\t\t\treturn ret;\n 277:\t\t}\n 278:\t\n 279:\t\tds-\u003epriv = priv;\n 280:\t\tds-\u003edev = priv-\u003edev;\n 281:\t\tds-\u003eops = priv-\u003evariant-\u003eds_ops;\n 282:\t\tds-\u003ephylink_mac_ops = priv-\u003evariant-\u003ephylink_mac_ops;\n 283:\t\tds-\u003enum_ports = priv-\u003enum_ports;\n 284:\t\n 285:\t\tret = dsa_register_switch(ds);\n 286:\t\tif (ret) {\n 287:\t\t\tdev_err_probe(priv-\u003edev, ret, \"unable to register switch\\n\");\n 288:\t\t\treturn ret;\n 289:\t\t}\n 290:\t\n 291:\t\treturn 0;\n 292:\t}\n 293:\tEXPORT_SYMBOL_NS_GPL(rtl83xx_register_switch, \"REALTEK_DSA\");\n 294:\t\n 295:\t/**\n 296:\t * rtl83xx_unregister_switch() - unregister a switch\n 297:\t * @priv: realtek_priv pointer\n 298:\t *\n 299:\t * This function unregister a DSA switch.\n 300:\t *\n 301:\t * Context: Can sleep.\n 302:\t * Return: Nothing.\n 303:\t */\n 304:\tvoid rtl83xx_unregister_switch(struct realtek_priv *priv)\n 305:\t{\n 306:\t\tstruct dsa_switch *ds = \u0026priv-\u003eds;\n 307:\t\n 308:\t\tdsa_unregister_switch(ds);\n 309:\t}\n"
} |
| 17/2 | 2026/10/10 20:15 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53471 output: 49 thoughts: 64 Thoughts: Here's my analysis of what I'm looking at, from a low-level perspective: **Deep Dive into the RTL8365MB Detection Routine** Okay, so I'm starting with a function call: `priv->ops->detect(priv)`. This is likely a key method within a driver interface, probably related to network device detection. My immediate thought is to trace this, and figure out exactly what's happening. The `priv` variable is critical – it's likely a private data structure specific to the RTL8365MB switch. The `->ops` pointer suggests a method table or a set of function pointers allowing for polymorphism; I'm expecting this to be an abstraction layer for hardware-specific operations. I'm specifically looking at the `rtl8365mb_detect` function. Given the naming convention, I bet this is the *specific* detection routine for the RTL8365MB hardware. I'm going to want to understand how it identifies this particular switch. Does it read registers? Does it send specific commands? Does it probe for certain responses? My next step? Dive right into the code itself. I'm going to pull up `drivers/net/dsa/realtek/rtl8365mb_main.c` and zero in on the `rtl8365mb_detect` function to understand the detection strategy used. I need to understand what specific hardware interactions this code is performing. I'll be looking for register reads, initialization sequences, and any telltale hardware signatures that the routine is using to confirm the presence and model of the target switch. This is fundamental, and it's where the rubber meets the road. |
| 18/2 | 2026/10/10 20:15 | tool | read-file |
0mArgs:{
"File": "drivers/net/dsa/realtek/rtl8365mb_main.c",
"FirstLine": 3780,
"LineCount": 45
}Results: {
"Contents": "3780:\t\tu32 chip_id;\n3781:\t\tu32 chip_ver;\n3782:\t\tint ret;\n3783:\t\tint i;\n3784:\t\n3785:\t\tret = rtl8365mb_get_chip_id_and_ver(priv-\u003emap, \u0026chip_id, \u0026chip_ver);\n3786:\t\tif (ret) {\n3787:\t\t\tdev_err(priv-\u003edev, \"failed to read chip id and version: %pe\\n\",\n3788:\t\t\t\tERR_PTR(ret));\n3789:\t\t\treturn ret;\n3790:\t\t}\n3791:\t\n3792:\t\tfor (i = 0; i \u003c ARRAY_SIZE(rtl8365mb_chip_infos); i++) {\n3793:\t\t\tconst struct rtl8365mb_chip_info *ci = \u0026rtl8365mb_chip_infos[i];\n3794:\t\n3795:\t\t\tif (ci-\u003echip_id == chip_id \u0026\u0026 ci-\u003echip_ver == chip_ver) {\n3796:\t\t\t\tmb-\u003echip_info = ci;\n3797:\t\t\t\tbreak;\n3798:\t\t\t}\n3799:\t\t}\n3800:\t\n3801:\t\tif (!mb-\u003echip_info) {\n3802:\t\t\tdev_err(priv-\u003edev,\n3803:\t\t\t\t\"unrecognized switch (id=0x%04x, ver=0x%04x)\", chip_id,\n3804:\t\t\t\tchip_ver);\n3805:\t\t\treturn -ENODEV;\n3806:\t\t}\n3807:\t\n3808:\t\tdev_info(priv-\u003edev, \"found an %s switch\\n\", mb-\u003echip_info-\u003ename);\n3809:\t\n3810:\t\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D)\n3811:\t\t\tpriv-\u003enum_ports = RTL8365MB_D_MAX_NUM_PORTS;\n3812:\t\telse\n3813:\t\t\tpriv-\u003enum_ports = RTL8365MB_MAX_NUM_PORTS;\n3814:\t\n3815:\t\tret = devm_mutex_init(priv-\u003edev, \u0026mb-\u003esds_lock);\n3816:\t\tif (ret)\n3817:\t\t\treturn ret;\n3818:\t\n3819:\t\tif (rtl8365mb_get_family(priv) == RTL8365MB_FAMILY_D) {\n3820:\t\t\t/* Registered after sds_lock, so on release the work is\n3821:\t\t\t * cancelled before the mutex is destroyed.\n3822:\t\t\t */\n3823:\t\t\tINIT_DELAYED_WORK(\u0026mb-\u003esds_relatch,\n3824:\t\t\t\t\t rtl8365mb_sds_relatch_work);\n"
} |
| 19/2 | 2026/10/10 20:15 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 54712 output: 39 thoughts: 1949 Thoughts: **Fuzzing Analysis: Realtek RTL8365MB Driver** Okay, let's break this down. My initial observation is focused on `rtl8365mb_get_chip_id_and_ver`. This function reads hardware, specifically a Realtek Ethernet switch chip (like the RTL8365MB, RTL8367S, etc.) via MDIO or SMI (using GPIOs). The question is, can this even *run* in a standard fuzzing environment like QEMU or GCE? The answer, as I suspect, is no. QEMU doesn't emulate these Realtek switch chips. This falls under the "structurally unreachable hardware" category defined in the guidance. Now, let's verify that assumption by following the instructions: Section 2 says we should return WorthFuzzing=false if all code is in that category. Section 2, item "Structurally unreachable hardware" applies here: "Vendor-specific PCIe switches, SmartNICs, or GPU drivers... requiring physical ASIC/PCIe cards not emulated in standard QEMU". I need to confirm this Realtek DSA driver is *truly* unreachable. How is the `rtl8365mb` driver registered? I see it registers with both `mdio_driver` and `platform_driver`. The platform driver uses device tree (`rtl8365mb_of_match`). Can this even *match* without a Device Tree? In standard x86 QEMU/GCE environments, ACPI is used, not Device Tree, so no. Even if there's an OF node (unlikely), the `rtl83xx_probe` function *requires* the device tree via `of_device_get_match_data`. Furthermore, inside `rtl83xx_probe`, the code attempts to communicate with the hardware via MDIO or SMI to read the chip ID register. The driver looks for specific chip IDs (0x6367 or 0x6642) from the Realtek chip. Without the *actual* Realtek switch chip, it will fail during the probe stage, specifically, with -ENODEV (or possibly -EIO or timeout). Essentially, this is *dependent on real hardware*. So, the next obvious check is whether there is any *mock* DSA switch or emulator for Realtek switches. Let's see if the code tree includes anything that could emulate these switches, but that is very unlikely. Therefore, since the code's execution depends on the presence of physical hardware not emulated in standard fuzzing environments, I can confidently conclude that fuzzing this driver is *not* worth the effort. It's unreachable in the target environments. |
| 20/2 | 2026/10/10 20:15 | tool | grepper |
0mArgs:{
"Expression": "rtl8365mb",
"PathPrefixes": [
"tools/",
"drivers/net/dsa/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 1915 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (10 files in total):\ndrivers/net/dsa/realtek/Makefile:6\ndrivers/net/dsa/realtek/realtek.h:1\ndrivers/net/dsa/realtek/rtl8365mb.h:2\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:41\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:7\ndrivers/net/dsa/realtek/rtl8365mb_main.c:421\ndrivers/net/dsa/realtek/rtl8365mb_table.c:12\ndrivers/net/dsa/realtek/rtl8365mb_table.h:15\ndrivers/net/dsa/realtek/rtl8365mb_vlan.c:101\ndrivers/net/dsa/realtek/rtl8365mb_vlan.h:11\n\ndrivers/net/dsa/realtek/Makefile=17=endif\ndrivers/net/dsa/realtek/Makefile:18:obj-$(CONFIG_NET_DSA_REALTEK_RTL8365MB) += rtl8365mb.o\ndrivers/net/dsa/realtek/Makefile:19:rtl8365mb-objs := rtl8365mb_main.o \\\ndrivers/net/dsa/realtek/Makefile:20:\t\t rtl8365mb_table.o \\\ndrivers/net/dsa/realtek/Makefile:21:\t\t rtl8365mb_vlan.o \\\ndrivers/net/dsa/realtek/Makefile:22:\t\t rtl8365mb_l2.o \\\ndrivers/net/dsa/realtek/Makefile:23:# end of rtl8365mb-objs\n--\ndrivers/net/dsa/realtek/realtek.h=197=extern const struct realtek_variant rtl8366rb_variant;\ndrivers/net/dsa/realtek/realtek.h:198:extern const struct realtek_variant rtl8365mb_variant;\ndrivers/net/dsa/realtek/realtek.h-199-\n--\ndrivers/net/dsa/realtek/rtl8365mb.h-6-\ndrivers/net/dsa/realtek/rtl8365mb.h:7:enum rtl8365mb_family {\ndrivers/net/dsa/realtek/rtl8365mb.h-8-\tRTL8365MB_FAMILY_C,\n--\ndrivers/net/dsa/realtek/rtl8365mb.h-11-\ndrivers/net/dsa/realtek/rtl8365mb.h:12:enum rtl8365mb_family rtl8365mb_get_family(struct realtek_priv *priv);\ndrivers/net/dsa/realtek/rtl8365mb.h-13-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-1-// SPDX-License-Identifier: GPL-2.0\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:2:/* Forwarding and multicast database interface for the rtl8365mb switch family\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-3- *\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-8-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:9:#include \"rtl8365mb_l2.h\"\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:10:#include \"rtl8365mb_table.h\"\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-11-#include \u003clinux/regmap.h\u003e\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-91-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:92:struct rtl8365mb_l2_uc_key {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-93-\tu8 mac_addr[ETH_ALEN];\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-99-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:100:struct rtl8365mb_l2_uc {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:101:\tstruct rtl8365mb_l2_uc_key key;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-102-\tu8 port;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-113-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:114:struct rtl8365mb_l2_mc_key {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-115-\tu8 mac_addr[ETH_ALEN];\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-122-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:123:struct rtl8365mb_l2_mc {\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:124:\tstruct rtl8365mb_l2_mc_key key;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-125-\tu16 member;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-133-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:134:static void rtl8365mb_l2_data_to_uc(const u16 *data, struct rtl8365mb_l2_uc *uc)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-135-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-163-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:164:static void rtl8365mb_l2_uc_to_data(const struct rtl8365mb_l2_uc *uc, u16 *data)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-165-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-202-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:203:static void rtl8365mb_l2_data_to_mc(const u16 *data, struct rtl8365mb_l2_mc *mc)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-204-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-230-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:231:static void rtl8365mb_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc, u16 *data)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-232-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-261-/*\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:262: * rtl8365mb_l2_get_next_uc() - get the next Unicast L2 entry\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-263- * @priv: realtek_priv pointer\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-281- **/\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:282:int rtl8365mb_l2_get_next_uc(struct realtek_priv *priv, u16 *addr, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-283-\t\t\t struct realtek_fdb_entry *entry)\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-285-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:286:\tstruct rtl8365mb_l2_uc uc;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-287-\tint ret;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-288-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:289:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-290-\t\t\t\t RTL8365MB_TABLE_OP_READ, addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-295-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:296:\trtl8365mb_l2_data_to_uc(data, \u0026uc);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-297-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-304-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:305:int rtl8365mb_l2_add_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-306-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-309-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:310:\tstruct rtl8365mb_l2_uc uc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-311-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-328-\tuc.age = 1;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:329:\trtl8365mb_l2_uc_to_data(\u0026uc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-330-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-331-\t/* add the new entry or update an existing one */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:332:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-333-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-344-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:345:int rtl8365mb_l2_del_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-346-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-349-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:350:\tstruct rtl8365mb_l2_uc uc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-351-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-360-\tuc.age = 0;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:361:\trtl8365mb_l2_uc_to_data(\u0026uc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-362-\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-367-\t */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:368:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-369-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-383-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:384:int rtl8365mb_l2_flush(struct realtek_priv *priv, int port, u16 vid)\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-385-{\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-448-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:449:int rtl8365mb_l2_add_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-450-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-453-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:454:\tstruct rtl8365mb_l2_mc mc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-455-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-465-\tmc.is_static = 1;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:466:\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-467-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-468-\t/* First look for an existing entry (to get existing port members) */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:469:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-470-\t\t\t\t RTL8365MB_TABLE_OP_READ, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-474-\t\t/* There is already an entry... */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:475:\t\trtl8365mb_l2_data_to_mc(data, \u0026mc);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-476-\t\tdev_dbg(priv-\u003edev,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-489-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:490:\t\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-491-\t} else if (ret == -ENOENT) {\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-507-\t/* add the new entry or update an existing one */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:508:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-509-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-519-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:520:int rtl8365mb_l2_del_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-521-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-524-\tu16 data[RTL8365MB_L2_ENTRY_SIZE] = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:525:\tstruct rtl8365mb_l2_mc mc = { 0 };\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-526-\tu16 addr;\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-531-\tmc.key.ivl = true;\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:532:\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-533-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-534-\t/* First look for an existing entry (to get existing port members) */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:535:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-536-\t\t\t\t RTL8365MB_TABLE_OP_READ, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-549-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:550:\trtl8365mb_l2_data_to_mc(data, \u0026mc);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-551-\tdev_dbg(priv-\u003edev,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-567-\t}\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:568:\trtl8365mb_l2_mc_to_data(\u0026mc, data);\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-569-\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-570-\t/* update the existing entry. */\ndrivers/net/dsa/realtek/rtl8365mb_l2.c:571:\tret = rtl8365mb_table_query(priv, RTL8365MB_TABLE_L2,\ndrivers/net/dsa/realtek/rtl8365mb_l2.c-572-\t\t\t\t RTL8365MB_TABLE_OP_WRITE, \u0026addr,\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-1-/* SPDX-License-Identifier: GPL-2.0 */\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:2:/* Forwarding and multicast database interface for the rtl8365mb switch family\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-3- *\n--\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-14-\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:15:int rtl8365mb_l2_get_next_uc(struct realtek_priv *priv, u16 *addr, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-16-\t\t\t struct realtek_fdb_entry *entry);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:17:int rtl8365mb_l2_add_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-18-\t\t\tconst unsigned char addr[static ETH_ALEN],\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-19-\t\t\tu16 efid, u16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:20:int rtl8365mb_l2_del_uc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-21-\t\t\tconst unsigned char addr[static ETH_ALEN],\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-22-\t\t\tu16 efid, u16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:23:int rtl8365mb_l2_flush(struct realtek_priv *priv, int port, u16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-24-\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:25:int rtl8365mb_l2_add_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-26-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-27-\t\t\tu16 vid);\ndrivers/net/dsa/realtek/rtl8365mb_l2.h:28:int rtl8365mb_l2_del_mc(struct realtek_priv *priv, int port,\ndrivers/net/dsa/realtek/rtl8365mb_l2.h-29-\t\t\tconst unsigned char mac_addr[static ETH_ALEN],\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-64- * require the rtl8367d vendor driver. With all this uncertainty, the driver has\ndrivers/net/dsa/realtek/rtl8365mb_main.c:65: * been modestly named rtl8365mb. Future implementors may wish to rename things\ndrivers/net/dsa/realtek/rtl8365mb_main.c-66- * accordingly.\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-96- * configuration and the SerDes, so the code paths specific to it are selected\ndrivers/net/dsa/realtek/rtl8365mb_main.c:97: * with rtl8365mb_get_family().\ndrivers/net/dsa/realtek/rtl8365mb_main.c-98- */\n--\ndrivers/net/dsa/realtek/rtl8365mb_main.c-117-#include \"rtl83xx.h\"\n\n"
} |
| 21/2 | 2026/10/10 20:15 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 63858 output: 133 thoughts: 1563 Thoughts: **Analysis of Realtek RTL8367S-VB Switch Driver for Fuzzing** Okay, let's break this down. First, I need to understand if this new code is reachable in a fuzzing environment. My initial thought is to check DSA drivers and how Syzkaller tests network drivers. The `dsa_loop.c` mock driver is useful for DSA, but this looks different. The `rtl8365mb` driver is specific to Realtek switch ASICs (RTL8365MB, etc.). Embedded switches, found in routers and such. Communication via MDIO or SMI. Can they be emulated in standard QEMU or GCE on amd64? Nope. Definitely not. The probe requires Device Tree bindings and attempts to read a physical chip ID. If the chip isn't there, the probe fails, or doesn't even get called. Now, let's revisit the "WHEN TO RETURN WorthFuzzing=false" instructions in the documentation. We need to be strict. This code needs to fall *strictly* into a negative category. It looks like "Structurally unreachable hardware" applies here: vendor-specific PCIe switches, etc., requiring physical hardware not emulated in standard QEMU. Also, "Non-executable documentation changes" applies. Let's verify the files in the patch: 1. `Documentation/devicetree/bindings/net/dsa/realtek.yaml` - Documentation, non-executable. 2. `drivers/net/dsa/realtek/rtl8365mb.h` - Header declaration. 3. `drivers/net/dsa/realtek/rtl8365mb_main.c` - RTL8367S-VB support, the main code. 4. `drivers/net/dsa/realtek/rtl8365mb_vlan.c` - VLAN operations. The C code is all in `drivers/net/dsa/realtek/`. It's a Realtek switch ASIC driver. It requires the physical hardware via MDIO/SMI defined in the Device Tree. QEMU and GCE don't emulate these switches. Therefore, unreachable. No doubt about it. Let's make sure there is no other path. Can userspace or Syzkaller reach it? The driver registers with the DSA core after probe: `rtl83xx_probe()` -> `rtl83xx_register_switch()` -> `priv->ops->detect(priv)` -> `rtl8365mb_detect()` -> reads the chip ID. Without the hardware, `detect()` fails or the probe isn't called, no DSA switch, no network interfaces, no operations ever happen. The code is structurally unreachable. Therefore, `WorthFuzzing` must be false. Let's prepare the arguments for `set-results`: - `WorthFuzzing`: false - `Reasoning`: The patch series adds support for the Realtek RTL8367S-VB switch (family D) within the Realtek RTL8365MB DSA switch driver (`drivers/net/dsa/realtek/`). This driver controls a physical Ethernet switch ASIC accessed via MDIO or GPIO SMI based on Device Tree definitions. The hardware is not emulated in standard virtualized fuzzing environments (QEMU/GCE), making the modified code structurally unreachable. - `FocusSymbols`: [] - `EnableConfigs`: [] Empty arrays are fine for `FocusSymbols` and `EnableConfigs` when `WorthFuzzing=false`. Time to call `set-results`. |
| 22/2 | 2026/10/10 20:16 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch series adds support for the Realtek RTL8367S-VB Ethernet switch (family D) to the Realtek RTL8365MB DSA switch driver (drivers/net/dsa/realtek/). This driver requires a physical Realtek switch ASIC controlled via MDIO or SMI (GPIO bitbang) and instantiated through Device Tree. Because the hardware is not emulated in standard virtualized fuzzing environments (QEMU or GCE), the modified code is structurally unreachable.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch series adds support for the Realtek RTL8367S-VB Ethernet switch (family D) to the Realtek RTL8365MB DSA switch driver (drivers/net/dsa/realtek/). This driver requires a physical Realtek switch ASIC controlled via MDIO or SMI (GPIO bitbang) and instantiated through Device Tree. Because the hardware is not emulated in standard virtualized fuzzing environments (QEMU or GCE), the modified code is structurally unreachable.",
"WorthFuzzing": false
} |
| 23/1 | 2026/10/10 20:16 | action | If |
0mArgs:{
"WorthFuzzing": false
}Results: null |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|