From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=66.163.185.148 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796264303; b=nIPMtQudDsEr7QdDLxR/NM4UVow2nlx3cxceqCdwj08dQ3HLKxo0NBCbqllMZbkJ31CH 2mMZaXLIkgTz7n4ip5ZDTujmPouS3UD6l8VPHWTrLngOomiSFHMPg7ahpOfV9WKDVCeGR 25JhDy3IEGx3DVS8dk3PxqGgrhElM+ALIFewpvuZqRQHbN49YmH2zn0muHewxiw9XzY9a Q+PE/C1ejpm4PllTz+M1GPQg9pOb3q2LMeWoysyXA3KiyktYuae6IzoenuMLgVMM1A1/0 YImi4YdLhAbjkKclQ1uEr6zCsiuQtw5dt0kKxpgARtNsdBUmABUnmr/sFtIGyVQ9WcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796264303; 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=UifvBjJq7xZNm2/YP174h+pLenEabY4nQsuUrMRSfWQ=; b=mxDVyaSJcFaeYsKHknp6AskQ+MKmY61fTPbRzuy+eQ5Kya5lXh2YFl8Gr8C3yCdLT21v HOhwzLdeaosA4zJRUYm610qMRABSC3glwAq4UFjH4yvOUV/peQohsiXX0Q3YMI5ItNnca l/eiEOVQygVglVE53QoKz6E4zSJau43SONZFv0+ZMRCLWixHezQy6d/G6IDr8W2/W9W4O fcXrwPhMr5tH4D34oalgyP36wOtFhGyKJNqj6ndF8mkVLfnpPtsq8BxeiJCYCKHilQ/34 VBQoLyml2WwhMJQsNHxQeXxPvoFsIsqDPUIIINjOA9VaYe0tUktkVVzN81OarriAK8A== 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=OqCYwzGN; arc=none smtp.remote-ip=66.163.185.148 Received: from sonic305-22.consmr.mail.ne1.yahoo.com (sonic305-22.consmr.mail.ne1.yahoo.com [66.163.185.148]) (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 79B4D606A32F for ; Thu, 3 Dec 2026 02:18:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79B4D606A32F 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=OqCYwzGN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796264301; bh=UifvBjJq7xZNm2/YP174h+pLenEabY4nQsuUrMRSfWQ=; h=Date:Subject:To:References:In-Reply-To:From:Content-Type:From:Subject:Reply-To:Content-Type; b=OqCYwzGN08Sh41qEPXc1w7YCD17xUS8m3elqVIr/vkrhr2LXNtZSCGY/cZxfAqeeCkCw5I9Iu8/waTRNhcc9eSj1F2GFpLKF8CqPqN4tKz2ElWyyYFZl9e8Qt81u24a6eyztQnLor5KUOX38EpteQtNwpJHNkZP9r8yYEtxbYs4zNlLa8Ld3vdL8KpMOrTzIOmy2Q/el0zS4lEFJrZNGSygyfGvK8JTzEZ5gvjPkoaSygdOPnx4yrxgFLhHeFFQkx5Qg6CclUlHWeaRaR/oQmT4+nJUQDQady9TMzUa7ngSzUkZjmDkACMurGrzEegkqadyqaHhKN03fFkOuvh7Rpg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1796264301; bh=jKhg8E4g1vENi6YnpuNQIofJpXHeNE6TcZIBlwHMNXw=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=EHMYT4E3UmMz3i8Ek8ukZNFszuDPFq8Led5gIWn3qipg+R5C4hYpjkceAdHZW8C2H4ZxDfmmEAC9Pe/ROxG4TA4QAA/8Y/PFhpQOQt2tPSYMpeZzaippr22rjeAuclhe2HEorkctUD2vbXg2uyUxhQfLsASuga6bpPdb3AoSy989FgGr6RB/vR+jcExgE0Sk7WpENrhXod7kBuUX3/uHvWl41LN3GiEAp3wOH/QiY/FOUseRwuIAHN9SKmud7Z68FwXBabe4Mz31Dky5Nnpkz3ScFfzA7mMQQDqxqavlZPNfkyQFKPhX8d54ia4DxXhOOq9Twdb2DNuqRD15Oa2ZtQ== X-YMail-OSG: 1vncQlEVM1mwNJJN4xly8JjHa1N7s.CZOssh.079W6vWIuVlUnh4JcMz1FShKYF 2j1sFM5Mq.m4_dqj0W4RWU1IlyjwI2GGo86D2k1F2PqmnB5PNwlU6gAIKkKCyPVYezQlFjW0dZpH XovyhmGGJI2eONoFysHhy0B1hkEQm64RwVKk5puhwsOFddlRwR.x44LnbGf3jm0YlQvyVoqmQuaQ fQgWbJnizLFKhdbvuy.v8FcSPsWwM5QloCG_00L6C0z6A479mxyQ0OfsiPpPShEoD2SKwsPwuTv3 r6au315HIQvZpyrTUNMIUE3bra7SA0OYDwMwBiw7i_IHYUNmMZ74sxrYoOh4SmQyHXE0KumZEt7N z67jFr63Q.UDsKD1KzQTv3lhzB2HO9vjCLZ0v1ZAzfOShpuvUMn8kptrWr..QIbN2Qfc259fJKfc vaqxu9fk1eIIa5wH.Vk5e9BvURY7._2ZLYLTZVyLFknZ4_H9vRnb7WdCpUEDbNfpX4Oo4f9oiTwn HGQnkd9Ldz21BaLxCvwrhWHgd4CpxLOvLWC6e6YyZ9_ROhVwKpxAsqKvdijYRBrD9gMrAdbxSt3U vdUnt5XGbbViObSW893bH.XIPCdCNbq9bV7RecmNLYx5XxKvj7tZtVezJ0_GvnBVK8zR6dYuF_Hn lvXklUd.Dn.8ARXP.TD_UIsEa4G4vLJoaYUl12k7b9FslihCuRoZVJ5oaRlWsEljxY01QGydyQix Wr6xKsulRUblydQUMbfhxlCS2I.AEiCeMsrz3cDUPs544GNact23TF2JmSprQuDcV8h154RD8MMr OTCFWQWH97b6tVl.eGRrmb1a5iLkPZy6n0JIzkVL_gEigizkc32n091.VcAoK37KWHpZnq6S7psN faLQxXzIjK4xIU3DAG8cEVgFpiLLJ3vieAAoY6h3O_0HZjk.j9N5yJwUtIghc.amcVrLH87pbR5o aa_WDJ9J__ssIhR_A.iJUzJoO_5R90jUP2kXIx8AEIVvOkzRoHE2zAcdJn_5xG4RJJ_HBuI3ZFSB oU7QgstVWt625qMB6MENASsGWRHknbd1tf3lumGYLA93sEsOTfvGvUi0JHtymAlWmTrFI_i6anJl cB.uJ90hrbJoDInRQ4pg4OsfmMk_VodvlyhHPKU2QFttxhiN7C_evPIXrz8XbCUtgETndVV2IDpx iUlWbYuHAzo3m85C9h6w9KH9L8IDDKjuLJO2HNEToXRW5og7bxU20QoPUFHP68UMvBV7qYrbzFDG QS7azrsI._DO2SVEq0K_JwSKY2dcElskakfUis.cOtDt.gOOESBWiIjzn_gEbEK8LtVTGo4c1b2Z 1chTCwiL0gzVQb1EpvAFmeIvb9xNC0V5GRWPYLL.ukf0bOccPob5C9SlEELe5XdfgX_oS4EVxvvn fmCAX01RxXhlrUeQQKE2N5ivWPrZsCmZaB.7geDC4ntbjbaiNnzloQROSuzHW2L15.1FtUVtNFdO stgPZUxUklPwgqlNkKlv_5Z61gJWV1IS9ISm__uBOo4appgfpCMFHNfNtpL7FF2IAorZy7VbeuRU 9BLWEJetEen3kfhps.pdBhP3bgr_bzjeVlRlDidFVEn1vftsoj4kQVPEAuygaIzqbz0KbDxKyvjx XFlHTakF_5KcJqSHfFtls3Su7M3ryrOzh6gFqkgTMs.aBMEVYTKwlDoiUX0Ri85LvPsBbLx88yFj 8yFgf1RnWoNHVVHFpECSebJYjiNbGe1c9G3H0zwap4KvrJpJDhowfIU_0Vjh0CO61gQUN477PH9V 8FgSol1.lyZt0Oz7OpZrYefJhacnh_FZMeEIQoSJppwc.LX.p8onQf4m9wP5p39tRHHCG7hv98cC J_fglpIyx8o7.YCuqCbfR7Ki4RCBTGFVf8.0UTJwp9ZlqrmqKNLcAat74ER0PlEj09PoCjZyFj6M RK04GSHclrl6kZhTvz7y5jh.HHumoo_ldx4BsErrl72bpt7w.ZGsb5jAr4DHtm3aYecn6gYtd6I3 WkYRx_ztOXjFHPuK5ZNcNcX4bZ.aJQuo9AMDSMoE3It5S5dL_tUcuNBezg0_3JkYUor0hKyEKkL8 PqBy92x972yhODUqfq54ooxarL7n1.H.HIYFxVAAjS3lb5HePDZXVOEmHPuEA8zKDMOzbwl9hP3P 4QvFuG9UcMn.tfSzbNWH4pG6pWsC6NGF4.2nS8dDIzgO1LdGFxTvbP7mrFDFFN0S08iLN6NinHKb mBxCOPSHEqX0EILCwMB6N2Pkso0kGG.Zq5cZRgmhDUhSoEPY.1X2g.NtHgUn0bCjz3z8E9HCsTxR kYieU8jopdhm6k15jd04T14N_FeC_f1MiIgSysZMIiitxC4U- X-Sonic-MF: X-Sonic-ID: d3a48a56-e81f-42eb-8e1a-f03eb75e1ece Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.ne1.yahoo.com with HTTP; Thu, 3 Dec 2026 02:18:21 +0000 Received: by hermes--production-ir2-7c4859dc89-4b5bc (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID d865ca6b4bfcf749f41f974a32a8a893; Thu, 03 Dec 2026 02:18:19 +0000 (UTC) Message-ID: <35e8bbdc-dac6-4f34-aae4-6068f938269b@yahoo.com> Date: Thu, 3 Dec 2026 03:18:15 +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 v19 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: <59c7992d-1c83-4bf1-a2f4-c853d4777190@yahoo.com> Content-Language: pl In-Reply-To: <59c7992d-1c83-4bf1-a2f4-c853d4777190@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 | 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 734309e..b3fc6fb 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