net: dsa: yt921x: Add DCB/QoS support
David Yang
maintainerv5 cover net: dsa: yt921x: Add DCB/QoS support
This series add DCB/QoS support to the 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 (4):
net: dsa: tag_yt921x: fix 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 | 8 +- 4 files changed, 341 insertions(+), 33 deletions(-)
Signature · 1 line
2.51.0
David Yang
maintainerPATCH v5 1/4 net: dsa: tag_yt921x: fix priority support
Packet priority is part of the rx tag. It defaults to 0, but adding DCB support to the switch driver will break the tag driver by setting it to non-zero.
--- net/dsa/tag_yt921x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/dsa/tag_yt921x.c +6 -2
@@ -17,7 +17,8 @@* 2: Rx Port * 15b: Rx Port Valid * 14b-11b: Rx Port -* 10b-0b: Cmd? +* 10b-8b: Priority +* 7b-0b: Cmd * 2: Tx Port(s) * 15b: Tx Port(s) Valid * 10b-0b: Tx Port(s) Mask
@@ -33,7 +34,8 @@#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_PRIO_M GENMASK(10, 8) +#define YT921X_TAG_RX_CMD_M GENMASK(7, 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
@@ -98,6 +100,8 @@ yt921x_tag_rcv(struct sk_buff *skb, struct net_device *netdev)return NULL ; } + skb->priority =FIELD_GET (YT921X_TAG_RX_PRIO_M , rx); + cmd =FIELD_GET (YT921X_TAG_RX_CMD_M , rx);switch (cmd) {case YT921X_TAG_RX_CMD_FORWARDED :
Signature · 1 line
2.51.0
David Yang
maintainerPATCH v5 2/4 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
@@ -1768,6 +1768,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) {
@@ -1817,14 +1829,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;
@@ -2021,8 +2026,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 v5 3/4 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
@@ -2902,7 +2902,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;
@@ -2920,16 +2920,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);
@@ -2982,6 +2972,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 v5 4/4 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