]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: dsa: convert stp_get signature
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Tue, 13 Jan 2026 11:53:17 +0000 (12:53 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Wed, 21 Jan 2026 21:54:46 +0000 (22:54 +0100)
The device specific stp_get() function returns a device specific
state to the generic caller. So the caller must use a if/else
statement depending on the family to look into the retrieved data.

Change the signature of the function so it can return a device
independent state of a given port in the future. Additionally
use the new function prefix.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21527
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
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.c
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.h
target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c
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 a30748206791a4e3267c0bab11def68594992c35..66e7c784ffa80e2fe3aa98a3ea25d77c8b07f0d7 100644 (file)
@@ -43,7 +43,7 @@ int rtl83xx_port_get_stp_state(struct rtl838x_switch_priv *priv, int port)
        index = n - (pos >> 4) - 1;
        bit = (pos << 1) % 32;
 
-       priv->r->stp_get(priv, msti, port_state);
+       priv->r->stp_get(priv, msti, port, port_state);
 
        mutex_unlock(&priv->reg_mutex);
 
index b9c7cda60c59889139992a5d66c3e559768c3204..551bfe8efcb4529585e679567c8cbf43b85e0991 100644 (file)
@@ -1899,7 +1899,7 @@ static void rtldsa_port_xstp_state_set(struct rtl838x_switch_priv *priv, int por
        index = n - (pos >> 4) - 1;
        bit = (pos << 1) % 32;
 
-       priv->r->stp_get(priv, mst_slot, port_state);
+       priv->r->stp_get(priv, mst_slot, port, port_state);
 
        pr_debug("Current state, port %d: %d\n", port, (port_state[index] >> bit) & 3);
        port_state[index] &= ~(3 << bit);
index 39e15ba3e02b20b568f5c5d5d986699bd5555b71..37a782b5e1ddd8f112c4d1ea1134cd078703bfd5 100644 (file)
@@ -562,7 +562,7 @@ static void rtl838x_set_static_move_action(int port, bool forward)
                    RTL838X_L2_PORT_STATIC_MV_ACT(port));
 }
 
-static void rtl838x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
+static int rtldsa_838x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
 {
        u32 cmd = 1 << 15 | /* Execute cmd */
                  1 << 14 | /* Read */
@@ -572,6 +572,8 @@ static void rtl838x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port
 
        for (int i = 0; i < 2; i++)
                port_state[i] = sw_r32(priv->r->tbl_access_data_0(i));
+
+       return 0;
 }
 
 static void rtl838x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
@@ -1709,7 +1711,7 @@ const struct rtl838x_reg rtl838x_reg = {
        .enable_mcast_flood = rtl838x_enable_mcast_flood,
        .enable_bcast_flood = rtl838x_enable_bcast_flood,
        .set_static_move_action = rtl838x_set_static_move_action,
-       .stp_get = rtl838x_stp_get,
+       .stp_get = rtldsa_838x_stp_get,
        .stp_set = rtl838x_stp_set,
        .mac_port_ctrl = rtl838x_mac_port_ctrl,
        .l2_port_new_salrn = rtl838x_l2_port_new_salrn,
index 5c621eb1e3b82a4da6631f988d5ca62c4f8c6f93..a60eb7bdb8019e6e680a695bbbd2839a2cd3bcc7 100644 (file)
@@ -1226,7 +1226,7 @@ struct rtl838x_reg {
        void (*enable_mcast_flood)(int port, bool enable);
        void (*enable_bcast_flood)(int port, bool enable);
        void (*set_static_move_action)(int port, bool forward);
-       void (*stp_get)(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]);
+       int (*stp_get)(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[]);
        void (*stp_set)(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[]);
        int  (*mac_force_mode_ctrl)(int port);
        int  (*mac_port_ctrl)(int port);
index 6fac41296fb9b6bbe7d0ff4afb0532e9b964682e..18b3065f549a68db3810d5b57710dffd6778df16 100644 (file)
@@ -653,7 +653,7 @@ void rtl839x_vlan_profile_dump(int profile)
        pr_debug("VLAN profile %d: raw %08x, %08x\n", profile, p[0], p[1]);
 }
 
