From: mike.marciniszyn@gmail.com
To: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
Russell King <linux@armlinux.org.uk>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Alexander Duyck <alexanderduyck@fb.com>,
Kees Cook <kees@kernel.org>
Cc: mike.marciniszyn@gmail.com, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH net-next 1/2] net: pcs: xpcs: Add hooks for xpcs configuration of rsfec
Date: Wed, 6 May 2026 15:09:03 -0400 [thread overview]
Message-ID: <20260506190904.4029-2-mike.marciniszyn@gmail.com> (raw)
In-Reply-To: <20260506190904.4029-1-mike.marciniszyn@gmail.com>
From: "Mike Marciniszyn (Meta)" <mike.marciniszyn@gmail.com>
The DW PCS IP data sheet calls out the need to populate
these vendor registers when operating at speeds above 10Gbps.
This change enables the correct FEC settings to enable RS-FEC
encoding on the link which is the standard used for most links
at these higher speeds.
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Signed-off-by: Mike Marciniszyn (Meta) <mike.marciniszyn@gmail.com>
---
drivers/net/pcs/pcs-xpcs.c | 82 ++++++++++++++++++++++++++++++++++++++
drivers/net/pcs/pcs-xpcs.h | 6 +++
include/uapi/linux/mdio.h | 3 ++
3 files changed, 91 insertions(+)
diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c
index e69fa2f0a0e8..0987621632a7 100644
--- a/drivers/net/pcs/pcs-xpcs.c
+++ b/drivers/net/pcs/pcs-xpcs.c
@@ -219,6 +219,12 @@ int xpcs_write(struct dw_xpcs *xpcs, int dev, u32 reg, u16 val)
return mdiodev_c45_write(xpcs->mdiodev, dev, reg, val);
}
+static int
+xpcs_bus_write(struct dw_xpcs *xpcs, int prtad, int dev, u32 reg, u16 val)
+{
+ return mdiobus_c45_write(xpcs->mdiodev->bus, prtad, dev, reg, val);
+}
+
int xpcs_modify(struct dw_xpcs *xpcs, int dev, u32 reg, u16 mask, u16 set)
{
return mdiodev_c45_modify(xpcs->mdiodev, dev, reg, mask, set);
@@ -1402,6 +1408,78 @@ static int xpcs_read_ids(struct dw_xpcs *xpcs)
return 0;
}
+static int xpcs_get_pma_mmd(struct dw_xpcs *xpcs)
+{
+ int devs1, b;
+
+ devs1 = xpcs_read(xpcs, MDIO_MMD_PMAPMD, MDIO_DEVS1);
+ if (devs1 < 0)
+ return devs1;
+
+ /* Locate the PMA closest to the PCS as this should be the one provided
+ * with the DW IP. This is identified by being the PMA with the
+ * highest MMD device address.
+ */
+ devs1 &= MDIO_DEVS_SEP_PMA1 | MDIO_DEVS_SEP_PMA2 | MDIO_DEVS_SEP_PMA3 |
+ MDIO_DEVS_SEP_PMA4 | MDIO_DEVS_PMAPMD;
+ b = fls(devs1);
+ if (b)
+ return b - 1;
+
+ return -ENODEV;
+}
+
+struct pma_pcs_values {
+ int lanes;
+ u16 rsfec_ctrl;
+};
+
+static int
+xpcs_config_rsfec_pma(struct dw_xpcs *xpcs, const struct pma_pcs_values *v)
+{
+ int ret = 0, i, pma_mmd;
+
+ pma_mmd = xpcs_get_pma_mmd(xpcs);
+ if (pma_mmd < 1)
+ return pma_mmd;
+
+ for (i = 0; ret >= 0 && i < v->lanes; i++) {
+ ret = xpcs_bus_write(xpcs, i, pma_mmd, MDIO_PMA_RSFEC_CTRL,
+ v->rsfec_ctrl);
+ }
+ return ret;
+}
+
+static int xpcs_25gbaser_pma_config(struct dw_xpcs *xpcs)
+{
+ const struct pma_pcs_values v = {
+ .rsfec_ctrl = 0,
+ .lanes = 1,
+ };
+
+ return xpcs_config_rsfec_pma(xpcs, &v);
+}
+
+static int xpcs_50gbaser_pma_config(struct dw_xpcs *xpcs)
+{
+ const struct pma_pcs_values v = {
+ .rsfec_ctrl = DW_VR_RSFEC_CTRL_TC_PAD_ALTER,
+ .lanes = 2,
+ };
+
+ return xpcs_config_rsfec_pma(xpcs, &v);
+}
+
+static int xpcs_100gbasep_pma_config(struct dw_xpcs *xpcs)
+{
+ const struct pma_pcs_values v = {
+ .rsfec_ctrl = MDIO_PMA_RSFEC_CTRL_4LANE_PMD,
+ .lanes = 2,
+ };
+
+ return xpcs_config_rsfec_pma(xpcs, &v);
+}
+
static const struct dw_xpcs_compat synopsys_xpcs_compat[] = {
{
.interface = PHY_INTERFACE_MODE_USXGMII,
@@ -1415,6 +1493,7 @@ static const struct dw_xpcs_compat synopsys_xpcs_compat[] = {
.interface = PHY_INTERFACE_MODE_25GBASER,
.supported = xpcs_25gbaser_features,
.an_mode = DW_AN_C73,
+ .pma_config = xpcs_25gbaser_pma_config,
}, {
.interface = PHY_INTERFACE_MODE_XLGMII,
.supported = xpcs_xlgmii_features,
@@ -1423,14 +1502,17 @@ static const struct dw_xpcs_compat synopsys_xpcs_compat[] = {
.interface = PHY_INTERFACE_MODE_50GBASER,
.supported = xpcs_50gbaser_features,
.an_mode = DW_AN_C73,
+ .pma_config = xpcs_50gbaser_pma_config,
}, {
.interface = PHY_INTERFACE_MODE_LAUI,
.supported = xpcs_50gbaser2_features,
.an_mode = DW_AN_C73,
+ .pma_config = xpcs_50gbaser_pma_config,
}, {
.interface = PHY_INTERFACE_MODE_100GBASEP,
.supported = xpcs_100gbasep_features,
.an_mode = DW_AN_C73,
+ .pma_config = xpcs_100gbasep_pma_config,
}, {
.interface = PHY_INTERFACE_MODE_10GBASER,
.supported = xpcs_10gbaser_features,
diff --git a/drivers/net/pcs/pcs-xpcs.h b/drivers/net/pcs/pcs-xpcs.h
index 929fa238445e..187cdec30e70 100644
--- a/drivers/net/pcs/pcs-xpcs.h
+++ b/drivers/net/pcs/pcs-xpcs.h
@@ -94,6 +94,12 @@
#define DW_VR_MII_DIG_CTRL2_TX_POL_INV BIT(4)
#define DW_VR_MII_DIG_CTRL2_RX_POL_INV BIT(0)
+/* Clause 133 defines */
+/* RSFEC transcode pad alter
+ * DW vendor extension in RS-FEC control
+ */
+#define DW_VR_RSFEC_CTRL_TC_PAD_ALTER BIT(10)
+
#define DW_XPCS_INFO_DECLARE(_name, _pcs, _pma) \
static const struct dw_xpcs_info _name = { .pcs = _pcs, .pma = _pma }
diff --git a/include/uapi/linux/mdio.h b/include/uapi/linux/mdio.h
index b2541c948fc1..5219c877b2cf 100644
--- a/include/uapi/linux/mdio.h
+++ b/include/uapi/linux/mdio.h
@@ -317,6 +317,9 @@
#define MDIO_PMA_10GBR_FECABLE_ABLE 0x0001 /* FEC ability */
#define MDIO_PMA_10GBR_FECABLE_ERRABLE 0x0002 /* FEC error indic. ability */
+/* RSFEC PMA Control register */
+#define MDIO_PMA_RSFEC_CTRL_4LANE_PMD BIT(3)
+
/* PMA 10GBASE-R Fast Retrain status and control register. */
#define MDIO_PMA_10GBR_FSRT_ENABLE 0x0001 /* Fast retrain enable */
--
2.43.0
next prev parent reply other threads:[~2026-05-06 19:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-06 19:09 [PATCH net-next 0/2] second series for xpcs based rsfec configuration mike.marciniszyn
2026-05-06 19:09 ` mike.marciniszyn [this message]
2026-05-09 1:06 ` [PATCH net-next 1/2] net: pcs: xpcs: Add hooks for xpcs configuration of rsfec Jakub Kicinski
2026-05-06 19:09 ` [PATCH net-next 2/2] net: pcs: xpcs: Add handling for 4 channel rsfec device mike.marciniszyn
2026-05-09 1:06 ` Jakub Kicinski
2026-05-09 20:15 ` Mike Marciniszyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260506190904.4029-2-mike.marciniszyn@gmail.com \
--to=mike.marciniszyn@gmail.com \
--cc=alexanderduyck@fb.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=kees@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox