[openwrt/openwrt] realtek: dsa: enrich stp_get() return value
LEDE Commits
lede-commits at lists.infradead.org
Wed Jan 21 13:57:22 PST 2026
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/92121e6aa57de9a5c7f89ee39b99a6fc30e21182
commit 92121e6aa57de9a5c7f89ee39b99a6fc30e21182
Author: Markus Stockhausen <markus.stockhausen at gmx.de>
AuthorDate: Tue Jan 13 13:41:52 2026 +0100
realtek: dsa: enrich stp_get() return value
The family specific stp_get() functions have a new return value
that gives the stp status of a given port. Instead of a constant
zero value provide the real data.
While we are here align the RTL930x implementation with the
other ones.
- Drop the debug output
- Make use of priv->r->tbl_access_data_0()
Signed-off-by: Markus Stockhausen <markus.stockhausen at gmx.de>
Link: https://github.com/openwrt/openwrt/pull/21527
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
.../linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c | 6 ++++--
.../linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c | 6 ++++--
.../linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c | 9 +++++----
.../linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c | 6 ++++--
4 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c
index 37a782b5e1..2436093674 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl838x.c
@@ -564,16 +564,18 @@ static void rtl838x_set_static_move_action(int port, bool forward)
static int rtldsa_838x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
{
+ int idx = 1 - (port / 16);
+ int bit = 2 * (port % 16);
u32 cmd = 1 << 15 | /* Execute cmd */
1 << 14 | /* Read */
2 << 12 | /* Table type 0b10 */
(msti & 0xfff);
- priv->r->exec_tbl0_cmd(cmd);
+ priv->r->exec_tbl0_cmd(cmd);
for (int i = 0; i < 2; i++)
port_state[i] = sw_r32(priv->r->tbl_access_data_0(i));
- return 0;
+ return (port_state[idx] >> bit) & 3;
}
static void rtl838x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c
index 18b3065f54..7d3152d5b0 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl839x.c
@@ -655,16 +655,18 @@ void rtl839x_vlan_profile_dump(int profile)
static int rtldsa_839x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
{
+ int idx = 3 - ((port + 12) / 16);
+ int bit = 2 * ((port + 12) % 16);
u32 cmd = 1 << 16 | /* Execute cmd */
0 << 15 | /* Read */
5 << 12 | /* Table type 0b101 */
(msti & 0xfff);
- priv->r->exec_tbl0_cmd(cmd);
+ priv->r->exec_tbl0_cmd(cmd);
for (int i = 0; i < 4; i++)
port_state[i] = sw_r32(priv->r->tbl_access_data_0(i));
- return 0;
+ return (port_state[idx] >> bit) & 3;
}
static void rtl839x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
index 55c78ba54d..fbf21c07ca 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl930x.c
@@ -404,17 +404,18 @@ static void rtldsa_930x_enable_flood(int port, bool enable)
static int rtldsa_930x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
{
+ int idx = 1 - ((port + 3) / 16);
+ int bit = 2 * ((port + 3) % 16);
u32 cmd = 1 << 17 | /* Execute cmd */
0 << 16 | /* Read */
4 << 12 | /* Table type 0b10 */
(msti & 0xfff);
- priv->r->exec_tbl0_cmd(cmd);
+ priv->r->exec_tbl0_cmd(cmd);
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]);
+ port_state[i] = sw_r32(priv->r->tbl_access_data_0(i));
- return 0;
+ return (port_state[idx] >> bit) & 3;
}
static void rtl930x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
diff --git a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c
index e815eec10b..1a3b9858d5 100644
--- a/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c
+++ b/target/linux/realtek/files-6.12/drivers/net/dsa/rtl83xx/rtl931x.c
@@ -158,16 +158,18 @@ static void rtl931x_vlan_profile_dump(int index)
static int rtldsa_931x_stp_get(struct rtl838x_switch_priv *priv, u16 msti, int port, u32 port_state[])
{
+ int idx = 3 - ((port + 8) / 16);
+ int bit = 2 * ((port + 8) % 16);
u32 cmd = 1 << 20 | /* Execute cmd */
0 << 19 | /* Read */
5 << 15 | /* Table type 0b101 */
(msti & 0x3fff);
- priv->r->exec_tbl0_cmd(cmd);
+ priv->r->exec_tbl0_cmd(cmd);
for (int i = 0; i < 4; i++)
port_state[i] = sw_r32(priv->r->tbl_access_data_0(i));
- return 0;
+ return (port_state[idx] >> bit) & 3;
}
static void rtl931x_stp_set(struct rtl838x_switch_priv *priv, u16 msti, u32 port_state[])
More information about the lede-commits
mailing list