net: dsa: yt921x: Add support for Motorcomm YT921x
Subsystems (5)
David Yang
maintainerv4 cover net: dsa: yt921x: Add support for Motorcomm YT921x
Motorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:
- YT9215S / YT9215RB / YT9215SC: 5 GbE phys
- YT9213NB / YT9214NB: 2 GbE phys
- YT9218N / YT9218MB: 8 GbE phys
and up to 2 serdes interfaces.
This patch adds basic support for a working DSA switch.
v3: https://lore.kernel.org/r/[email protected]
- fix words and warnings in dt binding
- remove unnecessary dev_warn_ratelimited and u64_from_u32
- remove lag and mst
- check for mdio results and fix a unlocked write in conduit_state_change
v2: https://lore.kernel.org/r/[email protected]
- fix words in dt binding
- add support for lag and mst
v1: https://lore.kernel.org/r/[email protected]
- fix coding style
- add dt binding
- add support for fdb, vlan and bridge
David Yang (3):
dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
net: dsa: yt921x: Add support for Motorcomm YT921x
.../bindings/net/dsa/motorcomm,yt921x.yaml | 162 + drivers/net/dsa/Kconfig | 7 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/yt921x.c | 3584 +++++++++++++++++ include/net/dsa.h | 2 + net/dsa/Kconfig | 6 + net/dsa/Makefile | 1 + net/dsa/tag_yt921x.c | 128 + 8 files changed, 3891 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml create mode 100644 drivers/net/dsa/yt921x.c create mode 100644 net/dsa/tag_yt921x.c
Signature · 1 line
2.50.1
David Yang
maintainerPATCH v4 1/3 dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
The Motorcomm YT921x series is a family of Ethernet switches with up to 8 internal GbE PHYs and up to 2 GMACs.
--- .../bindings/net/dsa/motorcomm,yt921x.yaml | 162 ++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +162 -0
@@ -0,0 +1,162 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/motorcomm,yt921x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Motorcomm YT921x Ethernet switch family + +maintainers: + - David Yang <[email protected]> + +description: | + The Motorcomm YT921x series is a family of Ethernet switches with up to 8 + internal GbE PHYs and up to 2 GMACs, including: + + - YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs (Port 0-4) + 2 GMACs (Port 8-9) + - YT9213NB: 2 GbE PHYs (Port 1/3) + 1 GMAC (Port 9) + - YT9214NB: 2 GbE PHYs (Port 1/3) + 2 GMACs (Port 8-9) + - YT9218N: 8 GbE PHYs (Port 0-7) + - YT9218MB: 8 GbE PHYs (Port 0-7) + 2 GMACs (Port 8-9) + + Any port can be used as the CPU port. + +properties: + compatible: + const: motorcomm,yt9215 + + reg: + maxItems: 1 + + reset-gpios: + maxItems: 1 + + motorcomm,switch-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Value selected by Pin SWITCH_ID_1 / SWITCH_ID_0. + + Up to 4 chips can share the same MII port ('reg' in DT) by giving + different SWITCH_ID values. The default value should work if only one chip + is present. + enum: [0, 1, 2, 3] + default: 0 + + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: | + Internal MDIO bus for the internal GbE PHYs. PHYs 0-7 are used for Port + 0-7 respectively. + + mdio-external: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + description: | + External MDIO bus to access external components. External PHYs for GMACs + (Port 8-9) are expected to be connected to the external MDIO bus in + vendor's reference design, but that is not a hard limitation from the + chip. + +allOf: + - $ref: dsa.yaml#/$defs/ethernet-ports + +required: + - compatible + - reg + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + switch@1d { + compatible = "motorcomm,yt9215"; + /* default 0x1d, alternate 0x0 */ + reg = <0x1d>; + motorcomm,switch-id = <0>; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + sw_phy0: phy@0 { + reg = <0x0>; + }; + }; + + mdio-external { + #address-cells = <1>; + #size-cells = <0>; + + phy1: phy@b { + reg = <0xb>; + }; + }; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + /* phy-handle is optional for internal PHYs */ + port@0 { + reg = <0>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&sw_phy0>; + }; + + port@1 { + reg = <1>; + label = "lan2"; + phy-mode = "internal"; + }; + + port@2 { + reg = <2>; + label = "lan3"; + phy-mode = "internal"; + }; + + port@3 { + reg = <3>; + label = "lan4"; + phy-mode = "internal"; + }; + + port@4 { + reg = <4>; + label = "lan5"; + phy-mode = "internal"; + }; + + /* CPU port */ + port@8 { + reg = <8>; + phy-mode = "sgmii"; + ethernet = <ð0>; + + fixed-link { + speed = <1000>; + full-duplex; + pause; + asym-pause; + }; + }; + + /* if external phy is connected to a MAC */ + port@9 { + reg = <9>; + label = "wan"; + phy-mode = "rgmii"; + phy-handle = <&phy1>; + }; + }; + }; + };
Signature · 1 line
2.50.1
Andrew Lunn
maintainerRe: [net-next v4 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +10
-0+ motorcomm,switch-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Value selected by Pin SWITCH_ID_1 / SWITCH_ID_0. + + Up to 4 chips can share the same MII port ('reg' in DT) by giving + different SWITCH_ID values. The default value should work if only one chip + is present. + enum: [0, 1, 2, 3] + default: 0
It is like getting blood from a stone.
So what you are saying is that you have:
mdio {
#address-cells = <1>;
#size-cells = <0>;
switch@1d {
compatible = "motorcomm,yt9215";
/* default 0x1d, alternate 0x0 */
reg = <0x1d>;
motorcomm,switch-id = <0>;
reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
...
}
switch@1d {
compatible = "motorcomm,yt9215";
reg = <0x1d>;
motorcomm,switch-id = <1>;
reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
...
}
switch@1d {
compatible = "motorcomm,yt9215";
reg = <0x1d>;
motorcomm,switch-id = <2>;
reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>;
...
}
}Have you tested this? My _guess_ is, it does not work.
I'm not even sure DT allows you to have the same reg multiple times on one bus.
I'm pretty sure the MDIO core does not allow multiple devices on one MDIO address. Each device is represented by a struct mdio_device. struct mii_bus has an array of 32 of these, one per address on the bus. You cannot have 4 of them for one address.
Andrew
---
pw-bot: cr
Yangfl
maintainerRe: [net-next v4 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
Quoted 56 lines · Andrew Lunn
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 43
Quoted 11 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +10
-0+ motorcomm,switch-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Value selected by Pin SWITCH_ID_1 / SWITCH_ID_0. + + Up to 4 chips can share the same MII port ('reg' in DT) by giving + different SWITCH_ID values. The default value should work if only one chip + is present. + enum: [0, 1, 2, 3] + default: 0It is like getting blood from a stone.
So what you are saying is that you have:
mdio { #address-cells = <1>; #size-cells = <0>; switch@1d { compatible = "motorcomm,yt9215"; /* default 0x1d, alternate 0x0 */ reg = <0x1d>; motorcomm,switch-id = <0>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } switch@1d { compatible = "motorcomm,yt9215"; reg = <0x1d>; motorcomm,switch-id = <1>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } switch@1d { compatible = "motorcomm,yt9215"; reg = <0x1d>; motorcomm,switch-id = <2>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } }Have you tested this? My _guess_ is, it does not work.
I'm not even sure DT allows you to have the same reg multiple times on one bus.
I'm pretty sure the MDIO core does not allow multiple devices on one MDIO address. Each device is represented by a struct
mdio_device. structmii_bushas an array of 32 of these, one per address on the bus. You cannot have 4 of them for one address.
Quoted 4 lines
Andrew
---
pw-bot: cr
Of course I cannot test this, since I only have a stock device, as mentioned in patch 3.
But I think this is what the vendor wants to do, if I got it right from the datasheet.
If this is not acceptable anyway, I might as well remove switch-id completely since I doubt if anyone would concat more than one switch together in real world.
Andrew Lunn
maintainerRe: [net-next v4 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
Quoted 57 lines · Yangfl
Quoted 56 lines · Andrew Lunn
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 43
Quoted 11 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +10
-0+ motorcomm,switch-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Value selected by Pin SWITCH_ID_1 / SWITCH_ID_0. + + Up to 4 chips can share the same MII port ('reg' in DT) by giving + different SWITCH_ID values. The default value should work if only one chip + is present. + enum: [0, 1, 2, 3] + default: 0It is like getting blood from a stone.
So what you are saying is that you have:
mdio { #address-cells = <1>; #size-cells = <0>; switch@1d { compatible = "motorcomm,yt9215"; /* default 0x1d, alternate 0x0 */ reg = <0x1d>; motorcomm,switch-id = <0>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } switch@1d { compatible = "motorcomm,yt9215"; reg = <0x1d>; motorcomm,switch-id = <1>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } switch@1d { compatible = "motorcomm,yt9215"; reg = <0x1d>; motorcomm,switch-id = <2>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } }Have you tested this? My _guess_ is, it does not work.
I'm not even sure DT allows you to have the same reg multiple times on one bus.
I'm pretty sure the MDIO core does not allow multiple devices on one MDIO address. Each device is represented by a struct
mdio_device. structmii_bushas an array of 32 of these, one per address on the bus. You cannot have 4 of them for one address.
Quoted 7 lines
Quoted 4 lines
Andrew
---
pw-bot: crOf course I cannot test this, since I only have a stock device, as mentioned in patch 3.
You could create such a DT and see if it compiles and passes the binding tests. You could boot such a DT. You should get -ENODEV for the other two devices. But if it crashes, that tells you something... Looking at the stack trace might confirm this is never going to work with the current MDIO core code.
Quoted 3 lines
If this is not acceptable anyway, I might as well remove switch-id completely since I doubt if anyone would concat more than one switch together in real world.
I have a board with 4 Marvell switches. It does happen, especially in industrial systems. But they have individual addresses on the MDIO bus. I also have a SOHO black box switch, using two qualcomm switches in order to support 16 ports.
But i do agree you are unlikely to see a WiFi AP, or a cable modem use two switches.
Andrew
Re: [net-next v4 1/3] dt-bindings: net: dsa: yt921x: Add Motorcomm YT921x switch support
In reply to Andrew LunnQuoted 45 lines · Andrew Lunn
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml new file +10
-0+ motorcomm,switch-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Value selected by Pin SWITCH_ID_1 / SWITCH_ID_0. + + Up to 4 chips can share the same MII port ('reg' in DT) by giving + different SWITCH_ID values. The default value should work if only one chip + is present. + enum: [0, 1, 2, 3] + default: 0It is like getting blood from a stone.
So what you are saying is that you have:
mdio { #address-cells = <1>; #size-cells = <0>; switch@1d { compatible = "motorcomm,yt9215"; /* default 0x1d, alternate 0x0 */ reg = <0x1d>; motorcomm,switch-id = <0>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } switch@1d { compatible = "motorcomm,yt9215"; reg = <0x1d>; motorcomm,switch-id = <1>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } switch@1d { compatible = "motorcomm,yt9215"; reg = <0x1d>; motorcomm,switch-id = <2>; reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; ... } }
Quoted 1 line
Have you tested this? My _guess_ is, it does not work.
Regardless if kernel actually works with this, but duplicating unit address is not supported, so this obviously would be wrong. I guess that's the answer for switch-id.
Best regards,
Krzysztof
David Yang
maintainerPATCH v4 2/3 net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
In reply to David YangAdd support for Motorcomm YT921x tags, which includes a proper configurable ethertype field (default to 0x9988).
--- include/net/dsa.h | 2 + net/dsa/Kconfig | 6 ++ net/dsa/Makefile | 1 + net/dsa/tag_yt921x.c | 128 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 net/dsa/tag_yt921x.c
include/net/dsa.h +2 -0
@@ -55,6 +55,7 @@ struct tc_action;#define DSA_TAG_PROTO_LAN937X_VALUE 27#define DSA_TAG_PROTO_VSC73XX_8021Q_VALUE 28#define DSA_TAG_PROTO_BRCM_LEGACY_FCS_VALUE 29 +#define DSA_TAG_PROTO_YT921X_VALUE 30enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -87,6 +88,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_RZN1_A5PSW =DSA_TAG_PROTO_RZN1_A5PSW_VALUE ,DSA_TAG_PROTO_LAN937X =DSA_TAG_PROTO_LAN937X_VALUE ,DSA_TAG_PROTO_VSC73XX_8021Q =DSA_TAG_PROTO_VSC73XX_8021Q_VALUE , + DSA_TAG_PROTO_YT921X = DSA_TAG_PROTO_YT921X_VALUE, };struct dsa_switch ;
net/dsa/Kconfig +6 -0
@@ -190,4 +190,10 @@ config NET_DSA_TAG_XRS700X Say Y or M if you want to enable support for tagging frames for Arrow SpeedChips XRS700x switches that use a single byte tag trailer. +config NET_DSA_TAG_YT921X + tristate "Tag driver for Motorcomm YT921x switches" + help + Say Y or M if you want to enable support for tagging frames for + Motorcomm YT921x switches. + endif
net/dsa/Makefile +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o obj-$(CONFIG_NET_DSA_TAG_VSC73XX_8021Q) += tag_vsc73xx_8021q.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o +obj-$(CONFIG_NET_DSA_TAG_YT921X) += tag_yt921x.o # for tracing framework to find trace.h CFLAGS_trace.o := -I$(src)
net/dsa/tag_yt921x.c new file +128 -0
128 lines not on this page · raw message
Signature · 1 line
2.50.1
Andrew Lunn
maintainerRe: [net-next v4 2/3] net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
Quoted 16 lines
net/dsa/tag_yt921x.c new file +16
-0+static struct sk_buff * +yt921x_tag_xmit (struct sk_buff *skb,struct net_device *netdev) +{ +struct dsa_port *dp =dsa_user_to_port (netdev); +unsigned int port = dp->index; +struct dsa_port *partner; +__be16 *tag; +u16 tx; + +skb_push (skb,YT921X_TAG_LEN ); +dsa_alloc_etype_header (skb,YT921X_TAG_LEN ); + + tag =dsa_etype_header_pos_tx (skb); + +/* We might use yt921x_priv::tag_eth_p, but +* 1. CPU_TAG_TPID could be configured anyway;
net/dsa/tag_yt921x.c line 69
Quoted 10 lines
net/dsa/tag_yt921x.c new file +10
-0+* 2. Are you using the right chip? +*/ + tag[0 ] =htons (ETH_P_YT921X ); +/* Service VLAN tag not used */ + tag[1 ] =0 ; + tag[2 ] =0 ; + tx =YT921X_TAG_PORT_EN |YT921X_TAG_TX_PORTn (port); +if (dp->hsr_dev) +dsa_hsr_foreach_port (partner, dp->ds, dp->hsr_dev) + tx |= YT921X_TAG_TX_PORTn(partner->index);
As far as i remember, this was not in v1. When i spotting this in v2 that made me comment you should not add new features in revision of a patch.
Does the current version of the DSA driver support hsr? Is this useful? Maybe it would be better to add hsr support as a follow up patch?
Quoted 15 lines
net/dsa/tag_yt921x.c new file +15
-0+static struct sk_buff * +yt921x_tag_rcv (struct sk_buff *skb,struct net_device *netdev) +{ +unsigned int port; +__be16 *tag; +u16 rx; + +if (unlikely (!pskb_may_pull (skb,YT921X_TAG_LEN ))) +return NULL ; + + tag = (__be16 *)skb->data; + +/* Locate which port this is coming from */ + rx =ntohs (tag[1 ]); +if (unlikely ((rx &YT921X_TAG_PORT_EN ) ==0 )) {
net/dsa/tag_yt921x.c line 104
Quoted 10 lines
net/dsa/tag_yt921x.c new file +10
-0+netdev_err (netdev,"Unexpected rx tag 0x%04x\n" , rx); +return NULL ; + } + + port =FIELD_GET (YT921X_TAG_RX_PORT_M , rx); + skb->dev =dsa_conduit_find_user (netdev,0 , port); +if (unlikely (!skb->dev)) { +netdev_err (netdev,"Cannot locate rx port %u\n" , port); +return NULL ; + }
O.K. Stop. Think.
You changed the rate limiting to an unlimiting netdev_err().
What is the difference? Under what conditions would you want to use rate limiting? When would you not use rate limiting?
Please reply and explain why you made this change.
Andrew
Yangfl
maintainerRe: [net-next v4 2/3] net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
Quoted 32 lines · Andrew Lunn
Quoted 17 lines
net/dsa/tag_yt921x.c new file +16
-0+static struct sk_buff * +yt921x_tag_xmit (struct sk_buff *skb,struct net_device *netdev) +{ +struct dsa_port *dp =dsa_user_to_port (netdev); +unsigned int port = dp->index; +struct dsa_port *partner; +__be16 *tag; +u16 tx; + +skb_push (skb,YT921X_TAG_LEN ); +dsa_alloc_etype_header (skb,YT921X_TAG_LEN ); + + tag =dsa_etype_header_pos_tx (skb); + +/* We might use yt921x_priv::tag_eth_p, but +* 1. CPU_TAG_TPID could be configured anyway; net/dsa/tag_yt921x.c line 69
Quoted 10 lines
net/dsa/tag_yt921x.c new file +10
-0+* 2. Are you using the right chip? +*/ + tag[0 ] =htons (ETH_P_YT921X ); +/* Service VLAN tag not used */ + tag[1 ] =0 ; + tag[2 ] =0 ; + tx =YT921X_TAG_PORT_EN |YT921X_TAG_TX_PORTn (port); +if (dp->hsr_dev) +dsa_hsr_foreach_port (partner, dp->ds, dp->hsr_dev) + tx |= YT921X_TAG_TX_PORTn(partner->index);As far as i remember, this was not in v1. When i spotting this in v2 that made me comment you should not add new features in revision of a patch.
Quoted 3 lines
Does the current version of the DSA driver support hsr? Is this useful? Maybe it would be better to add hsr support as a follow up patch?
Sorry, this was forgotten to undo.
Quoted 28 lines
Quoted 15 lines
net/dsa/tag_yt921x.c new file +15
-0+static struct sk_buff * +yt921x_tag_rcv (struct sk_buff *skb,struct net_device *netdev) +{ +unsigned int port; +__be16 *tag; +u16 rx; + +if (unlikely (!pskb_may_pull (skb,YT921X_TAG_LEN ))) +return NULL ; + + tag = (__be16 *)skb->data; + +/* Locate which port this is coming from */ + rx =ntohs (tag[1 ]); +if (unlikely ((rx &YT921X_TAG_PORT_EN ) ==0 )) {net/dsa/tag_yt921x.c line 104
Quoted 10 lines
net/dsa/tag_yt921x.c new file +10
-0+netdev_err (netdev,"Unexpected rx tag 0x%04x\n" , rx); +return NULL ; + } + + port =FIELD_GET (YT921X_TAG_RX_PORT_M , rx); + skb->dev =dsa_conduit_find_user (netdev,0 , port); +if (unlikely (!skb->dev)) { +netdev_err (netdev,"Cannot locate rx port %u\n" , port); +return NULL ; + }O.K. Stop. Think.
Quoted 8 lines
You changed the rate limiting to an unlimiting
netdev_err().What is the difference? Under what conditions would you want to use rate limiting? When would you not use rate limiting?
Please reply and explain why you made this change.
Andrew
I copied the limited version from tag_vsc73xx_8021q.
Under no conditions I expect either of them to appear: it is the case when I did my own tests; unless something really bad happens, like pouring a cup of coffee over your device.
I know rate limiting is a way to prevent flooding the same message over dmesg, but if an event never happens, I would consider two methods are exchangeable. Theoretically if an event never happens, no warnings would ever be needed, but I placed one here in case you destroy your device accidentally.
Thus if you think rate limiting is not appropriate here, I would fix it with another.
Andrew Lunn
maintainerRe: [net-next v4 2/3] net: dsa: tag_yt921x: add support for Motorcomm YT921x tags
Quoted 43 lines
Quoted 28 lines
Quoted 15 lines
net/dsa/tag_yt921x.c new file +15
-0+static struct sk_buff * +yt921x_tag_rcv (struct sk_buff *skb,struct net_device *netdev) +{ +unsigned int port; +__be16 *tag; +u16 rx; + +if (unlikely (!pskb_may_pull (skb,YT921X_TAG_LEN ))) +return NULL ; + + tag = (__be16 *)skb->data; + +/* Locate which port this is coming from */ + rx =ntohs (tag[1 ]); +if (unlikely ((rx &YT921X_TAG_PORT_EN ) ==0 )) {net/dsa/tag_yt921x.c line 104
Quoted 10 lines
net/dsa/tag_yt921x.c new file +10
-0+netdev_err (netdev,"Unexpected rx tag 0x%04x\n" , rx); +return NULL ; + } + + port =FIELD_GET (YT921X_TAG_RX_PORT_M , rx); + skb->dev =dsa_conduit_find_user (netdev,0 , port); +if (unlikely (!skb->dev)) { +netdev_err (netdev,"Cannot locate rx port %u\n" , port); +return NULL ; + }O.K. Stop. Think.
Quoted 8 lines
You changed the rate limiting to an unlimiting
netdev_err().What is the difference? Under what conditions would you want to use rate limiting? When would you not use rate limiting?
Please reply and explain why you made this change.
Andrew
I copied the limited version from
tag_vsc73xx_8021q.Under no conditions I expect either of them to appear: it is the case when I did my own tests; unless something really bad happens, like pouring a cup of coffee over your device.
Quoted 8 lines
I know rate limiting is a way to prevent flooding the same message over dmesg, but if an event never happens, I would consider two methods are exchangeable. Theoretically if an event never happens, no warnings would ever be needed, but I placed one here in case you destroy your device accidentally.
Thus if you think rate limiting is not appropriate here, I would fix it with another.
My thinking is, every single packet come through here. That could be 100,000 packets per second. We have no control over these packets, they are from other hosts, they can contain anything, included specially crafted packets, ping of death packets, etc. If there is a way to trigger these prints, and they print 100,000 times per second, it makes a good DoS. The box is completely useless. With rate limiting, the box keeps working, there is no DoS, but you get to see the error messages.
The basic networking philosophy is that anything per packet related which could cause a print should be rate limited.
Andrew
David Yang
maintainerPATCH v4 3/3 net: dsa: yt921x: Add support for Motorcomm YT921x
In reply to David YangMotorcomm YT921x is a series of ethernet switches developed by Shanghai Motorcomm Electronic Technology, including:
- YT9215S / YT9215RB / YT9215SC: 5 GbE PHYs
- YT9213NB / YT9214NB: 2 GbE PHYs
- YT9218N / YT9218MB: 8 GbE PHYs
and up to 2 GMACs.
Driver verified on a stock wireless router with IPQ5018 + YT9215S.
--- drivers/net/dsa/Kconfig | 7 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/yt921x.c | 3584 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 3592 insertions(+) create mode 100644 drivers/net/dsa/yt921x.c
drivers/net/dsa/Kconfig +7 -0
@@ -152,4 +152,11 @@ config NET_DSA_VITESSE_VSC73XX_PLATFORM This enables support for the Vitesse VSC7385, VSC7388, VSC7395 and VSC7398 SparX integrated ethernet switches, connected over a CPU-attached address bus and work in memory-mapped I/O mode. + +config NET_DSA_YT921X + tristate "Motorcomm YT9215 ethernet switch chip support" + select NET_DSA_TAG_YT921X + help + This enables support for the Motorcomm YT9215 ethernet switch + chip. endmenu
drivers/net/dsa/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX) += vitesse-vsc73xx-core.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_PLATFORM) += vitesse-vsc73xx-platform.o obj-$(CONFIG_NET_DSA_VITESSE_VSC73XX_SPI) += vitesse-vsc73xx-spi.o +obj-$(CONFIG_NET_DSA_YT921X) += yt921x.o obj-y += b53/ obj-y += hirschmann/ obj-y += microchip/
drivers/net/dsa/yt921x.c new file +3584 -0
2,982 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.50.1
Part of the diff is not shown here. View the raw message.