Adding the Sparx5i Switch Driver
Subsystems (5)
Steen Hegelund
maintainerv5 cover Adding the Sparx5i Switch Driver
This series provides the Microchip Sparx5i Switch Driver
The SparX-5 Enterprise Ethernet switch family provides a rich set of Enterprise switching features such as advanced TCAM-based VLAN and QoS processing enabling delivery of differentiated services, and security through TCAMbased frame processing using versatile content aware processor (VCAP). IPv4/IPv6 Layer 3 (L3) unicast and multicast routing is supported with up to 18K IPv4/9K IPv6 unicast LPM entries and up to 9K IPv4/3K IPv6 (S,G) multicast groups. L3 security features include source guard and reverse path forwarding (uRPF) tasks. Additional L3 features include VRF-Lite and IP tunnels (IP over GRE/IP).
The SparX-5 switch family features a highly flexible set of Ethernet ports with support for 10G and 25G aggregation links, QSGMII, USGMII, and USXGMII. The device integrates a powerful 1 GHz dual-core ARM® Cortex®-A53 CPU enabling full management of the switch and advanced Enterprise applications.
The SparX-5 switch family targets managed Layer 2 and Layer 3 equipment in SMB, SME, and Enterprise where high port count 1G/2.5G/5G/10G switching with 10G/25G aggregation links is required.
The SparX-5 switch family consists of following SKUs:
VSC7546 SparX-5-64 supports up to 64 Gbps of bandwidth with the following primary port configurations.
- 6 ×10G
- 16 × 2.5G + 2 × 10G
- 24 × 1G + 4 × 10G
VSC7549 SparX-5-90 supports up to 90 Gbps of bandwidth with the following primary port configurations.
- 9 × 10G
- 16 × 2.5G + 4 × 10G
- 48 × 1G + 4 × 10G
VSC7552 SparX-5-128 supports up to 128 Gbps of bandwidth with the following primary port configurations.
- 12 × 10G
- 6 x 10G + 2 x 25G
- 16 × 2.5G + 8 × 10G
- 48 × 1G + 8 × 10G
VSC7556 SparX-5-160 supports up to 160 Gbps of bandwidth with the following primary port configurations.
- 16 × 10G
- 10 × 10G + 2 × 25G
- 16 × 2.5G + 10 × 10G
- 48 × 1G + 10 × 10G
VSC7558 SparX-5-200 supports up to 200 Gbps of bandwidth with the following primary port configurations.
- 20 × 10G
- 8 × 25G
In addition, the device supports one 10/100/1000/2500/5000 Mbps SGMII/SerDes node processor interface (NPI) Ethernet port.
Time sensitive networking (TSN) is supported through a comprehensive set of features including frame preemption, cut-through, frame replication and elimination for reliability, enhanced scheduling: credit-based shaping, time-aware shaping, cyclic queuing, and forwarding, and per-stream policing and filtering.
Together with IEEE 1588 and IEEE 802.1AS support, this guarantees low-latency deterministic networking for Industrial Ethernet.
The Sparx5i support is developed on the PCB134 and PCB135 evaluation boards.
- PCB134 main networking features:
- 12x SFP+ front 10G module slots (connected to Sparx5i through SFI).
- 8x SFP28 front 25G module slots (connected to Sparx5i through SFI high
speed).
- Optional, one additional 10/100/1000BASE-T (RJ45) Ethernet port (on-board VSC8211 PHY connected to Sparx5i through SGMII).
- PCB135 main networking features:
- 48x1G (10/100/1000M) RJ45 front ports using 12xVSC8514 QuadPHY’s each connected to VSC7558 through QSGMII.
- 4x10G (1G/2.5G/5G/10G) RJ45 front ports using the AQR407 10G QuadPHY each port connects to VSC7558 through SFI.
- 4x SFP28 25G module slots on back connected to VSC7558 through SFI high speed.
- Optional, one additional 1G (10/100/1000M) RJ45 port using an on-board VSC8211 PHY, which can be connected to VSC7558 NPI port through SGMII using a loopback add-on PCB)
This series provides support for:
- SFPs and DAC cables via PHYLINK with a number of 5G, 10G and 25G devices and media types.
- Port module configuration for 10M to 25G speeds with SGMII, QSGMII, 1000BASEX, 2500BASEX and 10GBASER as appropriate for these modes.
- SerDes configuration via the Sparx5i SerDes driver (see below).
- Host mode providing register based injection and extraction.
- Switch mode providing MAC/VLAN table learning and Layer2 switching offloaded to the Sparx5i switch.
- STP state, VLAN support, host/bridge port mode, Forwarding DB, and configuration and statistics via ethtool.
More support will be added at a later stage.
The Sparx5i Chip Register Model can be browsed at this location:
https://github.com/microchip-ung/sparx-5_reginfo
and the datasheet is available here:
https://ww1.microchip.com/downloads/en/DeviceDoc/SparX-5_Family_L2L3_Enterprise_10G_Ethernet_Switches_Datasheet_00003822B.pdf
The series depends on the following series currently on their way into the kernel:
- 25G Base-R phy mode
- Sparx5 Reset Driver
ChangeLog:
v5:
- cover letter
- updated the description to match the latest data sheets
- basic driver
- added error message in case of reset controller error
- port struct: replacing has_sfp with inband, adding pause_adv
- host mode
- port cleanup: unregisters netdevs and then removes phylink etc
- checking for pause_adv when comparing port config changes
- getting duplex and pause state in the link_up callback.
- getting inband, autoneg and pause_adv config in the pcs_config callback.
- port
- use only the pause_adv bits when getting aneg status
- use the inband state when updating the PCS and port config
v4:
- basic driver:
Using devm_reset_control_get_optional_shared to get the reset control, and let the reset framework check if it is valid.
- host mode (phylink):
Use the PCS operations to get state and update configuration. Removed the setting of interface modes. Let phylink control this. Using the new 5gbase-r and 25gbase-r modes.
Using a helper function to check if one of the 3 base-r modes has been selected.
Currently it will not be possible to change the interface mode by changing the speed (e.g via ethtool). This will be added later.
v3:
- basic driver:
- removed unneeded braces
- release reference to ports node after use
- use dev_err_probe to handle DEFER
- update error value when bailing out (a few cases)
- updated formatting of port struct and grouping of bool values
- simplified the spx5_rmw and spx5_inst_rmw inline functions
- host mode (netdev):
- removed lockless flag
- added port timer init
- host mode (packet - manual injection):
- updated error counters in error situations
- implemented timer handling of watermark threshold: stop and restart netif queues.
- fixed error message handling (rate limited)
- fixed comment style error
- used DIV_ROUND_UP macro
- removed a debug message for open ports
v2:
- Updated bindings:
- drop minItems for the reg property
- Statistics implementation:
- Reorganized statistics into ethtool groups:
eth-phy, eth-mac, eth-ctrl, rmon
as defined by the IEEE 802.3 categories and RFC 2819.
- The remaining statistics are provided by the classic ethtool statistics command.
- Hostmode support:
- Removed netdev renaming
- Validate ethernet address in sparx5_set_mac_address()
Steen Hegelund (10):
dt-bindings: net: sparx5: Add sparx5-switch bindings
net: sparx5: add the basic sparx5 driver
net: sparx5: add hostmode with phylink support
net: sparx5: add port module support
net: sparx5: add mactable support
net: sparx5: add vlan support
net: sparx5: add switching support
net: sparx5: add calendar bandwidth allocation support
net: sparx5: add ethtool configuration and statistics support
arm64: dts: sparx5: Add the Sparx5 switch node
.../bindings/net/microchip,sparx5-switch.yaml | 226 + arch/arm64/boot/dts/microchip/sparx5.dtsi | 94 +- .../dts/microchip/sparx5_pcb134_board.dtsi | 481 +- .../dts/microchip/sparx5_pcb135_board.dtsi | 621 ++- drivers/net/ethernet/microchip/Kconfig | 2 + drivers/net/ethernet/microchip/Makefile | 2 + drivers/net/ethernet/microchip/sparx5/Kconfig | 9 + .../net/ethernet/microchip/sparx5/Makefile | 10 + .../microchip/sparx5/sparx5_calendar.c | 596 +++ .../microchip/sparx5/sparx5_ethtool.c | 1227 +++++ .../microchip/sparx5/sparx5_mactable.c | 500 ++ .../ethernet/microchip/sparx5/sparx5_main.c | 852 +++ .../ethernet/microchip/sparx5/sparx5_main.h | 375 ++ .../microchip/sparx5/sparx5_main_regs.h | 4642 +++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_netdev.c | 264 + .../ethernet/microchip/sparx5/sparx5_packet.c | 320 ++ .../microchip/sparx5/sparx5_phylink.c | 210 + .../ethernet/microchip/sparx5/sparx5_port.c | 1146 ++++ .../ethernet/microchip/sparx5/sparx5_port.h | 93 + .../microchip/sparx5/sparx5_switchdev.c | 508 ++ .../ethernet/microchip/sparx5/sparx5_vlan.c | 224 + 21 files changed, 12318 insertions(+), 84 deletions(-) create mode 100644 Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml create mode 100644 drivers/net/ethernet/microchip/sparx5/Kconfig create mode 100644 drivers/net/ethernet/microchip/sparx5/Makefile create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_main.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_main.h create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_port.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_port.h create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 1/10 dt-bindings: net: sparx5: Add sparx5-switch bindings
Document the Sparx5 switch device driver bindings
--- .../bindings/net/microchip,sparx5-switch.yaml | 226 ++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml
Documentation/devicetree/bindings/net/microchip,sparx5-switch.yaml new file +226 -0
@@ -0,0 +1,226 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/microchip,sparx5-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip Sparx5 Ethernet switch controller + +maintainers: + - Steen Hegelund <[email protected]> + - Lars Povlsen <[email protected]> + +description: | + The SparX-5 Enterprise Ethernet switch family provides a rich set of + Enterprise switching features such as advanced TCAM-based VLAN and + QoS processing enabling delivery of differentiated services, and + security through TCAM-based frame processing using versatile content + aware processor (VCAP). + + IPv4/IPv6 Layer 3 (L3) unicast and multicast routing is supported + with up to 18K IPv4/9K IPv6 unicast LPM entries and up to 9K IPv4/3K + IPv6 (S,G) multicast groups. + + L3 security features include source guard and reverse path + forwarding (uRPF) tasks. Additional L3 features include VRF-Lite and + IP tunnels (IP over GRE/IP). + + The SparX-5 switch family targets managed Layer 2 and Layer 3 + equipment in SMB, SME, and Enterprise where high port count + 1G/2.5G/5G/10G switching with 10G/25G aggregation links is required. + +properties: + $nodename: + pattern: "^switch@[0-9a-f]+$" + + compatible: + const: microchip,sparx5-switch + + reg: + items: + - description: cpu target + - description: devices target + - description: general control block target + + reg-names: + items: + - const: cpu + - const: devices + - const: gcb + + interrupts: + minItems: 1 + items: + - description: register based extraction + - description: frame dma based extraction + + interrupt-names: + minItems: 1 + items: + - const: xtr + - const: fdma + + resets: + items: + - description: Reset controller used for switch core reset (soft reset) + + reset-names: + items: + - const: switch + + mac-address: true + + ethernet-ports: + type: object + patternProperties: + "^port@[0-9a-f]+$": + type: object + + properties: + '#address-cells': + const: 1 + '#size-cells': + const: 0 + + reg: + description: Switch port number + + phys: + maxItems: 1 + description: + phandle of a Ethernet SerDes PHY. This defines which SerDes + instance will handle the Ethernet traffic. + + phy-mode: + description: + This specifies the interface used by the Ethernet SerDes towards + the PHY or SFP. + + microchip,bandwidth: + description: Specifies bandwidth in Mbit/s allocated to the port. + $ref: "/schemas/types.yaml#/definitions/uint32" + maximum: 25000 + + phy-handle: + description: + phandle of a Ethernet PHY. This is optional and if provided it + points to the cuPHY used by the Ethernet SerDes. + + sfp: + description: + phandle of an SFP. This is optional and used when not specifying + a cuPHY. It points to the SFP node that describes the SFP used by + the Ethernet SerDes. + + managed: true + + microchip,sd-sgpio: + description: + Index of the ports Signal Detect SGPIO in the set of 384 SGPIOs + This is optional, and only needed if the default used index is + is not correct. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 383 + + required: + - reg + - phys + - phy-mode + - microchip,bandwidth + + oneOf: + - required: + - phy-handle + - required: + - sfp + - managed + +required: + - compatible + - reg + - reg-names + - interrupts + - interrupt-names + - resets + - reset-names + - ethernet-ports + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + switch: switch@600000000 { + compatible = "microchip,sparx5-switch"; + reg = <0 0x401000>, + <0x10004000 0x7fc000>, + <0x11010000 0xaf0000>; + reg-names = "cpu", "devices", "gcb"; + interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "xtr"; + resets = <&reset 0>; + reset-names = "switch"; + ethernet-ports { + #address-cells = <1>; + #size-cells = <0>; + + port0: port@0 { + reg = <0>; + microchip,bandwidth = <1000>; + phys = <&serdes 13>; + phy-handle = <&phy0>; + phy-mode = "qsgmii"; + }; + /* ... */ + /* Then the 25G interfaces */ + port60: port@60 { + reg = <60>; + microchip,bandwidth = <25000>; + phys = <&serdes 29>; + phy-mode = "10gbase-r"; + sfp = <&sfp_eth60>; + managed = "in-band-status"; + microchip,sd-sgpio = <365>; + }; + port61: port@61 { + reg = <61>; + microchip,bandwidth = <25000>; + phys = <&serdes 30>; + phy-mode = "10gbase-r"; + sfp = <&sfp_eth61>; + managed = "in-band-status"; + microchip,sd-sgpio = <369>; + }; + port62: port@62 { + reg = <62>; + microchip,bandwidth = <25000>; + phys = <&serdes 31>; + phy-mode = "10gbase-r"; + sfp = <&sfp_eth62>; + managed = "in-band-status"; + microchip,sd-sgpio = <373>; + }; + port63: port@63 { + reg = <63>; + microchip,bandwidth = <25000>; + phys = <&serdes 32>; + phy-mode = "10gbase-r"; + sfp = <&sfp_eth63>; + managed = "in-band-status"; + microchip,sd-sgpio = <377>; + }; + /* Finally the Management interface */ + port64: port@64 { + reg = <64>; + microchip,bandwidth = <1000>; + phys = <&serdes 0>; + phy-handle = <&phy64>; + phy-mode = "sgmii"; + mac-address = [ 00 00 00 01 02 03 ]; + }; + }; + }; + +... +# vim: set ts=2 sw=2 sts=2 tw=80 et cc=80 ft=yaml :
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 2/10 net: sparx5: add the basic sparx5 driver
In reply to Steen HegelundThis adds the Sparx5 basic SwitchDev driver framework with IO range mapping, switch device detection and core clock configuration.
Support for ports, phylink, netdev, mactable etc. are in the following patches.
--- drivers/net/ethernet/microchip/Kconfig | 2 + drivers/net/ethernet/microchip/Makefile | 2 + drivers/net/ethernet/microchip/sparx5/Kconfig | 9 + .../net/ethernet/microchip/sparx5/Makefile | 8 + .../ethernet/microchip/sparx5/sparx5_main.c | 744 +++ .../ethernet/microchip/sparx5/sparx5_main.h | 273 + .../microchip/sparx5/sparx5_main_regs.h | 4642 +++++++++++++++++ 7 files changed, 5680 insertions(+) create mode 100644 drivers/net/ethernet/microchip/sparx5/Kconfig create mode 100644 drivers/net/ethernet/microchip/sparx5/Makefile create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_main.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_main.h create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h
drivers/net/ethernet/microchip/Kconfig +2 -0
@@ -54,4 +54,6 @@ config LAN743X To compile this driver as a module, choose M here. The module will be called lan743x. +source "drivers/net/ethernet/microchip/sparx5/Kconfig" + endif # NET_VENDOR_MICROCHIP
drivers/net/ethernet/microchip/Makefile +2 -0
@@ -8,3 +8,5 @@ obj-$(CONFIG_ENCX24J600) += encx24j600.o encx24j600-regmap.o obj-$(CONFIG_LAN743X) += lan743x.o lan743x-objs := lan743x_main.o lan743x_ethtool.o lan743x_ptp.o + +obj-$(CONFIG_SPARX5_SWITCH) += sparx5/
drivers/net/ethernet/microchip/sparx5/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config SPARX5_SWITCH + tristate "Sparx5 switch driver" + depends on NET_SWITCHDEV + depends on HAS_IOMEM + select PHYLINK + select PHY_SPARX5_SERDES + select RESET_CONTROLLER + help + This driver supports the Sparx5 network switch device.
drivers/net/ethernet/microchip/sparx5/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for the Microchip Sparx5 network device drivers. +# + +obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o + +sparx5-switch-objs := sparx5_main.o
drivers/net/ethernet/microchip/sparx5/sparx5_main.c new file +744 -0
744 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_main.h new file +273 -0
273 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_main_regs.h new file +4642 -0
1,955 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.32.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH net-next v5 02/10] net: sparx5: add the basic sparx5 driver
Quoted 9 lines · Steen Hegelund
This adds the Sparx5 basic SwitchDev driver framework with IO range mapping, switch device detection and core clock configuration.
Support for ports, phylink, netdev, mactable etc. are in the following patches.
Signed-off-by Steen Hegelund <[email protected]>Signed-off-by Bjarni Jonasson <[email protected]>Signed-off-by Lars Povlsen <[email protected]>
For the reset handling,
regards
Philipp
Steen Hegelund
maintainerPATCH v5 3/10 net: sparx5: add hostmode with phylink support
In reply to Steen HegelundThis patch adds netdevs and phylink support for the ports in the switch. It also adds register based injection and extraction for these ports.
Frame DMA support for injection and extraction will be added in a later series.
--- .../net/ethernet/microchip/sparx5/Makefile | 3 +- .../ethernet/microchip/sparx5/sparx5_main.c | 81 ++++- .../ethernet/microchip/sparx5/sparx5_main.h | 33 ++ .../ethernet/microchip/sparx5/sparx5_netdev.c | 221 ++++++++++++ .../ethernet/microchip/sparx5/sparx5_packet.c | 314 ++++++++++++++++++ .../microchip/sparx5/sparx5_phylink.c | 199 +++++++++++ 6 files changed, 841 insertions(+), 10 deletions(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c
drivers/net/ethernet/microchip/sparx5/Makefile +2 -1
@@ -5,4 +5,5 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o -sparx5-switch-objs := sparx5_main.o +sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ + sparx5_netdev.o sparx5_phylink.o
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +72 -9
134 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +33 -0
@@ -14,6 +14,7 @@#include <linux/if_vlan.h> #include <linux/bitmap.h> #include <linux/phylink.h> +#include <linux/hrtimer.h> /* Target chip type */ enum spx5_target_chiptype {
@@ -69,6 +70,9 @@ enum sparx5_vlan_port_type {#define SPX5_BUFFER_CELL_SZ 184/* Cell size */ #define SPX5_BUFFER_MEMORY 4194280/* 22795 words * 184 bytes */ +#define XTR_QUEUE 0 +#define INJ_QUEUE 0 +struct sparx5 ;struct sparx5_port_config {
@@ -93,6 +97,9 @@ struct sparx5_port {struct device_node *of_node;struct phy *serdes;struct sparx5_port_config conf; +struct phylink_config phylink_config; +struct phylink *phylink; +struct phylink_pcs phylink_pcs;u16 portno;/* Ingress default VLAN (pvid) */ u16 pvid;
@@ -107,6 +114,7 @@ struct sparx5_port {u32 custom_etype;u32 ifh[IFH_LEN ];bool vlan_aware; +struct hrtimer inj_timer; };enum sparx5_core_clockfreq {
@@ -130,8 +138,23 @@ struct sparx5 {u8 base_mac[ETH_ALEN ];/* Board specifics */ bool sd_sgpio_remapping; +/* Register based inj/xtr */ +int xtr_irq; }; +/* sparx5_packet.c */ +irqreturn_t sparx5_xtr_handler (int irq,void *_priv); +int sparx5_port_xmit_impl (struct sk_buff *skb,struct net_device *dev); +int sparx5_manual_injection_mode (struct sparx5 *sparx5); +void sparx5_port_inj_timer_setup (struct sparx5_port *port); + +/* sparx5_netdev.c */ +bool sparx5_netdevice_check (const struct net_device *dev); +struct net_device *sparx5_create_netdev (struct sparx5 *sparx5,u32 portno); +int sparx5_register_netdevs (struct sparx5 *sparx5); +void sparx5_destroy_netdevs (struct sparx5 *sparx5); +void sparx5_unregister_netdevs (struct sparx5 *sparx5); +/* Clock period in picoseconds */ static inline u32 sparx5_clk_period (enum sparx5_core_clockfreq cclock) {
@@ -146,6 +169,16 @@ static inline u32 sparx5_clk_period(enum sparx5_core_clockfreq cclock) } } +static inline bool sparx5_is_baser (phy_interface_t interface) +{ +return interface ==PHY_INTERFACE_MODE_5GBASER || + interface ==PHY_INTERFACE_MODE_10GBASER || + interface ==PHY_INTERFACE_MODE_25GBASER ; +} + +extern const struct phylink_mac_ops sparx5_phylink_mac_ops; +extern const struct phylink_pcs_ops sparx5_phylink_pcs_ops; +/* Calculate raw offset */ static inline __pure int spx5_offset(int id, int tinst, int tcnt, int gbase, int ginst,
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c new file +221 -0
221 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c new file +314 -0
314 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c new file +199 -0
199 lines not on this page · raw message
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 4/10 net: sparx5: add port module support
In reply to Steen HegelundThis add configuration of the Sparx5 port module instances.
Sparx5 has in total 65 logical ports (denoted D0 to D64) and 33 physical SerDes connections (S0 to S32). The 65th port (D64) is fixed allocated to SerDes0 (S0). The remaining 64 ports can in various multiplexing scenarios be connected to the remaining 32 SerDes using QSGMII, or USGMII or USXGMII extenders. 32 of the ports can have a 1:1 mapping to the 32 SerDes.
Some additional ports (D65 to D69) are internal to the device and do not connect to port modules or SerDes macros. For example, internal ports are used for frame injection and extraction to the CPU queues.
The 65 logical ports are split up into the following blocks.
- 13 x 5G ports (D0-D11, D64)
- 32 x 2G5 ports (D16-D47)
- 12 x 10G ports (D12-D15, D48-D55)
- 8 x 25G ports (D56-D63)
Each logical port supports different line speeds, and depending on the speeds supported, different port modules (MAC+PCS) are needed. A port supporting 5 Gbps, 10 Gbps, or 25 Gbps as maximum line speed, will have a DEV5G, DEV10G, or DEV25G module to support the 5 Gbps, 10 Gbps (incl 5 Gbps), or 25 Gbps (including 10 Gbps and 5 Gbps) speeds. As well as, it will have a shadow DEV2G5 port module to support the lower speeds (10/100/1000/2500Mbps). When a port needs to operate at lower speed and the shadow DEV2G5 needs to be connected to its corresponding SerDes
Not all interface modes are supported in this series, but will be added at a later stage.
--- .../net/ethernet/microchip/sparx5/Makefile | 2 +- .../ethernet/microchip/sparx5/sparx5_main.c | 9 +- .../ethernet/microchip/sparx5/sparx5_netdev.c | 14 +- .../microchip/sparx5/sparx5_phylink.c | 27 +- .../ethernet/microchip/sparx5/sparx5_port.c | 1146 +++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_port.h | 93 ++ 6 files changed, 1279 insertions(+), 12 deletions(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_port.c create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_port.h
drivers/net/ethernet/microchip/sparx5/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ - sparx5_netdev.o sparx5_phylink.o + sparx5_netdev.o sparx5_phylink.o sparx5_port.o
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +8 -1
@@ -26,6 +26,7 @@#include "sparx5_main_regs.h" #include "sparx5_main.h" +#include "sparx5_port.h" #define QLIM_WM (fraction) \ ((SPX5_BUFFER_MEMORY / SPX5_BUFFER_CELL_SZ - 100) * (fraction) / 100)
@@ -252,6 +253,7 @@ static int sparx5_create_port(struct sparx5 *sparx5,struct sparx5_port *spx5_port;struct net_device *ndev;struct phylink *phylink; +int err; ndev =sparx5_create_netdev (sparx5, config->portno);if (IS_ERR (ndev)) {
@@ -273,9 +275,14 @@ static int sparx5_create_port(struct sparx5 *sparx5, spx5_port->phylink_pcs.ops = &sparx5_phylink_pcs_ops; sparx5->ports[config->portno] = spx5_port; + err =sparx5_port_init (sparx5, spx5_port, &config->conf); +if (err) { +dev_err (sparx5->dev,"port init failed\n" ); +return err; + } spx5_port->conf = config->conf; -/* VLAN setup to be added in later patches */ +/* VLAN support to be added in later patches */ /* Create a phylink for PHY management. Also handles SFPs */ spx5_port->phylink_config.dev = &spx5_port->ndev->dev;
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +12 -2
@@ -6,6 +6,7 @@#include "sparx5_main_regs.h" #include "sparx5_main.h" +#include "sparx5_port.h" /* The IFH bit position of the first VSTAX bit. This is because the * VSTAX bit positions in Data sheet is starting from zero.
@@ -71,6 +72,7 @@ static int sparx5_port_open(struct net_device *ndev)struct sparx5_port *port =netdev_priv (ndev);int err =0 ; +sparx5_port_enable (port, true); err =phylink_of_phy_connect (port->phylink, port->of_node,0 );if (err) {netdev_err (ndev,"Could not attach to PHY\n" );
@@ -82,7 +84,10 @@ static int sparx5_port_open(struct net_device *ndev)if (!ndev->phydev) {/* power up serdes */ port->conf.power_down = false; - err =phy_power_on (port->serdes); +if (port->conf.serdes_reset) + err =sparx5_serdes_set (port->sparx5, port, &port->conf); +else + err =phy_power_on (port->serdes);if (err)netdev_err (ndev,"%s failed\n" , __func__); }
@@ -95,12 +100,17 @@ static int sparx5_port_stop(struct net_device *ndev)struct sparx5_port *port =netdev_priv (ndev);int err =0 ; +sparx5_port_enable (port, false);phylink_stop (port->phylink);phylink_disconnect_phy (port->phylink);if (!ndev->phydev) { +/* power down serdes */ port->conf.power_down = true; - err =phy_power_off (port->serdes); +if (port->conf.serdes_reset) + err =sparx5_serdes_set (port->sparx5, port, &port->conf); +else + err =phy_power_off (port->serdes);if (err)netdev_err (ndev,"%s failed\n" , __func__); }
drivers/net/ethernet/microchip/sparx5/sparx5_phylink.c +19 -8
@@ -12,6 +12,7 @@#include "sparx5_main_regs.h" #include "sparx5_main.h" +#include "sparx5_port.h" static bool port_conf_has_changed (struct sparx5_port_config *a,struct sparx5_port_config *b) {
@@ -115,6 +116,7 @@ static void sparx5_phylink_mac_link_up(struct phylink_config *config, {struct sparx5_port *port =netdev_priv (to_net_dev (config->dev));struct sparx5_port_config conf; +int err; conf = port->conf; conf.duplex = duplex;
@@ -122,7 +124,10 @@ static void sparx5_phylink_mac_link_up(struct phylink_config *config, conf.pause |= tx_pause ?MLO_PAUSE_TX :0 ; conf.pause |= rx_pause ?MLO_PAUSE_RX :0 ; conf.speed = speed; -/* Port configuration to be added later */ +/* Configure the port to speed/duplex/pause */ + err =sparx5_port_config (port->sparx5, port, &conf); +if (err) +netdev_err (port->ndev,"port config failed: %d\n" , err); } static void sparx5_phylink_mac_link_down(struct phylink_config *config,
@@ -140,12 +145,15 @@ static struct sparx5_port *sparx5_pcs_to_port(struct phylink_pcs *pcs)static void sparx5_pcs_get_state (struct phylink_pcs *pcs,struct phylink_link_state *state) { -/* Getting port status to be added later, just defaults now */ - state->link = true; - state->an_complete = true; - state->speed =SPEED_1000 ; - state->duplex = true; - state->pause =MLO_PAUSE_AN ; +struct sparx5_port *port =sparx5_pcs_to_port (pcs); +struct sparx5_port_status status; + +sparx5_get_port_status (port->sparx5, port, &status); + state->link = status.link && !status.link_down; + state->an_complete = status.an_complete; + state->speed = status.speed; + state->duplex = status.duplex; + state->pause = status.pause; } static int sparx5_pcs_config(struct phylink_pcs *pcs,
@@ -176,7 +184,10 @@ static int sparx5_pcs_config(struct phylink_pcs *pcs, }if (!port_conf_has_changed (&port->conf, &conf))return ret; -/* PCS configuration added later */ +/* Enable the PCS matching this interface type */ + ret =sparx5_port_pcs_set (port->sparx5, port, &conf); +if (ret) +netdev_err (port->ndev,"port PCS config failed: %d\n" , ret);return ret; }
drivers/net/ethernet/microchip/sparx5/sparx5_port.c new file +1146 -0
1,146 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_port.h new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 5/10 net: sparx5: add mactable support
In reply to Steen HegelundThis adds the Sparx5 MAC tables: listening for MAC table updates and updating on request.
--- .../net/ethernet/microchip/sparx5/Makefile | 2 +- .../microchip/sparx5/sparx5_mactable.c | 497 ++++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_main.c | 21 +- .../ethernet/microchip/sparx5/sparx5_main.h | 26 + .../ethernet/microchip/sparx5/sparx5_netdev.c | 21 + 5 files changed, 565 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c
drivers/net/ethernet/microchip/sparx5/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ - sparx5_netdev.o sparx5_phylink.o sparx5_port.o + sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o
drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c new file +497 -0
497 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +20 -1
@@ -558,6 +558,8 @@ static void sparx5_board_init(struct sparx5 *sparx5)static int sparx5_start (struct sparx5 *sparx5) { +u8 broadcast[ETH_ALEN ] = {0xff ,0xff ,0xff ,0xff ,0xff ,0xff }; +char queue_name[32 ];u32 idx;int err;
@@ -589,12 +591,29 @@ static int sparx5_start(struct sparx5 *sparx5)ANA_CL_FILTER_CTRL_FORCE_FCS_UPDATE_ENA , sparx5, ANA_CL_FILTER_CTRL(idx)); -/* MAC/VLAN support to be added in later patches */ +/* Init MAC table, ageing */ +sparx5_mact_init (sparx5); + +/* VLAN support to be added in later patches */ + +/* Add host mode BC address (points only to CPU) */ +sparx5_mact_learn (sparx5,PGID_CPU , broadcast,NULL_VID ); +/* Enable queue limitation watermarks */ sparx5_qlim_set (sparx5);/* Resource calendar support to be added in later patches */ +/* Init mact_sw struct */ +mutex_init (&sparx5->mact_lock); +INIT_LIST_HEAD (&sparx5->mact_entries); +snprintf (queue_name,sizeof (queue_name),"%s-mact" , +dev_name (sparx5->dev)); + sparx5->mact_queue =create_singlethread_workqueue (queue_name); +INIT_DELAYED_WORK (&sparx5->mact_work, sparx5_mact_pull_work); +queue_delayed_work (sparx5->mact_queue, &sparx5->mact_work, +SPX5_MACT_PULL_DELAY ); + err =sparx5_register_netdevs (sparx5);if (err)return err;
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +26 -0
@@ -135,7 +135,14 @@ struct sparx5 {/* port structures are in net device */ struct sparx5_port *ports[SPX5_PORTS ];enum sparx5_core_clockfreq coreclock; +/* Switch state */ u8 base_mac[ETH_ALEN ]; +/* SW MAC table */ +struct list_head mact_entries; +/* mac table list (mact_entries) mutex */ +struct mutex mact_lock; +struct delayed_work mact_work; +struct workqueue_struct *mact_queue;/* Board specifics */ bool sd_sgpio_remapping;/* Register based inj/xtr */
@@ -148,6 +155,25 @@ int sparx5_port_xmit_impl(struct sk_buff *skb, struct net_device *dev);int sparx5_manual_injection_mode (struct sparx5 *sparx5);void sparx5_port_inj_timer_setup (struct sparx5_port *port); +/* sparx5_mactable.c */ +void sparx5_mact_pull_work (struct work_struct *work); +int sparx5_mact_learn (struct sparx5 *sparx5,int port, +const unsigned char mac[ETH_ALEN ],u16 vid); +bool sparx5_mact_getnext (struct sparx5 *sparx5, +unsigned char mac[ETH_ALEN ],u16 *vid,u32 *pcfg2); +int sparx5_mact_forget (struct sparx5 *sparx5, +const unsigned char mac[ETH_ALEN ],u16 vid); +int sparx5_add_mact_entry (struct sparx5 *sparx5, +struct sparx5_port *port, +const unsigned char *addr,u16 vid); +int sparx5_del_mact_entry (struct sparx5 *sparx5, +const unsigned char *addr, +u16 vid); +int sparx5_mc_sync (struct net_device *dev,const unsigned char *addr); +int sparx5_mc_unsync (struct net_device *dev,const unsigned char *addr); +void sparx5_set_ageing (struct sparx5 *sparx5,int msecs); +void sparx5_mact_init (struct sparx5 *sparx5); +/* sparx5_netdev.c */ bool sparx5_netdevice_check (const struct net_device *dev);struct net_device *sparx5_create_netdev (struct sparx5 *sparx5,u32 portno);
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +21 -0
@@ -132,17 +132,37 @@ static int sparx5_port_get_phys_port_name(struct net_device *dev,static int sparx5_set_mac_address (struct net_device *dev,void *p) { +struct sparx5_port *port =netdev_priv (dev); +struct sparx5 *sparx5 = port->sparx5;const struct sockaddr *addr = p;if (!is_valid_ether_addr (addr->sa_data))return -EADDRNOTAVAIL ; +/* Remove current */ +sparx5_mact_forget (sparx5, dev->dev_addr, port->pvid); + +/* Add new */ +sparx5_mact_learn (sparx5,PGID_CPU , addr->sa_data, port->pvid); +/* Record the address */ ether_addr_copy (dev->dev_addr, addr->sa_data);return 0 ; } +static int sparx5_get_port_parent_id (struct net_device *dev, +struct netdev_phys_item_id *ppid) +{ +struct sparx5_port *sparx5_port =netdev_priv (dev); +struct sparx5 *sparx5 = sparx5_port->sparx5; + + ppid->id_len =sizeof (sparx5->base_mac); +memcpy (&ppid->id, &sparx5->base_mac, ppid->id_len); + +return 0 ; +} +static const struct net_device_ops sparx5_port_netdev_ops = { .ndo_open = sparx5_port_open, .ndo_stop = sparx5_port_stop,
@@ -150,6 +170,7 @@ static const struct net_device_ops sparx5_port_netdev_ops = { .ndo_get_phys_port_name = sparx5_port_get_phys_port_name, .ndo_set_mac_address = sparx5_set_mac_address, .ndo_validate_addr = eth_validate_addr, + .ndo_get_port_parent_id = sparx5_get_port_parent_id, };bool sparx5_netdevice_check (const struct net_device *dev)
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 6/10 net: sparx5: add vlan support
In reply to Steen HegelundThis adds Sparx5 VLAN support.
Sparx5 has more VLAN features than provided here, but these will be added in later series. For now we only add the basic L2 features.
--- .../net/ethernet/microchip/sparx5/Makefile | 2 +- .../ethernet/microchip/sparx5/sparx5_main.c | 10 +- .../ethernet/microchip/sparx5/sparx5_main.h | 14 ++ .../ethernet/microchip/sparx5/sparx5_vlan.c | 224 ++++++++++++++++++ 4 files changed, 246 insertions(+), 4 deletions(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c
drivers/net/ethernet/microchip/sparx5/Makefile +1 -1
@@ -6,4 +6,4 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ - sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o + sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o sparx5_vlan.o
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +7 -3
@@ -282,7 +282,8 @@ static int sparx5_create_port(struct sparx5 *sparx5, } spx5_port->conf = config->conf; -/* VLAN support to be added in later patches */ +/* Setup VLAN */ +sparx5_vlan_port_setup (sparx5, spx5_port->portno);/* Create a phylink for PHY management. Also handles SFPs */ spx5_port->phylink_config.dev = &spx5_port->ndev->dev;
@@ -578,7 +579,9 @@ static int sparx5_start(struct sparx5 *sparx5) sparx5, QFWD_SWITCH_PORT_MODE(idx)); -/* Forwarding masks to be added in later patches */ +/* Init masks */ +sparx5_update_fwd (sparx5); +/* CPU copy CPU pgids */ spx5_wr (ANA_AC_PGID_MISC_CFG_PGID_CPU_COPY_ENA_SET (1 ), sparx5,ANA_AC_PGID_MISC_CFG (PGID_CPU ));
@@ -594,7 +597,8 @@ static int sparx5_start(struct sparx5 *sparx5)/* Init MAC table, ageing */ sparx5_mact_init (sparx5); -/* VLAN support to be added in later patches */ +/* Setup VLANs */ +sparx5_vlan_init (sparx5);/* Add host mode BC address (points only to CPU) */ sparx5_mact_learn (sparx5,PGID_CPU , broadcast,NULL_VID );
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +14 -0
@@ -137,6 +137,10 @@ struct sparx5 {enum sparx5_core_clockfreq coreclock;/* Switch state */ u8 base_mac[ETH_ALEN ]; +/* Bridged interfaces */ +DECLARE_BITMAP (bridge_fwd_mask,SPX5_PORTS ); +DECLARE_BITMAP (bridge_lrn_mask,SPX5_PORTS ); +DECLARE_BITMAP (vlan_mask[VLAN_N_VID ],SPX5_PORTS );/* SW MAC table */ struct list_head mact_entries;/* mac table list (mact_entries) mutex */
@@ -174,6 +178,16 @@ int sparx5_mc_unsync(struct net_device *dev, const unsigned char *addr);void sparx5_set_ageing (struct sparx5 *sparx5,int msecs);void sparx5_mact_init (struct sparx5 *sparx5); +/* sparx5_vlan.c */ +void sparx5_pgid_update_mask (struct sparx5_port *port,int pgid,bool enable); +void sparx5_update_fwd (struct sparx5 *sparx5); +void sparx5_vlan_init (struct sparx5 *sparx5); +void sparx5_vlan_port_setup (struct sparx5 *sparx5,int portno); +int sparx5_vlan_vid_add (struct sparx5_port *port,u16 vid,bool pvid, +bool untagged); +int sparx5_vlan_vid_del (struct sparx5_port *port,u16 vid); +void sparx5_vlan_port_apply (struct sparx5 *sparx5,struct sparx5_port *port); +/* sparx5_netdev.c */ bool sparx5_netdevice_check (const struct net_device *dev);struct net_device *sparx5_create_netdev (struct sparx5 *sparx5,u32 portno);
drivers/net/ethernet/microchip/sparx5/sparx5_vlan.c new file +224 -0
224 lines not on this page · raw message
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 7/10 net: sparx5: add switching support
In reply to Steen HegelundThis adds SwitchDev support by hardware offloading the software bridge.
--- .../net/ethernet/microchip/sparx5/Makefile | 3 +- .../microchip/sparx5/sparx5_mactable.c | 3 + .../ethernet/microchip/sparx5/sparx5_main.c | 4 + .../ethernet/microchip/sparx5/sparx5_main.h | 11 + .../ethernet/microchip/sparx5/sparx5_netdev.c | 10 + .../ethernet/microchip/sparx5/sparx5_packet.c | 6 + .../microchip/sparx5/sparx5_switchdev.c | 508 ++++++++++++++++++ 7 files changed, 544 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c
drivers/net/ethernet/microchip/sparx5/Makefile +2 -1
@@ -6,4 +6,5 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ - sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o sparx5_vlan.o + sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o sparx5_vlan.o \ + sparx5_switchdev.o
drivers/net/ethernet/microchip/sparx5/sparx5_mactable.c +3 -0
@@ -371,6 +371,9 @@ static void sparx5_mact_handle_entry(struct sparx5 *sparx5,if (port >=SPX5_PORTS )return ; +if (!test_bit (port, sparx5->bridge_mask)) +return ; +mutex_lock (&sparx5->mact_lock);list_for_each_entry (mact_entry, &sparx5->mact_entries, list) { if (mact_entry->vid == vid &&
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +4 -0
@@ -623,6 +623,7 @@ static int sparx5_start(struct sparx5 *sparx5)return err;sparx5_board_init (sparx5); + err =sparx5_register_notifier_blocks (sparx5);/* Start register based INJ/XTR */ err = -ENXIO ;
@@ -812,6 +813,9 @@ static int mchp_sparx5_remove(struct platform_device *pdev) sparx5->xtr_irq = -ENXIO ; }sparx5_cleanup_ports (sparx5); +/* Unregister netdevs */ +sparx5_unregister_notifier_blocks (sparx5); +return 0 ; }
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +11 -0
@@ -135,9 +135,16 @@ struct sparx5 {/* port structures are in net device */ struct sparx5_port *ports[SPX5_PORTS ];enum sparx5_core_clockfreq coreclock; +/* Notifiers */ +struct notifier_block netdevice_nb; +struct notifier_block switchdev_nb; +struct notifier_block switchdev_blocking_nb;/* Switch state */ u8 base_mac[ETH_ALEN ]; +/* Associated bridge device (when bridged) */ +struct net_device *hw_bridge_dev;/* Bridged interfaces */ +DECLARE_BITMAP (bridge_mask,SPX5_PORTS );DECLARE_BITMAP (bridge_fwd_mask,SPX5_PORTS );DECLARE_BITMAP (bridge_lrn_mask,SPX5_PORTS );DECLARE_BITMAP (vlan_mask[VLAN_N_VID ],SPX5_PORTS );
@@ -153,6 +160,10 @@ struct sparx5 {int xtr_irq; }; +/* sparx5_switchdev.c */ +int sparx5_register_notifier_blocks (struct sparx5 *sparx5); +void sparx5_unregister_notifier_blocks (struct sparx5 *sparx5); +/* sparx5_packet.c */ irqreturn_t sparx5_xtr_handler (int irq,void *_priv);int sparx5_port_xmit_impl (struct sk_buff *skb,struct net_device *dev);
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +10 -0
@@ -117,6 +117,15 @@ static int sparx5_port_stop(struct net_device *ndev)return 0 ; } +static void sparx5_set_rx_mode (struct net_device *dev) +{ +struct sparx5_port *port =netdev_priv (dev); +struct sparx5 *sparx5 = port->sparx5; + +if (!test_bit (port->portno, sparx5->bridge_mask)) +__dev_mc_sync (dev, sparx5_mc_sync, sparx5_mc_unsync); +} +static int sparx5_port_get_phys_port_name (struct net_device *dev,char *buf,size_t len) {
@@ -167,6 +176,7 @@ static const struct net_device_ops sparx5_port_netdev_ops = { .ndo_open = sparx5_port_open, .ndo_stop = sparx5_port_stop, .ndo_start_xmit = sparx5_port_xmit_impl, + .ndo_set_rx_mode = sparx5_set_rx_mode, .ndo_get_phys_port_name = sparx5_port_get_phys_port_name, .ndo_set_mac_address = sparx5_set_mac_address, .ndo_validate_addr = eth_validate_addr,
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +6 -0
@@ -139,6 +139,12 @@ static void sparx5_xtr_grp(struct sparx5 *sparx5, u8 grp, bool byte_swap)return ; } +/* Everything we see on an interface that is in the HW bridge +* has already been forwarded +*/ +if (test_bit (port->portno, sparx5->bridge_mask)) + skb->offload_fwd_mark =1 ; +/* Finish up skb */ skb_put (skb, byte_cnt -ETH_FCS_LEN );eth_skb_pad (skb);
drivers/net/ethernet/microchip/sparx5/sparx5_switchdev.c new file +508 -0
508 lines not on this page · raw message
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 8/10 net: sparx5: add calendar bandwidth allocation support
In reply to Steen HegelundThis configures the Sparx5 calendars according to the bandwidth requested in the Device Tree nodes.
It also checks if the total requested bandwidth is within the specs of the detected Sparx5 models limits.
--- .../net/ethernet/microchip/sparx5/Makefile | 2 +- .../microchip/sparx5/sparx5_calendar.c | 596 ++++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_main.c | 9 +- .../ethernet/microchip/sparx5/sparx5_main.h | 4 + 4 files changed, 609 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c
drivers/net/ethernet/microchip/sparx5/Makefile +1 -1
@@ -7,4 +7,4 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o sparx5_vlan.o \ - sparx5_switchdev.o + sparx5_switchdev.o sparx5_calendar.o
drivers/net/ethernet/microchip/sparx5/sparx5_calendar.c new file +596 -0
596 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +8 -1
@@ -606,7 +606,14 @@ static int sparx5_start(struct sparx5 *sparx5)/* Enable queue limitation watermarks */ sparx5_qlim_set (sparx5); -/* Resource calendar support to be added in later patches */ + err =sparx5_config_auto_calendar (sparx5); +if (err) +return err; + + err =sparx5_config_dsm_calendar (sparx5); +if (err) +return err; +/* Init mact_sw struct */ mutex_init (&sparx5->mact_lock);
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +4 -0
@@ -199,6 +199,10 @@ int sparx5_vlan_vid_add(struct sparx5_port *port, u16 vid, bool pvid,int sparx5_vlan_vid_del (struct sparx5_port *port,u16 vid);void sparx5_vlan_port_apply (struct sparx5 *sparx5,struct sparx5_port *port); +/* sparx5_calendar.c */ +int sparx5_config_auto_calendar (struct sparx5 *sparx5); +int sparx5_config_dsm_calendar (struct sparx5 *sparx5); +/* sparx5_netdev.c */ bool sparx5_netdevice_check (const struct net_device *dev);struct net_device *sparx5_create_netdev (struct sparx5 *sparx5,u32 portno);
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 9/10 net: sparx5: add ethtool configuration and statistics support
In reply to Steen HegelundThis adds statistic counters for the network interfaces provided by the driver. It also adds CPU port counters (which are not exposed by ethtool).
This also adds support for configuring the network interface parameters via ethtool: speed, duplex, aneg etc.
--- .../net/ethernet/microchip/sparx5/Makefile | 2 +- .../microchip/sparx5/sparx5_ethtool.c | 1227 +++++++++++++++++ .../ethernet/microchip/sparx5/sparx5_main.c | 4 + .../ethernet/microchip/sparx5/sparx5_main.h | 14 + .../ethernet/microchip/sparx5/sparx5_netdev.c | 2 + 5 files changed, 1248 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c
drivers/net/ethernet/microchip/sparx5/Makefile +1 -1
@@ -7,4 +7,4 @@ obj-$(CONFIG_SPARX5_SWITCH) += sparx5-switch.o sparx5-switch-objs := sparx5_main.o sparx5_packet.o \ sparx5_netdev.o sparx5_phylink.o sparx5_port.o sparx5_mactable.o sparx5_vlan.o \ - sparx5_switchdev.o sparx5_calendar.o + sparx5_switchdev.o sparx5_calendar.o sparx5_ethtool.o
drivers/net/ethernet/microchip/sparx5/sparx5_ethtool.c new file +1227 -0
1,227 lines not on this page · raw message
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +4 -0
@@ -614,6 +614,10 @@ static int sparx5_start(struct sparx5 *sparx5)if (err)return err; +/* Init stats */ + err =sparx_stats_init (sparx5); +if (err) +return err;/* Init mact_sw struct */ mutex_init (&sparx5->mact_lock);
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +14 -0
@@ -135,6 +135,15 @@ struct sparx5 {/* port structures are in net device */ struct sparx5_port *ports[SPX5_PORTS ];enum sparx5_core_clockfreq coreclock; +/* Statistics */ +u32 num_stats; +u32 num_ethtool_stats; +const char *const *stats_layout; +u64 *stats; +/* Workqueue for reading stats */ +struct mutex queue_stats_lock; +struct delayed_work stats_work; +struct workqueue_struct *stats_queue;/* Notifiers */ struct notifier_block netdevice_nb;struct notifier_block switchdev_nb;
@@ -203,6 +212,10 @@ void sparx5_vlan_port_apply(struct sparx5 *sparx5, struct sparx5_port *port);int sparx5_config_auto_calendar (struct sparx5 *sparx5);int sparx5_config_dsm_calendar (struct sparx5 *sparx5); +/* sparx5_ethtool.c */ +void sparx5_get_stats64 (struct net_device *ndev,struct rtnl_link_stats64 *stats); +int sparx_stats_init (struct sparx5 *sparx5); +/* sparx5_netdev.c */ bool sparx5_netdevice_check (const struct net_device *dev);struct net_device *sparx5_create_netdev (struct sparx5 *sparx5,u32 portno);
@@ -233,6 +246,7 @@ static inline bool sparx5_is_baser(phy_interface_t interface)extern const struct phylink_mac_ops sparx5_phylink_mac_ops;extern const struct phylink_pcs_ops sparx5_phylink_pcs_ops; +extern const struct ethtool_ops sparx5_ethtool_ops;/* Calculate raw offset */ static inline __pure int spx5_offset(int id, int tinst, int tcnt,
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +2 -0
@@ -180,6 +180,7 @@ static const struct net_device_ops sparx5_port_netdev_ops = { .ndo_get_phys_port_name = sparx5_port_get_phys_port_name, .ndo_set_mac_address = sparx5_set_mac_address, .ndo_validate_addr = eth_validate_addr, + .ndo_get_stats64 = sparx5_get_stats64, .ndo_get_port_parent_id = sparx5_get_port_parent_id, };
@@ -206,6 +207,7 @@ struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno)sparx5_set_port_ifh (spx5_port->ifh, portno); ndev->netdev_ops = &sparx5_port_netdev_ops; + ndev->ethtool_ops = &sparx5_ethtool_ops; val =ether_addr_to_u64 (sparx5->base_mac) + portno +1 ;u64_to_ether_addr (val, ndev->dev_addr);
Signature · 1 line
2.32.0
Steen Hegelund
maintainerPATCH v5 10/10 arm64: dts: sparx5: Add the Sparx5 switch node
In reply to Steen HegelundThis provides the configuration for the currently available evaluation boards PCB134 and PCB135.
The series depends on the following series currently on its way into the kernel:
- Sparx5 Reset Driver
--- arch/arm64/boot/dts/microchip/sparx5.dtsi | 94 ++- .../dts/microchip/sparx5_pcb134_board.dtsi | 481 ++++++++++++-- .../dts/microchip/sparx5_pcb135_board.dtsi | 621 +++++++++++++++++- 3 files changed, 1112 insertions(+), 84 deletions(-)
arch/arm64/boot/dts/microchip/sparx5.dtsi +92 -2
@@ -135,9 +135,12 @@ mux: mux-controller { }; }; - reset@611010008 { - compatible = "microchip,sparx5-chip-reset"; + reset: reset-controller@611010008 { + compatible = "microchip,sparx5-switch-reset"; reg = <0x6 0x11010008 0x4>; + reg-names = "gcb"; + #reset-cells = <1>; + cpu-syscon = <&cpu_ctrl>; }; uart0: serial@600100000 {
@@ -275,6 +278,21 @@ emmc_pins: emmc-pins { "GPIO_46", "GPIO_47"; function = "emmc"; }; + + miim1_pins: miim1-pins { + pins = "GPIO_56", "GPIO_57"; + function = "miim"; + }; + + miim2_pins: miim2-pins { + pins = "GPIO_58", "GPIO_59"; + function = "miim"; + }; + + miim3_pins: miim3-pins { + pins = "GPIO_52", "GPIO_53"; + function = "miim"; + }; }; sgpio0: gpio@61101036c {
@@ -285,6 +303,8 @@ sgpio0: gpio@61101036c { clocks = <&sys_clk>; pinctrl-0 = <&sgpio0_pins>; pinctrl-names = "default"; + resets = <&reset 0>; + reset-names = "switch"; reg = <0x6 0x1101036c 0x100>; sgpio_in0: gpio@0 { compatible = "microchip,sparx5-sgpio-bank";
@@ -292,6 +312,9 @@ sgpio_in0: gpio@0 { gpio-controller; #gpio-cells = <3>; ngpios = <96>; + interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <3>; }; sgpio_out0: gpio@1 { compatible = "microchip,sparx5-sgpio-bank";
@@ -310,6 +333,8 @@ sgpio1: gpio@611010484 { clocks = <&sys_clk>; pinctrl-0 = <&sgpio1_pins>; pinctrl-names = "default"; + resets = <&reset 0>; + reset-names = "switch"; reg = <0x6 0x11010484 0x100>; sgpio_in1: gpio@0 { compatible = "microchip,sparx5-sgpio-bank";
@@ -317,6 +342,9 @@ sgpio_in1: gpio@0 { gpio-controller; #gpio-cells = <3>; ngpios = <96>; + interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <3>; }; sgpio_out1: gpio@1 { compatible = "microchip,sparx5-sgpio-bank";
@@ -335,6 +363,8 @@ sgpio2: gpio@61101059c { clocks = <&sys_clk>; pinctrl-0 = <&sgpio2_pins>; pinctrl-names = "default"; + resets = <&reset 0>; + reset-names = "switch"; reg = <0x6 0x1101059c 0x100>; sgpio_in2: gpio@0 { reg = <0>;
@@ -342,6 +372,9 @@ sgpio_in2: gpio@0 { gpio-controller; #gpio-cells = <3>; ngpios = <96>; + interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; + interrupt-controller; + #interrupt-cells = <3>; }; sgpio_out2: gpio@1 { compatible = "microchip,sparx5-sgpio-bank";
@@ -386,5 +419,62 @@ tmon0: tmon@610508110 { #thermal-sensor-cells = <0>; clocks = <&ahb_clk>; }; + + mdio0: mdio@6110102b0 { + compatible = "mscc,ocelot-miim"; + status = "disabled"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x6 0x110102b0 0x24>; + }; + + mdio1: mdio@6110102d4 { + compatible = "mscc,ocelot-miim"; + status = "disabled"; + pinctrl-0 = <&miim1_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x6 0x110102d4 0x24>; + }; + + mdio2: mdio@6110102f8 { + compatible = "mscc,ocelot-miim"; + status = "disabled"; + pinctrl-0 = <&miim2_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x6 0x110102d4 0x24>; + }; + + mdio3: mdio@61101031c { + compatible = "mscc,ocelot-miim"; + status = "disabled"; + pinctrl-0 = <&miim3_pins>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x6 0x1101031c 0x24>; + }; + + serdes: serdes@10808000 { + compatible = "microchip,sparx5-serdes"; + #phy-cells = <1>; + clocks = <&sys_clk>; + reg = <0x6 0x10808000 0x5d0000>; + }; + + switch: switch@0x600000000 { + compatible = "microchip,sparx5-switch"; + reg = <0x6 0 0x401000>, + <0x6 0x10004000 0x7fc000>, + <0x6 0x11010000 0xaf0000>; + reg-names = "cpu", "dev", "gcb"; + interrupt-names = "xtr"; + interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>; + resets = <&reset 0>; + reset-names = "switch"; + }; }; };
arch/arm64/boot/dts/microchip/sparx5_pcb134_board.dtsi +423 -58
591 lines not on this page · raw message
arch/arm64/boot/dts/microchip/sparx5_pcb135_board.dtsi +597 -24
665 lines not on this page · raw message
Signature · 1 line
2.32.0
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 12 lines · On Thu, 24 Jun 2021 09:07:48 +0200 you wrote:
This series provides the Microchip Sparx5i Switch Driver
The SparX-5 Enterprise Ethernet switch family provides a rich set of Enterprise switching features such as advanced TCAM-based VLAN and QoS processing enabling delivery of differentiated services, and security through TCAMbased frame processing using versatile content aware processor (VCAP). IPv4/IPv6 Layer 3 (L3) unicast and multicast routing is supported with up to 18K IPv4/9K IPv6 unicast LPM entries and up to 9K IPv4/3K IPv6 (S,G) multicast groups. L3 security features include source guard and reverse path forwarding (uRPF) tasks. Additional L3 features include VRF-Lite and IP tunnels (IP over GRE/IP).
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v5,01/10] dt-bindings: net: sparx5: Add sparx5-switch bindings
https://git.kernel.org/netdev/net-next/c/f8c63088a98b - [net-next,v5,02/10] net: sparx5: add the basic sparx5 driver https://git.kernel.org/netdev/net-next/c/3cfa11bac9bb - [net-next,v5,03/10] net: sparx5: add hostmode with phylink support https://git.kernel.org/netdev/net-next/c/f3cad2611a77 - [net-next,v5,04/10] net: sparx5: add port module support https://git.kernel.org/netdev/net-next/c/946e7fd5053a - [net-next,v5,05/10] net: sparx5: add mactable support https://git.kernel.org/netdev/net-next/c/b37a1bae742f - [net-next,v5,06/10] net: sparx5: add vlan support https://git.kernel.org/netdev/net-next/c/78eab33bb68b - [net-next,v5,07/10] net: sparx5: add switching support https://git.kernel.org/netdev/net-next/c/d6fce5141929 - [net-next,v5,08/10] net: sparx5: add calendar bandwidth allocation support https://git.kernel.org/netdev/net-next/c/0a9d48ad0d09 - [net-next,v5,09/10] net: sparx5: add ethtool configuration and statistics support https://git.kernel.org/netdev/net-next/c/af4b11022e2d - [net-next,v5,10/10] arm64: dts: sparx5: Add the Sparx5 switch node https://git.kernel.org/netdev/net-next/c/d0f482bb06f9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html