From 63fab3bad4fd24ad2b6b28bd17710296ea313f77 Mon Sep 17 00:00:00 2001 From: Markus Stockhausen Date: Tue, 15 Sep 2026 12:25:31 +0200 Subject: [PATCH] realtek: dsa: fix RTL839x egress queue configuration RTL839X_QM_PORT_QNUM contains ten packed 3-bit port fields per register. Writing the complete register for each port therefore clears the queue configuration of the other ports sharing that register. Update rtl839x_set_egress_queue() to modify only the field belonging to the requested port. Use the corrected helper during QoS initialization for all user ports and the CPU port. While we are here make the function static. Assisted-by: ChatGPT (OpenAI GPT-5.6 Sol) Link: https://github.com/openwrt/openwrt/pull/25186 Signed-off-by: Markus Stockhausen --- .../files-6.18/drivers/net/dsa/rtl83xx/qos.c | 14 +++++++------- .../files-6.18/drivers/net/dsa/rtl83xx/qos.h | 2 -- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.c b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.c index a759ff3338f..3d259d9f558 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.c +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.c @@ -157,9 +157,12 @@ static void rtl839x_setup_default_prio2queue(void) } /* Sets the output queue assigned to a port, the port can be the CPU-port */ -void rtl839x_set_egress_queue(int port, int queue) +static void rtl839x_set_egress_queue(int port, int queue) { - sw_w32(queue << ((port % 10) * 3), RTL839X_QM_PORT_QNUM(port)); + u32 shift = (port % 10) * 3; + u32 mask = 0x7 << shift; + + sw_w32_mask(mask, (queue & 0x7) << shift, RTL839X_QM_PORT_QNUM(port)); } /* Sets the priority assigned of an ingress port, the port can be the CPU-port */ @@ -322,11 +325,8 @@ void rtldsa_839x_qos_init(struct rtl838x_switch_priv *priv) pr_info("RTL839X_PRI_SEL_TBL_CTRL(i): %08x\n", sw_r32(RTL839X_PRI_SEL_TBL_CTRL(0))); rtl839x_setup_default_prio2queue(); - for (int port = 0; port < priv->r->cpu_port; port++) - sw_w32(7, RTL839X_QM_PORT_QNUM(port)); - - /* CPU-port gets queue number 7 */ - sw_w32(7, RTL839X_QM_PORT_QNUM(priv->r->cpu_port)); + for (int port = 0; port <= priv->r->cpu_port; port++) + rtl839x_set_egress_queue(port, 7); for (int port = 0; port <= priv->r->cpu_port; port++) { rtldsa_839x_set_ingress_priority(port, 0); diff --git a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.h b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.h index e741273673a..1593d2715a1 100644 --- a/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.h +++ b/target/linux/realtek/files-6.18/drivers/net/dsa/rtl83xx/qos.h @@ -17,6 +17,4 @@ void rtldsa_839x_qos_init(struct rtl838x_switch_priv *priv); void rtldsa_930x_qos_init(struct rtl838x_switch_priv *priv); void rtldsa_931x_qos_init(struct rtl838x_switch_priv *priv); -void rtl839x_set_egress_queue(int port, int queue); - #endif /* _OTTO_QOS_H */