realtek: pcs: rtl930x: gate TX tuning on attachment and baud rate

TX amp/pre-emphasis tuning depends on the SerDes' real baud rate class
rather than hw_mode, so key config_attachment's dispatch on that instead.

At 1G/2.5G, attachment doesn't change meaningful: even a non-adaptive
fiber receiver needs little compensation on a short trace, so
PHY-attached and fiber links already use the same config there. At 10G,
real channel loss is high enough that it matters: PHY-attached links
equalize on the PHY's own far-end receiver and need less amp drive,
while genuine fiber/DAC links, which have no adaptive receiver
downstream, need the full config. Real DAC-vs-fiber detection doesn't
exist yet, so both of those still share one config for now.

Make use of the PLL speed enum for now, though it is a bit blurry and
may not represent the real baud rate in some cases, e.g. QSGMII (1.25G
PLL with multiplier -> 5G).

Link: https://github.com/openwrt/openwrt/pull/24232
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
This commit is contained in:
Jonas Jelonek
2026-07-15 19:37:01 +02:00
parent 629c5c8b11
commit 7f063b1f95
@@ -1691,6 +1691,17 @@ static const struct rtpcs_sds_tx_config rtpcs_930x_sds_tx_config_10g = {
.main_amp = 0x10, .impedance = 0x8
};
/*
* PHY-attached 10G-class links (XSGMII, USXGMII): weaker than the fiber/DAC
* value above since the far-end PHY equalizes on its own. main_amp reuses
* the 1G/2.5G fiber override's value, also the vendor SDK's genuine-fiber
* (non-DAC) 10G value; a non-adaptive receiver needing no more than this
* should be a safe upper bound for a PHY that equalizes on top.
*/
static const struct rtpcs_sds_tx_config rtpcs_930x_sds_tx_config_phy = {
.main_amp = 0x9, .impedance = 0x8
};
/*
* RTL930X needs a special mapping from logic SerDes ID to physical SerDes ID,
* which takes the page into account. This applies to most of read/write calls.
@@ -2989,6 +3000,7 @@ static int rtpcs_930x_sds_config_attachment(struct rtpcs_serdes *sds,
enum rtpcs_sds_mode hw_mode)
{
const struct rtpcs_sds_tx_config *tx_cfg;
enum rtpcs_sds_pll_speed speed;
int ret;
if (sds->type != RTPCS_SDS_TYPE_10G)
@@ -3002,19 +3014,26 @@ static int rtpcs_930x_sds_config_attachment(struct rtpcs_serdes *sds,
if (ret < 0)
return ret;
switch (hw_mode) {
case RTPCS_SDS_MODE_1000BASEX:
case RTPCS_SDS_MODE_SGMII:
ret = rtpcs_sds_select_pll_speed(hw_mode, &speed);
if (ret < 0)
return ret;
switch (speed) {
case RTPCS_SDS_PLL_SPD_1000:
tx_cfg = &rtpcs_930x_sds_tx_config_1g;
break;
case RTPCS_SDS_MODE_2500BASEX:
case RTPCS_SDS_PLL_SPD_2500:
tx_cfg = &rtpcs_930x_sds_tx_config_2g5;
break;
case RTPCS_SDS_MODE_10GBASER:
case RTPCS_SDS_MODE_XSGMII:
case RTPCS_SDS_MODE_USXGMII_10GSXGMII:
case RTPCS_SDS_MODE_USXGMII_10GQXGMII:
tx_cfg = &rtpcs_930x_sds_tx_config_10g;
case RTPCS_SDS_PLL_SPD_10000:
/*
* PHY-attached links equalize on the PHY's own far-end
* receiver, less amp drive needed. Real DAC-vs-fiber
* detection doesn't exist yet, so both of those share
* the same config for now.
*/
tx_cfg = (attachment == RTPCS_SDS_ATTACH_PHY) ? &rtpcs_930x_sds_tx_config_phy
: &rtpcs_930x_sds_tx_config_10g;
break;
default:
return -EOPNOTSUPP;