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]
v10 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 and L2 table layouts, speed/RGMII configuration and SerDes (SDS13) handling.
Patch 1 documents the chip in the devicetree binding.
Patch 2 adds the chip family infrastructure, with the per-family data (port count, init jam table) in struct rtl8365mb_family_info (no functional change).
Patch 3 moves the external interface force-mode configuration behind the family info (no functional change).
Patches 4-5 add the port speed and RGMII mode configuration for family D. Patch 6 moves the VLAN 4k table accessors behind the family info (no functional change).
Patches 7-8 add the VLAN 4k table access (dynamically selecting the IVL learning mode from the filtering state of the user ports for family D only) and the raw-VID PVID handling for family D.
Patch 9 adds SDS13 PCS support.
Patch 10 refactors the family C L2 MAC handling by introducing shared pack/unpack helpers and reaching the family C serializers through function pointers in the family info (no functional change). Patch 11 makes the L2 (FDB/MDB) table access work on family D, which has a 5-word entry layout, narrower table access fields and no EFID, and where a VLAN-unaware bridge (VID 0) is handled with an SVL key. Patch 12 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 L2 table access and FDB/MDB code is shared; the family D handling is selected at runtime through the family info and rtl8365mb_is_d() (patch 11). The RTL8367S-VB has 8 ports, described by num_ports in its family info (patch 12). On family D, FDB/MDB offload is available, but there is no per-bridge FDB isolation (no EFID), so only one bridge is offloaded (max_num_bridges = 1). Further bridges are forwarded in software and isolated by the port isolation masks only (patch 11). Standalone ports, software-bridged ports and the offloaded VLAN-unaware bridge share FID 0 in the LUT.
Tested on a TP-Link Archer AX55 v1 (RTL8367S-VB, CPU port over HSGMII to an IPQ5018, with the UNIPHY mode sequence run at GMAC probe) with bridge VLAN filtering and per-port PVIDs, by Oleg Gavrilov.
Tested on family D by Gustavo Foletto Mora on a TP-Link EX511 v2 (RTL8367S-VB, CPU port 6 over 1G SGMII to an IPQ5018) on a live network, with a VLAN-aware bridge (tagged trunk with VIDs 10-40, access ports on VIDs 10 and 20) and a VLAN-unaware one: VLAN table and PVIDs, tagged and untagged traffic through the CPU port, VLAN isolation, FDB and MDB entries, VLAN add/delete churn, moving a port to a second bridge, traffic in the switch and through the CPU port, a conduit down/up and reboots, with no FCS, symbol, drop, fragment or jabber errors on the checked ports.
Regression-tested on family C by Stanislaw Pal on a TP-Link Archer AX55 v1 (RTL8367S, CPU port over a 2500base-x fixed link to an IPQ5018), on a tree that also carries an 802.1Q-based tagger for this switch:
three boots (after sysupgrade, a reboot and a cold start) and traffic between a LAN client and an 802.11s mesh in both directions, with no FCS errors, drops or driver warnings. Family D paths are not exercised on that chip.
Not covered: RGMII and real Wi-Fi stations.
---
v10:
- 8/11 of v9 (SerDes re-latch): dropped. Johan Alvarado traced the symptom to the SoC side: the bootloader hands the UNIPHY over in SGMII and the out-of-tree qca-uniphy PCS programs SGMII+ only from pcs_config() at the first open of the conduit, about two seconds after the switch brought its SerDes up in HSGMII at DSA setup, so the switch receiver trains against the wrong line rate. Running the UNIPHY mode sequence at GMAC probe, before the switch probes, fixes it with no change in rtl8365mb (0 of 32 broken boots, versus 18 of 51). As neither dwmac-ipq5018 nor pcs-qca-uniphy is in mainline, the workqueue, the extra locks and the reboot notifier are not needed in this driver (Johan, Alvin)
- 2/12: say "family-specific" in the comment on the init jam table
- 3/12 (new): move ext_config_forcemode() behind struct rtl8365mb_family_info, the existing code becoming the family C implementation; no functional change (Alvin)
- 4/12: only add the family D force-mode implementation, instead of is_d() branches in the shared code; no functional change; say in the commit message why the function is not static until the last patch
- 5/12: log an error instead of a warning when RGMII is not available on port 7, and say in the commit message that port 7 then has no supported interface
- 6/12 (new): move the VLAN 4k table accessors behind struct rtl8365mb_family_info, the existing code becoming the family C implementation; no functional change (Alvin)
- 7/12: only add the family D VLAN 4k accessors, instead of is_d() branches in the shared code; on family D enable IVL while any user port has VLAN filtering enabled, independent of the port being configured (so the CPU port cannot reset it); document that IVL_EN (bit 3, versus bit 14 on family C) is refreshed on the next port_vlan_add/del of the VID, not on a vlan_filtering change; say in the commit message why the accessors are not static until the last patch
- 9/12: do not advertise 10 and 100 Mbit/s on the family D SerDes port, as no SerDes rate is programmed for them
- 11/12: do not delete a dynamic unicast entry on family D; correct the commit message about standalone ports (DSA programs no entries for them without fdb_isolation) and describe that FID 0 is shared; name the vendor function that writes the LUT aging value (dal_rtl8367d_l2_init); say in the commit message why the family D functions are not static until the last patch
- 2/12 and 12/12: restored Reviewed-by from Linus, reconfirmed on the list after v9
v9: https://lore.kernel.org/netdev/[email protected]/
- 2/11: add struct rtl8365mb_family_info holding per-family data
(port count, init jam table); use num_ports from it in
rtl8365mb_detect(); rename the port count constant to
RTL8365MB_C_MAX_NUM_PORTS (Alvin)
- 3/11: drop the FORCE_SPEED_WIDTH macro and add a mask for the most
significant speed bit (Alvin)
- 5/11: restructure the family D checks when unpacking the untag
field; no functional change
- 7/11: update the kernel-doc of sds_supported and the commit message
for family D always setting it; note in a comment that the register
and field names follow the vendor API
- 8/11:
- use explicit mutex_lock()/mutex_unlock() instead of
guard(mutex); no functional change
- arm the re-latch only for 2500base-x on a CPU port, and say
so in the commit message; ignore conduit state changes of other
switches in the tree
- 9/11: reach the family C L2 serialisers and entry size through
function pointers in the family info (Alvin)
- 10/11:
- add the family D L2 serialisers to the family info, drop
RTL8365MB_D_L2_MAX_PORT and the port checks, as the core never
passes a port above num_ports - 1 (Alvin)
- use an SVL key (IVL=0, FID=0) for VID 0, so static unicast
and multicast entries match the learned ones in a VLAN-unaware
bridge; they were written with IVL set and never replaced the
learned entries (reported and tested by Gustavo Foletto Mora)
- offload only one bridge on family D (max_num_bridges = 1),
as the LUT cannot tell bridges apart without EFID; further bridges
fall back to software forwarding
- do not delete a unicast entry on family D if the entry
found belongs to another port; update the l2_lock and EFID
comments; note that the LUT aging value is undocumented
- 11/11: describe the 8 ports of the RTL8367S-VB in its family info
instead of a family check in rtl8365mb_detect(); mention the L2/LUT
and table access differences in the family D overview comment
- Dropped the Reviewed-by tags of Linus and Luiz from 2/11 and the
one of Linus from 11/11, as these patches changed substantially.
Linus, Luiz, could you please take another look? Tags on the other
patches are unchanged.
- Added Tested-by tags: Gustavo Foletto Mora on 2, 3, 5, 6, 7, 9, 10,
11 and Stanislaw Pal on 2, 3, 7, 8, 9, 10v8: https://lore.kernel.org/netdev/[email protected]/
- 2/11: declare the rtl8365mb_is_d() helper as a global inline function in the new header
- 9/10: split into two patches to improve structure and address reviewer comments:
- 9/11 (new): introduce shared MAC pack/unpack helpers and refactor family C serializers without functional changes
- 10/11: drop the confusing _any() suffixes in favor of clean symmetric dispatchers, switch to the global rtl8365mb_is_d() helper, and fix the memset size in family D serializers
v7: https://lore.kernel.org/netdev/[email protected]/
- 3/10, 6/10: note that the family D path is unreachable until the last patch
- 4/10: program EXT_TXC_DLY, the pin mux and the SerDes 1 disable before selecting RGMII; warn when RGMII is disabled because MAC4 owns EXT1
- 8/10: act only on the conduit of the CPU port that carries the SerDes; queue the work with schedule_delayed_work() and rename the devres action to rtl8365mb_sds_relatch_disable()
- 9/10: new, make L2/LUT access work on family D (5-word entries, narrower table access fields, LUT init, no FDB isolation)
- 10/10: update the NET_DSA_REALTEK_RTL8365MB help text
v6: https://lore.kernel.org/netdev/[email protected]/
- 4/9: do not advertise RGMII for port 7 when MAC4 owns EXT1, instead of returning -EBUSY from mac_config(), which phylink ignores
- 5/9: take IVL_EN from vlan4k->ivl_en and leave SVLAN_CHK_IVL_SVL at 0, as the vendor API does
- 7/9: pcs_get_state(): keep phylink's speed and duplex for SGMII and never report the link up with an unknown speed
- 8/9: start the re-latch work when the conduit comes up and stop it when it goes down (.conduit_state_change); serialize it against pcs_config() with sds_cfg_lock; disable it for good on shutdown and unbind
v5: https://lore.kernel.org/netdev/[email protected]/
- 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 (12):
dt-bindings: net: dsa: realtek: add RTL8367S-VB
net: dsa: realtek: rtl8365mb: add chip family infrastructure
net: dsa: realtek: rtl8365mb: refactor forcemode handling
net: dsa: realtek: rtl8365mb: set speed for family D
net: dsa: realtek: rtl8365mb: set RGMII mode for family D
net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling
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: refactor L2 MAC handling
net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB
.../devicetree/bindings/net/dsa/realtek.yaml | 2 +- drivers/net/dsa/realtek/Kconfig | 3 +- drivers/net/dsa/realtek/realtek.h | 4 +- drivers/net/dsa/realtek/rtl8365mb.h | 48 ++ drivers/net/dsa/realtek/rtl8365mb_l2.c | 249 +++++-- drivers/net/dsa/realtek/rtl8365mb_l2.h | 18 + drivers/net/dsa/realtek/rtl8365mb_main.c | 647 +++++++++++++++--- drivers/net/dsa/realtek/rtl8365mb_table.c | 44 +- drivers/net/dsa/realtek/rtl8365mb_vlan.c | 321 ++++++++- drivers/net/dsa/realtek/rtl8365mb_vlan.h | 12 + drivers/net/dsa/realtek/rtl83xx.c | 5 +- 11 files changed, 1150 insertions(+), 203 deletions(-) create mode 100644 drivers/net/dsa/realtek/rtl8365mb.h
Signature · 1 line
2.53.0
PATCH v10 1/12 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 v10 2/12 net: dsa: realtek: rtl8365mb: add chip family infrastructure
In reply to Mieczyslaw NalewajAdd enum rtl8365mb_family and struct rtl8365mb_family_info, which holds the data shared by all chips of one family: the family id, the port count and the init jam table. struct rtl8365mb_chip_info now points to it through a family_info member, and all existing chips use the RTL8365MB_FAMILY_C instance. rtl8365mb_get_family_info() and rtl8365mb_is_d() are declared in a new rtl8365mb.h so that the VLAN code can use them too.
Use num_ports from the family info in rtl8365mb_detect() instead of a fixed constant, so that a family with a different port count can be described by its own entry.
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 | 29 +++++++++++++ drivers/net/dsa/realtek/rtl8365mb_main.c | 54 +++++++++++++++--------- 2 files changed, 62 insertions(+), 21 deletions(-) create mode 100644 drivers/net/dsa/realtek/rtl8365mb.h
drivers/net/dsa/realtek/rtl8365mb.h new file +29 -0
@@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _RTL8365MB_H +#define _RTL8365MB_H + +#include "realtek.h" + +enum rtl8365mb_family { +RTL8365MB_FAMILY_C , +RTL8365MB_FAMILY_D , +}; + +struct rtl8365mb_jam_tbl_entry ; + +struct rtl8365mb_family_info { +enum rtl8365mb_family family; +unsigned int num_ports; +const struct rtl8365mb_jam_tbl_entry *jam_table; +size_t jam_size; +}; + +const struct rtl8365mb_family_info * +rtl8365mb_get_family_info (struct realtek_priv *priv); + +static inline bool rtl8365mb_is_d (struct realtek_priv *priv) +{ +return rtl8365mb_get_family_info (priv)->family ==RTL8365MB_FAMILY_D ; +} + +#endif /* _RTL8365MB_H */
drivers/net/dsa/realtek/rtl8365mb_main.c +33 -21
148 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v10 3/12 net: dsa: realtek: rtl8365mb: refactor forcemode handling
In reply to Mieczyslaw NalewajMove the external interface force-mode configuration behind struct rtl8365mb_family_info, so that family D can provide its own versions without is_d() checks in the shared code. The existing code becomes the family C implementation and is otherwise unchanged. The mac_link_up() and mac_link_down() callbacks call it through the family info.
No functional change.
--- drivers/net/dsa/realtek/rtl8365mb.h | 3 ++ drivers/net/dsa/realtek/rtl8365mb_main.c | 44 ++++++++++++++---------- 2 files changed, 29 insertions(+), 18 deletions(-)
drivers/net/dsa/realtek/rtl8365mb.h +3 -0
@@ -16,6 +16,9 @@ struct rtl8365mb_family_info {unsigned int num_ports;const struct rtl8365mb_jam_tbl_entry *jam_table;size_t jam_size; +int (*ext_config_forcemode)(struct realtek_priv *priv,int port, +bool link,int speed,int duplex, +bool tx_pause,bool rx_pause); }; const struct rtl8365mb_family_info *
drivers/net/dsa/realtek/rtl8365mb_main.c +26 -18
116 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH net-next v10 03/12] net: dsa: realtek: rtl8365mb: refactor forcemode handling
Quoted 7 lines · Mieczyslaw Nalewaj
Move the external interface force-mode configuration behind struct
rtl8365mb_family_info, so that family D can provide its own versions withoutis_d()checks in the shared code. The existing code becomes the family C implementation and is otherwise unchanged. Themac_link_up()andmac_link_down()callbacks call it through the family info.
Quoted 5 lines
No functional change.
Tested-by Gustavo Foletto Mora <[email protected]>Tested-by Stanislaw Pal <[email protected]>Signed-off-by Mieczyslaw Nalewaj <[email protected]>
Yours,
Linus Walleij
PATCH v10 4/12 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.
Add the family D implementation as rtl8365mb_d_ext_config_forcemode(). The shared code reaches it through the ext_config_forcemode pointer in struct rtl8365mb_family_info, so it needs no is_d() check.
Nothing points to it until the family D info is added together with the chip table entry in the last patch. Until then it is not static and is declared in rtl8365mb.h, so that the build does not warn about an unused function.
--- drivers/net/dsa/realtek/rtl8365mb.h | 4 + drivers/net/dsa/realtek/rtl8365mb_main.c | 110 +++++++++++++++++++++++ 2 files changed, 114 insertions(+)
drivers/net/dsa/realtek/rtl8365mb.h +4 -0
@@ -24,6 +24,10 @@ struct rtl8365mb_family_info {const struct rtl8365mb_family_info *rtl8365mb_get_family_info (struct realtek_priv *priv); +int rtl8365mb_d_ext_config_forcemode (struct realtek_priv *priv,int port, +bool link,int speed,int duplex, +bool tx_pause,bool rx_pause); +static inline bool rtl8365mb_is_d (struct realtek_priv *priv) {return rtl8365mb_get_family_info (priv)->family ==RTL8365MB_FAMILY_D ;
drivers/net/dsa/realtek/rtl8365mb_main.c +110 -0
128 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v10 5/12 net: dsa: realtek: rtl8365mb: set RGMII mode for family D
In reply to Mieczyslaw NalewajOn family D, RGMII on extension interface 1 needs three 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, the pin mux in the top-level configuration register must be set up, and SerDes 1, which shares the pins, must be disabled.
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, do not advertise RGMII for port 7 in phylink_get_caps(), so the configuration is refused before any EXT1 register is touched. This mirrors the vendor RTL8367D API, which returns an error for RGMII on port 7 when UTP port 4 uses the RGMII interface. The driver logs an error naming the conflict. RGMII is the only interface of port 7 this driver implements, so port 7 then has no supported interface: phylink_create() fails for it, and if it is a CPU port the switch does not probe.
When MAC4 does not own the pins, bind the RGMII/MII pins to MAC7 and disable SerDes 1, which shares them. The TX delay field, the pin mux and the SerDes 1 disable are all programmed before RGMII is selected, so the shared pins are never driven by RGMII and SerDes 1 at the same time.
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 | 70 +++++++++++++++++++++++- 1 file changed, 68 insertions(+), 2 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +68 -2
@@ -334,6 +334,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
@@ -466,6 +472,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
@@ -1263,6 +1283,32 @@ static int rtl8365mb_ext_config_rgmii(struct realtek_priv *priv, int port,if (ret)return ret; +if (rtl8365mb_is_d (priv) && 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: +* RGMII is not advertised otherwise, see +* rtl8365mb_phylink_get_caps(). +*/ + 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; + } + ret = regmap_update_bits( priv->map, RTL8365MB_DIGITAL_INTERFACE_SELECT_REG(extint->id), RTL8365MB_DIGITAL_INTERFACE_SELECT_MODE_MASK(extint->id),
@@ -1830,6 +1876,8 @@ static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port,rtl8365mb_get_port_extint (ds->priv, port);struct realtek_priv *priv = ds->priv;struct rtl8365mb *mb = priv->chip_data; +u32 data; +int ret; config->mac_capabilities =MAC_SYM_PAUSE |MAC_ASYM_PAUSE |MAC_10 |MAC_100 |MAC_1000FD ;
@@ -1859,8 +1907,26 @@ static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port,* which remain unimplemented. */ -if (extint->supported_interfaces &RTL8365MB_PHY_INTERFACE_MODE_RGMII ) -phy_interface_set_rgmii (config->supported_interfaces); +if (extint->supported_interfaces &RTL8365MB_PHY_INTERFACE_MODE_RGMII ) { +/* On family D the EXT1 pins are shared with MAC4 (UTP port 4). +* If MAC4 owns them, RGMII on this port cannot work. +*/ +if (rtl8365mb_is_d (priv) && extint->id ==1 ) { + ret =regmap_read (priv->map,RTL8365MB_D_REG_TOP_CON0 , &data); +if (ret) +dev_err (priv->dev, +"failed to read TOP_CON0, RGMII on port %d disabled: %pe\n" , + port,ERR_PTR (ret)); +else if (data &RTL8365MB_D_MAC4_SEL_EXT1_MASK ) +dev_err (priv->dev, +"port %d: EXT1 is owned by MAC4, RGMII cannot be used\n" , + port); +else +phy_interface_set_rgmii (config->supported_interfaces); + }else { +phy_interface_set_rgmii (config->supported_interfaces); + } + }if (extint->supported_interfaces &RTL8365MB_PHY_INTERFACE_MODE_SGMII && mb->sds_supported)
Signature · 1 line
2.53.0
PATCH v10 6/12 net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling
In reply to Mieczyslaw NalewajMove the family-specific VLAN 4k table accessors behind struct rtl8365mb_family_info, so that family D can provide its own versions without is_d() checks in the shared code. The existing code becomes the family C implementation and is otherwise unchanged: rename the functions to rtl8365mb_c_vlan_4k_read() and rtl8365mb_c_vlan_4k_write(), export them and call them through the family info.
No functional change.
--- drivers/net/dsa/realtek/rtl8365mb.h | 5 +++++ drivers/net/dsa/realtek/rtl8365mb_main.c | 2 ++ drivers/net/dsa/realtek/rtl8365mb_vlan.c | 21 ++++++++++++--------- drivers/net/dsa/realtek/rtl8365mb_vlan.h | 7 +++++++ 4 files changed, 26 insertions(+), 9 deletions(-)
drivers/net/dsa/realtek/rtl8365mb.h +5 -0
@@ -10,6 +10,7 @@ enum rtl8365mb_family { };struct rtl8365mb_jam_tbl_entry ; +struct rtl8365mb_vlan4k ;struct rtl8365mb_family_info {enum rtl8365mb_family family;
@@ -19,6 +20,10 @@ struct rtl8365mb_family_info {int (*ext_config_forcemode)(struct realtek_priv *priv,int port,bool link,int speed,int duplex,bool tx_pause,bool rx_pause); +int (*vlan_4k_read)(struct realtek_priv *priv,u16 vid, +struct rtl8365mb_vlan4k *vlan4k); +int (*vlan_4k_write)(struct realtek_priv *priv, +const struct rtl8365mb_vlan4k *vlan4k); }; const struct rtl8365mb_family_info *
drivers/net/dsa/realtek/rtl8365mb_main.c +2 -0
@@ -757,6 +757,8 @@ static const struct rtl8365mb_family_info rtl8365mb_family_c = { .jam_table = rtl8365mb_init_jam_8365mb_vc, .jam_size = ARRAY_SIZE(rtl8365mb_init_jam_8365mb_vc), .ext_config_forcemode = rtl8365mb_c_ext_config_forcemode, + .vlan_4k_read = rtl8365mb_c_vlan_4k_read, + .vlan_4k_write = rtl8365mb_c_vlan_4k_write, };/**
drivers/net/dsa/realtek/rtl8365mb_vlan.c +12 -9
@@ -48,12 +48,13 @@#include "rtl8365mb_vlan.h" #include "rtl8365mb_table.h" +#include "rtl8365mb.h" #include <linux/if_bridge.h> #include <linux/lockdep.h> #include <linux/regmap.h> /* CVLAN (i.e. VLAN4k) table entry layout, u16[3] */ -#define RTL8365MB_CVLAN_ENTRY_SIZE 3/* 48-bits */ +#define RTL8365MB_C_CVLAN_ENTRY_SIZE 3/* 48-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)
@@ -182,10 +183,10 @@ struct rtl8365mb_vlanmc { u8 meteridx : 6; }; -static int rtl8365mb_vlan_4k_read (struct realtek_priv *priv,u16 vid, -struct rtl8365mb_vlan4k *vlan4k) +int rtl8365mb_c_vlan_4k_read (struct realtek_priv *priv,u16 vid, +struct rtl8365mb_vlan4k *vlan4k) { -u16 data[RTL8365MB_CVLAN_ENTRY_SIZE ]; +u16 data[RTL8365MB_C_CVLAN_ENTRY_SIZE ];int val;int ret;
@@ -230,10 +231,10 @@ static int rtl8365mb_vlan_4k_read(struct realtek_priv *priv, u16 vid,return 0 ; } -static int rtl8365mb_vlan_4k_write (struct realtek_priv *priv, -const struct rtl8365mb_vlan4k *vlan4k) +int rtl8365mb_c_vlan_4k_write (struct realtek_priv *priv, +const struct rtl8365mb_vlan4k *vlan4k) { -u16 data[RTL8365MB_CVLAN_ENTRY_SIZE ] = {0 }; +u16 data[RTL8365MB_C_CVLAN_ENTRY_SIZE ] = {0 };u16 vid;int val;
@@ -282,6 +283,7 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port, struct netlink_ext_ack *extack, bool include) { +const struct rtl8365mb_family_info *fi;struct realtek_priv *priv = ds->priv;struct rtl8365mb_vlan4k vlan4k = {0 };int ret;
@@ -296,7 +298,8 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port,return -EINVAL ; } - ret =rtl8365mb_vlan_4k_read (priv, vlan->vid, &vlan4k); + fi =rtl8365mb_get_family_info (priv); + ret = fi->vlan_4k_read (priv, vlan->vid, &vlan4k);if (ret) {dev_err (priv->dev,"Failed to read VLAN 4k table\n" );return ret;
@@ -313,7 +316,7 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port, vlan4k.untag &= ~BIT (port); vlan4k.ivl_en = true;/* always use Independent VLAN Learning */ - ret =rtl8365mb_vlan_4k_write (priv, &vlan4k); + ret = fi->vlan_4k_write (priv, &vlan4k);if (ret) {dev_err (priv->dev,"Failed to write VLAN 4k table\n" );return ret;
drivers/net/dsa/realtek/rtl8365mb_vlan.h +7 -0
@@ -18,6 +18,13 @@ enum rtl8365mb_frame_ingress { RTL8365MB_FRAME_TYPE_UNTAGGED_ONLY, }; +struct rtl8365mb_vlan4k ; + +int rtl8365mb_c_vlan_4k_read (struct realtek_priv *priv,u16 vid, +struct rtl8365mb_vlan4k *vlan4k); +int rtl8365mb_c_vlan_4k_write (struct realtek_priv *priv, +const struct rtl8365mb_vlan4k *vlan4k); +int rtl8365mb_vlan_port_get_pvid (struct realtek_priv *priv,int port,u16 *pvid);int
Signature · 1 line
2.53.0
Re: [PATCH net-next v10 06/12] net: dsa: realtek: rtl8365mb: refactor VLAN 4k handling
Quoted 7 lines · Mieczyslaw Nalewaj
Move the family-specific VLAN 4k table accessors behind struct
rtl8365mb_family_info, so that family D can provide its own versions withoutis_d()checks in the shared code. The existing code becomes the family C implementation and is otherwise unchanged: rename the functions tortl8365mb_c_vlan_4k_read()andrtl8365mb_c_vlan_4k_write(), export them and call them through the family info.
Quoted 5 lines
No functional change.
Tested-by Gustavo Foletto Mora <[email protected]>Tested-by Stanislaw Pal <[email protected]>Signed-off-by Mieczyslaw Nalewaj <[email protected]>
Looks good to me!
Yours,
Linus Walleij
PATCH v10 7/12 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.
IVL_EN (bit 3, versus bit 14 on family C) follows vlan4k->ivl_en. On family D, rtl8365mb_vlan_4k_port_set() enables it while any user port has VLAN filtering enabled (dsa_port_is_vlan_filtering()), so that static and learned FDB/MDB entries use the same key. Family C keeps IVL always enabled, as before.
The stored IVL_EN is refreshed on the next port_vlan_add/del for the VID, not on a vlan_filtering change.
Reusing the three-word family C layout on family D would read a third word that does not exist as a distinct table word on family D's die. Whatever data happens to be in that register would be folded into member/untag bits [10:8] on read, and written back on every read-modify-write cycle in rtl8365mb_vlan_4k_port_set(). Give family D its own two-word pack/unpack instead: add rtl8365mb_d_vlan_4k_read() and rtl8365mb_d_vlan_4k_write(). The shared code reaches them through the vlan_4k_read and vlan_4k_write pointers in struct rtl8365mb_family_info, so the pack/unpack code needs no is_d() check.
The two-word layout matches the vendor switch API for this chip family, which writes only 0x0510/0x0511 for a CVLAN entry.
Nothing points to them until the family D info is added together with the chip table entry in the last patch. Until then they are not static and are declared in rtl8365mb_vlan.h, so that the build does not warn about unused functions.
--- drivers/net/dsa/realtek/rtl8365mb_vlan.c | 95 +++++++++++++++++++++++- drivers/net/dsa/realtek/rtl8365mb_vlan.h | 4 + 2 files changed, 97 insertions(+), 2 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_vlan.c +93 -2
@@ -53,8 +53,11 @@#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_C_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)
@@ -66,6 +69,9 @@#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_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)
@@ -231,6 +237,45 @@ int rtl8365mb_c_vlan_4k_read(struct realtek_priv *priv, u16 vid,return 0 ; } +int rtl8365mb_d_vlan_4k_read (struct realtek_priv *priv,u16 vid, +struct rtl8365mb_vlan4k *vlan4k) +{ +u16 data[RTL8365MB_D_CVLAN_ENTRY_SIZE ]; +int val; +int ret; + + ret =rtl8365mb_table_query (priv,RTL8365MB_TABLE_CVLAN , +RTL8365MB_TABLE_OP_READ , &vid,0 ,0 , + data,RTL8365MB_D_CVLAN_ENTRY_SIZE ); +if (ret) +return ret; + +/* Unpack table entry */ +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_D0_UNTAG_MASK , data[0 ]); + vlan4k->untag =FIELD_PREP (RTL8365MB_CVLAN_UNTAG_LO_MASK , val); + + 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 ]); + +return 0 ; +} +int rtl8365mb_c_vlan_4k_write (struct realtek_priv *priv,const struct rtl8365mb_vlan4k *vlan4k) {
@@ -277,6 +322,38 @@ int rtl8365mb_c_vlan_4k_write(struct realtek_priv *priv, data, ARRAY_SIZE(data)); } +int rtl8365mb_d_vlan_4k_write (struct realtek_priv *priv, +const struct rtl8365mb_vlan4k *vlan4k) +{ +/* Unknown bits of word 1 are written as zero, same as the vendor +* API does for this chip family. +*/ +u16 data[RTL8365MB_D_CVLAN_ENTRY_SIZE ] = {0 }; +u16 vid; +int val; + +/* Pack table entry value */ + val =FIELD_GET (RTL8365MB_CVLAN_MBR_LO_MASK , vlan4k->member); + data[0 ] |=FIELD_PREP (RTL8365MB_CVLAN_ENTRY_D0_MBR_MASK , val); + + 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_D_CVLAN_ENTRY_D1_IVL_EN_MASK , + vlan4k->ivl_en); + 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. +*/ + + vid = vlan4k->vid; +return rtl8365mb_table_query (priv,RTL8365MB_TABLE_CVLAN , +RTL8365MB_TABLE_OP_WRITE , &vid,0 ,0 , + data,RTL8365MB_D_CVLAN_ENTRY_SIZE ); +} + static int rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port, const struct switchdev_obj_port_vlan *vlan,
@@ -314,7 +391,21 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port, vlan4k.untag |=BIT (port); else vlan4k.untag &= ~BIT(port); - vlan4k.ivl_en = true;/* always use Independent VLAN Learning */ + +/* Family C always uses IVL. On family D, IVL is on while any user +* port has VLAN filtering enabled, so that static entries match +* learned ones in a VLAN-unaware bridge (SVL). +*/ +if (!rtl8365mb_is_d (priv)) { + vlan4k.ivl_en = true; + }else { +struct dsa_port *dp; + + vlan4k.ivl_en = false; +dsa_switch_for_each_user_port (dp, ds) +if (dsa_port_is_vlan_filtering (dp)) + vlan4k.ivl_en = true; + } ret = fi->vlan_4k_write (priv, &vlan4k);if (ret) {
drivers/net/dsa/realtek/rtl8365mb_vlan.h +4 -0
@@ -24,6 +24,10 @@ int rtl8365mb_c_vlan_4k_read(struct realtek_priv *priv, u16 vid, struct rtl8365mb_vlan4k *vlan4k);int rtl8365mb_c_vlan_4k_write (struct realtek_priv *priv,const struct rtl8365mb_vlan4k *vlan4k); +int rtl8365mb_d_vlan_4k_read (struct realtek_priv *priv,u16 vid, +struct rtl8365mb_vlan4k *vlan4k); +int rtl8365mb_d_vlan_4k_write (struct realtek_priv *priv, +const struct rtl8365mb_vlan4k *vlan4k);int rtl8365mb_vlan_port_get_pvid (struct realtek_priv *priv,int port,u16 *pvid);
Signature · 1 line
2.53.0
Re: [PATCH net-next v10 07/12] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
Quoted 28 lines · Mieczyslaw Nalewaj
The 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.
IVL_EN(bit 3, versus bit 14 on family C) followsvlan4k->ivl_en. On family D,rtl8365mb_vlan_4k_port_set()enables it while any user port has VLAN filtering enabled (dsa_port_is_vlan_filtering()), so that static and learned FDB/MDB entries use the same key. Family C keeps IVL always enabled, as before.The stored
IVL_ENis refreshed on the next port_vlan_add/del for the VID, not on avlan_filteringchange.Reusing the three-word family C layout on family D would read a third word that does not exist as a distinct table word on family D's die. Whatever data happens to be in that register would be folded into member/untag bits [10:8] on read, and written back on every read-modify-write cycle in
rtl8365mb_vlan_4k_port_set(). Give family D its own two-word pack/unpack instead: addrtl8365mb_d_vlan_4k_read()andrtl8365mb_d_vlan_4k_write(). The shared code reaches them through thevlan_4k_readandvlan_4k_writepointers in structrtl8365mb_family_info, so the pack/unpack code needs nois_d()check.The two-word layout matches the vendor switch API for this chip family, which writes only 0x0510/0x0511 for a CVLAN entry.
Quoted 7 lines
Nothing points to them until the family D info is added together with the chip table entry in the last patch. Until then they are not static and are declared in
rtl8365mb_vlan.h, so that the build does not warn about unused functions.Tested-by Gustavo Foletto Mora <[email protected]>Signed-off-by Mieczyslaw Nalewaj <[email protected]>
Yours,
Linus Walleij
[email protected]
AI reviewRe: [PATCH net-next v10 07/12] net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
In reply to Mieczyslaw NalewajThank 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, the per-VID IVL_EN bit (CVLAN word 1, bit 3) is set only inside rtl8365mb_vlan_4k_port_set()…
--
net: dsa: realtek: rtl8365mb: set and get vlan 4k for family D
This adds two-word pack/unpack helpers for the family D CVLAN (4K VLAN) table entry, rtl8365mb_d_vlan_4k_read() and rtl8365mb_d_vlan_4k_write(). It also changes rtl8365mb_vlan_4k_port_set() so that on family D, IVL_EN is set only while some user port has VLAN filtering enabled. Family C keeps IVL always on.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +0
-0
[ ... ]
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +5
-1@@ -314,7 +391,21 @@ rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port, vlan4k.untag |=BIT (port); else vlan4k.untag &= ~BIT(port); - vlan4k.ivl_en = true;/* always use Independent VLAN Learning */ + +/* Family C always uses IVL. On family D, IVL is on while any user +* port has VLAN filtering enabled, so that static entries match +* learned ones in a VLAN-unaware bridge (SVL). +*/
drivers/net/dsa/realtek/rtl8365mb_vlan.c rtl8365mb_vlan_4k_port_set(struct dsa_switch *ds, int port, · line 408
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +10
-0+if (!rtl8365mb_is_d (priv)) { + vlan4k.ivl_en = true; + }else { +struct dsa_port *dp; + + vlan4k.ivl_en = false; +dsa_switch_for_each_user_port (dp, ds) +if (dsa_port_is_vlan_filtering (dp)) + vlan4k.ivl_en = true; + }
[Severity: Medium]
Can the per-VID IVL_EN bit go stale here when vlan_filtering changes?
The bit is only computed when a VLAN is added or deleted. rtl8365mb_port_vlan_filtering() in rtl8365mb_main.c changes ingress filtering, the transparent masks, the frame filter and the egress mode. It never rewrites the 4K table entries:
rtl8365mb_port_vlan_filtering() {
...
ret = rtl8365mb_port_set_ingress_filtering(priv, port, vlan_filtering);
...
ret = rtl8365mb_port_set_transparent(priv, port, dp->index,
!vlan_filtering);
...
}rtl8365mb_setup() sets ds->configure_vlan_while_not_filtering = true, so VLANs are programmed while the bridge is still VLAN-unaware. Take a common sequence:
ip link add br0 type bridge
ip link set lanX master br0
ip link set br0 type bridge vlan_filtering 1
VID 1 is written with IVL_EN=0 and keeps it after filtering is turned on. VIDs added after that get IVL_EN=1, so the table ends up with a mix of IVL and SVL VLANs inside one VLAN-aware bridge.
The reverse also happens. If filtering is turned off, the VLANs stay in IVL mode. Later in the series, rtl8365mb_d_l2_uc_to_data() and rtl8365mb_d_l2_mc_to_data() key vid 0 static entries with SVL (FID 0):
bool ivl = uc->key.ivl && uc->key.vid; u16 id = ivl ? uc->key.vid : uc->key.fid;
In both cases, would static FDB/MDB entries and learned entries end up with different keys? The commit message says this logic exists to prevent that.
The bridge join ordering seems to add a further case. In dsa_port_bridge_join(), switchdev_bridge_port_offload() replays the bridge VLANs through br_switchdev_vlan_replay() before dsa_port_switchdev_sync_attrs() sets dp->vlan_filtering. When the first port joins a bridge that already filters, are the replayed VLANs written with IVL_EN=0?
The policy is also switch-wide. With one VLAN-aware bridge and one VLAN-unaware bridge on the same switch, the unaware bridge's VIDs would be forced to IVL.
The commit message says:
The stored IVL_EN is refreshed on the next port_vlan_add/del for the VID, not on a vlan_filtering change.
Nothing in the driver triggers that refresh, so the final hardware state depends on the order of configuration steps. Should rtl8365mb_port_vlan_filtering(), or the family D join path, walk the existing 4K entries and rewrite IVL_EN?
This is still present at the end of the series, where the family D info is wired up in "net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB".
Quoted 3 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +0
-0ret = fi->vlan_4k_write (priv, &vlan4k);if (ret) {
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/d9da17af-f49e-4878-a8dd-59a8919e6930%40yahoo.com
PATCH v10 8/12 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.
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 | 9 + drivers/net/dsa/realtek/rtl8365mb_vlan.c | 205 ++++++++++++++++++++++- drivers/net/dsa/realtek/rtl8365mb_vlan.h | 1 + 3 files changed, 210 insertions(+), 5 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +9 -0
@@ -2420,6 +2420,15 @@ 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
@@ -31,6 +31,7 @@ int rtl8365mb_d_vlan_4k_write(struct realtek_priv *priv,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
[email protected]
AI reviewRe: [PATCH net-next v10 08/12] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The kernel-doc of the new rtl8365mb_vlan_port_reset_pvid() (drivers/net/dsa/realtek/rtl8365mb_vlan.c) gives two reasons that…
- [Low] net: dsa: realtek: PVID helpers use rtl8365mb_is_d() instead of family ops
--
net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D
This patch changes the rtl8365mb PVID helpers so that, on family D, they use a raw 12-bit VID in the per-port register at 0x0700 + port, because family D has no VLAN MC table. It also adds rtl8365mb_vlan_port_reset_pvid(), which rtl8365mb_vlan_setup() calls to clear the family D PVID registers at setup time. Family C behaviour is meant to stay the same.
Quoted 7 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0@@ -2420,6 +2420,15 @@ static int rtl8365mb_vlan_setup(struct dsa_switch *ds)int ret;
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_vlan_setup(struct dsa_switch *ds) · line 2431
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +9
-0dsa_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; + } +
[Severity: Low]
This still dispatches on rtl8365mb_is_d() inside the family C helpers. rtl8365mb_vlan_port_get_pvid() now holds two implementations that share nothing but the signature. rtl8365mb_vlan_pvid_port_set() and rtl8365mb_vlan_pvid_port_clear() each start with an early return into a _direct variant. rtl8365mb_vlan_port_reset_pvid() is a no-op unless the chip is family D.
Luiz raised these points on v7. He asked why rtl8365mb_vlan_setup() needs a separate reset helper when the PVID clear path already exists. He asked for rtl8365mb_vlan_port_get_pvid() not to lump both families into one if/else. He pointed out that VLANMC index 0 is a driver convention (VID 0) rather than a hardware neutral PVID. He also said the _direct suffix is not meaningful, and that family-specific implementations with the same signatures would be cleaner. I don't see these points addressed or answered in this version.
v10 already moved vlan_4k_read()/vlan_4k_write() and the l2_* entry converters behind callbacks in struct rtl8365mb_family_info. Could the PVID get, set, clear and setup-time reset go through the same family ops, with separate family C and family D functions? That would also avoid adding another rtl8365mb_is_d() branch to each of these helpers when the next family shows up.
If there is a reason to keep the branches as they are, could you reply to the v7 comments or note it in the commit message?
[ ... ]
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/dsa/realtek/rtl8365mb_vlan.c +0
-0@@ -773,14 +782,51 @@ int rtl8365mb_vlan_port_get_pvid(struct realtek_priv *priv, int port, u16 *pvid)
[ ... ]
Quoted 7 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +7
-0+/** +* rtl8365mb_vlan_port_reset_pvid() - Put a port's PVID in its neutral state +* @priv: realtek_priv pointer +* @port: the port number +* +* On family C the neutral PVID is VLANMC index 0, which is the reset value, so +* there is nothing to do. On family D the PVID is a raw VID in a per-port
drivers/net/dsa/realtek/rtl8365mb_vlan.c int rtl8365mb_vlan_port_get_pvid(struct realtek_priv *priv, int port, u16 *pvid) · line 823
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +10
-0+* register whose value after reset is not defined by the driver (it may come +* from the hardware default or from an EEPROM), so clear it to 0. +* +* Context: Can sleep. +* Return: 0 on success, or a negative error code on failure. +*/ +int rtl8365mb_vlan_port_reset_pvid (struct realtek_priv *priv,int port) +{ +if (!rtl8365mb_is_d (priv)) +return 0 ;
[Severity: Low]
The two halves of this kernel-doc don't seem to agree. Family D gets cleared because its value after reset "may come from the hardware default or from an EEPROM". Family C is assumed to be at VLANMC index 0 because that is "the reset value".
The file header in rtl8365mb_main.c says the EEPROM applies to every chip the driver handles:
* The EEPROM contains initial register values which the chip will read over I2C
* upon hardware reset. It is also possible to omit the EEPROM.
Both families also use the same PVID register block:
#define RTL8365MB_VLAN_PVID_CTRL_BASE 0x0700
...
#define RTL8365MB_D_VLAN_PVID_CTRL_BASE 0x0700
Is there something that prevents the family C MCIDX fields and VLANMC entries from being loaded from EEPROM as well?
Suppose a family C EEPROM programs a non-zero MC index and a matching VLANMC entry. Then rtl8365mb_vlan_setup() leaves it in place, even though its comment says "Start every port with the neutral PVID". Later:
rtl8365mb_port_vlan_filtering(ds, port, true, ...)
rtl8365mb_vlan_port_get_pvid()
-> returns the stale vlanmc.evid
accepted_frame = RTL8365MB_FRAME_TYPE_ANY_FRAME;Wouldn't that accept untagged frames on a port the driver never configured? The commit message gives this same case as the reason to clear family D.
Family C never cleared these registers before, so "No functional change for family C" is accurate. The final tree in the series still returns early here for family C.
Could this either write MC index 0 for family C too (index 0 is documented as the reserved neutral PVID), or explain in the comment why the family C PVID registers are known not to be loaded from EEPROM?
Quoted 5 lines
drivers/net/dsa/realtek/rtl8365mb_vlan.c +5
-0+ +return regmap_update_bits (priv->map, +RTL8365MB_D_VLAN_PVID_CTRL_REG (port), +RTL8365MB_D_VLAN_PVID_CTRL_MASK ,0 ); +}
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/d9da17af-f49e-4878-a8dd-59a8919e6930%40yahoo.com
Re: [PATCH net-next v10 08/12] net: dsa: realtek: rtl8365mb: use raw VID for PVID on family D
Hi,
Thanks for the review. Replying to the two PVID points.
Quoted 1 line
Is there something that prevents the family C MCIDX fields and VLANMC entries from being loaded from EEPROM as well?
Nothing prevents it in principle, but I would like to keep it out of this series. The series is meant to leave family C behaviour untouched, and the family C regression runs (RTL8367S on Archer AX55 v1) were done with the existing setup path. Writing the PVID registers of every family C port at setup would be a behaviour change on chips this series does not otherwise touch, so it is better done as a separate patch with its own justification and testing.
The family D case is different in kind: there the register holds a raw VID with no VLANMC indirection, so a non-zero hardware or EEPROM default is directly used as the PVID by rtl8365mb_vlan_port_get_pvid() and rtl8365mb_port_vlan_filtering(). I could not rule that out for a chip whose reset state I cannot verify against the vendor API, hence the explicit clear.
I agree the kernel-doc of rtl8365mb_c_vlan_port_reset_pvid() should not claim more than is known. I will reword it in the next revision to say that family C relies on the reset value of the register and does not defend against an EEPROM-preloaded MC index. If you or Luiz would rather have family C cleared as well, I can send that as a separate follow-up.
Quoted 1 line
Luiz raised these points on v7 ... I don't see these points addressed or answered in this version.
This is addressed in v11. The rtl8365mb_is_d() branches and the _direct helpers are gone, and PVID get/set/clear/reset now go through struct rtl8365mb_family_info, with separate family C (8/13) and family D (9/13) implementations. VLANMC index 0 is described as a driver convention, not as a hardware neutral PVID.
Best regards,
Mieczyslaw Nalewaj
PATCH v10 9/12 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.
On family D rtl8365mb_sds_probe_option() does not read the family C option register and always sets sds_supported, so the port 6 rate limits are raised for every family D chip. The only family D chip in this series, the RTL8367S-VB, has a SerDes interface on port 6.
Nothing on family D programs a SerDes rate for 10 and 100 Mbit/s:pcs_link_up() does nothing and the MAC force register only sets the MAC side. It is not known whether the SerDes follows that register, and only 1G SGMII and 2500base-x were tested, so do not advertise 10 and 100 Mbit/s on the SerDes port of family D.
--- drivers/net/dsa/realtek/rtl8365mb_main.c | 257 ++++++++++++++++++----- 1 file changed, 199 insertions(+), 58 deletions(-)
drivers/net/dsa/realtek/rtl8365mb_main.c +199 -58
@@ -264,7 +264,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)
@@ -286,6 +287,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
@@ -315,8 +317,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
@@ -334,7 +338,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. */
@@ -721,6 +740,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),
@@ -909,8 +943,9 @@ struct rtl8365mb_port {* @mib_lock: prevent concurrent reads of MIB counters * @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_supported: SerDes interface modes can be advertised: the tuning +* parameters match the chip option (family C), or the chip +* is family D, which does not use the option * * Private data for this driver. */
@@ -1323,7 +1358,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;
@@ -1341,10 +1377,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;
@@ -1354,7 +1393,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;
@@ -1394,6 +1435,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_is_d (priv)) { + 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];
@@ -1475,25 +1524,44 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,const struct rtl8365mb_jam_tbl_entry *sds_jam;const int id =RTL8365MB_SDS_EXT_INTERFACE_ID ;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_is_d (priv); +/* 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
@@ -1522,34 +1590,58 @@ 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) { +/* The register and field names follow the vendor RTL8367D API, +* whose SDS numbering differs from the SDS13 window used +* here. As in the vendor 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;
@@ -1559,27 +1651,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)
@@ -1604,18 +1701,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_is_d (priv); + +/* 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 ;
@@ -1626,6 +1732,23 @@ static void rtl8365mb_pcs_get_state(struct phylink_pcs *pcs,if (!state->link)return ; +if (is_d) { +if (state->interface ==PHY_INTERFACE_MODE_2500BASEX ) { + state->duplex =DUPLEX_FULL ; + state->speed =SPEED_2500 ; + }else { +/* Keep what phylink passed in, but never report the +* link up with an unknown speed: mac_link_up() cannot +* force the port with it. +*/ +if (state->speed ==SPEED_UNKNOWN ) + state->speed =SPEED_1000 ; +if (state->duplex ==DUPLEX_UNKNOWN ) + state->duplex =DUPLEX_FULL ; + } +return ; + } +/* The speed and duplex are forced; read them back from the values * programmed into the SerDes MISC register. */
@@ -1667,6 +1790,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_is_d (priv)) +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.
@@ -1931,10 +2060,17 @@ static void rtl8365mb_phylink_get_caps(struct dsa_switch *ds, int port, }if (extint->supported_interfaces &RTL8365MB_PHY_INTERFACE_MODE_SGMII && - mb->sds_supported) + mb->sds_supported) {__set_bit (PHY_INTERFACE_MODE_SGMII , config->supported_interfaces); +/* The SerDes rate is not programmed for 10 and 100 Mbit/s on +* family D, see rtl8365mb_pcs_link_up(). +*/ +if (rtl8365mb_is_d (priv)) + config->mac_capabilities &= ~(MAC_10 |MAC_100 ); + } +if (extint->supported_interfaces &RTL8365MB_PHY_INTERFACE_MODE_HSGMII && mb->sds_supported) { __set_bit(PHY_INTERFACE_MODE_2500BASEX,
@@ -2013,7 +2149,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)) {
@@ -2048,9 +2184,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)) {
@@ -2063,18 +2201,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_d_ext_config_forcemode(). */ -if (rtl8365mb_interface_is_serdes (interface)) { +if (rtl8365mb_interface_is_serdes (interface) && + !rtl8365mb_is_d (priv)) {u32 val =0 ;if (tx_pause)
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net-next v10 09/12] net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] rtl8365mb_pcs_config() now runs on family D too, but it still starts with the family C DW8051 hold sequence, applied on both…
--
net: dsa: realtek: rtl8365mb: add family D SDS13 PCS support
This commit extends the RTL8367S SGMII/HSGMII PCS code in rtl8365mb so it also works on family D switches. On family D the CPU SerDes sits behind the indexed SDS13 window, and the SDS_MISC layout is different. The family D paths only become reachable once the RTL8367S-VB chip entry is added later in the series.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0@@ -1475,25 +1524,44 @@ static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode,
[ ... ]
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_pcs_config(struct phylink_pcs *pcs, unsigned int neg_mode, · line 1567
Quoted 5 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +2
-0+ 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
[Severity: Low]
Are the DW8051 bits known to have the same meaning on family D?
With this patch, rtl8365mb_pcs_config() also runs on family D. It still starts with the family C DW8051 hold sequence, and that sequence has no is_d check:
ret = regmap_update_bits(priv->map, RTL8365MB_CHIP_RESET_REG,
RTL8365MB_CHIP_RESET_DW8051_MASK,
RTL8365MB_CHIP_RESET_DW8051_MASK);
...
ret = regmap_update_bits(priv->map, RTL8365MB_MISC_CFG0_REG,
RTL8365MB_MISC_CFG0_DW8051_EN_MASK, 0);This sets BIT(4) in CHIP_RESET (0x1322) and clears BIT(5) in MISC_CFG0 (0x130C). Both masks are defined only once, as family C registers, and neither has a family D note.
Most of the rest of rtl8365mb_pcs_config() is now split by family: the tuning table, the SDS index, the SDS_MISC layout, FIBER_CFG2 and DIGITAL_INTERFACE_SELECT. The comment on RTL8365MB_BYPASS_LINE_RATE_REG was also changed to say family D matches the vendor RTL8367D API. The DW8051 bits get no such note.
If either bit means something else on family D, every pcs_config() call for SerDes port 6 on the RTL8367S-VB would set an unknown bit in a reset register and clear an unknown config bit.
There is some evidence that the layouts match. rtl8365mb_reset_chip() already uses BIT(0) of 0x1322 on family D, and the series reports SGMII and 2500base-x tested on two family D boards.
Could the vendor RTL8367D API be checked for these two bits? Then either a comment like the one on the bypass register could be added, or the sequence could be limited to family C.
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/d9da17af-f49e-4878-a8dd-59a8919e6930%40yahoo.com
PATCH v10 10/12 net: dsa: realtek: rtl8365mb: refactor L2 MAC handling
In reply to Mieczyslaw NalewajAdd L2 MAC pack/unpack helpers and use them in the family C serializers instead of open-coding the byte packing, since the layout of the MAC address words is the same for both families. The now unused per-field MAC masks are dropped.
Rename the family C serializers to rtl8365mb_c_l2_*(), export them and reach them through function pointers in struct rtl8365mb_family_info, so that a following patch can add the family D layout without touching the family C code again.
No functional change.
--- drivers/net/dsa/realtek/rtl8365mb.h | 7 ++ drivers/net/dsa/realtek/rtl8365mb_l2.c | 125 +++++++++++------------ drivers/net/dsa/realtek/rtl8365mb_l2.h | 12 +++ drivers/net/dsa/realtek/rtl8365mb_main.c | 5 + 4 files changed, 83 insertions(+), 66 deletions(-)
drivers/net/dsa/realtek/rtl8365mb.h +7 -0
@@ -11,6 +11,8 @@ enum rtl8365mb_family {struct rtl8365mb_jam_tbl_entry ;struct rtl8365mb_vlan4k ; +struct rtl8365mb_l2_uc ; +struct rtl8365mb_l2_mc ;struct rtl8365mb_family_info {enum rtl8365mb_family family;
@@ -24,6 +26,11 @@ struct rtl8365mb_family_info { struct rtl8365mb_vlan4k *vlan4k);int (*vlan_4k_write)(struct realtek_priv *priv,const struct rtl8365mb_vlan4k *vlan4k); +size_t l2_entry_size; +void (*l2_data_to_uc)(const u16 *data,struct rtl8365mb_l2_uc *uc); +void (*l2_uc_to_data)(const struct rtl8365mb_l2_uc *uc,u16 *data); +void (*l2_data_to_mc)(const u16 *data,struct rtl8365mb_l2_mc *mc); +void (*l2_mc_to_data)(const struct rtl8365mb_l2_mc *mc,u16 *data); }; const struct rtl8365mb_family_info *
drivers/net/dsa/realtek/rtl8365mb_l2.c +59 -66
291 lines not on this page · raw message
drivers/net/dsa/realtek/rtl8365mb_l2.h +12 -0
@@ -12,6 +12,18 @@#include "realtek.h" +#define RTL8365MB_C_L2_ENTRY_SIZE 6 +/* Highest L2 entry size of any supported chip, used for sizing */ +#define RTL8365MB_L2_ENTRY_SIZE RTL8365MB_C_L2_ENTRY_SIZE + +struct rtl8365mb_l2_uc ; +struct rtl8365mb_l2_mc ; + +void rtl8365mb_c_l2_data_to_uc (const u16 *data,struct rtl8365mb_l2_uc *uc); +void rtl8365mb_c_l2_uc_to_data (const struct rtl8365mb_l2_uc *uc,u16 *data); +void rtl8365mb_c_l2_data_to_mc (const u16 *data,struct rtl8365mb_l2_mc *mc); +void rtl8365mb_c_l2_mc_to_data (const struct rtl8365mb_l2_mc *mc,u16 *data); +int rtl8365mb_l2_get_next_uc (struct realtek_priv *priv,u16 *addr,int port,struct realtek_fdb_entry *entry); int rtl8365mb_l2_add_uc(struct realtek_priv *priv, int port,
drivers/net/dsa/realtek/rtl8365mb_main.c +5 -0
@@ -793,6 +793,11 @@ static const struct rtl8365mb_family_info rtl8365mb_family_c = { .ext_config_forcemode = rtl8365mb_c_ext_config_forcemode, .vlan_4k_read = rtl8365mb_c_vlan_4k_read, .vlan_4k_write = rtl8365mb_c_vlan_4k_write, + .l2_entry_size = RTL8365MB_C_L2_ENTRY_SIZE, + .l2_data_to_uc = rtl8365mb_c_l2_data_to_uc, + .l2_uc_to_data = rtl8365mb_c_l2_uc_to_data, + .l2_data_to_mc = rtl8365mb_c_l2_data_to_mc, + .l2_mc_to_data = rtl8365mb_c_l2_mc_to_data, };/**
Signature · 1 line
2.53.0
Re: [PATCH net-next v10 10/12] net: dsa: realtek: rtl8365mb: refactor L2 MAC handling
Quoted 10 lines · Mieczyslaw Nalewaj
Add L2 MAC pack/unpack helpers and use them in the family C serializers instead of open-coding the byte packing, since the layout of the MAC address words is the same for both families. The now unused per-field MAC masks are dropped.
Rename the family C serializers to rtl8365mb_c_l2_*(), export them and reach them through function pointers in struct
rtl8365mb_family_info, so that a following patch can add the family D layout without touching the family C code again.
Quoted 5 lines
No functional change.
Tested-by Gustavo Foletto Mora <[email protected]>Tested-by Stanislaw Pal <[email protected]>Signed-off-by Mieczyslaw Nalewaj <[email protected]>
Yours,
Linus Walleij
PATCH v10 11/12 net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
In reply to Mieczyslaw NalewajThe L2 lookup table on family D switches (e.g. RTL8367S-VB) differs from family C in ways that make the current FDB/MDB code misbehave:
- An L2 entry is 5 words instead of 6, with a different field layout in words 3 and 4 (port, age, static and multicast member bits).
- There is no EFID and no per-bridge FDB isolation. The register at 0x0A32, used as the per-port EFID register on family C, is the LUT aging timer on family D, so writing an EFID there corrupts it.
- In the table access interface, the SPA field is 3 bits wide and the address register is 12 bits wide, with no address extension bit.
- Only ports 0..7 are present in the LUT and there is no FLUSH_PORT_EXT register.
- A VLAN-unaware bridge reaches the driver with VID 0, where the chip learns in SVL (IVL=0, FID=0). An entry programmed by DSA with IVL set gets a different key than the learned one for the same MAC, so both coexist and the learned one keeps winning.
Teach the table and L2 code about these differences. The L2 entry layout is selected through struct rtl8365mb_family_info, the other differences with rtl8365mb_is_d(). Family C behavior is unchanged.
Specifically:
- rtl8365mb_table: use the family D port mask and address width, and read the hit address from status bits [11:0].
- rtl8365mb_l2: add family D unicast/multicast entry (de)serializers, is selected through struct rtl8365mb_family_info. The IVL bit is set only for a non-zero VID, so VID 0 produces the SVL key (IVL=0, FID=0) and static unicast and multicast entries match the learned ones in a VLAN-unaware bridge. Entries read back with IVL=0 are reported with VID 0. Use age 6 for static unicast entries as the vendor code does. Look an entry up before deleting it, so that a missing entry is not allocated by the delete; as the key has no EFID, an entry found on another port or one that is not static is left alone.
- rtl8365mb_main: make port_set_efid() a no-op on family D, add a LUT init step that clears IPMC_HASH and BCAM_DISABLE and writes 3000 to the aging timer register, as dal_rtl8367d_l2_init() does in the vendor RTL8367D API (the unit is not documented), and do not advertise fdb_isolation. Without EFID the bridges cannot be told apart in the LUT, so offload only one bridge (max_num_bridges = 1). Further bridges fall back to software forwarding, and traffic between them is isolated by the port isolation masks only.
Without EFID, FID 0 is shared by every port that is not in a VLAN-aware
bridge: standalone ports, ports of bridges left to software and the offloaded VLAN-unaware bridge. There is no isolation between them in the LUT, only the port isolation masks. DSA does not program FDB/MDB entries of standalone ports here, as fdb_isolation is not set, so those ports get no host address filtering and their traffic goes to the CPU. A MAC learned in FID 0 on a bridge port may therefore also be hit by traffic from a standalone port, or from a software-bridged one, until the entry ages out or is replaced. This was observed by Gustavo Foletto
Mora: with the hosts on standalone ports of the same switch, unicast to a host was dropped once its MAC had been learned on the VLAN-unaware bridge side. With learning off on the bridge ports it was forwarded, and with a VLAN-aware bridge it did not happen.
Register layouts follow the vendor RTL8367D API; the code itself is an independent implementation.
Tested by Gustavo Foletto Mora on a TP-Link EX511 v2 (RTL8367S-VB, CPU port 6 over 1G SGMII to an IPQ5018). With a VLAN-aware bridge: per-VID FDB readback, static entries replacing learned ones and being deleted again on every port and VID, the same MAC as a static entry on two VIDs, MDB entries, VLAN add/delete churn, and moving a port to a second bridge (handled in software). With a VLAN-unaware bridge: a static entry with VID 0 replaces the learned one and traffic follows it, a static entry pointing at the ingress port drops the frames, the MAC relearns on the original port after the delete; traffic to the bridge MAC no longer floods to the WAN port; MDB entries limit the flood to the group members and the flood returns after the delete. Unicast and multicast forwarding were also checked with loopback cables between user ports (known and unknown unicast, static entries on the wrong port, MDB, 20k full-size pings without loss or port errors). MACs of foreign ports (a veth standing in for a Wi-Fi station) become entries on the CPU port through assisted learning. Real Wi-Fi stations, RGMII and 2500base-x were not covered by this test. Leaving a dynamic or foreign-port entry alone in l2_del_uc() was not exercised.
Nothing points to them until the family D info is added together with the chip table entry in the last patch. Until then they are not static and are declared in rtl8365mb_l2.h, so that the build does not warn about unused functions.
--- drivers/net/dsa/realtek/realtek.h | 4 +- drivers/net/dsa/realtek/rtl8365mb_l2.c | 124 +++++++++++++++++++++- drivers/net/dsa/realtek/rtl8365mb_l2.h | 6 ++ drivers/net/dsa/realtek/rtl8365mb_main.c | 55 +++++++++- drivers/net/dsa/realtek/rtl8365mb_table.c | 44 ++++++-- drivers/net/dsa/realtek/rtl83xx.c | 5 +- 6 files changed, 221 insertions(+), 17 deletions(-)
drivers/net/dsa/realtek/realtek.h +3 -1
@@ -71,7 +71,9 @@ struct realtek_priv {* create/update it. l2_(add|del)_uc uses a single table op and, * internally, it might not need this lock. However, altering FDB * may still collide, as well as l2_flush, with fdb_dump iterating -* over FDB. +* over FDB. On the RTL8367S-VB (family D), l2_del_uc also looks the +* entry up before writing it, as two separate table queries, so it +* does depend on this lock. */ struct mutex l2_lock;struct mii_bus *user_mii_bus;
drivers/net/dsa/realtek/rtl8365mb_l2.c +122 -2
148 lines not on this page · raw message
drivers/net/dsa/realtek/rtl8365mb_l2.h +6 -0
@@ -13,6 +13,7 @@#include "realtek.h" #define RTL8365MB_C_L2_ENTRY_SIZE 6 +#define RTL8365MB_D_L2_ENTRY_SIZE 5/* Highest L2 entry size of any supported chip, used for sizing */ #define RTL8365MB_L2_ENTRY_SIZE RTL8365MB_C_L2_ENTRY_SIZE
@@ -24,6 +25,11 @@ void rtl8365mb_c_l2_uc_to_data(const struct rtl8365mb_l2_uc *uc, u16 *data);void rtl8365mb_c_l2_data_to_mc (const u16 *data,struct rtl8365mb_l2_mc *mc);void rtl8365mb_c_l2_mc_to_data (const struct rtl8365mb_l2_mc *mc,u16 *data); +void rtl8365mb_d_l2_data_to_uc (const u16 *data,struct rtl8365mb_l2_uc *uc); +void rtl8365mb_d_l2_uc_to_data (const struct rtl8365mb_l2_uc *uc,u16 *data); +void rtl8365mb_d_l2_data_to_mc (const u16 *data,struct rtl8365mb_l2_mc *mc); +void rtl8365mb_d_l2_mc_to_data (const struct rtl8365mb_l2_mc *mc,u16 *data); +int rtl8365mb_l2_get_next_uc (struct realtek_priv *priv,u16 *addr,int port,struct realtek_fdb_entry *entry); int rtl8365mb_l2_add_uc(struct realtek_priv *priv, int port,
drivers/net/dsa/realtek/rtl8365mb_main.c +52 -3
85 lines not on this page · raw message
drivers/net/dsa/realtek/rtl8365mb_table.c +34 -10
90 lines not on this page · raw message
drivers/net/dsa/realtek/rtl83xx.c +4 -1
@@ -602,7 +602,8 @@ int rtl83xx_port_fdb_add(struct dsa_switch *ds, int port,/* Bridge ports use bridge.num as EFID, while standalone ports use * EFID 0. FDB entries for the CPU port follow the bridge EFID due -* to assisted learning. +* to assisted learning. Chips without an EFID in their L2 table +* (RTL8367S-VB) ignore it in l2_add_uc(). */ efid = db.type ==DSA_DB_BRIDGE ? db.bridge.num :0 ;
@@ -654,6 +655,8 @@ int rtl83xx_port_fdb_del(struct dsa_switch *ds, int port,/* * DSA_DB_BRIDGE ports use bridge number [1..N] as EFID, while * DSA_DB_PORT use the default EFID (0), not used by any bridge. +* Chips without an EFID in their L2 table (RTL8367S-VB) ignore it in +* l2_del_uc(). */ efid = db.type ==DSA_DB_BRIDGE ? db.bridge.num :0 ;
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [PATCH net-next v10 11/12] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider.
Critical: 0 · High: 2 · Medium: 0 · 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).
- [High] On family D, the new L2 serializers pick the LUT key with a rule that does not match the hardware.
- [High] On family D this patch makes rtl8365mb_port_set_efid() a no-op (rtl8365mb_main.c:2666), leaves ds->fdb_isolation false, and still…
- [Low] On family D, rtl8365mb_setup() sets ds->max_num_bridges = 1 to cap offload at one bridge, and the in-tree comment says "offload only…
--
net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
This adds family D (RTL8367S-VB) L2 entry serializers and table access differences, and makes the per-port EFID write a no-op on family D. It also adds a LUT init step and limits family D to one offloaded bridge without fdb_isolation.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_l2.c +0
-0
[ ... ]
Quoted 1 line
drivers/net/dsa/realtek/rtl8365mb_l2.c +0
-0@@ -240,6 +255,76 @@ void rtl8365mb_c_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc,
[ ... ]
drivers/net/dsa/realtek/rtl8365mb_l2.c void rtl8365mb_c_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc, · line 283
Quoted 9 lines
drivers/net/dsa/realtek/rtl8365mb_l2.c +9
-0+void rtl8365mb_d_l2_uc_to_data (const struct rtl8365mb_l2_uc *uc, +u16 *data) +{ +/* A VLAN-unaware bridge reaches us with VID 0. The chip learns such +* traffic in SVL (IVL=0, FID=0), so use the same key here, otherwise +* the static entry never matches the learned one. Only a real VID +* selects IVL. +*/ +bool ivl = uc->key.ivl && uc->key.vid;
[Severity: High]
Does this rule match the key the chip uses when it learns? The chip picks IVL or SVL from the IVL_EN bit of the classified VID's VLAN4K entry. On family D that bit is only written in rtl8365mb_vlan_4k_port_set():
} else {
struct dsa_port *dp;
vlan4k.ivl_en = false;
dsa_switch_for_each_user_port(dp, ds)
if (dsa_port_is_vlan_filtering(dp))
vlan4k.ivl_en = true;
}That value is a snapshot from the last time the VID's membership was written. rtl8365mb_port_vlan_filtering() does not rewrite existing VLAN4K entries, so IVL_EN and the vid != 0 rule used here can drift apart.
Three cases where they seem to disagree:
(a) The bridge is VLAN-aware and then vlan_filtering is set to 0. VID 1 keeps IVL_EN=1, so the chip keeps learning untagged traffic as IVL/VID 1. DSA now passes vid 0, which is serialized here as SVL/FID 0. Static FDB entries, host and assisted-learning entries on the CPU port, and MDB entries then get a different key than the learned one. That is the same VLAN-unaware bridge failure the commit message says is fixed.
(b) The bridge is VLAN-unaware and then vlan_filtering is set to 1. VID 1 stays SVL/FID 0, but DSA programs vid 1 with IVL set.
(c) A port joins a bridge that is already VLAN-aware. dsa_port_bridge_join() replays VLANs through switchdev_bridge_port_offload() before dsa_port_switchdev_sync_attrs() sets dp->vlan_filtering. If no other user port is filtering yet, those VIDs are written with IVL_EN=0. With a single switch port in the bridge, nothing rewrites them later.
In each case static, host and MDB entries would be ignored. Traffic to the bridge MAC floods, MDB entries do not limit flooding, and fdb_dump reports wrong VIDs.
The earlier "set and get vlan 4k for family D" patch already says IVL_EN "is refreshed on the next port_vlan_add/del for the VID, not on a vlan_filtering change".
Could the key be derived from the VID's VLAN4K IVL_EN/FID, or could IVL_EN be refreshed on every vlan_filtering change?
Quoted 1 line
drivers/net/dsa/realtek/rtl8365mb_l2.c +1
-0+u16 id = ivl ? uc->key.vid : uc->key.fid;
[ ... ]
drivers/net/dsa/realtek/rtl8365mb_l2.c void rtl8365mb_c_l2_mc_to_data(const struct rtl8365mb_l2_mc *mc, · line 316
Quoted 5 lines
drivers/net/dsa/realtek/rtl8365mb_l2.c +5
-0+void rtl8365mb_d_l2_mc_to_data (const struct rtl8365mb_l2_mc *mc, +u16 *data) +{ +/* Same as for unicast: VID 0 means a VLAN-unaware bridge, use SVL. */ +bool ivl = mc->key.ivl && mc->key.vid;
The same question applies here. MDB entries use the same vid != 0 rule, so they would also miss whenever IVL_EN for the VID does not match.
[ ... ]
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0
[ ... ]
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_port_pre_bridge_flags(struct dsa_switch *ds, int port, · line 2668
Quoted 8 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +4
-0@@ -2650,6 +2662,10 @@ static int rtl8365mb_port_pre_bridge_flags(struct dsa_switch *ds, int port,static int rtl8365mb_port_set_efid (struct realtek_priv *priv,int port,u32 efid) { +/* Family D has no EFID; see RTL8365MB_D_LUT_CFG2_REG. */ +if (rtl8365mb_is_d (priv)) +return 0 ; +
[Severity: High]
Without EFID and without fdb_isolation, one bridge is still offloaded with hardware learning. Standalone ports, ports of software-bridged bridges and the offloaded VLAN-unaware bridge then all share SVL FID 0. Can a MAC learned on a bridge port take over DA lookups for frames that enter a standalone port?
frame with SA=X enters a LAN bridge port
-> X is learned in FID 0 on that LAN port
frame with DA=X enters a standalone port (e.g. WAN)
-> LUT hit points at the LAN port
-> the standalone port's isolation mask (CPU only) drops itThe commit message describes this mechanism, and the tester saw it.
Since fdb_isolation is false, DSA installs no host entries for the MACs of standalone ports. So nothing pins, for example, a distinct WAN interface MAC to the CPU port.
Any host on an offloaded LAN port could forge a source MAC, such as the router's WAN MAC or the MAC of a host behind a standalone port, and keep refreshing it. Traffic for that MAC arriving on the standalone port would then be dropped until the entry ages out.
Documentation/networking/dsa/dsa.rst expects standalone ports to behave like independent NICs. It only lets them share a database because their entries always point to the CPU port.
Would it work to give the offloaded bridge's VLANs a private FID (the family D VLAN4K entry has a FID field)? Disabling hardware learning on family D bridge ports, or not offloading VLAN-unaware bridges, would be other options.
[ ... ]
Quoted 6 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-2@@ -3600,9 +3642,16 @@ static int rtl8365mb_setup(struct dsa_switch *ds) goto out_teardown_irq; ds->assisted_learning_on_cpu_port = true; - ds->fdb_isolation = true; -/* The EFID is 3 bits, but EFID 0 is reserved for standalone ports */
drivers/net/dsa/realtek/rtl8365mb_main.c static int rtl8365mb_setup(struct dsa_switch *ds) · line 3653
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +9
-1- ds->max_num_bridges =FIELD_MAX (RTL8365MB_EFID_MASK ); +if (!rtl8365mb_is_d (priv)) { + ds->fdb_isolation = true; +/* The EFID is 3 bits, but EFID 0 is reserved for standalone */ + ds->max_num_bridges =FIELD_MAX (RTL8365MB_EFID_MASK ); + }else { +/* No EFID, so bridges cannot be told apart in the LUT: offload +* only one, others fall back to software forwarding. +*/ + ds->max_num_bridges =1 ;
[Severity: Low]
Does max_num_bridges = 1 really guarantee that one bridge is offloaded on this switch? DSA takes bridge numbers from a system-wide bitmap, not a per-switch one. In dsa_bridge_num_get():
bridge_num = find_next_zero_bit(&dsa_fwd_offloading_bridges, DSA_MAX_NUM_OFFLOADING_BRIDGES, 1); if (bridge_num > max) return 0;
and in dsa_port_bridge_create():
bridge->num = dsa_bridge_num_get(br, ds->max_num_bridges);
if (ds->max_num_bridges && !bridge->num) {
NL_SET_ERR_MSG_MOD(extack,
"Range of offloadable bridges exceeded");
kfree(bridge);
return -EOPNOTSUPP;
}If another DSA switch in the system already holds bridge number 1, the first and only bridge on this family D switch gets number 2. It would then not be offloaded at all and would fall back to software forwarding.
Since fdb_isolation is false, db.bridge.num is zeroed in FDB/MDB notifications anyway, so the number only acts as this cap. Should the comment be reworded, or is a different way of limiting offload needed?
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +1
-0+ } ds->configure_vlan_while_not_filtering = true;
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/d9da17af-f49e-4878-a8dd-59a8919e6930%40yahoo.com
Re: [PATCH net-next v10 11/12] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
Subject: Re: [PATCH net-next v10 11/12] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
Hi,
Thanks for the review. Replying to the point about a MAC learned in FID 0 on an offloaded bridge port taking over lookups for frames entering a standalone port.
The mechanism is as described, and the commit message already documents it as a known limitation, including the case of a host on an offloaded port refreshing a forged entry. I would like to keep it as a documented limitation in this series, for these reasons:
1. Private FID for the offloaded bridge. The family D VLAN4K entry has a FID field, but it is only 2 bits wide, and I cannot confirm from the vendor API alone which FID the chip uses for learning when a standalone port or a VLAN-unaware bridge classifies traffic into a VLAN. Without fdb_isolation DSA also zeroes db.bridge.num, so fdb_add/del cannot tell bridge entries from port entries by EFID. Doing this properly needs hardware experiments that I cannot do reliably, and a wrong FID would break the VLAN-unaware case that was tested.
2. Disabling hardware learning on bridge ports. This does avoid the problem (it was the workaround in the report), but it turns all unicast on the offloaded bridge into flooding, which defeats the point of offloading.
3. Not offloading VLAN-unaware bridges. This removes the offload for the default OpenWrt br-lan configuration, which is the main use of the boards this series was tested on.
The impact is limited: an attacker needs a host on the local L2 segment of an offloaded port, and the effect is dropping traffic for one MAC on a standalone port until the entry ages out. Given max_num_bridges = 1 and no EFID, I think a documented limitation is the right trade-off for now. If someone with datasheet access can confirm how FID is used for learning on this chip, a per-bridge FID would be a reasonable follow-up.
Best regards,
Mieczyslaw Nalewaj
Re: [PATCH net-next v10 11/12] net: dsa: realtek: rtl8365mb: make L2/LUT access work on family D
Hi,
A follow-up to my reply about point 1 (a private FID for the offloaded bridge). I could not confirm it from the vendor API and said it needed hardware experiments. Gustavo Foletto Mora has now measured it on an RTL8367S-VB (EX511) with a development version that wrote FID 1 into the VLAN 4K entries of the bridge and used it in the FDB/MDB keys.
What the measurement showed:
- The chip learns with the FID of the 4K entry the frame is classified into (IVL_EN=0), and static entries written with that FID replace the learned ones.
- Standalone ports (PVID 0) do not land in that FID, so for a bridge whose ports have a PVID the collision is gone.
Why I still won’t do this in the next series:
- The FID comes only from a VLAN 4K entry. The default OpenWrt br-lan has no VLAN: its ports keep PVID 0, the driver writes no 4K entry for VID 0, and the bridge is looked up in FID 0, while the entries are written with FID 1. The keys then never match: a static entry no longer steers or drops (104 frames out of the uplink for 100 sent, 7 with the shared FID 0).
- With fdb_isolation, DSA installs the standalone ports' addresses as host entries in FID 0, which the plain bridge also looks up. Its frames to them go to the CPU with offload_fwd_mark set and are not forwarded by the software bridge: 0/50 on h1 -> h2, versus 50/50 with the shared FID.
So a private FID fixes the case with a PVID and breaks the more common one, which is worse than the documented limitation. The next revision will keep the shared FID 0 and the limitation as described in the commit message.
A complete solution would give the ports of a VLAN-unaware bridge a private PVID whose 4K entry carries the bridge FID, as mv88e6xxx does (MV88E6XXX_VID_BRIDGED / MV88E6XXX_FID_BRIDGED). That needs the PVID to follow vlan_filtering changes, and the handling of tagged frames with a VID that has no 4K entry is still unknown, so I would like to do it as a separate follow-up with testing on hardware.
Best regards,
Mieczyslaw Nalewaj
PATCH v10 12/12 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, which is described by rtl8365mb_family_d. This sets ds->num_ports, the IRQ domain size and the bound of every loop over priv->num_ports for this chip. rtl8365mb_family_d also selects the family D implementations added in the preceding patches: the force-mode configuration, the VLAN 4k accessors and the L2 entry (de)serializers.
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, and on a TP-Link EX511 v2 (RTL8367S-VB, CPU port over 1G SGMII to an IPQ5018). RGMII mode has not been tested. See the cover letter for details.
--- drivers/net/dsa/realtek/Kconfig | 3 +- drivers/net/dsa/realtek/rtl8365mb_main.c | 41 ++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 4 deletions(-)
drivers/net/dsa/realtek/Kconfig +2 -1
@@ -34,7 +34,8 @@ config NET_DSA_REALTEK_RTL8365MB depends on NET_DSA_REALTEK_SMI || NET_DSA_REALTEK_MDIO select NET_DSA_TAG_RTL8_4 help - Select to enable support for Realtek RTL8365MB-VC and RTL8367S. + Select to enable support for Realtek RTL8365MB-VC, RTL8367S and + RTL8367S-VB. config NET_DSA_REALTEK_RTL8366RB tristate "Realtek RTL8366RB switch driver"
drivers/net/dsa/realtek/rtl8365mb_main.c +38 -3
67 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This last patch in the series does not finish a cleanup that an earlier patch said was temporary.
--
net: dsa: realtek: rtl8365mb: add support for RTL8367S-VB
This patch adds the RTL8367S-VB (chip ID 0x6642, version 0x0010) to the rtl8365mb chip table as the first chip of family D. It also adds the rtl8365mb_family_d info structure, which hooks up the family D callbacks added earlier in the series.
Quoted 4 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +0
-0
[ ... ]
drivers/net/dsa/realtek/rtl8365mb_main.c static const struct rtl8365mb_family_info rtl8365mb_family_c = { · line 829
Quoted 10 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +6
-0@@ -812,6 +821,21 @@ static const struct rtl8365mb_family_info rtl8365mb_family_c = { .l2_mc_to_data = rtl8365mb_c_l2_mc_to_data, }; +static const struct rtl8365mb_family_info rtl8365mb_family_d = { + .family =RTL8365MB_FAMILY_D , + .num_ports =RTL8365MB_D_MAX_NUM_PORTS , + .jam_table = rtl8365mb_init_jam_8365mb_vc, + .jam_size =ARRAY_SIZE (rtl8365mb_init_jam_8365mb_vc), + .ext_config_forcemode = rtl8365mb_d_ext_config_forcemode,
[Severity: Low]
This isn't a bug, but now that this initializer exists, should rtl8365mb_d_ext_config_forcemode() become static?
The earlier patch "net: dsa: realtek: rtl8365mb: set speed for family D" says the non-static definition was meant to be temporary:
Nothing points to it until the family D info is added together with the chip table entry in the last patch. Until then it is not static and is declared in rtl8365mb.h, so that the build does not warn about an unused function.
After this patch the only user is this initializer, and it is in the same file as the definition:
drivers/net/dsa/realtek/rtl8365mb_main.c:
int rtl8365mb_d_ext_config_forcemode(struct realtek_priv *priv, int port,
bool link, int speed, int duplex, bool tx_pause, bool rx_pause)
The prototype is still in drivers/net/dsa/realtek/rtl8365mb.h:
int rtl8365mb_d_ext_config_forcemode(struct realtek_priv *priv, int port,
bool link, int speed, int duplex, bool tx_pause, bool rx_pause);
Could the function be made static, with a forward declaration next to the existing one for family C:
static int rtl8365mb_c_ext_config_forcemode(struct realtek_priv *priv, int port,
bool link, int speed, int duplex, ...
and the prototype dropped from rtl8365mb.h?
The family D VLAN 4k and L2 helpers should stay non-static, because they are defined in rtl8365mb_vlan.c and rtl8365mb_l2.c.
Quoted 2 lines
drivers/net/dsa/realtek/rtl8365mb_main.c +2
-0+ .vlan_4k_read = rtl8365mb_d_vlan_4k_read, + .vlan_4k_write = rtl8365mb_d_vlan_4k_write,
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/d9da17af-f49e-4878-a8dd-59a8919e6930%40yahoo.com