From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=66.163.187.33 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796169404; b=FyF3nnXRA87k143Ye7oIR7ImqWJxw+iOQpuX6pV8F+CCYj4NTsm9dAmsQsCIKfdPo3gY zXH2nuTqV5frzGE5JzxBVvSpkaoZrYuU8N2lyGyWl4Bg1RTsevP6b7tztnaTTYsjv99H3 u35bOwwl/731uFRTw4sXiNRi3ZZY9dl7d7dG03D7mvOtY/V1j10yyi5OHwjobOPWoPmzY WXnNDBWkFckw41lmVI9q+D6CZFQheg6attVm2UWeu3rtBMd6NU9/pNaleLiTUqd3gEsos pnefGon0xyC/8idPVzboTwr9p+ZnS2UNwvtHn8jH1gFzVbxoBlC20FM6rJCtgA48wOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796169404; 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=HMKmgSgga1oyA9PAPVuAVbKdtud1XQWQnqBzcmshV1M=; b=HPxP7cQbetjSZddi+3Y1wtoi2MFNh0ErdWovohyg3ug4JLPMbuLwNK0Bt41pgT16hnjg IYBFmxKYtgELm4jlminfye/Es3tU0EObDT9lavNyA9PmXFaOisGdOn+rYzB9m+y0D2MRI FhGH8Axdu99PM8iBge7zgexXQIKmP06Q2UToeRIxqxWlqRrYQ6oz8HNXgOLt5w7tRUq1j X4DzIft6dfzm76mPkafiEafSHQ1/ucTxrdCnC2/dYLRX100cSIQmP7JNugb0+RWRyox3q WSyMDrYs3k8ywy5asjAObQVsUXe9b0+nx4XfrlTTfWQ2n4MjScMGyf7AVpvxf0dchQw== 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=GhLoh5Tk; arc=none smtp.remote-ip=66.163.187.33 Received: from sonic308-10.consmr.mail.ne1.yahoo.com (sonic308-10.consmr.mail.ne1.yahoo.com [66.163.187.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 03891606A31A for ; Tue, 1 Dec 2026 23:56:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 03891606A31A 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=GhLoh5Tk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796169402; bh=HMKmgSgga1oyA9PAPVuAVbKdtud1XQWQnqBzcmshV1M=; h=Date:Subject:To:References:In-Reply-To:From:Content-Type:From:Subject:Reply-To:Content-Type; b=GhLoh5Tkkvs9mNal4OXsL4n0rhRZXClDhHTHkkk6UrwwPro0ckx4yV44cWK7NyoN7IMzy54jSPOD7v4CMSO2A83dYyx5ykKO41br7EcO3/FHqEGwx+HrKwcpN20hzCN/Jpv97jNKhxYFO56pLFTu2qKjharH2mEDfYVM5OB+NeIsPGWl2YC/U+ULMtTQhufmpjxry5uKyofteuqgpj4BeYXiTRxC8sNs+sutFDSayNS1Lx0bpVINCx/+fHb3qH9zDYksMQ1AHMH5vkPgc8ntQt32PJoSrIe/CYtFjAumxMd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ygZASM9ACczLYWFm3jC5NQr6kSpPwt2qr2ylElUyV4YSp5jbQC9PONRO7kJW7UcbPzywGip 4OhiP3M7My5Uf2w2fvtq7vOgOQWSTT0I56.Tv.U93LckwjTHKpHM5UWyRSVdMNteXhYqivcbowvl i0Gr_MNlE3i3E0Zo5Jcm8A9bJhlPQxBQN3l_je3TTavMnhV8S4rpZv2rkWgdeO5451KeUUQbBC3R 8VbXeWSTN6t.zJTMNornBr5yGkY115JR49DL.khj9IYva1RTeVm3r1KVGoaLxXQbq0.ztYquUH7M HHMg_EcbQ93jPhlCVKHfqQsROCsjW1gyvWDoXwQvxdZba9PGYv8lcIkKfQ.1ib5mTZ9dlCx4vZkF 0YuJT2lJ2aRuQJFmqtiDC1znuEB_W1rTilVcHA3qK2dOpGnMoaoC6Yw8jm01f1sQUR2BtHq3t8AO g13JRBEQi0.Udki_c0Zngi2ZnImEW8Uu7NktcpUQ_RrbaX9H5BFb8ObQ9h.xacH24r2WepiNO6cQ ukU42zNDeqsupxReEG_wgbRIqH5rtS5jdHMSsV.FtJSD2nzMp_CKVykTU1vD11BuqZKDTHpPnhZc o68HDS12SS8Ljh2MnoLUMWuFagOQOv3UHpKfzw5yg9Pz9Opxm8fobtLO4QjJ46j89dW1cu.7HCEW VkuON1dFqby05wX6gwP4NAsCRbSlbIsKV3ha5lADWECH6Fc7mBl51YzXLx6huyjSltIcwhoVdyqh gU6839xjb9b0mTNE8FPTGAg_5sqASxV1wG.pXiN6.7BxCtS79BJjv X-Sonic-MF: X-Sonic-ID: 8c30ea88-4d5e-4221-b2ab-105935c5bb9a Received: from sonic.gate.mail.ne1.yahoo.com by sonic308.consmr.mail.ne1.yahoo.com with HTTP; Tue, 1 Dec 2026 23:56:42 +0000 Received: by hermes--production-ir2-7c4859dc89-nqpvs (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID cd7b3255728ed54f7189742beb5356b3; Tue, 01 Dec 2026 23:56:37 +0000 (UTC) Message-ID: Date: Wed, 2 Dec 2026 00:56:34 +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 v18 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: <1383a67b-15e4-4c76-8bbf-65d3cbfa1fc1@yahoo.com> Content-Language: pl In-Reply-To: <1383a67b-15e4-4c76-8bbf-65d3cbfa1fc1@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 663c964..207f59a 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