]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: dsa: make pcs a port attribute
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Tue, 3 Mar 2026 18:26:59 +0000 (19:26 +0100)
committerRobert Marko <robimarko@gmail.com>
Thu, 5 Mar 2026 09:39:34 +0000 (10:39 +0100)
pcs is currently a standalone array for the pcs of each port.
Convert it to an attribute of the port structure and thus move
it where it belongs.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/22255
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/common.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/dsa.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c

index ba2a0529635af7a19c95e803217be543a08e8752..4b0e4b4fa2e34af995c1e78fee9647d10d3016c8 100644 (file)
@@ -305,11 +305,11 @@ static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
                }
 
                if (pcs_node) {
-                       priv->pcs[pn] = rtpcs_create(priv->dev, pcs_node, pn);
-                       if (IS_ERR(priv->pcs[pn])) {
+                       priv->ports[pn].pcs = rtpcs_create(priv->dev, pcs_node, pn);
+                       if (IS_ERR(priv->ports[pn].pcs)) {
                                dev_err(priv->dev, "port %u failed to create PCS instance: %ld\n",
-                                       pn, PTR_ERR(priv->pcs[pn]));
-                               priv->pcs[pn] = NULL;
+                                       pn, PTR_ERR(priv->ports[pn].pcs));
+                               priv->ports[pn].pcs = NULL;
                                continue;
                        }
                }
@@ -338,7 +338,7 @@ static int rtl83xx_mdio_probe(struct rtl838x_switch_priv *priv)
                }
 
                if (!phy_node) {
-                       if (priv->pcs[pn])
+                       if (priv->ports[pn].pcs)
                                priv->ports[pn].phy_is_integrated = true;
 
                        continue;
index b8bbea432ed1676bd2799556b697326237e8dd32..8f4ed35f125e83ca990fe18bd9c5d80113e00836 100644 (file)
@@ -50,7 +50,7 @@ static void rtldsa_enable_phy_polling(struct rtl838x_switch_priv *priv)
        msleep(1000);
        /* Enable all ports with a PHY, including the SFP-ports */
        for (int i = 0; i < priv->cpu_port; i++) {
-               if (priv->ports[i].phy || priv->pcs[i])
+               if (priv->ports[i].phy || priv->ports[i].pcs)
                        v |= BIT_ULL(i);
        }
 
@@ -180,7 +180,7 @@ static int rtldsa_83xx_setup(struct dsa_switch *ds)
         * they will work in isolated mode (only traffic between port and CPU).
         */
        for (int i = 0; i < priv->cpu_port; i++) {
-               if (priv->ports[i].phy || priv->pcs[i]) {
+               if (priv->ports[i].phy || priv->ports[i].pcs) {
                        priv->ports[i].pm = BIT_ULL(priv->cpu_port);
                        priv->r->traffic_set(i, BIT_ULL(i));
                }
@@ -253,7 +253,7 @@ static int rtldsa_93xx_setup(struct dsa_switch *ds)
         * they will work in isolated mode (only traffic between port and CPU).
         */
        for (int i = 0; i < priv->cpu_port; i++) {
-               if (priv->ports[i].phy || priv->pcs[i]) {
+               if (priv->ports[i].phy || priv->ports[i].pcs) {
                        priv->ports[i].pm = BIT_ULL(priv->cpu_port);
                        priv->r->traffic_set(i, BIT_ULL(i));
                }
@@ -291,7 +291,7 @@ static struct phylink_pcs *rtldsa_phylink_mac_select_pcs(struct dsa_switch *ds,
 {
        struct rtl838x_switch_priv *priv = ds->priv;
 
-       return priv->pcs[port];
+       return priv->ports[port].pcs;
 }
 
 static void rtldsa_83xx_phylink_get_caps(struct dsa_switch *ds, int port,
@@ -767,7 +767,7 @@ static void rtldsa_poll_counters(struct work_struct *work)
                                                        counters_work);
 
        for (int port = 0; port < priv->cpu_port; port++) {
-               if (!priv->ports[port].phy && !priv->pcs[port])
+               if (!priv->ports[port].phy && !priv->ports[port].pcs)
                        continue;
 
                rtldsa_counters_lock(priv, port);
@@ -784,7 +784,7 @@ static void rtldsa_init_counters(struct rtl838x_switch_priv *priv)
        struct rtldsa_counter_state *counters;
 
        for (int port = 0; port < priv->cpu_port; port++) {
-               if (!priv->ports[port].phy && !priv->pcs[port])
+               if (!priv->ports[port].phy && !priv->ports[port].pcs)
                        continue;
 
                counters = &priv->ports[port].counters;
index 119e4210c2832eec4181cdf4c75cc3074f811d06..c900da01cdd1044c51666aebab92546db33d2b14 100644 (file)
@@ -886,6 +886,7 @@ struct rtl838x_port {
        u16 pvid;
        bool eee_enabled;
        enum phy_type phy;
+       struct phylink_pcs *pcs;
        int led_set;
        int leds_on_this_port;
        struct rtldsa_counter_state counters;
@@ -1375,7 +1376,6 @@ struct rtl838x_switch_priv {
        u16 id;
        u16 family_id;
        struct rtl838x_port ports[57];
-       struct phylink_pcs *pcs[57];
        struct mutex reg_mutex;         /* Mutex for individual register manipulations */
        struct mutex pie_mutex;         /* Mutex for Packet Inspection Engine */
        int link_state_irq;
index 7368f31a9f8d6aca14be4547b7ded26aa2fdd4e7..39477b84bb90db6548db26758ba676828c50eb76 100644 (file)
@@ -2637,7 +2637,7 @@ static void rtl930x_led_init(struct rtl838x_switch_priv *priv)
                sw_w32_mask(0x3 << pos, 0, RTL930X_LED_PORT_FIB_SET_SEL_CTRL(i));
                sw_w32_mask(0x3 << pos, 0, RTL930X_LED_PORT_COPR_SET_SEL_CTRL(i));
 
-               if (!priv->ports[i].phy && !priv->pcs[i] && !(forced_leds_per_port[i]))
+               if (!priv->ports[i].phy && !priv->ports[i].pcs && !(forced_leds_per_port[i]))
                        continue;
 
                if (forced_leds_per_port[i] > 0)
index 18fc77c6bc0a8bfcf108fe2d048a7e1160eb98c8..2bbc20d63335a4b3e386898d6a42f025c4f70f52 100644 (file)
@@ -1749,7 +1749,7 @@ static void rtldsa_931x_led_init(struct rtl838x_switch_priv *priv)
                sw_w32_mask(0x3 << pos, 0, RTL931X_LED_PORT_COPR_SET_SEL_CTRL(i));
 
                /* Skip port if not present (auto-detect) or not in forced mask */
-               if (!priv->ports[i].phy && !priv->pcs[i] && !(forced_leds_per_port[i]))
+               if (!priv->ports[i].phy && !priv->ports[i].pcs && !(forced_leds_per_port[i]))
                        continue;
 
                if (forced_leds_per_port[i] > 0)