summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Jelonek2025-12-24 10:28:36 +0000
committerHauke Mehrtens2026-01-03 15:59:48 +0000
commit76f392194b43178adaf9c322cf95a8008a42238c (patch)
tree93cd6e9afb5ab4bb9ce68bd9e9abef93a2881b1d
parentdfd6a4212f30cabe4eb50620391251db0579582c (diff)
downloadopenwrt-76f392194b43178adaf9c322cf95a8008a42238c.tar.gz
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@gmail.com> Link: https://github.com/openwrt/openwrt/pull/21365 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
-rw-r--r--target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c14
1 files 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;