net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB
Subsystems (5)
A message that is not in the archive (sent off-list or not yet received): [email protected]
v5 cover net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB
This series adds support for the RTL8367S-VB (chip ID 0x6642) to the rtl8365mb driver. The chip belongs to a new "family D" that differs from the existing family C in its VLAN table layout, speed/RGMII configuration and SerDes (SDS13) handling.
Patch 1 documents the chip in the devicetree binding. Patch 2 adds the chip family infrastructure (no functional change). Patches 3-4 add port speed and RGMII mode configuration for family D. Patches 5-6 add VLAN 4k table access and raw-VID PVID handling. Patches 7-8 add SDS13 PCS support and re-latching of the SerDes. Patch 9 adds the RTL8367S-VB chip table entry. It comes last, so that no intermediate commit exposes a family D chip with incomplete handling and the series stays bisectable.
Family C's functional behaviour is unchanged. The only change in a shared path is a mutex serializing SerDes register access, added in patch 8. The port count is capped at 8 for family D only (patch 9).
Tested on a TP-Link Archer AX55 v1 (RTL8367S-VB, CPU port over HSGMII to an IPQ5018) with bridge VLAN filtering and per-port PVIDs. SGMII has also been seen working, but I no longer have the exact link partner and speed it was tested with, so treat it as lightly tested. RGMII mode has not yet been tested.
---
v5:
- 1/9: fix the subject
- 4/9: refuse RGMII on EXT1 with -EBUSY when it is owned by MAC4, before touching any EXT1 register
- 5/9: drop the unverified rationale for forcing SVLAN_CHK_IVL_SVL, say that the vendor API leaves it at 0, and note that the family D paths are not reachable until the last patch
- 6/9: init prev_accepted_frame to avoid a maybe-uninitialized warning
- 7/9: comment the write of the whole RX disable field, as in the vendor sequence; fix two comments that still credit pcs_link_up() on family D
- 8/9: cancel the re-latch work from a reboot notifier instead of checking the driver data; fix the RESTORE_TRIES comment and do not sleep after the last failed restore attempt
- 9/9: fix the description of the external interface indices. The v4 changelog said that only HSGMII is exposed; that was wrong, SGMII is still exposed
v4: https://lore.kernel.org/netdev/[email protected]/
- 1/9: reword the commit message (support is added by the series)
- 3/9: document the per-port force enable register
- 5/9: document both forced IVL bits, update stale comments
- 6/9: clear the family D PVID registers at setup
- 7/9: do not override the forced SGMII speed in pcs_get_state(), update stale comments, note that the patch is preparatory
- 8/9: remember a failed restore and retry it first; stop the work after shutdown (driver data cleared)
- 9/9: expose HSGMII only on the SerDes port, update the SerDes interface comment
v3: https://lore.kernel.org/netdev/[email protected]/
- add a dt-bindings patch (1/9): RTL8367S-VB listed under
realtek,rtl8365mb
- add chip family infrastructure as its own patch (2/9), no functional change
- squash the family D PVID getter and the PVID set/clear patches into one (6/9), so the read and write paths use the same register layout at every point of the series
- add the RTL8367S-VB chip table entry last (9/9), after the family D speed, RGMII, VLAN and PCS support, so no intermediate commit can reach the chip with incomplete handling (reported by the automated review)
- 6/9: fix the commit message (port p's write lands in port p >> 1) and update the stale kernel-doc and file comments
- 8/9: start the re-latch work only for 2500base-x, cancel it from .pcs_disable, from pcs_config() and via a devres action; retry the SDS_MISC restore and come back soon if it fails; rewrite the commit message to match the code (reported by the automated review)
- 9/9: document family D in the file header comment and in the learn limit comment (limit confirmed against the Realtek vendor API)
v2: https://lore.kernel.org/netdev/[email protected]/
- 2/8: mask r_speed to the width of the FORCE_SPEED field before passing it to FIELD_PREP(), so that the family D 2500M value (5) cannot trip the compile-time range check; bit 2 still goes to FORCE_SPEED2 (reported by the automated review).
- 4/8: the commit message now explains why EXT_TXC_DLY[5:3] is cleared for RGMII on EXT1: the vendor RGMII setup does it, and the init jam table leaves the field at 2, which would add an extra TX delay on top of tx-internal-delay-ps. Add a comment describing the EXT_TXC_DLY layout (Andrew Lunn's review).
- 8/8: document the new struct rtl8365mb members in the kernel-doc comment (sds_lock, sds_relatch, sds_relatch_count, sds_misc_target_val), which fixes the kernel-doc warnings.
- 1/8, 3/8, 5/8, 6/8, 7/8: no changes.
v1: https://lore.kernel.org/netdev/[email protected]/
Mieczyslaw Nalewaj (9):
dt-bindings: net: dsa: realtek: add RTL8367S-VB
net: dsa: realtek: rtl8365mb: add chip family infrastructure
net: dsa: realtek: rtl8365mb: set speed for family D
net: dsa: realtek: rtl8365mb: set RGMII mode for family D
net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D
net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
net: dsa: realtek: rtl8365mb: re-latch the family D SerDes
net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB
.../devicetree/bindings/net/dsa/realtek.yaml | 2 +- drivers/net/dsa/realtek/rtl8365mb.h | 14 + drivers/net/dsa/realtek/rtl8365mb_main.c | 741 ++++++++++++++++-- drivers/net/dsa/realtek/rtl8365mb_vlan.c | 380 +++++++-- drivers/net/dsa/realtek/rtl8365mb_vlan.h | 1 + 5 files changed, 998 insertions(+), 140 deletions(-) create mode 100644 drivers/net/dsa/realtek/rtl8365mb.h
Signature · 1 line
2.53.0
PATCH v5 1/9 dt-bindings: net: dsa: realtek: add RTL8367S-VB
The RTL8367S-VB (chip ID 0x6642) is supported by the rtl8365mb driver with the changes that follow in this series. It is identified by its chip ID register, so it does not need a compatible string of its own. List it under realtek,rtl8365mb.
--- Documentation/devicetree/bindings/net/dsa/realtek.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/net/dsa/realtek.yaml +1 -1
@@ -43,7 +43,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
Signature · 1 line
2.53.0
PATCH v5 2/9 net: dsa: realtek: rtl8365mb: add chip family infrastructure
In reply to Mieczyslaw NalewajAdd enum rtl8365mb_family and a family member to struct rtl8365mb_chip_info, together with rtl8365mb_get_family() declared in a new rtl8365mb.h so that the VLAN code can use it too. Tag all existing chips as RTL8365MB_FAMILY_C.
RTL8365MB_FAMILY_D is defined here but no chip uses it yet; it is needed by the following patches, which add family D handling for chips whose register layout differs from the existing ones.
No functional change.
--- drivers/net/dsa/realtek/rtl8365mb.h | 14 ++++++++++++++ drivers/net/dsa/realtek/rtl8365mb_main.c | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 drivers/net/dsa/realtek/rtl8365mb.h
drivers/net/dsa/realtek/rtl8365mb.h new file +14 -0
@@ -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 */
drivers/net/dsa/realtek/rtl8365mb_main.c +14 -0
@@ -110,6 +110,7 @@#include "rtl83xx.h" #include "rtl8365mb_l2.h" #include "rtl8365mb_vlan.h" +#include "rtl8365mb.h" /* Family-specific data and limits */ #define RTL8365MB_PHYADDRMAX 7
@@ -707,6 +708,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 +721,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 +734,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 +746,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 +759,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 +774,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) },
@@ -874,6 +881,13 @@ struct rtl8365mb {#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;
Signature · 1 line
2.53.0
Re: [PATCH net-next v5 2/9] net: dsa: realtek: rtl8365mb: add chip family infrastructure
Quoted 5 lines · Mieczyslaw Nalewaj
Add enum
rtl8365mb_familyand a family member to structrtl8365mb_chip_info, together withrtl8365mb_get_family()declared in a newrtl8365mb.hso that the VLAN code can use it too. Tag all existing chips asRTL8365MB_FAMILY_C.
Quoted 7 lines
RTL8365MB_FAMILY_Dis defined here but no chip uses it yet; it is needed by the following patches, which add family D handling for chips whose register layout differs from the existing ones.No functional change.
Signed-off-by Mieczyslaw Nalewaj <[email protected]>
Makes sense.
Yours,
Linus Walleij
PATCH v5 3/9 net: dsa: realtek: rtl8365mb: set speed for family D
In reply to Mieczyslaw NalewajOn family C hardware, forcing a 2.5 Gbps link speed requires relying strictly on the HSGMII SerDes configuration block, while forcing a dummy 1 Gbps value inside the standard digital interface register. Family D introduces a dedicated hardware link speed value (5) for 2500M. The speed bitfield width has been expanded to 3 bits, splitting the most significant bit into a new separate register field (FORCE_SPEED2), which maps directly to a distinct per-port digital interface force layout.
On family D the forced-mode configuration (link, duplex, pause, speed) is written to a per-port register at 0x12c0 + port instead of the per-extint register. The bit positions of TXPAUSE, RXPAUSE, LINK, DUPLEX and the low two speed bits are the same as on family C; the upper speed bits go to bits 13:12 (FORCE_SPEED2), so FORCE_EN (bit 12 on family C) is not set. A second per-port register at 0x12c8 + port enables the forced mode: the vendor RTL8367D API writes 0xFFFF there when the MAC is forced and 0 otherwise. This driver always forces the MAC, as on family C, so it writes 0xFFFF on every call, including link down.
--- drivers/net/dsa/realtek/rtl8365mb_main.c | 82 ++++++++++++++++++++---- 1 file changed, 69 insertions(+), 13 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +69 -13
@@ -344,6 +344,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 */
@@ -361,6 +362,28 @@#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)) + +/* Per-port force-mode enable. The vendor RTL8367D API +* (dal_rtl8367d_port_macForceLink_set()) treats it as an on/off switch for +* the whole forced configuration: all bits set when the MAC is forced, zero +* when it is not. The meaning of the individual bits is not documented. +* This driver always forces the MAC, as on family C, so all bits are set +* on every call, including link down. +*/ +#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
@@ -1646,23 +1669,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 ;
@@ -1692,20 +1724,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 ; }
Signature · 1 line
2.53.0
PATCH v5 4/9 net: dsa: realtek: rtl8365mb: set RGMII mode for family D
In reply to Mieczyslaw NalewajOn family D, RGMII on extension interface 1 needs two things that the other families do not: the EXT1 RGMII TX clock delay field in EXT_TXC_DLY (0x13f9, bits [5:3]) must be cleared, and the pin mux in the top-level configuration register must be set up.
The vendor RGMII setup for EXT1 clears the RGMII field of EXT_TXC_DLY (0x13f9, bits [5:3]) in addition to programming TXDELAY in RGMXF. Do the same. The init jam table writes 0x0090 to this register, which leaves the field at 2, so without the clear an extra TX delay would be applied on top of tx-internal-delay-ps. Clearing it makes tx-internal-delay-ps the only source of TX delay.
If the internal MAC4 block occupies extension 1, refuse the RGMII configuration with -EBUSY before any EXT1 register is touched. Otherwise bind the RGMII/MII pins to MAC7. SerDes 1, which shares the pins, is always disabled.
The family D branch is not reachable until the chip table entry is added in the last patch.
--- drivers/net/dsa/realtek/rtl8365mb_main.c | 60 ++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
drivers/net/dsa/realtek/rtl8365mb_main.c +60 -0
@@ -332,6 +332,12 @@#define RTL8365MB_SDS_OPTION_ARM_KEY 0x0249#define RTL8365MB_SDS_OPTION_REG 0x13C1 +#define RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK GENMASK(4, 0) +/* 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
@@ -465,6 +471,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
@@ -1201,12 +1221,26 @@ 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;if (!extint)return -ENODEV ; +/* On family D the EXT1 pins are shared with MAC4 (UTP port 4). If +* MAC4 owns them, RGMII on this port cannot work, so do not touch +* any EXT1 register. +*/ +if (rtl8365mb_get_family (priv) ==RTL8365MB_FAMILY_D && + extint->id ==1 ) { + ret =regmap_read (priv->map,RTL8365MB_D_REG_TOP_CON0 , &data); +if (ret) +return ret; +if (data &RTL8365MB_D_MAC4_SEL_EXT1_MASK ) +return -EBUSY ; + } + dp =dsa_to_port (ds, port); dn = dp->dn;
@@ -1270,6 +1304,32 @@ 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; + +/* Bind the RGMII/MII pins to MAC7; MAC4 does not own them, +* see the check at the top of the function. +*/ + 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 ; }
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net-next v5 4/9] net: dsa: realtek: rtl8365mb: set RGMII mode for family D
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] On family D, rtl8365mb_ext_config_rgmii() reads TOP_CON0 and returns -EBUSY for extint id 1 when RTL8365MB_D_MAC4_SEL_EXT1_MASK…
- [Low] The concern: in rtl8365mb_ext_config_rgmii(), family D EXT1 is switched to RGMII in DIGITAL_INTERFACE_SELECT before EXT_TXC_DLY[5:3]…
--
net: dsa: realtek: rtl8365mb: set RGMII mode for family D
On family D, this commit clears the EXT1 RGMII TX clock delay field in EXT_TXC_DLY and binds the RGMII/MII pins to MAC7 in TOP_CON0. It also disables SerDes 1 when RGMII is configured on extension interface 1. If MAC4 already owns extension 1, it returns -EBUSY before touching any EXT1 register.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0
[ ... ]
Quoted 13 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +3
-0@@ -1201,12 +1221,26 @@ 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;if (!extint)return -ENODEV ; +/* On family D the EXT1 pins are shared with MAC4 (UTP port 4). If +* MAC4 owns them, RGMII on this port cannot work, so do not touch
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port, · line 1242
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +10
-0+* any EXT1 register. +*/ +if (rtl8365mb_get_family (priv) ==RTL8365MB_FAMILY_D && + extint->id ==1 ) { + ret =regmap_read (priv->map,RTL8365MB_D_REG_TOP_CON0 , &data); +if (ret) +return ret; +if (data &RTL8365MB_D_MAC4_SEL_EXT1_MASK ) +return -EBUSY ; + }
[Severity: Medium]
Is the RGMII configuration actually refused here? The commit message says:
"If the internal MAC4 block occupies extension 1, refuse the RGMII configuration with -EBUSY before any EXT1 register is touched."
The only caller is the void phylink callback rtl8365mb_phylink_mac_config(), which just logs the error and returns:
if (phy_interface_mode_is_rgmii(state->interface)) {
ret = rtl8365mb_ext_config_rgmii(priv, port, state->interface);
if (ret)
dev_err(priv->dev,
"failed to configure RGMII mode on port %d: %pe\n",
port, ERR_PTR(ret));The driver has no mac_prepare or mac_finish, and mac_select_pcs returns NULL for RGMII. So phylink never sets major_config_failed, and phylink_resolve() goes on to bring the link up:
phylink_resolve()->phylink_link_up()->rtl8365mb_phylink_mac_link_up()
rtl8365mb_phylink_mac_link_up() then forces the port up for any RGMII interface without checking TOP_CON0 again:
if (phy_interface_mode_is_rgmii(interface) ||
rtl8365mb_interface_is_serdes(interface)) {
ret = rtl8365mb_ext_config_forcemode(priv, port, true, speed,
duplex, tx_pause,
rx_pause);On family D, rtl8365mb_ext_config_forcemode() writes RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG(port) with link set. It also sets RTL8365MB_D_DIGITAL_INTERFACE_FORCE_REG_EN(port) to RTL8365MB_D_DIGITAL_INTERFACE_FORCE_EN_ALL_MASK.
Take an RTL8367S-VB with extint {7, 1, RGMII}, where TOP_CON0 bit 12 is set and DT describes port 7 as an RGMII fixed-link CPU port. Wouldn't phylink and DSA report port 7 as configured and link-up while its traffic is silently lost? The only sign would be the dev_err(), repeated on every major reconfiguration.
The check does stop MAC7_SEL_EXT1 from being written, so MAC4 keeps its pins. Would it be better to return the error through a hook phylink honours, such as mac_prepare? Another option is to leave RGMII out of supported_interfaces in rtl8365mb_phylink_get_caps() when TOP_CON0 bit 12 is set. At a minimum, the force in mac_link_up could be skipped.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +1
-0+ dp =dsa_to_port (ds, port); dn = dp->dn;
[ ... ]
Quoted 19 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +15
-0@@ -1270,6 +1304,32 @@ 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; + +/* Bind the RGMII/MII pins to MAC7; MAC4 does not own them, +* see the check at the top of the function. +*/ + ret =regmap_update_bits (priv->map, +RTL8365MB_D_REG_TOP_CON0 , +RTL8365MB_D_MAC7_SEL_EXT1_MASK , +RTL8365MB_D_MAC7_SEL_EXT1_MASK );
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port, · line 1331
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +10
-0+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; + }
[Severity: Low]
This is a minor question about ordering. EXT1 is switched to RGMII in RTL8365MB_DIGITAL_INTERFACE_SELECT_REG() just above this block. Only after that does the code clear EXT_TXC_DLY[5:3], set MAC7_SEL_EXT1 in TOP_CON0, and disable SerDes 1 in SDS1_MISC0.
phylink only calls mac_config with the link down, so no traffic should cross the pins during this window. The existing comment's constraint (delays programmed before the forcing in mac_link_up) also holds.
Does the vendor sequence set the pin mux and disable SerDes 1 before selecting RGMII mode? If one of these regmap writes fails partway through, the shared EXT1 pins are left half-configured and nothing rolls them back. Is that acceptable here?
Quoted 3 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0return 0 ; }
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/aa5fa12c-e43e-4e5e-9f77-c6eaf477abc4%40yahoo.com
PATCH v5 5/9 net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
In reply to Mieczyslaw NalewajThe hardware structure of 4K VLAN table entries has changed between silicon families. Family D's CVLAN entry is two 16-bit words rather than three: there is no third word extending member/untag past bit 7, and no priority/meter fields at all. The FID field is restricted to a narrower 2-bit width. The chip itself supports both IVL and SVL, but this driver always requests IVL for VLAN 4K entries (rtl8365mb_vlan_4k_port_set() sets ivl_en = true on both families), so both the IVL_EN (bit 3) and SVLAN_CHK_IVL_SVL (bit 2) controls are forced to 1 here. The vendor RTL8367D CVLAN API leaves SVLAN_CHK_IVL_SVL at 0 and only sets it from the SVLAN member API; the value 1 has not been verified against the hardware with the bit cleared. vlan4k->ivl_en is still read back from IVL_EN.
Reusing the three-word family C layout unconditionally means the third word is read from and written back to the register that holds it on family C, but does not exist as a distinct table word on family D's die; whatever data happens to be there gets folded into member/untag bits [10:8] on read, and re-written on every read-modify-write cycle in rtl8365mb_vlan_4k_port_set(). Give family D its own two-word pack/unpack instead.
The two-word layout matches the vendor switch API for this chip family, which writes only 0x0510/0x0511 for a CVLAN entry.
The family D paths are not reachable until the RTL8367S-VB chip table entry is added in the last patch of the series.
--- drivers/net/dsa/realtek/rtl8365mb_vlan.c | 175 ++++++++++++++++------- 1 file changed, 123 insertions(+), 52 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_vlan.c +123 -52
@@ -33,7 +33,9 @@* 1. VLAN4k entries can specify whether to use Independent or Shared VLAN * Learning (IVL or SVL respectively). VLAN membership config entries * cannot. This underscores the fact that VLAN membership configs are not -* involved in the learning process of the ASIC. +* involved in the learning process of the ASIC. (The driver honors this +* selection on family C only; on family D it always forces IVL, see +* rtl8365mb_vlan_4k_write().) * * 2. VLAN membership config entries use an "enhanced VLAN ID" (efid), which has * a range 0~8191 compared with the standard 0~4095 range of the VLAN4k
@@ -48,12 +50,16 @@#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] */ +/* CVLAN (i.e. VLAN4k) table entry layout: u16[3] on family C, u16[2] on +* family D +*/ #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,11 @@#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) +/* Family D CVLAN entry, word 1 (family D has no word 2) */ +#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)
@@ -132,7 +143,8 @@* @priority: priority classification (unused) * @priority_en: enable priority (unused) * @policing_en: enable policing (unused) -* @ivl_en: enable IVL instead of default SVL +* @ivl_en: enable IVL instead of default SVL (family D always forces IVL +* on write, see rtl8365mb_vlan_4k_write()) * @meteridx: metering index (unused) * * This structure is used to get/set entries in the VLAN4k table. The
@@ -185,13 +197,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 +214,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 +276,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 +290,61 @@ 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. +* The vendor CVLAN API leaves SVLAN_CHK_IVL_SVL at 0, see the +* commit message. +*/ + 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
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net-next v5 5/9] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] On family D, rtl8365mb_vlan_4k_write() (drivers/net/dsa/realtek/rtl8365mb_vlan.c) sets…
--
net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
This commit gives family D its own two-word pack/unpack for CVLAN (VLAN 4K) table entries, instead of reusing the three-word family C layout. It uses a narrower 2-bit FID and drops the priority/meter fields. On write, it forces both the IVL_EN and SVLAN_CHK_IVL_SVL bits to 1.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +0
-0
[ ... ]
Quoted 5 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +0
-1@@ -244,36 +290,61 @@ 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);
[ ... ]
drivers/net/dsa/realtek/rtl8365mb_vlan.c static int rtl8365mb_vlan_4k_write(struct realtek_priv *priv, · line 304
Quoted 12 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +12
-0+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. +* The vendor CVLAN API leaves SVLAN_CHK_IVL_SVL at 0, see the +* commit message. +*/ + 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 );
[Severity: Medium]
Should SVLAN_CHK_IVL_SVL be written as 1 in rtl8365mb_vlan_4k_write() on family D?
The commit message says:
The vendor RTL8367D CVLAN API leaves SVLAN_CHK_IVL_SVL
at 0 and only sets it from the SVLAN member API; the value 1 has not been verified against the hardware with the bit cleared.
The reason given for forcing both bits is that the only caller always asks for IVL:
drivers/net/dsa/realtek/rtl8365mb_vlan.c:rtl8365mb_vlan_4k_port_set() {
...
vlan4k.ivl_en = true; /* always use Independent VLAN Learning */
...
}That explains IVL_EN = 1, but does it explain the SVLAN bit? The vendor ties that bit to SVLAN membership. This driver never configures SVLAN, and RTL8365MB_D_CVLAN_ENTRY_D1_SVLAN_CHK_IVL_SVL_MASK is the only SVLAN-related symbol under drivers/net/dsa/realtek/.
Even so, every bridge VLAN add or delete on a family D port sets the bit to 1:
rtl8365mb_vlan_4k_port_add()/rtl8365mb_vlan_4k_port_del()
-> rtl8365mb_vlan_4k_port_set()
-> rtl8365mb_vlan_4k_write()
This also covers entries whose member set becomes empty after the last port is removed.
rtl8365mb_vlan_4k_read() never decodes this bit, so the read-modify-write in rtl8365mb_vlan_4k_port_set() can't preserve whatever value the hardware had.
If the bit has any effect, for example on how S-tagged traffic follows this CVLAN entry's IVL/SVL setting, could learning or forwarding for matching VIDs differ from what the vendor code produces?
Would it be safer to follow the vendor CVLAN path here? That would mean writing SVLAN_CHK_IVL_SVL as 0 and deriving IVL_EN from vlan4k->ivl_en.
A related point about IVL_EN: on family D, rtl8365mb_vlan_4k_write() ignores vlan4k->ivl_en, but rtl8365mb_vlan_4k_read() decodes it:
drivers/net/dsa/realtek/rtl8365mb_vlan.c static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid, · line 245
Quoted 3 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +3
-0+ vlan4k->ivl_en = +FIELD_GET (RTL8365MB_D_CVLAN_ENTRY_D1_IVL_EN_MASK , + data[1 ]);
That asymmetry only does no harm because the single caller sets ivl_en = true.
The code is unchanged at the end of the series, so this behavior ships with the RTL8367S-VB enablement in "net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB".
Quoted 2 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +2
-0+ data[1 ] |=FIELD_PREP (RTL8365MB_D_CVLAN_ENTRY_D1_FID_MASK , + vlan4k->fid);
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/aa5fa12c-e43e-4e5e-9f77-c6eaf477abc4%40yahoo.com
PATCH v5 6/9 net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D
In reply to Mieczyslaw NalewajFamily D has no working VLAN member config (MC) table. Its PVID is a raw 12-bit VID in a per-port register at 0x0700 + port, whereas family C stores a 5-bit MC table index, two ports per register, at 0x0700 + (port >> 1).
Running the family C code on family D therefore reads an MC table that does not exist, and writes an MC index into the VID register of port (port >> 1) instead of the one of the port being configured.
Read the PVID straight from its register in rtl8365mb_vlan_port_get_pvid(), and make rtl8365mb_vlan_pvid_port_set() and rtl8365mb_vlan_pvid_port_clear() use direct-VID variants on family D that skip the MC table. They keep the family C frame filter handling and rollback on error.
Also clear the family D PVID registers when the VLAN support is set up. Unlike on family C, where VLANMC index 0 is the neutral PVID, the register holds a raw VID, and after a reset it keeps its hardware (or EEPROM) default. Without clearing it an unconfigured port could report a stale PVID from rtl8365mb_vlan_port_get_pvid(), and rtl8365mb_port_vlan_filtering() would accept untagged frames into it.
No functional change for family C.
--- drivers/net/dsa/realtek/rtl8365mb_main.c | 8 + drivers/net/dsa/realtek/rtl8365mb_vlan.c | 205 ++++++++++++++++++++++- drivers/net/dsa/realtek/rtl8365mb_vlan.h | 1 + 3 files changed, 209 insertions(+), 5 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +8 -0
@@ -2352,6 +2352,14 @@ static int rtl8365mb_vlan_setup(struct dsa_switch *ds)int ret;dsa_switch_for_each_available_port (dp, ds) { +/* Start every port with the neutral PVID */ + ret =rtl8365mb_vlan_port_reset_pvid (priv, dp->index); +if (ret) { +dev_err (priv->dev, +"Failed to reset PVID on port %d\n" , + dp->index); +return ret; + }/* Disable vlan-filtering for all ports */ ret =rtl8365mb_port_vlan_filtering (ds, dp->index, false,NULL );if (ret) {
drivers/net/dsa/realtek/rtl8365mb_vlan.c +200 -5
269 lines not on this page · raw message
drivers/net/dsa/realtek/rtl8365mb_vlan.h +1 -0
@@ -20,6 +20,7 @@ enum rtl8365mb_frame_ingress {int rtl8365mb_vlan_port_get_pvid (struct realtek_priv *priv,int port,u16 *pvid); +int rtl8365mb_vlan_port_reset_pvid (struct realtek_priv *priv,int port); int rtl8365mb_vlan_port_get_framefilter(struct realtek_priv *priv, int port,
Signature · 1 line
2.53.0
PATCH v5 7/9 net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
In reply to Mieczyslaw NalewajExtend the existing RTL8367S SGMII/HSGMII PCS implementation in this driver for family D switches, whose CPU SerDes is reached through the indexed SDS13 window and whose SDS_MISC fields differ from family C.
The register sequence and tuning tables are derived from the GPL-licensed Realtek RTL8367D port API distributed in the Mercusys MR80X GPL release. Keep the existing family C path unchanged and select the new behavior from the driver's chip-family metadata, making the implementation reusable by other family D boards.
This patch only prepares the family D paths; they become reachable when the RTL8367S-VB chip entry is added in the last patch.
--- drivers/net/dsa/realtek/rtl8365mb_main.c | 238 +++++++++++++++++------ 1 file changed, 182 insertions(+), 56 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +182 -56
@@ -262,7 +262,8 @@* interface, indexed by the external port number with port 5 (the first * external port) as the base. Other RTL8367 families index this register * differently (e.g. the RTL8367R uses (id + 1) % 2), so this mapping only -* holds for the RTL8367C-style parts this driver supports. +* holds for the RTL8367C-style parts and for family D, where it is the same +* (one bit per external port, base port 5), as in the vendor RTL8367D API. */ #define RTL8365MB_BYPASS_LINE_RATE_REG 0x03F7#define RTL8365MB_BYPASS_LINE_RATE_MASK (_port) BIT((_port) - 5)
@@ -284,6 +285,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
@@ -313,8 +315,10 @@#define RTL8365MB_SDS_REG_LINK_STATUS 0x003d#define RTL8365MB_SDS_LINK_STATUS_LINK_MASK BIT(4) -/* The embedded SerDes can only be muxed to external interface 1 (MAC8), -* which is port 6. +/* On family C the embedded SerDes can only be muxed to external interface +* 1 (MAC8), which is port 6. Family D has it on external interface 0 +* (MAC6), see RTL8365MB_D_SDS_EXT0_INDEX. RTL8365MB_SDS_EXT_INTERFACE_ID +* below is the family C id; the SerDes port is 6 on both families. */ #define RTL8365MB_SDS_EXT_INTERFACE_ID 1#define RTL8365MB_SDS_EXT_INTERFACE_PORT 6
@@ -332,7 +336,22 @@#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. */
@@ -720,6 +739,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),
@@ -1333,7 +1367,8 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,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) {int ret;
@@ -1351,10 +1386,13 @@ static int rtl8365mb_sds_write(struct realtek_priv *priv, u16 addr, u16 data)*/ return regmap_write (priv->map,RTL8365MB_SDS_INDACS_CMD_REG ,RTL8365MB_SDS_INDACS_CMD_RUN_MASK | -RTL8365MB_SDS_INDACS_CMD_WR_MASK ); +RTL8365MB_SDS_INDACS_CMD_WR_MASK | +FIELD_PREP (RTL8365MB_SDS_INDACS_CMD_INDEX_MASK , + index)); } -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) {u32 val;int ret;
@@ -1364,7 +1402,9 @@ static int rtl8365mb_sds_read(struct realtek_priv *priv, u16 addr, u16 *data)return ret; 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;
@@ -1404,6 +1444,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];
@@ -1482,28 +1530,47 @@ 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 ; +/* 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
@@ -1532,34 +1599,57 @@ 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) { +/* Bit 6 disables the RX of SDS0. As in the vendor RTL8367D +* sequence the whole 2-bit field (bits 7:6) is written, so +* bit 7 is cleared as well. +*/ + 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) { + 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;
@@ -1569,27 +1659,32 @@ 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;/* Keep SGMII in-band autonegotiation disabled: the link parameters are -* forced from rtl8365mb_pcs_link_up() instead. +* forced from rtl8365mb_pcs_link_up() instead (family C), or from +* mac_link_up() (family D). */ - 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); +return rtl8365mb_sds_write (priv, sds_index, +RTL8365MB_SDS_REG_NWAY , val); }static bool rtl8365mb_interface_is_serdes (phy_interface_t interface)
@@ -1614,18 +1709,27 @@ 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; -/* 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 + 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() on family C, and from +* mac_link_up() on family D. The real link state must still be read +* from the SerDes itself: the embedded DW8051 microcontroller that * the vendor firmware uses to poll the SerDes is kept disabled (see * 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 ;
@@ -1636,6 +1740,17 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,if (!state->link)return ; +if (is_d) { +/* Only 2500base-x is a fixed rate; for the other modes keep +* the speed and duplex phylink passed in. +*/ +if (state->interface ==PHY_INTERFACE_MODE_2500BASEX ) { + state->duplex =DUPLEX_FULL ; + state->speed =SPEED_2500 ; + } +return ; + } +/* The speed and duplex are forced; read them back from the values * programmed into the SerDes MISC register. */
@@ -1677,6 +1792,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.
@@ -1946,7 +2067,7 @@ static void rtl8365mb_phylink_mac_link_down(struct phylink_config *config,/* phylink has no pcs_link_down callback, so on the SerDes path only the * MAC external interface force is reset here. Clearing the MAC force is * enough to bring the link down; the SerDes keeps presenting its last -* forced state until the next pcs_link_up() reprograms it. +* forced state (family C) until the next pcs_link_up() reprograms it. */ if (phy_interface_mode_is_rgmii (interface) ||rtl8365mb_interface_is_serdes (interface)) {
@@ -1979,9 +2100,11 @@ static void rtl8365mb_phylink_mac_link_up(struct phylink_config *config, p = &mb->ports[port];schedule_delayed_work (&p->mib_work,0 ); -/* The SerDes forced link state is programmed by the PCS in +/* On family C the SerDes forced link state is programmed by the PCS in * rtl8365mb_pcs_link_up(); here only the MAC external interface force -* is configured, for both RGMII and SerDes. +* is configured. On family D pcs_link_up() does nothing, and the MAC +* external interface force is the only forced link state, for both +* RGMII and SerDes. */ if (phy_interface_mode_is_rgmii (interface) ||rtl8365mb_interface_is_serdes (interface)) {
@@ -1995,18 +2118,21 @@ static void rtl8365mb_phylink_mac_link_up(struct phylink_config *config,return ; } -/* The SerDes has its own pause enables; program them from -* the resolved pause modes, as the vendor driver does when -* forcing the link on a SerDes external interface. These -* bits, not the MAC force pause bits, gate pause on the -* SerDes external interface: flow control testing shows -* that pause frames are only emitted with the SerDes TXFC -* bit set, while the MAC force pause bits alone have no -* effect on this port. This is done here rather than in -* rtl8365mb_pcs_link_up() because pcs_link_up() carries no -* pause information. +/* Family C: the SerDes has its own pause enables; program +* them from the resolved pause modes, as the vendor driver +* does when forcing the link on a SerDes external +* interface. These bits, not the MAC force pause bits, gate +* pause on the SerDes external interface: flow control +* testing shows that pause frames are only emitted with the +* SerDes TXFC bit set, while the MAC force pause bits alone +* have no effect on this port. This is done here rather +* than in rtl8365mb_pcs_link_up() because pcs_link_up() +* carries no pause information. Family D does not use this +* path: its pause bits are set in the forced-mode register +* by rtl8365mb_ext_config_forcemode(). */ -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)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net-next v5 7/9] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] Consider family D port 6 in SGMII with managed = "in-band- status" and no PHY.
--
net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
This extends the rtl8365mb SGMII/HSGMII PCS code to family D switches. On those switches the CPU SerDes is reached through the indexed SDS13 window, and the SDS_MISC layout differs from family C. For family D, pcs_link_up() becomes a no-op and the link is forced only from mac_link_up().
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0
[ ... ]
Quoted 5 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +1
-0@@ -1636,6 +1740,17 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,if (!state->link)return ; +if (is_d) {
drivers/net/dsa/realtek/rtl8365mb_main.c static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs, · line 1753
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +10
-0+/* Only 2500base-x is a fixed rate; for the other modes keep +* the speed and duplex phylink passed in. +*/ +if (state->interface ==PHY_INTERFACE_MODE_2500BASEX ) { + state->duplex =DUPLEX_FULL ; + state->speed =SPEED_2500 ; + } +return ; + } +
[Severity: Medium]
On family D in SGMII mode with no PHY, can phylink pass SPEED_UNKNOWN to mac_link_up() here?
Take port 6 with phy-mode = "sgmii", managed = "in-band-status" and no phy-handle. rtl8365mb_pcs_inband_caps() only reports LINK_INBAND_DISABLE. That makes phylink_pcs_neg_mode() pick PHYLINK_PCS_NEG_OUTBAND, and since there is no phydev the mode stays MLO_AN_INBAND.
phylink_resolve() then gets the link state through phylink_mac_pcs_get_state(), which seeds speed and duplex like this:
drivers/net/phy/phylink.c:phylink_mac_pcs_get_state() {
...
} else {
state->speed = pl->link_config.speed;
state->duplex = pl->link_config.duplex;
...
}phylink_create() sets link_config.speed/duplex to SPEED_UNKNOWN and DUPLEX_UNKNOWN, and nothing updates them on this path.
When the SerDes reports link up, the family D branch above only overrides speed and duplex for 2500BASEX. For SGMII it returns with SPEED_UNKNOWN still set. The call chain would then be:
phylink_link_up()
rtl8365mb_phylink_mac_link_up()
rtl8365mb_ext_config_forcemode()
dev_err(..., "unsupported port speed %s\n", ...)
return -EINVALmac_link_up() returns void, so phylink still marks the link up and turns the carrier on. However, the family D MAC force register is never programmed, so wouldn't the port show link up and pass no traffic?
Family C avoids this because its pcs_get_state() reads speed and duplex back from SDS_MISC. This also seems to still be present at the end of the series.
Could the family D branch report a concrete speed and duplex for SGMII as well, or otherwise avoid returning link up with an unknown speed?
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/aa5fa12c-e43e-4e5e-9f77-c6eaf477abc4%40yahoo.com
PATCH v5 8/9 net: dsa: realtek: rtl8365mb: re-latch the family D SerDes
In reply to Mieczyslaw NalewajThe family D receiver latches on the DISABLE -> HSGMII edge in SDS_MISC rather than on the value, and it will not latch until the MAC at the other end of the trunk has brought its own half of the link up. If it does not latch, the trunk reports 2.5Gbps/Full on both sides but moves no frames: the CPU MAC transmits, the switch CPU port counts no octets, and there are no CRC, alignment or FIFO errors.
The two ends can be seconds apart, e.g. on an IPQ5018 board:
5.27 rtl8365mb: configuring for fixed/2500base-x <- pcs_config() 7.72 ipq5018-gmac-dwmac eth0: configuring for fixed/2500base-x 8.02 ipq5018-gmac-dwmac eth0: Link is Up - 2.5Gbps/Full 8.56 SerDes latches
pcs_config() runs seconds before the far-end MAC even starts configuring, so a single edge driven from there is not enough: the receiver has nothing to latch onto yet. Neither is pcs_link_up(), which is seconds early for the same reason. phylink does not help either - it never calls rtl8365mb_pcs_get_state() for this port in the first place, since mb->pcs.poll only arms phylink's own poll for in-band links, and this CPU port is a fixed link.
There is no local signal that predicts when the far-end MAC will bring up its half of the link (bit 8 of the SDS link-status word does not change ahead of it), so the work cannot wait for it; it can only tell afterwards, from the link-status bit, whether an edge took. Nothing external re-checks this later. So pcs_config() kicks off one attempt, and the work re-arms itself after each edge; the next run checks whether the edge took, rather than waiting on a poll that will not come.
Each attempt (park for 20 ms, then restore the target mode) is performed by a work item rather than from pcs_config(), because the attempts have to continue for seconds after pcs_config() has returned. pcs_config() re-runs cancel the work, so an attempt never interleaves with a reconfiguration. Before parking, the work reads the link status itself and does not park if the receiver has already latched, since the condition that queued it may be stale by the time it runs; it then ends the episode instead.
Attempts are spaced about 1 s apart and capped at RTL8365MB_D_SDS_RELATCH_MAX_TRIES (15) per fast episode. After the last attempt one more run checks whether it took and only then warns that the SerDes did not latch. The work then keeps driving one edge per RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL, so a far end that comes up late or a link that drops again is recovered without a reconfiguration, at a bounded cost of one 20 ms park per interval.
Once the receiver has latched, the work keeps checking the link every 10 s (RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL). If it finds the link down outside a reconfiguration, e.g. after the far end reset its PLL, it logs that and starts a new episode. An episode also starts at every pcs_config().
For family D, pcs_config() keeps the masked update of SDS_MISC and saves the value it wrote as the target the work restores. The work parks and restores with masked updates over the same fields, so other bits are never touched.
The work reads the SerDes link status through the SDS_INDACS indirect access window, a multi-register ADR/CMD/DATA sequence that the PCS callbacks also use, so those sequences are serialized by a new sds_lock. The SDS_MISC updates need no extra locking: each one is a single regmap read-modify-write.
The work is only started for 2500base-x, the mode the re-latch edge was observed with. It is cancelled from pcs_disable(), from pcs_config() before SDS_MISC is touched, from teardown(), from a reboot notifier and by a devres action, so that it never outlives the PCS or the driver data and does not touch the bus while it is shut down.
If restoring the target mode fails, the lane would stay parked. The mode field in SDS_MISC tells so, so the next run puts it back before doing anything else. dsa_switch_shutdown() does not stop the PCS, so the reboot notifier cancels the work before the devices are shut down; a devres action cancels it on unbind.
--- drivers/net/dsa/realtek/rtl8365mb_main.c | 320 +++++++++++++++++++++-- 1 file changed, 305 insertions(+), 15 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +305 -15
@@ -97,6 +97,8 @@#include <linux/irqdomain.h> #include <linux/mii.h> #include <linux/mutex.h> +#include <linux/workqueue.h> +#include <linux/reboot.h> #include <linux/of_irq.h> #include <linux/regmap.h> #include <linux/if_bridge.h>
@@ -299,6 +301,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 the write is +* attempted up to 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
@@ -938,10 +962,17 @@ 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_reboot_nb: cancels @sds_relatch before the devices are shut down +* @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. */
@@ -951,9 +982,14 @@ 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 notifier_block sds_reboot_nb; +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)
@@ -1370,43 +1406,53 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,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 | -FIELD_PREP (RTL8365MB_SDS_INDACS_CMD_INDEX_MASK , - index)); + 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,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 |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.
@@ -1416,15 +1462,19 @@ static int rtl8365mb_sds_read(struct realtek_priv *priv, u8 index, !(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
@@ -1546,6 +1596,13 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, 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 ) {if (is_d) {
@@ -1635,7 +1692,9 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,if (ret)return ret; -if (!is_d) { +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),
@@ -1683,8 +1742,187 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, val &= ~RTL8365MB_SDS_NWAY_EN_MASK ; val |=RTL8365MB_SDS_NWAY_RESTART_MASK ; -return rtl8365mb_sds_write (priv, sds_index, -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 ; +} + +/* Put SDS_MISC back to the target mode. The lane stays parked (mode field +* DISABLE) until this succeeds, so retry a few times before giving up until +* the next run. +*/ +static int rtl8365mb_sds_relatch_restore (struct rtl8365mb *mb) +{ +struct realtek_priv *priv = mb->priv; +int ret =0 ; +int i; + +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) +return 0 ; +if (i <RTL8365MB_D_SDS_RESTORE_TRIES -1 ) +usleep_range (1000 ,2000 ); + } + +dev_err_ratelimited (priv->dev,"failed to restore SDS_MISC: %pe\n" , +ERR_PTR (ret)); +return ret; +} + +/* 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; +u32 misc; +int ret; + +/* An earlier run may have failed to restore the target mode, which +* leaves the lane parked. The mode field in SDS_MISC says so: put it +* back before anything else. +*/ + ret =regmap_read (priv->map,RTL8365MB_SDS_MISC_REG , &misc); +if (ret) { +dev_err_ratelimited (priv->dev, +"failed to read SDS_MISC: %pe\n" , +ERR_PTR (ret)); + goto rearm; + } +if ((misc &RTL8365MB_D_SDS_MISC_MODE_FIELD_MASK ) == +RTL8365MB_D_PORT_SDS_MODE_DISABLE ) { +if (rtl8365mb_sds_relatch_restore (mb)) + delay =RTL8365MB_D_SDS_RELATCH_INTERVAL ; + goto rearm; + } + +/* 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 ); + +if (rtl8365mb_sds_relatch_restore (mb)) { +/* 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)
@@ -1832,11 +2070,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,
@@ -3548,6 +3795,10 @@ out_error: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);
@@ -3580,6 +3831,21 @@ static int rtl8365mb_get_chip_id_and_ver(struct regmap *map, u32 *id, u32 *ver)return 0 ; } +static int rtl8365mb_sds_reboot_notify (struct notifier_block *nb, +unsigned long action,void *data) +{ + struct rtl8365mb *mb = container_of(nb, struct rtl8365mb, + sds_reboot_nb); + +/* Runs before device_shutdown() on reboot, halt, power off and kexec. +* cancel_delayed_work_sync() waits for a running pass, so the SerDes +* is not left parked and the bus is not touched while it is shut down. +*/ +cancel_delayed_work_sync (&mb->sds_relatch); + +return NOTIFY_DONE ; +} +static int rtl8365mb_detect (struct realtek_priv *priv) {struct rtl8365mb *mb = priv->chip_data;
@@ -3614,6 +3880,30 @@ 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 ; + + 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->sds_reboot_nb.notifier_call = rtl8365mb_sds_reboot_notify; + ret =devm_register_reboot_notifier (priv->dev, + &mb->sds_reboot_nb); +if (ret) +return ret; + } + mb->priv = priv; mb->cpu.trap_port =RTL8365MB_MAX_NUM_PORTS ; mb->cpu.insert =RTL8365MB_CPU_INSERT_TO_ALL ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net-next v5 8/9] net: dsa: realtek: rtl8365mb: re-latch the family D SerDes
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The commit message (and the comment above rtl8365mb_sds_relatch_work()) gives two reasons for the blind design.
- [Low] At this commit no rtl8365mb_chip_infos entry uses RTL8365MB_FAMILY_D.
- [Low] The comment in rtl8365mb_sds_reboot_notify() says:
"cancel_delayed_work_sync() waits for a running pass, so the SerDes is…
- [Low] The concern is that rtl8365mb_sds_reboot_notify(), pcs_disable() and teardown() use cancel_delayed_work_sync() instead of…
--
net: dsa: realtek: rtl8365mb: re-latch the family D SerDes
This adds a delayed work item for family D chips. The work parks SDS_MISC and then restores the HSGMII mode, so the SerDes receiver sees a DISABLE -> mode edge after the far-end MAC has come up. Each episode starts from pcs_config() and drives up to 15 edges about 1 s apart, then falls back to a 10 s health check, with a new sds_lock serializing the SDS_INDACS window.
Quoted 6 lines
The two ends can be seconds apart, e.g. on an IPQ5018 board:
5.27 rtl8365mb: configuring for fixed/2500base-x <- pcs_config() 7.72 ipq5018-gmac-dwmac eth0: configuring for fixed/2500base-x 8.02 ipq5018-gmac-dwmac eth0: Link is Up - 2.5Gbps/Full 8.56 SerDes latches
[Severity: Low]
This isn't a bug, but at this commit no entry in rtl8365mb_chip_infos[] uses RTL8365MB_FAMILY_D. All entries have chip_id 0x6367. None of the re-latch code can run until the later "add support for RTL8367S-VB" patch adds the 0x6642 entry.
The sibling patches in the series ("set RGMII mode for family D", "set and get vlan 4k for family D", "add family D SDS13 PCS support") each say that the family D paths are unreachable until the last patch.
This commit message describes a live failure with board logs. Could it include the same note?
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0
[ ... ]
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +4
-2@@ -1683,8 +1742,187 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, val &= ~RTL8365MB_SDS_NWAY_EN_MASK ; val |=RTL8365MB_SDS_NWAY_RESTART_MASK ; -return rtl8365mb_sds_write (priv, sds_index, -RTL8365MB_SDS_REG_NWAY , val); + ret =rtl8365mb_sds_write (priv, sds_index, +RTL8365MB_SDS_REG_NWAY , val); +if (ret) +return ret;
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, · line 1758
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +10
-0+ +/* 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 ); + }
[Severity: Medium]
Should the re-latch episode start from pcs_config()? The design rests on two statements in the commit message:
There is no local signal that predicts when the far-end MAC will bring up its half of the link [...]
Nothing external re-checks this later.
For the CPU trunk, struct dsa_switch_ops already has a hook for this:
include/net/dsa.h:
void (*conduit_state_change)(struct dsa_switch *ds,
const struct net_device *conduit, bool operational);
dsa_tree_conduit_admin_state_change() and dsa_tree_conduit_oper_state_change() call this hook when the conduit becomes admin-up and netif_oper_up(). That is the "8.02 eth0: Link is Up" line in the log above.
The budget is counted from pcs_config() at switch setup. What happens if userspace, or the first user port open, brings the conduit up more than about 15 s after probe?
All 15 fast edges would go to a far end that is not up yet. The MAX_TRIES + 1 run in rtl8365mb_sds_relatch_work() would then print "SerDes did not latch after 15 re-latch attempts". After that, an edge is driven only once per RTL8365MB_D_SDS_HEALTHCHECK_INTERVAL.
When the conduit does come up, could the CPU port report 2.5Gbps/Full and still pass no frames for up to 10 s? That does not fit the comment above RTL8365MB_D_SDS_RELATCH_INTERVAL, which says the budget is "generous enough to outlast a slow conduit".
Conduit admin-down has a similar problem if the far-end MAC drops its SerDes. The !attempts branch would print "SerDes link lost outside a reconfiguration" and run another 15 parks. It would then warn again and park every 10 s until the conduit comes back.
The CPU port's phylink is not stopped on conduit down, so rtl8365mb_pcs_disable() does not cancel the work in that case.
Could the episode be started from conduit_state_change() instead? That would avoid the misleading warnings and the delay of up to 10 s before recovery.
[ ... ]
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0@@ -3580,6 +3831,21 @@ static int rtl8365mb_get_chip_id_and_ver(struct regmap *map, u32 *id, u32 *ver)return 0 ; }
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_get_chip_id_and_ver(struct regmap *map, u32 *id, u32 *ver) · line 3843
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +10
-0+static int rtl8365mb_sds_reboot_notify (struct notifier_block *nb, +unsigned long action,void *data) +{ + struct rtl8365mb *mb = container_of(nb, struct rtl8365mb, + sds_reboot_nb); + +/* Runs before device_shutdown() on reboot, halt, power off and kexec. +* cancel_delayed_work_sync() waits for a running pass, so the SerDes +* is not left parked and the bus is not touched while it is shut down. +*/
[Severity: Low]
Does "the SerDes is not left parked" still hold when the restore fails?
In rtl8365mb_sds_relatch_work(), the lane is parked first. If rtl8365mb_sds_relatch_restore() then fails all RTL8365MB_D_SDS_RESTORE_TRIES writes, the lane stays in DISABLE, and only the next run can put it back:
if (rtl8365mb_sds_relatch_restore(mb)) {
...
delay = RTL8365MB_D_SDS_RELATCH_INTERVAL;
goto rearm;
}
...
rearm:
schedule_delayed_work(&mb->sds_relatch, delay);cancel_delayed_work_sync() goes through __cancel_work_sync(), which calls __cancel_work(work, cflags | WORK_CANCEL_DISABLE). The work is disabled during the cancel, so the running pass's schedule_delayed_work() is dropped. No later run restores the mode.
The same is true for the cancels in pcs_disable(), teardown() and the devres action.
This takes three regmap failures in a row, and the next probe or pcs_config() rewrites SDS_MISC. Would it be enough to just correct the comment?
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_get_chip_id_and_ver(struct regmap *map, u32 *id, u32 *ver) · line 3844
Quoted 1 line
drivers/net/dsa/realtek/rtl8365mb_main.c +1
-0+cancel_delayed_work_sync (&mb->sds_relatch);
[Severity: Low]
This isn't a bug, but would disable_delayed_work_sync() be more robust in the reboot notifier?
After the notifier runs, cancel_delayed_work_sync() does not stop rtl8365mb_pcs_config() from calling schedule_delayed_work() again.
I couldn't find a concrete path where that happens for the fixed-link CPU port. For a user port on the SerDes, dsa_switch_shutdown() closes the user ports first. phylink_stop() then calls rtl8365mb_pcs_disable() again before the parent bus shuts down. So this would only be hardening.
Quoted 3 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +3
-0+ +return NOTIFY_DONE ; +}
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/aa5fa12c-e43e-4e5e-9f77-c6eaf477abc4%40yahoo.com
PATCH v5 9/9 net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB
In reply to Mieczyslaw NalewajAdd the RTL8367S-VB (chip ID 0x6642, version 0x0010) to the chip table. It is the first chip of family D, whose handling was added in the preceding patches, so this is the patch that makes it reachable.
The SGMII/HSGMII SerDes of this chip sits on port 6 and the MII/TMII/RMII/RGMII interface on port 7, as on family C, but the external interface indices are one lower (EXT0 and EXT1 instead of EXT1 and EXT2). The chip reuses the existing initialization jam table.
The chip has 8 ports, not 11. Cap priv->num_ports at RTL8365MB_D_MAX_NUM_PORTS for family D. This is a functional change: it sets ds->num_ports, the IRQ domain size and the bound of every loop over priv->num_ports.
The L2 learning limit is the same as on family C (2112 entries), as given by the Realtek rtl8367 common API (rtl8367_common V1.4.2), so RTL8365MB_LEARN_LIMIT_MAX needs no per-family handling; only its comment is updated.
Tested on a TP-Link Archer AX55 v1 (RTL8367S-VB, CPU port over HSGMII to an IPQ5018) with bridge VLAN filtering and per-port PVIDs. SGMII has also been seen working, but I no longer have the exact link partner and speed it was tested with, so treat it as lightly tested. RGMII mode has not yet been tested.
--- drivers/net/dsa/realtek/rtl8365mb_main.c | 31 +++++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +27 -4
@@ -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>
@@ -119,9 +125,10 @@#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
@@ -885,6 +892,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 {
@@ -3879,7 +3899,10 @@ 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)
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [Medium] The family-D SerDes re-latch work can be queued again after the reboot notifier has cancelled it.
--
net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB
This patch adds the RTL8367S-VB (chip ID 0x6642, version 0x0010) to the chip table. It is the first family D chip, so the family D handling added in the earlier patches becomes reachable. On family D it also caps priv->num_ports at RTL8365MB_D_MAX_NUM_PORTS.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0
[ ... ]
drivers/net/dsa/realtek/rtl8365mb_main.c static const struct rtl8365mb_chip_info rtl8365mb_chip_infos[] = { · line 899
Quoted 9 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +5
-0@@ -885,6 +892,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,
[Severity: Medium]
With this entry, the family D SerDes re-latch work and the reboot notifier can now run. Can the sds_relatch work be queued again after the reboot notifier has cancelled it?
The notifier cancels the work once. It sets no state that anything else checks:
drivers/net/dsa/realtek/rtl8365mb_main.c:rtl8365mb_sds_reboot_notify() {
/* Runs before device_shutdown() on reboot, halt, power off and kexec.
* cancel_delayed_work_sync() waits for a running pass, so the SerDes
* is not left parked and the bus is not touched while it is shut down.
*/
cancel_delayed_work_sync(&mb->sds_relatch);
...
}rtl8365mb_pcs_config() queues the work for 2500base-x on family D without any check:
if (is_d && interface == PHY_INTERFACE_MODE_2500BASEX) {
WRITE_ONCE(mb->sds_relatch_count, 1);
schedule_delayed_work(&mb->sds_relatch, 0);
}After that, rtl8365mb_sds_relatch_work() re-arms itself every time it exits:
rearm:
schedule_delayed_work(&mb->sds_relatch, delay);
pcs_config() could run after the reboot notifier chain in two ways:
- Probe overlaps reboot. rtl8365mb_detect() registers the notifier, and dsa_port_setup()->dsa_port_enable()->dsa_port_enable_rt()-> phylink_start() then configures the HSGMII CPU port. kernel_restart_prepare() runs the notifiers before device_shutdown() calls wait_for_device_probe().
- A user port on the SerDes is brought up at the same time, through dsa_user_open()->phylink_start().
After that, rtl83xx_shutdown()->dsa_switch_shutdown() only closes the conduits and detaches the user netdevs. It doesn't stop the CPU port phylink, call rtl8365mb_teardown(), or cancel sds_relatch. The devm action rtl8365mb_sds_relatch_cancel() doesn't run on shutdown either.
In that case, wouldn't the work keep parking SDS_MISC, sleeping for 20 ms and doing regmap I/O over SMI/MDIO while the switch, and possibly the host MDIO/GPIO controller, is being shut down? The notifier comment says this cannot happen.
Would disable_delayed_work_sync() in the notifier work here? Another option would be a shutdown flag that rtl8365mb_pcs_config() and the work check before re-queueing.
Quoted 9 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +8
-0+ .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), + }, };
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/aa5fa12c-e43e-4e5e-9f77-c6eaf477abc4%40yahoo.com