[openwrt/openwrt] realtek: pcs: keep track of number of links per SerDes

LEDE Commits lede-commits at lists.infradead.org
Sat Jan 3 08:00:43 PST 2026


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/76f392194b43178adaf9c322cf95a8008a42238c

commit 76f392194b43178adaf9c322cf95a8008a42238c
Author: Jonas Jelonek <jelonek.jonas at gmail.com>
AuthorDate: Wed Dec 24 10:28:36 2025 +0000

    realtek: pcs: keep track of number of links per SerDes
    
    Add a field to the rtpcs_serdes structure to keep track of how many
    links (aka ports) are used on a single SerDes. This is needed to be
    known to map kernel interface modes to SerDes hardware modes properly
    (e.g. USXGMII --> USXGMII/10G-QXGMII/XSGMII).
    
    While working in rtpcs_create, optimize referencing the SerDes instance
    for cleaner code.
    
    Signed-off-by: Jonas Jelonek <jelonek.jonas at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/21365
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c      | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
index 2953c5c5f5..da11b7bafe 100644
--- a/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
+++ b/target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c
@@ -12,6 +12,7 @@
 
 #define RTPCS_SDS_CNT				14
 #define RTPCS_PORT_CNT				57
+#define RTPCS_MAX_LINKS_PER_SDS			8
 
 #define RTPCS_SPEED_10				0
 #define RTPCS_SPEED_100				1
@@ -134,8 +135,9 @@ struct rtpcs_ctrl;
 
 struct rtpcs_serdes {
 	struct rtpcs_ctrl *ctrl;
-	u8 id;
 	enum rtpcs_sds_mode hw_mode;
+	u8 id;
+	u8 num_of_links;
 
 	bool rx_pol_inv;
 	bool tx_pol_inv;
@@ -3090,6 +3092,7 @@ struct phylink_pcs *rtpcs_create(struct device *dev, struct device_node *np, int
 {
 	struct platform_device *pdev;
 	struct device_node *pcs_np;
+	struct rtpcs_serdes *sds;
 	struct rtpcs_ctrl *ctrl;
 	struct rtpcs_link *link;
 	u32 sds_id;
@@ -3124,8 +3127,12 @@ struct phylink_pcs *rtpcs_create(struct device *dev, struct device_node *np, int
 		return ERR_PTR(-EINVAL);
 	if (sds_id >= ctrl->cfg->serdes_count)
 		return ERR_PTR(-EINVAL);
-	if (rtpcs_sds_read(&ctrl->serdes[sds_id], 0, 0) < 0)
+
+	sds = &ctrl->serdes[sds_id];
+	if (rtpcs_sds_read(sds, 0, 0) < 0)
 		return ERR_PTR(-EINVAL);
+	if (sds->num_of_links >= RTPCS_MAX_LINKS_PER_SDS)
+		return ERR_PTR(-ERANGE);
 
 	link = kzalloc(sizeof(*link), GFP_KERNEL);
 	if (!link) {
@@ -3135,9 +3142,10 @@ struct phylink_pcs *rtpcs_create(struct device *dev, struct device_node *np, int
 
 	device_link_add(dev, ctrl->dev, DL_FLAG_AUTOREMOVE_CONSUMER);
 
+	sds->num_of_links++;
 	link->ctrl = ctrl;
 	link->port = port;
-	link->sds = &ctrl->serdes[sds_id];
+	link->sds = sds;
 	link->pcs.ops = ctrl->cfg->pcs_ops;
 	link->pcs.neg_mode = true;
 




More information about the lede-commits mailing list