net: dsa: yt921x: Add DCB/QoS support
David Yang
maintainerv6 cover net: dsa: yt921x: Add DCB/QoS support
This series add DCB/QoS support to the driver.
v5: https://lore.kernel.org/r/[email protected]
- fix xmit priority for tag driver
v4: https://lore.kernel.org/r/[email protected]
- change the color for DEI bit and add a comment for it
v3: https://lore.kernel.org/r/[email protected]
- fix port_del_dscp_prio()
- split yt921x_chip_setup()
v2: https://lore.kernel.org/r/[email protected]
- make DCB support optional
- refine with enum yt921x_app_selector
- add missing dscp_prio_mapping_is_global
- fix pcp support
v1: https://lore.kernel.org/r/[email protected]
- rebase
David Yang (5):
net: dsa: tag_yt921x: clarify priority and code fields
net: dsa: tag_yt921x: add priority support
net: dsa: yt921x: Refactor VLAN awareness setting
net: dsa: yt921x: Refactor yt921x_chip_setup()
net: dsa: yt921x: Add DCB/QoS support
drivers/net/dsa/Kconfig | 1 + drivers/net/dsa/yt921x.c | 310 ++++++++++++++++++++++++++++++++++++--- drivers/net/dsa/yt921x.h | 55 +++++-- net/dsa/tag_yt921x.c | 89 +++++++---- 4 files changed, 393 insertions(+), 62 deletions(-)
Signature · 1 line
2.51.0
David Yang
maintainerPATCH v6 1/5 net: dsa: tag_yt921x: clarify priority and code fields
Packet priority is part of the tag, and the priority and code fields are used by tx and rx. Make revisions to reflect the facts.
--- net/dsa/tag_yt921x.c | 83 ++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 30 deletions(-)
net/dsa/tag_yt921x.c +53 -30
@@ -14,11 +14,14 @@* are conflicts somewhere and/or you want to change it for some reason. * Tag: * 2: VLAN Tag -* 2: Rx Port +* 2: * 15b: Rx Port Valid * 14b-11b: Rx Port -* 10b-0b: Cmd? -* 2: Tx Port(s) +* 10b-8b: Tx/Rx Priority +* 7b: Tx/Rx Code Valid +* 6b-1b: Tx/Rx Code +* 0b: ? (unset) +* 2: * 15b: Tx Port(s) Valid * 10b-0b: Tx Port(s) Mask */
@@ -33,18 +36,30 @@#define YT921X_TAG_PORT_EN BIT(15)#define YT921X_TAG_RX_PORT_M GENMASK(14, 11) -#define YT921X_TAG_RX_CMD_M GENMASK(10, 0) -#define YT921X_TAG_RX_CMD (x) FIELD_PREP(YT921X_TAG_RX_CMD_M, (x)) -#define YT921X_TAG_RX_CMD_FORWARDED 0x80 -#define YT921X_TAG_RX_CMD_UNK_UCAST 0xb2 -#define YT921X_TAG_RX_CMD_UNK_MCAST 0xb4 -#define YT921X_TAG_TX_PORTS GENMASK(10, 0) +#define YT921X_TAG_PRIO_M GENMASK(10, 8) +#define YT921X_TAG_PRIO (x) FIELD_PREP(YT921X_TAG_PRIO_M, (x)) +#define YT921X_TAG_CODE_EN BIT(7) +#define YT921X_TAG_CODE_M GENMASK(6, 1) +#define YT921X_TAG_CODE (x) FIELD_PREP(YT921X_TAG_CODE_M, (x)) +#define YT921X_TAG_TX_PORTS_M GENMASK(10, 0) +#define YT921X_TAG_TX_PORTS (x) FIELD_PREP(YT921X_TAG_TX_PORTS_M, (x)) + +/* Incomplete. Some are configurable via RMA_CTRL_CPU_CODE, the meaning of +* others remains unknown. +*/ +enum yt921x_tag_code { +YT921X_TAG_CODE_FORWARD =0 , +YT921X_TAG_CODE_UNK_UCAST =0x19 , +YT921X_TAG_CODE_UNK_MCAST =0x1a , +YT921X_TAG_CODE_PORT_COPY =0x1b , +YT921X_TAG_CODE_FDB_COPY =0x1c , +};static struct sk_buff *yt921x_tag_xmit (struct sk_buff *skb,struct net_device *netdev) {__be16 *tag; -u16 tx; +u16 ctrl;skb_push (skb,YT921X_TAG_LEN );dsa_alloc_etype_header (skb,YT921X_TAG_LEN );
@@ -55,9 +70,9 @@ yt921x_tag_xmit(struct sk_buff *skb, struct net_device *netdev)/* VLAN tag unrelated when TX */ tag[1 ] =0 ; tag[2 ] =0 ; - tx =FIELD_PREP (YT921X_TAG_TX_PORTS ,dsa_xmit_port_mask (skb, netdev)) | -YT921X_TAG_PORT_EN ; - tag[3 ] =htons (tx); + ctrl =YT921X_TAG_TX_PORTS (dsa_xmit_port_mask (skb, netdev)) | +YT921X_TAG_PORT_EN ; + tag[3 ] =htons (ctrl);return skb; }
@@ -67,7 +82,6 @@ yt921x_tag_rcv(struct sk_buff *skb, struct net_device *netdev) {unsigned int port;__be16 *tag; -u16 cmd;u16 rx;if (unlikely (!pskb_may_pull (skb,YT921X_TAG_LEN )))
@@ -98,23 +112,32 @@ yt921x_tag_rcv(struct sk_buff *skb, struct net_device *netdev)return NULL ; } - cmd =FIELD_GET (YT921X_TAG_RX_CMD_M , rx); -switch (cmd) { -case YT921X_TAG_RX_CMD_FORWARDED : -/* Already forwarded by hardware */ -dsa_default_offload_fwd_mark (skb); -break ; -case YT921X_TAG_RX_CMD_UNK_UCAST : -case YT921X_TAG_RX_CMD_UNK_MCAST : -/* NOTE: hardware doesn't distinguish between TRAP (copy to CPU -* only) and COPY (forward and copy to CPU). In order to perform -* a soft switch, NEVER use COPY action in the switch driver. -*/ -break ; -default : +if (!(rx &YT921X_TAG_CODE_EN )) {dev_warn_ratelimited (&netdev->dev, -"Unexpected rx cmd 0x%02x\n" , cmd); -break ; +"Tag code not enabled in rx packet\n" ); + }else { +u16 code =FIELD_GET (YT921X_TAG_CODE_M , rx); + +switch (code) { +case YT921X_TAG_CODE_FORWARD : +case YT921X_TAG_CODE_PORT_COPY : +case YT921X_TAG_CODE_FDB_COPY : +/* Already forwarded by hardware */ +dsa_default_offload_fwd_mark (skb); +break ; +case YT921X_TAG_CODE_UNK_UCAST : +case YT921X_TAG_CODE_UNK_MCAST : +/* NOTE: hardware doesn't distinguish between TRAP (copy +* to CPU only) and COPY (forward and copy to CPU). In +* order to perform a soft switch, NEVER use COPY action +* in the switch driver. +*/ +break ; +default : +dev_warn_ratelimited (&netdev->dev, +"Unknown code 0x%02x\n" , code); +break ; + } }/* Remove YT921x tag and update checksum */
Signature · 1 line
2.51.0
David Yang
maintainerPATCH v6 2/5 net: dsa: tag_yt921x: add priority support
In reply to David YangRequired by DCB/QoS support of the switch driver, since the rx packets will have non-zero priorities.
--- net/dsa/tag_yt921x.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/dsa/tag_yt921x.c +5 -1
@@ -69,7 +69,9 @@ yt921x_tag_xmit(struct sk_buff *skb, struct net_device *netdev) tag[0 ] =htons (ETH_P_YT921X );/* VLAN tag unrelated when TX */ tag[1 ] =0 ; - tag[2 ] =0 ; + ctrl =YT921X_TAG_CODE (YT921X_TAG_CODE_FORWARD ) |YT921X_TAG_CODE_EN | +YT921X_TAG_PRIO (skb->priority); + tag[2 ] =htons (ctrl); ctrl =YT921X_TAG_TX_PORTS (dsa_xmit_port_mask (skb, netdev)) |YT921X_TAG_PORT_EN ; tag[3 ] =htons (ctrl);
@@ -112,6 +114,8 @@ yt921x_tag_rcv(struct sk_buff *skb, struct net_device *netdev)return NULL ; } + skb->priority =FIELD_GET (YT921X_TAG_PRIO_M , rx); +if (!(rx &YT921X_TAG_CODE_EN )) {dev_warn_ratelimited (&netdev->dev,"Tag code not enabled in rx packet\n" );
Signature · 1 line
2.51.0
David Yang
maintainerPATCH v6 3/5 net: dsa: yt921x: Refactor VLAN awareness setting
In reply to David YangCreate a helper function to centralize the logic for enabling and disabling VLAN awareness on a port.
--- drivers/net/dsa/yt921x.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/net/dsa/yt921x.c +14 -10
@@ -1769,6 +1769,18 @@ yt921x_dsa_port_mdb_add(struct dsa_switch *ds, int port,return res; } +static int +yt921x_vlan_aware_set (struct yt921x_priv *priv,int port,bool vlan_aware) +{ +u32 ctrl; + +if (!vlan_aware) + ctrl =0 ; +else + ctrl =YT921X_PORT_IGR_TPIDn_CTAG (0 ); +return yt921x_reg_write (priv,YT921X_PORTn_IGR_TPID (port), ctrl); +} +static int yt921x_port_set_pvid (struct yt921x_priv *priv,int port,u16 vid) {
@@ -1818,14 +1830,7 @@ yt921x_vlan_filtering(struct yt921x_priv *priv, int port, bool vlan_filtering)if (res)return res; -/* Turn on / off VLAN awareness */ - mask = YT921X_PORT_IGR_TPIDn_CTAG_M; -if (!vlan_filtering) - ctrl =0 ; -else - ctrl =YT921X_PORT_IGR_TPIDn_CTAG (0 ); - res =yt921x_reg_update_bits (priv,YT921X_PORTn_IGR_TPID (port), - mask, ctrl); + res =yt921x_vlan_aware_set (priv, port, vlan_filtering);if (res)return res;
@@ -2022,8 +2027,7 @@ static int yt921x_userport_standalone(struct yt921x_priv *priv, int port)return res;/* Turn off VLAN awareness */ - mask = YT921X_PORT_IGR_TPIDn_CTAG_M; - res =yt921x_reg_clear_bits (priv,YT921X_PORTn_IGR_TPID (port), mask); + res =yt921x_vlan_aware_set (priv, port, false);if (res)return res;
Signature · 1 line
2.51.0
David Yang
maintainerPATCH v6 4/5 net: dsa: yt921x: Refactor yt921x_chip_setup()
In reply to David Yangyt921x_chip_setup() is already pretty long, and is going to become longer. Split it into parts.
--- drivers/net/dsa/yt921x.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/net/dsa/yt921x.c +24 -11
@@ -2903,7 +2903,7 @@ static int yt921x_chip_reset(struct yt921x_priv *priv)return 0 ; } -static int yt921x_chip_setup (struct yt921x_priv *priv) +static int yt921x_chip_setup_dsa (struct yt921x_priv *priv) {struct dsa_switch *ds = &priv->ds;unsigned long cpu_ports_mask;
@@ -2921,16 +2921,6 @@ static int yt921x_chip_setup(struct yt921x_priv *priv)if (res)return res; -/* Enable and clear MIB */ - res =yt921x_reg_set_bits (priv,YT921X_FUNC ,YT921X_FUNC_MIB ); -if (res) -return res; - - ctrl =YT921X_MIB_CTRL_CLEAN |YT921X_MIB_CTRL_ALL_PORT ; - res =yt921x_reg_write (priv,YT921X_MIB_CTRL , ctrl); -if (res) -return res; -/* Setup software switch */ ctrl =YT921X_CPU_COPY_TO_EXT_CPU ; res =yt921x_reg_write (priv,YT921X_CPU_COPY , ctrl);
@@ -2983,6 +2973,29 @@ static int yt921x_chip_setup(struct yt921x_priv *priv)if (res)return res; +return 0 ; +} + +static int yt921x_chip_setup (struct yt921x_priv *priv) +{ +u32 ctrl; +int res; + + ctrl =YT921X_FUNC_MIB ; + res =yt921x_reg_set_bits (priv,YT921X_FUNC , ctrl); +if (res) +return res; + + res =yt921x_chip_setup_dsa (priv); +if (res) +return res; + +/* Clear MIB */ + ctrl =YT921X_MIB_CTRL_CLEAN |YT921X_MIB_CTRL_ALL_PORT ; + res =yt921x_reg_write (priv,YT921X_MIB_CTRL , ctrl); +if (res) +return res; +/* Miscellaneous */ res =yt921x_reg_set_bits (priv,YT921X_SENSOR ,YT921X_SENSOR_TEMP );if (res)
Signature · 1 line
2.51.0
David Yang
maintainerPATCH v6 5/5 net: dsa: yt921x: Add DCB/QoS support
In reply to David YangSet up global DSCP/PCP priority mappings and add related DCB methods.
--- drivers/net/dsa/Kconfig | 1 + drivers/net/dsa/yt921x.c | 253 ++++++++++++++++++++++++++++++++++++++- drivers/net/dsa/yt921x.h | 55 +++++++-- 3 files changed, 298 insertions(+), 11 deletions(-)
drivers/net/dsa/Kconfig +1 -0
@@ -158,6 +158,7 @@ config NET_DSA_VITESSE_VSC73XX_PLATFORM config NET_DSA_YT921X tristate "Motorcomm YT9215 ethernet switch chip support" select NET_DSA_TAG_YT921X + select NET_IEEE8021Q_HELPERS if DCB help This enables support for the Motorcomm YT9215 ethernet switch chip.
drivers/net/dsa/yt921x.c +252 -1
320 lines not on this page · raw message
drivers/net/dsa/yt921x.h +45 -10
95 lines not on this page · raw message
Signature · 1 line
2.51.0
Vladimir Oltean
maintainerdrivers/net/dsa/yt921x.c yt921x_vlan_aware_set(struct yt921x_priv *priv, int port, bool vlan_aware) · line 1783
Quoted 7 lines · David Yang
drivers/net/dsa/yt921x.c +3
-0@@ -1774,8 +1778,11 @@ yt921x_vlan_aware_set(struct yt921x_priv *priv, int port, bool vlan_aware) {u32 ctrl; +/* Abuse SVLAN for PCP parsing without polluting the FDB - it just works +* despite YT921X_VLAN_CTRL_SVLAN_EN never being set +*/
Why "abuse" - what else does this setting affect? Does the port not remain VLAN-unaware w.r.t. filtering/forwarding destinations?
How is the unused YT921X_VLAN_CTRL_PRIO_EN field from VLAN table entries related to VLAN PCP parsing?
Quoted 6 lines
drivers/net/dsa/yt921x.c +1
-1if (!vlan_aware) - ctrl =0 ; + ctrl =YT921X_PORT_IGR_TPIDn_STAG (0 );else ctrl =YT921X_PORT_IGR_TPIDn_CTAG (0 );return yt921x_reg_write (priv,YT921X_PORTn_IGR_TPID (port), ctrl);
David Yang
maintainerQuoted 6 lines · Vladimir Oltean
Quoted 4 lines · David Yang
drivers/net/dsa/yt921x.c +0
-0@@ -1774,8 +1778,11 @@ yt921x_vlan_aware_set(struct yt921x_priv *priv, int port, bool vlan_aware) {u32 ctrl;
Quoted 7 lines
drivers/net/dsa/yt921x.c yt921x_vlan_aware_set(struct yt921x_priv *priv, int port, bool vlan_aware) · line 1783
Quoted 3 lines
drivers/net/dsa/yt921x.c +3
-0+/* Abuse SVLAN for PCP parsing without polluting the FDB - it just works +* despite YT921X_VLAN_CTRL_SVLAN_EN never being set +*/ Why "abuse" - what else does this setting affect? Does the port not remain VLAN-unaware w.r.t. filtering/forwarding destinations?
It does. Recognizing SVLAN without enabling SVLAN bit makes it ignore VLAN tag, but somehow except for PCP. I guess the manufacturer never expected such usage.
Quoted 3 lines
How is the unused
YT921X_VLAN_CTRL_PRIO_ENfield from VLAN table entries related to VLAN PCP parsing?
It's another appsel APP_SEL_VID, using priority in PRIO_M instead.
Quoted 24 lines · David Yang
This series add DCB/QoS support to the driver.
v5: https://lore.kernel.org/r/[email protected]
- fix xmit priority for tag driver
v4: https://lore.kernel.org/r/[email protected]
- change the color for DEI bit and add a comment for it
v3: https://lore.kernel.org/r/[email protected]
- fixport_del_dscp_prio()
- splityt921x_chip_setup()
v2: https://lore.kernel.org/r/[email protected]
- make DCB support optional
- refine with enumyt921x_app_selector
- add missingdscp_prio_mapping_is_global
- fix pcp support
v1: https://lore.kernel.org/r/[email protected]
- rebaseDavid Yang (5):
net: dsa:tag_yt921x: clarify priority and code fields
net: dsa:tag_yt921x: add priority support
net: dsa: yt921x: Refactor VLAN awareness setting
net: dsa: yt921x: Refactoryt921x_chip_setup()
net: dsa: yt921x: Add DCB/QoS support
Quoted 9 lines
drivers/net/dsa/Kconfig | 1 + drivers/net/dsa/yt921x.c | 310 ++++++++++++++++++++++++++++++++++++--- drivers/net/dsa/yt921x.h | 55 +++++-- net/dsa/tag_yt921x.c | 89 +++++++---- 4 files changed, 393 insertions(+), 62 deletions(-)Signature · 1 line
2.51.0
From the perspective of API use this appears fine.
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:
Quoted 17 lines · On Sat, 31 Jan 2026 10:18:46 +0800 you wrote:
This series add DCB/QoS support to the driver.
v5: https://lore.kernel.org/r/[email protected]
- fix xmit priority for tag driver
v4: https://lore.kernel.org/r/[email protected]
- change the color for DEI bit and add a comment for it
v3: https://lore.kernel.org/r/[email protected]
- fixport_del_dscp_prio()
- splityt921x_chip_setup()
v2: https://lore.kernel.org/r/[email protected]
- make DCB support optional
- refine with enumyt921x_app_selector
- add missingdscp_prio_mapping_is_global
- fix pcp support
v1: https://lore.kernel.org/r/[email protected]
- rebase
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v6,1/5] net: dsa: tag_yt921x: clarify priority and code fields
https://git.kernel.org/netdev/net-next/c/a63daf73a587 - [net-next,v6,2/5] net: dsa: tag_yt921x: add priority support https://git.kernel.org/netdev/net-next/c/8cdb2cc9a11b - [net-next,v6,3/5] net: dsa: yt921x: Refactor VLAN awareness setting https://git.kernel.org/netdev/net-next/c/75b85703fd48 - [net-next,v6,4/5] net: dsa: yt921x: Refactor yt921x_chip_setup() https://git.kernel.org/netdev/net-next/c/95e6bcab3c08 - [net-next,v6,5/5] net: dsa: yt921x: Add DCB/QoS support https://git.kernel.org/netdev/net-next/c/d5f778353fd4
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html