realtek: dsa: convert stp_get signature

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>
This commit is contained in:
Markus Stockhausen 2026-01-13 12:53:17 +01:00 committed by Hauke Mehrtens
parent 5b61a50244
commit f70ea84215
7 changed files with 19 additions and 11 deletions

View 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);

View 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);

View 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,

View 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);

View 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,

View 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,

View 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,