-static void rtl839x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
+static int rtldsa_839x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
 {
        u32 cmd = 1 << 16 | /* Execute cmd */
                  0 << 15 | /* Read */
@@ -663,6 +663,8 @@ static void rtl839x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port
 
        for (int i = 0; i < 4; i++)
                port_state[i] = sw_r32(priv->r->tbl_access_data_0(i));
+
+       return 0;
 }
 
 static void rtl839x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
@@ -1661,7 +1663,7 @@ const struct rtl838x_reg rtl839x_reg = {
        .enable_mcast_flood = rtl839x_enable_mcast_flood,
        .enable_bcast_flood = rtl839x_enable_bcast_flood,
        .set_static_move_action = rtl839x_set_static_move_action,
-       .stp_get = rtl839x_stp_get,
+       .stp_get = rtldsa_839x_stp_get,
        .stp_set = rtl839x_stp_set,
        .mac_force_mode_ctrl = rtl839x_mac_force_mode_ctrl,
        .mac_port_ctrl = rtl839x_mac_port_ctrl,
index bb41acaf64ac9a297d8604e89fdfb8bb5f93aa0e..55c78ba54d815c890a042228480833691f3ef3fe 100644 (file)
@@ -402,7 +402,7 @@ static void rtldsa_930x_enable_flood(int port, bool enable)
                    RTL930X_L2_LRN_PORT_CONSTRT_CTRL + port * 4);
 }
 
-static void rtl930x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
+static int rtldsa_930x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
 {
        u32 cmd = 1 << 17 | /* Execute cmd */
                  0 << 16 | /* Read */
@@ -413,6 +413,8 @@ static void rtl930x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port
        for (int i = 0; i < 2; i++)
                port_state[i] = sw_r32(RTL930X_TBL_ACCESS_DATA_0(i));
        pr_debug("MSTI: %d STATE: %08x, %08x\n", msti, port_state[0], port_state[1]);
+
+       return 0;
 }
 
 static void rtl930x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
@@ -2646,7 +2648,7 @@ const struct rtl838x_reg rtl930x_reg = {
        .vlan_fwd_on_inner = rtl930x_vlan_fwd_on_inner,
        .set_vlan_igr_filter = rtl930x_set_igr_filter,
        .set_vlan_egr_filter = rtl930x_set_egr_filter,
-       .stp_get = rtl930x_stp_get,
+       .stp_get = rtldsa_930x_stp_get,
        .stp_set = rtl930x_stp_set,
        .mac_force_mode_ctrl = rtl930x_mac_force_mode_ctrl,
        .mac_port_ctrl = rtl930x_mac_port_ctrl,
index e6e42a4bc19fbb35371e9a85e71e81d13100f6b0..e815eec10b23b50bb1e7aebc309b3bf81bbfc673 100644 (file)
@@ -156,7 +156,7 @@ static void rtl931x_vlan_profile_dump(int index)
                 index, (u32)(profile[0] & (3 << 14)), profile[1], profile[2], profile[3]);
 }
 
-static void rtl931x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
+static int rtldsa_931x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
 {
        u32 cmd = 1 << 20 | /* Execute cmd */
                  0 << 19 | /* Read */
@@ -166,6 +166,8 @@ static void rtl931x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, u32 port
 
        for (int i = 0; i < 4; i++)
                port_state[i] = sw_r32(priv->r->tbl_access_data_0(i));
+
+       return 0;
 }
 
 static void rtl931x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
@@ -1829,7 +1831,7 @@ const struct rtl838x_reg rtl931x_reg = {
        .vlan_profile_dump = rtl931x_vlan_profile_dump,
        .vlan_profile_setup = rtl931x_vlan_profile_setup,
        .vlan_fwd_on_inner = rtl931x_vlan_fwd_on_inner,
-       .stp_get = rtl931x_stp_get,
+       .stp_get = rtldsa_931x_stp_get,
        .stp_set = rtl931x_stp_set,
        .mac_force_mode_ctrl = rtl931x_mac_force_mode_ctrl,
        .mac_port_ctrl = rtl931x_mac_port_ctrl,