mirror of
https://github.com/openwrt/openwrt.git
synced 2026-11-27 14:41:12 +04:00
generic: 6.18: sync MxL862xx DSA switch driver
Support for the SerDes ports has been merged upstream, firmware update support has gained several robustness and recovery features. Trapping of link-local traffic has also been improved and now allows multicast snooping to work as expected. Add more sophisticated ready-state assessment to avoid racing of the driver with the firmware applying the initial default configuration. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
1 parent
3d902d07a9
commit
f0204d78e1
26 files changed
+3268
-1101
No files matched your search
+6
-3
@@ -1,7 +1,7 @@
|
||||
From 1ad83956d550a252fffc473a191dbe155c4a383e Mon Sep 17 00:00:00 2001
|
||||
From 272e1fab11a528ee67eb5751e2abf9d64e2d7a46 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 17:56:35 +0000
|
||||
Subject: [PATCH 01/19] net: dsa: mxl862xx: store firmware version for feature
|
||||
Date: Sat, 13 Jun 2026 04:07:11 +0100
|
||||
Subject: [PATCH 1/6] net: dsa: mxl862xx: store firmware version for feature
|
||||
gating
|
||||
|
||||
Query the firmware version at init (already done in wait_ready),
|
||||
@@ -13,6 +13,9 @@ bitwise shifts so that versions compare with natural ordering,
|
||||
independent of host endianness.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Link: https://patch.msgid.link/91a26a8ffeaa2ce1729f98347e93e779973976bb.1781319534.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 3 +++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.h | 23 +++++++++++++++++++++++
|
||||
+6
-3
@@ -1,7 +1,7 @@
|
||||
From eaf472bfc89692cd3cc5e0298c90791f4c1c3244 Mon Sep 17 00:00:00 2001
|
||||
From 47b20c3afd6912fc718869ed9bc0e83253006172 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 25 Mar 2026 21:39:30 +0000
|
||||
Subject: [PATCH 02/19] net: dsa: mxl862xx: move phylink stubs to
|
||||
Date: Sat, 13 Jun 2026 04:07:16 +0100
|
||||
Subject: [PATCH 2/6] net: dsa: mxl862xx: move phylink stubs to
|
||||
mxl862xx-phylink.c
|
||||
|
||||
Move the phylink MAC operations and get_caps callback from mxl862xx.c
|
||||
@@ -13,6 +13,9 @@ driver file.
|
||||
No functional change.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
|
||||
Link: https://patch.msgid.link/fb9336de94bef47a0834287cbca87954e5e4c795.1781319534.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/Makefile | 2 +-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.c | 51 +++++++++++++++++++++
|
||||
+6
-3
@@ -1,7 +1,7 @@
|
||||
From 483be884b2fdee28ac70458067c45a1369939144 Mon Sep 17 00:00:00 2001
|
||||
From 891fc80cae109f5f709273f03139473c448e0ed4 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Thu, 26 Mar 2026 01:50:00 +0000
|
||||
Subject: [PATCH 03/19] net: dsa: mxl862xx: move API macros to mxl862xx-host.h
|
||||
Date: Sat, 13 Jun 2026 04:07:23 +0100
|
||||
Subject: [PATCH 3/6] net: dsa: mxl862xx: move API macros to mxl862xx-host.h
|
||||
|
||||
Move the MXL862XX_API_WRITE, MXL862XX_API_READ and
|
||||
MXL862XX_API_READ_QUIET convenience macros from mxl862xx.c to
|
||||
@@ -13,6 +13,9 @@ mxl862xx-phylink.c also calls firmware commands.
|
||||
No functional change.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
|
||||
Link: https://patch.msgid.link/914f57931e79cc3932a9f32813465c08d29cf4bf.1781319534.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.h | 8 ++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 7 -------
|
||||
+228
-269
@@ -1,7 +1,7 @@
|
||||
From 376f6f71bd1f291e0adf471f2753c89ed7eac9e6 Mon Sep 17 00:00:00 2001
|
||||
From 46e2517566c69bc0859a85dfe76b6d2150ebfa97 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sun, 22 Mar 2026 00:57:44 +0000
|
||||
Subject: [PATCH 04/19] net: dsa: mxl862xx: add support for SerDes ports
|
||||
Date: Sat, 13 Jun 2026 04:07:29 +0100
|
||||
Subject: [PATCH 4/6] net: dsa: mxl862xx: add support for SerDes ports
|
||||
|
||||
The MxL862xx has two XPCS/SerDes interfaces (XPCS0 for ports 9-12,
|
||||
XPCS1 for ports 13-16). Each can operate in various single-lane modes
|
||||
@@ -10,6 +10,8 @@ QSGMII or 10G_QXGMII providing four sub-ports per interface.
|
||||
|
||||
Implement phylink PCS operations using the firmware's XPCS API:
|
||||
|
||||
- pcs_enable/pcs_disable: refcount the sub-ports sharing an XPCS
|
||||
and power it down once the last sub-port is released.
|
||||
- pcs_config: configure negotiation mode and CL37/SGMII advertising.
|
||||
- pcs_get_state: read link state and the link-partner ability word
|
||||
from firmware and decode using phylink's standard CL37, SGMII, and
|
||||
@@ -22,85 +24,62 @@ Register a PCS instance for each SerDes interface and
|
||||
QSGMII/10G_QXGMII sub-ports during setup. Advertise the supported
|
||||
interface modes in phylink_get_caps based on port number.
|
||||
|
||||
Firmware older than 1.0.84 lacks the XPCS API and instead configures
|
||||
the SerDes itself, using defaults stored in flash. mac_select_pcs()
|
||||
returns NULL in that case while the single-lane interface modes stay
|
||||
advertised, so a CPU port keeps working in the firmware-configured
|
||||
mode.
|
||||
|
||||
Lacking support for expressing PHY-side role modes in Linux only the
|
||||
MAC-side of SGMII, QSGMII, USXGMII and 10G_QXGMII are implemented for
|
||||
now.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://patch.msgid.link/736e4df02e4cb8c530c1670cbe7efac20b5d696d.1781319534.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-api.h | 302 ++++++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-api.h | 215 +++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-cmd.h | 9 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.c | 369 +++++++++++++++++++-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.c | 399 +++++++++++++++++++-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.h | 7 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 6 +-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.h | 31 ++
|
||||
6 files changed, 721 insertions(+), 3 deletions(-)
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 7 +-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.h | 34 ++
|
||||
6 files changed, 668 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -1366,4 +1366,306 @@ struct mxl862xx_rmon_port_cnt {
|
||||
@@ -1366,4 +1366,219 @@ struct mxl862xx_rmon_port_cnt {
|
||||
__le64 tx_good_bytes;
|
||||
} __packed;
|
||||
|
||||
+/**
|
||||
+ * enum mxl862xx_xpcs_if_mode - XPCS interface mode
|
||||
+ * @MXL862XX_XPCS_IF_SGMII: SGMII
|
||||
+ * @MXL862XX_XPCS_IF_1000BASEX: 1000BASE-X
|
||||
+ * @MXL862XX_XPCS_IF_2500BASEX: 2500BASE-X
|
||||
+ * @MXL862XX_XPCS_IF_USXGMII: USXGMII (single or quad)
|
||||
+ * @MXL862XX_XPCS_IF_10GBASER: 10GBASE-R
|
||||
+ * @MXL862XX_XPCS_IF_10GKR: 10GBASE-KR
|
||||
+ * @MXL862XX_XPCS_IF_5GBASER: 5GBASE-R
|
||||
+ * @MXL862XX_XPCS_IF_QSGMII: QSGMII
|
||||
+ */
|
||||
+enum mxl862xx_xpcs_if_mode {
|
||||
+ MXL862XX_XPCS_IF_SGMII = 0,
|
||||
+ MXL862XX_XPCS_IF_1000BASEX = 1,
|
||||
+ MXL862XX_XPCS_IF_2500BASEX = 2,
|
||||
+ MXL862XX_XPCS_IF_USXGMII = 3,
|
||||
+ MXL862XX_XPCS_IF_10GBASER = 4,
|
||||
+ MXL862XX_XPCS_IF_10GKR = 5,
|
||||
+ MXL862XX_XPCS_IF_5GBASER = 6,
|
||||
+ MXL862XX_XPCS_IF_QSGMII = 7,
|
||||
+};
|
||||
+/* XPCS interface mode, MXL862XX_XPCS_*_INTERFACE field values */
|
||||
+#define MXL862XX_XPCS_IF_SGMII 0
|
||||
+#define MXL862XX_XPCS_IF_1000BASEX 1
|
||||
+#define MXL862XX_XPCS_IF_2500BASEX 2
|
||||
+#define MXL862XX_XPCS_IF_USXGMII 3 /* single or quad */
|
||||
+#define MXL862XX_XPCS_IF_10GBASER 4
|
||||
+#define MXL862XX_XPCS_IF_10GKR 5 /* 10GBASE-KR */
|
||||
+#define MXL862XX_XPCS_IF_5GBASER 6
|
||||
+#define MXL862XX_XPCS_IF_QSGMII 7
|
||||
+
|
||||
+/**
|
||||
+ * enum mxl862xx_xpcs_neg_mode - PCS negotiation mode
|
||||
+ * @MXL862XX_XPCS_NEG_NONE: no inband negotiation
|
||||
+ * @MXL862XX_XPCS_NEG_INBAND_AN_OFF: inband selected but AN disabled
|
||||
+ * @MXL862XX_XPCS_NEG_INBAND_AN_ON: inband with AN enabled
|
||||
+ */
|
||||
+enum mxl862xx_xpcs_neg_mode {
|
||||
+ MXL862XX_XPCS_NEG_NONE = 0,
|
||||
+ MXL862XX_XPCS_NEG_INBAND_AN_OFF = 1,
|
||||
+ MXL862XX_XPCS_NEG_INBAND_AN_ON = 2,
|
||||
+};
|
||||
+/* PCS negotiation mode, MXL862XX_XPCS_CFG_NEG_MODE field values */
|
||||
+#define MXL862XX_XPCS_NEG_NONE 0 /* no inband negotiation */
|
||||
+#define MXL862XX_XPCS_NEG_INBAND_AN_OFF 1 /* inband, AN disabled */
|
||||
+#define MXL862XX_XPCS_NEG_INBAND_AN_ON 2 /* inband, AN enabled */
|
||||
+
|
||||
+/**
|
||||
+ * enum mxl862xx_xpcs_role - PCS protocol role
|
||||
+ * @MXL862XX_XPCS_ROLE_MAC: local end is MAC side (TX_CONFIG = 0)
|
||||
+ * @MXL862XX_XPCS_ROLE_PHY: local end is PHY side (TX_CONFIG = 1)
|
||||
+ *
|
||||
+ * Selects the role the XPCS plays in protocols that have an asymmetric
|
||||
+ * AN code word (Cisco SGMII / QSGMII / USXGMII). Drives
|
||||
+ * VR_MII_AN_CTRL.TX_CONFIG: 0 means the local end receives the partner's
|
||||
+ * AN word, 1 means it sources one. Ignored for symmetric protocols
|
||||
+ * (1000BASE-X, 2500BASE-X, 10GBASE-R/KR).
|
||||
+/*
|
||||
+ * PCS protocol role, MXL862XX_XPCS_CFG_ROLE field value. Selects the role
|
||||
+ * the XPCS plays in protocols with an asymmetric AN code word (Cisco SGMII
|
||||
+ * / QSGMII / USXGMII), driving VR_MII_AN_CTRL.TX_CONFIG: MAC means the
|
||||
+ * local end receives the partner's AN word, PHY means it sources one.
|
||||
+ * Ignored for symmetric protocols (1000BASE-X, 2500BASE-X, 10GBASE-R/KR).
|
||||
+ */
|
||||
+enum mxl862xx_xpcs_role {
|
||||
+ MXL862XX_XPCS_ROLE_MAC = 0,
|
||||
+ MXL862XX_XPCS_ROLE_PHY = 1,
|
||||
+};
|
||||
+#define MXL862XX_XPCS_ROLE_MAC 0 /* local end is MAC side */
|
||||
+#define MXL862XX_XPCS_ROLE_PHY 1 /* local end is PHY side */
|
||||
+
|
||||
+/**
|
||||
+ * enum mxl862xx_xpcs_usx_lane_mode - USXGMII lane mode
|
||||
+ * @MXL862XX_XPCS_USX_SINGLE: single USXGMII lane
|
||||
+ * @MXL862XX_XPCS_USX_QUAD: quad USXGMII (4 ports per lane)
|
||||
+ */
|
||||
+enum mxl862xx_xpcs_usx_lane_mode {
|
||||
+ MXL862XX_XPCS_USX_SINGLE = 0,
|
||||
+ MXL862XX_XPCS_USX_QUAD = 1,
|
||||
+};
|
||||
+/* USXGMII lane mode, MXL862XX_XPCS_*_USX_LANE_MODE field values */
|
||||
+#define MXL862XX_XPCS_USX_SINGLE 0 /* single USXGMII lane */
|
||||
+#define MXL862XX_XPCS_USX_QUAD 1 /* quad USXGMII, 4 ports/lane */
|
||||
+
|
||||
+/**
|
||||
+ * union mxl862xx_xpcs_an_word - XPCS AN code word, tagged by interface mode
|
||||
@@ -128,15 +107,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ } cl73;
|
||||
+} __packed;
|
||||
+
|
||||
+/**
|
||||
+ * enum mxl862xx_xpcs_duplex - PCS duplex mode
|
||||
+ * @MXL862XX_XPCS_DUPLEX_HALF: half duplex
|
||||
+ * @MXL862XX_XPCS_DUPLEX_FULL: full duplex
|
||||
+ */
|
||||
+enum mxl862xx_xpcs_duplex {
|
||||
+ MXL862XX_XPCS_DUPLEX_HALF = 0,
|
||||
+ MXL862XX_XPCS_DUPLEX_FULL = 1,
|
||||
+};
|
||||
+/* PCS duplex mode, MXL862XX_XPCS_*_DUPLEX field values */
|
||||
+#define MXL862XX_XPCS_DUPLEX_HALF 0
|
||||
+#define MXL862XX_XPCS_DUPLEX_FULL 1
|
||||
+
|
||||
+/**
|
||||
+ * enum mxl862xx_xpcs_loopback_mode - XPCS loopback mode
|
||||
@@ -154,105 +127,73 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ MXL862XX_XPCS_LB_PMA_PARALLEL = 4,
|
||||
+};
|
||||
+
|
||||
+/* Fields of mxl862xx_xpcs_pcs_cfg.mode */
|
||||
+#define MXL862XX_XPCS_CFG_PORT_ID GENMASK(1, 0)
|
||||
+#define MXL862XX_XPCS_CFG_INTERFACE GENMASK(7, 2)
|
||||
+#define MXL862XX_XPCS_CFG_NEG_MODE GENMASK(9, 8)
|
||||
+#define MXL862XX_XPCS_CFG_PERMIT_PAUSE BIT(10)
|
||||
+#define MXL862XX_XPCS_CFG_USX_LANE_MODE GENMASK(12, 11)
|
||||
+#define MXL862XX_XPCS_CFG_ROLE BIT(13)
|
||||
+#define MXL862XX_XPCS_CFG_USX_SUBPORT GENMASK(15, 14)
|
||||
+
|
||||
+/**
|
||||
+ * struct mxl862xx_xpcs_pcs_cfg - PCS configuration parameters
|
||||
+ * @port_id: XPCS port index (0-3)
|
||||
+ * @interface: PCS interface mode. See &enum mxl862xx_xpcs_if_mode
|
||||
+ * @neg_mode: PCS negotiation mode. See &enum mxl862xx_xpcs_neg_mode
|
||||
+ * @permit_pause: Allow pause to MAC
|
||||
+ * @usx_lane_mode: USXGMII lane mode.
|
||||
+ * See &enum mxl862xx_xpcs_usx_lane_mode
|
||||
+ * @role: PCS protocol role. See &enum mxl862xx_xpcs_role
|
||||
+ * @usx_subport: Sub-port (0-3) within the XPCS. Used by the firmware
|
||||
+ * to set MAC pause per sub-port; ignored for the
|
||||
+ * XPCS-wide bringup, which is idempotent across slots.
|
||||
+ * @mode: Packed interface and negotiation parameters, see
|
||||
+ * MXL862XX_XPCS_CFG_*. port_id is the XPCS port index (0-3);
|
||||
+ * interface is the PCS interface mode (MXL862XX_XPCS_IF_*);
|
||||
+ * neg_mode is the negotiation mode (MXL862XX_XPCS_NEG_*);
|
||||
+ * permit_pause allows pause to MAC; usx_lane_mode is the USXGMII
|
||||
+ * lane mode (MXL862XX_XPCS_USX_*); role is the protocol role
|
||||
+ * (MXL862XX_XPCS_ROLE_*); usx_subport is the sub-port (0-3) within
|
||||
+ * the XPCS -- despite the name it also identifies the QSGMII
|
||||
+ * sub-port -- used by the firmware to set MAC pause per sub-port
|
||||
+ * and ignored for the XPCS-wide bringup, which is idempotent across
|
||||
+ * slots.
|
||||
+ * @advertising: AN code word the local end transmits. The active union
|
||||
+ * member is selected by @interface (and, for the asymmetric
|
||||
+ * protocols, by @role). Ignored when the local end does
|
||||
+ * not transmit an AN word (role=MAC for SGMII/QSGMII/
|
||||
+ * USXGMII, 10GBASE-R, 5GBASE-R) or when @neg_mode is not
|
||||
+ * member is selected by the interface field (and, for the
|
||||
+ * asymmetric protocols, by role). Ignored when the local end
|
||||
+ * does not transmit an AN word (role=MAC for SGMII/QSGMII/
|
||||
+ * USXGMII, 10GBASE-R, 5GBASE-R) or when neg_mode is not
|
||||
+ * INBAND_AN_ON. Pass all-zero to keep the firmware default
|
||||
+ * advertisement.
|
||||
+ * @result: Firmware result. >0 means the host must follow with an AN
|
||||
+ * restart, 0 means no host follow-up is needed, <0 is an errno.
|
||||
+ */
|
||||
+struct mxl862xx_xpcs_pcs_cfg {
|
||||
+#ifdef __LITTLE_ENDIAN_BITFIELD
|
||||
+ u8 port_id:2;
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 neg_mode:2; /* enum mxl862xx_xpcs_neg_mode */
|
||||
+ u8 permit_pause:1;
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+ u8 role:1; /* enum mxl862xx_xpcs_role */
|
||||
+ u8 usx_subport:2;
|
||||
+#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 port_id:2;
|
||||
+ u8 usx_subport:2;
|
||||
+ u8 role:1; /* enum mxl862xx_xpcs_role */
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+ u8 permit_pause:1;
|
||||
+ u8 neg_mode:2; /* enum mxl862xx_xpcs_neg_mode */
|
||||
+#else
|
||||
+#error "Unknown bitfield endianness"
|
||||
+#endif
|
||||
+ __le16 mode;
|
||||
+ union mxl862xx_xpcs_an_word advertising;
|
||||
+ __le16 result;
|
||||
+} __packed;
|
||||
+
|
||||
+/* Fields of mxl862xx_xpcs_pcs_state.mode */
|
||||
+#define MXL862XX_XPCS_ST_PORT_ID GENMASK(1, 0)
|
||||
+#define MXL862XX_XPCS_ST_INTERFACE GENMASK(7, 2)
|
||||
+#define MXL862XX_XPCS_ST_USX_LANE_MODE GENMASK(9, 8)
|
||||
+#define MXL862XX_XPCS_ST_USX_SUBPORT GENMASK(11, 10)
|
||||
+#define MXL862XX_XPCS_ST_LINK BIT(12)
|
||||
+#define MXL862XX_XPCS_ST_AN_COMPLETE BIT(13)
|
||||
+#define MXL862XX_XPCS_ST_DUPLEX BIT(14)
|
||||
+#define MXL862XX_XPCS_ST_PCS_FAULT BIT(15)
|
||||
+#define MXL862XX_XPCS_ST_PAUSE GENMASK(17, 16)
|
||||
+#define MXL862XX_XPCS_ST_LP_EEE_CAP BIT(18)
|
||||
+#define MXL862XX_XPCS_ST_LP_EEE_CS_CAP BIT(19)
|
||||
+
|
||||
+/**
|
||||
+ * struct mxl862xx_xpcs_pcs_state - PCS link state
|
||||
+ * @port_id: XPCS port index (0-3) (input)
|
||||
+ * @interface: PCS interface mode (input).
|
||||
+ * See &enum mxl862xx_xpcs_if_mode
|
||||
+ * @usx_lane_mode: USX lane mode (input)
|
||||
+ * @usx_subport: USX sub-port 0-3 (input)
|
||||
+ * @link: Link up (1) / down (0) (output)
|
||||
+ * @an_complete: Auto-negotiation complete (output)
|
||||
+ * @duplex: Duplex mode (output). See &enum mxl862xx_xpcs_duplex
|
||||
+ * @pcs_fault: PCS fault (output)
|
||||
+ * @pause: Pause negotiation result, bit 0 symmetric, bit 1 asymmetric
|
||||
+ * (output)
|
||||
+ * @lp_eee_cap: Link partner supports EEE (output)
|
||||
+ * @lp_eee_cs_cap: Link partner supports EEE clock-stop (output)
|
||||
+ * @__rsv: reserved
|
||||
+ * @__pad: padding
|
||||
+ * @mode: Packed input parameters and firmware status, see
|
||||
+ * MXL862XX_XPCS_ST_*. The host writes port_id (XPCS port index 0-3),
|
||||
+ * interface (MXL862XX_XPCS_IF_*), usx_lane_mode
|
||||
+ * (MXL862XX_XPCS_USX_*) and usx_subport (0-3); the firmware fills in
|
||||
+ * link, an_complete, duplex (MXL862XX_XPCS_DUPLEX_*), pcs_fault,
|
||||
+ * pause (bit 0 symmetric, bit 1 asymmetric), lp_eee_cap and
|
||||
+ * lp_eee_cs_cap.
|
||||
+ * @speed: Resolved speed in Mbit/s (output)
|
||||
+ * @lpa: Link partner ability word (output). Same union as
|
||||
+ * &union mxl862xx_xpcs_an_word; the host picks the member based on
|
||||
+ * @interface.
|
||||
+ * the interface field.
|
||||
+ */
|
||||
+struct mxl862xx_xpcs_pcs_state {
|
||||
+#ifdef __LITTLE_ENDIAN_BITFIELD
|
||||
+ u8 port_id:2;
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+ u8 usx_subport:2;
|
||||
+ u8 link:1;
|
||||
+ u8 an_complete:1;
|
||||
+ u8 duplex:1; /* enum mxl862xx_xpcs_duplex */
|
||||
+ u8 pcs_fault:1;
|
||||
+ u8 pause:2;
|
||||
+ u8 lp_eee_cap:1;
|
||||
+ u8 lp_eee_cs_cap:1;
|
||||
+ u8 __rsv:4;
|
||||
+#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 port_id:2;
|
||||
+ u8 pcs_fault:1;
|
||||
+ u8 duplex:1; /* enum mxl862xx_xpcs_duplex */
|
||||
+ u8 an_complete:1;
|
||||
+ u8 link:1;
|
||||
+ u8 usx_subport:2;
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+ u8 __rsv:4;
|
||||
+ u8 lp_eee_cs_cap:1;
|
||||
+ u8 lp_eee_cap:1;
|
||||
+ u8 pause:2;
|
||||
+#else
|
||||
+#error "Unknown bitfield endianness"
|
||||
+#endif
|
||||
+ u8 __pad;
|
||||
+ __le32 mode;
|
||||
+ __le16 speed; /* Mbit/s */
|
||||
+ union mxl862xx_xpcs_an_word lpa;
|
||||
+} __packed;
|
||||
@@ -273,48 +214,46 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ __le16 result;
|
||||
+} __packed;
|
||||
+
|
||||
+/* Fields of mxl862xx_xpcs_an_restart.mode */
|
||||
+#define MXL862XX_XPCS_ANR_PORT_ID GENMASK(1, 0)
|
||||
+#define MXL862XX_XPCS_ANR_INTERFACE GENMASK(7, 2)
|
||||
+#define MXL862XX_XPCS_ANR_USX_LANE_MODE GENMASK(9, 8)
|
||||
+#define MXL862XX_XPCS_ANR_USX_SUBPORT GENMASK(11, 10)
|
||||
+
|
||||
+/**
|
||||
+ * struct mxl862xx_xpcs_an_restart - AN restart parameters
|
||||
+ * @port_id: XPCS port index (0-3)
|
||||
+ * @interface: PCS interface mode. See &enum mxl862xx_xpcs_if_mode
|
||||
+ * @usx_lane_mode: USX lane mode
|
||||
+ * @usx_subport: Sub-port (0-3) within the XPCS. Selects the lane
|
||||
+ * whose AN is restarted for QSGMII and QUSXGMII;
|
||||
+ * ignored by single-lane modes.
|
||||
+ * @__rsv: reserved
|
||||
+ * @mode: Packed input parameters, see MXL862XX_XPCS_ANR_*. port_id is the
|
||||
+ * XPCS port index (0-3); interface is the PCS interface mode
|
||||
+ * (MXL862XX_XPCS_IF_*); usx_lane_mode is the USX lane mode
|
||||
+ * (MXL862XX_XPCS_USX_*); usx_subport (0-3) selects the lane whose
|
||||
+ * AN is restarted for QSGMII and QUSXGMII and is ignored by
|
||||
+ * single-lane modes.
|
||||
+ * @result: Firmware result. 0 on success, <0 on error.
|
||||
+ *
|
||||
+ * Restarts auto-negotiation on a single sub-port of the XPCS. The
|
||||
+ * SERDES must already be configured.
|
||||
+ */
|
||||
+struct mxl862xx_xpcs_an_restart {
|
||||
+#ifdef __LITTLE_ENDIAN_BITFIELD
|
||||
+ u8 port_id:2;
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+ u8 usx_subport:2;
|
||||
+ u8 __rsv:4;
|
||||
+#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 port_id:2;
|
||||
+ u8 __rsv:4;
|
||||
+ u8 usx_subport:2;
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+#else
|
||||
+#error "Unknown bitfield endianness"
|
||||
+#endif
|
||||
+ __le16 mode;
|
||||
+ __le16 result;
|
||||
+} __packed;
|
||||
+
|
||||
+/* Fields of mxl862xx_xpcs_pcs_link_up.mode */
|
||||
+#define MXL862XX_XPCS_LU_PORT_ID GENMASK(1, 0)
|
||||
+#define MXL862XX_XPCS_LU_INTERFACE GENMASK(7, 2)
|
||||
+#define MXL862XX_XPCS_LU_DUPLEX BIT(8)
|
||||
+#define MXL862XX_XPCS_LU_USX_LANE_MODE GENMASK(10, 9)
|
||||
+#define MXL862XX_XPCS_LU_USX_SUBPORT GENMASK(12, 11)
|
||||
+
|
||||
+/**
|
||||
+ * struct mxl862xx_xpcs_pcs_link_up - PCS link-up parameters
|
||||
+ * @port_id: XPCS port index (0-3)
|
||||
+ * @interface: PCS interface mode. See &enum mxl862xx_xpcs_if_mode
|
||||
+ * @duplex: Duplex mode. See &enum mxl862xx_xpcs_duplex
|
||||
+ * @usx_lane_mode: USX lane mode (USXGMII only; ignored otherwise).
|
||||
+ * See &enum mxl862xx_xpcs_usx_lane_mode
|
||||
+ * @usx_subport: USX sub-port 0-3 (QUSXGMII only; ignored otherwise)
|
||||
+ * @__rsv0: reserved
|
||||
+ * @mode: Packed input parameters, see MXL862XX_XPCS_LU_*. port_id is the
|
||||
+ * XPCS port index (0-3); interface is the PCS interface mode
|
||||
+ * (MXL862XX_XPCS_IF_*); duplex is the duplex mode
|
||||
+ * (MXL862XX_XPCS_DUPLEX_*); usx_lane_mode is the USX lane mode
|
||||
+ * (USXGMII only, ignored otherwise, MXL862XX_XPCS_USX_*);
|
||||
+ * usx_subport (0-3) selects the sub-port for QUSXGMII and QSGMII
|
||||
+ * (despite the name) and is ignored otherwise.
|
||||
+ * @speed: Resolved speed in Mbit/s
|
||||
+ * @result: Firmware result. 0 on success, <0 is errno.
|
||||
+ *
|
||||
@@ -323,23 +262,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * PCS get-state, or from a fixed-link description).
|
||||
+ */
|
||||
+struct mxl862xx_xpcs_pcs_link_up {
|
||||
+#ifdef __LITTLE_ENDIAN_BITFIELD
|
||||
+ u8 port_id:2;
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 duplex:1; /* enum mxl862xx_xpcs_duplex */
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+ u8 usx_subport:2;
|
||||
+ u8 __rsv0:3;
|
||||
+#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
+ u8 interface:6; /* enum mxl862xx_xpcs_if_mode */
|
||||
+ u8 port_id:2;
|
||||
+ u8 __rsv0:3;
|
||||
+ u8 usx_subport:2;
|
||||
+ u8 usx_lane_mode:2; /* enum mxl862xx_xpcs_usx_lane_mode */
|
||||
+ u8 duplex:1; /* enum mxl862xx_xpcs_duplex */
|
||||
+#else
|
||||
+#error "Unknown bitfield endianness"
|
||||
+#endif
|
||||
+ __le16 mode;
|
||||
+ __le16 speed; /* Mbit/s */
|
||||
+ __le16 result;
|
||||
+} __packed;
|
||||
@@ -372,11 +295,12 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#endif /* __MXL862XX_CMD_H */
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
@@ -7,20 +7,382 @@
|
||||
@@ -7,20 +7,414 @@
|
||||
* Copyright (C) 2025 Daniel Golle <daniel@makrotopia.org>
|
||||
*/
|
||||
|
||||
+#include <linux/atomic.h>
|
||||
+#include <linux/bitfield.h>
|
||||
+#include <linux/mutex.h>
|
||||
#include <linux/phylink.h>
|
||||
#include <net/dsa.h>
|
||||
|
||||
@@ -403,6 +327,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ break;
|
||||
+ case 9:
|
||||
+ case 13:
|
||||
+ /* Advertised also on old firmware lacking the XPCS API:
|
||||
+ * there the SerDes runs in its flash-configured mode
|
||||
+ * without host control (mac_select_pcs returns NULL),
|
||||
+ * keeping the CPU port working.
|
||||
+ */
|
||||
+ __set_bit(PHY_INTERFACE_MODE_SGMII, config->supported_interfaces);
|
||||
+ __set_bit(PHY_INTERFACE_MODE_1000BASEX, config->supported_interfaces);
|
||||
+ __set_bit(PHY_INTERFACE_MODE_2500BASEX, config->supported_interfaces);
|
||||
@@ -471,7 +400,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * sub-port so pcs_disable powers the shared XPCS down only after
|
||||
+ * the last sub-port has been released.
|
||||
+ */
|
||||
+ atomic_inc(&mpcs->priv->serdes_refcount[mpcs->serdes_id]);
|
||||
+ mutex_lock(&mpcs->priv->serdes_lock);
|
||||
+ mpcs->priv->serdes_refcount[mpcs->serdes_id]++;
|
||||
+ mutex_unlock(&mpcs->priv->serdes_lock);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
@@ -482,15 +413,17 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct mxl862xx_xpcs_pcs_disable dis = {};
|
||||
+ struct mxl862xx_priv *priv = mpcs->priv;
|
||||
+
|
||||
+ /* The SerDes is shared across QSGMII/QUSXGMII sub-ports; only
|
||||
+ * power it down once the last active sub-port goes away.
|
||||
+ */
|
||||
+ if (!atomic_dec_and_test(&priv->serdes_refcount[mpcs->serdes_id]))
|
||||
+ return;
|
||||
+
|
||||
+ dis.port_id = mpcs->serdes_id;
|
||||
+
|
||||
+ MXL862XX_API_WRITE(priv, MXL862XX_XPCS_PCS_DISABLE, dis);
|
||||
+ /* The SerDes is shared across QSGMII/QUSXGMII sub-ports; only
|
||||
+ * power it down once the last active sub-port goes away. Hold
|
||||
+ * serdes_lock across the count and the power-down so a sibling
|
||||
+ * sub-port enable cannot race the transition to zero.
|
||||
+ */
|
||||
+ mutex_lock(&priv->serdes_lock);
|
||||
+ if (--priv->serdes_refcount[mpcs->serdes_id] == 0)
|
||||
+ MXL862XX_API_WRITE(priv, MXL862XX_XPCS_PCS_DISABLE, dis);
|
||||
+ mutex_unlock(&priv->serdes_lock);
|
||||
+}
|
||||
+
|
||||
+/* The XPCS firmware reports failures in the result field using its own
|
||||
@@ -517,10 +450,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct mxl862xx_pcs *mpcs = pcs_to_mxl862xx_pcs(pcs);
|
||||
+ struct mxl862xx_priv *priv = mpcs->priv;
|
||||
+ struct mxl862xx_xpcs_pcs_cfg cfg = {};
|
||||
+ int if_mode, ret;
|
||||
+ u16 adv;
|
||||
+
|
||||
+ mpcs->interface = interface;
|
||||
+ int if_mode, lane, ret, adv;
|
||||
+
|
||||
+ if_mode = mxl862xx_xpcs_if_mode(interface);
|
||||
+ if (if_mode < 0) {
|
||||
@@ -533,32 +463,33 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * firmware: every QSGMII/QUSXGMII sub-port may call pcs_config
|
||||
+ * and the firmware will skip the bringup if the requested mode
|
||||
+ * matches the cached one, then update MAC pause for the
|
||||
+ * sub-port indicated by @usx_subport.
|
||||
+ * sub-port indicated by @usx_subport. No serdes_lock is needed
|
||||
+ * here: the refcount held since pcs_enable keeps a sibling
|
||||
+ * pcs_disable from powering the XPCS down, and pcs_disable
|
||||
+ * invalidates the firmware's cached mode so the next pcs_config
|
||||
+ * redoes the bringup.
|
||||
+ */
|
||||
+ cfg.port_id = mpcs->serdes_id;
|
||||
+ cfg.usx_subport = mpcs->slot;
|
||||
+ cfg.usx_lane_mode = (interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+ cfg.interface = if_mode;
|
||||
+ cfg.neg_mode = mxl862xx_xpcs_neg_mode(neg_mode);
|
||||
+ cfg.role = MXL862XX_XPCS_ROLE_MAC;
|
||||
+ cfg.permit_pause = permit_pause_to_mac ? 1 : 0;
|
||||
+ lane = (interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+
|
||||
+ cfg.mode = cpu_to_le16(FIELD_PREP(MXL862XX_XPCS_CFG_PORT_ID,
|
||||
+ mpcs->serdes_id) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_CFG_USX_SUBPORT,
|
||||
+ mpcs->slot) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_CFG_USX_LANE_MODE, lane) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_CFG_INTERFACE, if_mode) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_CFG_NEG_MODE,
|
||||
+ mxl862xx_xpcs_neg_mode(neg_mode)) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_CFG_ROLE,
|
||||
+ MXL862XX_XPCS_ROLE_MAC) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_CFG_PERMIT_PAUSE,
|
||||
+ permit_pause_to_mac));
|
||||
+
|
||||
+ if (neg_mode & PHYLINK_PCS_NEG_INBAND) {
|
||||
+ switch (interface) {
|
||||
+ case PHY_INTERFACE_MODE_1000BASEX:
|
||||
+ case PHY_INTERFACE_MODE_2500BASEX:
|
||||
+ adv = linkmode_adv_to_mii_adv_x(advertising,
|
||||
+ ETHTOOL_LINK_MODE_1000baseX_Full_BIT);
|
||||
+ adv = phylink_mii_c22_pcs_encode_advertisement(interface,
|
||||
+ advertising);
|
||||
+ if (adv >= 0)
|
||||
+ cfg.advertising.cl37 = cpu_to_le16(adv);
|
||||
+ break;
|
||||
+ case PHY_INTERFACE_MODE_SGMII:
|
||||
+ case PHY_INTERFACE_MODE_QSGMII:
|
||||
+ cfg.advertising.cl37 = cpu_to_le16(ADVERTISE_SGMII);
|
||||
+ break;
|
||||
+ default:
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ret = MXL862XX_API_READ(priv, MXL862XX_XPCS_PCS_CONFIG, cfg);
|
||||
@@ -568,6 +499,8 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ ret = (s16)le16_to_cpu(cfg.result);
|
||||
+ if (ret < 0)
|
||||
+ return mxl862xx_xpcs_errno(ret);
|
||||
+
|
||||
+ mpcs->interface = interface;
|
||||
+ return ret > 0 ? 1 : 0;
|
||||
+}
|
||||
+
|
||||
@@ -578,25 +511,36 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct mxl862xx_pcs *mpcs = pcs_to_mxl862xx_pcs(pcs);
|
||||
+ struct mxl862xx_priv *priv = mpcs->priv;
|
||||
+ struct mxl862xx_xpcs_pcs_state st = {};
|
||||
+ int if_mode, ret;
|
||||
+ int if_mode, lane, ret;
|
||||
+ u32 mode;
|
||||
+ u16 bmsr;
|
||||
+
|
||||
+ if_mode = mxl862xx_xpcs_if_mode(state->interface);
|
||||
+ if (if_mode < 0)
|
||||
+ if (if_mode < 0) {
|
||||
+ state->link = false;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ st.port_id = mpcs->serdes_id;
|
||||
+ st.interface = if_mode;
|
||||
+ st.usx_subport = mpcs->slot;
|
||||
+ st.usx_lane_mode = (state->interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+ lane = (state->interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+
|
||||
+ st.mode = cpu_to_le32(FIELD_PREP(MXL862XX_XPCS_ST_PORT_ID,
|
||||
+ mpcs->serdes_id) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_ST_INTERFACE, if_mode) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_ST_USX_SUBPORT,
|
||||
+ mpcs->slot) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_ST_USX_LANE_MODE, lane));
|
||||
+
|
||||
+ ret = MXL862XX_API_READ(priv, MXL862XX_XPCS_PCS_GET_STATE, st);
|
||||
+ if (ret)
|
||||
+ if (ret) {
|
||||
+ state->link = false;
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ state->link = st.link && !st.pcs_fault;
|
||||
+ state->an_complete = st.an_complete;
|
||||
+ mode = le32_to_cpu(st.mode);
|
||||
+ state->link = FIELD_GET(MXL862XX_XPCS_ST_LINK, mode) &&
|
||||
+ !FIELD_GET(MXL862XX_XPCS_ST_PCS_FAULT, mode);
|
||||
+ state->an_complete = FIELD_GET(MXL862XX_XPCS_ST_AN_COMPLETE, mode);
|
||||
+
|
||||
+ switch (state->interface) {
|
||||
+ case PHY_INTERFACE_MODE_1000BASEX:
|
||||
@@ -635,17 +579,21 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct mxl862xx_pcs *mpcs = pcs_to_mxl862xx_pcs(pcs);
|
||||
+ struct mxl862xx_priv *priv = mpcs->priv;
|
||||
+ struct mxl862xx_xpcs_an_restart an = {};
|
||||
+ int if_mode;
|
||||
+ int if_mode, lane;
|
||||
+
|
||||
+ if_mode = mxl862xx_xpcs_if_mode(mpcs->interface);
|
||||
+ if (if_mode < 0)
|
||||
+ return;
|
||||
+
|
||||
+ an.port_id = mpcs->serdes_id;
|
||||
+ an.interface = if_mode;
|
||||
+ an.usx_subport = mpcs->slot;
|
||||
+ an.usx_lane_mode = (mpcs->interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+ lane = (mpcs->interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+
|
||||
+ an.mode = cpu_to_le16(FIELD_PREP(MXL862XX_XPCS_ANR_PORT_ID,
|
||||
+ mpcs->serdes_id) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_ANR_INTERFACE, if_mode) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_ANR_USX_SUBPORT,
|
||||
+ mpcs->slot) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_ANR_USX_LANE_MODE, lane));
|
||||
+
|
||||
+ MXL862XX_API_WRITE(priv, MXL862XX_XPCS_AN_RESTART, an);
|
||||
+}
|
||||
@@ -657,11 +605,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct mxl862xx_pcs *mpcs = pcs_to_mxl862xx_pcs(pcs);
|
||||
+ struct mxl862xx_xpcs_pcs_link_up lu = {};
|
||||
+ struct mxl862xx_priv *priv = mpcs->priv;
|
||||
+ int if_mode;
|
||||
+ int if_mode, lane, dup;
|
||||
+
|
||||
+ /* With inband-AN enabled (role=MAC), the XPCS auto-resolves
|
||||
+ * speed/duplex from the partner's AN word and the firmware
|
||||
+ * short-circuits link_up. Skip the firmware round-trip, same
|
||||
+ * short-circuits link_up. Skip the firmware round-trip, same
|
||||
+ * as pcs-mtk-lynxi.
|
||||
+ */
|
||||
+ if (neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED)
|
||||
@@ -671,13 +619,18 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ if (if_mode < 0)
|
||||
+ return;
|
||||
+
|
||||
+ lu.port_id = mpcs->serdes_id;
|
||||
+ lu.interface = if_mode;
|
||||
+ lu.usx_subport = mpcs->slot;
|
||||
+ lu.usx_lane_mode = (interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+ lu.duplex = (duplex == DUPLEX_FULL) ? MXL862XX_XPCS_DUPLEX_FULL :
|
||||
+ MXL862XX_XPCS_DUPLEX_HALF;
|
||||
+ lane = (interface == PHY_INTERFACE_MODE_10G_QXGMII) ?
|
||||
+ MXL862XX_XPCS_USX_QUAD : MXL862XX_XPCS_USX_SINGLE;
|
||||
+ dup = (duplex == DUPLEX_FULL) ? MXL862XX_XPCS_DUPLEX_FULL :
|
||||
+ MXL862XX_XPCS_DUPLEX_HALF;
|
||||
+
|
||||
+ lu.mode = cpu_to_le16(FIELD_PREP(MXL862XX_XPCS_LU_PORT_ID,
|
||||
+ mpcs->serdes_id) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_LU_INTERFACE, if_mode) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_LU_USX_SUBPORT,
|
||||
+ mpcs->slot) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_LU_USX_LANE_MODE, lane) |
|
||||
+ FIELD_PREP(MXL862XX_XPCS_LU_DUPLEX, dup));
|
||||
+ lu.speed = cpu_to_le16(speed);
|
||||
+
|
||||
+ MXL862XX_API_WRITE(priv, MXL862XX_XPCS_PCS_LINK_UP, lu);
|
||||
@@ -745,11 +698,13 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct mxl862xx_priv *priv = dp->ds->priv;
|
||||
+ int port = dp->index;
|
||||
+
|
||||
+ if (!MXL862XX_FW_VER_MIN(priv, 1, 0, 84))
|
||||
+ return NULL;
|
||||
+
|
||||
+ switch (port) {
|
||||
+ case 9 ... 16:
|
||||
+ if (!MXL862XX_FW_VER_MIN(priv, 1, 0, 84)) {
|
||||
+ dev_warn_once(dp->ds->dev,
|
||||
+ "SerDes PCS unsupported on old firmware.\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ return &priv->serdes_ports[port - 9].pcs;
|
||||
+ default:
|
||||
+ return NULL;
|
||||
@@ -757,7 +712,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
static void mxl862xx_phylink_mac_config(struct phylink_config *config,
|
||||
@@ -48,4 +410,5 @@ const struct phylink_mac_ops mxl862xx_ph
|
||||
@@ -48,4 +442,5 @@ const struct phylink_mac_ops mxl862xx_ph
|
||||
.mac_config = mxl862xx_phylink_mac_config,
|
||||
.mac_link_down = mxl862xx_phylink_mac_link_down,
|
||||
.mac_link_up = mxl862xx_phylink_mac_link_up,
|
||||
@@ -792,10 +747,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
ret = mxl862xx_reset(priv);
|
||||
if (ret)
|
||||
@@ -632,6 +632,10 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
@@ -632,6 +632,11 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
+ mutex_init(&priv->serdes_lock);
|
||||
+ for (i = 0; i < ARRAY_SIZE(priv->serdes_ports); i++)
|
||||
+ mxl862xx_setup_pcs(priv, &priv->serdes_ports[i],
|
||||
+ i + MXL862XX_FIRST_SERDES_PORT);
|
||||
@@ -842,7 +798,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* struct mxl862xx_fw_version - firmware version for comparison and display
|
||||
* @major: firmware major version
|
||||
* @minor: firmware minor version
|
||||
@@ -280,6 +303,12 @@ struct mxl862xx_fw_version {
|
||||
@@ -280,6 +303,14 @@ struct mxl862xx_fw_version {
|
||||
* flooding)
|
||||
* @fw_version: cached firmware version, populated at probe and
|
||||
* compared with MXL862XX_FW_VER_MIN()
|
||||
@@ -850,17 +806,20 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * 10G_QXGMII or QSGMII
|
||||
+ * @serdes_refcount: per-XPCS count of sub-ports enabled by phylink;
|
||||
+ * pcs_disable powers an XPCS down when the count
|
||||
+ * reaches zero. atomic_t so concurrent sub-port
|
||||
+ * enable/disable need no extra lock.
|
||||
+ * reaches zero. Protected by @serdes_lock.
|
||||
+ * @serdes_lock: serializes the @serdes_refcount transitions with
|
||||
+ * the XPCS power-down so a sibling sub-port enable
|
||||
+ * cannot race a power-down to zero
|
||||
* @ports: per-port state, indexed by switch port number
|
||||
* @bridges: maps DSA bridge number to firmware bridge ID;
|
||||
* zero means no firmware bridge allocated for that
|
||||
@@ -298,6 +327,8 @@ struct mxl862xx_priv {
|
||||
@@ -298,6 +329,9 @@ struct mxl862xx_priv {
|
||||
unsigned long flags;
|
||||
u16 drop_meter;
|
||||
struct mxl862xx_fw_version fw_version;
|
||||
+ struct mxl862xx_pcs serdes_ports[8];
|
||||
+ atomic_t serdes_refcount[2];
|
||||
+ int serdes_refcount[2];
|
||||
+ struct mutex serdes_lock;
|
||||
struct mxl862xx_port ports[MXL862XX_MAX_PORTS];
|
||||
u16 bridges[MXL862XX_MAX_BRIDGES + 1];
|
||||
u16 evlan_ingress_size;
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
From 63bd7556b0530bf380b2bf77c09e04494bb5bd0f Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Fri, 19 Jun 2026 04:39:25 +0100
|
||||
Subject: [PATCH 5/6] net: dsa: mxl862xx: avoid unaligned 16-bit access in
|
||||
api_wrap
|
||||
|
||||
The MXL862XX_API_* macros pass the address of a stack-allocated, __packed
|
||||
firmware-ABI struct to mxl862xx_api_wrap() as a void *. The struct has an
|
||||
alignment of 1, so the compiler is free to place it at an odd address.
|
||||
|
||||
mxl862xx_api_wrap() reinterprets that buffer as a __le16 * and accesses it
|
||||
with data[i], for which the compiler assumes the natural 2-byte alignment
|
||||
of __le16 and emits aligned 16-bit loads/stores (e.g. lhu/sh on MIPS).
|
||||
When the buffer lands on an odd address these fault on architectures that
|
||||
do not support unaligned access, such as MIPS32.
|
||||
|
||||
-Waddress-of-packed-member does not catch this: the packed origin is
|
||||
laundered through the void * parameter, so the cast inside api_wrap looks
|
||||
alignment-safe to the compiler and no warning is emitted.
|
||||
|
||||
Use get_unaligned_le16()/put_unaligned_le16() for the three 16-bit word
|
||||
accesses. The byte accesses (*(u8 *)&data[i], crc16()) are already safe
|
||||
and are left unchanged.
|
||||
|
||||
Link: https://sashiko.dev/#/patchset/cover.1781319534.git.daniel%40makrotopia.org?part=4
|
||||
Fixes: 23794bec1cb6 ("net: dsa: add basic initial driver for MxL862xx switches")
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://patch.msgid.link/599327521db465a534d277de53ab9b6cac01928b.1781702256.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.c | 7 ++++---
|
||||
1 file changed, 4 insertions(+), 3 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <linux/crc16.h>
|
||||
#include <linux/iopoll.h>
|
||||
#include <linux/limits.h>
|
||||
+#include <linux/unaligned.h>
|
||||
#include <net/dsa.h>
|
||||
#include "mxl862xx.h"
|
||||
#include "mxl862xx-host.h"
|
||||
@@ -349,7 +350,7 @@ int mxl862xx_api_wrap(struct mxl862xx_pr
|
||||
* zero words individually.
|
||||
*/
|
||||
for (i = 0, zeros = 0; i < size / 2 && zeros < RST_DATA_THRESHOLD; i++)
|
||||
- if (!data[i])
|
||||
+ if (!get_unaligned_le16(&data[i]))
|
||||
zeros++;
|
||||
|
||||
if (zeros < RST_DATA_THRESHOLD && (size & 1) && !*(u8 *)&data[i])
|
||||
@@ -395,7 +396,7 @@ int mxl862xx_api_wrap(struct mxl862xx_pr
|
||||
*/
|
||||
val = *(u8 *)&data[i] | ((crc & 0xff) << 8);
|
||||
} else {
|
||||
- val = le16_to_cpu(data[i]);
|
||||
+ val = get_unaligned_le16(&data[i]);
|
||||
}
|
||||
|
||||
/* After RST_DATA, skip zero data words as the registers
|
||||
@@ -453,7 +454,7 @@ int mxl862xx_api_wrap(struct mxl862xx_pr
|
||||
*(uint8_t *)&data[i] = ret & 0xff;
|
||||
crc = (ret >> 8) & 0xff;
|
||||
} else {
|
||||
- data[i] = cpu_to_le16((u16)ret);
|
||||
+ put_unaligned_le16((u16)ret, &data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
From 49d72a09ea975a042294e52e93b37fdf9245b937 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Fri, 19 Jun 2026 04:40:14 +0100
|
||||
Subject: [PATCH 6/6] net: dsa: mxl862xx: fix use-after-free of DSA ports in
|
||||
crc_err_work
|
||||
|
||||
Upon an MDIO CRC error mxl862xx_crc_err_work_fn() walks the DSA ports
|
||||
and closes the CPU port conduits:
|
||||
|
||||
dsa_switch_for_each_cpu_port(dp, priv->ds)
|
||||
dev_close(dp->conduit);
|
||||
|
||||
mxl862xx_remove() unregisters the switch before cancelling this work:
|
||||
|
||||
set_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags);
|
||||
cancel_delayed_work_sync(&priv->stats_work);
|
||||
dsa_unregister_switch(ds);
|
||||
mxl862xx_host_shutdown(priv);
|
||||
|
||||
dsa_unregister_switch() frees the dsa_port objects. If a CRC error
|
||||
schedules the work during teardown it can run after the ports have been
|
||||
freed and dereference freed memory.
|
||||
|
||||
Guard the port walk with MXL862XX_FLAG_WORK_STOPPED, which is already set
|
||||
before dsa_unregister_switch(). DSA tears the ports down under
|
||||
rtnl_lock(), so checking the flag under rtnl_lock() means the work either
|
||||
runs before teardown and sees valid ports, or runs afterwards, observes
|
||||
the flag and skips the walk. This mirrors the host_flood_work handler,
|
||||
which skips torn-down ports under rtnl_lock().
|
||||
|
||||
Link: https://sashiko.dev/#/patchset/cover.1780968180.git.daniel%40makrotopia.org?part=2
|
||||
Fixes: a319d0c8c8ce ("net: dsa: mxl862xx: add CRC for MDIO communication")
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Link: https://patch.msgid.link/5e55169926c02f2b914e5ada529d7453b943cda4.1781702256.git.daniel@makrotopia.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.c | 11 ++++++-----
|
||||
1 file changed, 6 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
@@ -41,12 +41,13 @@ static void mxl862xx_crc_err_work_fn(str
|
||||
crc_err_work);
|
||||
struct dsa_port *dp;
|
||||
|
||||
- dev_warn(&priv->mdiodev->dev,
|
||||
- "MDIO CRC error detected, shutting down all ports\n");
|
||||
-
|
||||
rtnl_lock();
|
||||
- dsa_switch_for_each_cpu_port(dp, priv->ds)
|
||||
- dev_close(dp->conduit);
|
||||
+ if (!test_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags)) {
|
||||
+ dev_warn(&priv->mdiodev->dev,
|
||||
+ "MDIO CRC error detected, shutting down all ports\n");
|
||||
+ dsa_switch_for_each_cpu_port(dp, priv->ds)
|
||||
+ dev_close(dp->conduit);
|
||||
+ }
|
||||
rtnl_unlock();
|
||||
|
||||
clear_bit(MXL862XX_FLAG_CRC_ERR, &priv->flags);
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
From 6758d67ecec231a370f24a7da664f1eb3061bc23 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 12 Aug 2026 22:15:45 +0100
|
||||
Subject: [PATCH] net: dsa: mxl862xx: wait for firmware boot-time configuration
|
||||
to finish
|
||||
|
||||
The switch firmware answers MDIO API commands long before its
|
||||
application thread has finished applying the built-in boot-time
|
||||
default configuration. The management interface is brought up as
|
||||
part of the firmware's device initialization, while the application
|
||||
thread afterwards reconfigures bridge ports 0..16, meters, WRED
|
||||
thresholds, PCE rules and VLAN resources, and only then enables
|
||||
ingress SDMA on all ports as the very last step of its default
|
||||
configuration.
|
||||
|
||||
mxl862xx_wait_ready() declares the switch ready as soon as
|
||||
FW_VERSION and CFGGET succeed, typically ~2.4s after reset. All
|
||||
configuration issued by the driver between that point and the
|
||||
firmware's final SDMA enable races the firmware's own writes and may
|
||||
be silently overwritten. Depending on boot timing this can leave the
|
||||
switch in a state where every frame received from the conduit is
|
||||
dropped by the ingress filter (RxFilteredPkts on the CPU port
|
||||
increments in lockstep with conduit TX) while the reverse direction
|
||||
keeps working. The state persists until the race is re-run with
|
||||
better luck. Observed on a MxL86252C in roughly half of the boots
|
||||
of a BananaPi BPI-R4 Pro 8X board [1].
|
||||
|
||||
Gate readiness on the firmware's final configuration step instead:
|
||||
poll the SDMA port control register of logical port 0 via the
|
||||
RegisterGet API until the port enable bit is set. The reset issued
|
||||
right before waiting clears that bit on all ports, and the driver
|
||||
does not touch any port state until after mxl862xx_wait_ready() has
|
||||
returned, so within this window the bit can only have been set by
|
||||
the firmware application completing its boot-time configuration.
|
||||
Logical port 0 is the switch-internal CPU port which the driver
|
||||
itself never enables.
|
||||
|
||||
[1] https://github.com/openwrt/openwrt/pull/24642#issuecomment-5270711174
|
||||
|
||||
Fixes: 23794bec1cb6 ("net: dsa: add basic initial driver for MxL862xx switches")
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-api.h | 13 +++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-cmd.h | 1 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 20 +++++++++++++++++++-
|
||||
3 files changed, 33 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -21,6 +21,19 @@ struct mdio_relay_data {
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
+ * struct mxl862xx_register - Register access parameter to directly read
|
||||
+ * internal registers
|
||||
+ * @addr: Register address offset for read access
|
||||
+ * @data: Value read from the register address
|
||||
+ *
|
||||
+ * Used for direct register read operations.
|
||||
+ */
|
||||
+struct mxl862xx_register {
|
||||
+ __le16 addr;
|
||||
+ __le16 data;
|
||||
+} __packed;
|
||||
+
|
||||
+/**
|
||||
* struct mxl862xx_register_mod - Register access parameter to directly
|
||||
* modify internal registers
|
||||
* @addr: Register address offset for modification
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -26,6 +26,7 @@
|
||||
#define SYS_MISC_MAGIC 0x1900
|
||||
#define MXL862XX_XPCS_MAGIC 0x1a00
|
||||
|
||||
+#define MXL862XX_COMMON_REGISTERGET (MXL862XX_COMMON_MAGIC + 0x1)
|
||||
#define MXL862XX_COMMON_CFGGET (MXL862XX_COMMON_MAGIC + 0x9)
|
||||
#define MXL862XX_COMMON_CFGSET (MXL862XX_COMMON_MAGIC + 0xa)
|
||||
#define MXL862XX_COMMON_REGISTERMOD (MXL862XX_COMMON_MAGIC + 0x11)
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -227,6 +227,7 @@ static int mxl862xx_wait_ready(struct ds
|
||||
struct mxl862xx_sys_fw_image_version ver = {};
|
||||
unsigned long start = jiffies, timeout;
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
+ struct mxl862xx_register reg = {};
|
||||
struct mxl862xx_cfg cfg = {};
|
||||
int ret;
|
||||
|
||||
@@ -238,7 +239,7 @@ static int mxl862xx_wait_ready(struct ds
|
||||
goto not_ready_yet;
|
||||
|
||||
/* being able to perform CFGGET indicates that
|
||||
- * the firmware is ready
|
||||
+ * the firmware is servicing API requests
|
||||
*/
|
||||
ret = MXL862XX_API_READ_QUIET(priv,
|
||||
MXL862XX_COMMON_CFGGET,
|
||||
@@ -246,6 +247,23 @@ static int mxl862xx_wait_ready(struct ds
|
||||
if (ret)
|
||||
goto not_ready_yet;
|
||||
|
||||
+ /* The firmware application enables ingress SDMA on all
|
||||
+ * ports as the very last step of its boot-time default
|
||||
+ * configuration; driver configuration issued before that
|
||||
+ * point may be silently overwritten. The reset cleared
|
||||
+ * this bit on all ports and the driver has not touched
|
||||
+ * any port state yet at this point, so the bit of
|
||||
+ * logical port 0 (switch-internal port, never enabled by
|
||||
+ * the driver) being set means the firmware boot-time
|
||||
+ * configuration has completed.
|
||||
+ */
|
||||
+ reg.addr = cpu_to_le16(MXL862XX_SDMA_PCTRLP(0));
|
||||
+ ret = MXL862XX_API_READ_QUIET(priv,
|
||||
+ MXL862XX_COMMON_REGISTERGET,
|
||||
+ reg);
|
||||
+ if (ret || !(le16_to_cpu(reg.data) & MXL862XX_SDMA_PCTRL_EN))
|
||||
+ goto not_ready_yet;
|
||||
+
|
||||
dev_info(ds->dev, "switch ready after %ums, firmware %u.%u.%u (build %u)\n",
|
||||
jiffies_to_msecs(jiffies - start),
|
||||
ver.iv_major, ver.iv_minor,
|
||||
+6
-6
@@ -21,7 +21,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -1668,4 +1668,96 @@ struct mxl862xx_xpcs_pcs_link_up {
|
||||
@@ -1594,4 +1594,96 @@ struct mxl862xx_xpcs_pcs_link_up {
|
||||
__le16 result;
|
||||
} __packed;
|
||||
|
||||
@@ -120,7 +120,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#endif /* __MXL862XX_API_H */
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -79,6 +79,7 @@
|
||||
@@ -80,6 +80,7 @@
|
||||
#define MXL862XX_XPCS_PCS_LINK_UP (MXL862XX_XPCS_MAGIC + 0x7)
|
||||
#define MXL862XX_XPCS_LOOPBACK (MXL862XX_XPCS_MAGIC + 0x8)
|
||||
#define MXL862XX_XPCS_RESET (MXL862XX_XPCS_MAGIC + 0x9)
|
||||
@@ -130,7 +130,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
@@ -412,3 +412,100 @@ const struct phylink_mac_ops mxl862xx_ph
|
||||
@@ -444,3 +444,100 @@ const struct phylink_mac_ops mxl862xx_ph
|
||||
.mac_link_up = mxl862xx_phylink_mac_link_up,
|
||||
.mac_select_pcs = mxl862xx_phylink_mac_select_pcs,
|
||||
};
|
||||
@@ -244,7 +244,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#endif /* __MXL862XX_PHYLINK_H */
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -1776,6 +1776,8 @@ static void mxl862xx_get_strings(struct
|
||||
@@ -1795,6 +1795,8 @@ static void mxl862xx_get_strings(struct
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(mxl862xx_mib); i++)
|
||||
ethtool_puts(&data, mxl862xx_mib[i].name);
|
||||
@@ -253,7 +253,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
static int mxl862xx_get_sset_count(struct dsa_switch *ds, int port, int sset)
|
||||
@@ -1783,7 +1785,7 @@ static int mxl862xx_get_sset_count(struc
|
||||
@@ -1802,7 +1804,7 @@ static int mxl862xx_get_sset_count(struc
|
||||
if (sset != ETH_SS_STATS)
|
||||
return 0;
|
||||
|
||||
@@ -262,7 +262,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
static int mxl862xx_read_rmon(struct dsa_switch *ds, int port,
|
||||
@@ -1819,6 +1821,8 @@ static void mxl862xx_get_ethtool_stats(s
|
||||
@@ -1838,6 +1840,8 @@ static void mxl862xx_get_ethtool_stats(s
|
||||
else
|
||||
*data++ = le64_to_cpu(*(__le64 *)field);
|
||||
}
|
||||
+17
-8
@@ -1,12 +1,21 @@
|
||||
From d11e0b07317e04f347de1b5053bb6720d72fd111 Mon Sep 17 00:00:00 2001
|
||||
From 76491785e22884af9ee8ab5ea824ba8100a91fe1 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 16:30:08 +0000
|
||||
Subject: [PATCH 11/19] net: dsa: wire flash_update devlink callback to drivers
|
||||
Date: Mon, 3 Aug 2026 04:51:51 +0100
|
||||
Subject: [PATCH net-next v10 1/5] net: dsa: add devlink flash_update callback
|
||||
to dsa_switch_ops
|
||||
|
||||
Add a devlink_flash_update callback to dsa_switch_ops so that DSA
|
||||
drivers can support devlink dev flash without open-coding the devlink
|
||||
plumbing. The new trampoline in net/dsa/devlink.c follows the existing
|
||||
dsa_devlink_info_get pattern exactly.
|
||||
plumbing. Like the other trampolines in net/dsa/devlink.c, the op
|
||||
returns -EOPNOTSUPP when the driver does not implement the callback;
|
||||
the devlink core will then have fetched the firmware file from
|
||||
userspace before the request fails, which is acceptable for an
|
||||
operation as infrequent as a firmware update.
|
||||
|
||||
The devlink core calls the op with the devlink instance lock held and
|
||||
without rtnl_lock, whereas DSA serialises its switch and port ops
|
||||
under rtnl_lock, so a driver has to serialise a flash against its own
|
||||
ops itself.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
@@ -16,13 +25,13 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/include/net/dsa.h
|
||||
+++ b/include/net/dsa.h
|
||||
@@ -1171,6 +1171,9 @@ struct dsa_switch_ops {
|
||||
@@ -1169,6 +1169,9 @@ struct dsa_switch_ops {
|
||||
int (*devlink_info_get)(struct dsa_switch *ds,
|
||||
struct devlink_info_req *req,
|
||||
struct netlink_ext_ack *extack);
|
||||
+ int (*devlink_flash_update)(struct dsa_switch *ds,
|
||||
+ struct devlink_flash_update_params *params,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
+ struct devlink_flash_update_params *params,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
int (*devlink_sb_pool_get)(struct dsa_switch *ds,
|
||||
unsigned int sb_index, u16 pool_index,
|
||||
struct devlink_sb_pool_info *pool_info);
|
||||
+27
-11
@@ -1,24 +1,35 @@
|
||||
From 4dd558c7422fcd2b5c76994928fe3a65e0059fb4 Mon Sep 17 00:00:00 2001
|
||||
From e2ee86f5e021eb02a9c08d37e87e0206a5da16a2 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 16:30:17 +0000
|
||||
Subject: [PATCH 12/19] net: dsa: mxl862xx: add SMDIO clause-22 register access
|
||||
Date: Mon, 3 Aug 2026 04:51:57 +0100
|
||||
Subject: [PATCH net-next v10 2/5] net: dsa: mxl862xx: add SMDIO clause-22
|
||||
register access
|
||||
|
||||
Add mxl862xx_smdio_read() and mxl862xx_smdio_write() for clause-22
|
||||
SMDIO register access. MCUboot rescue mode only exposes clause-22
|
||||
registers; the existing clause-45 MMD interface is unavailable during
|
||||
firmware transfer. The MDIO bus lock is held per-transaction (not
|
||||
across polls) so that SB PDI polling during flash erase does not
|
||||
starve other MDIO users.
|
||||
SMDIO register access. The switch's MCUboot bootloader exposes only
|
||||
clause-22 registers; the clause-45 MMD interface needs the running
|
||||
firmware and is unavailable while the switch is in MCUboot. The MDIO
|
||||
bus lock is held per-transaction (not across polls) so that SB PDI
|
||||
polling during flash erase does not starve other non-switch users of
|
||||
the same MDIO bus, such as separate PHYs providing WAN or management
|
||||
interfaces.
|
||||
|
||||
Unlike mxl862xx_api_wrap(), which takes the bus lock with
|
||||
MDIO_MUTEX_NESTED because it can be entered from the accessors of
|
||||
the switch-internal MDIO bus while that bus's lock of the same lock
|
||||
class is already held, the SMDIO helpers take it with a plain
|
||||
mutex_lock(). They are only called from probe and devlink flash
|
||||
contexts where no other MDIO bus lock can be held.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.c | 35 ++++++++++++++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.c | 40 ++++++++++++++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.h | 2 ++
|
||||
2 files changed, 37 insertions(+)
|
||||
2 files changed, 42 insertions(+)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
@@ -493,6 +493,41 @@ out:
|
||||
@@ -495,6 +495,46 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -26,6 +37,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+#define MXL862XX_SMDIO_PAGE_MASK 0xfff0
|
||||
+#define MXL862XX_SMDIO_OFF_MASK 0x000f
|
||||
+
|
||||
+/* Paged clause-22 window: the page goes into MII register 0x1f, the low nibble
|
||||
+ * of addr selects one of the 16 registers within it. Both helpers take the MDIO
|
||||
+ * bus lock per transaction, so callers must not already hold it -- unlike
|
||||
+ * mxl862xx_api_wrap(), which holds it across a whole firmware command.
|
||||
+ */
|
||||
+int mxl862xx_smdio_read(struct mxl862xx_priv *priv, u32 addr)
|
||||
+{
|
||||
+ struct mii_bus *bus = priv->mdiodev->bus;
|
||||
+1102
File diff suppressed because it is too large.
Load diff
+917
@@ -0,0 +1,917 @@
|
||||
From 513eb8147a2c74762bf700b2859bb39469aaa707 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Mon, 3 Aug 2026 04:52:10 +0100
|
||||
Subject: [PATCH net-next v10 4/5] net: dsa: mxl862xx: recover switch stuck in
|
||||
MCUboot rescue mode
|
||||
|
||||
A broken or interrupted firmware image, or the sticky rescue bit, keeps
|
||||
the switch in its MCUboot bootloader, which exposes only the clause-22
|
||||
SMDIO download interface. The clause-45 MMD API never comes up, so probe
|
||||
would fail with -ETIMEDOUT and the only way back would be the switch's
|
||||
UART console, or a power cycle or out-of-band reset (not currently
|
||||
implemented).
|
||||
|
||||
Probe for the loader over SB PDI at setup, before any clause-45 access,
|
||||
since the C45 API floods the log with CRC errors when no firmware
|
||||
answers. A scratch write to two mailbox registers first establishes
|
||||
that a switch is there at all. It reaches a running firmware as well,
|
||||
but lands in registers that firmware does not read, so it is inert
|
||||
there. The status register the loader publishes then tells the cases
|
||||
apart without touching C45: a running firmware, which answers with its
|
||||
own non-zero status word (0x0003 on the firmware tested), so probe
|
||||
continues normally; a loader idle in its console loop, confirmed live
|
||||
by a register-read challenge; a loader wedged mid-download, the one
|
||||
case that publishes zero; the flashless download loop, which this
|
||||
driver cannot drive; and a switch whose scratch write does not latch --
|
||||
absent, unpowered, misdescribed in the device tree (wrong address or
|
||||
bus, or a reset GPIO with inverted polarity), or with its SB PDI window
|
||||
somewhere other than the OTP reset offsets assumed here. The first
|
||||
three enter rescue mode or normal operation, the last two fail probe
|
||||
cleanly with -EOPNOTSUPP and -ENODEV instead of a CRC-error storm.
|
||||
|
||||
A loader that publishes the ready magic but never services the
|
||||
register-read challenge fails probe too, with -ENXIO. The challenge is
|
||||
what tells the loader apart from a firmware whose status word happens
|
||||
to read the same value, and offering to flash a healthy firmware would
|
||||
be worse than refusing to bind, so a mailbox that does not answer is
|
||||
treated as unusable rather than as a flash target. Every loader tested
|
||||
services it.
|
||||
|
||||
In rescue mode the switch registers without user interfaces so devlink
|
||||
stays available: user ports fail port_setup with -ENODEV (the DSA core
|
||||
re-registers them as unused) while shared and CPU ports succeed, and the
|
||||
CPU port works on its fixed link with mac_select_pcs returning no PCS.
|
||||
Firmware API commands fail fast with -ENODEV and the port and STP
|
||||
callbacks become no-ops.
|
||||
|
||||
An interrupted download can leave the loader wedged mid-payload. A
|
||||
background work item off the devlink flash path drains it back to a
|
||||
clean ready state by feeding the outstanding byte count one byte at a
|
||||
time, which takes tens of minutes for a large image and is logged as it
|
||||
progresses; until then devlink dev info reports no version and devlink
|
||||
dev flash returns -EBUSY, and -EIO once a drain has failed for good.
|
||||
Reaching the end of the count is all the drain does: the loader then
|
||||
verifies the corrupt image and returns to its console loop on its own,
|
||||
so the drain reprobes and lets the probe-time detection re-classify the
|
||||
switch -- a valid image that a last-moment interruption left bootable
|
||||
comes up as running firmware, with no second-guessing in the drain path.
|
||||
|
||||
The reprobe the drain queues owns itself and cannot be cancelled from
|
||||
teardown, so, like the post-flash reprobe, it checks whether the device
|
||||
is still bound before touching it: a drain finishing after the driver
|
||||
is gone does nothing. Should that hand-off fail to be set up at all,
|
||||
recovery stops with an error, since the loader would otherwise sit at a
|
||||
clean ready state that nothing reclassifies while devlink keeps
|
||||
promising that a retry will work.
|
||||
|
||||
The CHIP ID registers need a running firmware, so no asic.id/asic.rev is
|
||||
reported in rescue mode. Once the loader is ready, devlink dev info
|
||||
reports the null firmware version "0.0.0" as both running and stored:
|
||||
|
||||
$ devlink dev info mdio_bus/mdio-bus:10
|
||||
mdio_bus/mdio-bus:10:
|
||||
driver mxl862xx
|
||||
versions:
|
||||
running:
|
||||
fw 0.0.0
|
||||
stored:
|
||||
fw 0.0.0
|
||||
|
||||
An operational switch never reports 0.0.0 (a released firmware's major
|
||||
is non-zero), so version-comparing tools like fwupd offer every release
|
||||
as an upgrade, recovering the switch through the regular flash flow,
|
||||
matched on the driver name. The flash skips the FW_UPDATE command since
|
||||
MCUboot is already waiting. A successful flash reboots the switch into
|
||||
the new firmware and the reprobe then brings the driver up against it
|
||||
normally; after a failed one the switch is still in MCUboot, rescue mode
|
||||
is detected again, and the user can retry.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-fw.c | 463 +++++++++++++++++++-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-fw.h | 3 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.c | 8 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.c | 2 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 100 ++++-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.h | 20 +
|
||||
6 files changed, 566 insertions(+), 30 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-fw.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-fw.c
|
||||
@@ -29,9 +29,11 @@
|
||||
*
|
||||
* STAT magics:
|
||||
* READY 0xc55c loader idle in the console loop (this driver)
|
||||
+ * DL_RDY 0xc33c loader idle in the flashless loop
|
||||
* START 0xf48f host -> begin download session
|
||||
* ACK 0xf490 loader -> START acknowledged (START + 1)
|
||||
* END 0x3cc3 host -> finalise now (optional, see below)
|
||||
+ * RDREG 0xe2c0 host -> register-read command (| index), see below
|
||||
*
|
||||
* Console flash path (STAT=0xc55c) - mxl862xx_flash_firmware():
|
||||
*
|
||||
@@ -71,7 +73,40 @@
|
||||
* - never send a slice/chunk count larger than what is outstanding;
|
||||
* - a STAT write is a command only once the loader has left the loop;
|
||||
* - the loader leaves the count in STAT while it programs the chunk, so
|
||||
- * a lingering count does not distinguish "busy" from "verdict".
|
||||
+ * a lingering count does not distinguish "busy" from "verdict";
|
||||
+ * - interrupted-download recovery feeds 1 byte at a time (see below).
|
||||
+ *
|
||||
+ * Interrupted-flash recovery (mxl862xx_rescue_drain):
|
||||
+ * A host that dies mid-payload leaves the loader in the receive loop holding
|
||||
+ * STAT=0. Feed single 1-byte chunks (one DATA word + STAT=1) until r_remain
|
||||
+ * reaches 0; the loader then verifies the (now corrupt) image, publishes its
|
||||
+ * verdict and comes back to READY by itself. END is never sent here: while
|
||||
+ * r_remain is non-zero it would be consumed as a 15555-byte count, and a
|
||||
+ * lingering STAT=1 cannot be told from a chunk still being programmed.
|
||||
+ *
|
||||
+ * Register-read challenge (non-destructive liveness proof):
|
||||
+ * DATA := 0x7c23 (marker); STAT := 0xe2c0|idx
|
||||
+ * -> loader returns a runtime word in DATA and re-arms STAT=0xc55c.
|
||||
+ * The reply source is loader BSS, not a chip id; used only to prove a live
|
||||
+ * mailbox in mxl862xx_rescue_mode_detect().
|
||||
+ *
|
||||
+ * The other STAT ready magic, 0xc33c, marks the loader's flashless
|
||||
+ * chip-to-chip download mode (MxL86281S 16-port tier); this driver does not
|
||||
+ * use it.
|
||||
+ *
|
||||
+ * Rescue lifecycle (devlink): probe runs mxl862xx_rescue_mode_detect(); a
|
||||
+ * wedged loader is drained back to READY by a background self-heal
|
||||
+ * (rescue_heal_work), so the long recovery never holds the devlink lock.
|
||||
+ * devlink dev info exposes the fw version (the "flashable" signal) only once at
|
||||
+ * READY; flash_update returns -EBUSY until then, and reprobes to WSP firmware
|
||||
+ * on success.
|
||||
+ *
|
||||
+ * Notes:
|
||||
+ * - Chip id/revision (0xc0d28884/88) are NOT reachable on this channel; they
|
||||
+ * need the clause-45 MMD firmware mailbox, which is dead under MCUboot.
|
||||
+ * Rescue identity is by SB PDI behaviour only (mxl862xx_rescue_mode_detect).
|
||||
+ * - The SMDIO PHY address comes from the device tree; the 0xe1xx register
|
||||
+ * offsets are the OTP reset defaults and the only layout supported here.
|
||||
*/
|
||||
|
||||
#include <linux/crc32.h>
|
||||
@@ -104,8 +139,15 @@
|
||||
|
||||
/* SB PDI handshake magic (published/consumed via STAT) */
|
||||
#define MXL862XX_SB_PDI_READY 0xc55c /* loader idle, console loop */
|
||||
+#define MXL862XX_SB_PDI_DL_READY 0xc33c /* loader idle, flashless loop */
|
||||
#define MXL862XX_SB_PDI_START 0xf48f
|
||||
#define MXL862XX_SB_PDI_END 0x3cc3
|
||||
+#define MXL862XX_SB_PDI_RDREG 0xe2c0 /* register-read cmd (| index) */
|
||||
+#define MXL862XX_SB_PDI_RDREG_MARK 0x7c23 /* marker placed in DATA for RDREG */
|
||||
+
|
||||
+/* Behavioural presence probe: two distinct 16-bit latches on ADDR/DATA. */
|
||||
+#define MXL862XX_SB_PDI_PROBE_A 0x5a5a
|
||||
+#define MXL862XX_SB_PDI_PROBE_D 0xa5a5
|
||||
|
||||
/* Image verification verdict published in STAT once the receive loop ends */
|
||||
#define MXL862XX_SB_PDI_VERIFY_OK 0
|
||||
@@ -124,6 +166,10 @@
|
||||
#define MXL862XX_FW_WRITE_TIMEOUT_MS 60000
|
||||
#define MXL862XX_FW_REBOOT_DELAY_MS 5000
|
||||
#define MXL862XX_FW_REPROBE_DELAY_MS 500
|
||||
+/* One loader mailbox step: program a 1-byte chunk or service a command */
|
||||
+#define MXL862XX_SB_PDI_STEP_MS 2000
|
||||
+/* Covers the loader's END wait, verification and the reset into READY */
|
||||
+#define MXL862XX_SB_PDI_VERIFY_MS 15000
|
||||
|
||||
static int mxl862xx_sb_pdi_reset(struct mxl862xx_priv *priv)
|
||||
{
|
||||
@@ -193,7 +239,8 @@ static int mxl862xx_sb_pdi_flush_last(st
|
||||
|
||||
ret = read_poll_timeout(mxl862xx_smdio_read, val,
|
||||
val < 0 || (u16)val != (u16)data_written,
|
||||
- 10000, MXL862XX_FW_WRITE_TIMEOUT_MS * 1000,
|
||||
+ 10000, (MXL862XX_FW_WRITE_TIMEOUT_MS +
|
||||
+ MXL862XX_SB_PDI_VERIFY_MS) * 1000,
|
||||
false, priv, MXL862XX_SB_PDI_STAT);
|
||||
if (val < 0)
|
||||
return val;
|
||||
@@ -278,6 +325,357 @@ static struct mxl862xx_reprobe *mxl862xx
|
||||
return rp;
|
||||
}
|
||||
|
||||
+/* Byte-count of each chunk fed to the loader during drain. It MUST be 1: the
|
||||
+ * loader only lets us observe "counter == 0", never "counter < step", so any
|
||||
+ * step > 1 can subtract past zero, underflow the 32-bit counter and wedge the
|
||||
+ * loader for ~2^32 more bytes (a state only a power cycle clears). Stepping by
|
||||
+ * 1 walks the counter through every value and is guaranteed to land on zero
|
||||
+ * whatever its (possibly odd) start. A 1-byte chunk is a path the loader
|
||||
+ * already handles: the normal transfer ends with a single trailing byte for
|
||||
+ * odd-sized images (see Step 6).
|
||||
+ */
|
||||
+#define MXL862XX_DRAIN_CHUNK_BYTES 1
|
||||
+
|
||||
+/* Log the drain's progress every so many bytes; it can run for a long time */
|
||||
+#define MXL862XX_DRAIN_LOG_BYTES (128 * 1024)
|
||||
+
|
||||
+/* Wait for the loader to ask for the next chunk (STAT 0) or to come back to its
|
||||
+ * command loop (STAT READY), and return the STAT value either way. On timeout
|
||||
+ * that is whatever STAT still holds, which carries no further information: the
|
||||
+ * loader keeps the count we wrote visible while it programs the chunk, and that
|
||||
+ * is the same value it publishes as the "image rejected" verdict once the
|
||||
+ * counter reaches zero.
|
||||
+ *
|
||||
+ * STAT 0 is unambiguous here even though it is also the "image verified"
|
||||
+ * verdict: by the r_remain == 0 rule the loader leaves the receive loop the
|
||||
+ * moment the counter reaches zero, so it is never both inside the loop asking
|
||||
+ * for a chunk and publishing a verdict. Once it has left, the next STAT write
|
||||
+ * is a command rather than a count, so feeding one more chunk after a verdict
|
||||
+ * cannot underflow anything either.
|
||||
+ */
|
||||
+static int mxl862xx_sb_pdi_poll_drain(struct mxl862xx_priv *priv,
|
||||
+ unsigned long timeout_ms)
|
||||
+{
|
||||
+ int val;
|
||||
+
|
||||
+ read_poll_timeout(mxl862xx_smdio_read, val,
|
||||
+ val < 0 || (u16)val == MXL862XX_SB_PDI_READY ||
|
||||
+ (u16)val == 0,
|
||||
+ 50, timeout_ms * 1000, false,
|
||||
+ priv, MXL862XX_SB_PDI_STAT);
|
||||
+ if (val < 0)
|
||||
+ return val;
|
||||
+ return (u16)val;
|
||||
+}
|
||||
+
|
||||
+/* The loader is not asking for a chunk: it may still be programming the last
|
||||
+ * one, or the counter has reached zero and it is verifying the image and
|
||||
+ * resetting into READY. Wait that out -- STAT cannot tell the two apart, and
|
||||
+ * guessing would mean writing END into a live receive loop.
|
||||
+ *
|
||||
+ * Return: 0 once the loader has left the loop, -EAGAIN if it asks for another
|
||||
+ * chunk after all, -EIO for a loader still holding the count when the verify
|
||||
+ * window expires, or an SMDIO bus error.
|
||||
+ */
|
||||
+static int mxl862xx_rescue_drain_finish(struct mxl862xx_priv *priv, u32 chunk)
|
||||
+{
|
||||
+ struct device *dev = &priv->mdiodev->dev;
|
||||
+ int stat;
|
||||
+
|
||||
+ stat = mxl862xx_sb_pdi_poll_drain(priv, MXL862XX_SB_PDI_VERIFY_MS);
|
||||
+ if (stat < 0)
|
||||
+ return stat;
|
||||
+ if (stat == MXL862XX_SB_PDI_READY)
|
||||
+ return 0;
|
||||
+ if (stat == MXL862XX_SB_PDI_VERIFY_BAD) {
|
||||
+ dev_err(dev,
|
||||
+ "flash: loader stuck after %u chunks, power cycle it\n",
|
||||
+ chunk);
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+ if (stat) {
|
||||
+ /* A firmware is answering, not the loader: an image survived
|
||||
+ * in flash and booted.
|
||||
+ */
|
||||
+ dev_info(dev, "flash: firmware booted while draining\n");
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ return -EAGAIN;
|
||||
+}
|
||||
+
|
||||
+/* Recover a switch whose SB PDI download was interrupted mid-transfer - the
|
||||
+ * host died after MCUboot began erasing flash, whether it aborted mid erase or
|
||||
+ * mid image-write, both end up in the same place: the payload receive loop.
|
||||
+ * There the loader publishes STAT=0, waits for the host to write a byte-count
|
||||
+ * to STAT, DMAs that many bytes and subtracts the count from a remaining-bytes
|
||||
+ * counter, leaving the loop only when the counter reaches exactly zero. The
|
||||
+ * image size died with the host, so we feed single-byte chunks (see
|
||||
+ * MXL862XX_DRAIN_CHUNK_BYTES) to walk the counter to zero without underflow.
|
||||
+ * The loader then verifies the (now corrupt) image and returns to READY by
|
||||
+ * itself, or boots a valid image that happened to survive in flash; either way
|
||||
+ * the caller's reprobe classifies the result. Every byte costs about a dozen
|
||||
+ * MDIO frames, so a multi-MiB outstanding count takes tens of minutes.
|
||||
+ * Returns 0 once the loader has left the receive loop, <0 on error. Does NOT
|
||||
+ * recover a counter already underflowed by an earlier oversized-chunk attempt
|
||||
+ * - that needs a power cycle.
|
||||
+ */
|
||||
+static int mxl862xx_rescue_drain(struct mxl862xx_priv *priv)
|
||||
+{
|
||||
+ struct device *dev = &priv->mdiodev->dev;
|
||||
+ /* Bound: twice the loader's 16 MiB image cap, one byte per chunk. */
|
||||
+ u32 max_chunks = 2u * (16u << 20) / MXL862XX_DRAIN_CHUNK_BYTES;
|
||||
+ u32 chunk = 0;
|
||||
+ int ret, stat;
|
||||
+
|
||||
+ while (chunk < max_chunks) {
|
||||
+ /* Teardown can interrupt this long drain. */
|
||||
+ if (test_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags))
|
||||
+ return -ECANCELED;
|
||||
+
|
||||
+ stat = mxl862xx_sb_pdi_poll_drain(priv, MXL862XX_SB_PDI_STEP_MS);
|
||||
+ if (stat < 0)
|
||||
+ return stat;
|
||||
+ if (stat == MXL862XX_SB_PDI_READY)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (stat) {
|
||||
+ ret = mxl862xx_rescue_drain_finish(priv, chunk);
|
||||
+ if (ret != -EAGAIN)
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* Feed one zero byte; reset cleared the write latch. */
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_WR);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_DATA, 0x0000);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ ret = mxl862xx_sb_pdi_reset(priv);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ MXL862XX_DRAIN_CHUNK_BYTES);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ chunk++;
|
||||
+ if (!(chunk % MXL862XX_DRAIN_LOG_BYTES))
|
||||
+ dev_info(dev, "flash: drained %u KiB so far\n",
|
||||
+ chunk / 1024);
|
||||
+ cond_resched();
|
||||
+ }
|
||||
+
|
||||
+ dev_err(dev,
|
||||
+ "flash: interrupted download did not drain after %u chunks\n",
|
||||
+ chunk);
|
||||
+
|
||||
+ return -ETIMEDOUT;
|
||||
+}
|
||||
+
|
||||
+/* Background self-heal: drain a wedged download off the devlink flash path, so
|
||||
+ * the long recovery never holds the devlink lock. Scheduled from probe;
|
||||
+ * reprobes on success so the probe-time detection re-classifies the switch.
|
||||
+ */
|
||||
+void mxl862xx_rescue_heal_work_fn(struct work_struct *work)
|
||||
+{
|
||||
+ struct mxl862xx_priv *priv =
|
||||
+ container_of(work, struct mxl862xx_priv, rescue_heal_work);
|
||||
+ struct device *dev = &priv->mdiodev->dev;
|
||||
+ struct mxl862xx_reprobe *ko;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = mxl862xx_rescue_drain(priv);
|
||||
+ if (ret == -ECANCELED)
|
||||
+ return;
|
||||
+ if (ret) {
|
||||
+ /* Nothing retries this, so say so: rescue_ready stays clear
|
||||
+ * and devlink dev flash reports why it refuses.
|
||||
+ */
|
||||
+ dev_err(dev, "flash: download recovery failed: %pe\n",
|
||||
+ ERR_PTR(ret));
|
||||
+ WRITE_ONCE(priv->rescue_failed, true);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ /* The interrupted transfer is finalised; reprobe so the probe-time
|
||||
+ * detection brings the driver up -- flashable in rescue mode if the
|
||||
+ * loader is at READY, or normally if a valid image booted. The refs
|
||||
+ * are released by the reprobe once it completes, which also decides
|
||||
+ * whether it may still run: teardown cannot cancel a work item queued
|
||||
+ * here, so the reprobe checks for itself that the device is still
|
||||
+ * bound. The flag test below only avoids queueing work that would
|
||||
+ * certainly be skipped.
|
||||
+ */
|
||||
+ if (test_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags))
|
||||
+ return;
|
||||
+
|
||||
+ if (!try_module_get(THIS_MODULE))
|
||||
+ return;
|
||||
+
|
||||
+ get_device(dev);
|
||||
+ ko = mxl862xx_reprobe_alloc(dev);
|
||||
+ if (!ko) {
|
||||
+ put_device(dev);
|
||||
+ module_put(THIS_MODULE);
|
||||
+ /* The loader is at READY and would take an image, but nothing
|
||||
+ * will reclassify the switch, so refuse flashing with a real
|
||||
+ * error instead of the "retry shortly" that never comes true.
|
||||
+ */
|
||||
+ dev_err(dev, "flash: cannot reinitialise after recovery, unbind and rebind to flash\n");
|
||||
+ WRITE_ONCE(priv->rescue_failed, true);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ queue_delayed_work(system_long_wq, &ko->work,
|
||||
+ msecs_to_jiffies(MXL862XX_FW_REPROBE_DELAY_MS));
|
||||
+}
|
||||
+
|
||||
+/* Detect MCUboot rescue mode over clause-22 SMDIO alone, so the caller can rule
|
||||
+ * the loader out before any C45 API request (which spews CRC errors when no WSP
|
||||
+ * firmware answers). A scratch write to ADDR/DATA must latch or the chip is
|
||||
+ * absent (-ENODEV); the mailbox is reset first, or a transfer interrupted with
|
||||
+ * CTRL=WR would take that write as a payload word instead of latching it. STAT
|
||||
+ * then classifies the state, poked destructively only when 0, the one value a
|
||||
+ * running firmware never holds:
|
||||
+ *
|
||||
+ * - 0xc33c: flashless loop; recognised but not supported here.
|
||||
+ * - 0xc55c: console loop, if the register-read challenge is serviced.
|
||||
+ * - other non-zero: running firmware, left unpoked.
|
||||
+ * - 0: wedged receive loop; the 1-byte slice-advance then says whether it
|
||||
+ * still needs draining or has just finished.
|
||||
+ *
|
||||
+ * The scratch write reaches a running firmware too, but lands in mailbox
|
||||
+ * registers it does not read, so it is inert there.
|
||||
+ *
|
||||
+ * Return: MXL862XX_IN_RESCUE, MXL862XX_NOT_RESCUE, -ENODEV when the scratch
|
||||
+ * write does not latch, which is a switch that does not answer at all or one
|
||||
+ * whose SB PDI window is not at the offsets above, -EOPNOTSUPP for the
|
||||
+ * flashless loop, -ENXIO for a READY loader whose mailbox fails the challenge,
|
||||
+ * or an SMDIO bus error.
|
||||
+ */
|
||||
+int mxl862xx_rescue_mode_detect(struct mxl862xx_priv *priv)
|
||||
+{
|
||||
+ int stat, dat, ret, rb, a, d;
|
||||
+
|
||||
+ /* rescue_ready gates flashing; a wedged loader needs the drain first. */
|
||||
+ WRITE_ONCE(priv->rescue_ready, false);
|
||||
+
|
||||
+ ret = mxl862xx_sb_pdi_reset(priv);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ /* Presence: a live chip latches the scratch write, an absent one floats. */
|
||||
+ a = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_ADDR,
|
||||
+ MXL862XX_SB_PDI_PROBE_A);
|
||||
+ if (a < 0)
|
||||
+ return a;
|
||||
+ d = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_DATA,
|
||||
+ MXL862XX_SB_PDI_PROBE_D);
|
||||
+ if (d < 0)
|
||||
+ return d;
|
||||
+ a = mxl862xx_smdio_read(priv, MXL862XX_SB_PDI_ADDR);
|
||||
+ if (a < 0)
|
||||
+ return a;
|
||||
+ d = mxl862xx_smdio_read(priv, MXL862XX_SB_PDI_DATA);
|
||||
+ if (d < 0)
|
||||
+ return d;
|
||||
+ if ((u16)a != MXL862XX_SB_PDI_PROBE_A ||
|
||||
+ (u16)d != MXL862XX_SB_PDI_PROBE_D)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ ret = mxl862xx_sb_pdi_reset(priv);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ stat = mxl862xx_smdio_read(priv, MXL862XX_SB_PDI_STAT);
|
||||
+ if (stat < 0)
|
||||
+ return stat;
|
||||
+
|
||||
+ /* Flashless-download loop (MxL86281S tier): this driver does not
|
||||
+ * support it -- the console flash path expects READY. Treat it as an
|
||||
+ * unusable configuration, like any other unsupported state.
|
||||
+ */
|
||||
+ if ((u16)stat == MXL862XX_SB_PDI_DL_READY)
|
||||
+ return -EOPNOTSUPP;
|
||||
+
|
||||
+ /* Console loop at READY: confirm the live mailbox with the register-read
|
||||
+ * challenge (consumes the marker from DATA and re-arms READY).
|
||||
+ */
|
||||
+ if ((u16)stat == MXL862XX_SB_PDI_READY) {
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_DATA,
|
||||
+ MXL862XX_SB_PDI_RDREG_MARK);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ MXL862XX_SB_PDI_RDREG);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ rb = mxl862xx_sb_pdi_poll_stat(priv, MXL862XX_SB_PDI_READY,
|
||||
+ MXL862XX_SB_PDI_STEP_MS);
|
||||
+ dat = mxl862xx_smdio_read(priv, MXL862XX_SB_PDI_DATA);
|
||||
+ ret = mxl862xx_sb_pdi_reset(priv);
|
||||
+ /* Never re-arming READY fails the challenge like any other
|
||||
+ * unserviced command; report it as such rather than as a bus
|
||||
+ * timeout the bus never saw.
|
||||
+ */
|
||||
+ if (rb == -ETIMEDOUT)
|
||||
+ rb = -ENXIO;
|
||||
+ if (rb < 0)
|
||||
+ return rb;
|
||||
+ if (dat < 0)
|
||||
+ return dat;
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ if ((u16)dat != MXL862XX_SB_PDI_RDREG_MARK) {
|
||||
+ WRITE_ONCE(priv->rescue_ready, true);
|
||||
+ return MXL862XX_IN_RESCUE;
|
||||
+ }
|
||||
+ /* READY but the marker is untouched, so nothing is servicing the
|
||||
+ * mailbox. A firmware publishing 0xc55c as its status word looks
|
||||
+ * exactly like this, and flashing one would be far worse than
|
||||
+ * refusing to bind, so treat it as unusable.
|
||||
+ */
|
||||
+ return -ENXIO;
|
||||
+ }
|
||||
+
|
||||
+ /* Any other non-zero value is a running firmware, not a loader. */
|
||||
+ if (stat)
|
||||
+ return MXL862XX_NOT_RESCUE;
|
||||
+
|
||||
+ /* STAT == 0: a wedged receive loop takes a 1-byte slice-advance (feed
|
||||
+ * one DATA word first, like a drain chunk) and asks for the next chunk
|
||||
+ * by publishing 0 again. Had that byte been the last one outstanding,
|
||||
+ * the loader leaves the loop instead and returns to READY, having
|
||||
+ * consumed the advance -- proof enough of a live mailbox to skip the
|
||||
+ * challenge. Anything else means it is still working on it. All three
|
||||
+ * are rescue, so this never fails probe; only the drain does.
|
||||
+ */
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_WR);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_DATA, 0x0000);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ ret = mxl862xx_sb_pdi_reset(priv);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ ret = mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ MXL862XX_DRAIN_CHUNK_BYTES);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ rb = mxl862xx_sb_pdi_poll_drain(priv, MXL862XX_SB_PDI_STEP_MS);
|
||||
+ if (rb < 0)
|
||||
+ return rb;
|
||||
+ if (rb == MXL862XX_SB_PDI_READY)
|
||||
+ WRITE_ONCE(priv->rescue_ready, true);
|
||||
+
|
||||
+ return MXL862XX_IN_RESCUE;
|
||||
+}
|
||||
+
|
||||
/* MCUboot firmware image header */
|
||||
struct mxl862xx_fw_hdr {
|
||||
__le32 image_type;
|
||||
@@ -353,13 +751,15 @@ static int mxl862xx_flash_firmware(struc
|
||||
int ret, i;
|
||||
|
||||
/* Step 1: reboot the firmware into MCUboot rescue mode */
|
||||
- ret = mxl862xx_api_wrap(priv, SYS_MISC_FW_UPDATE, NULL, 0,
|
||||
- false, false);
|
||||
- if (ret) {
|
||||
- dev_err(&priv->mdiodev->dev,
|
||||
- "flash: FW_UPDATE command failed: %pe\n",
|
||||
- ERR_PTR(ret));
|
||||
- return ret;
|
||||
+ if (!priv->rescue_mode) {
|
||||
+ ret = mxl862xx_api_wrap(priv, SYS_MISC_FW_UPDATE, NULL, 0,
|
||||
+ false, false);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: FW_UPDATE command failed: %pe\n",
|
||||
+ ERR_PTR(ret));
|
||||
+ return ret;
|
||||
+ }
|
||||
}
|
||||
|
||||
/* Step 2: wait for bootloader ready */
|
||||
@@ -541,6 +941,25 @@ int mxl862xx_devlink_info_get(struct dsa
|
||||
char buf[16];
|
||||
int ret;
|
||||
|
||||
+ /* No chip-id/revision in MCUboot (needs the firmware MMD mailbox). The
|
||||
+ * fw version doubles as the "ready to flash" signal: report it only
|
||||
+ * once the loader is at a clean READY, nothing while still draining.
|
||||
+ */
|
||||
+ if (priv->rescue_mode) {
|
||||
+ if (!READ_ONCE(priv->rescue_ready))
|
||||
+ return 0;
|
||||
+
|
||||
+ snprintf(buf, sizeof(buf), "%u.%u.%u",
|
||||
+ priv->fw_version.major, priv->fw_version.minor,
|
||||
+ priv->fw_version.revision);
|
||||
+ ret = devlink_info_version_running_put(req,
|
||||
+ DEVLINK_INFO_VERSION_GENERIC_FW, buf);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ return devlink_info_version_stored_put(req,
|
||||
+ DEVLINK_INFO_VERSION_GENERIC_FW, buf);
|
||||
+ }
|
||||
+
|
||||
/* A 0 part number means the CHIP ID read failed or the part is
|
||||
* unfused; omit it rather than publish a bogus "0000" that fwupd
|
||||
* would match firmware against -- it then falls back to the driver
|
||||
@@ -614,6 +1033,21 @@ int mxl862xx_devlink_flash_update(struct
|
||||
return ret;
|
||||
}
|
||||
|
||||
+ /* Refuse to flash while the background self-heal is still draining, and
|
||||
+ * for good once it has given up on the loader.
|
||||
+ */
|
||||
+ if (READ_ONCE(priv->rescue_failed)) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack,
|
||||
+ "download recovery failed, power cycle the switch");
|
||||
+ return -EIO;
|
||||
+ }
|
||||
+
|
||||
+ if (priv->rescue_mode && !READ_ONCE(priv->rescue_ready)) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack,
|
||||
+ "switch is recovering an interrupted download, retry shortly");
|
||||
+ return -EBUSY;
|
||||
+ }
|
||||
+
|
||||
/* The references the reprobe work needs to restore normal operation
|
||||
* must be held before the switch is disturbed; the work itself is
|
||||
* scheduled only once the flash is done (see below).
|
||||
@@ -633,9 +1067,13 @@ int mxl862xx_devlink_flash_update(struct
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
- dev_info(ds->dev, "flash: running firmware %u.%u.%u\n",
|
||||
- priv->fw_version.major, priv->fw_version.minor,
|
||||
- priv->fw_version.revision);
|
||||
+ if (priv->rescue_mode)
|
||||
+ dev_info(ds->dev,
|
||||
+ "flash: flashing switch via MCUboot rescue mode\n");
|
||||
+ else
|
||||
+ dev_info(ds->dev, "flash: running firmware %u.%u.%u\n",
|
||||
+ priv->fw_version.major, priv->fw_version.minor,
|
||||
+ priv->fw_version.revision);
|
||||
|
||||
/* Close ports while the firmware is still alive so the DSA core's
|
||||
* MDB/FDB tracking is drained, and detach user ports so userspace
|
||||
@@ -679,6 +1117,7 @@ int mxl862xx_devlink_flash_update(struct
|
||||
mutex_lock_nested(&priv->mdiodev->bus->mdio_lock,
|
||||
MDIO_MUTEX_NESTED);
|
||||
priv->block_host = false;
|
||||
+ priv->rescue_mode = false;
|
||||
mutex_unlock(&priv->mdiodev->bus->mdio_lock);
|
||||
|
||||
/* Refresh the cached versions so the flash update only
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-fw.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-fw.h
|
||||
@@ -6,7 +6,10 @@
|
||||
#include <net/dsa.h>
|
||||
|
||||
struct mxl862xx_priv;
|
||||
+struct work_struct;
|
||||
|
||||
+int mxl862xx_rescue_mode_detect(struct mxl862xx_priv *priv);
|
||||
+void mxl862xx_rescue_heal_work_fn(struct work_struct *work);
|
||||
int mxl862xx_devlink_info_get(struct dsa_switch *ds,
|
||||
struct devlink_info_req *req,
|
||||
struct netlink_ext_ack *extack);
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <net/dsa.h>
|
||||
#include "mxl862xx.h"
|
||||
#include "mxl862xx-cmd.h"
|
||||
+#include "mxl862xx-fw.h"
|
||||
#include "mxl862xx-host.h"
|
||||
|
||||
#define CTRL_BUSY_MASK BIT(15)
|
||||
@@ -346,6 +347,11 @@ int mxl862xx_api_wrap(struct mxl862xx_pr
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ if (priv->rescue_mode) {
|
||||
+ ret = -ENODEV;
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
if (priv->block_host && cmd != SYS_MISC_FW_UPDATE) {
|
||||
ret = -EBUSY;
|
||||
goto out;
|
||||
@@ -549,9 +555,11 @@ int mxl862xx_smdio_write(struct mxl862xx
|
||||
void mxl862xx_host_init(struct mxl862xx_priv *priv)
|
||||
{
|
||||
INIT_WORK(&priv->crc_err_work, mxl862xx_crc_err_work_fn);
|
||||
+ INIT_WORK(&priv->rescue_heal_work, mxl862xx_rescue_heal_work_fn);
|
||||
}
|
||||
|
||||
void mxl862xx_host_shutdown(struct mxl862xx_priv *priv)
|
||||
{
|
||||
cancel_work_sync(&priv->crc_err_work);
|
||||
+ cancel_work_sync(&priv->rescue_heal_work);
|
||||
}
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
@@ -406,6 +406,8 @@ mxl862xx_phylink_mac_select_pcs(struct p
|
||||
|
||||
switch (port) {
|
||||
case 9 ... 16:
|
||||
+ if (priv->rescue_mode)
|
||||
+ return NULL;
|
||||
if (!MXL862XX_FW_VER_MIN(priv, 1, 0, 84)) {
|
||||
dev_warn_once(dp->ds->dev,
|
||||
"SerDes PCS unsupported on old firmware.\n");
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -692,21 +692,66 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
int n_user_ports = 0, max_vlans;
|
||||
int ingress_finals, vid_rules;
|
||||
struct dsa_port *dp;
|
||||
- int ret, i;
|
||||
-
|
||||
- ret = mxl862xx_reset(priv);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
-
|
||||
- ret = mxl862xx_wait_ready(ds);
|
||||
- if (ret)
|
||||
- return ret;
|
||||
+ int ret, i, rescue;
|
||||
|
||||
+ /* The SerDes state is software-only and must exist before anything can
|
||||
+ * reach phylink, including a rescue-mode flash clearing rescue_mode
|
||||
+ * ahead of the reprobe.
|
||||
+ */
|
||||
mutex_init(&priv->serdes_lock);
|
||||
for (i = 0; i < ARRAY_SIZE(priv->serdes_ports); i++)
|
||||
mxl862xx_setup_pcs(priv, &priv->serdes_ports[i],
|
||||
i + MXL862XX_FIRST_SERDES_PORT);
|
||||
|
||||
+ /* Detect the loader over SB PDI first: it needs no firmware, unlike the
|
||||
+ * C45 API (mxl862xx_reset/wait_ready) which spews CRC errors when none
|
||||
+ * answers. Touch C45 only once rescue is ruled out.
|
||||
+ */
|
||||
+ rescue = mxl862xx_rescue_mode_detect(priv);
|
||||
+ if (rescue < 0) {
|
||||
+ dev_err(ds->dev, "switch state detection failed: %pe\n",
|
||||
+ ERR_PTR(rescue));
|
||||
+ return rescue;
|
||||
+ }
|
||||
+
|
||||
+ if (rescue == MXL862XX_NOT_RESCUE) {
|
||||
+ ret = mxl862xx_reset(priv);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ ret = mxl862xx_wait_ready(ds);
|
||||
+ if (ret) {
|
||||
+ /* the reset may only now have triggered rescue mode */
|
||||
+ rescue = mxl862xx_rescue_mode_detect(priv);
|
||||
+ if (rescue < 0) {
|
||||
+ dev_err(ds->dev,
|
||||
+ "switch not responding after reset: %pe\n",
|
||||
+ ERR_PTR(rescue));
|
||||
+ return rescue;
|
||||
+ }
|
||||
+ if (rescue == MXL862XX_NOT_RESCUE)
|
||||
+ return ret;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ priv->rescue_mode = rescue;
|
||||
+
|
||||
+ if (priv->rescue_mode) {
|
||||
+ if (priv->rescue_ready) {
|
||||
+ dev_warn(ds->dev,
|
||||
+ "switch in MCUboot rescue mode, use devlink to flash new firmware\n");
|
||||
+ } else {
|
||||
+ /* Drain the wedged download in the background so it
|
||||
+ * never holds the devlink lock; info and flash become
|
||||
+ * available once ready.
|
||||
+ */
|
||||
+ dev_warn(ds->dev,
|
||||
+ "switch in MCUboot with an interrupted download, recovering in background\n");
|
||||
+ queue_work(system_long_wq, &priv->rescue_heal_work);
|
||||
+ }
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
/* Calculate Extended VLAN block sizes.
|
||||
* With VLAN Filter handling VID membership checks:
|
||||
* Ingress: only final catchall rules (PVID insertion, 802.1Q
|
||||
@@ -785,11 +830,21 @@ static int mxl862xx_port_state(struct ds
|
||||
static int mxl862xx_port_enable(struct dsa_switch *ds, int port,
|
||||
struct phy_device *phydev)
|
||||
{
|
||||
+ struct mxl862xx_priv *priv = ds->priv;
|
||||
+
|
||||
+ if (priv->rescue_mode)
|
||||
+ return 0;
|
||||
+
|
||||
return mxl862xx_port_state(ds, port, true);
|
||||
}
|
||||
|
||||
static void mxl862xx_port_disable(struct dsa_switch *ds, int port)
|
||||
{
|
||||
+ struct mxl862xx_priv *priv = ds->priv;
|
||||
+
|
||||
+ if (priv->rescue_mode)
|
||||
+ return;
|
||||
+
|
||||
if (mxl862xx_port_state(ds, port, false))
|
||||
dev_err(ds->dev, "failed to disable port %d\n", port);
|
||||
}
|
||||
@@ -1407,6 +1462,17 @@ static int mxl862xx_port_setup(struct ds
|
||||
bool is_cpu_port = dsa_port_is_cpu(dp);
|
||||
int ret;
|
||||
|
||||
+ if (dsa_port_is_dsa(dp)) {
|
||||
+ dev_err(ds->dev, "port %d: DSA links not supported\n", port);
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ /* DSA reinits failed user ports as unused; shared ports must
|
||||
+ * succeed for the tree to register.
|
||||
+ */
|
||||
+ if (priv->rescue_mode)
|
||||
+ return dsa_port_is_user(dp) ? -ENODEV : 0;
|
||||
+
|
||||
ret = mxl862xx_port_state(ds, port, false);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1416,11 +1482,6 @@ static int mxl862xx_port_setup(struct ds
|
||||
if (dsa_port_is_unused(dp))
|
||||
return 0;
|
||||
|
||||
- if (dsa_port_is_dsa(dp)) {
|
||||
- dev_err(ds->dev, "port %d: DSA links not supported\n", port);
|
||||
- return -EOPNOTSUPP;
|
||||
- }
|
||||
-
|
||||
ret = mxl862xx_configure_sp_tag_proto(ds, port, is_cpu_port);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1642,11 +1703,11 @@ static int mxl862xx_port_mdb_del(struct
|
||||
ether_addr_copy(qparam.mac, mdb->addr);
|
||||
|
||||
ret = MXL862XX_API_READ(priv, MXL862XX_MAC_TABLEENTRYQUERY, qparam);
|
||||
- /* Post-flash teardown: the firmware and its MAC table are gone, so
|
||||
- * there is nothing left to delete. Outside it, -ENODEV is a bus error
|
||||
- * and must be reported.
|
||||
+ /* Post-flash teardown or MCUboot: the firmware and its MAC table are
|
||||
+ * gone, so there is nothing left to delete. Outside those, -ENODEV is a
|
||||
+ * bus error and must be reported.
|
||||
*/
|
||||
- if (ret == -ENODEV && priv->skip_teardown)
|
||||
+ if (ret == -ENODEV && (priv->skip_teardown || priv->rescue_mode))
|
||||
return 0;
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1704,6 +1765,9 @@ static void mxl862xx_port_stp_state_set(
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
int ret;
|
||||
|
||||
+ if (priv->rescue_mode)
|
||||
+ return;
|
||||
+
|
||||
switch (state) {
|
||||
case BR_STATE_DISABLED:
|
||||
param.port_state = cpu_to_le32(MXL862XX_STP_PORT_STATE_DISABLE);
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -4,7 +4,9 @@
|
||||
#define __MXL862XX_H
|
||||
|
||||
#include <asm/byteorder.h>
|
||||
+#include <linux/bitops.h>
|
||||
#include <linux/mdio.h>
|
||||
+#include <linux/mutex.h>
|
||||
#include <linux/workqueue.h>
|
||||
#include <net/dsa.h>
|
||||
|
||||
@@ -14,6 +16,10 @@ struct mxl862xx_priv;
|
||||
#define MXL862XX_FIRST_SERDES_PORT 9
|
||||
#define MXL862XX_SERDES_SLOTS 4
|
||||
|
||||
+/* mxl862xx_rescue_mode_detect() return codes (negative values are errors) */
|
||||
+#define MXL862XX_NOT_RESCUE 0
|
||||
+#define MXL862XX_IN_RESCUE 1
|
||||
+
|
||||
#define MXL862XX_DEFAULT_BRIDGE 0
|
||||
#define MXL862XX_MAX_BRIDGES 48
|
||||
#define MXL862XX_MAX_BRIDGE_PORTS 128
|
||||
@@ -327,6 +333,16 @@ struct mxl862xx_fw_version {
|
||||
* during a firmware flash
|
||||
* @skip_teardown: discard firmware API commands during the teardown
|
||||
* triggered by the post-flash reprobe
|
||||
+ * @rescue_mode: switch is in MCUboot; firmware API commands fail fast,
|
||||
+ * only clause-22 SMDIO works. Set from setup() before the
|
||||
+ * switch is registered and cleared under the MDIO bus lock
|
||||
+ * for the benefit of mxl862xx_api_wrap(); other readers
|
||||
+ * only need it to be a stable single flag.
|
||||
+ * @rescue_ready: (rescue_mode) loader is at a clean READY and will accept
|
||||
+ * a flash; false while rescue_heal_work is draining
|
||||
+ * @rescue_failed: (rescue_mode) the self-heal gave up; the loader needs a
|
||||
+ * power cycle and no flash can be accepted
|
||||
+ * @rescue_heal_work: background self-heal draining a wedged download to READY
|
||||
* @stats_work: periodic work item that polls RMON hardware counters
|
||||
* and accumulates them into 64-bit per-port stats
|
||||
*/
|
||||
@@ -334,6 +350,7 @@ struct mxl862xx_priv {
|
||||
struct dsa_switch *ds;
|
||||
struct mdio_device *mdiodev;
|
||||
struct work_struct crc_err_work;
|
||||
+ struct work_struct rescue_heal_work;
|
||||
unsigned long flags;
|
||||
u16 drop_meter;
|
||||
struct mxl862xx_fw_version fw_version;
|
||||
@@ -349,6 +366,9 @@ struct mxl862xx_priv {
|
||||
u16 vf_block_size;
|
||||
bool block_host;
|
||||
bool skip_teardown;
|
||||
+ bool rescue_mode;
|
||||
+ bool rescue_ready;
|
||||
+ bool rescue_failed;
|
||||
struct delayed_work stats_work;
|
||||
};
|
||||
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
From 3eb794a9c0ce3f5af8309e713d700a1469dbed23 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 7 Jul 2026 17:17:21 +0200
|
||||
Subject: [PATCH 01/12] net: dsa: tag_mxl862xx: leave offload_fwd_mark unset on
|
||||
trapped IGMP/MLD
|
||||
|
||||
The mxl862xx driver installs PCE rules on every user port which
|
||||
redirect IGMP and MLD frames exclusively to the CPU port, so the
|
||||
hardware no longer forwards or floods them to other ports. Setting
|
||||
skb->offload_fwd_mark on such frames makes
|
||||
nbp_switchdev_allowed_egress() suppress software forwarding towards
|
||||
ports of the same switch as well, with the result that IGMP and MLD
|
||||
frames never cross the switch at all: queries from an external
|
||||
querier are not delivered to hosts on other ports, reports never
|
||||
reach the querier, and multicast group state at the router expires.
|
||||
With multicast snooping disabled on the bridge these frames are
|
||||
blackholed entirely.
|
||||
|
||||
Frames which are trapped rather than forwarded by the hardware must
|
||||
be handed to the bridge without offload_fwd_mark so that the
|
||||
software bridge performs the forwarding decision, just like
|
||||
mv88e6xxx does for TO_CPU frames. The MxL862xx special tag carries
|
||||
no trap-reason indication, so classify received frames structurally,
|
||||
mirroring the PCE trap rule patterns: IPv4 packets carrying IP
|
||||
protocol 2 (IGMP, all types), and IPv6 packets whose final next
|
||||
header after any extension headers is ICMPv6 with type 130-132
|
||||
(MLDv1 query/report/done) or 143 (MLDv2 listener report). Like the
|
||||
hardware parser, the classifier looks through up to two VLAN tags
|
||||
and PPPoE session encapsulation.
|
||||
|
||||
Non-first IPv6 fragments and LLC/SNAP encapsulated frames are
|
||||
treated as not trapped; MLD is not fragmented in practice.
|
||||
|
||||
This change is ordered before the driver commit installing the trap
|
||||
rules. Until those rules are installed the affected frames are still
|
||||
flooded in hardware and may transiently be duplicated by the
|
||||
software bridge, which is harmless for IGMP/MLD control frames,
|
||||
whereas the opposite order would transiently blackhole them.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
net/dsa/tag_mxl862xx.c | 88 +++++++++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 87 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/net/dsa/tag_mxl862xx.c
|
||||
+++ b/net/dsa/tag_mxl862xx.c
|
||||
@@ -8,8 +8,15 @@
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/etherdevice.h>
|
||||
+#include <linux/icmpv6.h>
|
||||
+#include <linux/if_pppox.h>
|
||||
+#include <linux/if_vlan.h>
|
||||
+#include <linux/ip.h>
|
||||
+#include <linux/ipv6.h>
|
||||
+#include <linux/ppp_defs.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <net/dsa.h>
|
||||
+#include <net/ipv6.h>
|
||||
#include "tag.h"
|
||||
|
||||
#define MXL862_NAME "mxl862xx"
|
||||
@@ -56,6 +63,84 @@ static struct sk_buff *mxl862_tag_xmit(s
|
||||
return skb;
|
||||
}
|
||||
|
||||
+/* Must match the IGMP/MLD trap rules the mxl862xx driver installs on
|
||||
+ * all user ports; frames matching them reach the CPU port without
|
||||
+ * being forwarded in hardware.
|
||||
+ */
|
||||
+static bool mxl862_rcv_is_snoop_trapped(struct sk_buff *skb)
|
||||
+{
|
||||
+ unsigned int offset = MXL862_HEADER_LEN - 2;
|
||||
+ const struct ipv6hdr *ip6h;
|
||||
+ const struct iphdr *iph;
|
||||
+ struct ipv6hdr _ip6h;
|
||||
+ struct iphdr _iph;
|
||||
+ const __be16 *p;
|
||||
+ __be16 frag_off;
|
||||
+ __be16 _proto;
|
||||
+ __be16 proto;
|
||||
+ const u8 *tp;
|
||||
+ u8 nexthdr;
|
||||
+ int start;
|
||||
+ u8 _tp;
|
||||
+ int i;
|
||||
+
|
||||
+ p = skb_header_pointer(skb, offset, sizeof(_proto), &_proto);
|
||||
+ if (!p)
|
||||
+ return false;
|
||||
+ proto = *p;
|
||||
+
|
||||
+ for (i = 0; i < 2 && (proto == htons(ETH_P_8021Q) ||
|
||||
+ proto == htons(ETH_P_8021AD)); i++) {
|
||||
+ offset += VLAN_HLEN;
|
||||
+ p = skb_header_pointer(skb, offset, sizeof(_proto), &_proto);
|
||||
+ if (!p)
|
||||
+ return false;
|
||||
+ proto = *p;
|
||||
+ }
|
||||
+
|
||||
+ start = offset + 2;
|
||||
+
|
||||
+ if (proto == htons(ETH_P_PPP_SES)) {
|
||||
+ p = skb_header_pointer(skb, start + sizeof(struct pppoe_hdr),
|
||||
+ sizeof(_proto), &_proto);
|
||||
+ if (!p)
|
||||
+ return false;
|
||||
+ if (*p == htons(PPP_IP))
|
||||
+ proto = htons(ETH_P_IP);
|
||||
+ else if (*p == htons(PPP_IPV6))
|
||||
+ proto = htons(ETH_P_IPV6);
|
||||
+ else
|
||||
+ return false;
|
||||
+ start += PPPOE_SES_HLEN;
|
||||
+ }
|
||||
+
|
||||
+ if (proto == htons(ETH_P_IP)) {
|
||||
+ iph = skb_header_pointer(skb, start, sizeof(_iph), &_iph);
|
||||
+ return iph && iph->version == 4 &&
|
||||
+ iph->protocol == IPPROTO_IGMP;
|
||||
+ }
|
||||
+
|
||||
+ if (proto != htons(ETH_P_IPV6))
|
||||
+ return false;
|
||||
+
|
||||
+ ip6h = skb_header_pointer(skb, start, sizeof(_ip6h), &_ip6h);
|
||||
+ if (!ip6h || ip6h->version != 6)
|
||||
+ return false;
|
||||
+
|
||||
+ nexthdr = ip6h->nexthdr;
|
||||
+ start = ipv6_skip_exthdr(skb, start + sizeof(*ip6h), &nexthdr,
|
||||
+ &frag_off);
|
||||
+ if (start < 0 || frag_off != 0 || nexthdr != IPPROTO_ICMPV6)
|
||||
+ return false;
|
||||
+
|
||||
+ tp = skb_header_pointer(skb, start, sizeof(_tp), &_tp);
|
||||
+ if (!tp)
|
||||
+ return false;
|
||||
+
|
||||
+ return (*tp >= ICMPV6_MGM_QUERY && *tp <= ICMPV6_MGM_REDUCTION) ||
|
||||
+ *tp == ICMPV6_MLD2_REPORT;
|
||||
+}
|
||||
+
|
||||
static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
@@ -86,7 +171,8 @@ static struct sk_buff *mxl862_tag_rcv(st
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest)))
|
||||
+ if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest) &&
|
||||
+ !mxl862_rcv_is_snoop_trapped(skb)))
|
||||
dsa_default_offload_fwd_mark(skb);
|
||||
|
||||
/* remove the MxL862xx special tag between the MAC addresses and the
|
||||
+120
-48
@@ -1,7 +1,7 @@
|
||||
From 50a84327282120a51af12da91214ed9e06f585cb Mon Sep 17 00:00:00 2001
|
||||
From 37e3010db4b84caa239d97cb0f334542e7a7a1bb Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 18:51:13 +0000
|
||||
Subject: [PATCH 06/19] net: dsa: mxl862xx: trap link-local and multicast
|
||||
Subject: [PATCH 02/12] net: dsa: mxl862xx: trap link-local and multicast
|
||||
snooping frames to CPU
|
||||
|
||||
Install per-CTP PCE rules on each user port that trap IEEE 802.1D
|
||||
@@ -12,13 +12,21 @@ All trap rules share a common action helper,
|
||||
mxl862xx_fill_cpu_trap_action(), which sets PORTMAP_ALTERNATIVE to
|
||||
redirect frames to the CPU and enables cross-state forwarding so
|
||||
that frames reach the host even when the bridge port is in BLOCKING
|
||||
or LEARNING state.
|
||||
or LEARNING state. Learning is forced off for trapped frames so
|
||||
that their source addresses are not learned into the trap FID.
|
||||
|
||||
A dedicated bridge FID (cpu_trap_fid) is allocated during setup with
|
||||
all flood modes enabled. Each trap rule points the bridge engine at
|
||||
this FID via bFidEnable so that IGMP and MLD frames are never
|
||||
silently dropped by the ingress port's private flood policy.
|
||||
|
||||
The redirect is exclusive: matching frames are no longer forwarded
|
||||
or flooded to other ports by the hardware. The tag_mxl862xx receive
|
||||
path recognises these trapped frame classes and leaves
|
||||
skb->offload_fwd_mark unset, so the software bridge takes over
|
||||
forwarding of them (flooding queries, delivering reports to router
|
||||
ports), analogous to how mv88e6xxx handles TO_CPU frames.
|
||||
|
||||
Rules are written through the firmware's logical-index API,
|
||||
GSW_TFLOW_PCERULELOGICWRITE. The firmware translates the logical
|
||||
index in @rule->pattern.index into a physical position within the
|
||||
@@ -35,20 +43,25 @@ flow-control marking rule):
|
||||
index 3 -- ICMPv6 types 130-132 (MLDv1 query, report, done)
|
||||
index 4 -- ICMPv6 type 143 (MLDv2 Listener Report)
|
||||
|
||||
The MLDv1 rule matches the ICMPv6 type/code word in range mode,
|
||||
where the hardware accepts values from the base value up to base
|
||||
plus range span, inclusive: base 0x8200 (type 130, code 0) with
|
||||
span 0x02ff covers exactly types 130-132 with any code value.
|
||||
|
||||
Add the PCE rule firmware API structures, command definitions, and
|
||||
the rule block allocation interface.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-api.h | 684 ++++++++++++++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-api.h | 709 ++++++++++++++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-cmd.h | 6 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 198 +++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 225 +++++++-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.h | 8 +
|
||||
4 files changed, 896 insertions(+)
|
||||
4 files changed, 943 insertions(+), 5 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -1184,6 +1184,690 @@ struct mxl862xx_ctp_port_assignment {
|
||||
@@ -1197,6 +1197,715 @@ struct mxl862xx_ctp_port_assignment {
|
||||
__le16 bridge_port_id;
|
||||
} __packed;
|
||||
|
||||
@@ -88,7 +101,10 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * @mac_src_mask: Source MAC nibble mask
|
||||
+ * @app_data_msb: MSB application field (first 2 bytes after IP header,
|
||||
+ * typically TCP/UDP source port)
|
||||
+ * @app_mask_range_msb: MSB application mask or range value
|
||||
+ * @app_mask_range_msb: MSB application nibble mask, or range span when
|
||||
+ * @app_mask_range_msb_select is set: the rule then
|
||||
+ * matches values from @app_data_msb to
|
||||
+ * @app_data_msb + @app_mask_range_msb, inclusive
|
||||
+ * @ether_type: EtherType value to match
|
||||
+ * @ether_type_mask: EtherType nibble mask
|
||||
+ * @session_id: PPPoE session ID
|
||||
@@ -117,7 +133,10 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * @parser_flag1_msb_mask: Parser flag1 MSW mask
|
||||
+ * @app_data_lsb: LSB application field (next 2 bytes after @app_data_msb,
|
||||
+ * typically TCP/UDP destination port)
|
||||
+ * @app_mask_range_lsb: LSB application mask or range value
|
||||
+ * @app_mask_range_lsb: LSB application nibble mask, or range span when
|
||||
+ * @app_mask_range_lsb_select is set: the rule then
|
||||
+ * matches values from @app_data_lsb to
|
||||
+ * @app_data_lsb + @app_mask_range_lsb, inclusive
|
||||
+ * @insertion_flag: CPU-inserted packet flag
|
||||
+ * @vid_range: CTAG VLAN ID range (used as mask when @vid_range_select is 0)
|
||||
+ * @flex_field2_mask_range: Flexible field 2 mask or range
|
||||
@@ -509,6 +528,26 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * enum mxl862xx_pce_action_learning - MAC learning action selector
|
||||
+ *
|
||||
+ * Controls source address learning for packets matching the rule.
|
||||
+ *
|
||||
+ * @MXL862XX_PCE_ACTION_LEARNING_DISABLE: Learning action is disabled
|
||||
+ * @MXL862XX_PCE_ACTION_LEARNING_REGULAR: Enabled; learning follows the
|
||||
+ * regular port and bridge configuration
|
||||
+ * @MXL862XX_PCE_ACTION_LEARNING_FORCE_NOT: Enabled; the source address
|
||||
+ * of matching packets is never learned
|
||||
+ * @MXL862XX_PCE_ACTION_LEARNING_FORCE: Enabled; the source address of
|
||||
+ * matching packets is always learned
|
||||
+ */
|
||||
+enum mxl862xx_pce_action_learning {
|
||||
+ MXL862XX_PCE_ACTION_LEARNING_DISABLE = 0,
|
||||
+ MXL862XX_PCE_ACTION_LEARNING_REGULAR = 1,
|
||||
+ MXL862XX_PCE_ACTION_LEARNING_FORCE_NOT = 2,
|
||||
+ MXL862XX_PCE_ACTION_LEARNING_FORCE = 3,
|
||||
+};
|
||||
+
|
||||
+/**
|
||||
+ * struct mxl862xx_pce_action - PCE rule action configuration
|
||||
+ *
|
||||
+ * Defines the actions applied to packets matching a PCE rule pattern.
|
||||
@@ -538,9 +577,8 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * @traffic_class_action: Traffic class action selector
|
||||
+ * (0 = disable, 1 = regular CoS, 2 = alternative)
|
||||
+ * @snooping_type_action: IGMP snooping control selector
|
||||
+ * @learning_action: MAC learning action selector
|
||||
+ * (0 = disable, 1 = regular, 2 = force no learn,
|
||||
+ * 3 = force learn)
|
||||
+ * @learning_action: MAC learning action selector.
|
||||
+ * See &enum mxl862xx_pce_action_learning
|
||||
+ * @irq_action: Interrupt action selector
|
||||
+ * (0 = disable, 1 = regular, 2 = generate interrupt)
|
||||
+ * @cross_state_action: Cross state action selector.
|
||||
@@ -749,7 +787,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#define MXL862XX_BRDG_MAGIC 0x300
|
||||
#define MXL862XX_BRDGPORT_MAGIC 0x400
|
||||
#define MXL862XX_CTP_MAGIC 0x500
|
||||
@@ -30,6 +31,11 @@
|
||||
@@ -31,6 +32,11 @@
|
||||
#define MXL862XX_COMMON_CFGSET (MXL862XX_COMMON_MAGIC + 0xa)
|
||||
#define MXL862XX_COMMON_REGISTERMOD (MXL862XX_COMMON_MAGIC + 0x11)
|
||||
|
||||
@@ -771,23 +809,10 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#include <linux/if_bridge.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
@@ -251,9 +252,11 @@ static int mxl862xx_wait_ready(struct ds
|
||||
ver.iv_major, ver.iv_minor,
|
||||
le16_to_cpu(ver.iv_revision),
|
||||
le32_to_cpu(ver.iv_build_num));
|
||||
+
|
||||
priv->fw_version.major = ver.iv_major;
|
||||
priv->fw_version.minor = ver.iv_minor;
|
||||
priv->fw_version.revision = le16_to_cpu(ver.iv_revision);
|
||||
+
|
||||
return 0;
|
||||
|
||||
not_ready_yet:
|
||||
@@ -381,6 +384,170 @@ static int mxl862xx_setup_drop_meter(str
|
||||
@@ -451,6 +452,173 @@ static int mxl862xx_setup_drop_meter(str
|
||||
return MXL862XX_API_WRITE(priv, MXL862XX_COMMON_REGISTERMOD, reg);
|
||||
}
|
||||
|
||||
+
|
||||
+/* Per-CTP logical indices for protocol trap rules.
|
||||
+ *
|
||||
+ * The firmware pre-allocates a per-CTP PCE block for every port during
|
||||
@@ -830,10 +855,10 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * Cross-state is enabled so trapped frames bypass STP port state.
|
||||
+ */
|
||||
+static void mxl862xx_fill_cpu_trap_action(struct dsa_switch *ds, int port,
|
||||
+ struct mxl862xx_pce_rule *rule)
|
||||
+ struct mxl862xx_pce_rule *rule)
|
||||
+{
|
||||
+ struct mxl862xx_priv *priv = ds->priv;
|
||||
+ int cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
|
||||
+ struct mxl862xx_priv *priv = ds->priv;
|
||||
+
|
||||
+ rule->action.port_map_action =
|
||||
+ cpu_to_le32(MXL862XX_PCE_ACTION_PORTMAP_ALTERNATIVE);
|
||||
@@ -842,6 +867,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ rule->action.cross_state_action =
|
||||
+ cpu_to_le32(MXL862XX_PCE_ACTION_CROSS_STATE_CROSS);
|
||||
+
|
||||
+ rule->action.learning_action =
|
||||
+ cpu_to_le32(MXL862XX_PCE_ACTION_LEARNING_FORCE_NOT);
|
||||
+
|
||||
+ rule->action.fid_enable = 1;
|
||||
+ rule->action.fid = priv->cpu_trap_fid;
|
||||
+}
|
||||
@@ -892,9 +920,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * index 4 -- ICMPv6 type 143 (MLDv2 Listener Report)
|
||||
+ *
|
||||
+ * The MLDv1 rule uses range mode on the first two bytes after the IP
|
||||
+ * header (ICMPv6 type + code): lower bound 0x8200 (type 130, code 0)
|
||||
+ * to upper bound 0x84ff (type 132, code 255). The MLDv2 rule uses
|
||||
+ * nibble mask 0x3 to match type 143 with any code byte.
|
||||
+ * header (ICMPv6 type + code): base 0x8200 (type 130, code 0), span
|
||||
+ * 0x02ff (up to type 132, code 255). The MLDv2 rule uses nibble mask
|
||||
+ * 0x3 to match type 143 with any code byte.
|
||||
+ */
|
||||
+static int mxl862xx_setup_snooping_traps(struct dsa_switch *ds, int port)
|
||||
+{
|
||||
@@ -927,7 +955,8 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ rule.pattern.app_data_msb =
|
||||
+ cpu_to_le16((u16)ICMPV6_MGM_QUERY << 8);
|
||||
+ rule.pattern.app_mask_range_msb =
|
||||
+ cpu_to_le16(((u16)ICMPV6_MGM_REDUCTION << 8) | 0xff);
|
||||
+ cpu_to_le16(((u16)(ICMPV6_MGM_REDUCTION -
|
||||
+ ICMPV6_MGM_QUERY) << 8) | 0xff);
|
||||
+ rule.pattern.app_data_msb_enable = 1;
|
||||
+ rule.pattern.app_mask_range_msb_select = 1; /* range mode */
|
||||
+
|
||||
@@ -954,11 +983,38 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
static int mxl862xx_set_bridge_port(struct dsa_switch *ds, int port)
|
||||
{
|
||||
struct mxl862xx_bridge_port_config br_port_cfg = {};
|
||||
@@ -684,6 +851,28 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
@@ -666,17 +834,23 @@ static int mxl862xx_allocate_bridge(stru
|
||||
return le16_to_cpu(br_alloc.bridge_id);
|
||||
}
|
||||
|
||||
+static int mxl862xx_free_fw_bridge(struct mxl862xx_priv *priv, u16 fw_id)
|
||||
+{
|
||||
+ struct mxl862xx_bridge_alloc br_alloc = {
|
||||
+ .bridge_id = cpu_to_le16(fw_id),
|
||||
+ };
|
||||
+
|
||||
+ return MXL862XX_API_WRITE(priv, MXL862XX_BRIDGE_FREE, br_alloc);
|
||||
+}
|
||||
+
|
||||
static void mxl862xx_free_bridge(struct dsa_switch *ds,
|
||||
const struct dsa_bridge *bridge)
|
||||
{
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
u16 fw_id = priv->bridges[bridge->num];
|
||||
- struct mxl862xx_bridge_alloc br_alloc = {
|
||||
- .bridge_id = cpu_to_le16(fw_id),
|
||||
- };
|
||||
int ret;
|
||||
|
||||
- ret = MXL862XX_API_WRITE(priv, MXL862XX_BRIDGE_FREE, br_alloc);
|
||||
+ ret = mxl862xx_free_fw_bridge(priv, fw_id);
|
||||
if (ret) {
|
||||
dev_err(ds->dev, "failed to free fw bridge %u: %pe\n",
|
||||
fw_id, ERR_PTR(ret));
|
||||
@@ -800,10 +974,42 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
+
|
||||
+ /* Allocate a dedicated PCE snooping FID with all flood modes enabled.
|
||||
+ * Per-port PCE trap rules (link-local, IGMP, MLD) set bFidEnable to
|
||||
+ * this FID so that the bridge engine uses it for its flood-permission
|
||||
@@ -971,19 +1027,35 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (WARN_ON_ONCE(ret > 0x3F))
|
||||
+ return -ERANGE;
|
||||
+
|
||||
+ priv->cpu_trap_fid = ret;
|
||||
+
|
||||
+ if (WARN_ON_ONCE(priv->cpu_trap_fid > 0x3F)) {
|
||||
+ ret = -ERANGE;
|
||||
+ goto free_trap_fid;
|
||||
+ }
|
||||
+
|
||||
+ ret = mxl862xx_bridge_config_fwd(ds, priv->cpu_trap_fid,
|
||||
+ true, true, true);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ goto free_trap_fid;
|
||||
+
|
||||
+ ret = mxl862xx_setup_mdio(ds);
|
||||
+ if (ret)
|
||||
+ goto free_trap_fid;
|
||||
+
|
||||
schedule_delayed_work(&priv->stats_work,
|
||||
MXL862XX_STATS_POLL_INTERVAL);
|
||||
|
||||
@@ -1383,6 +1572,15 @@ static int mxl862xx_port_setup(struct ds
|
||||
- return mxl862xx_setup_mdio(ds);
|
||||
+ return 0;
|
||||
+
|
||||
+free_trap_fid:
|
||||
+ mxl862xx_free_fw_bridge(priv, priv->cpu_trap_fid);
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
static int mxl862xx_port_state(struct dsa_switch *ds, int port, bool enable)
|
||||
@@ -1515,6 +1721,15 @@ static int mxl862xx_port_setup(struct ds
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -1001,10 +1073,10 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -317,6 +317,13 @@ struct mxl862xx_fw_version {
|
||||
* @evlan_ingress_size: per-port ingress Extended VLAN block size
|
||||
* @evlan_egress_size: per-port egress Extended VLAN block size
|
||||
* @vf_block_size: per-port VLAN Filter block size
|
||||
@@ -343,6 +343,13 @@ struct mxl862xx_fw_version {
|
||||
* @rescue_failed: (rescue_mode) the self-heal gave up; the loader needs a
|
||||
* power cycle and no flash can be accepted
|
||||
* @rescue_heal_work: background self-heal draining a wedged download to READY
|
||||
+ * @cpu_trap_fid: firmware bridge FID allocated for PCE-trapped frames;
|
||||
+ * configured with uc/mc/bc flood all enabled so that
|
||||
+ * IGMP, MLD, and link-local frames always reach the CPU
|
||||
@@ -1015,10 +1087,10 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @stats_work: periodic work item that polls RMON hardware counters
|
||||
* and accumulates them into 64-bit per-port stats
|
||||
*/
|
||||
@@ -334,6 +341,7 @@ struct mxl862xx_priv {
|
||||
u16 evlan_ingress_size;
|
||||
u16 evlan_egress_size;
|
||||
u16 vf_block_size;
|
||||
@@ -369,6 +376,7 @@ struct mxl862xx_priv {
|
||||
bool rescue_mode;
|
||||
bool rescue_ready;
|
||||
bool rescue_failed;
|
||||
+ u16 cpu_trap_fid;
|
||||
struct delayed_work stats_work;
|
||||
};
|
||||
+9
-9
@@ -1,7 +1,7 @@
|
||||
From 6126dff8c28e71091c23fd0cc2f55b1a50e117a6 Mon Sep 17 00:00:00 2001
|
||||
From 685beb8e962d7e7a0b1a7b5aed1a4669308141cd Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 18:51:21 +0000
|
||||
Subject: [PATCH 07/19] net: dsa: mxl862xx: warn about old firmware default PCE
|
||||
Subject: [PATCH 03/12] net: dsa: mxl862xx: warn about old firmware default PCE
|
||||
rules
|
||||
|
||||
Firmware versions older than 1.0.80 install global PCE rules at
|
||||
@@ -19,14 +19,14 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -873,6 +873,10 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
true, true, true);
|
||||
@@ -998,6 +998,10 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
if (ret)
|
||||
return ret;
|
||||
+
|
||||
goto free_trap_fid;
|
||||
|
||||
+ if (!MXL862XX_FW_VER_MIN(priv, 1, 0, 80))
|
||||
+ dev_warn(ds->dev, "firmware < 1.0.80 installs global PCE rules "
|
||||
+ "that interfere with DSA operation, please update\n");
|
||||
schedule_delayed_work(&priv->stats_work,
|
||||
MXL862XX_STATS_POLL_INTERVAL);
|
||||
|
||||
+
|
||||
ret = mxl862xx_setup_mdio(ds);
|
||||
if (ret)
|
||||
goto free_trap_fid;
|
||||
+330
-79
@@ -1,7 +1,7 @@
|
||||
From 69a0946ef48325b85f4a331152d6340f39083053 Mon Sep 17 00:00:00 2001
|
||||
From a09bb7727358764e8bac42d3b15f6c997a9cef89 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Sun, 22 Mar 2026 00:58:04 +0000
|
||||
Subject: [PATCH 08/19] net: dsa: add 802.1Q VLAN-based tag driver for MxL862xx
|
||||
Subject: [PATCH 04/12] net: dsa: add 802.1Q VLAN-based tag driver for MxL862xx
|
||||
|
||||
The MxL862xx native 8-byte special tag (SpTag) requires firmware
|
||||
support on the switch CPU and is not compatible with all SoC Ethernet
|
||||
@@ -17,18 +17,35 @@ switch_id and source port from the management VID in the receive
|
||||
path. Set promisc_on_conduit so the conduit interface accepts
|
||||
frames with management VIDs that are not in its own VLAN filter.
|
||||
|
||||
The driver installs its link-local and IGMP/MLD snooping trap rules
|
||||
regardless of the tag protocol in use, so frames trapped to the CPU
|
||||
must be exempted from offload_fwd_mark in 802.1Q mode as well, as
|
||||
otherwise they are blackholed just as described in commit
|
||||
("net: dsa: tag_mxl862xx: leave offload_fwd_mark unset on trapped
|
||||
IGMP/MLD"). Move the structural IGMP/MLD classifier to a header
|
||||
shared by both tag drivers, taking the outermost EtherType and the
|
||||
offset of its payload as parameters: the SpTag driver passes the
|
||||
EtherType following the special tag, whose presence in the linear
|
||||
data area is already guaranteed by the existing pskb_may_pull()
|
||||
call, while the 802.1Q driver starts from eth_hdr()->h_proto after
|
||||
dsa_8021q_rcv() has removed the VLAN tag and left skb->data at the
|
||||
network header.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/Kconfig | 1 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-api.h | 221 +++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-cmd.h | 2 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 1677 ++++++++++++++++++++---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 1697 ++++++++++++++++++++---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.h | 12 +
|
||||
include/net/dsa.h | 2 +
|
||||
net/dsa/Kconfig | 7 +
|
||||
net/dsa/Makefile | 1 +
|
||||
net/dsa/tag_mxl862xx_8021q.c | 65 +
|
||||
9 files changed, 1804 insertions(+), 184 deletions(-)
|
||||
net/dsa/tag_mxl862xx.c | 89 +-
|
||||
net/dsa/tag_mxl862xx.h | 92 ++
|
||||
net/dsa/tag_mxl862xx_8021q.c | 70 +
|
||||
11 files changed, 1917 insertions(+), 277 deletions(-)
|
||||
create mode 100644 net/dsa/tag_mxl862xx.h
|
||||
create mode 100644 net/dsa/tag_mxl862xx_8021q.c
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/Kconfig
|
||||
@@ -43,7 +60,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
These switches have two 10GE SerDes interfaces, one typically
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -1184,6 +1184,227 @@ struct mxl862xx_ctp_port_assignment {
|
||||
@@ -1197,6 +1197,227 @@ struct mxl862xx_ctp_port_assignment {
|
||||
__le16 bridge_port_id;
|
||||
} __packed;
|
||||
|
||||
@@ -273,7 +290,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* Binary layout must exactly match the firmware's GSW_PCE_rule_t
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -47,12 +47,14 @@
|
||||
@@ -48,12 +48,14 @@
|
||||
#define MXL862XX_BRIDGEPORT_FREE (MXL862XX_BRDGPORT_MAGIC + 0x4)
|
||||
|
||||
#define MXL862XX_CTP_PORTASSIGNMENTSET (MXL862XX_CTP_MAGIC + 0x3)
|
||||
@@ -298,7 +315,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#include <net/dsa.h>
|
||||
|
||||
#include "mxl862xx.h"
|
||||
@@ -88,6 +89,9 @@ enum mxl862xx_evlan_action {
|
||||
@@ -96,6 +97,9 @@ enum mxl862xx_evlan_action {
|
||||
EVLAN_STRIP_IF_UNTAGGED, /* remove 1 tag if entry's untagged flag set */
|
||||
EVLAN_PVID_OR_DISCARD, /* insert PVID tag or discard if no PVID */
|
||||
EVLAN_STRIP1_AND_PVID_OR_DISCARD,/* strip 1 tag + insert PVID, or discard */
|
||||
@@ -308,7 +325,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
};
|
||||
|
||||
struct mxl862xx_evlan_rule_desc {
|
||||
@@ -97,6 +101,7 @@ struct mxl862xx_evlan_rule_desc {
|
||||
@@ -105,6 +109,7 @@ struct mxl862xx_evlan_rule_desc {
|
||||
u8 inner_tpid; /* enum mxl862xx_extended_vlan_filter_tpid */
|
||||
bool match_vid; /* true: match on VID from the vid parameter */
|
||||
u8 action; /* enum mxl862xx_evlan_action */
|
||||
@@ -316,7 +333,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
};
|
||||
|
||||
/* Shorthand constants for readability */
|
||||
@@ -162,11 +167,69 @@ static const struct mxl862xx_evlan_rule_
|
||||
@@ -170,11 +175,69 @@ static const struct mxl862xx_evlan_rule_
|
||||
{ FT_NO_FILTER, FT_NO_TAG, TP_NONE, TP_NONE, false, EVLAN_STRIP_IF_UNTAGGED },
|
||||
};
|
||||
|
||||
@@ -387,7 +404,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
/* PHY access via firmware relay */
|
||||
@@ -410,6 +473,78 @@ static int mxl862xx_pce_rule_write(struc
|
||||
@@ -477,6 +540,78 @@ static int mxl862xx_pce_rule_write(struc
|
||||
*rule);
|
||||
}
|
||||
|
||||
@@ -466,7 +483,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
/* Fill the action fields of a PCE rule that traps ingress frames to
|
||||
* the CPU port. Used by both the link-local trap and the multicast
|
||||
* snooping traps. The caller must already have set the rule header
|
||||
@@ -418,24 +553,36 @@ static int mxl862xx_pce_rule_write(struc
|
||||
@@ -485,24 +620,36 @@ static int mxl862xx_pce_rule_write(struc
|
||||
* PORTMAP_ALTERNATIVE redirects the frame to the CPU port but does
|
||||
* not by itself bypass downstream flood gates. In SpTag mode the
|
||||
* ingress port's private FID may have forward_unknown_multicast=false,
|
||||
@@ -485,11 +502,12 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ * state.
|
||||
*/
|
||||
static void mxl862xx_fill_cpu_trap_action(struct dsa_switch *ds, int port,
|
||||
struct mxl862xx_pce_rule *rule)
|
||||
struct mxl862xx_pce_rule *rule)
|
||||
{
|
||||
- int cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
+ struct mxl862xx_port *p = &priv->ports[port];
|
||||
int cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
|
||||
+ int cpu_port = dsa_to_port(ds, port)->cpu_dp->index;
|
||||
|
||||
rule->action.port_map_action =
|
||||
cpu_to_le32(MXL862XX_PCE_ACTION_PORTMAP_ALTERNATIVE);
|
||||
@@ -505,7 +523,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
rule->action.cross_state_action =
|
||||
cpu_to_le32(MXL862XX_PCE_ACTION_CROSS_STATE_CROSS);
|
||||
|
||||
@@ -564,11 +711,17 @@ static int mxl862xx_set_bridge_port(stru
|
||||
@@ -635,11 +782,17 @@ static int mxl862xx_set_bridge_port(stru
|
||||
return 0;
|
||||
|
||||
if (dsa_port_is_cpu(dp)) {
|
||||
@@ -528,7 +546,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
} else if (dp->bridge) {
|
||||
dsa_switch_for_each_bridge_member(member_dp, ds,
|
||||
@@ -579,10 +732,10 @@ static int mxl862xx_set_bridge_port(stru
|
||||
@@ -650,10 +803,10 @@ static int mxl862xx_set_bridge_port(stru
|
||||
member_dp->index);
|
||||
}
|
||||
mxl862xx_fw_portmap_set_bit(br_port_cfg.bridge_port_map,
|
||||
@@ -541,7 +559,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
p->flood_block = 0;
|
||||
p->learning = false;
|
||||
}
|
||||
@@ -786,10 +939,12 @@ static void mxl862xx_free_bridge(struct
|
||||
@@ -863,10 +1016,12 @@ static void mxl862xx_free_bridge(struct
|
||||
static int mxl862xx_setup(struct dsa_switch *ds)
|
||||
{
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
@@ -550,22 +568,22 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ int cpu_egress_rules, cpu_ingress_per_port;
|
||||
int ingress_finals, vid_rules;
|
||||
+ int egress_catchalls, evlan_reserved;
|
||||
+ int ret, i, rescue, port;
|
||||
struct dsa_port *dp;
|
||||
- int ret, i;
|
||||
+ int ret, i, port;
|
||||
- int ret, i, rescue;
|
||||
|
||||
ret = mxl862xx_reset(priv);
|
||||
if (ret)
|
||||
@@ -803,7 +958,7 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
mxl862xx_setup_pcs(priv, &priv->serdes_ports[i],
|
||||
i + MXL862XX_FIRST_SERDES_PORT);
|
||||
/* The SerDes state is software-only and must exist before anything can
|
||||
* reach phylink, including a rescue-mode flash clearing rescue_mode
|
||||
@@ -926,7 +1081,7 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
return 0;
|
||||
}
|
||||
|
||||
- /* Calculate Extended VLAN block sizes.
|
||||
+ /* Calculate Extended VLAN and VLAN Filter block sizes.
|
||||
* With VLAN Filter handling VID membership checks:
|
||||
* Ingress: only final catchall rules (PVID insertion, 802.1Q
|
||||
* accept, non-8021Q TPID handling, discard).
|
||||
@@ -811,46 +966,151 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
@@ -934,46 +1089,151 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
* ingress EVLAN rules are needed. (7 entries.)
|
||||
* Egress: 2 rules per VID that needs tag stripping (untagged VIDs).
|
||||
* No egress final catchalls -- VLAN Filter does the discard.
|
||||
@@ -726,21 +744,21 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
|
||||
/* Allocate a dedicated PCE snooping FID with all flood modes enabled.
|
||||
* Per-port PCE trap rules (link-local, IGMP, MLD) set bFidEnable to
|
||||
@@ -873,10 +1133,6 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
true, true, true);
|
||||
* this FID so that the bridge engine uses it for its flood-permission
|
||||
@@ -998,10 +1258,6 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
if (ret)
|
||||
return ret;
|
||||
-
|
||||
goto free_trap_fid;
|
||||
|
||||
- if (!MXL862XX_FW_VER_MIN(priv, 1, 0, 80))
|
||||
- dev_warn(ds->dev, "firmware < 1.0.80 installs global PCE rules "
|
||||
- "that interfere with DSA operation, please update\n");
|
||||
schedule_delayed_work(&priv->stats_work,
|
||||
MXL862XX_STATS_POLL_INTERVAL);
|
||||
|
||||
@@ -957,10 +1213,71 @@ static int mxl862xx_configure_sp_tag_pro
|
||||
-
|
||||
ret = mxl862xx_setup_mdio(ds);
|
||||
if (ret)
|
||||
goto free_trap_fid;
|
||||
@@ -1100,10 +1356,71 @@ static int mxl862xx_configure_sp_tag_pro
|
||||
return MXL862XX_API_WRITE(ds->priv, MXL862XX_SS_SPTAG_SET, tag);
|
||||
}
|
||||
|
||||
@@ -813,7 +831,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
{
|
||||
struct mxl862xx_extendedvlan_config cfg = {};
|
||||
struct mxl862xx_extendedvlan_filter_vlan *fv;
|
||||
@@ -1029,6 +1346,31 @@ static int mxl862xx_evlan_write_rule(str
|
||||
@@ -1172,6 +1489,31 @@ static int mxl862xx_evlan_write_rule(str
|
||||
cpu_to_le32(MXL862XX_EXTENDEDVLAN_TREATMENT_DISCARD_UPSTREAM);
|
||||
}
|
||||
break;
|
||||
@@ -845,7 +863,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
return MXL862XX_API_WRITE(priv, MXL862XX_EXTENDEDVLAN_SET, cfg);
|
||||
@@ -1067,7 +1409,7 @@ static int mxl862xx_evlan_write_final_ru
|
||||
@@ -1210,7 +1552,7 @@ static int mxl862xx_evlan_write_final_ru
|
||||
for (i = 0; i < n_rules; i++) {
|
||||
ret = mxl862xx_evlan_write_rule(priv, blk->block_id,
|
||||
start_idx + i, &rules[i],
|
||||
@@ -854,7 +872,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
@@ -1188,6 +1530,41 @@ static int mxl862xx_vf_del_vid(struct mx
|
||||
@@ -1331,6 +1673,41 @@ static int mxl862xx_vf_del_vid(struct mx
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -896,7 +914,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
static int mxl862xx_evlan_program_ingress(struct mxl862xx_priv *priv, int port)
|
||||
{
|
||||
struct mxl862xx_port *p = &priv->ports[port];
|
||||
@@ -1212,8 +1589,8 @@ static int mxl862xx_evlan_program_egress
|
||||
@@ -1355,8 +1732,8 @@ static int mxl862xx_evlan_program_egress
|
||||
const struct mxl862xx_evlan_rule_desc *vid_rules;
|
||||
struct mxl862xx_vf_vid *vfv;
|
||||
u16 old_active = blk->n_active;
|
||||
@@ -906,7 +924,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
if (p->vlan_filtering) {
|
||||
vid_rules = vid_accept_standard;
|
||||
@@ -1227,13 +1604,23 @@ static int mxl862xx_evlan_program_egress
|
||||
@@ -1370,13 +1747,23 @@ static int mxl862xx_evlan_program_egress
|
||||
if (!vfv->untagged)
|
||||
continue;
|
||||
|
||||
@@ -931,7 +949,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -1242,7 +1629,29 @@ static int mxl862xx_evlan_program_egress
|
||||
@@ -1385,7 +1772,29 @@ static int mxl862xx_evlan_program_egress
|
||||
idx++, &vid_rules[1],
|
||||
vfv->vid,
|
||||
vfv->untagged,
|
||||
@@ -962,7 +980,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
@@ -1254,8 +1663,7 @@ static int mxl862xx_evlan_program_egress
|
||||
@@ -1397,8 +1806,7 @@ static int mxl862xx_evlan_program_egress
|
||||
*/
|
||||
for (i = idx; i < old_active; i++) {
|
||||
ret = mxl862xx_evlan_deactivate_entry(priv,
|
||||
@@ -972,7 +990,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
@@ -1280,13 +1688,16 @@ static int mxl862xx_port_vlan_filtering(
|
||||
@@ -1423,13 +1831,16 @@ static int mxl862xx_port_vlan_filtering(
|
||||
p->vlan_filtering = vlan_filtering;
|
||||
|
||||
if (changed) {
|
||||
@@ -994,7 +1012,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
ret = mxl862xx_evlan_program_ingress(priv, port);
|
||||
if (ret)
|
||||
@@ -1506,22 +1917,575 @@ static void mxl862xx_port_bridge_leave(s
|
||||
@@ -1649,22 +2060,581 @@ static void mxl862xx_port_bridge_leave(s
|
||||
port, ERR_PTR(err));
|
||||
|
||||
/* Revert leaving port, omitted by the sync above, to its
|
||||
@@ -1450,6 +1468,12 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct dsa_port *dp;
|
||||
+ int ret, port;
|
||||
+
|
||||
+ /* Just do nothing when in rescue mode */
|
||||
+ if (priv->rescue_mode) {
|
||||
+ priv->tag_proto = proto;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ /* Flush all MAC entries on tag protocol change. Host entries
|
||||
+ * installed via portmap (tag_8021q VBP-based) vs single port_id
|
||||
+ * (SpTag) are not compatible across modes.
|
||||
@@ -1572,9 +1596,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
static int mxl862xx_port_setup(struct dsa_switch *ds, int port)
|
||||
{
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
@@ -1543,33 +2507,52 @@ static int mxl862xx_port_setup(struct ds
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -1692,33 +2662,52 @@ static int mxl862xx_port_setup(struct ds
|
||||
if (dsa_port_is_unused(dp))
|
||||
return 0;
|
||||
|
||||
- ret = mxl862xx_configure_sp_tag_proto(ds, port, is_cpu_port);
|
||||
+ /* configure tag protocol: SpTag for native, disable for 8021q */
|
||||
@@ -1641,7 +1665,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = mxl862xx_set_bridge_port(ds, port);
|
||||
@@ -1585,24 +2568,7 @@ static int mxl862xx_port_setup(struct ds
|
||||
@@ -1734,24 +2723,7 @@ static int mxl862xx_port_setup(struct ds
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -1666,7 +1690,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1624,7 +2590,7 @@ static void mxl862xx_port_teardown(struc
|
||||
@@ -1773,7 +2745,7 @@ static void mxl862xx_port_teardown(struc
|
||||
priv->ports[port].setup_done = false;
|
||||
}
|
||||
|
||||
@@ -1675,7 +1699,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
{
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
|
||||
@@ -1642,23 +2608,247 @@ static int mxl862xx_get_fid(struct dsa_s
|
||||
@@ -1791,23 +2763,253 @@ static int mxl862xx_get_fid(struct dsa_s
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1708,12 +1732,12 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ if (dsa_is_cpu_port(ds, port) && priv->tag_proto == DSA_TAG_PROTO_MXL862_8021Q &&
|
||||
+ db.type == DSA_DB_PORT) {
|
||||
+ bp_cpu = priv->ports[db.dp->index].bridge_port_cpu;
|
||||
|
||||
- param.port_id = cpu_to_le32(port);
|
||||
+
|
||||
+ if (bp_cpu)
|
||||
+ return bp_cpu;
|
||||
+ }
|
||||
+
|
||||
|
||||
- param.port_id = cpu_to_le32(port);
|
||||
+ return port;
|
||||
+}
|
||||
+
|
||||
@@ -1826,6 +1850,12 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ qparam.tci = cpu_to_le16(FIELD_PREP(MXL862XX_TCI_VLAN_ID, vid));
|
||||
+
|
||||
+ ret = MXL862XX_API_READ(priv, MXL862XX_MAC_TABLEENTRYQUERY, qparam);
|
||||
+ /* Post-flash teardown or MCUboot: the firmware and its MAC table are
|
||||
+ * gone, so there is nothing left to delete. Outside those, -ENODEV is a
|
||||
+ * bus error and must be reported.
|
||||
+ */
|
||||
+ if (ret == -ENODEV && (priv->skip_teardown || priv->rescue_mode))
|
||||
+ return 0;
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
@@ -1931,7 +1961,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
dev_err(ds->dev, "failed to add FDB entry on port %d\n", port);
|
||||
|
||||
@@ -1668,18 +2858,25 @@ static int mxl862xx_port_fdb_add(struct
|
||||
@@ -1817,18 +3019,25 @@ static int mxl862xx_port_fdb_add(struct
|
||||
static int mxl862xx_port_fdb_del(struct dsa_switch *ds, int port,
|
||||
const unsigned char *addr, u16 vid, const struct dsa_db db)
|
||||
{
|
||||
@@ -1964,7 +1994,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
dev_err(ds->dev, "failed to remove FDB entry on port %d\n", port);
|
||||
|
||||
@@ -1718,84 +2915,153 @@ static int mxl862xx_port_fdb_dump(struct
|
||||
@@ -1867,90 +3076,153 @@ static int mxl862xx_port_fdb_dump(struct
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2065,8 +2095,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
- sizeof(aparam.port_map));
|
||||
+ return ret;
|
||||
+}
|
||||
|
||||
- mxl862xx_fw_portmap_set_bit(aparam.port_map, port);
|
||||
+
|
||||
+/**
|
||||
+ * mxl862xx_mac_del_host_bridge - Remove every user-port VBP bit from a host
|
||||
+ * FDB/MDB entry, dropping the entry when its
|
||||
@@ -2090,13 +2119,14 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ struct dsa_port *dp;
|
||||
+ u16 vbp;
|
||||
|
||||
- return MXL862XX_API_WRITE(priv, MXL862XX_MAC_TABLEENTRYADD, aparam);
|
||||
- mxl862xx_fw_portmap_set_bit(aparam.port_map, port);
|
||||
+ dsa_switch_for_each_user_port(dp, ds) {
|
||||
+ vbp = priv->ports[dp->index].bridge_port_cpu;
|
||||
+ if (vbp)
|
||||
+ mxl862xx_fw_portmap_set_bit(del_map, vbp);
|
||||
+ }
|
||||
+
|
||||
|
||||
- return MXL862XX_API_WRITE(priv, MXL862XX_MAC_TABLEENTRYADD, aparam);
|
||||
+ return mxl862xx_mac_portmap_del(priv, addr, fid, vid, del_map);
|
||||
}
|
||||
|
||||
@@ -2130,6 +2160,12 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
- ether_addr_copy(qparam.mac, mdb->addr);
|
||||
-
|
||||
- ret = MXL862XX_API_READ(priv, MXL862XX_MAC_TABLEENTRYQUERY, qparam);
|
||||
- /* Post-flash teardown or MCUboot: the firmware and its MAC table are
|
||||
- * gone, so there is nothing left to delete. Outside those, -ENODEV is a
|
||||
- * bus error and must be reported.
|
||||
- */
|
||||
- if (ret == -ENODEV && (priv->skip_teardown || priv->rescue_mode))
|
||||
- return 0;
|
||||
+ ret = mxl862xx_mdb_del_from_fid(ds, mdb, fid,
|
||||
+ mxl862xx_fdb_bridge_port(ds, port, db),
|
||||
+ mdb->vid);
|
||||
@@ -2165,7 +2201,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -1880,6 +3146,9 @@ static void mxl862xx_host_flood_work_fn(
|
||||
@@ -2038,6 +3310,9 @@ static void mxl862xx_host_flood_work_fn(
|
||||
host_flood_work);
|
||||
struct mxl862xx_priv *priv = p->priv;
|
||||
struct dsa_switch *ds = priv->ds;
|
||||
@@ -2175,7 +2211,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
rtnl_lock();
|
||||
|
||||
@@ -1889,13 +3158,34 @@ static void mxl862xx_host_flood_work_fn(
|
||||
@@ -2047,13 +3322,34 @@ static void mxl862xx_host_flood_work_fn(
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2217,7 +2253,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
rtnl_unlock();
|
||||
}
|
||||
@@ -2261,7 +3551,9 @@ static void mxl862xx_get_stats64(struct
|
||||
@@ -2425,7 +3721,9 @@ static void mxl862xx_get_stats64(struct
|
||||
|
||||
static const struct dsa_switch_ops mxl862xx_switch_ops = {
|
||||
.get_tag_protocol = mxl862xx_get_tag_protocol,
|
||||
@@ -2227,7 +2263,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
.port_setup = mxl862xx_port_setup,
|
||||
.port_teardown = mxl862xx_port_teardown,
|
||||
.phylink_get_caps = mxl862xx_phylink_get_caps,
|
||||
@@ -2283,6 +3575,8 @@ static const struct dsa_switch_ops mxl86
|
||||
@@ -2447,6 +3745,8 @@ static const struct dsa_switch_ops mxl86
|
||||
.port_vlan_filtering = mxl862xx_port_vlan_filtering,
|
||||
.port_vlan_add = mxl862xx_port_vlan_add,
|
||||
.port_vlan_del = mxl862xx_port_vlan_del,
|
||||
@@ -2236,7 +2272,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
.get_strings = mxl862xx_get_strings,
|
||||
.get_sset_count = mxl862xx_get_sset_count,
|
||||
.get_ethtool_stats = mxl862xx_get_ethtool_stats,
|
||||
@@ -2330,6 +3624,8 @@ static int mxl862xx_probe(struct mdio_de
|
||||
@@ -2502,6 +3802,8 @@ static int mxl862xx_probe(struct mdio_de
|
||||
|
||||
INIT_DELAYED_WORK(&priv->stats_work, mxl862xx_stats_work_fn);
|
||||
|
||||
@@ -2245,7 +2281,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
dev_set_drvdata(dev, ds);
|
||||
|
||||
err = dsa_register_switch(ds);
|
||||
@@ -2358,6 +3654,19 @@ static void mxl862xx_remove(struct mdio_
|
||||
@@ -2532,6 +3834,19 @@ static void mxl862xx_remove(struct mdio_
|
||||
set_bit(MXL862XX_FLAG_WORK_STOPPED, &priv->flags);
|
||||
cancel_delayed_work_sync(&priv->stats_work);
|
||||
|
||||
@@ -2267,7 +2303,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
mxl862xx_host_shutdown(priv);
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -212,6 +212,9 @@ struct mxl862xx_port_stats {
|
||||
@@ -218,6 +218,9 @@ struct mxl862xx_port_stats {
|
||||
* @vf: per-port VLAN Filter block state
|
||||
* @ingress_evlan: ingress extended VLAN block state
|
||||
* @egress_evlan: egress extended VLAN block state
|
||||
@@ -2277,7 +2313,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @host_flood_uc: desired host unicast flood state (true = flood);
|
||||
* updated atomically by port_set_host_flood, consumed
|
||||
* by the deferred host_flood_work
|
||||
@@ -226,6 +229,7 @@ struct mxl862xx_port_stats {
|
||||
@@ -232,6 +235,7 @@ struct mxl862xx_port_stats {
|
||||
* periodically by the stats polling work
|
||||
* @stats_lock: protects accumulator reads in .get_stats64 against
|
||||
* concurrent updates from the polling work
|
||||
@@ -2285,7 +2321,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
*/
|
||||
struct mxl862xx_port {
|
||||
struct mxl862xx_priv *priv;
|
||||
@@ -238,9 +242,13 @@ struct mxl862xx_port {
|
||||
@@ -244,9 +248,13 @@ struct mxl862xx_port {
|
||||
struct mxl862xx_vf_block vf;
|
||||
struct mxl862xx_evlan_block ingress_evlan;
|
||||
struct mxl862xx_evlan_block egress_evlan;
|
||||
@@ -2299,7 +2335,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
struct mxl862xx_port_stats stats;
|
||||
spinlock_t stats_lock; /* protects stats accumulators */
|
||||
};
|
||||
@@ -298,6 +306,7 @@ struct mxl862xx_fw_version {
|
||||
@@ -304,6 +312,7 @@ struct mxl862xx_fw_version {
|
||||
* before CRC-triggered shutdown and cleared after;
|
||||
* %MXL862XX_FLAG_WORK_STOPPED is set before cancelling
|
||||
* stats_work to prevent rescheduling during teardown
|
||||
@@ -2307,30 +2343,30 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @drop_meter: index of the single shared zero-rate firmware meter
|
||||
* used to unconditionally drop traffic (used to block
|
||||
* flooding)
|
||||
@@ -316,6 +325,7 @@ struct mxl862xx_fw_version {
|
||||
@@ -328,6 +337,7 @@ struct mxl862xx_fw_version {
|
||||
* (0 .. ds->max_num_bridges).
|
||||
* @evlan_ingress_size: per-port ingress Extended VLAN block size
|
||||
* @evlan_egress_size: per-port egress Extended VLAN block size
|
||||
+ * @cpu_evlan_ingress_size: CPU port ingress EVLAN block size (tag_8021q)
|
||||
* @vf_block_size: per-port VLAN Filter block size
|
||||
* @cpu_trap_fid: firmware bridge FID allocated for PCE-trapped frames;
|
||||
* configured with uc/mc/bc flood all enabled so that
|
||||
@@ -332,6 +342,7 @@ struct mxl862xx_priv {
|
||||
struct mdio_device *mdiodev;
|
||||
* @block_host: reject firmware API commands (except FW_UPDATE)
|
||||
* during a firmware flash
|
||||
@@ -359,6 +369,7 @@ struct mxl862xx_priv {
|
||||
struct work_struct crc_err_work;
|
||||
struct work_struct rescue_heal_work;
|
||||
unsigned long flags;
|
||||
+ enum dsa_tag_protocol tag_proto;
|
||||
u16 drop_meter;
|
||||
struct mxl862xx_fw_version fw_version;
|
||||
struct mxl862xx_pcs serdes_ports[8];
|
||||
@@ -340,6 +351,7 @@ struct mxl862xx_priv {
|
||||
u16 asic_id;
|
||||
@@ -370,6 +381,7 @@ struct mxl862xx_priv {
|
||||
u16 bridges[MXL862XX_MAX_BRIDGES + 1];
|
||||
u16 evlan_ingress_size;
|
||||
u16 evlan_egress_size;
|
||||
+ u16 cpu_evlan_ingress_size;
|
||||
u16 vf_block_size;
|
||||
u16 cpu_trap_fid;
|
||||
struct delayed_work stats_work;
|
||||
bool block_host;
|
||||
bool skip_teardown;
|
||||
--- a/include/net/dsa.h
|
||||
+++ b/include/net/dsa.h
|
||||
@@ -56,6 +56,7 @@ struct tc_action;
|
||||
@@ -2375,9 +2411,219 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
obj-$(CONFIG_NET_DSA_TAG_NONE) += tag_none.o
|
||||
obj-$(CONFIG_NET_DSA_TAG_OCELOT) += tag_ocelot.o
|
||||
obj-$(CONFIG_NET_DSA_TAG_OCELOT_8021Q) += tag_ocelot_8021q.o
|
||||
--- a/net/dsa/tag_mxl862xx.c
|
||||
+++ b/net/dsa/tag_mxl862xx.c
|
||||
@@ -8,16 +8,10 @@
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/etherdevice.h>
|
||||
-#include <linux/icmpv6.h>
|
||||
-#include <linux/if_pppox.h>
|
||||
-#include <linux/if_vlan.h>
|
||||
-#include <linux/ip.h>
|
||||
-#include <linux/ipv6.h>
|
||||
-#include <linux/ppp_defs.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <net/dsa.h>
|
||||
-#include <net/ipv6.h>
|
||||
#include "tag.h"
|
||||
+#include "tag_mxl862xx.h"
|
||||
|
||||
#define MXL862_NAME "mxl862xx"
|
||||
|
||||
@@ -63,84 +57,6 @@ static struct sk_buff *mxl862_tag_xmit(s
|
||||
return skb;
|
||||
}
|
||||
|
||||
-/* Must match the IGMP/MLD trap rules the mxl862xx driver installs on
|
||||
- * all user ports; frames matching them reach the CPU port without
|
||||
- * being forwarded in hardware.
|
||||
- */
|
||||
-static bool mxl862_rcv_is_snoop_trapped(struct sk_buff *skb)
|
||||
-{
|
||||
- unsigned int offset = MXL862_HEADER_LEN - 2;
|
||||
- const struct ipv6hdr *ip6h;
|
||||
- const struct iphdr *iph;
|
||||
- struct ipv6hdr _ip6h;
|
||||
- struct iphdr _iph;
|
||||
- const __be16 *p;
|
||||
- __be16 frag_off;
|
||||
- __be16 _proto;
|
||||
- __be16 proto;
|
||||
- const u8 *tp;
|
||||
- u8 nexthdr;
|
||||
- int start;
|
||||
- u8 _tp;
|
||||
- int i;
|
||||
-
|
||||
- p = skb_header_pointer(skb, offset, sizeof(_proto), &_proto);
|
||||
- if (!p)
|
||||
- return false;
|
||||
- proto = *p;
|
||||
-
|
||||
- for (i = 0; i < 2 && (proto == htons(ETH_P_8021Q) ||
|
||||
- proto == htons(ETH_P_8021AD)); i++) {
|
||||
- offset += VLAN_HLEN;
|
||||
- p = skb_header_pointer(skb, offset, sizeof(_proto), &_proto);
|
||||
- if (!p)
|
||||
- return false;
|
||||
- proto = *p;
|
||||
- }
|
||||
-
|
||||
- start = offset + 2;
|
||||
-
|
||||
- if (proto == htons(ETH_P_PPP_SES)) {
|
||||
- p = skb_header_pointer(skb, start + sizeof(struct pppoe_hdr),
|
||||
- sizeof(_proto), &_proto);
|
||||
- if (!p)
|
||||
- return false;
|
||||
- if (*p == htons(PPP_IP))
|
||||
- proto = htons(ETH_P_IP);
|
||||
- else if (*p == htons(PPP_IPV6))
|
||||
- proto = htons(ETH_P_IPV6);
|
||||
- else
|
||||
- return false;
|
||||
- start += PPPOE_SES_HLEN;
|
||||
- }
|
||||
-
|
||||
- if (proto == htons(ETH_P_IP)) {
|
||||
- iph = skb_header_pointer(skb, start, sizeof(_iph), &_iph);
|
||||
- return iph && iph->version == 4 &&
|
||||
- iph->protocol == IPPROTO_IGMP;
|
||||
- }
|
||||
-
|
||||
- if (proto != htons(ETH_P_IPV6))
|
||||
- return false;
|
||||
-
|
||||
- ip6h = skb_header_pointer(skb, start, sizeof(_ip6h), &_ip6h);
|
||||
- if (!ip6h || ip6h->version != 6)
|
||||
- return false;
|
||||
-
|
||||
- nexthdr = ip6h->nexthdr;
|
||||
- start = ipv6_skip_exthdr(skb, start + sizeof(*ip6h), &nexthdr,
|
||||
- &frag_off);
|
||||
- if (start < 0 || frag_off != 0 || nexthdr != IPPROTO_ICMPV6)
|
||||
- return false;
|
||||
-
|
||||
- tp = skb_header_pointer(skb, start, sizeof(_tp), &_tp);
|
||||
- if (!tp)
|
||||
- return false;
|
||||
-
|
||||
- return (*tp >= ICMPV6_MGM_QUERY && *tp <= ICMPV6_MGM_REDUCTION) ||
|
||||
- *tp == ICMPV6_MLD2_REPORT;
|
||||
-}
|
||||
-
|
||||
static struct sk_buff *mxl862_tag_rcv(struct sk_buff *skb,
|
||||
struct net_device *dev)
|
||||
{
|
||||
@@ -172,7 +88,8 @@ static struct sk_buff *mxl862_tag_rcv(st
|
||||
}
|
||||
|
||||
if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest) &&
|
||||
- !mxl862_rcv_is_snoop_trapped(skb)))
|
||||
+ !mxl862_rcv_is_snoop_trapped(skb, mxl862_tag[4],
|
||||
+ MXL862_HEADER_LEN)))
|
||||
dsa_default_offload_fwd_mark(skb);
|
||||
|
||||
/* remove the MxL862xx special tag between the MAC addresses and the
|
||||
--- /dev/null
|
||||
+++ b/net/dsa/tag_mxl862xx.h
|
||||
@@ -0,0 +1,92 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
+/*
|
||||
+ * Helpers shared by the MaxLinear MxL862xx DSA tag drivers
|
||||
+ *
|
||||
+ * Copyright (C) 2025 Daniel Golle <daniel@makrotopia.org>
|
||||
+ */
|
||||
+
|
||||
+#ifndef _NET_DSA_TAG_MXL862XX_H
|
||||
+#define _NET_DSA_TAG_MXL862XX_H
|
||||
+
|
||||
+#include <linux/icmpv6.h>
|
||||
+#include <linux/if_pppox.h>
|
||||
+#include <linux/if_vlan.h>
|
||||
+#include <linux/ip.h>
|
||||
+#include <linux/ipv6.h>
|
||||
+#include <linux/ppp_defs.h>
|
||||
+#include <linux/skbuff.h>
|
||||
+#include <net/ipv6.h>
|
||||
+
|
||||
+/* Must match the IGMP/MLD trap rules the mxl862xx driver installs on
|
||||
+ * all user ports; frames matching them reach the CPU port without
|
||||
+ * being forwarded in hardware. proto is the outermost EtherType of
|
||||
+ * the frame as seen by the hardware parser, start is the offset of
|
||||
+ * its payload relative to skb->data.
|
||||
+ */
|
||||
+static inline bool mxl862_rcv_is_snoop_trapped(struct sk_buff *skb,
|
||||
+ __be16 proto, int start)
|
||||
+{
|
||||
+ const struct ipv6hdr *ip6h;
|
||||
+ const struct iphdr *iph;
|
||||
+ struct ipv6hdr _ip6h;
|
||||
+ struct iphdr _iph;
|
||||
+ const __be16 *p;
|
||||
+ __be16 frag_off;
|
||||
+ __be16 _proto;
|
||||
+ const u8 *tp;
|
||||
+ u8 nexthdr;
|
||||
+ u8 _tp;
|
||||
+ int i;
|
||||
+
|
||||
+ for (i = 0; i < 2 && (proto == htons(ETH_P_8021Q) ||
|
||||
+ proto == htons(ETH_P_8021AD)); i++) {
|
||||
+ p = skb_header_pointer(skb, start + 2, sizeof(_proto),
|
||||
+ &_proto);
|
||||
+ if (!p)
|
||||
+ return false;
|
||||
+ proto = *p;
|
||||
+ start += VLAN_HLEN;
|
||||
+ }
|
||||
+
|
||||
+ if (proto == htons(ETH_P_PPP_SES)) {
|
||||
+ p = skb_header_pointer(skb, start + sizeof(struct pppoe_hdr),
|
||||
+ sizeof(_proto), &_proto);
|
||||
+ if (!p)
|
||||
+ return false;
|
||||
+ if (*p == htons(PPP_IP))
|
||||
+ proto = htons(ETH_P_IP);
|
||||
+ else if (*p == htons(PPP_IPV6))
|
||||
+ proto = htons(ETH_P_IPV6);
|
||||
+ else
|
||||
+ return false;
|
||||
+ start += PPPOE_SES_HLEN;
|
||||
+ }
|
||||
+
|
||||
+ if (proto == htons(ETH_P_IP)) {
|
||||
+ iph = skb_header_pointer(skb, start, sizeof(_iph), &_iph);
|
||||
+ return iph && iph->version == 4 &&
|
||||
+ iph->protocol == IPPROTO_IGMP;
|
||||
+ }
|
||||
+
|
||||
+ if (proto != htons(ETH_P_IPV6))
|
||||
+ return false;
|
||||
+
|
||||
+ ip6h = skb_header_pointer(skb, start, sizeof(_ip6h), &_ip6h);
|
||||
+ if (!ip6h || ip6h->version != 6)
|
||||
+ return false;
|
||||
+
|
||||
+ nexthdr = ip6h->nexthdr;
|
||||
+ start = ipv6_skip_exthdr(skb, start + sizeof(*ip6h), &nexthdr,
|
||||
+ &frag_off);
|
||||
+ if (start < 0 || frag_off != 0 || nexthdr != IPPROTO_ICMPV6)
|
||||
+ return false;
|
||||
+
|
||||
+ tp = skb_header_pointer(skb, start, sizeof(_tp), &_tp);
|
||||
+ if (!tp)
|
||||
+ return false;
|
||||
+
|
||||
+ return (*tp >= ICMPV6_MGM_QUERY && *tp <= ICMPV6_MGM_REDUCTION) ||
|
||||
+ *tp == ICMPV6_MLD2_REPORT;
|
||||
+}
|
||||
+
|
||||
+#endif /* _NET_DSA_TAG_MXL862XX_H */
|
||||
--- /dev/null
|
||||
+++ b/net/dsa/tag_mxl862xx_8021q.c
|
||||
@@ -0,0 +1,65 @@
|
||||
@@ -0,0 +1,70 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+/*
|
||||
+ * DSA 802.1Q-based tag driver for MaxLinear MxL862xx switches
|
||||
@@ -2389,9 +2635,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/dsa/8021q.h>
|
||||
+#include <linux/etherdevice.h>
|
||||
+
|
||||
+#include "tag.h"
|
||||
+#include "tag_8021q.h"
|
||||
+#include "tag_mxl862xx.h"
|
||||
+
|
||||
+#define MXL862_8021Q_NAME "mxl862xx-8021q"
|
||||
+
|
||||
@@ -2424,7 +2672,10 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ dsa_default_offload_fwd_mark(skb);
|
||||
+ if (likely(!is_link_local_ether_addr(eth_hdr(skb)->h_dest) &&
|
||||
+ !mxl862_rcv_is_snoop_trapped(skb, eth_hdr(skb)->h_proto,
|
||||
+ 0)))
|
||||
+ dsa_default_offload_fwd_mark(skb);
|
||||
+
|
||||
+ return skb;
|
||||
+}
|
||||
+26
-26
@@ -1,7 +1,7 @@
|
||||
From 4220567bd18b2174c74e90d22f3bf47422c1fdf6 Mon Sep 17 00:00:00 2001
|
||||
From 7f19a836cf7572b8f3e85bc2f78237d9eda23d7f Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 03:44:41 +0000
|
||||
Subject: [PATCH 09/19] net: dsa: mxl862xx: add link aggregation support
|
||||
Subject: [PATCH 05/12] net: dsa: mxl862xx: add link aggregation support
|
||||
|
||||
Implement LAG offloading via the firmware's trunking engine. A
|
||||
dedicated firmware bridge port is allocated per LAG and remains
|
||||
@@ -39,7 +39,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -564,6 +564,28 @@ struct mxl862xx_pmapper {
|
||||
@@ -577,6 +577,28 @@ struct mxl862xx_pmapper {
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
@@ -70,7 +70,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @mask: See &enum mxl862xx_bridge_port_config_mask
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -51,6 +51,7 @@
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
#define MXL862XX_QOS_METERCFGSET (MXL862XX_QOS_MAGIC + 0x2)
|
||||
#define MXL862XX_QOS_METERALLOC (MXL862XX_QOS_MAGIC + 0x2a)
|
||||
@@ -78,7 +78,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
#define MXL862XX_RMON_PORT_GET (MXL862XX_RMON_MAGIC + 0x1)
|
||||
|
||||
@@ -73,6 +74,9 @@
|
||||
@@ -74,6 +75,9 @@
|
||||
|
||||
#define MXL862XX_SS_SPTAG_SET (MXL862XX_SS_MAGIC + 0x2)
|
||||
|
||||
@@ -90,7 +90,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#define INT_GPHY_READ (GPY_GPY2XX_MAGIC + 0x1)
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -695,7 +695,42 @@ static int mxl862xx_setup_snooping_traps
|
||||
@@ -766,7 +766,42 @@ static int mxl862xx_setup_snooping_traps
|
||||
return mxl862xx_pce_rule_write(priv, &rule);
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
{
|
||||
struct mxl862xx_bridge_port_config br_port_cfg = {};
|
||||
struct dsa_port *dp = dsa_to_port(ds, port);
|
||||
@@ -728,8 +763,12 @@ static int mxl862xx_set_bridge_port(stru
|
||||
@@ -799,8 +834,12 @@ static int mxl862xx_set_bridge_port(stru
|
||||
dp->bridge->dev) {
|
||||
if (member_dp->index == port)
|
||||
continue;
|
||||
@@ -149,7 +149,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
mxl862xx_fw_portmap_set_bit(br_port_cfg.bridge_port_map,
|
||||
mxl862xx_cpu_bridge_port_id(ds, port));
|
||||
@@ -742,7 +781,7 @@ static int mxl862xx_set_bridge_port(stru
|
||||
@@ -813,7 +852,7 @@ static int mxl862xx_set_bridge_port(stru
|
||||
|
||||
bridge_id = dp->bridge ? priv->bridges[dp->bridge->num] : p->fid;
|
||||
|
||||
@@ -158,7 +158,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
br_port_cfg.bridge_id = cpu_to_le16(bridge_id);
|
||||
br_port_cfg.mask = cpu_to_le32(MXL862XX_BRIDGE_PORT_CONFIG_MASK_BRIDGE_ID |
|
||||
MXL862XX_BRIDGE_PORT_CONFIG_MASK_BRIDGE_PORT_MAP |
|
||||
@@ -823,11 +862,38 @@ static int mxl862xx_set_bridge_port(stru
|
||||
@@ -894,11 +933,38 @@ static int mxl862xx_set_bridge_port(stru
|
||||
br_port_cfg);
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
dsa_switch_for_each_bridge_member(dp, ds, bridge->dev) {
|
||||
err = mxl862xx_set_bridge_port(ds, dp->index);
|
||||
@@ -835,6 +901,25 @@ static int mxl862xx_sync_bridge_members(
|
||||
@@ -906,6 +972,25 @@ static int mxl862xx_sync_bridge_members(
|
||||
ret = err;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1875,6 +1960,408 @@ static int mxl862xx_setup_cpu_bridge(str
|
||||
@@ -2018,6 +2103,408 @@ static int mxl862xx_setup_cpu_bridge(str
|
||||
return mxl862xx_set_bridge_port(ds, port);
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
static int mxl862xx_port_bridge_join(struct dsa_switch *ds, int port,
|
||||
const struct dsa_bridge bridge,
|
||||
bool *tx_fwd_offload,
|
||||
@@ -1900,7 +2387,18 @@ static int mxl862xx_port_bridge_join(str
|
||||
@@ -2043,7 +2530,18 @@ static int mxl862xx_port_bridge_join(str
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -653,7 +653,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
static void mxl862xx_port_bridge_leave(struct dsa_switch *ds, int port,
|
||||
@@ -1951,6 +2449,17 @@ static void mxl862xx_port_bridge_leave(s
|
||||
@@ -2094,6 +2592,17 @@ static void mxl862xx_port_bridge_leave(s
|
||||
"failed to update CPU VBP for port %d: %pe\n", port,
|
||||
ERR_PTR(err));
|
||||
|
||||
@@ -671,7 +671,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (!dsa_bridge_ports(ds, bridge.dev))
|
||||
mxl862xx_free_bridge(ds, &bridge);
|
||||
}
|
||||
@@ -2609,18 +3118,17 @@ static int mxl862xx_get_fid(struct dsa_s
|
||||
@@ -2764,18 +3273,17 @@ static int mxl862xx_get_fid(struct dsa_s
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -697,7 +697,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
*/
|
||||
static int mxl862xx_fdb_bridge_port(struct dsa_switch *ds, int port,
|
||||
const struct dsa_db db)
|
||||
@@ -2636,7 +3144,7 @@ static int mxl862xx_fdb_bridge_port(stru
|
||||
@@ -2791,7 +3299,7 @@ static int mxl862xx_fdb_bridge_port(stru
|
||||
return bp_cpu;
|
||||
}
|
||||
|
||||
@@ -706,7 +706,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2883,11 +3391,43 @@ static int mxl862xx_port_fdb_del(struct
|
||||
@@ -3044,11 +3552,43 @@ static int mxl862xx_port_fdb_del(struct
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
u32 entry_port_id;
|
||||
int ret;
|
||||
|
||||
@@ -2901,7 +3441,7 @@ static int mxl862xx_port_fdb_dump(struct
|
||||
@@ -3062,7 +3602,7 @@ static int mxl862xx_port_fdb_dump(struct
|
||||
|
||||
entry_port_id = le32_to_cpu(param.port_id);
|
||||
|
||||
@@ -759,7 +759,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
ret = cb(param.mac, FIELD_GET(MXL862XX_TCI_VLAN_ID,
|
||||
le16_to_cpu(param.tci)),
|
||||
param.static_entry, data);
|
||||
@@ -3572,6 +4112,11 @@ static const struct dsa_switch_ops mxl86
|
||||
@@ -3742,6 +4282,11 @@ static const struct dsa_switch_ops mxl86
|
||||
.port_fdb_dump = mxl862xx_port_fdb_dump,
|
||||
.port_mdb_add = mxl862xx_port_mdb_add,
|
||||
.port_mdb_del = mxl862xx_port_mdb_del,
|
||||
@@ -771,7 +771,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
.port_vlan_filtering = mxl862xx_port_vlan_filtering,
|
||||
.port_vlan_add = mxl862xx_port_vlan_add,
|
||||
.port_vlan_del = mxl862xx_port_vlan_del,
|
||||
@@ -3612,6 +4157,7 @@ static int mxl862xx_probe(struct mdio_de
|
||||
@@ -3790,6 +4335,7 @@ static int mxl862xx_probe(struct mdio_de
|
||||
ds->num_ports = MXL862XX_MAX_PORTS;
|
||||
ds->fdb_isolation = true;
|
||||
ds->max_num_bridges = MXL862XX_MAX_BRIDGES;
|
||||
@@ -781,7 +781,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -19,6 +19,19 @@ struct mxl862xx_priv;
|
||||
@@ -25,6 +25,19 @@ struct mxl862xx_priv;
|
||||
#define MXL862XX_MAX_BRIDGE_PORTS 128
|
||||
#define MXL862XX_TOTAL_EVLAN_ENTRIES 1024
|
||||
#define MXL862XX_TOTAL_VF_ENTRIES 1024
|
||||
@@ -801,7 +801,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
/* Number of __le16 words in a firmware portmap (128-bit bitmap). */
|
||||
#define MXL862XX_FW_PORTMAP_WORDS (MXL862XX_MAX_BRIDGE_PORTS / 16)
|
||||
@@ -230,6 +243,12 @@ struct mxl862xx_port_stats {
|
||||
@@ -236,6 +249,12 @@ struct mxl862xx_port_stats {
|
||||
* @stats_lock: protects accumulator reads in .get_stats64 against
|
||||
* concurrent updates from the polling work
|
||||
* @tag_8021q_vid: currently assigned tag_8021q management VID
|
||||
@@ -814,7 +814,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
*/
|
||||
struct mxl862xx_port {
|
||||
struct mxl862xx_priv *priv;
|
||||
@@ -249,6 +268,9 @@ struct mxl862xx_port {
|
||||
@@ -255,6 +274,9 @@ struct mxl862xx_port {
|
||||
struct work_struct host_flood_work;
|
||||
u16 tag_8021q_vid;
|
||||
struct mxl862xx_evlan_block cpu_egress_evlan;
|
||||
@@ -824,7 +824,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
struct mxl862xx_port_stats stats;
|
||||
spinlock_t stats_lock; /* protects stats accumulators */
|
||||
};
|
||||
@@ -334,6 +356,15 @@ struct mxl862xx_fw_version {
|
||||
@@ -360,6 +382,15 @@ struct mxl862xx_fw_version {
|
||||
* policy. Set once in setup() and referenced by
|
||||
* fill_cpu_trap_action() via bFidEnable. The PCE FID
|
||||
* action field is 6 bits, so this value must be <= 63.
|
||||
@@ -840,9 +840,9 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @stats_work: periodic work item that polls RMON hardware counters
|
||||
* and accumulates them into 64-bit per-port stats
|
||||
*/
|
||||
@@ -354,6 +385,8 @@ struct mxl862xx_priv {
|
||||
u16 cpu_evlan_ingress_size;
|
||||
u16 vf_block_size;
|
||||
@@ -389,6 +420,8 @@ struct mxl862xx_priv {
|
||||
bool rescue_ready;
|
||||
bool rescue_failed;
|
||||
u16 cpu_trap_fid;
|
||||
+ u16 lag_bridge_ports[MXL862XX_MAX_LAG_IDS + 1];
|
||||
+ u8 trunk_hash;
|
||||
+12
-12
@@ -1,7 +1,7 @@
|
||||
From 8f7296099da5eaedfe5108a6fe93296bcc0c4b45 Mon Sep 17 00:00:00 2001
|
||||
From a82d75f1132dd577a8e2be1226b808e43f67ebaa Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 12:05:29 +0000
|
||||
Subject: [PATCH 10/19] net: dsa: mxl862xx: add support for mirror port
|
||||
Subject: [PATCH 06/12] net: dsa: mxl862xx: add support for mirror port
|
||||
|
||||
The MxL862xx hardware supports a single monitor port which can be
|
||||
configured to mirror any other port's ingress and/or egress traffic.
|
||||
@@ -19,7 +19,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -729,6 +729,18 @@ struct mxl862xx_bridge_port_config {
|
||||
@@ -742,6 +742,18 @@ struct mxl862xx_bridge_port_config {
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
@@ -40,8 +40,8 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @age_timer: Custom MAC table aging timer in seconds
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#define MXL862XX_COMMON_REGISTERGET (MXL862XX_COMMON_MAGIC + 0x1)
|
||||
#define MXL862XX_COMMON_CFGGET (MXL862XX_COMMON_MAGIC + 0x9)
|
||||
#define MXL862XX_COMMON_CFGSET (MXL862XX_COMMON_MAGIC + 0xa)
|
||||
+#define MXL862XX_COMMON_MONITORPORTCFGSET (MXL862XX_COMMON_MAGIC + 0xe)
|
||||
@@ -50,7 +50,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#define MXL862XX_TFLOW_PCERULEALLOC (MXL862XX_TFLOW_MAGIC + 0x4)
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -1116,6 +1116,8 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
@@ -1239,6 +1239,8 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
(n_user_ports + n_cpu_ports);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
ret = mxl862xx_setup_drop_meter(ds);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -1960,6 +1962,120 @@ static int mxl862xx_setup_cpu_bridge(str
|
||||
@@ -2103,6 +2105,120 @@ static int mxl862xx_setup_cpu_bridge(str
|
||||
return mxl862xx_set_bridge_port(ds, port);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
/**
|
||||
* mxl862xx_lag_master_port - Find the LAG master (lowest-numbered member)
|
||||
* @ds: DSA switch
|
||||
@@ -4112,6 +4228,8 @@ static const struct dsa_switch_ops mxl86
|
||||
@@ -4282,6 +4398,8 @@ static const struct dsa_switch_ops mxl86
|
||||
.port_fdb_dump = mxl862xx_port_fdb_dump,
|
||||
.port_mdb_add = mxl862xx_port_mdb_add,
|
||||
.port_mdb_del = mxl862xx_port_mdb_del,
|
||||
@@ -191,7 +191,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
.port_lag_change = mxl862xx_port_lag_change,
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -243,6 +243,8 @@ struct mxl862xx_port_stats {
|
||||
@@ -249,6 +249,8 @@ struct mxl862xx_port_stats {
|
||||
* @stats_lock: protects accumulator reads in .get_stats64 against
|
||||
* concurrent updates from the polling work
|
||||
* @tag_8021q_vid: currently assigned tag_8021q management VID
|
||||
@@ -200,7 +200,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @lag: non-NULL when port is member of a LAG group;
|
||||
* points to the DSA LAG structure
|
||||
* @lag_tx_enabled: true when this port is active for TX in its LAG
|
||||
@@ -268,6 +270,8 @@ struct mxl862xx_port {
|
||||
@@ -274,6 +276,8 @@ struct mxl862xx_port {
|
||||
struct work_struct host_flood_work;
|
||||
u16 tag_8021q_vid;
|
||||
struct mxl862xx_evlan_block cpu_egress_evlan;
|
||||
@@ -209,7 +209,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
struct dsa_lag *lag;
|
||||
bool lag_tx_enabled;
|
||||
u8 lag_hash_bits;
|
||||
@@ -365,6 +369,8 @@ struct mxl862xx_fw_version {
|
||||
@@ -391,6 +395,8 @@ struct mxl862xx_fw_version {
|
||||
* @trunk_hash: current global hash field bitmask (6 bits,
|
||||
* MXL862XX_TRUNK_HASH_*); union of all active LAGs'
|
||||
* hash requirements
|
||||
@@ -218,7 +218,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @stats_work: periodic work item that polls RMON hardware counters
|
||||
* and accumulates them into 64-bit per-port stats
|
||||
*/
|
||||
@@ -387,6 +393,7 @@ struct mxl862xx_priv {
|
||||
@@ -422,6 +428,7 @@ struct mxl862xx_priv {
|
||||
u16 cpu_trap_fid;
|
||||
u16 lag_bridge_ports[MXL862XX_MAX_LAG_IDS + 1];
|
||||
u8 trunk_hash;
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
From d27d60f42f5188d6cfcb771d2188633f1031646f Mon Sep 17 00:00:00 2001
|
||||
From f1916daad4ef5f366bad4a29305299858c88811e Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 1 Apr 2026 13:43:08 +0100
|
||||
Subject: [PATCH 14/19] net: dsa: mxl862xx: implement port MTU configuration
|
||||
Subject: [PATCH 07/12] net: dsa: mxl862xx: implement port MTU configuration
|
||||
|
||||
The firmware exposes a global max_packet_len register via
|
||||
MXL862XX_COMMON_CFGSET. Since this is switch-wide rather than
|
||||
@@ -25,7 +25,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#include <linux/module.h>
|
||||
#include <linux/of_device.h>
|
||||
#include <linux/of_mdio.h>
|
||||
@@ -3743,6 +3744,53 @@ static int mxl862xx_set_ageing_time(stru
|
||||
@@ -3903,6 +3904,53 @@ static int mxl862xx_set_ageing_time(stru
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
static void mxl862xx_port_stp_state_set(struct dsa_switch *ds, int port,
|
||||
u8 state)
|
||||
{
|
||||
@@ -4218,6 +4266,8 @@ static const struct dsa_switch_ops mxl86
|
||||
@@ -4387,6 +4435,8 @@ static const struct dsa_switch_ops mxl86
|
||||
.port_disable = mxl862xx_port_disable,
|
||||
.port_fast_age = mxl862xx_port_fast_age,
|
||||
.set_ageing_time = mxl862xx_set_ageing_time,
|
||||
@@ -90,7 +90,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
.port_pre_bridge_flags = mxl862xx_port_pre_bridge_flags,
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -251,6 +251,8 @@ struct mxl862xx_port_stats {
|
||||
@@ -257,6 +257,8 @@ struct mxl862xx_port_stats {
|
||||
* @lag_hash_bits: hash field bitmask (MXL862XX_TRUNK_HASH_*) requested
|
||||
* when this port joined its LAG; used to recompute the
|
||||
* global trunk_hash when a LAG is destroyed
|
||||
@@ -99,7 +99,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
*/
|
||||
struct mxl862xx_port {
|
||||
struct mxl862xx_priv *priv;
|
||||
@@ -275,6 +277,7 @@ struct mxl862xx_port {
|
||||
@@ -281,6 +283,7 @@ struct mxl862xx_port {
|
||||
struct dsa_lag *lag;
|
||||
bool lag_tx_enabled;
|
||||
u8 lag_hash_bits;
|
||||
-568
@@ -1,568 +0,0 @@
|
||||
From 099e70920b16f5da14d34bc00ac58a5ca95c1e33 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 16:30:31 +0000
|
||||
Subject: [PATCH 13/19] net: dsa: mxl862xx: add devlink flash_update and
|
||||
info_get
|
||||
|
||||
Implement runtime firmware upgrade via "devlink dev flash" and version
|
||||
reporting via "devlink dev info":
|
||||
|
||||
devlink dev info mdio_bus/<bus>/<addr>
|
||||
devlink dev flash mdio_bus/<bus>/<addr> file <firmware.bin>
|
||||
|
||||
The driver sends SYS_MISC_FW_UPDATE to enter MCUboot rescue mode,
|
||||
transfers the signed image over the SB PDI bulk-transfer protocol
|
||||
(clause-22 SMDIO), waits for the switch to reboot, then schedules
|
||||
device_reprobe() for a clean remove()+probe() cycle.
|
||||
|
||||
Before the transfer begins the driver closes all conduit interfaces
|
||||
and marks every netdev (user and conduit) not-present via
|
||||
netif_device_detach() so that userspace cannot bring ports back up
|
||||
during the ~15 minute flash process. Progress is reported through
|
||||
devlink status notifications. Once the FW_UPDATE command has been
|
||||
sent the switch is in MCUboot mode and normal operation can only be
|
||||
restored by a reprobe, so the driver always schedules one regardless
|
||||
of transfer outcome.
|
||||
|
||||
The reprobe work item is dynamically allocated (following the iwlwifi
|
||||
pattern) because device_reprobe() triggers remove() which frees the
|
||||
devm-managed priv while the work is still executing.
|
||||
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/Makefile | 2 +-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-cmd.h | 1 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-fw.c | 434 +++++++++++++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-fw.h | 15 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-host.c | 7 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 3 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.h | 2 +
|
||||
7 files changed, 463 insertions(+), 1 deletion(-)
|
||||
create mode 100644 drivers/net/dsa/mxl862xx/mxl862xx-fw.c
|
||||
create mode 100644 drivers/net/dsa/mxl862xx/mxl862xx-fw.h
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/Makefile
|
||||
+++ b/drivers/net/dsa/mxl862xx/Makefile
|
||||
@@ -1,3 +1,3 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
obj-$(CONFIG_NET_DSA_MXL862) += mxl862xx_dsa.o
|
||||
-mxl862xx_dsa-y := mxl862xx.o mxl862xx-host.o mxl862xx-phylink.o
|
||||
+mxl862xx_dsa-y := mxl862xx.o mxl862xx-host.o mxl862xx-phylink.o mxl862xx-fw.o
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -83,6 +83,7 @@
|
||||
#define INT_GPHY_READ (GPY_GPY2XX_MAGIC + 0x1)
|
||||
#define INT_GPHY_WRITE (GPY_GPY2XX_MAGIC + 0x2)
|
||||
|
||||
+#define SYS_MISC_FW_UPDATE (SYS_MISC_MAGIC + 0x1)
|
||||
#define SYS_MISC_FW_VERSION (SYS_MISC_MAGIC + 0x2)
|
||||
|
||||
#define MXL862XX_XPCS_PCS_CONFIG (MXL862XX_XPCS_MAGIC + 0x1)
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-fw.c
|
||||
@@ -0,0 +1,434 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+/*
|
||||
+ * Firmware flash and devlink support for MaxLinear MxL862xx
|
||||
+ *
|
||||
+ * Copyright (C) 2025 Daniel Golle <daniel@makrotopia.org>
|
||||
+ *
|
||||
+ * Usage:
|
||||
+ * # Query running firmware version:
|
||||
+ * devlink dev info mdio_bus/<bus>/<addr>
|
||||
+ *
|
||||
+ * # Flash new firmware (all ports are taken down automatically):
|
||||
+ * devlink dev flash mdio_bus/<bus>/<addr> file <firmware.bin>
|
||||
+ *
|
||||
+ * The flash process takes approximately 15 minutes. Progress is
|
||||
+ * reported via devlink status notifications. After a successful (or
|
||||
+ * failed) flash the driver reprobes the device automatically.
|
||||
+ */
|
||||
+
|
||||
+#include <linux/crc32.h>
|
||||
+#include <linux/delay.h>
|
||||
+#include <linux/device.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/netdevice.h>
|
||||
+#include <linux/rtnetlink.h>
|
||||
+#include <net/dsa.h>
|
||||
+
|
||||
+#include "mxl862xx.h"
|
||||
+#include "mxl862xx-api.h"
|
||||
+#include "mxl862xx-cmd.h"
|
||||
+#include "mxl862xx-fw.h"
|
||||
+#include "mxl862xx-host.h"
|
||||
+
|
||||
+/* SB PDI registers (clause-22 SMDIO address space) */
|
||||
+#define MXL862XX_SB_PDI_CTRL 0xe100
|
||||
+#define MXL862XX_SB_PDI_ADDR 0xe101
|
||||
+#define MXL862XX_SB_PDI_DATA 0xe102
|
||||
+#define MXL862XX_SB_PDI_STAT 0xe103
|
||||
+
|
||||
+/* SB PDI CTRL modes */
|
||||
+#define MXL862XX_SB_PDI_CTRL_RST 0x00
|
||||
+#define MXL862XX_SB_PDI_CTRL_WR 0x02
|
||||
+
|
||||
+/* SB PDI handshake magic */
|
||||
+#define MXL862XX_SB_PDI_READY 0xc55c
|
||||
+#define MXL862XX_SB_PDI_START 0xf48f
|
||||
+#define MXL862XX_SB_PDI_END 0x3cc3
|
||||
+
|
||||
+/* Firmware transfer geometry */
|
||||
+#define MXL862XX_FW_HDR_SIZE 20
|
||||
+#define MXL862XX_FW_BANK_HALF 16384 /* words per half-bank */
|
||||
+#define MXL862XX_FW_BANK_SLICE 32760 /* words per full slice */
|
||||
+#define MXL862XX_FW_SB1_ADDR 0x7800 /* SB1 word address */
|
||||
+
|
||||
+/* Timeouts */
|
||||
+#define MXL862XX_FW_READY_TIMEOUT_MS 30000
|
||||
+#define MXL862XX_FW_ACK_TIMEOUT_MS 5000
|
||||
+#define MXL862XX_FW_ERASE_TIMEOUT_MS 300000 /* flash erase is very slow */
|
||||
+#define MXL862XX_FW_WRITE_TIMEOUT_MS 120000 /* per-slice program timeout */
|
||||
+#define MXL862XX_FW_REBOOT_DELAY_MS 5000
|
||||
+
|
||||
+static void mxl862xx_sb_pdi_reset(struct mxl862xx_priv *priv)
|
||||
+{
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_RST);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_ADDR,
|
||||
+ MXL862XX_SB_PDI_CTRL_RST);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_DATA,
|
||||
+ MXL862XX_SB_PDI_CTRL_RST);
|
||||
+}
|
||||
+
|
||||
+static int mxl862xx_sb_pdi_poll_stat(struct mxl862xx_priv *priv, u16 expected,
|
||||
+ unsigned long timeout_ms)
|
||||
+{
|
||||
+ unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
|
||||
+ int ret;
|
||||
+
|
||||
+ do {
|
||||
+ ret = mxl862xx_smdio_read(priv, MXL862XX_SB_PDI_STAT);
|
||||
+ if (ret < 0)
|
||||
+ return ret;
|
||||
+ if ((u16)ret == expected)
|
||||
+ return 0;
|
||||
+ usleep_range(10000, 11000);
|
||||
+ } while (time_before(jiffies, timeout));
|
||||
+
|
||||
+ return -ETIMEDOUT;
|
||||
+}
|
||||
+
|
||||
+/* Reprobe work -- dynamically allocated so it survives remove().
|
||||
+ * device_reprobe() -> remove() frees priv (devm) while work is executing,
|
||||
+ * so the work struct must not live in mxl862xx_priv.
|
||||
+ */
|
||||
+struct mxl862xx_reprobe {
|
||||
+ struct device *dev;
|
||||
+ struct delayed_work dwork;
|
||||
+};
|
||||
+
|
||||
+static void mxl862xx_reprobe_work_fn(struct work_struct *work)
|
||||
+{
|
||||
+ struct mxl862xx_reprobe *reprobe =
|
||||
+ container_of(work, struct mxl862xx_reprobe, dwork.work);
|
||||
+
|
||||
+ if (device_reprobe(reprobe->dev))
|
||||
+ dev_err(reprobe->dev, "reprobe failed\n");
|
||||
+ put_device(reprobe->dev);
|
||||
+ kfree(reprobe);
|
||||
+ module_put(THIS_MODULE);
|
||||
+}
|
||||
+
|
||||
+/* MCUboot firmware image header (20 bytes) */
|
||||
+struct mxl862xx_fw_hdr {
|
||||
+ __le32 image_type;
|
||||
+ __le32 image_size_1;
|
||||
+ __le32 image_checksum_1;
|
||||
+ __le32 image_size_2;
|
||||
+ __le32 image_checksum_2;
|
||||
+} __packed;
|
||||
+
|
||||
+static int mxl862xx_flash_firmware(struct mxl862xx_priv *priv,
|
||||
+ const struct firmware *fw,
|
||||
+ struct devlink *dl)
|
||||
+{
|
||||
+ const struct mxl862xx_fw_hdr *hdr;
|
||||
+ u32 word_idx = 0, data_written = 0, idx = 0;
|
||||
+ unsigned long next_notify = 0;
|
||||
+ const u8 *payload;
|
||||
+ u32 payload_size;
|
||||
+ u16 word, fdata;
|
||||
+ int ret, i;
|
||||
+ u32 crc;
|
||||
+
|
||||
+ if (fw->size < MXL862XX_FW_HDR_SIZE)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ hdr = (const struct mxl862xx_fw_hdr *)fw->data;
|
||||
+ payload = fw->data + MXL862XX_FW_HDR_SIZE;
|
||||
+ payload_size = le32_to_cpu(hdr->image_size_1) +
|
||||
+ le32_to_cpu(hdr->image_size_2);
|
||||
+
|
||||
+ if (payload_size > fw->size - MXL862XX_FW_HDR_SIZE) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: firmware file too small for declared size\n");
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+
|
||||
+ /* Validate CRC-32 of both image slots before touching hardware */
|
||||
+ if (le32_to_cpu(hdr->image_size_1)) {
|
||||
+ crc = ~crc32_le(~0U, payload,
|
||||
+ le32_to_cpu(hdr->image_size_1));
|
||||
+ if (crc != le32_to_cpu(hdr->image_checksum_1)) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: image 1 CRC mismatch (got %08x, expected %08x)\n",
|
||||
+ crc, le32_to_cpu(hdr->image_checksum_1));
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (le32_to_cpu(hdr->image_size_2)) {
|
||||
+ crc = ~crc32_le(~0U,
|
||||
+ payload + le32_to_cpu(hdr->image_size_1),
|
||||
+ le32_to_cpu(hdr->image_size_2));
|
||||
+ if (crc != le32_to_cpu(hdr->image_checksum_2)) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: image 2 CRC mismatch (got %08x, expected %08x)\n",
|
||||
+ crc, le32_to_cpu(hdr->image_checksum_2));
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Step 1: Tell firmware to enter MCUboot rescue mode.
|
||||
+ * The FW_UPDATE command takes no payload (size 0).
|
||||
+ */
|
||||
+ ret = mxl862xx_api_wrap(priv, SYS_MISC_FW_UPDATE, NULL, 0,
|
||||
+ false, false);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: FW_UPDATE command failed: %pe\n",
|
||||
+ ERR_PTR(ret));
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* From this point on, the switch is in MCUboot rescue mode.
|
||||
+ * Any failure must go through the end_magic label to tell
|
||||
+ * MCUboot to reboot rather than leaving it stuck waiting.
|
||||
+ */
|
||||
+
|
||||
+ /* Step 2: Reset PDI and wait for bootloader ready */
|
||||
+ devlink_flash_update_status_notify(dl, "Waiting for bootloader",
|
||||
+ NULL, 0, 0);
|
||||
+ mxl862xx_sb_pdi_reset(priv);
|
||||
+ ret = mxl862xx_sb_pdi_poll_stat(priv, MXL862XX_SB_PDI_READY,
|
||||
+ MXL862XX_FW_READY_TIMEOUT_MS);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: bootloader not ready: %pe\n", ERR_PTR(ret));
|
||||
+ goto end_magic;
|
||||
+ }
|
||||
+
|
||||
+ /* Step 3: Start handshake */
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ MXL862XX_SB_PDI_START);
|
||||
+ ret = mxl862xx_sb_pdi_poll_stat(priv, MXL862XX_SB_PDI_START + 1,
|
||||
+ MXL862XX_FW_ACK_TIMEOUT_MS);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: start handshake failed: %pe\n", ERR_PTR(ret));
|
||||
+ goto end_magic;
|
||||
+ }
|
||||
+
|
||||
+ /* Step 4: Transfer 20-byte header using auto-increment write mode */
|
||||
+ devlink_flash_update_status_notify(dl, "Erasing flash", NULL, 0, 0);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_WR);
|
||||
+ for (i = 0; i < MXL862XX_FW_HDR_SIZE / 2; i++) {
|
||||
+ word = fw->data[i * 2] |
|
||||
+ ((u16)fw->data[i * 2 + 1] << 8);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_DATA, word);
|
||||
+ }
|
||||
+ mxl862xx_sb_pdi_reset(priv);
|
||||
+
|
||||
+ /* Write header byte count to STAT to trigger erase */
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ MXL862XX_FW_HDR_SIZE);
|
||||
+
|
||||
+ /* Wait for header ACK (header_size + 1) */
|
||||
+ ret = mxl862xx_sb_pdi_poll_stat(priv, MXL862XX_FW_HDR_SIZE + 1,
|
||||
+ MXL862XX_FW_ACK_TIMEOUT_MS);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: header ACK failed: %pe\n", ERR_PTR(ret));
|
||||
+ goto end_magic;
|
||||
+ }
|
||||
+
|
||||
+ /* Step 5: Wait for erase to complete (STAT goes to 0) */
|
||||
+ ret = mxl862xx_sb_pdi_poll_stat(priv, 0,
|
||||
+ MXL862XX_FW_ERASE_TIMEOUT_MS);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: erase timeout: %pe\n", ERR_PTR(ret));
|
||||
+ goto end_magic;
|
||||
+ }
|
||||
+
|
||||
+ /* Step 6: Transfer payload using dual-bank auto-increment writes */
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_WR);
|
||||
+
|
||||
+ while (idx < payload_size) {
|
||||
+ if (idx + 1 < payload_size) {
|
||||
+ fdata = payload[idx] |
|
||||
+ ((u16)payload[idx + 1] << 8);
|
||||
+ idx += 2;
|
||||
+ data_written += 2;
|
||||
+ } else {
|
||||
+ fdata = payload[idx];
|
||||
+ idx++;
|
||||
+ data_written++;
|
||||
+ }
|
||||
+
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_DATA, fdata);
|
||||
+ word_idx++;
|
||||
+
|
||||
+ /* Last byte(s): flush final partial slice */
|
||||
+ if (idx >= payload_size) {
|
||||
+ mxl862xx_sb_pdi_reset(priv);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ data_written);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ /* Half-bank boundary: switch to SB1 address */
|
||||
+ if (word_idx == MXL862XX_FW_BANK_HALF) {
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_RST);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_ADDR,
|
||||
+ MXL862XX_FW_SB1_ADDR);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_WR);
|
||||
+ } else if (word_idx >= MXL862XX_FW_BANK_SLICE) {
|
||||
+ /* Full slice: flush and wait for program */
|
||||
+ mxl862xx_sb_pdi_reset(priv);
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ data_written);
|
||||
+ word_idx = 0;
|
||||
+ data_written = 0;
|
||||
+
|
||||
+ ret = mxl862xx_sb_pdi_poll_stat(
|
||||
+ priv, 0, MXL862XX_FW_WRITE_TIMEOUT_MS);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: write timeout at %u/%u: %pe\n",
|
||||
+ idx, payload_size, ERR_PTR(ret));
|
||||
+ goto end_magic;
|
||||
+ }
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_CTRL,
|
||||
+ MXL862XX_SB_PDI_CTRL_WR);
|
||||
+
|
||||
+ if (time_after(jiffies, next_notify)) {
|
||||
+ devlink_flash_update_status_notify(
|
||||
+ dl, "Flashing", NULL,
|
||||
+ idx, payload_size);
|
||||
+ next_notify = jiffies +
|
||||
+ msecs_to_jiffies(500);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Wait for final slice to be programmed */
|
||||
+ ret = mxl862xx_sb_pdi_poll_stat(priv, 0,
|
||||
+ MXL862XX_FW_WRITE_TIMEOUT_MS);
|
||||
+ if (ret) {
|
||||
+ dev_err(&priv->mdiodev->dev,
|
||||
+ "flash: final write timeout: %pe\n", ERR_PTR(ret));
|
||||
+ goto end_magic;
|
||||
+ }
|
||||
+
|
||||
+ devlink_flash_update_status_notify(dl, "Flashing", NULL,
|
||||
+ payload_size, payload_size);
|
||||
+
|
||||
+end_magic:
|
||||
+ /* Always send end magic so MCUboot reboots instead of sitting
|
||||
+ * idle. The hardware reset during reprobe recovers the switch
|
||||
+ * regardless of whether the transfer succeeded or failed.
|
||||
+ */
|
||||
+ mxl862xx_smdio_write(priv, MXL862XX_SB_PDI_STAT,
|
||||
+ MXL862XX_SB_PDI_END);
|
||||
+ msleep(MXL862XX_FW_REBOOT_DELAY_MS);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+int mxl862xx_devlink_info_get(struct dsa_switch *ds,
|
||||
+ struct devlink_info_req *req,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct mxl862xx_priv *priv = ds->priv;
|
||||
+ char ver_str[32];
|
||||
+
|
||||
+ snprintf(ver_str, sizeof(ver_str), "%u.%u.%u",
|
||||
+ priv->fw_version.major, priv->fw_version.minor,
|
||||
+ priv->fw_version.revision);
|
||||
+
|
||||
+ return devlink_info_version_running_put(req, "fw", ver_str);
|
||||
+}
|
||||
+
|
||||
+int mxl862xx_devlink_flash_update(struct dsa_switch *ds,
|
||||
+ struct devlink_flash_update_params *params,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct mxl862xx_priv *priv = ds->priv;
|
||||
+ struct mxl862xx_sys_fw_image_version ver = {};
|
||||
+ struct mxl862xx_reprobe *reprobe;
|
||||
+ struct dsa_port *dp;
|
||||
+ int ret, i;
|
||||
+
|
||||
+ if (params->component) {
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "component is not supported");
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ dev_info(ds->dev, "flash: running firmware %u.%u.%u\n",
|
||||
+ priv->fw_version.major, priv->fw_version.minor,
|
||||
+ priv->fw_version.revision);
|
||||
+
|
||||
+ /* Close all user and CPU ports while the firmware is still
|
||||
+ * alive. dev_close() on user ports triggers multicast group
|
||||
+ * leave and host MDB/FDB removal on the CPU port through the
|
||||
+ * normal DSA callbacks so the core's tracking lists are
|
||||
+ * drained before we enter MCUboot. Then mark user ports
|
||||
+ * not-present so userspace cannot bring them back up during
|
||||
+ * the (slow) flash process. The conduit is only closed, not
|
||||
+ * detached -- it is owned by the Ethernet MAC driver and
|
||||
+ * dev_open() during reprobe must be able to bring it back.
|
||||
+ */
|
||||
+ rtnl_lock();
|
||||
+ dsa_switch_for_each_user_port(dp, ds) {
|
||||
+ if (dp->user) {
|
||||
+ dev_close(dp->user);
|
||||
+ netif_device_detach(dp->user);
|
||||
+ }
|
||||
+ }
|
||||
+ dsa_switch_for_each_cpu_port(dp, ds)
|
||||
+ dev_close(dp->conduit);
|
||||
+ rtnl_unlock();
|
||||
+
|
||||
+ /* Block all firmware API commands while the switch is being
|
||||
+ * reflashed. The conduit is intentionally kept open -- it is
|
||||
+ * owned by the Ethernet MAC driver and would not recover on
|
||||
+ * reprobe if we closed it here.
|
||||
+ */
|
||||
+ priv->block_host = true;
|
||||
+
|
||||
+ /* Stop stats polling and pending host-flood work */
|
||||
+ cancel_delayed_work_sync(&priv->stats_work);
|
||||
+ for (i = 0; i < ds->num_ports; i++)
|
||||
+ cancel_work_sync(&priv->ports[i].host_flood_work);
|
||||
+
|
||||
+ ret = mxl862xx_flash_firmware(priv, params->fw, ds->devlink);
|
||||
+ if (ret)
|
||||
+ NL_SET_ERR_MSG_MOD(extack, "firmware transfer failed");
|
||||
+
|
||||
+ if (!ret) {
|
||||
+ /* Read new firmware version (switch just rebooted).
|
||||
+ * Temporarily lift the block for this single query.
|
||||
+ */
|
||||
+ priv->block_host = false;
|
||||
+ memset(&ver, 0, sizeof(ver));
|
||||
+ if (!MXL862XX_API_READ_QUIET(priv, SYS_MISC_FW_VERSION, ver)
|
||||
+ && ver.iv_major)
|
||||
+ dev_info(ds->dev, "flash: new firmware %u.%u.%u\n",
|
||||
+ ver.iv_major, ver.iv_minor,
|
||||
+ le16_to_cpu(ver.iv_revision));
|
||||
+ }
|
||||
+
|
||||
+ /* Silently discard all API commands during the teardown that
|
||||
+ * reprobe triggers -- the switch firmware has been reset and
|
||||
+ * has no knowledge of the old configuration.
|
||||
+ */
|
||||
+ priv->skip_teardown = true;
|
||||
+
|
||||
+ reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
|
||||
+ if (!reprobe)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (!try_module_get(THIS_MODULE)) {
|
||||
+ kfree(reprobe);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ reprobe->dev = get_device(ds->dev);
|
||||
+ INIT_DELAYED_WORK(&reprobe->dwork, mxl862xx_reprobe_work_fn);
|
||||
+ schedule_delayed_work(&reprobe->dwork, msecs_to_jiffies(500));
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
--- /dev/null
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-fw.h
|
||||
@@ -0,0 +1,15 @@
|
||||
+/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
+
|
||||
+#ifndef __MXL862XX_FW_H
|
||||
+#define __MXL862XX_FW_H
|
||||
+
|
||||
+#include <net/dsa.h>
|
||||
+
|
||||
+int mxl862xx_devlink_info_get(struct dsa_switch *ds,
|
||||
+ struct devlink_info_req *req,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
+int mxl862xx_devlink_flash_update(struct dsa_switch *ds,
|
||||
+ struct devlink_flash_update_params *params,
|
||||
+ struct netlink_ext_ack *extack);
|
||||
+
|
||||
+#endif /* __MXL862XX_FW_H */
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <linux/limits.h>
|
||||
#include <net/dsa.h>
|
||||
#include "mxl862xx.h"
|
||||
+#include "mxl862xx-cmd.h"
|
||||
#include "mxl862xx-host.h"
|
||||
|
||||
#define CTRL_BUSY_MASK BIT(15)
|
||||
@@ -334,6 +335,12 @@ int mxl862xx_api_wrap(struct mxl862xx_pr
|
||||
int ret, cmd_ret;
|
||||
u16 max, crc, i;
|
||||
|
||||
+ if (priv->skip_teardown)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (priv->block_host && cmd != SYS_MISC_FW_UPDATE)
|
||||
+ return -EBUSY;
|
||||
+
|
||||
dev_dbg(&priv->mdiodev->dev, "CMD %04x DATA %*ph\n", cmd, size, data);
|
||||
|
||||
mutex_lock_nested(&priv->mdiodev->bus->mdio_lock, MDIO_MUTEX_NESTED);
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "mxl862xx.h"
|
||||
#include "mxl862xx-api.h"
|
||||
#include "mxl862xx-cmd.h"
|
||||
+#include "mxl862xx-fw.h"
|
||||
#include "mxl862xx-host.h"
|
||||
#include "mxl862xx-phylink.h"
|
||||
|
||||
@@ -4248,6 +4249,8 @@ static const struct dsa_switch_ops mxl86
|
||||
.get_pause_stats = mxl862xx_get_pause_stats,
|
||||
.get_rmon_stats = mxl862xx_get_rmon_stats,
|
||||
.get_stats64 = mxl862xx_get_stats64,
|
||||
+ .devlink_info_get = mxl862xx_devlink_info_get,
|
||||
+ .devlink_flash_update = mxl862xx_devlink_flash_update,
|
||||
};
|
||||
|
||||
static int mxl862xx_probe(struct mdio_device *mdiodev)
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -394,6 +394,8 @@ struct mxl862xx_priv {
|
||||
u16 lag_bridge_ports[MXL862XX_MAX_LAG_IDS + 1];
|
||||
u8 trunk_hash;
|
||||
int mirror_dest;
|
||||
+ bool block_host;
|
||||
+ bool skip_teardown;
|
||||
struct delayed_work stats_work;
|
||||
};
|
||||
|
||||
+7
-7
@@ -1,7 +1,7 @@
|
||||
From ba48edffc80f3dd676a9e8cf63aa4778a4ed0f0d Mon Sep 17 00:00:00 2001
|
||||
From 24bfab62d4aff34510d24d80c97ea98d8bec6fb0 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 1 Apr 2026 13:43:12 +0100
|
||||
Subject: [PATCH 15/19] net: dsa: mxl862xx: support BR_HAIRPIN_MODE bridge flag
|
||||
Subject: [PATCH 08/12] net: dsa: mxl862xx: support BR_HAIRPIN_MODE bridge flag
|
||||
|
||||
Implement hairpin mode by including the port's own bridge port ID in
|
||||
its forwarding portmap. When hairpin is enabled, bridged frames whose
|
||||
@@ -24,7 +24,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -774,6 +774,10 @@ static int __mxl862xx_set_bridge_port(st
|
||||
@@ -844,6 +844,10 @@ static int __mxl862xx_set_bridge_port(st
|
||||
}
|
||||
mxl862xx_fw_portmap_set_bit(br_port_cfg.bridge_port_map,
|
||||
mxl862xx_cpu_bridge_port_id(ds, port));
|
||||
@@ -35,7 +35,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
} else {
|
||||
mxl862xx_fw_portmap_set_bit(br_port_cfg.bridge_port_map,
|
||||
mxl862xx_cpu_bridge_port_id(ds, port));
|
||||
@@ -3911,7 +3915,7 @@ static int mxl862xx_port_pre_bridge_flag
|
||||
@@ -4074,7 +4078,7 @@ static int mxl862xx_port_pre_bridge_flag
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD |
|
||||
@@ -44,7 +44,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
@@ -3953,7 +3957,11 @@ static int mxl862xx_port_bridge_flags(st
|
||||
@@ -4116,7 +4120,11 @@ static int mxl862xx_port_bridge_flags(st
|
||||
if (flags.mask & BR_LEARNING)
|
||||
priv->ports[port].learning = !!(flags.val & BR_LEARNING);
|
||||
|
||||
@@ -59,7 +59,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
if (ret)
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -243,6 +243,10 @@ struct mxl862xx_port_stats {
|
||||
@@ -249,6 +249,10 @@ struct mxl862xx_port_stats {
|
||||
* @stats_lock: protects accumulator reads in .get_stats64 against
|
||||
* concurrent updates from the polling work
|
||||
* @tag_8021q_vid: currently assigned tag_8021q management VID
|
||||
@@ -70,7 +70,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @ingress_mirror: true when ingress mirroring is active on this port
|
||||
* @egress_mirror: true when egress mirroring is active on this port
|
||||
* @lag: non-NULL when port is member of a LAG group;
|
||||
@@ -272,6 +276,7 @@ struct mxl862xx_port {
|
||||
@@ -278,6 +282,7 @@ struct mxl862xx_port {
|
||||
struct work_struct host_flood_work;
|
||||
u16 tag_8021q_vid;
|
||||
struct mxl862xx_evlan_block cpu_egress_evlan;
|
||||
+8
-8
@@ -1,7 +1,7 @@
|
||||
From 45fcd9669da62b27823004480c07854c54574a1a Mon Sep 17 00:00:00 2001
|
||||
From e487214236ec970a3012148389953111d74d28ea Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 25 Mar 2026 01:51:33 +0000
|
||||
Subject: [PATCH 16/19] net: dsa: mxl862xx: support BR_ISOLATED bridge flag
|
||||
Subject: [PATCH 09/12] net: dsa: mxl862xx: support BR_ISOLATED bridge flag
|
||||
|
||||
Implement port isolation by excluding isolated ports from each other's
|
||||
forwarding portmaps in sync_bridge_members. Non-isolated ports can
|
||||
@@ -19,7 +19,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -767,6 +767,8 @@ static int __mxl862xx_set_bridge_port(st
|
||||
@@ -837,6 +837,8 @@ static int __mxl862xx_set_bridge_port(st
|
||||
continue;
|
||||
if (!mxl862xx_is_lag_master(priv, member_dp->index))
|
||||
continue;
|
||||
@@ -28,7 +28,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
mxl862xx_fw_portmap_set_bit(
|
||||
br_port_cfg.bridge_port_map,
|
||||
mxl862xx_lag_bridge_port(priv,
|
||||
@@ -3915,7 +3917,7 @@ static int mxl862xx_port_pre_bridge_flag
|
||||
@@ -4078,7 +4080,7 @@ static int mxl862xx_port_pre_bridge_flag
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
if (flags.mask & ~(BR_FLOOD | BR_MCAST_FLOOD | BR_BCAST_FLOOD |
|
||||
@@ -37,7 +37,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
@@ -3928,6 +3930,7 @@ static int mxl862xx_port_bridge_flags(st
|
||||
@@ -4091,6 +4093,7 @@ static int mxl862xx_port_bridge_flags(st
|
||||
struct mxl862xx_priv *priv = ds->priv;
|
||||
unsigned long old_block = priv->ports[port].flood_block;
|
||||
unsigned long block = old_block;
|
||||
@@ -45,7 +45,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
int ret;
|
||||
|
||||
if (flags.mask & BR_FLOOD) {
|
||||
@@ -3968,6 +3971,21 @@ static int mxl862xx_port_bridge_flags(st
|
||||
@@ -4131,6 +4134,21 @@ static int mxl862xx_port_bridge_flags(st
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.h
|
||||
@@ -216,6 +216,9 @@ struct mxl862xx_port_stats {
|
||||
@@ -222,6 +222,9 @@ struct mxl862xx_port_stats {
|
||||
* @flood_block: bitmask of firmware meter indices that are currently
|
||||
* rate-limiting flood traffic on this port (zero-rate
|
||||
* meters used to block flooding)
|
||||
@@ -79,7 +79,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @learning: true when address learning is enabled on this port
|
||||
* @setup_done: set at end of port_setup, cleared at start of
|
||||
* port_teardown; guards deferred work against
|
||||
@@ -262,6 +265,7 @@ struct mxl862xx_port {
|
||||
@@ -268,6 +271,7 @@ struct mxl862xx_port {
|
||||
struct mxl862xx_priv *priv;
|
||||
u16 fid;
|
||||
unsigned long flood_block;
|
||||
+10
-9
@@ -1,7 +1,7 @@
|
||||
From 8120b9b88ec47ee41b8350e3e4341839f5fdc28e Mon Sep 17 00:00:00 2001
|
||||
From bd0a830828df2c06af09a4c7ed176ee6b1b96092 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 18:17:49 +0000
|
||||
Subject: [PATCH 17/19] DO NOT SUBMIT: net: dsa: mxl862xx: re-introduce PCE
|
||||
Subject: [PATCH 10/12] DO NOT SUBMIT: net: dsa: mxl862xx: re-introduce PCE
|
||||
workaround for old firmware
|
||||
|
||||
Re-introduce the legacy PCE rule paths needed for firmware versions
|
||||
@@ -31,12 +31,12 @@ upstream.
|
||||
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-cmd.h | 1 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 61 +++++++++++++++++++++----
|
||||
2 files changed, 53 insertions(+), 9 deletions(-)
|
||||
drivers/net/dsa/mxl862xx/mxl862xx.c | 62 +++++++++++++++++++++----
|
||||
2 files changed, 54 insertions(+), 9 deletions(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -32,6 +32,7 @@
|
||||
@@ -33,6 +33,7 @@
|
||||
#define MXL862XX_COMMON_MONITORPORTCFGSET (MXL862XX_COMMON_MAGIC + 0xe)
|
||||
#define MXL862XX_COMMON_REGISTERMOD (MXL862XX_COMMON_MAGIC + 0x11)
|
||||
|
||||
@@ -46,7 +46,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
#define MXL862XX_TFLOW_PCERULELOGICWRITE \
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx.c
|
||||
@@ -449,6 +449,43 @@ static int mxl862xx_setup_drop_meter(str
|
||||
@@ -516,6 +516,44 @@ static int mxl862xx_setup_drop_meter(str
|
||||
return MXL862XX_API_WRITE(priv, MXL862XX_COMMON_REGISTERMOD, reg);
|
||||
}
|
||||
|
||||
@@ -87,10 +87,11 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
|
||||
+
|
||||
/* Per-CTP logical indices for protocol trap rules.
|
||||
*
|
||||
@@ -463,16 +500,20 @@ static int mxl862xx_setup_drop_meter(str
|
||||
* The firmware pre-allocates a per-CTP PCE block for every port during
|
||||
@@ -529,16 +567,20 @@ static int mxl862xx_setup_drop_meter(str
|
||||
#define MXL862XX_MLDV1_CTP_INDEX 3
|
||||
#define MXL862XX_MLDV2_CTP_INDEX 4
|
||||
|
||||
@@ -117,7 +118,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1130,9 +1171,11 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
@@ -1252,9 +1294,11 @@ static int mxl862xx_setup(struct dsa_swi
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
+12
-22
@@ -1,7 +1,7 @@
|
||||
From 494a1eb62219d9ccb97a60e15ea59e7de2f5d9bc Mon Sep 17 00:00:00 2001
|
||||
From 08ba61677ddff8235d5996d785f3a77f983d1b5f Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Tue, 24 Mar 2026 18:19:56 +0000
|
||||
Subject: [PATCH 18/19] DO NOT SUBMIT: net: dsa: mxl862xx: legacy SFP API
|
||||
Subject: [PATCH 11/12] DO NOT SUBMIT: net: dsa: mxl862xx: legacy SFP API
|
||||
fallback for old firmware
|
||||
|
||||
Re-introduce the SYS_MISC_SFP_SET-based PCS implementation as a
|
||||
@@ -16,13 +16,13 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
---
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-api.h | 244 ++++++++++++++++++++
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-cmd.h | 3 +
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.c | 155 ++++++++++++-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.c | 152 +++++++++++-
|
||||
drivers/net/dsa/mxl862xx/mxl862xx-phylink.h | 3 +
|
||||
4 files changed, 401 insertions(+), 4 deletions(-)
|
||||
4 files changed, 401 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-api.h
|
||||
@@ -2164,6 +2164,18 @@ struct mxl862xx_sys_fw_image_version {
|
||||
@@ -2212,6 +2212,18 @@ struct mxl862xx_sys_reg_rw {
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* enum mxl862xx_port_type - Port Type
|
||||
* @MXL862XX_LOGICAL_PORT: Logical Port
|
||||
* @MXL862XX_PHYSICAL_PORT: Physical Port
|
||||
@@ -2178,6 +2190,238 @@ enum mxl862xx_port_type {
|
||||
@@ -2226,6 +2238,238 @@ enum mxl862xx_port_type {
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -282,26 +282,26 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
* @MXL862XX_RMON_CTP_PORT_TX: CTP TX counters
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
|
||||
@@ -27,6 +27,8 @@
|
||||
#define SYS_MISC_MAGIC 0x1900
|
||||
@@ -28,6 +28,8 @@
|
||||
#define MXL862XX_XPCS_MAGIC 0x1a00
|
||||
|
||||
#define MXL862XX_COMMON_REGISTERGET (MXL862XX_COMMON_MAGIC + 0x1)
|
||||
+#define MXL862XX_COMMON_PORTLINKCFGGET (MXL862XX_COMMON_MAGIC + 0x5)
|
||||
+#define MXL862XX_COMMON_PORTCFGGET (MXL862XX_COMMON_MAGIC + 0x7)
|
||||
#define MXL862XX_COMMON_CFGGET (MXL862XX_COMMON_MAGIC + 0x9)
|
||||
#define MXL862XX_COMMON_CFGSET (MXL862XX_COMMON_MAGIC + 0xa)
|
||||
#define MXL862XX_COMMON_MONITORPORTCFGSET (MXL862XX_COMMON_MAGIC + 0xe)
|
||||
@@ -86,6 +88,7 @@
|
||||
|
||||
@@ -88,6 +90,7 @@
|
||||
#define SYS_MISC_FW_UPDATE (SYS_MISC_MAGIC + 0x1)
|
||||
#define SYS_MISC_FW_VERSION (SYS_MISC_MAGIC + 0x2)
|
||||
#define SYS_MISC_REG_RD (SYS_MISC_MAGIC + 0x8)
|
||||
+#define SYS_MISC_SFP_SET (SYS_MISC_MAGIC + 0xe)
|
||||
|
||||
#define MXL862XX_XPCS_PCS_CONFIG (MXL862XX_XPCS_MAGIC + 0x1)
|
||||
#define MXL862XX_XPCS_PCS_GET_STATE (MXL862XX_XPCS_MAGIC + 0x2)
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-phylink.c
|
||||
@@ -60,6 +60,153 @@ static struct mxl862xx_pcs *pcs_to_mxl86
|
||||
@@ -66,6 +66,153 @@ static struct mxl862xx_pcs *pcs_to_mxl86
|
||||
return container_of(pcs, struct mxl862xx_pcs, pcs);
|
||||
}
|
||||
|
||||
@@ -455,7 +455,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
static int mxl862xx_xpcs_if_mode(phy_interface_t interface)
|
||||
{
|
||||
switch (interface) {
|
||||
@@ -350,7 +497,10 @@ void mxl862xx_setup_pcs(struct mxl862xx_
|
||||
@@ -380,7 +527,10 @@ void mxl862xx_setup_pcs(struct mxl862xx_
|
||||
pcs->slot = MXL862XX_SERDES_SLOT(port);
|
||||
pcs->interface = PHY_INTERFACE_MODE_NA;
|
||||
|
||||
@@ -467,16 +467,6 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
pcs->pcs.poll = true;
|
||||
|
||||
__set_bit(PHY_INTERFACE_MODE_QSGMII, pcs->pcs.supported_interfaces);
|
||||
@@ -374,9 +524,6 @@ mxl862xx_phylink_mac_select_pcs(struct p
|
||||
struct mxl862xx_priv *priv = dp->ds->priv;
|
||||
int port = dp->index;
|
||||
|
||||
- if (!MXL862XX_FW_VER_MIN(priv, 1, 0, 84))
|
||||
- return NULL;
|
||||
-
|
||||
switch (port) {
|
||||
case 9 ... 16:
|
||||
return &priv->serdes_ports[port - 9].pcs;
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-phylink.h
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-phylink.h
|
||||
@@ -11,6 +11,9 @@
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
From 332dd61f50b096256f889ecb4d730d385e58aec2 Mon Sep 17 00:00:00 2001
|
||||
From ccec10ae50745572d14b84f157cf7aadb3291033 Mon Sep 17 00:00:00 2001
|
||||
From: Daniel Golle <daniel@makrotopia.org>
|
||||
Date: Wed, 22 Apr 2026 15:15:52 +0100
|
||||
Subject: [PATCH 19/19] DO NOT SUBMIT: net: dsa: mxl862xx: increase CMD timeout
|
||||
Subject: [PATCH 12/12] DO NOT SUBMIT: net: dsa: mxl862xx: increase CMD timeout
|
||||
|
||||
Lift the command timeout by 10x from 500ms to 5s.
|
||||
This is done because older firmware can be extremely slow to respond
|
||||
@@ -14,7 +14,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
+++ b/drivers/net/dsa/mxl862xx/mxl862xx-host.c
|
||||
@@ -207,7 +207,7 @@ static int mxl862xx_busy_wait(struct mxl
|
||||
@@ -210,7 +210,7 @@ static int mxl862xx_busy_wait(struct mxl
|
||||
int val;
|
||||
|
||||
return readx_poll_timeout(mxl862xx_ctrl_read, priv, val,
|
||||
+1
-1
@@ -28,7 +28,7 @@ Signed-off-by: Daniel Golle <daniel@makrotopia.org>
|
||||
|
||||
--- a/net/dsa/tag_mxl862xx_8021q.c
|
||||
+++ b/net/dsa/tag_mxl862xx_8021q.c
|
||||
@@ -23,6 +23,14 @@ static struct sk_buff *mxl862_8021q_xmit
|
||||
@@ -25,6 +25,14 @@ static struct sk_buff *mxl862_8021q_xmit
|
||||
u16 queue_mapping = skb_get_queue_mapping(skb);
|
||||
u8 pcp = netdev_txq_to_tc(netdev, queue_mapping);
|
||||
|
||||
|
||||
Reference in new issue
Block a user