From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=66.163.186.205 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796069547; b=SiaHrXSql6Eb/tovsATCdPVt4Ovdl9HKcv6hccOgAwfrR45r7L4A9YHGXAzNeYXMJJTn 0B5g8CXJ32XvmkXT7CckTTD03C8BwXWxVmZAvJc5+OCdWC0wAwjf15LEosI9rvq9oLAhM +gBU6AVtFI8BBNNSt2GsTjfkpbg6bj8IGH+uMBpcMx88BU4ACGpPB1U2lyhOdVW83MCz7 ZviNGB4SB33pWDwQc5hplzDlYNUC6N4VVMzVtjmUd0y/AvQH9RRKbv/4cy6CJqnZ48VgE Nn7H9i1k9z2oyISRKbVMUcWOHOy0I9D9P1KsW6+Pf8T+fTgLo4gs0GCPz36pZf0tTvg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796069547; 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=zZr3XJHwa1b/UFn0qQhPMGuRXD0YTHKz4CeHiZa2liE=; b=vtP3aP89Nd3sfWlQ/rFY71I7H+/PTTP3KXBa6gwmwfLBWHJ/YDqlCeAbun0sNdiFKZgb 93pH5TbGxyOQAdxaUPIC8bOfQ8mlt8JwG6dEso5Y8x7nxvj8/ZOsgXiKmzNkzMJJ7pkAq e4bmiEuJhmzPHmc1g8AjboOReorM0iz5sQVPmLwDbzaVtK5aJFxs0YEraQJAR3SpOviIa 5tLGuCalnVIbKHkh0EYcwoXKL9n3NTlPoZOxrgXBJ+rldypaRv61e1iWbpv40vykbNwp8 t9v9EO50xEIIh0qs8a8mbZIsxcFkKAu/KwVxXZT8/JKBpcA0ot/LNsXYjbDU+HJFr2g== 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=n1TTMXwo; arc=none smtp.remote-ip=66.163.186.205 Received: from sonic310-24.consmr.mail.ne1.yahoo.com (sonic310-24.consmr.mail.ne1.yahoo.com [66.163.186.205]) (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 98F2D606A327 for ; Mon, 30 Nov 2026 20:12:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98F2D606A327 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=n1TTMXwo DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796069545; bh=zZr3XJHwa1b/UFn0qQhPMGuRXD0YTHKz4CeHiZa2liE=; h=Date:Subject:To:References:In-Reply-To:From:Content-Type:From:Subject:Reply-To:Content-Type; b=n1TTMXwodOQe1G+sh7HxCKmTIycbsF1S+wTNr8CxzYbXrEiC1eUHkUuD6CwWNdLDtcE+ZfwaNtRG3NzPW0Uk8SXNYQvpnZ0OQl7BeD1coShgVIHt3wDOhLooIC1GLTkx0jIwqSb8ZGP6PyzindZpzPEJMEBAd8i41MUU1woL+7YOOgoaChGlVx/8H4F/EOTe9ainvgkb2Lt4G2eWBcoo7jYptGTafbVOcL5nENl8tXE93vcKbtlH7rCvclXM984shcz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ASaDThbdB3IcTBNxJbBRfwL.NEBFE23H2koNxOq06x qnQSFhgIVqdV2dtFwUHTeyyqGaR9Ppm_g.TC8Mg7XseYpYChPQ2LxG4D5AHc2lY7d7RXHS5QJ2f9 6fXdApe5E0aD1DDxrrbfWbDp3TA7QudtaSjZkNM64LranPEP5Wf30rVld3PoZhE4q1oT3IRP.ls5 fsPGtkBAxL2rHKs2Gizuw9UIj772ityY.qh_Ml51xEJ0rUmng1YilW7.ONJ01eKsG.6C6efpYZ_x YwO5ZrCeItCosUf3HRqZ.T6CVW1xae403afZbPuuhHKv8P3VRtL31r1h90mqOWIyXPiMv0Xkny0m pyoqUjvCocPsbu3wHk41fUz0q1AlynaMY3Fg4heS.c5L5yccqvFNrECxs2aWQQ3C_abRps3vUD9W Mk7uHBCf0HiQ_dRGSvI7MXs2F2.2oOlkE9YDwQW361XDuhU_ET3RAgyOLHbUlmox3gk.0GqYBz.d 4skqrXb6oNog23O.J8yj2AuTsn7zslK3aQhlkjLLKWmXzt7z8P8nps24pB9qsuU5X5CB5DeqSeay pvTVy3omGDHSGXS_PdRcVyvCuuaGu2f7MAXlrwu80DWkmPSyG9DOh4EJvXb.bNrr4sWhO4Xuit5m m_nU5bc1sSdQxy.a_z3HcZVeLKsApAl1piHUcG4TM0jwMr9rwHZWa8vKHeE9ixzRxOkCpycQ_D_J FAA5uGrp52BE362NV46UIcNbNeeaTO5kxw8.75khDbEePbNnky4AFXXbH2eXgFr23p1e1VRllcqn u7h2cI58CvMsw3pTpKXtZcujTpwePCh5rv0ZKH7VSBEK7s4DuGQ-- X-Sonic-MF: X-Sonic-ID: 1ed38117-efa8-4446-a896-d8a8cc127f23 Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Mon, 30 Nov 2026 20:12:25 +0000 Received: by hermes--production-bf1-8768df57c-hdswg (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID db6ed37712d12e3fffe8511af4c04237; Mon, 30 Nov 2026 20:12:23 +0000 (UTC) Message-ID: Date: Mon, 30 Nov 2026 21:12:18 +0100 X-Mailing-List: linux-kernel@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 v17 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: <236d002f-5ca5-4f12-bf5b-0ed6442e5c9a@yahoo.com> Content-Language: pl In-Reply-To: <236d002f-5ca5-4f12-bf5b-0ed6442e5c9a@yahoo.com> From: Mieczyslaw Nalewaj Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.27100 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 | 25 +++++ 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, 129 insertions(+), 26 deletions(-) diff --git a/drivers/net/dsa/realtek/rtl8365mb.h b/drivers/net/dsa/realtek/rtl8365mb.h index 9a69e85..7fb1a46 100644 --- a/drivers/net/dsa/realtek/rtl8365mb.h +++ b/drivers/net/dsa/realtek/rtl8365mb.h @@ -16,6 +16,27 @@ 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 + * @jam_size: number of entries in @jam_table + * @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 +59,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 05e0d58..7dcf401 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