From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=66.163.190.33 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796422051; b=Vspf6sj0knpXZh+9O0W36uBBxoTBGuv+UKNz3rFsiWNEMS0joOgQ3fyxiQTJHCjH1zhw 0aw7xXaSziJWGtnboWeeFaBYvDDTw87/QzsTGqoK/Lb2pptsCz9O/NVgEHSkRJ5ucR5B2 7PStBgtF5rtlROSai151gkeL9UXS+ewZPv+nnn/rPtv2AdKy50kiWfGr0dXExagckBabX UeOkizM49hfI9PeGZQiY6daPrkNHuXOZczM6nOFcTbD8OeayKuMdkfteJ7lXC8r4N2SGH ksyNX6tH1GQZgx+rmpydgN8cuY3PPVbOxnQdKOJUnlYi/5c6SKlfDjaUsCD6oWuCKSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796422051; h=DMARC-Filter:DKIM-Signature:X-SONIC-DKIM-SIGN:X-YMail-OSG:X-Sonic-MF: X-Sonic-ID:Received:Received:Message-ID:Date:MIME-Version:User-Agent: Subject:To:References:Content-Language:In-Reply-To:From:Content-Type: Content-Transfer-Encoding:X-Mailer; bh=R1mUlJvWm6A5zj5qvvVKFEQdLiwIsZD6qeDfu1XUZp8=; b=Eyz+kuu/BPt/w9ECr8YwhTyXxb8SVLVZr7LihxZB0pFbNQLgki4D2hTCB1U6QieB1yAD PyQeGd0N7v4488Q7OTgYRKFUHKUdACX6c62gyKsJVLFtZXy90SVQjju6S1xbWjwhYwMr6 ou9X1qpmYEy0pBcstTThhL/AbRLT1gE37zWR7BkZZ9zMcAu7sY9p/8LceRB3Y+OI7CViD GfEBU14c6VuB+Uy6b/sx9+v7sc9Gdw7ingIOm0vXMApl2dkeAvglkytI7acges9m7fZnq /HyHpKZVwATPyRyTqG7/4ZT7eZI9hdrZG8xhrzzGqdJ3ssAqcXPV35mnK8vpyrcnGCw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=yahoo.com; spf=pass smtp.mailfrom=yahoo.com; dkim=pass header.d=yahoo.com header.i=@yahoo.com header.a=rsa-sha256 header.s=s2048 header.b=G79jNi5b; arc=none smtp.remote-ip=66.163.190.33 Received: from sonic307-10.consmr.mail.ne1.yahoo.com (sonic307-10.consmr.mail.ne1.yahoo.com [66.163.190.33]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 357E8606A32D for ; Fri, 4 Dec 2026 22:07:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 357E8606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=yahoo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yahoo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=yahoo.com header.i=@yahoo.com header.a=rsa-sha256 header.s=s2048 header.b=G79jNi5b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796422050; bh=R1mUlJvWm6A5zj5qvvVKFEQdLiwIsZD6qeDfu1XUZp8=; h=Date:Subject:To:References:In-Reply-To:From:Content-Type:From:Subject:Reply-To:Content-Type; b=G79jNi5bhGuW89ZoLUta1bz9XKaAcU2nek+R7SS0AmnPA/HVPiIGaJ26RtJKW7kjnKRIj1MPMss KvWMDvJx6635La9tF7SvgpnxFNKOsc/AqGaLuN6ZwEADgEe/aHwqKVPgHuWZ/bxBf/rflPqfnOCsK etnyVHVbL4elPqtO6il6x7SQc0YCVXp2AdFFxkB7cFhBv2fZC0HafG6g+GY8vxam76oLy3l6s7c2l y1dAz8I2/ZxB4adWSeoQFDzyyDGNaIe9bvVxYpVzdnYPiAH+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4XZTH_jhNn8itOs 81xpbGH9w0RvNolCi1kDpjjaYxoTGfFPi7gZScj336S_ZHrWPzpMd9OQs3Euxwm.EybElxnMD19f .3NvDIlw5fe5CD8Xog5ZsmVWidRa0Q_j.noapqrp4cgNsilE5SiRrkquk3tJoX3IwxcucnUKZx6y cKo1R85urRh0Hc7HFBSUcQfThqiKsEcRg.1YaEN3yWWw3uNbp284XG3IF0rBeuiAv2AXit04hb8d fh.RDrhqIYusd972IBoHjR3ttyMlsofvp_SKGKLyEPJTU2L8u4joEaGXh22BezTBO3XVpOhJmW0t PNQsgSX5VlHLlOKStfGACBUXTlhuqdwd5_B0EEJ7v8CO.E157wN21gnZzFhrn2Pk0w2GvQlxEGGg OaKeqsS7MM3s1neyxo5vE0_6Vm51lfG4QR98I7D0toXQgCpAwd.FtbRUxdnlZNE3SY3FcX4FIaHD 4FhKcxHaT3MYQ_fhCHCjbA45gH8bS3RIOztS4sAWh3nIXvHcf5MW3tRtSVTCH91YoIPU4AI9dZkR F9UQalhYcwNsaisjdLStPyarnJmYp2wF.h3kQ0hjAbll8Mky5VrtKbPe0sTTYV30Zq..rWm.SXw7 qQFbnJzxznjkhBUVbXsTYSmtgz073BFsZCVh7pqqoI6dDrXdIX45g2na8CMH.AgNuD2u_brjVDXl ACF70vVcWXjT4O1qhLXApRjNZ31MlapquyGxIvcbe44uwJ9ZaVMmRuZUJFVq7aFd_bUhgkcmf0Q0 6RdnMewd8y4gNCAc1gupPKbrjzqKz76ods4yYtQsT.wQsg1Hwog-- X-Sonic-MF: X-Sonic-ID: fa0e5e68-335d-4ebd-b126-fb37557cd27f Received: from sonic.gate.mail.ne1.yahoo.com by sonic307.consmr.mail.ne1.yahoo.com with HTTP; Fri, 4 Dec 2026 22:07:30 +0000 Received: by hermes--production-ir2-7c4859dc89-4b5bc (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 5125743ea3a032e89433a9745372f9a8; Fri, 04 Dec 2026 22:07:26 +0000 (UTC) Message-ID: <89d0b901-22c5-4c03-80b0-dc14749b3534@yahoo.com> Date: Fri, 4 Dec 2026 23:07:24 +0100 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH net-next v20 13/15] net: dsa: realtek: rtl8365mb: refactor QoS priority handling To: linusw@kernel.org, andrew@lunn.ch, olteanv@gmail.com, kuba@kernel.org, davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, linux@armlinux.org.uk, luizluca@gmail.com, maxime.chevallier@bootlin.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, alvin.sipraga@analog.com, gusfmora@gmail.com, kuncy7@gmail.com, fabianotassotti@gmail.com, gabonpivovich@gmail.com, contact@c127.dev, o.rempel@pengutronix.de References: <9efcb80a-517c-4413-8261-4f9380e0eb83@yahoo.com> Content-Language: pl In-Reply-To: <9efcb80a-517c-4413-8261-4f9380e0eb83@yahoo.com> From: Mieczyslaw Nalewaj Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.27159 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo The shared QoS layer hands the backend internal priorities that are 802.1Q traffic types, and the backend stores them in the chip as they are, together with a separate per-port PCP for untagged frames. Family D numbers its internal priorities differently and has no separate untagged-PCP register, which the next patch adds. Move the conversion between a traffic type and the chip's priority, and the programming of the PCP of untagged frames, behind three new hooks in struct rtl8365mb_family_info, as for the VLAN, PVID and L2 helpers: qos_iprio_to_hw, qos_hw_to_iprio and qos_set_untag_pcp. The existing behaviour becomes the family C implementation: the traffic type is stored as it is and the untagged PCP register is written as before. rtl8365mb_qos_qmap_init() now iterates over the chip's priorities and converts each one back to its traffic type. Name the qmap index hw_prio throughout, because it is already in the chip's numbering. No functional change. Tested-by: Gustavo Foletto Mora Signed-off-by: Mieczyslaw Nalewaj Reviewed-by: Linus Walleij --- drivers/net/dsa/realtek/rtl8365mb.h | 26 +++++ drivers/net/dsa/realtek/rtl8365mb_main.c | 3 + drivers/net/dsa/realtek/rtl8365mb_qos.c | 119 ++++++++++++++++++----- drivers/net/dsa/realtek/rtl8365mb_qos.h | 8 +- 4 files changed, 130 insertions(+), 26 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.h b/drivers/net/dsa/realtek/rtl8365mb.h index 9a69e85..b87b7bc 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.h +++ b/drivers/net/dsa/realtek/rtl8365mb.h @@ -16,6 +16,28 @@ struct rtl8365mb_vlan4k; struct rtl8365mb_l2_uc; struct rtl8365mb_l2_mc; +/** + * struct rtl8365mb_family_info - family-specific data and operations + * @family: silicon family identifier + * @jam_table: family-specific initialization jam table, or NULL if the + * family needs none (family D) + * @jam_size: number of entries in @jam_table, 0 if @jam_table is NULL + * @ext_config_forcemode: program an external interface force-mode register + * @vlan_4k_read: read a 4K VLAN table entry + * @vlan_4k_write: write a 4K VLAN table entry + * @vlan_port_get_pvid: read a port PVID + * @vlan_port_reset_pvid: restore a port PVID to its default + * @vlan_pvid_port_set: add a port to a PVID + * @vlan_pvid_port_clear: remove a port from a PVID + * @l2_entry_size: number of words in an L2 table entry + * @l2_data_to_uc: unpack a unicast L2 table entry + * @l2_uc_to_data: pack a unicast L2 table entry + * @l2_data_to_mc: unpack a multicast L2 table entry + * @l2_mc_to_data: pack a multicast L2 table entry + * @qos_iprio_to_hw: convert a traffic type to a hardware priority + * @qos_hw_to_iprio: convert a hardware priority to a traffic type + * @qos_set_untag_pcp: program the per-port untagged PCP where supported + */ struct rtl8365mb_family_info { enum rtl8365mb_family family; const struct rtl8365mb_jam_tbl_entry *jam_table; @@ -38,6 +60,10 @@ struct rtl8365mb_family_info { void (*l2_uc_to_data)(const struct rtl8365mb_l2_uc *uc, u16 *data); void (*l2_data_to_mc)(const u16 *data, struct rtl8365mb_l2_mc *mc); void (*l2_mc_to_data)(const struct rtl8365mb_l2_mc *mc, u16 *data); + int (*qos_iprio_to_hw)(u8 iprio); + int (*qos_hw_to_iprio)(u8 hw); + int (*qos_set_untag_pcp)(struct realtek_priv *priv, int port, + u8 untag_pcp); }; const struct rtl8365mb_family_info * diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c index 87ecb0c..57fdee5 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_main.c +++ b/drivers/net/dsa/realtek/rtl8365mb_main.c @@ -840,6 +840,9 @@ static const struct rtl8365mb_family_info rtl8365mb_family_c = { .l2_uc_to_data = rtl8365mb_c_l2_uc_to_data, .l2_data_to_mc = rtl8365mb_c_l2_data_to_mc, .l2_mc_to_data = rtl8365mb_c_l2_mc_to_data, + .qos_iprio_to_hw = rtl8365mb_c_qos_iprio_to_hw, + .qos_hw_to_iprio = rtl8365mb_c_qos_hw_to_iprio, + .qos_set_untag_pcp = rtl8365mb_c_qos_set_untag_pcp, }; /** diff --git a/drivers/net/dsa/realtek/rtl8365mb_qos.c b/drivers/net/dsa/realtek/rtl8365mb_qos.c index 5b9e1ab..d422955 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_qos.c +++ b/drivers/net/dsa/realtek/rtl8365mb_qos.c @@ -18,10 +18,12 @@ #include #include "realtek.h" +#include "rtl8365mb.h" #include "rtl8365mb_qos.h" -/* The chip's eight internal priorities carry 802.1Q traffic types, one - * internal priority per traffic type. +/* The shared rtl83xx-qos.c layer hands this backend internal priorities + * that are 802.1Q traffic types. The chip's own priority is derived from + * them through the qos_* hooks of struct rtl8365mb_family_info. */ static_assert(RTL8365MB_NUM_INTERNAL_PRIOS == IEEE8021Q_TT_MAX); @@ -40,12 +42,12 @@ static_assert(RTL8365MB_QOS_SEL_BITS <= RTL8365MB_QOS_SEL_STRIDE); static_assert(RTL8365MB_QOS_SEL_STRIDE * RTL8365MB_QOS_SELS_PER_REG <= RTL8365MB_QOS_REG_BITS); -/* qmaps: the queue id of each internal priority, one table per qmap */ +/* qmaps: the queue id of each hardware priority, one table per qmap */ #define RTL8365MB_QOS_QMAP_TBL_REGS \ (RTL8365MB_NUM_INTERNAL_PRIOS / RTL8365MB_QOS_SELS_PER_REG) -#define RTL8365MB_QOS_QMAP_TBL_REG(_m, _iprio) \ +#define RTL8365MB_QOS_QMAP_TBL_REG(_m, _hw_prio) \ (0x0904 + (_m) * RTL8365MB_QOS_QMAP_TBL_REGS + \ - (_iprio) / RTL8365MB_QOS_SELS_PER_REG) + (_hw_prio) / RTL8365MB_QOS_SELS_PER_REG) /* The qmap each port reads, one select per port */ #define RTL8365MB_QOS_PORT_QMAP_SEL_REG(_p) \ @@ -218,54 +220,113 @@ static int rtl8365mb_qos_check_port(struct realtek_priv *priv, int port) return 0; } +/* Family C stores the traffic type as the chip's priority */ +int rtl8365mb_c_qos_iprio_to_hw(u8 iprio) +{ + return iprio; +} + +int rtl8365mb_c_qos_hw_to_iprio(u8 hw) +{ + return hw; +} + +int rtl8365mb_c_qos_set_untag_pcp(struct realtek_priv *priv, int port, + u8 untag_pcp) +{ + return rtl8365mb_qos_regmap_update_field(priv, + RTL8365MB_QOS_PORT_UNTAG_PCP_REG(port), + rtl8365mb_qos_sel_mask(port), + untag_pcp); +} + +/* Convert an internal priority (an 802.1Q traffic type) to the value the + * chip uses. Return the value or a negative errno. + */ +static int rtl8365mb_qos_iprio_to_hw(struct realtek_priv *priv, u8 iprio) +{ + return rtl8365mb_get_family_info(priv)->qos_iprio_to_hw(iprio); +} + +/* Convert a chip priority back to an internal priority (a traffic type) */ +static int rtl8365mb_qos_hw_to_iprio(struct realtek_priv *priv, u8 hw) +{ + return rtl8365mb_get_family_info(priv)->qos_hw_to_iprio(hw); +} + int rtl8365mb_qos_get_port_prio(struct realtek_priv *priv, int port) { - return rtl8365mb_qos_regmap_read_field(priv, - RTL8365MB_QOS_PORT_PRI_REG(port), - rtl8365mb_qos_sel_mask(port)); + int val; + + val = rtl8365mb_qos_regmap_read_field(priv, + RTL8365MB_QOS_PORT_PRI_REG(port), + rtl8365mb_qos_sel_mask(port)); + if (val < 0) + return val; + + return rtl8365mb_qos_hw_to_iprio(priv, val); } int rtl8365mb_qos_set_port_prio(struct realtek_priv *priv, int port, u8 iprio, u8 untag_pcp) { - u32 untag_reg = RTL8365MB_QOS_PORT_UNTAG_PCP_REG(port); u32 reg = RTL8365MB_QOS_PORT_PRI_REG(port); u32 mask = rtl8365mb_qos_sel_mask(port); - int ret; + int hw, ret; ret = rtl8365mb_qos_check_port(priv, port); if (ret) return ret; - ret = rtl8365mb_qos_regmap_update_field(priv, untag_reg, mask, - untag_pcp); + hw = rtl8365mb_qos_iprio_to_hw(priv, iprio); + if (hw < 0) + return hw; + + ret = rtl8365mb_get_family_info(priv)->qos_set_untag_pcp(priv, port, + untag_pcp); if (ret) return ret; - return rtl8365mb_qos_regmap_update_field(priv, reg, mask, iprio); + return rtl8365mb_qos_regmap_update_field(priv, reg, mask, hw); } int rtl8365mb_qos_set_pcp_prio(struct realtek_priv *priv, u8 pcp, u8 iprio) { u32 reg = RTL8365MB_QOS_1Q_REMAP_REG(pcp); u32 mask = rtl8365mb_qos_sel_mask(pcp); + int hw; - return rtl8365mb_qos_regmap_update_field(priv, reg, mask, iprio); + hw = rtl8365mb_qos_iprio_to_hw(priv, iprio); + if (hw < 0) + return hw; + + return rtl8365mb_qos_regmap_update_field(priv, reg, mask, hw); } int rtl8365mb_qos_get_dscp_prio(struct realtek_priv *priv, u8 dscp) { - return rtl8365mb_qos_regmap_read_field(priv, - RTL8365MB_QOS_DSCP_PRI_REG(dscp), - rtl8365mb_qos_sel_mask(dscp)); + int val; + + val = rtl8365mb_qos_regmap_read_field(priv, + RTL8365MB_QOS_DSCP_PRI_REG(dscp), + rtl8365mb_qos_sel_mask(dscp)); + if (val < 0) + return val; + + return rtl8365mb_qos_hw_to_iprio(priv, val); } int rtl8365mb_qos_set_dscp_prio(struct realtek_priv *priv, u8 dscp, u8 iprio) { u32 reg = RTL8365MB_QOS_DSCP_PRI_REG(dscp); u32 mask = rtl8365mb_qos_sel_mask(dscp); + int hw; - return rtl8365mb_qos_regmap_update_field(priv, reg, mask, iprio); + hw = rtl8365mb_qos_iprio_to_hw(priv, iprio); + if (hw < 0) + return hw; + + return rtl8365mb_qos_regmap_update_field(priv, reg, mask, hw); } static int rtl8365mb_qos_set_port_qmap(struct realtek_priv *priv, int port, @@ -280,10 +341,10 @@ static int rtl8365mb_qos_set_port_qmap(struct realtek_priv *priv, int port, } static int rtl8365mb_qos_set_qmap_qid(struct realtek_priv *priv, int qmap, - u8 iprio, u8 qid) + u8 hw_prio, u8 qid) { - u32 reg = RTL8365MB_QOS_QMAP_TBL_REG(qmap, iprio); - u32 mask = rtl8365mb_qos_sel_mask(iprio); + u32 reg = RTL8365MB_QOS_QMAP_TBL_REG(qmap, hw_prio); + u32 mask = rtl8365mb_qos_sel_mask(hw_prio); return rtl8365mb_qos_regmap_update_field(priv, reg, mask, qid); } @@ -306,19 +367,27 @@ int rtl8365mb_qos_qmap_init(struct realtek_priv *priv) { unsigned int nq = priv->ds.num_tx_queues; struct dsa_port *dp; - int iprio, ret; + int hw_prio, ret; - for (iprio = 0; iprio < RTL8365MB_NUM_INTERNAL_PRIOS; iprio++) { - int tc = ieee8021q_tt_to_tc(iprio, nq); + /* The table is indexed by the chip's priority, not by the traffic + * type. + */ + for (hw_prio = 0; hw_prio < RTL8365MB_NUM_INTERNAL_PRIOS; hw_prio++) { + int tt = rtl8365mb_qos_hw_to_iprio(priv, hw_prio); + int tc; u8 qid; + if (tt < 0) + return tt; + + tc = ieee8021q_tt_to_tc(tt, nq); if (tc < 0) return tc; qid = rtl8365mb_qos_tc_to_qid(nq, tc); ret = rtl8365mb_qos_set_qmap_qid(priv, RTL8365MB_QOS_QMAP_DEFAULT, - iprio, qid); + hw_prio, qid); if (ret) return ret; } diff --git a/drivers/net/dsa/realtek/rtl8365mb_qos.h b/drivers/net/dsa/realtek/rtl8365mb_qos.h index 9602807..70c50ab 100644 --- a/drivers/net/dsa/realtek/rtl8365mb_qos.h +++ b/drivers/net/dsa/realtek/rtl8365mb_qos.h @@ -14,7 +14,7 @@ struct realtek_priv; /* Ports the QoS code handles */ #define RTL8365MB_QOS_MAX_PORTS 8 -/* Internal priority -> queue id tables (qmaps) */ +/* Hardware priority -> queue id tables (qmaps) */ #define RTL8365MB_QOS_NUM_QMAPS 8 int rtl8365mb_qos_pridec_init(struct realtek_priv *priv); @@ -30,4 +30,10 @@ int rtl8365mb_qos_set_apptrust(struct realtek_priv *priv, int port, int rtl8365mb_qos_get_apptrust(struct realtek_priv *priv, int port, bool *trust, unsigned int n); +/* Hooks of struct rtl8365mb_family_info, one set per chip family */ +int rtl8365mb_c_qos_iprio_to_hw(u8 iprio); +int rtl8365mb_c_qos_hw_to_iprio(u8 hw); +int rtl8365mb_c_qos_set_untag_pcp(struct realtek_priv *priv, int port, + u8 untag_pcp); + #endif /* _REALTEK_RTL8365MB_QOS_H */ -- 2.53.0