]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: pcs: cover number of links per SerDes for USXGMII
authorJonas Jelonek <jelonek.jonas@gmail.com>
Fri, 2 Jan 2026 16:30:16 +0000 (16:30 +0000)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 3 Jan 2026 15:59:48 +0000 (16:59 +0100)
A SerDes may supply multiple ports and depending on that number,
different hardware modes need to be used. While there are corresponding
modes in the kernel in some cases (e.g. USXGMII with 4 2.5G ports aka
10G-QXGMII), this doesn't always map to Realtek hardware modes. Use the
previously added link number accounting for that.

An obvious example of this is the SerDes on XGS12xx-12 switches which
is connected to an octa-PHY. This runs Realtek proprietary XSGMII mode
(10G-pumped SGMII interface) for which there is no corresponding mode
in the kernel.

Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/21365
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c

index da11b7bafe326d7c92fdb8379d032487bf2f5636..bd19bd5fb23f7c5c899f1b308b8cab77273d85e5 100644 (file)
@@ -285,6 +285,8 @@ static int rtpcs_sds_determine_hw_mode(struct rtpcs_serdes *sds,
                                        phy_interface_t if_mode,
                                        enum rtpcs_sds_mode *hw_mode)
 {
+       u8 n_links = sds->num_of_links;
+
        switch (if_mode) {
        case PHY_INTERFACE_MODE_NA:
                *hw_mode = RTPCS_SDS_MODE_OFF;
@@ -308,8 +310,15 @@ static int rtpcs_sds_determine_hw_mode(struct rtpcs_serdes *sds,
                *hw_mode = RTPCS_SDS_MODE_QSGMII;
                break;
        case PHY_INTERFACE_MODE_USXGMII:
-               /* TODO: set this depending on number of links on SerDes */
-               *hw_mode = RTPCS_SDS_MODE_USXGMII_10GSXGMII;
+               if (n_links == 1)
+                       *hw_mode = RTPCS_SDS_MODE_USXGMII_10GSXGMII;
+               else if (n_links == 2)
+                       *hw_mode = RTPCS_SDS_MODE_USXGMII_10GDXGMII;
+               else if (n_links <= 4)
+                       *hw_mode = RTPCS_SDS_MODE_USXGMII_10GQXGMII;
+               else if (n_links <= 8)
+                       *hw_mode = RTPCS_SDS_MODE_XSGMII;
+
                break;
        case PHY_INTERFACE_MODE_10G_QXGMII:
                *hw_mode = RTPCS_SDS_MODE_USXGMII_10GQXGMII;