netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v3] net: dsa: mv88e6xxx: Add erratum 3.14 for 88E6390X and 88E6190X
@ 2023-07-21 10:26 Ante Knezic
  2023-07-25  8:56 ` Paolo Abeni
  2023-07-25 17:23 ` Vladimir Oltean
  0 siblings, 2 replies; 11+ messages in thread
From: Ante Knezic @ 2023-07-21 10:26 UTC (permalink / raw)
  To: netdev
  Cc: andrew, f.fainelli, olteanv, davem, edumazet, kuba, pabeni,
	linux-kernel, Ante Knezic

Fixes XAUI/RXAUI lane alignment errors.
Issue causes dropped packets when trying to communicate over
fiber via SERDES lanes of port 9 and 10.
Errata document applies only to 88E6190X and 88E6390X devices.
Requires poking in undocumented registers.

Signed-off-by: Ante Knezic <ante.knezic@helmholz.de>
---
V3 : Rework to fit the new phylink_pcs infrastructure
V2 : Rework as suggested by Andrew Lunn <andrew@lun.ch> 
 * make int lanes[] const 
 * reorder prod_nums
 * update commit message to indicate we are dealing with
   undocumented Marvell registers and magic values
---
 drivers/net/dsa/mv88e6xxx/pcs-639x.c | 42 ++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx/pcs-639x.c b/drivers/net/dsa/mv88e6xxx/pcs-639x.c
index 98dd49dac421..50b14804c360 100644
--- a/drivers/net/dsa/mv88e6xxx/pcs-639x.c
+++ b/drivers/net/dsa/mv88e6xxx/pcs-639x.c
@@ -20,6 +20,7 @@ struct mv88e639x_pcs {
 	struct mdio_device mdio;
 	struct phylink_pcs sgmii_pcs;
 	struct phylink_pcs xg_pcs;
+	struct mv88e6xxx_chip *chip;
 	bool supports_5g;
 	phy_interface_t interface;
 	unsigned int irq;
@@ -205,13 +206,52 @@ static void mv88e639x_sgmii_pcs_pre_config(struct phylink_pcs *pcs,
 	mv88e639x_sgmii_pcs_control_pwr(mpcs, false);
 }
 
+static int mv88e6390_erratum_3_14(struct mv88e639x_pcs *mpcs)
+{
+	const int lanes[] = { MV88E6390_PORT9_LANE0, MV88E6390_PORT9_LANE1,
+		MV88E6390_PORT9_LANE2, MV88E6390_PORT9_LANE3,
+		MV88E6390_PORT10_LANE0, MV88E6390_PORT10_LANE1,
+		MV88E6390_PORT10_LANE2, MV88E6390_PORT10_LANE3 };
+	struct mdio_device mdio;
+	int err, i;
+
+	/* 88e6190x and 88e6390x errata 3.14:
+	 * After chip reset, SERDES reconfiguration or SERDES core
+	 * Software Reset, the SERDES lanes may not be properly aligned
+	 * resulting in CRC errors
+	 */
+
+	mdio.bus = mpcs->mdio.bus;
+
+	for (i = 0; i < ARRAY_SIZE(lanes); i++) {
+		mdio.addr = lanes[i];
+
+		err = mdiodev_c45_write(&mdio, MDIO_MMD_PHYXS,
+					0xf054, 0x400C);
+		if (err)
+			return err;
+
+		err = mdiodev_c45_write(&mdio, MDIO_MMD_PHYXS,
+					0xf054, 0x4000);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
 static int mv88e639x_sgmii_pcs_post_config(struct phylink_pcs *pcs,
 					   phy_interface_t interface)
 {
 	struct mv88e639x_pcs *mpcs = sgmii_pcs_to_mv88e639x_pcs(pcs);
+	struct mv88e6xxx_chip *chip = mpcs->chip;
 
 	mv88e639x_sgmii_pcs_control_pwr(mpcs, true);
 
+	if (chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6190X ||
+	    chip->info->prod_num == MV88E6XXX_PORT_SWITCH_ID_PROD_6390X)
+		mv88e6390_erratum_3_14(mpcs);
+
 	return 0;
 }
 
@@ -523,6 +563,7 @@ static int mv88e6390_pcs_init(struct mv88e6xxx_chip *chip, int port)
 	mpcs->sgmii_pcs.neg_mode = true;
 	mpcs->xg_pcs.ops = &mv88e6390_xg_pcs_ops;
 	mpcs->xg_pcs.neg_mode = true;
+	mpcs->chip = chip;
 
 	err = mv88e639x_pcs_setup_irq(mpcs, chip, port);
 	if (err)
@@ -873,6 +914,7 @@ static int mv88e6393x_pcs_init(struct mv88e6xxx_chip *chip, int port)
 	mpcs->xg_pcs.ops = &mv88e6393x_xg_pcs_ops;
 	mpcs->xg_pcs.neg_mode = true;
 	mpcs->supports_5g = true;
+	mpcs->chip = chip;
 
 	err = mv88e6393x_erratum_4_6(mpcs);
 	if (err)
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-26 10:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 10:26 [PATCH net-next v3] net: dsa: mv88e6xxx: Add erratum 3.14 for 88E6390X and 88E6190X Ante Knezic
2023-07-25  8:56 ` Paolo Abeni
2023-07-25  9:59   ` Ante Knezic
2023-07-25 10:47     ` Paolo Abeni
2023-07-25 10:56       ` Russell King (Oracle)
2023-07-25 17:23 ` Vladimir Oltean
2023-07-25 17:49   ` Russell King (Oracle)
2023-07-26  9:49     ` Ante Knezic
2023-07-26  9:53       ` Russell King (Oracle)
2023-07-26 10:03         ` Ante Knezic
2023-07-26  9:50   ` Ante Knezic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).