add support for Renesas RZ/N1 ethernet subsystem devices
Subsystems (6)
Clément Léger
maintainerv3 cover add support for Renesas RZ/N1 ethernet subsystem devices
The Renesas RZ/N1 SoCs features an ethernet subsystem which contains (most notably) a switch, two GMACs, and a MII converter [1]. This series adds support for the switch and the MII converter.
The MII converter present on this SoC has been represented as a PCS which sit between the MACs and the PHY. This PCS driver is probed from the device-tree since it requires to be configured. Indeed the MII converter also contains the registers that are handling the muxing of ports (Switch, MAC, HSR, RTOS, etc) internally to the SoC.
The switch driver is based on DSA and exposes 4 ports + 1 CPU management port. It include basic bridging support as well as FDB and statistics support.
This series needs commits bcfb459b25b8 and 542d5835e4f6 which are on the renesas-devel tree in order to enable generic power domain on RZ/N1.
-----
Changes in V3:
- PCS:
- Fixed reverse christmas tree declaration
- Remove spurious pr_err
- Use pm_runtime functions
- Tag driver:
- Remove packed attribute from the tag struct
- Fix comment about packet size
- Switch:
- Fix missing spin_unlock in fdb_dump in case of error
- Add static qualifier to dsa_switch_ops
- Add missing documentation for hclk and clk members of struct a5psw
- Changed types of fdb_entry to u16 to discard GCC note on char packed bitfields and add reserved field
- Added Reviewed-by tag from Florian Fainelli
Changes in V2:
- PCS:
- Fix Reverse Christmas tree declaration
- Removed stray newline
- Add PCS remove function and disable clocks in them
- Fix miic_validate function to return correct values
- Split PCS CONV_MODE definition
- Reordered phylink_pcs_ops in definition order
- Remove interface setting in miic_link_up
- Remove useless checks for invalid interface/speed and error prints
- Replace phylink_pcs_to_miic_port macro by a static function
- Add comment in miic_probe about platform_set_drvdata
- Bindings:
- Fix wrong path for mdio.yaml $ref
- Fix yamllint errors
- Tag driver:
- Squashed commit that added tag value with tag driver
- Add BUILD_BUG_ON for tag size
- Split control_data2 in 2 16bits values
- Switch:
- Use .phylink_get_caps instead of .phylink_validate and fill supported_interface correctly
- Use fixed size (ETH_GSTRING_LEN) string for stats and use memcpy
- Remove stats access locking since RTNL lock is used in upper layers
- Check for non C45 addresses in mdio_read/write and return -EOPNOTSUPP
- Add get_eth_mac_stats, get_eth_mac_ctrl_stat, get_rmon_stats
- Fix a few indentation problems
- Remove reset callback from MDIO bus operation
- Add phy/mac/rmon stats
- Add get_rmon_stat to dsa_ops
Clément Léger (12):
net: dsa: add support for ethtool get_rmon_stats()
net: dsa: add Renesas RZ/N1 switch tag driver
dt-bindings: net: pcs: add bindings for Renesas RZ/N1 MII converter
net: pcs: add Renesas MII converter driver
dt-bindings: net: dsa: add bindings for Renesas RZ/N1 Advanced 5 port
switch
net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver
net: dsa: rzn1-a5psw: add statistics support
net: dsa: rzn1-a5psw: add FDB support
ARM: dts: r9a06g032: describe MII converter
ARM: dts: r9a06g032: describe GMAC2
ARM: dts: r9a06g032: describe switch
MAINTAINERS: add Renesas RZ/N1 switch related driver entry
.../bindings/net/dsa/renesas,rzn1-a5psw.yaml | 132 ++ .../bindings/net/pcs/renesas,rzn1-miic.yaml | 162 +++ MAINTAINERS | 11 + arch/arm/boot/dts/r9a06g032.dtsi | 64 + drivers/net/dsa/Kconfig | 9 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/rzn1_a5psw.c | 1057 +++++++++++++++++ drivers/net/dsa/rzn1_a5psw.h | 260 ++++ drivers/net/pcs/Kconfig | 8 + drivers/net/pcs/Makefile | 1 + drivers/net/pcs/pcs-rzn1-miic.c | 502 ++++++++ include/dt-bindings/net/pcs-rzn1-miic.h | 33 + include/linux/pcs-rzn1-miic.h | 18 + include/net/dsa.h | 5 + net/dsa/Kconfig | 7 + net/dsa/Makefile | 1 + net/dsa/slave.c | 13 + net/dsa/tag_rzn1_a5psw.c | 114 ++ 18 files changed, 2398 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml create mode 100644 Documentation/devicetree/bindings/net/pcs/renesas,rzn1-miic.yaml create mode 100644 drivers/net/dsa/rzn1_a5psw.c create mode 100644 drivers/net/dsa/rzn1_a5psw.h create mode 100644 drivers/net/pcs/pcs-rzn1-miic.c create mode 100644 include/dt-bindings/net/pcs-rzn1-miic.h create mode 100644 include/linux/pcs-rzn1-miic.h create mode 100644 net/dsa/tag_rzn1_a5psw.c
Signature · 1 line
2.34.1
Clément Léger
maintainerPATCH v3 1/12 net: dsa: add support for ethtool get_rmon_stats()
Add support to allow dsa drivers to specify the .get_rmon_stats() operation.
--- include/net/dsa.h | 3 +++ net/dsa/slave.c | 13 +++++++++++++ 2 files changed, 16 insertions(+)
include/net/dsa.h +3 -0
@@ -873,6 +873,9 @@ struct dsa_switch_ops { struct ethtool_eth_mac_stats *mac_stats);void (*get_eth_ctrl_stats)(struct dsa_switch *ds,int port,struct ethtool_eth_ctrl_stats *ctrl_stats); +void (*get_rmon_stats)(struct dsa_switch *ds,int port, +struct ethtool_rmon_stats *rmon_stats, +const struct ethtool_rmon_hist_range **ranges);void (*get_stats64)(struct dsa_switch *ds,int port,struct rtnl_link_stats64 *s); void (*self_test)(struct dsa_switch *ds, int port,
net/dsa/slave.c +13 -0
@@ -1026,6 +1026,18 @@ dsa_slave_get_eth_ctrl_stats(struct net_device *dev, ds->ops->get_eth_ctrl_stats (ds, dp->index, ctrl_stats); } +static void +dsa_slave_get_rmon_stats (struct net_device *dev, +struct ethtool_rmon_stats *rmon_stats, +const struct ethtool_rmon_hist_range **ranges) +{ +struct dsa_port *dp =dsa_slave_to_port (dev); +struct dsa_switch *ds = dp->ds; + +if (ds->ops->get_rmon_stats) + ds->ops->get_rmon_stats (ds, dp->index, rmon_stats, ranges); +} +static void dsa_slave_net_selftest (struct net_device *ndev,struct ethtool_test *etest,u64 *buf) {
@@ -2105,6 +2117,7 @@ static const struct ethtool_ops dsa_slave_ethtool_ops = { .get_eth_phy_stats = dsa_slave_get_eth_phy_stats, .get_eth_mac_stats = dsa_slave_get_eth_mac_stats, .get_eth_ctrl_stats = dsa_slave_get_eth_ctrl_stats, + .get_rmon_stats = dsa_slave_get_rmon_stats, .set_wol = dsa_slave_set_wol, .get_wol = dsa_slave_get_wol, .set_eee = dsa_slave_set_eee,
Signature · 1 line
2.34.1
Re: [PATCH net-next v3 01/12] net: dsa: add support for ethtool get_rmon_stats()
Quoted 6 lines · Clément Léger
Add support to allow dsa drivers to specify the .get_rmon_stats() operation.
Reviewed-by Florian Fainelli <[email protected]>Signed-off-by Clément Léger <[email protected]>---
Clément Léger
maintainerPATCH v3 2/12 net: dsa: add Renesas RZ/N1 switch tag driver
In reply to Clément LégerThe switch that is present on the Renesas RZ/N1 SoC uses a specific VLAN value followed by 6 bytes which contains forwarding configuration.
--- include/net/dsa.h | 2 + net/dsa/Kconfig | 7 +++ net/dsa/Makefile | 1 + net/dsa/tag_rzn1_a5psw.c | 114 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 net/dsa/tag_rzn1_a5psw.c
include/net/dsa.h +2 -0
@@ -53,6 +53,7 @@ struct phylink_link_state;#define DSA_TAG_PROTO_SJA1110_VALUE 23#define DSA_TAG_PROTO_RTL8_4_VALUE 24#define DSA_TAG_PROTO_RTL8_4T_VALUE 25 +#define DSA_TAG_PROTO_RZN1_A5PSW_VALUE 26enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,
@@ -81,6 +82,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_SJA1110 =DSA_TAG_PROTO_SJA1110_VALUE ,DSA_TAG_PROTO_RTL8_4 =DSA_TAG_PROTO_RTL8_4_VALUE ,DSA_TAG_PROTO_RTL8_4T =DSA_TAG_PROTO_RTL8_4T_VALUE , + DSA_TAG_PROTO_RZN1_A5PSW = DSA_TAG_PROTO_RZN1_A5PSW_VALUE, };struct dsa_switch ;
net/dsa/Kconfig +7 -0
@@ -132,6 +132,13 @@ config NET_DSA_TAG_RTL8_4 Say Y or M if you want to enable support for tagging frames for Realtek switches with 8 byte protocol 4 tags, such as the Realtek RTL8365MB-VC. +config NET_DSA_TAG_RZN1_A5PSW + tristate "Tag driver for Renesas RZ/N1 A5PSW switch" + help + Say Y or M if you want to enable support for tagging frames for + Renesas RZ/N1 embedded switch that uses a 8 byte tag located after + destination MAC address. + config NET_DSA_TAG_LAN9303 tristate "Tag driver for SMSC/Microchip LAN9303 family of switches" help
net/dsa/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_NET_DSA_TAG_OCELOT_8021Q) += tag_ocelot_8021q.o obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o obj-$(CONFIG_NET_DSA_TAG_RTL4_A) += tag_rtl4_a.o obj-$(CONFIG_NET_DSA_TAG_RTL8_4) += tag_rtl8_4.o +obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.o obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.o
net/dsa/tag_rzn1_a5psw.c new file +114 -0
114 lines not on this page · raw message
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerRe: [PATCH net-next v3 02/12] net: dsa: add Renesas RZ/N1 switch tag driver
Quoted 37 lines · Clément Léger
The switch that is present on the Renesas RZ/N1 SoC uses a specific VLAN value followed by 6 bytes which contains forwarding configuration.
Signed-off-by Clément Léger <[email protected]>--- include/net/dsa.h | 2 + net/dsa/Kconfig | 7 +++ net/dsa/Makefile | 1 + net/dsa/tag_rzn1_a5psw.c | 114 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 net/dsa/tag_rzn1_a5psw.cinclude/net/dsa.h +2
-0@@ -53,6 +53,7 @@ struct phylink_link_state;#define DSA_TAG_PROTO_SJA1110_VALUE 23#define DSA_TAG_PROTO_RTL8_4_VALUE 24#define DSA_TAG_PROTO_RTL8_4T_VALUE 25 +#define DSA_TAG_PROTO_RZN1_A5PSW_VALUE 26enum dsa_tag_protocol {DSA_TAG_PROTO_NONE =DSA_TAG_PROTO_NONE_VALUE ,@@ -81,6 +82,7 @@ enum dsa_tag_protocol {DSA_TAG_PROTO_SJA1110 =DSA_TAG_PROTO_SJA1110_VALUE ,DSA_TAG_PROTO_RTL8_4 =DSA_TAG_PROTO_RTL8_4_VALUE ,DSA_TAG_PROTO_RTL8_4T =DSA_TAG_PROTO_RTL8_4T_VALUE , + DSA_TAG_PROTO_RZN1_A5PSW = DSA_TAG_PROTO_RZN1_A5PSW_VALUE, };struct dsa_switch ;net/dsa/Kconfig +0
-0
net/dsa/Kconfig config NET_DSA_TAG_RTL8_4 · line 139
Quoted 8 lines
net/dsa/Kconfig +5
-0@@ -132,6 +132,13 @@ config NET_DSA_TAG_RTL8_4 Say Y or M if you want to enable support for tagging frames for Realtek switches with 8 byte protocol 4 tags, such as the Realtek RTL8365MB-VC. +config NET_DSA_TAG_RZN1_A5PSW + tristate "Tag driver for Renesas RZ/N1 A5PSW switch" + help + Say Y or M if you want to enable support for tagging frames for + Renesas RZ/N1 embedded switch that uses a 8 byte tag located after
"an" 8 byte tag
Quoted 37 lines
net/dsa/Kconfig +2
-0+ destination MAC address. + config NET_DSA_TAG_LAN9303 tristate "Tag driver for SMSC/Microchip LAN9303 family of switches" helpnet/dsa/Makefile +1
-0@@ -17,6 +17,7 @@ obj-$(CONFIG_NET_DSA_TAG_OCELOT_8021Q) += tag_ocelot_8021q.o obj-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o obj-$(CONFIG_NET_DSA_TAG_RTL4_A) += tag_rtl4_a.o obj-$(CONFIG_NET_DSA_TAG_RTL8_4) += tag_rtl8_4.o +obj-$(CONFIG_NET_DSA_TAG_RZN1_A5PSW) += tag_rzn1_a5psw.o obj-$(CONFIG_NET_DSA_TAG_SJA1105) += tag_sja1105.o obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o obj-$(CONFIG_NET_DSA_TAG_XRS700X) += tag_xrs700x.onet/dsa/tag_rzn1_a5psw.c new file +14
-0@@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (C) 2022 Schneider Electric +* +* Clément Léger <[email protected]> +*/ + +#include <linux/bitfield.h> +#include <linux/etherdevice.h> +#include <net/dsa.h> + +#include "dsa_priv.h" + +/* To define the outgoing port and to discover the incoming port a TAG is
net/dsa/tag_rzn1_a5psw.c line 24
Quoted 10 lines
net/dsa/tag_rzn1_a5psw.c new file +10
-0+* inserted after Src MAC : +* +* Dest MAC Src MAC TAG Type +* ...| 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 | 1 2 |... +* |<--------------->| +* +* See struct a5psw_tag for layout +*/ + +#define A5PSW_TAG_VALUE 0xE001
Maybe an ETH_P_DSA_A5PSW definition in include/uapi/linux/if_ether.h would be appropriate? I'm not sure.
Quoted 18 lines
net/dsa/tag_rzn1_a5psw.c new file +18
-0+#define A5PSW_TAG_LEN 8 +#define A5PSW_CTRL_DATA_FORCE_FORWARD BIT(0) +/* This is both used for xmit tag and rcv tagging */ +#define A5PSW_CTRL_DATA_PORT GENMASK(3, 0) + +struct a5psw_tag { +__be16 ctrl_tag; +__be16 ctrl_data; +__be16 ctrl_data2_hi; +__be16 ctrl_data2_lo; +}; + +static struct sk_buff *a5psw_tag_xmit (struct sk_buff *skb,struct net_device *dev) +{ +struct dsa_port *dp =dsa_slave_to_port (dev); +struct a5psw_tag *ptag; +u32 data2_val; +
net/dsa/tag_rzn1_a5psw.c line 52
Quoted 10 lines
net/dsa/tag_rzn1_a5psw.c new file +10
-0+BUILD_BUG_ON (sizeof (*ptag) !=A5PSW_TAG_LEN ); + +/* The Ethernet switch we are interfaced with needs packets to be at +* least 64 bytes (including FCS) otherwise they will be discarded when +* they enter the switch port logic. When tagging is enabled, we need +* to make sure that packets are at least 70 bytes (including FCS and +* tag). +*/ +if (__skb_put_padto (skb,ETH_ZLEN +ETH_FCS_LEN +A5PSW_TAG_LEN , false)) +return NULL ;
I'm confused by the inclusion of the FCS length in this calculation, since the FCS space isn't present in the skb buffer as far as I know?
"64 bytes including FCS" means "60 bytes excluding FCS". And ETH_ZLEN is 60...
And I'm also not sure how we got to the number 70? A5PSW_TAG_LEN is 8. If we add it to 60 we get 68. If we add it to 64 we get 72?
Quoted 65 lines
net/dsa/tag_rzn1_a5psw.c new file +62
-0+ +/* provide 'A5PSW_TAG_LEN' bytes additional space */ +skb_push (skb,A5PSW_TAG_LEN ); + +/* make room between MACs and Ether-Type to insert tag */ +dsa_alloc_etype_header (skb,A5PSW_TAG_LEN ); + + ptag =dsa_etype_header_pos_tx (skb); + + data2_val =FIELD_PREP (A5PSW_CTRL_DATA_PORT ,BIT (dp->index)); + ptag->ctrl_tag =htons (A5PSW_TAG_VALUE ); + ptag->ctrl_data =htons (A5PSW_CTRL_DATA_FORCE_FORWARD ); + ptag->ctrl_data2_lo =htons (data2_val); + ptag->ctrl_data2_hi =0 ; + +return skb; +} + +static struct sk_buff *a5psw_tag_rcv (struct sk_buff *skb, +struct net_device *dev) +{ +struct a5psw_tag *tag; +int port; + +if (unlikely (!pskb_may_pull (skb,A5PSW_TAG_LEN ))) { +dev_warn_ratelimited (&dev->dev, +"Dropping packet, cannot pull\n" ); +return NULL ; + } + + tag =dsa_etype_header_pos_rx (skb); + +if (tag->ctrl_tag !=htons (A5PSW_TAG_VALUE )) { +dev_warn_ratelimited (&dev->dev,"Dropping packet due to invalid TAG marker\n" ); +return NULL ; + } + + port =FIELD_GET (A5PSW_CTRL_DATA_PORT ,ntohs (tag->ctrl_data)); + + skb->dev =dsa_master_find_slave (dev,0 , port); +if (!skb->dev) +return NULL ; + +skb_pull_rcsum (skb,A5PSW_TAG_LEN ); +dsa_strip_etype_header (skb,A5PSW_TAG_LEN ); + +dsa_default_offload_fwd_mark (skb); + +return skb; +} + +static const struct dsa_device_ops a5psw_netdev_ops = { + .name ="a5psw" , + .proto =DSA_TAG_PROTO_RZN1_A5PSW , + .xmit = a5psw_tag_xmit, + .rcv = a5psw_tag_rcv, + .needed_headroom =A5PSW_TAG_LEN , +}; + +MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS_DSA_TAG_DRIVER (DSA_TAG_PROTO_A5PSW ); +module_dsa_tag_driver (a5psw_netdev_ops);Signature · 1 line
2.34.1
Clément Léger
maintainerRe: [PATCH net-next v3 02/12] net: dsa: add Renesas RZ/N1 switch tag driver
Quoted 6 lines · Vladimir Oltean
Quoted 6 lines
+/* To define the outgoing port and to discover the incoming port a TAG is
+ * inserted after Src MAC :
+ *
+ * Dest MAC Src MAC TAG Type+ * ...| 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 5 6 7 8 | 1 2 |... + * |<--------------->|
Quoted 8 lines
Review
Quoted 5 lines
+ *
+ * See structa5psw_tagfor layout
+ */(quoted diff) +2
-0+ +#define A5PSW_TAG_VALUE 0xE001Maybe an
ETH_P_DSA_A5PSWdefinition ininclude/uapi/linux/if_ether.hwould be appropriate? I'm not sure.
That's a good question. Actually, this value is the default but is configurable in the hardware so I'm not sure this should be a reserved value. Maybe it would make sense to add it anyway to have the define shared between the switch driver and the tag driver.
Quoted 24 lines
Quoted 24 lines
net/dsa/tag_rzn1_a5psw.c new file +23
-0+#define A5PSW_TAG_LEN 8 +#define A5PSW_CTRL_DATA_FORCE_FORWARD BIT(0) +/* This is both used for xmit tag and rcv tagging */ +#define A5PSW_CTRL_DATA_PORT GENMASK(3, 0) + +struct a5psw_tag { +__be16 ctrl_tag; +__be16 ctrl_data; +__be16 ctrl_data2_hi; +__be16 ctrl_data2_lo; +}; + +static struct sk_buff *a5psw_tag_xmit (struct sk_buff *skb,struct net_device *dev) +{ +struct dsa_port *dp =dsa_slave_to_port (dev); +struct a5psw_tag *ptag; +u32 data2_val; + +BUILD_BUG_ON (sizeof (*ptag) !=A5PSW_TAG_LEN ); + +/* The Ethernet switch we are interfaced with needs packets to be at +* least 64 bytes (including FCS) otherwise they will be discarded when +* they enter the switch port logic. When tagging is enabled, we need
Quoted 8 lines
net/dsa/tag_rzn1_a5psw.c line 52
Quoted 5 lines
net/dsa/tag_rzn1_a5psw.c new file +5
-0+* to make sure that packets are at least 70 bytes (including FCS and +* tag). +*/ +if (__skb_put_padto (skb,ETH_ZLEN +ETH_FCS_LEN +A5PSW_TAG_LEN , false)) +return NULL ;I'm confused by the inclusion of the FCS length in this calculation, since the FCS space isn't present in the skb buffer as far as I know?
I'm not sure either, the documentation is not really clear on what is the requirement for the minimal size of a packet. This was the closest thing I could find about that requirement:
"A frame has a valid length if it contains at least 64 octets and does not exceed the programmed maximum length"
And the figure associated to the frame show that the frame length includes the FCS which lead to a 64bytes frame.
Quoted 7 lines
"64 bytes including FCS" means "60 bytes excluding FCS". And
ETH_ZLENis 60...And I'm also not sure how we got to the number 70?
A5PSW_TAG_LENis 8. If we add it to 60 we get 68. If we add it to 64 we get 72?
I'll check all these numbers and find the correct size that is expected by the switch.
Signature · 3 lines
Clément Léger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com
Clément Léger
maintainerPATCH v3 3/12 dt-bindings: net: pcs: add bindings for Renesas RZ/N1 MII converter
In reply to Clément LégerThis MII converter can be found on the RZ/N1 processor family. The MII converter ports are declared as subnodes which are then referenced by users of the PCS driver such as the switch.
--- .../bindings/net/pcs/renesas,rzn1-miic.yaml | 162 ++++++++++++++++++ include/dt-bindings/net/pcs-rzn1-miic.h | 33 ++++ 2 files changed, 195 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/pcs/renesas,rzn1-miic.yaml create mode 100644 include/dt-bindings/net/pcs-rzn1-miic.h
Documentation/devicetree/bindings/net/pcs/renesas,rzn1-miic.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/pcs/renesas,rzn1-miic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RZ/N1 MII converter + +maintainers: + - Clément Léger <[email protected]> + +description: | + This MII converter is present on the Renesas RZ/N1 SoC family. It is + responsible to do MII passthrough or convert it to RMII/RGMII. + +properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + compatible: + items: + - enum: + - renesas,r9a06g032-miic + - const: renesas,rzn1-miic + + reg: + maxItems: 1 + + clocks: + items: + - description: MII reference clock + - description: RGMII reference clock + - description: RMII reference clock + - description: AHB clock used for the MII converter register interface + + renesas,miic-switch-portin: + description: MII Switch PORTIN configuration. This value should use one of + the values defined in dt-bindings/net/pcs-rzn1-miic.h. + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2] + + power-domains: + maxItems: 1 + +patternProperties: + "^mii-conv@[0-9]+$": + type: object + description: MII converter port + + properties: + reg: + description: MII Converter port number. + enum: [1, 2, 3, 4, 5] + + renesas,miic-input: + description: Converter input port configuration. This value should use + one of the values defined in dt-bindings/net/pcs-rzn1-miic.h. + $ref: /schemas/types.yaml#/definitions/uint32 + + required: + - reg + - renesas,miic-input + + additionalProperties: false + + allOf: + - if: + properties: + reg: + const: 1 + then: + properties: + renesas,miic-input: + enum: [0] + - if: + properties: + reg: + const: 2 + then: + properties: + renesas,miic-input: + enum: [1, 11] + - if: + properties: + reg: + const: 3 + then: + properties: + renesas,miic-input: + enum: [7, 10] + - if: + properties: + reg: + const: 4 + then: + properties: + renesas,miic-input: + enum: [4, 6, 9, 13] + - if: + properties: + reg: + const: 5 + then: + properties: + renesas,miic-input: + enum: [3, 5, 8, 12] + +required: + - '#address-cells' + - '#size-cells' + - compatible + - reg + - clocks + - power-domains + +additionalProperties: false + +examples: + - | + #include <dt-bindings/net/pcs-rzn1-miic.h> + #include <dt-bindings/clock/r9a06g032-sysctrl.h> + + eth-miic@44030000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "renesas,r9a06g032-miic", "renesas,rzn1-miic"; + reg = <0x44030000 0x10000>; + clocks = <&sysctrl R9A06G032_CLK_MII_REF>, + <&sysctrl R9A06G032_CLK_RGMII_REF>, + <&sysctrl R9A06G032_CLK_RMII_REF>, + <&sysctrl R9A06G032_HCLK_SWITCH_RG>; + renesas,miic-switch-portin = <MIIC_GMAC2_PORT>; + power-domains = <&sysctrl>; + + mii_conv1: mii-conv@1 { + renesas,miic-input = <MIIC_GMAC1_PORT>; + reg = <1>; + }; + + mii_conv2: mii-conv@2 { + renesas,miic-input = <MIIC_SWITCH_PORTD>; + reg = <2>; + }; + + mii_conv3: mii-conv@3 { + renesas,miic-input = <MIIC_SWITCH_PORTC>; + reg = <3>; + }; + + mii_conv4: mii-conv@4 { + renesas,miic-input = <MIIC_SWITCH_PORTB>; + reg = <4>; + }; + + mii_conv5: mii-conv@5 { + renesas,miic-input = <MIIC_SWITCH_PORTA>; + reg = <5>; + }; + };
include/dt-bindings/net/pcs-rzn1-miic.h new file +33 -0
@@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */ +/* +* Copyright (C) 2022 Schneider-Electric +* +* Clément Léger <[email protected]> +*/ + +#ifndef _DT_BINDINGS_PCS_RZN1_MIIC +#define _DT_BINDINGS_PCS_RZN1_MIIC + +/* +* Reefer to the datasheet [1] section 8.2.1, Internal Connection of Ethernet +* Ports to check the available combination +* +* [1] REN_r01uh0750ej0140-rzn1-introduction_MAT_20210228.pdf +*/ + +#define MIIC_GMAC1_PORT 0 +#define MIIC_GMAC2_PORT 1 +#define MIIC_RTOS_PORT 2 +#define MIIC_SERCOS_PORTA 3 +#define MIIC_SERCOS_PORTB 4 +#define MIIC_ETHERCAT_PORTA 5 +#define MIIC_ETHERCAT_PORTB 6 +#define MIIC_ETHERCAT_PORTC 7 +#define MIIC_SWITCH_PORTA 8 +#define MIIC_SWITCH_PORTB 9 +#define MIIC_SWITCH_PORTC 10 +#define MIIC_SWITCH_PORTD 11 +#define MIIC_HSR_PORTA 12 +#define MIIC_HSR_PORTB 13 + +#endif
Signature · 1 line
2.34.1
Clément Léger
maintainerPATCH v3 4/12 net: pcs: add Renesas MII converter driver
In reply to Clément LégerAdd a PCS driver for the MII converter that is present on the Renesas RZ/N1 SoC. This MII converter is reponsible for converting MII to RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to reuse it in both the switch driver and the stmmac driver. Currently, this driver only allows the PCS to be used by the dual Cortex-A7 subsystem since the register locking system is not used.
--- drivers/net/pcs/Kconfig | 8 + drivers/net/pcs/Makefile | 1 + drivers/net/pcs/pcs-rzn1-miic.c | 502 ++++++++++++++++++++++++++++++++ include/linux/pcs-rzn1-miic.h | 18 ++ 4 files changed, 529 insertions(+) create mode 100644 drivers/net/pcs/pcs-rzn1-miic.c create mode 100644 include/linux/pcs-rzn1-miic.h
drivers/net/pcs/Kconfig +8 -0
@@ -18,4 +18,12 @@ config PCS_LYNX This module provides helpers to phylink for managing the Lynx PCS which is part of the Layerscape and QorIQ Ethernet SERDES. +config PCS_RZN1_MIIC + tristate "Renesas RZ/N1 MII converter" + depends on ARCH_RZN1 || COMPILE_TEST + help + This module provides a driver for the MII converter that is available + on RZ/N1 SoCs. This PCS converts MII to RMII/RGMII or can be set in + pass-through mode for MII. + endmenu
drivers/net/pcs/Makefile +1 -0
@@ -5,3 +5,4 @@ pcs_xpcs-$(CONFIG_PCS_XPCS) := pcs-xpcs.o pcs-xpcs-nxp.o obj-$(CONFIG_PCS_XPCS) += pcs_xpcs.o obj-$(CONFIG_PCS_LYNX) += pcs-lynx.o +obj-$(CONFIG_PCS_RZN1_MIIC) += pcs-rzn1-miic.o
drivers/net/pcs/pcs-rzn1-miic.c new file +502 -0
502 lines not on this page · raw message
include/linux/pcs-rzn1-miic.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2022 Schneider Electric +* +* Clément Léger <[email protected]> +*/ + +#ifndef __LINUX_PCS_MIIC_H +#define __LINUX_PCS_MIIC_H + +struct phylink ; +struct device_node ; + +struct phylink_pcs *miic_create (struct device_node *np); + +void miic_destroy (struct phylink_pcs *pcs); + +#endif /* __LINUX_PCS_MIIC_H */
Signature · 1 line
2.34.1
Re: [PATCH net-next v3 04/12] net: pcs: add Renesas MII converter driver
Hi Clément,
Quoted 8 lines · Clément Léger
Add a PCS driver for the MII converter that is present on the Renesas RZ/N1 SoC. This MII converter is reponsible for converting MII to RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to reuse it in both the switch driver and the stmmac driver. Currently, this driver only allows the PCS to be used by the dual Cortex-A7 subsystem since the register locking system is not used.
Signed-off-by Clément Léger <[email protected]>
Thanks for your patch!
Quoted 17 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +14
-0+static int miic_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct miic *miic; +u32 mode_cfg; +int ret; + + ret =miic_parse_dt (dev, &mode_cfg); +if (ret <0 ) +return -EINVAL ; + + miic =devm_kzalloc (dev,sizeof (*miic),GFP_KERNEL ); +if (!miic) +return -ENOMEM ;
drivers/net/pcs/pcs-rzn1-miic.c line 455
Quoted 10 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +10
-0+ +spin_lock_init (&miic->lock); + miic->dev = dev; + miic->base =devm_platform_ioremap_resource (pdev,0 ); +if (!miic->base) +return -EINVAL ; + +pm_runtime_enable (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret <0 )
Missing pm_runtime_disable(dev).
Quoted 7 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +7
-0+return ret; + + ret =miic_init_hw (miic, mode_cfg); +if (ret) + goto disable_runtime_pm; + +/* miic_create() relies on that fact that data are attached to the
drivers/net/pcs/pcs-rzn1-miic.c line 472
Quoted 10 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +10
-0+* platform device to determine if the driver is ready so this needs to +* be the last thing to be done after everything is initialized +* properly. +*/ +platform_set_drvdata (pdev, miic); + +return 0 ; + +disable_runtime_pm: +pm_runtime_put (dev);
Missing pm_runtime_disable(dev).
drivers/net/pcs/pcs-rzn1-miic.c line 479
Quoted 7 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +7
-0+ +return ret; +} + +static int miic_remove (struct platform_device *pdev) +{ +pm_runtime_put (&pdev->dev);
Missing pm_runtime_disable(dev).
drivers/net/pcs/pcs-rzn1-miic.c line 218
Quoted 3 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +3
-0+ +return 0 ; +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Clément Léger
maintainerRe: [PATCH net-next v3 04/12] net: pcs: add Renesas MII converter driver
Quoted 35 lines · Geert Uytterhoeven
Hi Clément,
Quoted 8 lines · Clément Léger
Add a PCS driver for the MII converter that is present on the Renesas RZ/N1 SoC. This MII converter is reponsible for converting MII to RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to reuse it in both the switch driver and the stmmac driver. Currently, this driver only allows the PCS to be used by the dual Cortex-A7 subsystem since the register locking system is not used.
Signed-off-by Clément Léger <[email protected]>Thanks for your patch!
Quoted 21 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +18
-0+static int miic_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct miic *miic; +u32 mode_cfg; +int ret; + + ret =miic_parse_dt (dev, &mode_cfg); +if (ret <0 ) +return -EINVAL ; + + miic =devm_kzalloc (dev,sizeof (*miic),GFP_KERNEL ); +if (!miic) +return -ENOMEM ; + +spin_lock_init (&miic->lock); + miic->dev = dev; + miic->base =devm_platform_ioremap_resource (pdev,0 );
Quoted 8 lines
drivers/net/pcs/pcs-rzn1-miic.c line 455
Quoted 6 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +6
-0+if (!miic->base) +return -EINVAL ; + +pm_runtime_enable (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret <0 )Missing
pm_runtime_disable(dev).
Maybe using devm_pm_runtime_enable() would be sufficient and avoid such calls.
Quoted 45 lines
Quoted 8 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +7
-0+return ret; + + ret =miic_init_hw (miic, mode_cfg); +if (ret) + goto disable_runtime_pm; + +/* miic_create() relies on that fact that data are attached to the drivers/net/pcs/pcs-rzn1-miic.c line 472
Quoted 10 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +10
-0+* platform device to determine if the driver is ready so this needs to +* be the last thing to be done after everything is initialized +* properly. +*/ +platform_set_drvdata (pdev, miic); + +return 0 ; + +disable_runtime_pm: +pm_runtime_put (dev);Missing
pm_runtime_disable(dev).drivers/net/pcs/pcs-rzn1-miic.c line 479
Quoted 7 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +7
-0+ +return ret; +} + +static int miic_remove (struct platform_device *pdev) +{ +pm_runtime_put (&pdev->dev);Missing
pm_runtime_disable(dev).drivers/net/pcs/pcs-rzn1-miic.c line 218
Quoted 3 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +3
-0+ +return 0 ; +}Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 3 lines
Clément Léger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com
Re: [PATCH net-next v3 04/12] net: pcs: add Renesas MII converter driver
Hi Clément,
Quoted 44 lines · Clément Léger
Quoted 33 lines · Geert Uytterhoeven
Quoted 8 lines · Clément Léger
Add a PCS driver for the MII converter that is present on the Renesas RZ/N1 SoC. This MII converter is reponsible for converting MII to RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to reuse it in both the switch driver and the stmmac driver. Currently, this driver only allows the PCS to be used by the dual Cortex-A7 subsystem since the register locking system is not used.
Signed-off-by Clément Léger <[email protected]>Thanks for your patch!
Quoted 21 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +18
-0+static int miic_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct miic *miic; +u32 mode_cfg; +int ret; + + ret =miic_parse_dt (dev, &mode_cfg); +if (ret <0 ) +return -EINVAL ; + + miic =devm_kzalloc (dev,sizeof (*miic),GFP_KERNEL ); +if (!miic) +return -ENOMEM ; + +spin_lock_init (&miic->lock); + miic->dev = dev; + miic->base =devm_platform_ioremap_resource (pdev,0 );Quoted 8 lines
drivers/net/pcs/pcs-rzn1-miic.c line 455
Quoted 6 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +6
-0+if (!miic->base) +return -EINVAL ; + +pm_runtime_enable (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret <0 )Missing
pm_runtime_disable(dev).
Quoted 2 lines
Maybe using
devm_pm_runtime_enable()would be sufficient and avoid such calls.
That's an option.
Note that that still won't allow you to get rid of the .remove() callback, as you still have to call pm_runtime_put() manually.
Quoted 21 lines
Quoted 21 lines
Quoted 8 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +7
-0+return ret; + + ret =miic_init_hw (miic, mode_cfg); +if (ret) + goto disable_runtime_pm; + +/* miic_create() relies on that fact that data are attached to the drivers/net/pcs/pcs-rzn1-miic.c line 472
Quoted 10 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +10
-0+* platform device to determine if the driver is ready so this needs to +* be the last thing to be done after everything is initialized +* properly. +*/ +platform_set_drvdata (pdev, miic); + +return 0 ; + +disable_runtime_pm: +pm_runtime_put (dev);Missing
pm_runtime_disable(dev).
Quoted 9 lines
Quoted 9 lines
drivers/net/pcs/pcs-rzn1-miic.c line 479
Quoted 7 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +7
-0+ +return ret; +} + +static int miic_remove (struct platform_device *pdev) +{ +pm_runtime_put (&pdev->dev);Missing
pm_runtime_disable(dev).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Clément Léger
maintainerRe: [PATCH net-next v3 04/12] net: pcs: add Renesas MII converter driver
Quoted 47 lines · Geert Uytterhoeven
Hi Clément,
Quoted 44 lines · Clément Léger
Quoted 41 lines · Geert Uytterhoeven
Quoted 8 lines · Clément Léger
Add a PCS driver for the MII converter that is present on the Renesas RZ/N1 SoC. This MII converter is reponsible for converting MII to RMII/RGMII or act as a MII pass-trough. Exposing it as a PCS allows to reuse it in both the switch driver and the stmmac driver. Currently, this driver only allows the PCS to be used by the dual Cortex-A7 subsystem since the register locking system is not used.
Signed-off-by Clément Léger <[email protected]>Thanks for your patch!
Quoted 17 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +14
-0+static int miic_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct miic *miic; +u32 mode_cfg; +int ret; + + ret =miic_parse_dt (dev, &mode_cfg); +if (ret <0 ) +return -EINVAL ; + + miic =devm_kzalloc (dev,sizeof (*miic),GFP_KERNEL ); +if (!miic) +return -ENOMEM ;drivers/net/pcs/pcs-rzn1-miic.c line 455
Quoted 10 lines
drivers/net/pcs/pcs-rzn1-miic.c new file +10
-0+ +spin_lock_init (&miic->lock); + miic->dev = dev; + miic->base =devm_platform_ioremap_resource (pdev,0 ); +if (!miic->base) +return -EINVAL ; + +pm_runtime_enable (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret <0 )Missing
pm_runtime_disable(dev).
Quoted 6 lines
Quoted 2 lines
Maybe using
devm_pm_runtime_enable()would be sufficient and avoid such calls.That's an option.
Note that that still won't allow you to get rid of the .remove() callback, as you still have to callpm_runtime_put()manually.
Yes, of course :) I'll do the modifications.
Thanks,
Signature · 3 lines
Clément Léger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com
Clément Léger
maintainerPATCH v3 5/12 dt-bindings: net: dsa: add bindings for Renesas RZ/N1 Advanced 5 port switch
In reply to Clément LégerAdd bindings for Renesas RZ/N1 Advanced 5 port switch. This switch is present on Renesas RZ/N1 SoC and was probably provided by MoreThanIP. This company does not exists anymore and has been bought by Synopsys. Since this IP can't be find anymore in the Synospsy portfolio, lets use Renesas as the vendor compatible for this IP.
--- .../bindings/net/dsa/renesas,rzn1-a5psw.yaml | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml
Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml new file +132 -0
@@ -0,0 +1,132 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/renesas,rzn1-a5psw.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas RZ/N1 Advanced 5 ports ethernet switch + +maintainers: + - Clément Léger <[email protected]> + +description: | + The advanced 5 ports switch is present on the Renesas RZ/N1 SoC family and + handles 4 ports + 1 CPU management port. + +allOf: + - $ref: dsa.yaml# + +properties: + compatible: + items: + - enum: + - renesas,r9a06g032-a5psw + - const: renesas,rzn1-a5psw + + reg: + maxItems: 1 + + mdio: + $ref: /schemas/net/mdio.yaml# + unevaluatedProperties: false + + clocks: + items: + - description: AHB clock used for the switch register interface + - description: Switch system clock + + clock-names: + items: + - const: hclk + - const: clk + +patternProperties: + "^ethernet-ports$": + type: object + properties: + '#address-cells': + const: 1 + '#size-cells': + const: 0 + + patternProperties: + "^(ethernet-)?port@[0-6]$": + type: object + description: Ethernet switch ports + + properties: + pcs-handle: + description: + phandle pointing to a PCS sub-node compatible with + renesas,rzn1-miic.yaml# + $ref: /schemas/types.yaml#/definitions/phandle + +unevaluatedProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/clock/r9a06g032-sysctrl.h> + + switch@44050000 { + compatible = "renesas,r9a06g032-a5psw", "renesas,rzn1-a5psw"; + reg = <0x44050000 0x10000>; + clocks = <&sysctrl R9A06G032_HCLK_SWITCH>, <&sysctrl R9A06G032_CLK_SWITCH>; + clock-names = "hclk", "clk"; + pinctrl-names = "default"; + pinctrl-0 = <&pins_mdio1>, <&pins_eth3>, <&pins_eth4>; + + dsa,member = <0 0>; + + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan0"; + phy-handle = <&switch0phy3>; + pcs-handle = <&mii_conv4>; + }; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&switch0phy1>; + pcs-handle = <&mii_conv3>; + }; + + port@4 { + reg = <4>; + ethernet = <&gmac1>; + label = "cpu"; + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + reset-gpios = <&gpio0a 2 GPIO_ACTIVE_HIGH>; + reset-delay-us = <15>; + clock-frequency = <2500000>; + + switch0phy1: ethernet-phy@1{ + reg = <1>; + }; + + switch0phy3: ethernet-phy@3{ + reg = <3>; + }; + }; + };
Signature · 1 line
2.34.1
Clément Léger
maintainerPATCH v3 6/12 net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver
In reply to Clément LégerAdd Renesas RZ/N1 advanced 5 port switch driver. This switch handles 5 ports including 1 CPU management port. A MDIO bus is also exposed by this switch and allows to communicate with PHYs connected to the ports. Each switch port (except for the CPU management ports) is connected to the MII converter.
This driver includes basic bridging support, more support will be added later (vlan, etc).
--- drivers/net/dsa/Kconfig | 9 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/rzn1_a5psw.c | 712 +++++++++++++++++++++++++++++++++++ drivers/net/dsa/rzn1_a5psw.h | 199 ++++++++++ 4 files changed, 921 insertions(+) create mode 100644 drivers/net/dsa/rzn1_a5psw.c create mode 100644 drivers/net/dsa/rzn1_a5psw.h
drivers/net/dsa/Kconfig +9 -0
@@ -70,6 +70,15 @@ config NET_DSA_QCA8K source "drivers/net/dsa/realtek/Kconfig" +config NET_DSA_RZN1_A5PSW + tristate "Renesas RZ/N1 A5PSW Ethernet switch support" + depends on NET_DSA + select NET_DSA_TAG_RZN1_A5PSW + select PCS_RZN1_MIIC + help + This driver supports the A5PSW switch, which is embedded in Renesas + RZ/N1 SoC. + config NET_DSA_SMSC_LAN9303 tristate depends on VLAN_8021Q || VLAN_8021Q=n
drivers/net/dsa/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o +obj-$(CONFIG_NET_DSA_RZN1_A5PSW) += rzn1_a5psw.o obj-$(CONFIG_NET_DSA_SMSC_LAN9303) += lan9303-core.o obj-$(CONFIG_NET_DSA_SMSC_LAN9303_I2C) += lan9303_i2c.o obj-$(CONFIG_NET_DSA_SMSC_LAN9303_MDIO) += lan9303_mdio.o
drivers/net/dsa/rzn1_a5psw.c new file +712 -0
712 lines not on this page · raw message
drivers/net/dsa/rzn1_a5psw.h new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerRe: [PATCH net-next v3 06/12] net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver
Quoted 13 lines · Clément Léger
Add Renesas RZ/N1 advanced 5 port switch driver. This switch handles 5 ports including 1 CPU management port. A MDIO bus is also exposed by this switch and allows to communicate with PHYs connected to the ports. Each switch port (except for the CPU management ports) is connected to the MII converter.
This driver includes basic bridging support, more support will be added later (vlan, etc).
Suggested-by Jean-Pierre Geslin <[email protected]>Suggested-by Phil Edworthy <[email protected]>Signed-off-by Clément Léger <[email protected]>---
drivers/net/dsa/rzn1_a5psw.c line 125
Quoted 7 lines
drivers/net/dsa/rzn1_a5psw.c new file +7
-0+static void a5psw_port_disable (struct dsa_switch *ds,int port) +{ +struct a5psw *a5psw = ds->priv; + +a5psw_port_authorize_set (a5psw, port, false); +a5psw_port_enable_set (a5psw, port, false); +a5psw_port_fdb_flush (a5psw, port);
The bridge core takes care of this by setting the port state to DISABLED, which makes DSA call dsa_port_fast_age(), no?
Standalone ports shouldn't need fast ageing because they shouldn't have address learning enabled in the first place.
drivers/net/dsa/rzn1_a5psw.c line 270
Quoted 12 lines
drivers/net/dsa/rzn1_a5psw.c new file +11
-0+} +static int a5psw_port_bridge_join (struct dsa_switch *ds,int port, +struct dsa_bridge bridge, +bool *tx_fwd_offload, +struct netlink_ext_ack *extack) +{ +struct a5psw *a5psw = ds->priv; + +/* We only support 1 bridge device */ +if (a5psw->br_dev && bridge.dev != a5psw->br_dev) +return -EINVAL ;
return -EOPNOTSUPP, to allow software bridging.
You might also want to set an extack message here and avoid overwriting it in dsa_slave_changeupper() with "Offloading not supported", but say something more specific like "Forwarding offload supported for a single bridge".
Quoted 7 lines
drivers/net/dsa/rzn1_a5psw.c new file +7
-0+ + a5psw->br_dev = bridge.dev; +a5psw_flooding_set_resolution (a5psw, port, true); +a5psw_port_mgmtfwd_set (a5psw, port, false); + +return 0 ; +}
drivers/net/dsa/rzn1_a5psw.c line 287
Quoted 10 lines
drivers/net/dsa/rzn1_a5psw.c new file +10
-0+ +static void a5psw_port_bridge_leave (struct dsa_switch *ds,int port, +struct dsa_bridge bridge) +{ +struct a5psw *a5psw = ds->priv; + +a5psw_flooding_set_resolution (a5psw, port, false); +a5psw_port_mgmtfwd_set (a5psw, port, true); + +/* No more port bridged */
s/port/ports/
drivers/net/dsa/rzn1_a5psw.c line 548
Quoted 12 lines
drivers/net/dsa/rzn1_a5psw.c new file +11
-0+if (a5psw->bridged_ports ==BIT (A5PSW_CPU_PORT )) + a5psw->br_dev =NULL ; +} +static int a5psw_pcs_get (struct a5psw *a5psw) +{ +struct device_node *ports, *port, *pcs_node; +struct phylink_pcs *pcs; +int ret; +u32 reg; + + ports =of_get_child_by_name (a5psw->dev->of_node,"ports" );
Can you please do:
ports = of_get_child_by_name(a5psw->dev->of_node, "ethernet-ports"); if (!ports) ports = of_get_child_by_name(a5psw->dev->of_node, "ports");
Quoted 52 lines
drivers/net/dsa/rzn1_a5psw.c new file +51
-0+if (!ports) +return -EINVAL ; + +for_each_available_child_of_node (ports, port) { + pcs_node =of_parse_phandle (port,"pcs-handle" ,0 ); +if (!pcs_node) +continue ; + +if (of_property_read_u32 (port,"reg" , ®)) { + ret = -EINVAL ; + goto free_pcs; + } + +if (reg >=ARRAY_SIZE (a5psw->pcs)) { + ret = -ENODEV ; + goto free_pcs; + } + + pcs =miic_create (pcs_node); +if (IS_ERR (pcs)) { +dev_err (a5psw->dev,"Failed to create PCS for port %d\n" , + reg); + ret =PTR_ERR (pcs); + goto free_pcs; + } + + a5psw->pcs[reg] = pcs; + } +of_node_put (ports); + +return 0 ; + +free_pcs: +a5psw_pcs_free (a5psw); + +return ret; +} +/* Ensure enough space for 2 VLAN tags */ +#define A5PSW_EXTRA_MTU_LEN (A5PSW_TAG_LEN + 8) +#define A5PSW_MAX_MTU (A5PSW_JUMBO_LEN - A5PSW_EXTRA_MTU_LEN) +#define A5PSW_MGMT_TAG_VALUE 0xE001 + +#define A5PSW_PATTERN_MGMTFWD 0 + +#define A5PSW_LK_BUSY_USEC_POLL 10 +#define A5PSW_CTRL_TIMEOUT 1000 +#define A5PSW_TABLE_ENTRIES 8192 + +/** +* struct a5psw - switch struct +* @base: Base address of the switch
drivers/net/dsa/rzn1_a5psw.c
Quoted 10 lines
drivers/net/dsa/rzn1_a5psw.c new file +10
-0+* @hclk: hclk_switch clock +* @clk: clk_switch clock +* @dev: Device associated to the switch +* @mii_bus: MDIO bus struct +* @mdio_freq: MDIO bus frequency requested +* @pcs: Array of PCS connected to the switch ports (not for the CPU) +* @ds: DSA switch struct +* @lk_lock: Lock for the lookup table +* @reg_lock: Lock for register read-modify-write operation +* @bridged_ports: List of ports that are bridged and should be flooded
s/List/Mask/
Quoted 18 lines
+ * @br_dev: Bridge net device
+ */drivers/net/dsa/rzn1_a5psw.h new file +13
-0+struct a5psw { +void __iomem *base; +struct clk *hclk; +struct clk *clk; +struct device *dev; +struct mii_bus *mii_bus; +struct phylink_pcs *pcs[A5PSW_PORTS_NUM -1 ]; +struct dsa_switch ds; +spinlock_t lk_lock; +spinlock_t reg_lock; +u32 bridged_ports; +struct net_device *br_dev; +};Signature · 1 line
2.34.1
Clément Léger
maintainerRe: [PATCH net-next v3 06/12] net: dsa: rzn1-a5psw: add Renesas RZ/N1 advanced 5 port switch driver
Quoted 10 lines · Vladimir Oltean
Quoted 9 lines · Clément Léger
Add Renesas RZ/N1 advanced 5 port switch driver. This switch handles 5 ports including 1 CPU management port. A MDIO bus is also exposed by this switch and allows to communicate with PHYs connected to the ports. Each switch port (except for the CPU management ports) is connected to the MII converter.
This driver includes basic bridging support, more support will be added later (vlan, etc).
Quoted 14 lines
drivers/net/dsa/rzn1_a5psw.c line 125
Quoted 11 lines
Suggested-by Jean-Pierre Geslin <[email protected]>Suggested-by Phil Edworthy <[email protected]>Signed-off-by Clément Léger <[email protected]>---
drivers/net/dsa/rzn1_a5psw.c new file +7
-0+static void a5psw_port_disable (struct dsa_switch *ds,int port) +{ +struct a5psw *a5psw = ds->priv; + +a5psw_port_authorize_set (a5psw, port, false); +a5psw_port_enable_set (a5psw, port, false); +a5psw_port_fdb_flush (a5psw, port);The bridge core takes care of this by setting the port state to DISABLED, which makes DSA call
dsa_port_fast_age(), no?
Yes you are right.
Quoted 3 lines
Standalone ports shouldn't need fast ageing because they shouldn't have address learning enabled in the first place.
Ok, makes sense.
Quoted 15 lines
drivers/net/dsa/rzn1_a5psw.c line 270
Quoted 13 lines
drivers/net/dsa/rzn1_a5psw.c new file +11
-0+} +static int a5psw_port_bridge_join (struct dsa_switch *ds,int port, +struct dsa_bridge bridge, +bool *tx_fwd_offload, +struct netlink_ext_ack *extack) +{ +struct a5psw *a5psw = ds->priv; + +/* We only support 1 bridge device */ +if (a5psw->br_dev && bridge.dev != a5psw->br_dev) +return -EINVAL ;return
-EOPNOTSUPP, to allow software bridging.
Ok.
Quoted 19 lines
You might also want to set an extack message here and avoid overwriting it in
dsa_slave_changeupper()with "Offloading not supported", but say something more specific like "Forwarding offload supported for a single bridge".drivers/net/dsa/rzn1_a5psw.c line 548
Quoted 11 lines
drivers/net/dsa/rzn1_a5psw.c new file +10
-0+ a5psw->br_dev =NULL ; +} +static int a5psw_pcs_get (struct a5psw *a5psw) +{ +struct device_node *ports, *port, *pcs_node; +struct phylink_pcs *pcs; +int ret; +u32 reg; + + ports =of_get_child_by_name (a5psw->dev->of_node,"ports" );Can you please do:
Quoted 3 lines
ports = of_get_child_by_name(a5psw->dev->of_node, "ethernet-ports"); if (!ports) ports = of_get_child_by_name(a5psw->dev->of_node, "ports");
Acked.
Signature · 3 lines
Clément Léger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com
Clément Léger
maintainerPATCH v3 7/12 net: dsa: rzn1-a5psw: add statistics support
In reply to Clément LégerAdd statistics support to the rzn1-a5psw driver by implementing the following dsa_switch_ops callbacks:
- get_sset_count()
- get_strings()
- get_ethtool_stats()
- get_eth_mac_stats()
- get_eth_ctrl_stats()
- get_rmon_stats()
--- drivers/net/dsa/rzn1_a5psw.c | 178 +++++++++++++++++++++++++++++++++++ drivers/net/dsa/rzn1_a5psw.h | 46 ++++++++- 2 files changed, 223 insertions(+), 1 deletion(-)
drivers/net/dsa/rzn1_a5psw.c +178 -0
@@ -16,6 +16,61 @@#include "rzn1_a5psw.h" +struct a5psw_stats { +u16 offset; +const char name[ETH_GSTRING_LEN ]; +}; + +#define STAT_DESC (_offset, _name) {.offset = _offset, .name = _name} + +static const struct a5psw_stats a5psw_stats[] = { +STAT_DESC (A5PSW_aFramesTransmittedOK,"aFrameTransmittedOK" ), +STAT_DESC (A5PSW_aFramesReceivedOK,"aFrameReceivedOK" ), +STAT_DESC (A5PSW_aFrameCheckSequenceErrors,"aFrameCheckSequenceErrors" ), +STAT_DESC (A5PSW_aAlignmentErrors,"aAlignmentErrors" ), +STAT_DESC (A5PSW_aOctetsTransmittedOK,"aOctetsTransmittedOK" ), +STAT_DESC (A5PSW_aOctetsReceivedOK,"aOctetsReceivedOK" ), +STAT_DESC (A5PSW_aTxPAUSEMACCtrlFrames,"aTxPAUSEMACCtrlFrames" ), +STAT_DESC (A5PSW_aRxPAUSEMACCtrlFrames,"aRxPAUSEMACCtrlFrames" ), +STAT_DESC (A5PSW_ifInErrors,"ifInErrors" ), +STAT_DESC (A5PSW_ifOutErrors,"ifOutErrors" ), +STAT_DESC (A5PSW_ifInUcastPkts,"ifInUcastPkts" ), +STAT_DESC (A5PSW_ifInMulticastPkts,"ifInMulticastPkts" ), +STAT_DESC (A5PSW_ifInBroadcastPkts,"ifInBroadcastPkts" ), +STAT_DESC (A5PSW_ifOutDiscards,"ifOutDiscards" ), +STAT_DESC (A5PSW_ifOutUcastPkts,"ifOutUcastPkts" ), +STAT_DESC (A5PSW_ifOutMulticastPkts,"ifOutMulticastPkts" ), +STAT_DESC (A5PSW_ifOutBroadcastPkts,"ifOutBroadcastPkts" ), +STAT_DESC (A5PSW_etherStatsDropEvents,"etherStatsDropEvents" ), +STAT_DESC (A5PSW_etherStatsOctets,"etherStatsOctets" ), +STAT_DESC (A5PSW_etherStatsPkts,"etherStatsPkts" ), +STAT_DESC (A5PSW_etherStatsUndersizePkts,"etherStatsUndersizePkts" ), +STAT_DESC (A5PSW_etherStatsOversizePkts,"etherStatsOversizePkts" ), +STAT_DESC (A5PSW_etherStatsPkts64Octets,"etherStatsPkts64Octets" ), +STAT_DESC (A5PSW_etherStatsPkts65to127Octets, +"etherStatsPkts65to127Octets" ), +STAT_DESC (A5PSW_etherStatsPkts128to255Octets, +"etherStatsPkts128to255Octets" ), +STAT_DESC (A5PSW_etherStatsPkts256to511Octets, +"etherStatsPkts256to511Octets" ), +STAT_DESC (A5PSW_etherStatsPkts512to1023Octets, +"etherStatsPkts512to1023Octets" ), +STAT_DESC (A5PSW_etherStatsPkts1024to1518Octets, +"etherStatsPkts1024to1518Octets" ), +STAT_DESC (A5PSW_etherStatsPkts1519toXOctets, +"etherStatsPkts1519toXOctets" ), +STAT_DESC (A5PSW_etherStatsJabbers,"etherStatsJabbers" ), +STAT_DESC (A5PSW_etherStatsFragments,"etherStatsFragments" ), +STAT_DESC (A5PSW_VLANReceived,"VLANReceived" ), +STAT_DESC (A5PSW_VLANTransmitted,"VLANTransmitted" ), +STAT_DESC (A5PSW_aDeferred,"aDeferred" ), +STAT_DESC (A5PSW_aMultipleCollisions,"aMultipleCollisions" ), +STAT_DESC (A5PSW_aSingleCollisions,"aSingleCollisions" ), +STAT_DESC (A5PSW_aLateCollisions,"aLateCollisions" ), +STAT_DESC (A5PSW_aExcessiveCollisions,"aExcessiveCollisions" ), +STAT_DESC (A5PSW_aCarrierSenseErrors,"aCarrierSenseErrors" ), +}; +static void a5psw_reg_writel (struct a5psw *a5psw,int offset,u32 value) {writel (value, a5psw->base + offset);
@@ -322,6 +377,123 @@ static void a5psw_port_fast_age(struct dsa_switch *ds, int port)a5psw_port_fdb_flush (a5psw, port); } +static u64 a5psw_read_stat (struct a5psw *a5psw,u32 offset,int port) +{ +u32 reg_lo, reg_hi; + + reg_lo =a5psw_reg_readl (a5psw, offset +A5PSW_PORT_OFFSET (port)); +/* A5PSW_STATS_HIWORD is latched on stat read */ + reg_hi =a5psw_reg_readl (a5psw,A5PSW_STATS_HIWORD ); + +return ((u64 )reg_hi <<32 ) | reg_lo; +} + +static void a5psw_get_strings (struct dsa_switch *ds,int port,u32 stringset, +uint8_t *data) +{ +unsigned int u; + +if (stringset !=ETH_SS_STATS ) +return ; + +for (u =0 ; u <ARRAY_SIZE (a5psw_stats); u++) { +memcpy (data + u *ETH_GSTRING_LEN , a5psw_stats[u].name, +ETH_GSTRING_LEN ); + } +} + +static void a5psw_get_ethtool_stats (struct dsa_switch *ds,int port, +uint64_t *data) +{ +struct a5psw *a5psw = ds->priv; +unsigned int u; + +for (u =0 ; u <ARRAY_SIZE (a5psw_stats); u++) + data[u] =a5psw_read_stat (a5psw, a5psw_stats[u].offset, port); +} + +static int a5psw_get_sset_count (struct dsa_switch *ds,int port,int sset) +{ +if (sset !=ETH_SS_STATS ) +return 0 ; + +return ARRAY_SIZE (a5psw_stats); +} + +static void a5psw_get_eth_mac_stats (struct dsa_switch *ds,int port, +struct ethtool_eth_mac_stats *mac_stats) +{ +struct a5psw *a5psw = ds->priv; + +#define RD (name) a5psw_read_stat(a5psw, A5PSW_##name, port) + mac_stats->FramesTransmittedOK =RD (aFramesTransmittedOK); + mac_stats->SingleCollisionFrames =RD (aSingleCollisions); + mac_stats->MultipleCollisionFrames =RD (aMultipleCollisions); + mac_stats->FramesReceivedOK =RD (aFramesReceivedOK); + mac_stats->FrameCheckSequenceErrors =RD (aFrameCheckSequenceErrors); + mac_stats->AlignmentErrors =RD (aAlignmentErrors); + mac_stats->OctetsTransmittedOK =RD (aOctetsTransmittedOK); + mac_stats->FramesWithDeferredXmissions =RD (aDeferred); + mac_stats->LateCollisions =RD (aLateCollisions); + mac_stats->FramesAbortedDueToXSColls =RD (aExcessiveCollisions); + mac_stats->FramesLostDueToIntMACXmitError =RD (ifOutErrors); + mac_stats->CarrierSenseErrors =RD (aCarrierSenseErrors); + mac_stats->OctetsReceivedOK =RD (aOctetsReceivedOK); + mac_stats->FramesLostDueToIntMACRcvError =RD (ifInErrors); + mac_stats->MulticastFramesXmittedOK =RD (ifOutMulticastPkts); + mac_stats->BroadcastFramesXmittedOK =RD (ifOutBroadcastPkts); + mac_stats->FramesWithExcessiveDeferral =RD (aDeferred); + mac_stats->MulticastFramesReceivedOK =RD (ifInMulticastPkts); + mac_stats->BroadcastFramesReceivedOK =RD (ifInBroadcastPkts); +#undef RD +} + +static const struct ethtool_rmon_hist_range a5psw_rmon_ranges[] = { + {0 ,64 }, + {65 ,127 }, + {128 ,255 }, + {256 ,511 }, + {512 ,1023 }, + {1024 ,1518 }, + {1519 ,A5PSW_MAX_MTU }, + {} +}; + +static void a5psw_get_rmon_stats (struct dsa_switch *ds,int port, +struct ethtool_rmon_stats *rmon_stats, +const struct ethtool_rmon_hist_range **ranges) +{ +struct a5psw *a5psw = ds->priv; + +#define RD (name) a5psw_read_stat(a5psw, A5PSW_##name, port) + rmon_stats->undersize_pkts =RD (etherStatsUndersizePkts); + rmon_stats->oversize_pkts =RD (etherStatsOversizePkts); + rmon_stats->fragments =RD (etherStatsFragments); + rmon_stats->jabbers =RD (etherStatsJabbers); + rmon_stats->hist[0 ] =RD (etherStatsPkts64Octets); + rmon_stats->hist[1 ] =RD (etherStatsPkts65to127Octets); + rmon_stats->hist[2 ] =RD (etherStatsPkts128to255Octets); + rmon_stats->hist[3 ] =RD (etherStatsPkts256to511Octets); + rmon_stats->hist[4 ] =RD (etherStatsPkts512to1023Octets); + rmon_stats->hist[5 ] =RD (etherStatsPkts1024to1518Octets); + rmon_stats->hist[6 ] =RD (etherStatsPkts1519toXOctets); +#undef RD + + *ranges = a5psw_rmon_ranges; +} + +static void a5psw_get_eth_ctrl_stats (struct dsa_switch *ds,int port, +struct ethtool_eth_ctrl_stats *ctrl_stats) +{ +struct a5psw *a5psw = ds->priv; +u64 stat; + + stat =a5psw_read_stat (a5psw, A5PSW_aTxPAUSEMACCtrlFrames, port); + ctrl_stats->MACControlFramesTransmitted = stat; + stat =a5psw_read_stat (a5psw, A5PSW_aRxPAUSEMACCtrlFrames, port); + ctrl_stats->MACControlFramesReceived = stat; +} +static int a5psw_setup (struct dsa_switch *ds) {struct a5psw *a5psw = ds->priv;
@@ -410,6 +582,12 @@ static const struct dsa_switch_ops a5psw_switch_ops = { .phylink_mac_link_up = a5psw_phylink_mac_link_up, .port_change_mtu = a5psw_port_change_mtu, .port_max_mtu = a5psw_port_max_mtu, + .get_sset_count = a5psw_get_sset_count, + .get_strings = a5psw_get_strings, + .get_ethtool_stats = a5psw_get_ethtool_stats, + .get_eth_mac_stats = a5psw_get_eth_mac_stats, + .get_eth_ctrl_stats = a5psw_get_eth_ctrl_stats, + .get_rmon_stats = a5psw_get_rmon_stats, .set_ageing_time = a5psw_set_ageing_time, .port_bridge_join = a5psw_port_bridge_join, .port_bridge_leave = a5psw_port_bridge_leave,
drivers/net/dsa/rzn1_a5psw.h +45 -1
58 lines not on this page · raw message
Signature · 1 line
2.34.1
Clément Léger
maintainerPATCH v3 8/12 net: dsa: rzn1-a5psw: add FDB support
In reply to Clément LégerThis commits add forwarding database support to the driver. It implements fdb_add(), fdb_del() and fdb_dump().
--- drivers/net/dsa/rzn1_a5psw.c | 167 +++++++++++++++++++++++++++++++++++ drivers/net/dsa/rzn1_a5psw.h | 17 ++++ 2 files changed, 184 insertions(+)
drivers/net/dsa/rzn1_a5psw.c +167 -0
@@ -377,6 +377,170 @@ static void a5psw_port_fast_age(struct dsa_switch *ds, int port)a5psw_port_fdb_flush (a5psw, port); } +static int a5psw_lk_execute_lookup (struct a5psw *a5psw,union lk_data *lk_data, +u16 *entry) +{ +u32 ctrl; +int ret; + +a5psw_reg_writel (a5psw,A5PSW_LK_DATA_LO , lk_data->lo); +a5psw_reg_writel (a5psw,A5PSW_LK_DATA_HI , lk_data->hi); + + ctrl =A5PSW_LK_ADDR_CTRL_LOOKUP ; + ret =a5psw_lk_execute_ctrl (a5psw, &ctrl); +if (ret) +return ret; + + *entry = ctrl &A5PSW_LK_ADDR_CTRL_ADDRESS ; + +return 0 ; +} + +static int a5psw_port_fdb_add (struct dsa_switch *ds,int port, +const unsigned char *addr,u16 vid, +struct dsa_db db) +{ +struct a5psw *a5psw = ds->priv; +union lk_data lk_data = {0 }; +bool inc_learncount = false; +int ret =0 ; +u16 entry; +u32 reg; + +ether_addr_copy (lk_data.entry.mac, addr); + lk_data.entry.port_mask =BIT (port); + +spin_lock (&a5psw->lk_lock); + +/* Set the value to be written in the lookup table */ + ret =a5psw_lk_execute_lookup (a5psw, &lk_data, &entry); +if (ret) + goto lk_unlock; + + lk_data.hi =a5psw_reg_readl (a5psw,A5PSW_LK_DATA_HI ); +if (!lk_data.entry.valid) { + inc_learncount = true; +/* port_mask set to 0x1f when entry is not valid, clear it */ + lk_data.entry.port_mask =0 ; + lk_data.entry.prio =0 ; + } + + lk_data.entry.port_mask |=BIT (port); + lk_data.entry.is_static =1 ; + lk_data.entry.valid =1 ; + +a5psw_reg_writel (a5psw,A5PSW_LK_DATA_HI , lk_data.hi); + + reg =A5PSW_LK_ADDR_CTRL_WRITE | entry; + ret =a5psw_lk_execute_ctrl (a5psw, ®); +if (ret) + goto lk_unlock; + +if (inc_learncount) { + reg =A5PSW_LK_LEARNCOUNT_MODE_INC ; +a5psw_reg_writel (a5psw,A5PSW_LK_LEARNCOUNT , reg); + } + +lk_unlock: +spin_unlock (&a5psw->lk_lock); + +return ret; +} + +static int a5psw_port_fdb_del (struct dsa_switch *ds,int port, +const unsigned char *addr,u16 vid, +struct dsa_db db) +{ +struct a5psw *a5psw = ds->priv; +union lk_data lk_data = {0 }; +bool clear = false; +int ret =0 ; +u16 entry; +u32 reg; + +ether_addr_copy (lk_data.entry.mac, addr); + +spin_lock (&a5psw->lk_lock); + + ret =a5psw_lk_execute_lookup (a5psw, &lk_data, &entry); +if (ret) { +dev_err (a5psw->dev,"Failed to lookup mac address\n" ); + goto lk_unlock; + } + + lk_data.hi =a5psw_reg_readl (a5psw,A5PSW_LK_DATA_HI ); +if (!lk_data.entry.valid) { +dev_err (a5psw->dev,"Tried to remove non-existing entry\n" ); + ret = -ENOENT ; + goto lk_unlock; + } + + lk_data.entry.port_mask &= ~BIT (port); +/* If there is no more port in the mask, clear the entry */ +if (lk_data.entry.port_mask ==0 ) + clear = true; + +a5psw_reg_writel (a5psw,A5PSW_LK_DATA_HI , lk_data.hi); + + reg = entry; +if (clear) + reg |=A5PSW_LK_ADDR_CTRL_CLEAR ; +else + reg |=A5PSW_LK_ADDR_CTRL_WRITE ; + + ret =a5psw_lk_execute_ctrl (a5psw, ®); +if (ret) + goto lk_unlock; + +/* Decrement LEARNCOUNT */ +if (clear) { + reg =A5PSW_LK_LEARNCOUNT_MODE_DEC ; +a5psw_reg_writel (a5psw,A5PSW_LK_LEARNCOUNT , reg); + } + +lk_unlock: +spin_unlock (&a5psw->lk_lock); + +return ret; +} + +static int a5psw_port_fdb_dump (struct dsa_switch *ds,int port, +dsa_fdb_dump_cb_t *cb,void *data) +{ +struct a5psw *a5psw = ds->priv; +union lk_data lk_data; +int i =0 , ret; +u32 reg; + +for (i =0 ; i <A5PSW_TABLE_ENTRIES ; i++) { + reg =A5PSW_LK_ADDR_CTRL_READ |A5PSW_LK_ADDR_CTRL_WAIT | i; +spin_lock (&a5psw->lk_lock); + + ret =a5psw_lk_execute_ctrl (a5psw, ®); +if (ret) { +spin_unlock (&a5psw->lk_lock); +return ret; + } + + lk_data.hi =a5psw_reg_readl (a5psw,A5PSW_LK_DATA_HI ); +/* If entry is not valid or does not contain the port, skip */ +if (!lk_data.entry.valid || + !(lk_data.entry.port_mask &BIT (port))) { +spin_unlock (&a5psw->lk_lock); +continue ; + } + + lk_data.lo =a5psw_reg_readl (a5psw,A5PSW_LK_DATA_LO ); +spin_unlock (&a5psw->lk_lock); + + ret =cb (lk_data.entry.mac,0 , lk_data.entry.is_static, data); +if (ret) +return ret; + } + +return 0 ; +} +static u64 a5psw_read_stat (struct a5psw *a5psw,u32 offset,int port) {u32 reg_lo, reg_hi;
@@ -593,6 +757,9 @@ static const struct dsa_switch_ops a5psw_switch_ops = { .port_bridge_leave = a5psw_port_bridge_leave, .port_stp_state_set = a5psw_port_stp_state_set, .port_fast_age = a5psw_port_fast_age, + .port_fdb_add = a5psw_port_fdb_add, + .port_fdb_del = a5psw_port_fdb_del, + .port_fdb_dump = a5psw_port_fdb_dump, };static int a5psw_mdio_wait_busy (struct a5psw *a5psw)
drivers/net/dsa/rzn1_a5psw.h +17 -0
@@ -212,6 +212,23 @@#define A5PSW_CTRL_TIMEOUT 1000#define A5PSW_TABLE_ENTRIES 8192 +struct fdb_entry { +u8 mac[ETH_ALEN ]; +u16 valid:1 ; +u16 is_static:1 ; +u16 prio:3 ; +u16 port_mask:5 ; +u16 reserved:6 ; +} __packed; + +union lk_data { +struct { +u32 lo; +u32 hi; + }; +struct fdb_entry entry; +}; +/** * struct a5psw - switch struct * @base: Base address of the switch
Signature · 1 line
2.34.1
Vladimir Oltean
maintainerRe: [PATCH net-next v3 08/12] net: dsa: rzn1-a5psw: add FDB support
Quoted 16 lines · Clément Léger
drivers/net/dsa/rzn1_a5psw.c +16
-0+static int a5psw_port_fdb_del (struct dsa_switch *ds,int port, +const unsigned char *addr,u16 vid, +struct dsa_db db) +{ +struct a5psw *a5psw = ds->priv; +union lk_data lk_data = {0 }; +bool clear = false; +int ret =0 ; +u16 entry; +u32 reg; + +ether_addr_copy (lk_data.entry.mac, addr); + +spin_lock (&a5psw->lk_lock); + + ret =a5psw_lk_execute_lookup (a5psw, &lk_data, &entry);
drivers/net/dsa/rzn1_a5psw.c static void a5psw_port_fast_age(struct dsa_switch *ds, int port) · line 475
Quoted 10 lines
drivers/net/dsa/rzn1_a5psw.c +10
-0+if (ret) { +dev_err (a5psw->dev,"Failed to lookup mac address\n" ); + goto lk_unlock; + } + + lk_data.hi =a5psw_reg_readl (a5psw,A5PSW_LK_DATA_HI ); +if (!lk_data.entry.valid) { +dev_err (a5psw->dev,"Tried to remove non-existing entry\n" ); + ret = -ENOENT ; + goto lk_unlock;
These error messages can happen under quite normal use with your hardware. For example:
ip link add br0 type bridge && ip link set br0 master br0 bridge fdb add dev swp0 00:01:02:03:04:05 vid 1 master static bridge fdb add dev swp0 00:01:02:03:04:05 vid 2 master static bridge fdb del dev swp0 00:01:02:03:04:05 vid 2 master static bridge fdb del dev swp0 00:01:02:03:04:05 vid 1 master static
Because the driver ignores the VID, then as soon as the VID 2 FDB entry is removed, the VID 1 FDB entry doesn't exist anymore, either.
The above is a bit artificial. More practically, the bridge installs local FDB entries (MAC address of bridge device, MAC addresses of ports) once in the VLAN-unaware database (VID 0), and once per VLAN installed on br0.
When the MAC address of br0 is different from that of the ports, and it is changed by the user, you'll get these errors too, since those changes translate into a deletion of the old local FDB entries (installed as FDB entries towards the CPU port). Do you want the users to see them and think something is wrong? I mean, something _is_ wrong (the hardware), but you have to work with that somehow.
Quoted 30 lines
drivers/net/dsa/rzn1_a5psw.c +30
-0+ } + + lk_data.entry.port_mask &= ~BIT (port); +/* If there is no more port in the mask, clear the entry */ +if (lk_data.entry.port_mask ==0 ) + clear = true; + +a5psw_reg_writel (a5psw,A5PSW_LK_DATA_HI , lk_data.hi); + + reg = entry; +if (clear) + reg |=A5PSW_LK_ADDR_CTRL_CLEAR ; +else + reg |=A5PSW_LK_ADDR_CTRL_WRITE ; + + ret =a5psw_lk_execute_ctrl (a5psw, ®); +if (ret) + goto lk_unlock; + +/* Decrement LEARNCOUNT */ +if (clear) { + reg =A5PSW_LK_LEARNCOUNT_MODE_DEC ; +a5psw_reg_writel (a5psw,A5PSW_LK_LEARNCOUNT , reg); + } + +lk_unlock: +spin_unlock (&a5psw->lk_lock); + +return ret; +}
Clément Léger
maintainerRe: [PATCH net-next v3 08/12] net: dsa: rzn1-a5psw: add FDB support
Quoted 31 lines · Vladimir Oltean
Quoted 16 lines · Clément Léger
drivers/net/dsa/rzn1_a5psw.c +16
-0+static int a5psw_port_fdb_del (struct dsa_switch *ds,int port, +const unsigned char *addr,u16 vid, +struct dsa_db db) +{ +struct a5psw *a5psw = ds->priv; +union lk_data lk_data = {0 }; +bool clear = false; +int ret =0 ; +u16 entry; +u32 reg; + +ether_addr_copy (lk_data.entry.mac, addr); + +spin_lock (&a5psw->lk_lock); + + ret =a5psw_lk_execute_lookup (a5psw, &lk_data, &entry);drivers/net/dsa/rzn1_a5psw.c static void a5psw_port_fast_age(struct dsa_switch *ds, int port) · line 475
Quoted 10 lines
drivers/net/dsa/rzn1_a5psw.c +10
-0+if (ret) { +dev_err (a5psw->dev,"Failed to lookup mac address\n" ); + goto lk_unlock; + } + + lk_data.hi =a5psw_reg_readl (a5psw,A5PSW_LK_DATA_HI ); +if (!lk_data.entry.valid) { +dev_err (a5psw->dev,"Tried to remove non-existing entry\n" ); + ret = -ENOENT ; + goto lk_unlock;These error messages can happen under quite normal use with your hardware. For example:
Quoted 8 lines
ip link add br0 type bridge && ip link set br0 master br0 bridge fdb add dev swp0 00:01:02:03:04:05 vid 1 master static bridge fdb add dev swp0 00:01:02:03:04:05 vid 2 master static bridge fdb del dev swp0 00:01:02:03:04:05 vid 2 master static bridge fdb del dev swp0 00:01:02:03:04:05 vid 1 master static
Because the driver ignores the VID, then as soon as the VID 2 FDB entry is removed, the VID 1 FDB entry doesn't exist anymore, either.
Argh did not thought about that but indeed, that will for sure trigger the error.
Quoted 5 lines
The above is a bit artificial. More practically, the bridge installs local FDB entries (MAC address of bridge device, MAC addresses of ports) once in the VLAN-unaware database (VID 0), and once per VLAN installed on br0.
Ok, seems clear.
Quoted 7 lines
When the MAC address of br0 is different from that of the ports, and it is changed by the user, you'll get these errors too, since those changes translate into a deletion of the old local FDB entries (installed as FDB entries towards the CPU port). Do you want the users to see them and think something is wrong? I mean, something _is_ wrong (the hardware), but you have to work with that somehow.
Indeed, I'll simply remove these error message. Should I still return an error value however ? Seems like I should not to avoid triggering any error that might confuse the user.
Signature · 3 lines
Clément Léger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com
Vladimir Oltean
maintainerRe: [PATCH net-next v3 08/12] net: dsa: rzn1-a5psw: add FDB support
Quoted 3 lines · Clément Léger
Indeed, I'll simply remove these error message. Should I still return an error value however ? Seems like I should not to avoid triggering any error that might confuse the user.
The error code will not be propagated to the bridge driver anyway, but will trigger prints in dsa_slave_switchdev_event_work() however.
You have to choose between 2 alternatives
(a) keep the FDB entry around until it gets removed from all VLANs
(b) delete the FDB entry as soon as it gets removed from the first VLAN
Both options are going to raise eyebrows. (a) will result in "huh, why did my packet get delivered to this port when the address wasn't in the FDB?", while (b) will result in "huh, why was my packet flooded when the address was in the FDB?"
And since (b) is of lower complexity than (a), I'd just silently exit, maybe add a comment explaining why, and hope for the best.
Clément Léger
maintainerPATCH v3 9/12 ARM: dts: r9a06g032: describe MII converter
In reply to Clément LégerAdd the MII converter node which describes the MII converter that is present on the RZ/N1 SoC.
--- arch/arm/boot/dts/r9a06g032.dtsi | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/arm/boot/dts/r9a06g032.dtsi +38 -0
@@ -201,6 +201,44 @@ nand_controller: nand-controller@40102000 { status = "disabled"; }; + eth_miic: eth-miic@44030000 { + compatible = "renesas,r9a06g032-miic", "renesas,rzn1-miic"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x44030000 0x10000>; + clocks = <&sysctrl R9A06G032_CLK_MII_REF>, + <&sysctrl R9A06G032_CLK_RGMII_REF>, + <&sysctrl R9A06G032_CLK_RMII_REF>, + <&sysctrl R9A06G032_HCLK_SWITCH_RG>; + power-domains = <&sysctrl>; + status = "disabled"; + + mii_conv1: mii-conv@1 { + reg = <1>; + status = "disabled"; + }; + + mii_conv2: mii-conv@2 { + reg = <2>; + status = "disabled"; + }; + + mii_conv3: mii-conv@3 { + reg = <3>; + status = "disabled"; + }; + + mii_conv4: mii-conv@4 { + reg = <4>; + status = "disabled"; + }; + + mii_conv5: mii-conv@5 { + reg = <5>; + status = "disabled"; + }; + }; + gic: interrupt-controller@44101000 { compatible = "arm,gic-400", "arm,cortex-a7-gic"; interrupt-controller;
Signature · 1 line
2.34.1
Clément Léger
maintainerPATCH v3 10/12 ARM: dts: r9a06g032: describe GMAC2
In reply to Clément LégerRZ/N1 SoC includes two MAC named GMACx that are compatible with the "snps,dwmac" driver. GMAC1 is connected directly to the MII converter port 1. GMAC2 however can be used as the MAC for the switch CPU management port or can be muxed to be connected directly to the MII converter port 2. This commit add description for the GMAC2 which will be used by the switch description.
--- arch/arm/boot/dts/r9a06g032.dtsi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
arch/arm/boot/dts/r9a06g032.dtsi +17 -0
@@ -201,6 +201,23 @@ nand_controller: nand-controller@40102000 { status = "disabled"; }; + gmac2: ethernet@44002000 { + compatible = "snps,dwmac"; + reg = <0x44002000 0x2000>; + interrupt-parent = <&gic>; + interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "macirq", "eth_wake_irq", "eth_lpi"; + clock-names = "stmmaceth"; + clocks = <&sysctrl R9A06G032_HCLK_GMAC1>; + snps,multicast-filter-bins = <256>; + snps,perfect-filter-entries = <128>; + tx-fifo-depth = <2048>; + rx-fifo-depth = <4096>; + status = "disabled"; + }; + eth_miic: eth-miic@44030000 { compatible = "renesas,r9a06g032-miic", "renesas,rzn1-miic"; #address-cells = <1>;
Signature · 1 line
2.34.1
Clément Léger
maintainerPATCH v3 11/12 ARM: dts: r9a06g032: describe switch
In reply to Clément LégerAdd description of the switch that is present on the RZ/N1 SoC.
--- arch/arm/boot/dts/r9a06g032.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/r9a06g032.dtsi +9 -0
@@ -256,6 +256,15 @@ mii_conv5: mii-conv@5 { }; }; + switch: switch@44050000 { + compatible = "renesas,r9a06g032-a5psw", "renesas,rzn1-a5psw"; + reg = <0x44050000 0x10000>; + clocks = <&sysctrl R9A06G032_HCLK_SWITCH>, + <&sysctrl R9A06G032_CLK_SWITCH>; + clock-names = "hclk", "clk"; + status = "disabled"; + }; + gic: interrupt-controller@44101000 { compatible = "arm,gic-400", "arm,cortex-a7-gic"; interrupt-controller;
Signature · 1 line
2.34.1
Clément Léger
maintainerPATCH v3 12/12 MAINTAINERS: add Renesas RZ/N1 switch related driver entry
In reply to Clément LégerAfter contributing the drivers, volunteer for maintenance and add myself as the maintainer for Renesas RZ/N1 switch related drivers.
--- MAINTAINERS | 11 +++++++++++ 1 file changed, 11 insertions(+)
MAINTAINERS +11 -0
@@ -16872,6 +16872,17 @@ S: Supported F: Documentation/devicetree/bindings/iio/adc/renesas,rzg2l-adc.yaml F: drivers/iio/adc/rzg2l_adc.c +RENESAS RZ/N1 A5PSW SWITCH DRIVER +M: Clément Léger <[email protected]> +S: Maintained +F: Documentation/devicetree/bindings/net/dsa/renesas,rzn1-a5psw.yaml +F: Documentation/devicetree/bindings/net/pcs/renesas,rzn1-miic.yaml +F: drivers/net/dsa/rzn1_a5psw* +F: drivers/net/pcs/pcs-rzn1-miic.c +F: include/dt-bindings/net/pcs-rzn1-miic.h +F: include/linux/pcs-rzn1-miic.h +F: net/dsa/tag_rzn1_a5psw.c + RENESAS R-CAR GEN3 & RZ/N1 NAND CONTROLLER DRIVER M: Miquel Raynal <[email protected]> L: [email protected]
Signature · 1 line
2.34.1
Hi Clément,
Quoted 3 lines · Clément Léger
This series needs commits
bcfb459b25b8and542d5835e4f6which are on the renesas-devel tree in order to enable generic power domain on RZ/N1.
-ENOENT
I assume you mean:14f11da778ff6421 ("soc: renesas: rzn1: Select PM and PM_GENERIC_DOMAINS configs")ed66b37f916ee23b ("ARM: dts: r9a06g032: Add missing '#power-domain-cells'")
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Clément Léger
maintainerQuoted 7 lines · Geert Uytterhoeven
Hi Clément,
Quoted 3 lines · Clément Léger
This series needs commits
bcfb459b25b8and542d5835e4f6which are on the renesas-devel tree in order to enable generic power domain on RZ/N1.
Quoted 6 lines
-ENOENTI assume you mean:
14f11da778ff6421("soc: renesas: rzn1: Select PM andPM_GENERIC_DOMAINSconfigs")ed66b37f916ee23b("ARM: dts: r9a06g032: Add missing '#power-domain-cells'")
Yep totally, did use my cherry-picked sha1 -_-'. Will fix that, sorry.
Quoted 11 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Signature · 3 lines
Clément Léger, Embedded Linux and Kernel engineer at Bootlin https://bootlin.com