net: dsa: Add Airoha AN8855 support
Subsystems (8)
v11 cover net: dsa: Add Airoha AN8855 support
This small series add the initial support for the Airoha AN8855 Switch.
It's a 5 port Gigabit Switch with SGMII/HSGMII upstream port.
This is starting to get in the wild and there are already some router having this switch chip.
It's conceptually similar to mediatek switch but register and bits are different. And there is that massive Hell that is the PCS configuration.
Saddly for that part we have absolutely NO documentation currently.
There is this special thing where PHY needs to be calibrated with values from the switch efuse. (the thing have a whole cpu timer and MCU)
From v8 Driver is now evaluated with Kernel selftest scripts for DSA:
Output local_termination.sh
TEST: lan2: Unicast IPv4 to primary MAC address [ OK ]
TEST: lan2: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: lan2: Unicast IPv4 to unknown MAC address [ OK ]
TEST: lan2: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: lan2: Unicast IPv4 to unknown MAC address, allmulti [ OK ]
TEST: lan2: Multicast IPv4 to joined group [ OK ]
TEST: lan2: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: lan2: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: lan2: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: lan2: Multicast IPv6 to joined group [ OK ]
TEST: lan2: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: lan2: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: lan2: Multicast IPv6 to unknown group, allmulti [ OK ]
TEST: lan2: 1588v2 over L2 transport, Sync [ OK ]
TEST: lan2: 1588v2 over L2 transport, Follow-Up [ OK ]
TEST: lan2: 1588v2 over L2 transport, Peer Delay Request [ OK ]
TEST: lan2: 1588v2 over IPv4, Sync [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
TEST: vlan_filtering=0 bridge: Unicast IPv4 to primary MAC address [ OK ]
TEST: vlan_filtering=0 bridge: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: vlan_filtering=0 bridge: Unicast IPv4 to unknown MAC address [ OK ]
TEST: vlan_filtering=0 bridge: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: vlan_filtering=0 bridge: Unicast IPv4 to unknown MAC address, allmulti [ OK ]
TEST: vlan_filtering=0 bridge: Multicast IPv4 to joined group [ OK ]
TEST: vlan_filtering=0 bridge: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: vlan_filtering=0 bridge: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: vlan_filtering=0 bridge: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: vlan_filtering=0 bridge: Multicast IPv6 to joined group [ OK ]
TEST: vlan_filtering=0 bridge: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: vlan_filtering=0 bridge: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: vlan_filtering=0 bridge: Multicast IPv6 to unknown group, allmulti [ OK ]
TEST: vlan_filtering=1 bridge: Unicast IPv4 to primary MAC address [ OK ]
TEST: vlan_filtering=1 bridge: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: vlan_filtering=1 bridge: Unicast IPv4 to unknown MAC address [ OK ]
TEST: vlan_filtering=1 bridge: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: vlan_filtering=1 bridge: Unicast IPv4 to unknown MAC address, allmulti [ OK ]
TEST: vlan_filtering=1 bridge: Multicast IPv4 to joined group [ OK ]
TEST: vlan_filtering=1 bridge: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: vlan_filtering=1 bridge: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: vlan_filtering=1 bridge: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: vlan_filtering=1 bridge: Multicast IPv6 to joined group [ OK ]
TEST: vlan_filtering=1 bridge: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: vlan_filtering=1 bridge: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: vlan_filtering=1 bridge: Multicast IPv6 to unknown group, allmulti [ OK ]
TEST: VLAN upper: Unicast IPv4 to primary MAC address [ OK ]
TEST: VLAN upper: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: VLAN upper: Unicast IPv4 to unknown MAC address [ OK ]
TEST: VLAN upper: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: VLAN upper: Unicast IPv4 to unknown MAC address, allmulti [ OK ]
TEST: VLAN upper: Multicast IPv4 to joined group [ OK ]
TEST: VLAN upper: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN upper: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: VLAN upper: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: VLAN upper: Multicast IPv6 to joined group [ OK ]
TEST: VLAN upper: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN upper: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: VLAN upper: Multicast IPv6 to unknown group, allmulti [ OK ]
TEST: VLAN upper: 1588v2 over L2 transport, Sync [ OK ]
TEST: VLAN upper: 1588v2 over L2 transport, Follow-Up [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over L2 transport, Peer Delay Request [ OK ]
TEST: VLAN upper: 1588v2 over IPv4, Sync [FAIL]
reception failed
;TEST: VLAN upper: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: Unicast IPv4 to primary MAC address [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Unicast IPv4 to unknown MAC address [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Unicast IPv4 to unknown MAC address, allmulti [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv4 to joined group [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv6 to joined group [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: Multicast IPv6 to unknown group, allmulti [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over L2 transport, Sync [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over L2 transport, Follow-Up [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over L2 transport, Peer Delay Request [ OK ]
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv4, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: Unicast IPv4 to primary MAC address [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Unicast IPv4 to unknown MAC address [FAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=1 bridged port: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Unicast IPv4 to unknown MAC address, allmulti [FAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv4 to joined group [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv6 to joined group [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: Multicast IPv6 to unknown group, allmulti [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over L2 transport, Sync [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over L2 transport, Follow-Up [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over L2 transport, Peer Delay Request [ OK ]
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv4, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridge: Unicast IPv4 to primary MAC address [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Unicast IPv4 to unknown MAC address [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Unicast IPv4 to unknown MAC address, allmulti [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv4 to joined group [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv6 to joined group [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=0 bridge: Multicast IPv6 to unknown group, allmulti [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Unicast IPv4 to primary MAC address [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Unicast IPv4 to macvlan MAC address [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Unicast IPv4 to unknown MAC address [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Unicast IPv4 to unknown MAC address, promisc [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Unicast IPv4 to unknown MAC address, allmulti [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv4 to joined group [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv4 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv4 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv4 to unknown group, allmulti [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv6 to joined group [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv6 to unknown group [XFAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv6 to unknown group, promisc [ OK ]
TEST: VLAN over vlan_filtering=1 bridge: Multicast IPv6 to unknown group, allmulti [ OK ]
Output bridge_vlan_unaware.sh
TEST: ping [ OK ]
TEST: ping6 [ OK ]
TEST: FDB learning [ OK ]
TEST: Unknown unicast flood [ OK ]
TEST: Unregistered multicast flood [ OK ]
Output bridge_vlan_aware.sh
TEST: ping [ OK ]
TEST: ping6 [ OK ]
TEST: FDB learning [ OK ]
TEST: Unknown unicast flood [ OK ]
TEST: Unregistered multicast flood [ OK ]
INFO: Add and delete a VLAN on bridge port lan2
TEST: ping [ OK ]
TEST: ping6 [ OK ]
TEST: Externally learned FDB entry - ageing & roaming [ OK ]
TEST: FDB entry in PVID for VLAN-tagged with other TPID [FAIL]
FDB entry was not learned when it should
TEST: Reception of VLAN with other TPID as untagged [FAIL]
Packet was not forwarded when it should
TEST: Reception of VLAN with other TPID as untagged (no PVID) [FAIL]
Packet was forwarded when should not
[ For Vladimir, I still have to implement fdb_isolation but posting to start the ball rolling for the multiple subsystem this patch affect and for the dubious DT schema ]
Changes v11:
- Address reviews from Christophe (spell mistake + dev_err_probe)
- Fix kconfig dependency for MFD driver (depends on MDIO_DEVICE instead of MDIO) (indirectly fix link error for mdio APIs)
- Fix copy-paste error for MFD driver of_table
- Fix compilation error for PHY (move NVMEM to .config)
- Drop unneeded NVMEM node from MDIO example schema (from Andrew)
- Adapt MFD example schema to MDIO reg property restrictions
Changes v10:
- Entire rework to MFD + split to MDIO, EFUSE, SWITCH separate drivers
- Drop EEE OPs (while Russell finish RFC for EEE changes)
- Use new pcs_inpand OPs
- Drop AN restart function and move to pcs_config
- Enable assisted_learning and disable CPU learn (preparation for fdb_isolation)
- Move EFUSE read in Internal PHY driver to .config to handle EPROBE_DEFER (needed now that NVMEM driver is register externally instead of internally to switch node)
Changes v9:
- Error out on using 5G speed as currently not supported
- Add missing MAC_2500FD in phylink mac_capabilities
- Add comment and improve if condition for an8855_phylink_mac_config Changes v8:
- Add port Fast Age support
- Add support for Port Isolation
- Use correct register for Learning Disable
- Add support for Ageing Time OP
- Set default PVID to 0 by default
- Add mdb OPs
- Add port change MTU
- Fix support for Upper VLAN
Changes v7:
- Fix devm_dsa_register_switch wrong export symbol
Changes v6:
- Drop standard MIB and handle with ethtool OPs (as requested by Jakub)
- Cosmetic: use bool instead of 0 or 1
Changes v5:
- Add devm_dsa_register_switch() patch
- Add Reviewed-by tag for DT patch
Changes v4:
- Set regmap readable_table static (mute compilation warning)
- Add support for port_bridge flags (LEARNING, FLOOD)
- Reset fdb struct in fdb_dump
- Drop support_asym_pause in port_enable
- Add define for get_phy_flags
- Fix bug for port not inititially part of a bridge
(in an8855_setup the port matrix was always cleared but
the CPU port was never initially added)
- Disable learning and flood for user port by default
- Set CPU port to flood and learning by default
- Correctly AND force duplex and flow control in an8855_phylink_mac_link_up
- Drop RGMII from pcs_config
- Check ret in "Disable AN if not in autoneg"
- Use devm_mutex_init
- Fix typo for AN8855_PORT_CHECK_MODE
- Better define AN8855_STP_LISTENING = AN8855_STP_BLOCKING
- Fix typo in AN8855_PHY_EN_DOWN_SHIFT
- Use paged helper for PHY
- Skip calibration in config_init if priv not defined
Changes v3:
- Out of RFC
- Switch PHY code to select_page API
- Better describe masks and bits in PHY driver for ADC register
- Drop raw values and use define for mii read/write
- Switch to absolute PHY address
- Replace raw values with mask and bits for pcs_config
- Fix typo for ext-surge property name
- Drop support for relocating Switch base PHY address on the bus
Changes v2:
- Drop mutex guard patch
- Drop guard usage in DSA driver
- Use __mdiobus_write/read
- Check return condition and return errors for mii read/write
- Fix wrong logic for EEE
- Fix link_down (don't force link down with autoneg)
- Fix forcing speed on sgmii autoneg
- Better document link speed for sgmii reg
- Use standard define for sgmii reg
- Imlement nvmem support to expose switch EFUSE
- Rework PHY calibration with the use of NVMEM producer/consumer
- Update DT with new NVMEM property
- Move aneg validation for 2500-basex in pcs_config
- Move r50Ohm table and function to PHY driver
Christian Marangi (9):
dt-bindings: nvmem: Document support for Airoha AN8855 Switch EFUSE
dt-bindings: net: Document support for Airoha AN8855 Switch Virtual
MDIO
dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch
dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC
mfd: an8855: Add support for Airoha AN8855 Switch MFD
net: mdio: Add Airoha AN8855 Switch MDIO Passtrough
nvmem: an8855: Add support for Airoha AN8855 Switch EFUSE
net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver
net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
.../bindings/mfd/airoha,an8855-mfd.yaml | 178 ++ .../bindings/net/airoha,an8855-mdio.yaml | 56 + .../net/dsa/airoha,an8855-switch.yaml | 105 + .../bindings/nvmem/airoha,an8855-efuse.yaml | 123 + MAINTAINERS | 17 + drivers/mfd/Kconfig | 10 + drivers/mfd/Makefile | 1 + drivers/mfd/airoha-an8855.c | 278 ++ drivers/net/dsa/Kconfig | 9 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/an8855.c | 2310 +++++++++++++++++ drivers/net/dsa/an8855.h | 783 ++++++ drivers/net/mdio/Kconfig | 9 + drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-an8855.c | 113 + drivers/net/phy/Kconfig | 5 + drivers/net/phy/Makefile | 1 + drivers/net/phy/air_an8855.c | 267 ++ drivers/nvmem/Kconfig | 11 + drivers/nvmem/Makefile | 2 + drivers/nvmem/an8855-efuse.c | 63 + include/linux/mfd/airoha-an8855-mfd.h | 41 + 22 files changed, 4384 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml create mode 100644 Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml create mode 100644 Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml create mode 100644 Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml create mode 100644 drivers/mfd/airoha-an8855.c create mode 100644 drivers/net/dsa/an8855.c create mode 100644 drivers/net/dsa/an8855.h create mode 100644 drivers/net/mdio/mdio-an8855.c create mode 100644 drivers/net/phy/air_an8855.c create mode 100644 drivers/nvmem/an8855-efuse.c create mode 100644 include/linux/mfd/airoha-an8855-mfd.h
Signature · 1 line
2.45.2
PATCH v11 1/9 dt-bindings: nvmem: Document support for Airoha AN8855 Switch EFUSE
Document support for Airoha AN8855 Switch EFUSE used to calibrate internal PHYs and store additional configuration info.
--- .../bindings/nvmem/airoha,an8855-efuse.yaml | 123 ++++++++++++++++++ MAINTAINERS | 8 ++ 2 files changed, 131 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml
Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml new file +123 -0
@@ -0,0 +1,123 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvmem/airoha,an8855-efuse.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN8855 Switch EFUSE + +maintainers: + - Christian Marangi <[email protected]> + +description: + Airoha AN8855 EFUSE used to calibrate internal PHYs and store additional + configuration info. + +$ref: nvmem.yaml# + +properties: + compatible: + const: airoha,an8855-efuse + + '#nvmem-cell-cells': + const: 0 + +required: + - compatible + - '#nvmem-cell-cells' + +unevaluatedProperties: false + +examples: + - | + efuse { + compatible = "airoha,an8855-efuse"; + + #nvmem-cell-cells = <0>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + shift_sel_port0_tx_a: shift-sel-port0-tx-a@c { + reg = <0xc 0x4>; + }; + + shift_sel_port0_tx_b: shift-sel-port0-tx-b@10 { + reg = <0x10 0x4>; + }; + + shift_sel_port0_tx_c: shift-sel-port0-tx-c@14 { + reg = <0x14 0x4>; + }; + + shift_sel_port0_tx_d: shift-sel-port0-tx-d@18 { + reg = <0x18 0x4>; + }; + + shift_sel_port1_tx_a: shift-sel-port1-tx-a@1c { + reg = <0x1c 0x4>; + }; + + shift_sel_port1_tx_b: shift-sel-port1-tx-b@20 { + reg = <0x20 0x4>; + }; + + shift_sel_port1_tx_c: shift-sel-port1-tx-c@24 { + reg = <0x24 0x4>; + }; + + shift_sel_port1_tx_d: shift-sel-port1-tx-d@28 { + reg = <0x28 0x4>; + }; + + shift_sel_port2_tx_a: shift-sel-port2-tx-a@2c { + reg = <0x2c 0x4>; + }; + + shift_sel_port2_tx_b: shift-sel-port2-tx-b@30 { + reg = <0x30 0x4>; + }; + + shift_sel_port2_tx_c: shift-sel-port2-tx-c@34 { + reg = <0x34 0x4>; + }; + + shift_sel_port2_tx_d: shift-sel-port2-tx-d@38 { + reg = <0x38 0x4>; + }; + + shift_sel_port3_tx_a: shift-sel-port3-tx-a@4c { + reg = <0x4c 0x4>; + }; + + shift_sel_port3_tx_b: shift-sel-port3-tx-b@50 { + reg = <0x50 0x4>; + }; + + shift_sel_port3_tx_c: shift-sel-port3-tx-c@54 { + reg = <0x54 0x4>; + }; + + shift_sel_port3_tx_d: shift-sel-port3-tx-d@58 { + reg = <0x58 0x4>; + }; + + shift_sel_port4_tx_a: shift-sel-port4-tx-a@5c { + reg = <0x5c 0x4>; + }; + + shift_sel_port4_tx_b: shift-sel-port4-tx-b@60 { + reg = <0x60 0x4>; + }; + + shift_sel_port4_tx_c: shift-sel-port4-tx-c@64 { + reg = <0x64 0x4>; + }; + + shift_sel_port4_tx_d: shift-sel-port4-tx-d@68 { + reg = <0x68 0x4>; + }; + }; + };
MAINTAINERS +8 -0
@@ -711,6 +711,14 @@ S: Supported F: fs/aio.c F: include/linux/*aio*.h +AIROHA DSA DRIVER +M: Christian Marangi <[email protected]> +L: [email protected] (moderated for non-subscribers) +L: [email protected] (moderated for non-subscribers) +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml + AIROHA ETHERNET DRIVER M: Lorenzo Bianconi <[email protected]> L: [email protected] (moderated for non-subscribers)
Signature · 1 line
2.45.2
Re: [net-next PATCH v11 1/9] dt-bindings: nvmem: Document support for Airoha AN8855 Switch EFUSE
Quoted 10 lines · Christian Marangi
Document support for Airoha AN8855 Switch EFUSE used to calibrate internal PHYs and store additional configuration info.
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/nvmem/airoha,an8855-efuse.yaml | 123 ++++++++++++++++++ MAINTAINERS | 8 ++ 2 files changed, 131 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml
PATCH v11 2/9 dt-bindings: net: Document support for Airoha AN8855 Switch Virtual MDIO
In reply to Christian MarangiDocument support for Airoha AN8855 Virtual MDIO Passtrough. This is needed as AN8855 require special handling as the same address on the MDIO bus is shared for both Switch and PHY and special handling for the page configuration is needed to switch accessing to Switch address space or PHY.
--- .../bindings/net/airoha,an8855-mdio.yaml | 56 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml
Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml new file +56 -0
@@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/airoha,an8855-mdio.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN8855 MDIO Passtrough + +maintainers: + - Christian Marangi <[email protected]> + +description: + Airoha AN8855 Virtual MDIO Passtrough. This is needed as AN8855 + require special handling as the same address on the MDIO bus is + shared for both Switch and PHY and special handling for the page + configuration is needed to switch accessing to Switch address space + or PHY. + +$ref: /schemas/net/mdio.yaml# + +properties: + compatible: + const: airoha,an8855-mdio + +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + mdio { + compatible = "airoha,an8855-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + internal_phy1: phy@1 { + reg = <1>; + }; + + internal_phy2: phy@2 { + reg = <2>; + }; + + internal_phy3: phy@3 { + reg = <3>; + }; + + internal_phy4: phy@4 { + reg = <4>; + }; + + internal_phy5: phy@5 { + reg = <5>; + }; + };
MAINTAINERS +1 -0
@@ -717,6 +717,7 @@ L: [email protected] (moderated for non-subscribers) L: [email protected] (moderated for non-subscribers) L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml AIROHA ETHERNET DRIVER
Signature · 1 line
2.45.2
Re: [net-next PATCH v11 2/9] dt-bindings: net: Document support for Airoha AN8855 Switch Virtual MDIO
Quoted 6 lines · Christian Marangi
Document support for Airoha AN8855 Virtual MDIO Passtrough. This is needed as AN8855 require special handling as the same address on the MDIO bus is shared for both Switch and PHY and special handling for the page configuration is needed to switch accessing to Switch address space or PHY.
Quoted 7 lines
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/net/airoha,an8855-mdio.yaml | 56 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml
PATCH v11 3/9 dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch
In reply to Christian MarangiDocument support for Airoha AN8855 5-port Gigabit Switch.
It does expose the 5 Internal PHYs on the MDIO bus and each port can access the Switch register space by configurting the PHY page.
Each internal PHY might require calibration with the fused EFUSE on the switch exposed by the Airoha AN8855 SoC NVMEM.
--- .../net/dsa/airoha,an8855-switch.yaml | 105 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 106 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +105 -0
@@ -0,0 +1,105 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/airoha,an8855-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN8855 Gigabit Switch + +maintainers: + - Christian Marangi <[email protected]> + +description: > + Airoha AN8855 is a 5-port Gigabit Switch. + + It does expose the 5 Internal PHYs on the MDIO bus and each port + can access the Switch register space by configurting the PHY page. + + Each internal PHY might require calibration with the fused EFUSE on + the switch exposed by the Airoha AN8855 SoC NVMEM. + +$ref: dsa.yaml# + +properties: + compatible: + const: airoha,an8855-switch + + reset-gpios: + description: + GPIO to be used to reset the whole device + maxItems: 1 + + airoha,ext-surge: + $ref: /schemas/types.yaml#/definitions/flag + description: + Calibrate the internal PHY with the calibration values stored in EFUSE + for the r50Ohm values. + +required: + - compatible + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + ethernet-switch { + compatible = "airoha,an8855-switch"; + reset-gpios = <&pio 39 0>; + + airoha,ext-surge; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&internal_phy1>; + }; + + port@1 { + reg = <1>; + label = "lan2"; + phy-mode = "internal"; + phy-handle = <&internal_phy2>; + }; + + port@2 { + reg = <2>; + label = "lan3"; + phy-mode = "internal"; + phy-handle = <&internal_phy3>; + }; + + port@3 { + reg = <3>; + label = "lan4"; + phy-mode = "internal"; + phy-handle = <&internal_phy4>; + }; + + port@4 { + reg = <4>; + label = "wan"; + phy-mode = "internal"; + phy-handle = <&internal_phy5>; + }; + + port@5 { + reg = <5>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -718,6 +718,7 @@ L: [email protected] (moderated for non-subscribers) L: [email protected] S: Maintained F: Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml +F: Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml AIROHA ETHERNET DRIVER
Signature · 1 line
2.45.2
Vladimir Oltean
maintainerRe: [net-next PATCH v11 3/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch
Quoted 4 lines · Christian Marangi
Document support for Airoha AN8855 5-port Gigabit Switch.
It does expose the 5 Internal PHYs on the MDIO bus and each port can access the Switch register space by configurting the PHY page.
typo: configuring
Also below.
Quoted 3 lines
Each internal PHY might require calibration with the fused EFUSE on the switch exposed by the Airoha AN8855 SoC NVMEM.
This paragraph should be irrelevant to the switch binding.
Quoted 34 lines
Signed-off-by Christian Marangi <[email protected]>--- .../net/dsa/airoha,an8855-switch.yaml | 105 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 106 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yamlDocumentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +20
-0@@ -0,0 +1,105 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/airoha,an8855-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN8855 Gigabit Switch + +maintainers: + - Christian Marangi <[email protected]> + +description: > + Airoha AN8855 is a 5-port Gigabit Switch. + + It does expose the 5 Internal PHYs on the MDIO bus and each port + can access the Switch register space by configurting the PHY page. + + Each internal PHY might require calibration with the fused EFUSE on + the switch exposed by the Airoha AN8855 SoC NVMEM. +
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml line 30
Quoted 10 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +10
-0+$ref: dsa.yaml# + +properties: + compatible: + const: airoha,an8855-switch + + reset-gpios: + description: + GPIO to be used to reset the whole device + maxItems: 1
Since this affects the whole device, the SoC node (handled by the MFD driver) should handle it. Otherwise you expose the code to weird race conditions where one child MFD device resets the whole chip after the other MFD children have probed, and this undoes their settings.
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml line 36
Quoted 6 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +6
-0+ + airoha,ext-surge: + $ref: /schemas/types.yaml#/definitions/flag + description: + Calibrate the internal PHY with the calibration values stored in EFUSE + for the r50Ohm values.
Doesn't seem that this pertains to the switch.
Re: [net-next PATCH v11 3/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch
Quoted 56 lines · Vladimir Oltean
Quoted 4 lines · Christian Marangi
Document support for Airoha AN8855 5-port Gigabit Switch.
It does expose the 5 Internal PHYs on the MDIO bus and each port can access the Switch register space by configurting the PHY page.
typo: configuring
Also below.Quoted 3 lines
Each internal PHY might require calibration with the fused EFUSE on the switch exposed by the Airoha AN8855 SoC NVMEM.
This paragraph should be irrelevant to the switch binding.
Quoted 41 lines
Signed-off-by Christian Marangi <[email protected]>--- .../net/dsa/airoha,an8855-switch.yaml | 105 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 106 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yamlDocumentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +27
-0@@ -0,0 +1,105 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/dsa/airoha,an8855-switch.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN8855 Gigabit Switch + +maintainers: + - Christian Marangi <[email protected]> + +description: > + Airoha AN8855 is a 5-port Gigabit Switch. + + It does expose the 5 Internal PHYs on the MDIO bus and each port + can access the Switch register space by configurting the PHY page. + + Each internal PHY might require calibration with the fused EFUSE on + the switch exposed by the Airoha AN8855 SoC NVMEM. + +$ref: dsa.yaml# + +properties: + compatible: + const: airoha,an8855-switch + + reset-gpios:
Quoted 9 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml line 30
Quoted 3 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +3
-0+ description: + GPIO to be used to reset the whole device + maxItems: 1Since this affects the whole device, the SoC node (handled by the MFD driver) should handle it. Otherwise you expose the code to weird race conditions where one child MFD device resets the whole chip after the other MFD children have probed, and this undoes their settings.
OK.
Quoted 8 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml line 36
Quoted 6 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +6
-0+ + airoha,ext-surge: + $ref: /schemas/types.yaml#/definitions/flag + description: + Calibrate the internal PHY with the calibration values stored in EFUSE + for the r50Ohm values.Doesn't seem that this pertains to the switch.
Do you think this should be placed in each PHY node? I wanted to prevent having to define a schema also for PHY if possible given how integrated these are. (originally it was defined in DT node to follow how it was done in Airoha SDK)
Signature · 1 line
Ansuel
Vladimir Oltean
maintainerRe: [net-next PATCH v11 3/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch
Quoted 9 lines · Christian Marangi
Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml line 36
Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +5
-0+ airoha,ext-surge: + $ref: /schemas/types.yaml#/definitions/flag + description: + Calibrate the internal PHY with the calibration values stored in EFUSE + for the r50Ohm values.Doesn't seem that this pertains to the switch.
Do you think this should be placed in each PHY node?
Logically speaking, that's where it belongs.
Quoted 3 lines
I wanted to prevent having to define a schema also for PHY if possible given how integrated these are. (originally it was defined in DT node to follow how it was done in Airoha SDK)
Does compatibility with the Airoha SDK dt-bindings matter in any way?
Re: [net-next PATCH v11 3/9] dt-bindings: net: dsa: Document support for Airoha AN8855 DSA Switch
Quoted 11 lines · Vladimir Oltean
Quoted 9 lines · Christian Marangi
Quoted 7 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml line 36
Quoted 5 lines
Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml new file +5
-0+ airoha,ext-surge: + $ref: /schemas/types.yaml#/definitions/flag + description: + Calibrate the internal PHY with the calibration values stored in EFUSE + for the r50Ohm values.Doesn't seem that this pertains to the switch.
Do you think this should be placed in each PHY node?
Quoted 7 lines
Logically speaking, that's where it belongs.
Quoted 3 lines
I wanted to prevent having to define a schema also for PHY if possible given how integrated these are. (originally it was defined in DT node to follow how it was done in Airoha SDK)
Does compatibility with the Airoha SDK dt-bindings matter in any way?
No it doesn't, the requirement for nvmem already deviates a lot so changes are needed anyway.
Signature · 1 line
Ansuel
PATCH v11 4/9 dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC
In reply to Christian MarangiDocument support for Airoha AN8855 Switch SoC. This SoC expose various peripherals like an Ethernet Switch, a NVMEM provider and Ethernet PHYs.
It does also support i2c and timers but those are not currently supported/used.
--- .../bindings/mfd/airoha,an8855-mfd.yaml | 178 ++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 179 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +178 -0
@@ -0,0 +1,178 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/airoha,an8855-mfd.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha AN8855 Switch SoC + +maintainers: + - Christian Marangi <[email protected]> + +description: > + Airoha AN8855 Switch is a SoC that expose various peripherals like an + Ethernet Switch, a NVMEM provider and Ethernet PHYs. + + It does also support i2c and timers but those are not currently + supported/used. + +properties: + compatible: + const: airoha,an8855-mfd + + reg: + maxItems: 1 + + efuse: + type: object + $ref: /schemas/nvmem/airoha,an8855-efuse.yaml + description: + EFUSE exposed by the Airoha AN8855 Switch. This child node definition + should follow the bindings specified in + Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml + + ethernet-switch: + type: object + $ref: /schemas/net/dsa/airoha,an8855-switch.yaml + description: + Switch exposed by the Airoha AN8855 Switch. This child node definition + should follow the bindings specified in + Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml + + mdio: + type: object + $ref: /schemas/net/airoha,an8855-mdio.yaml + description: + MDIO exposed by the Airoha AN8855 Switch. This child node definition + should follow the bindings specified in + Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + mfd@1 { + compatible = "airoha,an8855-mfd"; + reg = <1>; + + efuse { + compatible = "airoha,an8855-efuse"; + + #nvmem-cell-cells = <0>; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + shift_sel_port0_tx_a: shift-sel-port0-tx-a@c { + reg = <0xc 0x4>; + }; + + shift_sel_port0_tx_b: shift-sel-port0-tx-b@10 { + reg = <0x10 0x4>; + }; + + shift_sel_port0_tx_c: shift-sel-port0-tx-c@14 { + reg = <0x14 0x4>; + }; + + shift_sel_port0_tx_d: shift-sel-port0-tx-d@18 { + reg = <0x18 0x4>; + }; + + shift_sel_port1_tx_a: shift-sel-port1-tx-a@1c { + reg = <0x1c 0x4>; + }; + + shift_sel_port1_tx_b: shift-sel-port1-tx-b@20 { + reg = <0x20 0x4>; + }; + + shift_sel_port1_tx_c: shift-sel-port1-tx-c@24 { + reg = <0x24 0x4>; + }; + + shift_sel_port1_tx_d: shift-sel-port1-tx-d@28 { + reg = <0x28 0x4>; + }; + }; + }; + + ethernet-switch { + compatible = "airoha,an8855-switch"; + + reset-gpios = <&pio 39 0>; + + airoha,ext-surge; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + phy-mode = "internal"; + phy-handle = <&internal_phy1>; + }; + + port@1 { + reg = <1>; + label = "lan2"; + phy-mode = "internal"; + phy-handle = <&internal_phy2>; + }; + + port@5 { + reg = <5>; + label = "cpu"; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; + }; + + mdio { + compatible = "airoha,an8855-mdio"; + #address-cells = <1>; + #size-cells = <0>; + + internal_phy1: phy@1 { + reg = <1>; + + nvmem-cells = <&shift_sel_port0_tx_a>, + <&shift_sel_port0_tx_b>, + <&shift_sel_port0_tx_c>, + <&shift_sel_port0_tx_d>; + nvmem-cell-names = "tx_a", "tx_b", "tx_c", "tx_d"; + }; + + internal_phy2: phy@2 { + reg = <2>; + + nvmem-cells = <&shift_sel_port1_tx_a>, + <&shift_sel_port1_tx_b>, + <&shift_sel_port1_tx_c>, + <&shift_sel_port1_tx_d>; + nvmem-cell-names = "tx_a", "tx_b", "tx_c", "tx_d"; + }; + }; + }; + };
MAINTAINERS +1 -0
@@ -717,6 +717,7 @@ L: [email protected] (moderated for non-subscribers) L: [email protected] (moderated for non-subscribers) L: [email protected] S: Maintained +F: Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml F: Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml F: Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml
Signature · 1 line
2.45.2
Vladimir Oltean
maintainerRe: [net-next PATCH v11 4/9] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml line 21
Quoted 3 lines · Christian Marangi
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+properties: + compatible: + const: airoha,an8855-mfd
After assisting dt-binding reviews in the past, I get the impression that "mfd" in a compatible string name is not going to be accepted. The bindings should be OS-independent, MFD is a Linux implementation. In principle this could be just "airoha,an8855" for the entire SoC.
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml line 64
Quoted 9 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +9
-0+examples: + - | + #include <dt-bindings/gpio/gpio.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + mfd@1 {
And the node name could be just "soc@1".
Quoted 4 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +4
-0+ compatible = "airoha,an8855-mfd"; + reg = <1>; + + efuse {
...
Quoted 3 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+ }; + + ethernet-switch {
...
Quoted 3 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+ }; + + mdio {
...
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml line 88
Quoted 3 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+ }; + }; + };
I hope it's not mandatory to duplicate in the example also the bindings of the children, especially since you link to their own schemas.
Re: [net-next PATCH v11 4/9] dt-bindings: mfd: Document support for Airoha AN8855 Switch SoC
Quoted 10 lines · Vladimir Oltean
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml line 21
Quoted 3 lines · Christian Marangi
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+properties: + compatible: + const: airoha,an8855-mfdAfter assisting dt-binding reviews in the past, I get the impression that "mfd" in a compatible string name is not going to be accepted. The bindings should be OS-independent, MFD is a Linux implementation. In principle this could be just "airoha,an8855" for the entire SoC.
Ok I will use an8855. The DSA switch has the suffix so it's not a problem being that generic.
Quoted 12 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml line 64
Quoted 9 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +9
-0+examples: + - | + #include <dt-bindings/gpio/gpio.h> + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + mfd@1 {And the node name could be just "soc@1".
I tought there was a constraint with node name but this is not the case, will change to soc.
Quoted 12 lines
Quoted 4 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +4
-0+ compatible = "airoha,an8855-mfd"; + reg = <1>; + + efuse {...
Quoted 3 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+ }; + + ethernet-switch {...
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml line 152
Quoted 3 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+ }; + + mdio {
Quoted 7 lines
...
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml line 88
Quoted 3 lines
Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml new file +3
-0+ }; + }; + };I hope it's not mandatory to duplicate in the example also the bindings of the children, especially since you link to their own schemas.
I checked other example and some duplicate the example and some doesn't... My idea here is to try to add the most complete example possible. Especially to how to define efuse and how phy makes use of it.
Signature · 1 line
Ansuel
PATCH v11 5/9 mfd: an8855: Add support for Airoha AN8855 Switch MFD
In reply to Christian MarangiAdd support for Airoha AN8855 Switch MFD that provide support for a DSA switch and a NVMEM provider. Also provide support for a virtual MDIO passthrough as the PHYs address for the switch are shared with the switch address
--- MAINTAINERS | 1 + drivers/mfd/Kconfig | 10 + drivers/mfd/Makefile | 1 + drivers/mfd/airoha-an8855.c | 278 ++++++++++++++++++++++++++ include/linux/mfd/airoha-an8855-mfd.h | 41 ++++ 5 files changed, 331 insertions(+) create mode 100644 drivers/mfd/airoha-an8855.c create mode 100644 include/linux/mfd/airoha-an8855-mfd.h
MAINTAINERS +1 -0
@@ -721,6 +721,7 @@ F: Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml F: Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml F: Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml +F: drivers/mfd/airoha-an8855.c AIROHA ETHERNET DRIVER M: Lorenzo Bianconi <[email protected]>
drivers/mfd/Kconfig +10 -0
@@ -53,6 +53,16 @@ config MFD_ALTERA_SYSMGR using regmap_mmio accesses for ARM32 parts and SMC calls to EL3 for ARM64 parts. +config MFD_AIROHA_AN8855 + tristate "Airoha AN8855 Switch MFD" + select MFD_CORE + select MDIO_DEVICE + depends on NETDEVICES && OF + help + Support for the Airoha AN8855 Switch MFD. This is a SoC Switch + that provides various peripherals. Currently it provides a + DSA switch and a NVMEM provider. + config MFD_ACT8945A tristate "Active-semi ACT8945A" select MFD_CORE
drivers/mfd/Makefile +1 -0
@@ -8,6 +8,7 @@ obj-$(CONFIG_MFD_88PM860X) += 88pm860x.o obj-$(CONFIG_MFD_88PM800) += 88pm800.o 88pm80x.o obj-$(CONFIG_MFD_88PM805) += 88pm805.o 88pm80x.o obj-$(CONFIG_MFD_88PM886_PMIC) += 88pm886.o +obj-$(CONFIG_MFD_AIROHA_AN8855) += airoha-an8855.o obj-$(CONFIG_MFD_ACT8945A) += act8945a.o obj-$(CONFIG_MFD_SM501) += sm501.o obj-$(CONFIG_ARCH_BCM2835) += bcm2835-pm.o
drivers/mfd/airoha-an8855.c new file +278 -0
278 lines not on this page · raw message
include/linux/mfd/airoha-an8855-mfd.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.45.2
Jakub Kicinski
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
drivers/mfd/airoha-an8855.c line 250
Quoted 3 lines · On Mon, 9 Dec 2024 14:44:22 +0100 Christian Marangi wrote:
drivers/mfd/airoha-an8855.c new file +3
-0+ regmap =devm_regmap_init (priv->dev,NULL , priv, + &an8855_regmap_config); +if (IS_ERR (regmap))
^^^^^^^^^^^^^^
drivers/mfd/airoha-an8855.c line 251
Quoted 1 line
drivers/mfd/airoha-an8855.c new file +1
-0+ dev_err_probe(priv->dev, PTR_ERR(priv->dev),
^^^^^^^^^^^^^^^^^^
drivers/mfd/airoha-an8855.c line 252
Quoted 1 line
drivers/mfd/airoha-an8855.c new file +1
-0+ "regmap initialization failed\n");
wrong ptr?
Signature · 1 line
pw-bot: cr
Re: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 10 lines · Jakub Kicinski
drivers/mfd/airoha-an8855.c line 250
Quoted 3 lines · On Mon, 9 Dec 2024 14:44:22 +0100 Christian Marangi wrote:
drivers/mfd/airoha-an8855.c new file +3
-0+ regmap =devm_regmap_init (priv->dev,NULL , priv, + &an8855_regmap_config); +if (IS_ERR (regmap))^^^^^^^^^^^^^^drivers/mfd/airoha-an8855.c line 251
Quoted 1 line
drivers/mfd/airoha-an8855.c new file +1
-0+ dev_err_probe(priv->dev, PTR_ERR(priv->dev),^^^^^^^^^^^^^^^^^^drivers/mfd/airoha-an8855.c line 252
Quoted 1 line
drivers/mfd/airoha-an8855.c new file +1
-0+ "regmap initialization failed\n");wrong ptr?
yes wth... I'm sorry for all these stupid mistake for this series... Also hope we won't have to request multiple stable tag for this multi subsystem patch. Any hint on that?
Signature · 1 line
Ansuel
Jakub Kicinski
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 2 lines · On Tue, 10 Dec 2024 00:22:59 +0100 Christian Marangi wrote:
Also hope we won't have to request multiple stable tag for this multi subsystem patch. Any hint on that?
Sorry I haven't payed much attention to earlier discussions. Why multiple stable tags? AFAICT all trees will need patches 4 and 5, so we can put that on a stable tag / branch, the rest can go directly into respective trees (assuming the table tag has been merged in). No?
Re: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 9 lines · Jakub Kicinski
Quoted 2 lines · On Tue, 10 Dec 2024 00:22:59 +0100 Christian Marangi wrote:
Also hope we won't have to request multiple stable tag for this multi subsystem patch. Any hint on that?
Sorry I haven't payed much attention to earlier discussions. Why multiple stable tags? AFAICT all trees will need patches 4 and 5, so we can put that on a stable tag / branch, the rest can go directly into respective trees (assuming the table tag has been merged in). No?
Yes in theory only MFD is really needed (as it does export the page symbol)
- NVMEM can go in his own tree. (no need for stable tag)
- mdio (require stable tag to correctly compile)
- dsa/phy (no need for stable tag)
So you are right, only one tag needed.
Signature · 1 line
Ansuel
Vladimir Oltean
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
In reply to Jakub KicinskiQuoted 5 lines · Jakub Kicinski
drivers/mfd/airoha-an8855.c line 250
Quoted 3 lines · On Mon, 9 Dec 2024 14:44:22 +0100 Christian Marangi wrote:
drivers/mfd/airoha-an8855.c new file +3
-0+ regmap =devm_regmap_init (priv->dev,NULL , priv, + &an8855_regmap_config); +if (IS_ERR (regmap))^^^^^^^^^^^^^^
Quoted 7 lines
drivers/mfd/airoha-an8855.c line 251
Quoted 1 line
drivers/mfd/airoha-an8855.c new file +1
-0+ dev_err_probe(priv->dev, PTR_ERR(priv->dev),^^^^^^^^^^^^^^^^^^drivers/mfd/airoha-an8855.c line 252
Quoted 1 line
drivers/mfd/airoha-an8855.c new file +1
-0+ "regmap initialization failed\n");wrong ptr?
Signature · 1 line
pw-bot: cr
Also, why continue execution if devm_regmap_init() failed?
Vladimir Oltean
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
In reply to Christian MarangiQuoted 6 lines · Christian Marangi
drivers/mfd/airoha-an8855.c new file +6
-0+int an8855_mii_set_page (struct an8855_mfd_priv *priv,u8 phy_id, + u8 page) __must_hold(&priv->bus->mdio_lock) +{ +struct mii_bus *bus = priv->bus; +int ret; +
drivers/mfd/airoha-an8855.c line 41
Quoted 10 lines
drivers/mfd/airoha-an8855.c new file +10
-0+ ret =__mdiobus_write (bus, phy_id,AN8855_PHY_SELECT_PAGE , page); +if (ret <0 ) +dev_err_ratelimited (&bus->dev, +"failed to set an8855 mii page\n" ); + +/* Cache current page if next mii read/write is for switch */ + priv->current_page = page; +return ret <0 ? ret :0 ; +} +EXPORT_SYMBOL_GPL (an8855_mii_set_page);
You could keep the implementation more contained, and you could avoid exporting an8855_mii_set_page() and an8855_mfd_priv to the MDIO passthrough driver, if you implement a virtual regmap and give it to the MDIO passthrough child MFD device.
If this bus supports only clause 22 accesses (and it looks like it does), you could expose a 16-bit regmap with a linear address space of 32 MDIO addresses x 65536 registers. The bus->read() of the MDIO bus passthrough just performs regmap_read(), and bus->write() just performs regmap_write(). The MFD driver decodes the regmap address into a PHY address and a regnum, and performs the page switching locally, if needed.
Re: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 23 lines · Vladimir Oltean
Quoted 6 lines · Christian Marangi
drivers/mfd/airoha-an8855.c new file +6
-0+int an8855_mii_set_page (struct an8855_mfd_priv *priv,u8 phy_id, + u8 page) __must_hold(&priv->bus->mdio_lock) +{ +struct mii_bus *bus = priv->bus; +int ret; +drivers/mfd/airoha-an8855.c line 41
Quoted 10 lines
drivers/mfd/airoha-an8855.c new file +10
-0+ ret =__mdiobus_write (bus, phy_id,AN8855_PHY_SELECT_PAGE , page); +if (ret <0 ) +dev_err_ratelimited (&bus->dev, +"failed to set an8855 mii page\n" ); + +/* Cache current page if next mii read/write is for switch */ + priv->current_page = page; +return ret <0 ? ret :0 ; +} +EXPORT_SYMBOL_GPL (an8855_mii_set_page);You could keep the implementation more contained, and you could avoid exporting
an8855_mii_set_page()andan8855_mfd_privto the MDIO passthrough driver, if you implement a virtual regmap and give it to the MDIO passthrough child MFD device.
Quoted 6 lines
If this bus supports only clause 22 accesses (and it looks like it does), you could expose a 16-bit regmap with a linear address space of 32 MDIO addresses x 65536 registers. The
bus->read()of the MDIO bus passthrough just performsregmap_read(), andbus->write()just performsregmap_write(). The MFD driver decodes the regmap address into a PHY address and a regnum, and performs the page switching locally, if needed.
Doesn't regmap add lots of overhead tho? Maybe I should really change the switch regmap to apply a save/restore logic?
With an implementation like that current_page is not needed anymore. And I feel additional read/write are ok for switch OP.
On mdio I can use the parent-mdio-bus property to get the bus directly without using MFD priv.
What do you think?
Signature · 1 line
Ansuel
Andrew Lunn
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 1 line
Doesn't regmap add lots of overhead tho?
Compared to what. MDIO operates over a 2.5MHz bus, assuming it is true MDIO. The CPU overhead of regmap is probably negligible compared to waiting for MDIO transactions to finish.
Andrew
Vladimir Oltean
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
In reply to Christian MarangiQuoted 10 lines · Christian Marangi
Doesn't regmap add lots of overhead tho? Maybe I should really change the switch regmap to apply a save/restore logic?
With an implementation like that
current_pageis not needed anymore. And I feel additional read/write are ok for switch OP.On mdio I can use the parent-mdio-bus property to get the bus directly without using MFD priv.
What do you think?
If performance is a relevant factor at all, it will be hard to measure it, other than with synthetic tests (various mixes of switch and PHY register access). Though since you mention it, it would be interesting to see a comparison of the 3 arbitration methods. This could probably be all done from the an8855_mfd_probe() calling context: read a switch register and a PHY register 100K times and see how long it took, then read 2 switch registers and a PHY register 100K times, then 3 switch registers.... At some point, we should start seeing the penalty of the page restoration in Andrew's proposal, because that will be done after each switch register read. Just curious to put it into perspective and see how soon it starts to make a difference. And this test will also answer the regmap overhead issue.
Re: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 12 lines · Vladimir Oltean
Quoted 10 lines · Christian Marangi
Doesn't regmap add lots of overhead tho? Maybe I should really change the switch regmap to apply a save/restore logic?
With an implementation like that
current_pageis not needed anymore. And I feel additional read/write are ok for switch OP.On mdio I can use the parent-mdio-bus property to get the bus directly without using MFD priv.
What do you think?
Quoted 10 lines
If performance is a relevant factor at all, it will be hard to measure it, other than with synthetic tests (various mixes of switch and PHY register access). Though since you mention it, it would be interesting to see a comparison of the 3 arbitration methods. This could probably be all done from the
an8855_mfd_probe()calling context: read a switch register and a PHY register 100K times and see how long it took, then read 2 switch registers and a PHY register 100K times, then 3 switch registers.... At some point, we should start seeing the penalty of the page restoration in Andrew's proposal, because that will be done after each switch register read. Just curious to put it into perspective and see how soon it starts to make a difference. And this test will also answer the regmap overhead issue.
Ok sorry for the delay as I had to tackle an annoying crypto driver...
I was also curious about this and I hope I tested this correctly...
The testing code is this. Following Vladimir testing and simple time comparision before and after. I used 100 times as 100k was very big. From the results we can derive our conclusions.
static void test(struct an8855_mfd_priv *priv, struct regmap *regmap, struct regmap *regmap_phy)
{
ktime_t start_time, end_time;
// struct mii_bus *bus = priv->bus;
s64 elapsed_ns;
u32 val;
int times = 1;
int i, j;
start_time = ktime_get();
for (i = 0; i < 100; i++) {
for (j = 0; j < times; j++) {
regmap_read(regmap, 0x10005000, &val);
}
// mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
// // an8855_mii_set_page(priv, priv->switch_addr, 0);
// __mdiobus_read(bus, priv->switch_addr, 0x1);
// mutex_unlock(&bus->mdio_lock);
regmap_read(regmap_phy,
FIELD_PREP(GENMASK(20, 16), priv->switch_addr) |
FIELD_PREP(GENMASK(15, 0), 0x1),
&val);
times++;
}
end_time = ktime_get();
elapsed_ns = ktime_to_ns(ktime_sub(end_time, start_time));
pr_info("Time spent in the code block: %lld ns\n", elapsed_ns);
}With the code changed accordingly.
switch regmap + page (proposed implementation)
Time spent in the code block: 866179846 ns
switch regmap + phy regmap (proposed implementation + PHY regmap) Time spent in the code block: 861326846 ns
switch regmap restore (switch regmap read/set/restore page) Time spent in the code block: 1151011308 ns
switch regmap restore + phy regmap (switch regmap read/set/restore pgae
+ PHY regmap)
Time spent in the code block: 1147400462 ns
We can see that:
- as suggested regmap doesn't cause any performance penality. It does even produce better result.
- the read/set/restore implementation gives worse performance.
So I guess I will follow the path of regmap + cache page. What do you think?
Signature · 1 line
Ansuel
Vladimir Oltean
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 7 lines · Christian Marangi
We can see that:
- as suggested regmap doesn't cause any performance penality. It does even produce better result.
- the read/set/restore implementation gives worse performance.So I guess I will follow the path of regmap + cache page. What do you think?
I'm not seeing results with the "times" variable changed, but in general, I guess the "switch regmap + page" and "switch regmap + phy regmap" will remain neck and neck in terms of performance, surpassing the "switch regmap restore" techniques more and more as "times" increases. So going with a PHY regmap probably sounds good.
Vladimir Oltean
maintainerRe: [net-next PATCH v11 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD
Quoted 6 lines · Vladimir Oltean
Quoted 5 lines · Christian Marangi
We can see that:
- as suggested regmap doesn't cause any performance penality. It does even produce better result.
- the read/set/restore implementation gives worse performance.
Quoted 8 lines
Quoted 2 lines
So I guess I will follow the path of regmap + cache page. What do you think?
I'm not seeing results with the "times" variable changed, but in general, I guess the "switch regmap + page" and "switch regmap + phy regmap" will remain neck and neck in terms of performance, surpassing the "switch regmap restore" techniques more and more as "times" increases. So going with a PHY regmap probably sounds good.
Could you find a way to reuse Maxime's mdio-regmap.c driver? Either create separate regmaps for each PHY address, or make that driver accept a configuration which isn't limited to a single ctx->valid_addr?
PATCH v11 6/9 net: mdio: Add Airoha AN8855 Switch MDIO Passtrough
In reply to Christian MarangiAdd Airoha AN8855 Switch driver to register a MDIO passtrough as switch address is shared with the internal PHYs and require additional page handling.
This requires the upper Switch MFD to be probed and init to actually work.
--- MAINTAINERS | 1 + drivers/net/mdio/Kconfig | 9 +++ drivers/net/mdio/Makefile | 1 + drivers/net/mdio/mdio-an8855.c | 113 +++++++++++++++++++++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 drivers/net/mdio/mdio-an8855.c
MAINTAINERS +1 -0
@@ -722,6 +722,7 @@ F: Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml F: Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml F: drivers/mfd/airoha-an8855.c +F: drivers/net/mdio/mdio-an8855.c AIROHA ETHERNET DRIVER M: Lorenzo Bianconi <[email protected]>
drivers/net/mdio/Kconfig +9 -0
@@ -61,6 +61,15 @@ config MDIO_XGENE This module provides a driver for the MDIO busses found in the APM X-Gene SoC's. +config MDIO_AN8855 + tristate "Airoha AN8855 Switch MDIO bus controller" + depends on MFD_AIROHA_AN8855 + depends on OF_MDIO + help + This module provides a driver for the Airoha AN8855 Switch + that requires a MDIO passtrough as switch address is shared + with the internal PHYs and requires additional page handling. + config MDIO_ASPEED tristate "ASPEED MDIO bus controller" depends on ARCH_ASPEED || COMPILE_TEST
drivers/net/mdio/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_ACPI_MDIO) += acpi_mdio.o obj-$(CONFIG_FWNODE_MDIO) += fwnode_mdio.o obj-$(CONFIG_OF_MDIO) += of_mdio.o +obj-$(CONFIG_MDIO_AN8855) += mdio-an8855.o obj-$(CONFIG_MDIO_ASPEED) += mdio-aspeed.o obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o
drivers/net/mdio/mdio-an8855.c new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.45.2
Andrew Lunn
maintainerRe: [net-next PATCH v11 6/9] net: mdio: Add Airoha AN8855 Switch MDIO Passtrough
Quoted 7 lines
drivers/net/mdio/mdio-an8855.c new file +7
-0+static int an855_phy_restore_page (struct an8855_mfd_priv *priv, + int phy) __must_hold(&priv->bus->mdio_lock) +{ +/* Check PHY page only for addr shared with switch */ +if (phy != priv->switch_addr) +return 0 ; +
drivers/net/mdio/mdio-an8855.c line 27
Quoted 10 lines
drivers/net/mdio/mdio-an8855.c new file +10
-0+/* Don't restore page if it's not set to switch page */ +if (priv->current_page !=FIELD_GET (AN8855_PHY_PAGE , +AN8855_PHY_PAGE_EXTENDED_4 )) +return 0 ; + +/* Restore page to 0, PHY might change page right after but that +* will be ignored as it won't be a switch page. +*/ +return an8855_mii_set_page (priv, phy,AN8855_PHY_PAGE_STANDARD ); +}
I don't really understand what is going on here. Maybe the commit message needs expanding, or the function names changing.
Generally, i would expect a save/restore action. Save the current page, swap to the PHY page, do the PHY access, and then restore to the saved page.
Andrew
Re: [net-next PATCH v11 6/9] net: mdio: Add Airoha AN8855 Switch MDIO Passtrough
Quoted 21 lines · Andrew Lunn
Quoted 7 lines
drivers/net/mdio/mdio-an8855.c new file +7
-0+static int an855_phy_restore_page (struct an8855_mfd_priv *priv, + int phy) __must_hold(&priv->bus->mdio_lock) +{ +/* Check PHY page only for addr shared with switch */ +if (phy != priv->switch_addr) +return 0 ; +drivers/net/mdio/mdio-an8855.c line 27
Quoted 10 lines
drivers/net/mdio/mdio-an8855.c new file +10
-0+/* Don't restore page if it's not set to switch page */ +if (priv->current_page !=FIELD_GET (AN8855_PHY_PAGE , +AN8855_PHY_PAGE_EXTENDED_4 )) +return 0 ; + +/* Restore page to 0, PHY might change page right after but that +* will be ignored as it won't be a switch page. +*/ +return an8855_mii_set_page (priv, phy,AN8855_PHY_PAGE_STANDARD ); +}I don't really understand what is going on here. Maybe the commit message needs expanding, or the function names changing.
Quoted 4 lines
Generally, i would expect a save/restore action. Save the current page, swap to the PHY page, do the PHY access, and then restore to the saved page.
Idea is to save on extra read/write on subsequent write on the same page.
Idea here is that PHY will receive most of the read (for status poll) hence in 90% of the time page will be 0.
And switch will receive read/write only on setup or fdb/vlan access on configuration so it will receive subsequent write on the same page. (page 4)
PHY might also need to write on page 1 on setup but never on page 4 as that is reserved for switch.
Making the read/swap/write/restore adds 2 additional operation that can really be skipped 90% of the time.
Also curret_page cache is indirectly protected by the mdio lock.
So in short this function makes sure PHY for port 0 is configured on the right page based on the prev page set.
An alternative way might be assume PHY is always on page 0 and any switch operation save and restore the page.
Hope it's clear now why this is needed. Is this ok or you prefer the alternative way?
Signature · 1 line
Ansuel
Andrew Lunn
maintainerRe: [net-next PATCH v11 6/9] net: mdio: Add Airoha AN8855 Switch MDIO Passtrough
Quoted 45 lines · Christian Marangi
Quoted 21 lines · Andrew Lunn
Quoted 7 lines
drivers/net/mdio/mdio-an8855.c new file +7
-0+static int an855_phy_restore_page (struct an8855_mfd_priv *priv, + int phy) __must_hold(&priv->bus->mdio_lock) +{ +/* Check PHY page only for addr shared with switch */ +if (phy != priv->switch_addr) +return 0 ; +drivers/net/mdio/mdio-an8855.c line 27
Quoted 10 lines
drivers/net/mdio/mdio-an8855.c new file +10
-0+/* Don't restore page if it's not set to switch page */ +if (priv->current_page !=FIELD_GET (AN8855_PHY_PAGE , +AN8855_PHY_PAGE_EXTENDED_4 )) +return 0 ; + +/* Restore page to 0, PHY might change page right after but that +* will be ignored as it won't be a switch page. +*/ +return an8855_mii_set_page (priv, phy,AN8855_PHY_PAGE_STANDARD ); +}I don't really understand what is going on here. Maybe the commit message needs expanding, or the function names changing.
Quoted 4 lines
Generally, i would expect a save/restore action. Save the current page, swap to the PHY page, do the PHY access, and then restore to the saved page.
Idea is to save on extra read/write on subsequent write on the same page.
Idea here is that PHY will receive most of the read (for status poll) hence in 90% of the time page will be 0.
And switch will receive read/write only on setup or fdb/vlan access on configuration so it will receive subsequent write on the same page. (page 4)
PHY might also need to write on page 1 on setup but never on page 4 as that is reserved for switch.
Making the read/swap/write/restore adds 2 additional operation that can really be skipped 90% of the time.
Also
curret_pagecache is indirectly protected by the mdio lock.
Quoted 8 lines
So in short this function makes sure PHY for port 0 is configured on the right page based on the prev page set.
An alternative way might be assume PHY is always on page 0 and any switch operation save and restore the page.
Hope it's clear now why this is needed. Is this ok or you prefer the alternative way?
Please think about naming. I'm not sure _restore_ is the correct name for the function. Maybe select. And i suggest adding some comments to explain what is going on, since it is not obvious from the code in this file, you probably need to cross reference it with code in the DSA driver as well.
Andrew
PATCH v11 7/9 nvmem: an8855: Add support for Airoha AN8855 Switch EFUSE
In reply to Christian MarangiAdd support for Airoha AN8855 Switch EFUSE. These EFUSE might be used for calibration data for the internal switch PHYs.
--- MAINTAINERS | 1 + drivers/nvmem/Kconfig | 11 +++++++ drivers/nvmem/Makefile | 2 ++ drivers/nvmem/an8855-efuse.c | 63 ++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 drivers/nvmem/an8855-efuse.c
MAINTAINERS +1 -0
@@ -723,6 +723,7 @@ F: Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml F: drivers/mfd/airoha-an8855.c F: drivers/net/mdio/mdio-an8855.c +F: drivers/nvmem/an8855-efuse.c AIROHA ETHERNET DRIVER M: Lorenzo Bianconi <[email protected]>
drivers/nvmem/Kconfig +11 -0
@@ -28,6 +28,17 @@ source "drivers/nvmem/layouts/Kconfig" # Devices +config NVMEM_AN8855_EFUSE + tristate "Airoha AN8855 eFuse support" + depends on MFD_AIROHA_AN8855 || COMPILE_TEST + help + Say y here to enable support for reading eFuses on Airoha AN8855 + Switch. These are e.g. used to store factory programmed + calibration data required for the PHY. + + This driver can also be built as a module. If so, the module will + be called nvmem-an8855-efuse. + config NVMEM_APPLE_EFUSES tristate "Apple eFuse support" depends on ARCH_APPLE || COMPILE_TEST
drivers/nvmem/Makefile +2 -0
@@ -10,6 +10,8 @@ nvmem_layouts-y := layouts.o obj-y += layouts/ # Devices +obj-$(CONFIG_NVMEM_AN8855_EFUSE) += nvmem-an8855-efuse.o +nvmem-an8855-efuse-y := an8855-efuse.o obj-$(CONFIG_NVMEM_APPLE_EFUSES) += nvmem-apple-efuses.o nvmem-apple-efuses-y := apple-efuses.o obj-$(CONFIG_NVMEM_BCM_OCOTP) += nvmem-bcm-ocotp.o
drivers/nvmem/an8855-efuse.c new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v11 8/9 net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver
In reply to Christian MarangiAdd Airoha AN8855 5-Port Gigabit DSA switch. Switch can support 10M, 100M, 1Gb, 2.5G and 5G Ethernet Speed but 5G is currently error out as it's not currently supported as requires additional configuration for the PCS.
The switch is also a nvmem-provider as it does have EFUSE to calibrate the internal PHYs.
--- MAINTAINERS | 2 + drivers/net/dsa/Kconfig | 9 + drivers/net/dsa/Makefile | 1 + drivers/net/dsa/an8855.c | 2310 ++++++++++++++++++++++++++++++++++++++ drivers/net/dsa/an8855.h | 783 +++++++++++++ 5 files changed, 3105 insertions(+) create mode 100644 drivers/net/dsa/an8855.c create mode 100644 drivers/net/dsa/an8855.h
MAINTAINERS +2 -0
@@ -722,6 +722,8 @@ F: Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml F: Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml F: Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml F: drivers/mfd/airoha-an8855.c +F: drivers/net/dsa/an8855.c +F: drivers/net/dsa/an8855.h F: drivers/net/mdio/mdio-an8855.c F: drivers/nvmem/an8855-efuse.c
drivers/net/dsa/Kconfig +9 -0
@@ -24,6 +24,15 @@ config NET_DSA_LOOP This enables support for a fake mock-up switch chip which exercises the DSA APIs. +config NET_DSA_AN8855 + tristate "Airoha AN8855 Ethernet switch support" + depends on MFD_AIROHA_AN8855 || COMPILE_TEST + depends on NET_DSA + select NET_DSA_TAG_MTK + help + This enables support for the Airoha AN8855 Ethernet switch + chip. + source "drivers/net/dsa/hirschmann/Kconfig" config NET_DSA_LANTIQ_GSWIP
drivers/net/dsa/Makefile +1 -0
@@ -5,6 +5,7 @@ obj-$(CONFIG_NET_DSA_LOOP) += dsa_loop.o ifdef CONFIG_NET_DSA_LOOP obj-$(CONFIG_FIXED_PHY) += dsa_loop_bdinfo.o endif +obj-$(CONFIG_NET_DSA_AN8855) += an8855.o obj-$(CONFIG_NET_DSA_LANTIQ_GSWIP) += lantiq_gswip.o obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o obj-$(CONFIG_NET_DSA_MT7530_MDIO) += mt7530-mdio.o
drivers/net/dsa/an8855.c new file +2310 -0
2,310 lines not on this page · raw message
drivers/net/dsa/an8855.h new file +783 -0
660 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.45.2
Part of the diff is not shown here. View the raw message.
Vladimir Oltean
maintainerRe: [net-next PATCH v11 8/9] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver
Quoted 7 lines · Christian Marangi
Add Airoha AN8855 5-Port Gigabit DSA switch. Switch can support 10M, 100M, 1Gb, 2.5G and 5G Ethernet Speed but 5G is currently error out as it's not currently supported as requires additional configuration for the PCS.
The switch is also a nvmem-provider as it does have EFUSE to calibrate the internal PHYs.
This second paragraph is no longer actual.
Quoted 8 lines
Signed-off-by Christian Marangi <[email protected]>---
index2d10b4d6cfbb..99b1569ba35b100644drivers/net/dsa/Kconfig +0
-0@@ -24,6 +24,15 @@ config NET_DSA_LOOP This enables support for a fake mock-up switch chip which
drivers/net/dsa/Kconfig config NET_DSA_LOOP · line 34
Quoted 10 lines
drivers/net/dsa/Kconfig +8
-0exercises the DSA APIs. +config NET_DSA_AN8855 + tristate "Airoha AN8855 Ethernet switch support" + depends on MFD_AIROHA_AN8855 || COMPILE_TEST + depends on NET_DSA + select NET_DSA_TAG_MTK + help + This enables support for the Airoha AN8855 Ethernet switch + chip.
Not chip anymore, but for the switch *inside* the chip.
Quoted 41 lines
drivers/net/dsa/Kconfig +1
-0+ source "drivers/net/dsa/hirschmann/Kconfig" config NET_DSA_LANTIQ_GSWIPdrivers/net/dsa/an8855.c new file +31
-0@@ -0,0 +1,2310 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Airoha AN8855 DSA Switch driver +* Copyright (C) 2023 Min Yao <[email protected]> +* Copyright (C) 2024 Christian Marangi <[email protected]> +*/ +#include <linux/bitfield.h> +#include <linux/ethtool.h> +#include <linux/etherdevice.h> +#include <linux/gpio/consumer.h> +#include <linux/if_bridge.h> +#include <linux/iopoll.h> +#include <linux/netdevice.h> +#include <linux/of_net.h> +#include <linux/of_platform.h> +#include <linux/phylink.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> +#include <net/dsa.h> + +#include "an8855.h" + +static const struct an8855_mib_desc an8855_mib[] = { +MIB_DESC (1 ,AN8855_PORT_MIB_TX_DROP ,"TxDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_TX_CRC_ERR ,"TxCrcErr" ), +MIB_DESC (1 ,AN8855_PORT_MIB_TX_COLLISION ,"TxCollision" ), +MIB_DESC (1 ,AN8855_PORT_MIB_TX_OVERSIZE_DROP ,"TxOversizeDrop" ), +MIB_DESC (2 ,AN8855_PORT_MIB_TX_BAD_PKT_BYTES ,"TxBadPktBytes" ), +MIB_DESC (1 ,AN8855_PORT_MIB_RX_DROP ,"RxDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_RX_FILTERING ,"RxFiltering" ), +MIB_DESC (1 ,AN8855_PORT_MIB_RX_CRC_ERR ,"RxCrcErr" ),
drivers/net/dsa/an8855.c line 41
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+MIB_DESC (1 ,AN8855_PORT_MIB_RX_CTRL_DROP ,"RxCtrlDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_RX_INGRESS_DROP ,"RxIngressDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_RX_ARL_DROP ,"RxArlDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_FLOW_CONTROL_DROP ,"FlowControlDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_WRED_DROP ,"WredDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_MIRROR_DROP ,"MirrorDrop" ), +MIB_DESC (2 ,AN8855_PORT_MIB_RX_BAD_PKT_BYTES ,"RxBadPktBytes" ), +MIB_DESC (1 ,AN8855_PORT_MIB_RXS_FLOW_SAMPLING_PKT_DROP ,"RxsFlowSamplingPktDrop" ), +MIB_DESC (1 ,AN8855_PORT_MIB_RXS_FLOW_TOTAL_PKT_DROP ,"RxsFlowTotalPktDrop" ), + MIB_DESC(1, AN8855_PORT_MIB_PORT_CONTROL_DROP, "PortControlDrop"),
There isn't any standard counter to expose these leftover ethtool -S unstructured counters?
@Andrew, @Jakub: the more we push developers to stop reporting standard counters as unstructured, the harder it will be to debug packet loss on the CPU port, since we don't report anything structure there (no netdev). For ethtool -S, we append the CPU port counters to the conduit counters. Any ideas for gaining introspection into the structured counters of the CPU port?
Quoted 31 lines
drivers/net/dsa/an8855.c new file +31
-0+}; + +static int +an8855_mib_init (struct an8855_priv *priv) +{ +int ret; + + ret =regmap_write (priv->regmap,AN8855_MIB_CCR , +AN8855_CCR_MIB_ENABLE ); +if (ret) +return ret; + +return regmap_write (priv->regmap,AN8855_MIB_CCR , +AN8855_CCR_MIB_ACTIVATE ); +} + +static void an8855_fdb_write (struct an8855_priv *priv,u16 vid, +u8 port_mask,const u8 *mac, + bool add) __must_hold(&priv->reg_mutex) +{ +u32 mac_reg[2 ] = { }; +u32 reg; + + mac_reg[0 ] |=FIELD_PREP (AN8855_ATA1_MAC0 , mac[0 ]); + mac_reg[0 ] |=FIELD_PREP (AN8855_ATA1_MAC1 , mac[1 ]); + mac_reg[0 ] |=FIELD_PREP (AN8855_ATA1_MAC2 , mac[2 ]); + mac_reg[0 ] |=FIELD_PREP (AN8855_ATA1_MAC3 , mac[3 ]); + mac_reg[1 ] |=FIELD_PREP (AN8855_ATA2_MAC4 , mac[4 ]); + mac_reg[1 ] |=FIELD_PREP (AN8855_ATA2_MAC5 , mac[5 ]); + + regmap_bulk_write(priv->regmap, AN8855_ATA1, mac_reg,
drivers/net/dsa/an8855.c line 82
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+ ARRAY_SIZE(mac_reg)); + + reg =AN8855_ATWD_IVL ; +if (add) + reg |=AN8855_ATWD_VLD ; + reg |=FIELD_PREP (AN8855_ATWD_VID , vid); + reg |=FIELD_PREP (AN8855_ATWD_FID ,AN8855_FID_BRIDGED ); +regmap_write (priv->regmap,AN8855_ATWD , reg); +regmap_write (priv->regmap,AN8855_ATWD2 , +FIELD_PREP (AN8855_ATWD2_PORT , port_mask));
I guess regmap failures here shouldn't fail silently.
Quoted 74 lines
drivers/net/dsa/an8855.c new file +74
-0+} + +static void an8855_fdb_read (struct an8855_priv *priv,struct an8855_fdb *fdb) +{ +u32 reg[4 ]; + +regmap_bulk_read (priv->regmap,AN8855_ATRD0 , reg, +ARRAY_SIZE (reg)); + + fdb->live =FIELD_GET (AN8855_ATRD0_LIVE , reg[0 ]); + fdb->type =FIELD_GET (AN8855_ATRD0_TYPE , reg[0 ]); + fdb->ivl =FIELD_GET (AN8855_ATRD0_IVL , reg[0 ]); + fdb->vid =FIELD_GET (AN8855_ATRD0_VID , reg[0 ]); + fdb->fid =FIELD_GET (AN8855_ATRD0_FID , reg[0 ]); + fdb->aging =FIELD_GET (AN8855_ATRD1_AGING , reg[1 ]); + fdb->port_mask =FIELD_GET (AN8855_ATRD3_PORTMASK , reg[3 ]); + fdb->mac[0 ] =FIELD_GET (AN8855_ATRD2_MAC0 , reg[2 ]); + fdb->mac[1 ] =FIELD_GET (AN8855_ATRD2_MAC1 , reg[2 ]); + fdb->mac[2 ] =FIELD_GET (AN8855_ATRD2_MAC2 , reg[2 ]); + fdb->mac[3 ] =FIELD_GET (AN8855_ATRD2_MAC3 , reg[2 ]); + fdb->mac[4 ] =FIELD_GET (AN8855_ATRD1_MAC4 , reg[1 ]); + fdb->mac[5 ] =FIELD_GET (AN8855_ATRD1_MAC5 , reg[1 ]); + fdb->noarp = !!FIELD_GET (AN8855_ATRD0_ARP , reg[0 ]); +} + +static int an8855_fdb_cmd (struct an8855_priv *priv,u32 cmd, + u32 *rsp) __must_hold(&priv->reg_mutex) +{ +u32 val; +int ret; + +/* Set the command operating upon the MAC address entries */ + val =AN8855_ATC_BUSY | cmd; + ret =regmap_write (priv->regmap,AN8855_ATC , val); +if (ret) +return ret; + + ret =regmap_read_poll_timeout (priv->regmap,AN8855_ATC , val, + !(val &AN8855_ATC_BUSY ),20 ,200000 ); +if (ret) +return ret; + +if (rsp) + *rsp = val; + +return 0 ; +} + +static void +an8855_port_stp_state_set (struct dsa_switch *ds,int port,u8 state) +{ +struct dsa_port *dp =dsa_to_port (ds, port); +struct an8855_priv *priv = ds->priv; +bool learning = false; +u32 stp_state; + +switch (state) { +case BR_STATE_DISABLED : + stp_state =AN8855_STP_DISABLED ; +break ; +case BR_STATE_BLOCKING : + stp_state =AN8855_STP_BLOCKING ; +break ; +case BR_STATE_LISTENING : + stp_state =AN8855_STP_LISTENING ; +break ; +case BR_STATE_LEARNING : + stp_state =AN8855_STP_LEARNING ; + learning = dp->learning; +break ; +case BR_STATE_FORWARDING : + learning = dp->learning; + fallthrough; +default :
drivers/net/dsa/an8855.c line 166
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+ stp_state =AN8855_STP_FORWARDING ; +break ; + } + +regmap_update_bits (priv->regmap,AN8855_SSP_P (port), +AN8855_FID_PST_MASK (AN8855_FID_BRIDGED ), +AN8855_FID_PST_VAL (AN8855_FID_BRIDGED , stp_state)); + +regmap_update_bits (priv->regmap,AN8855_PSC_P (port),AN8855_SA_DIS , + learning ?0 :AN8855_SA_DIS );
Similar: please test the regmap return code and print an error if it fails.
drivers/net/dsa/an8855.c line 177
Quoted 11 lines
drivers/net/dsa/an8855.c new file +11
-0+} + +static void an8855_port_fast_age (struct dsa_switch *ds,int port) +{ +struct an8855_priv *priv = ds->priv; +int ret; + +/* Set to clean Dynamic entry */ + ret =regmap_write (priv->regmap,AN8855_ATA2 ,AN8855_ATA2_TYPE ); +if (ret) +return ;
Similar regarding silent failures. This should apply to the entire driver, please review again, there are too many instances to note them all.
Quoted 4 lines
drivers/net/dsa/an8855.c new file +4
-0+ +/* Set Port */ + ret =regmap_write (priv->regmap,AN8855_ATWD2 , +FIELD_PREP (AN8855_ATWD2_PORT ,BIT (port)));
drivers/net/dsa/an8855.c
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+if (ret) +return ; + +/* Flush Dynamic entry at port */ +an8855_fdb_cmd (priv,AN8855_ATC_MAT (AND8855_FDB_MAT_MAC_TYPE_PORT ) | +AN8855_FDB_FLUSH ,NULL ); +} + +static int an8855_port_set_pid (struct an8855_priv *priv,int port, +u16 pid)
s/pid/pvid/
Quoted 98 lines
drivers/net/dsa/an8855.c new file +98
-0+{ +int ret; + + ret =regmap_update_bits (priv->regmap,AN8855_PPBV1_P (port), +AN8855_PPBV_G0_PORT_VID , +FIELD_PREP (AN8855_PPBV_G0_PORT_VID , pid)); +if (ret) +return ret; + +return regmap_update_bits (priv->regmap,AN8855_PVID_P (port), +AN8855_G0_PORT_VID , +FIELD_PREP (AN8855_G0_PORT_VID , pid)); +} + +static int an8855_port_vlan_filtering (struct dsa_switch *ds,int port, +bool vlan_filtering, +struct netlink_ext_ack *extack) +{ +struct an8855_priv *priv = ds->priv; +u32 val; +int ret; + +/* The port is being kept as VLAN-unaware port when bridge is +* set up with vlan_filtering not being set, Otherwise, the +* port and the corresponding CPU port is required the setup +* for becoming a VLAN-aware port. +*/ +if (vlan_filtering) { +u32 acc_frm; +/* CPU port is set to fallback mode to let untagged +* frames pass through. +*/ + ret =an8855_port_set_vlan_mode (priv,AN8855_CPU_PORT , +AN8855_PORT_FALLBACK_MODE , +AN8855_VLAN_EG_CONSISTENT , +AN8855_VLAN_USER , +AN8855_VLAN_ACC_ALL ); +if (ret) +return ret; + + ret =regmap_read (priv->regmap,AN8855_PVID_P (port), &val); +if (ret) +return ret; + +/* Only accept tagged frames if PVID is not set */ +if (FIELD_GET (AN8855_G0_PORT_VID , val) !=AN8855_PORT_VID_DEFAULT ) + acc_frm =AN8855_VLAN_ACC_TAGGED ; +else + acc_frm =AN8855_VLAN_ACC_ALL ; + +/* Trapped into security mode allows packet forwarding through VLAN +* table lookup. +* Set the port as a user port which is to be able to recognize VID +* from incoming packets before fetching entry within the VLAN table. +*/ + ret =an8855_port_set_vlan_mode (priv, port, +AN8855_PORT_SECURITY_MODE , +AN8855_VLAN_EG_DISABLED , +AN8855_VLAN_USER , + acc_frm); +if (ret) +return ret; + }else { +bool disable_cpu_vlan = true; +struct dsa_port *dp; +u32 port_mode; + +/* This is called after .port_bridge_leave when leaving a VLAN-aware +* bridge. Don't set standalone ports to fallback mode. +*/ +if (dsa_port_bridge_dev_get (dsa_to_port (ds, port))) + port_mode =AN8855_PORT_FALLBACK_MODE ; +else + port_mode =AN8855_PORT_MATRIX_MODE ; + +/* When a port is removed from the bridge, the port would be set up +* back to the default as is at initial boot which is a VLAN-unaware +* port. +*/ + ret =an8855_port_set_vlan_mode (priv, port, port_mode, +AN8855_VLAN_EG_CONSISTENT , +AN8855_VLAN_TRANSPARENT , +AN8855_VLAN_ACC_ALL ); +if (ret) +return ret; + +/* Restore default PVID */ + ret =an8855_port_set_pid (priv, port,AN8855_PORT_VID_DEFAULT ); +if (ret) +return ret; + +dsa_switch_for_each_user_port (dp, ds) { +if (dsa_port_is_vlan_filtering (dp)) { + disable_cpu_vlan = false; +break ; + } + } +
drivers/net/dsa/an8855.c line 706
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+if (disable_cpu_vlan) { + ret =an8855_port_set_vlan_mode (priv,AN8855_CPU_PORT , +AN8855_PORT_MATRIX_MODE , +AN8855_VLAN_EG_CONSISTENT , +AN8855_VLAN_USER , +AN8855_VLAN_ACC_ALL ); +if (ret) +return ret; + } + }
I think this function would look less cluttered as two:
if (vlan_filtering) return an8855_port_enable_vlan_filtering(); return an8855_port_disable_vlan_filtering();
Quoted 7 lines
drivers/net/dsa/an8855.c new file +7
-0+ +return 0 ; +} + +static int +an8855_port_mdb_add(struct dsa_switch *ds, int port, + const struct switchdev_obj_port_mdb *mdb,
drivers/net/dsa/an8855.c line 815
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+ struct dsa_db db) +{ +struct an8855_priv *priv = ds->priv; +const u8 *addr = mdb->addr; +u16 vid = mdb->vid; +u8 port_mask =0 ; +u32 val; +int ret; + +/* Set the vid to the port vlan id if no vid is set */
The comment needs to not be wrong. "no vid is set" actually means this is a VLAN-unaware entry (matches packets when the bridge is under vlan_filtering=0, or when the port is standalone). This is why you set it to AN8855_PORT_VID_DEFAULT, because
Quoted 174 lines
drivers/net/dsa/an8855.c new file +174
-0+if (!vid) + vid =AN8855_PORT_VID_DEFAULT ; + +mutex_lock (&priv->reg_mutex); + +an8855_fdb_write (priv, vid,0 , addr, false); +if (!an8855_fdb_cmd (priv,AN8855_FDB_READ ,NULL )) { + ret =regmap_read (priv->regmap,AN8855_ATRD3 , &val); +if (ret) + goto exit; + + port_mask =FIELD_GET (AN8855_ATRD3_PORTMASK , val); + } + + port_mask |=BIT (port); +an8855_fdb_write (priv, vid, port_mask, addr, true); + ret =an8855_fdb_cmd (priv,AN8855_FDB_WRITE ,NULL ); + +exit: +mutex_unlock (&priv->reg_mutex); + +return ret; +} + +static int +an8855_port_mdb_del (struct dsa_switch *ds,int port, +const struct switchdev_obj_port_mdb *mdb, +struct dsa_db db) +{ +struct an8855_priv *priv = ds->priv; +const u8 *addr = mdb->addr; +u16 vid = mdb->vid; +u8 port_mask =0 ; +u32 val; +int ret; + +/* Set the vid to the port vlan id if no vid is set */ +if (!vid) + vid =AN8855_PORT_VID_DEFAULT ; + +mutex_lock (&priv->reg_mutex); + +an8855_fdb_write (priv, vid,0 , addr,0 ); +if (!an8855_fdb_cmd (priv,AN8855_FDB_READ ,NULL )) { + ret =regmap_read (priv->regmap,AN8855_ATRD3 , &val); +if (ret) + goto exit; + + port_mask =FIELD_GET (AN8855_ATRD3_PORTMASK , val); + } + + port_mask &= ~BIT (port); +an8855_fdb_write (priv, vid, port_mask, addr, port_mask ? true : false); + ret =an8855_fdb_cmd (priv,AN8855_FDB_WRITE ,NULL ); + +exit: +mutex_unlock (&priv->reg_mutex); + +return ret; +} + +static int +an8855_port_change_mtu (struct dsa_switch *ds,int port,int new_mtu) +{ +struct an8855_priv *priv = ds->priv; +int length; +u32 val; + +/* When a new MTU is set, DSA always set the CPU port's MTU to the +* largest MTU of the slave ports. Because the switch only has a global +* RX length register, only allowing CPU port here is enough. +*/ +if (!dsa_is_cpu_port (ds, port)) +return 0 ; + +/* RX length also includes Ethernet header, MTK tag, and FCS length */ + length = new_mtu +ETH_HLEN +MTK_TAG_LEN +ETH_FCS_LEN ; +if (length <=1522 ) + val =AN8855_MAX_RX_PKT_1518_1522 ; +else if (length <=1536 ) + val =AN8855_MAX_RX_PKT_1536 ; +else if (length <=1552 ) + val =AN8855_MAX_RX_PKT_1552 ; +else if (length <=3072 ) + val =AN8855_MAX_RX_JUMBO_3K ; +else if (length <=4096 ) + val =AN8855_MAX_RX_JUMBO_4K ; +else if (length <=5120 ) + val =AN8855_MAX_RX_JUMBO_5K ; +else if (length <=6144 ) + val =AN8855_MAX_RX_JUMBO_6K ; +else if (length <=7168 ) + val =AN8855_MAX_RX_JUMBO_7K ; +else if (length <=8192 ) + val =AN8855_MAX_RX_JUMBO_8K ; +else if (length <=9216 ) + val =AN8855_MAX_RX_JUMBO_9K ; +else if (length <=12288 ) + val =AN8855_MAX_RX_JUMBO_12K ; +else if (length <=15360 ) + val =AN8855_MAX_RX_JUMBO_15K ; +else + val =AN8855_MAX_RX_JUMBO_16K ; + +/* Enable JUMBO packet */ +if (length >1552 ) + val |=AN8855_MAX_RX_PKT_JUMBO ; + +return regmap_update_bits (priv->regmap,AN8855_GMACCR , +AN8855_MAX_RX_JUMBO |AN8855_MAX_RX_PKT_LEN , + val); +} + +static int +an8855_port_max_mtu (struct dsa_switch *ds,int port) +{ +return AN8855_MAX_MTU ; +} + +static void +an8855_get_strings (struct dsa_switch *ds,int port,u32 stringset, +uint8_t *data) +{ +int i; + +if (stringset !=ETH_SS_STATS ) +return ; + +for (i =0 ; i <ARRAY_SIZE (an8855_mib); i++) +ethtool_puts (&data, an8855_mib[i].name); +} + +static void +an8855_read_port_stats (struct an8855_priv *priv,int port,u32 offset,u8 size, +uint64_t *data) +{ +u32 val, reg =AN8855_PORT_MIB_COUNTER (port) + offset; + +regmap_read (priv->regmap, reg, &val); + *data = val; + +if (size ==2 ) { +regmap_read (priv->regmap, reg +4 , &val); + *data |= (u64 )val <<32 ; + } +} + +static void +an8855_get_ethtool_stats (struct dsa_switch *ds,int port,uint64_t *data) +{ +struct an8855_priv *priv = ds->priv; +const struct an8855_mib_desc *mib; +int i; + +for (i =0 ; i <ARRAY_SIZE (an8855_mib); i++) { + mib = &an8855_mib[i]; + +an8855_read_port_stats (priv, port, mib->offset, mib->size, + data + i); + } +} + +static int +an8855_get_sset_count (struct dsa_switch *ds,int port,int sset) +{ +if (sset !=ETH_SS_STATS ) +return 0 ; + +return ARRAY_SIZE (an8855_mib); +} + +static int an8855_port_mirror_add(struct dsa_switch *ds, int port, + struct dsa_mall_mirror_tc_entry *mirror, + bool ingress,
drivers/net/dsa/an8855.c
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+ struct netlink_ext_ack *extack) +{ +struct an8855_priv *priv = ds->priv; +int monitor_port; +u32 val; +int ret; + +/* Check for existent entry */ +if ((ingress ? priv->mirror_rx : priv->mirror_tx) &BIT (port)) +return -EEXIST ;
Please set extack with an informational message, here and everywhere else where it is available.
Quoted 60 lines
drivers/net/dsa/an8855.c new file +60
-0+ + ret =regmap_read (priv->regmap,AN8855_MIR , &val); +if (ret) +return ret; + +/* AN8855 supports 4 monitor port, but only use first group */ + monitor_port =FIELD_GET (AN8855_MIRROR_PORT , val); +if (val &AN8855_MIRROR_EN && monitor_port != mirror->to_local_port) +return -EEXIST ; + + val =AN8855_MIRROR_EN ; + val |=FIELD_PREP (AN8855_MIRROR_PORT , mirror->to_local_port); + ret =regmap_update_bits (priv->regmap,AN8855_MIR , +AN8855_MIRROR_EN |AN8855_MIRROR_PORT , + val); +if (ret) +return ret; + + ret =regmap_set_bits (priv->regmap,AN8855_PCR_P (port), + ingress ?AN8855_PORT_RX_MIR :AN8855_PORT_TX_MIR ); +if (ret) +return ret; + +if (ingress) + priv->mirror_rx |=BIT (port); +else + priv->mirror_tx |=BIT (port); + +return 0 ; +} + +static void an8855_port_mirror_del (struct dsa_switch *ds,int port, +struct dsa_mall_mirror_tc_entry *mirror) +{ +struct an8855_priv *priv = ds->priv; + +if (mirror->ingress) + priv->mirror_rx &= ~BIT (port); +else + priv->mirror_tx &= ~BIT (port); + +regmap_clear_bits (priv->regmap,AN8855_PCR_P (port), + mirror->ingress ?AN8855_PORT_RX_MIR : +AN8855_PORT_TX_MIR ); + +if (!priv->mirror_rx && !priv->mirror_tx) +regmap_clear_bits (priv->regmap,AN8855_MIR ,AN8855_MIRROR_EN ); +} + +static int an8855_port_set_status (struct an8855_priv *priv,int port, +bool enable) +{ +if (enable) +return regmap_set_bits (priv->regmap,AN8855_PMCR_P (port), +AN8855_PMCR_TX_EN |AN8855_PMCR_RX_EN ); +else +return regmap_clear_bits (priv->regmap,AN8855_PMCR_P (port), +AN8855_PMCR_TX_EN |AN8855_PMCR_RX_EN ); +} +
drivers/net/dsa/an8855.c line 1196
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+static int an8855_port_enable (struct dsa_switch *ds,int port, +struct phy_device *phy) +{ +return an8855_port_set_status (ds->priv, port, true); +} + +static void an8855_port_disable (struct dsa_switch *ds,int port) +{ +an8855_port_set_status (ds->priv, port, false); +}
I'm tempted to suggest to just keep the implementations separate rather than centralized in a single an8855_port_set_status() with no common code. Then, the remaining an8855_port_set_status() call could be replaced with an8855_port_enable(..., phy=NULL), since this driver doesn't use the last argument anyway.
drivers/net/dsa/an8855.c line 1198
Quoted 2 lines
drivers/net/dsa/an8855.c new file +2
-0+ +static u32 en8855_get_phy_flags (struct dsa_switch *ds,int port)
Odd that this function name starts with en8855 when the rest of the driver starts with an8855. I've seen your conversation with Andrew and I understand why, but this is still unconventional.
Could this just go to the PHY driver completely?
Quoted 142 lines
drivers/net/dsa/an8855.c new file +142
-0+{ +struct an8855_priv *priv = ds->priv; + +/* PHY doesn't need calibration */ +if (!priv->phy_require_calib) +return 0 ; + +/* Use AN8855_PHY_FLAGS_EN_CALIBRATION to signal +* calibration needed. +*/ +return AN8855_PHY_FLAGS_EN_CALIBRATION ; +} + +static int +an8855_setup_pvid_vlan (struct an8855_priv *priv) +{ +u32 val; +int ret; + +/* Validate the entry with independent learning, keep the original +* ingress tag attribute. +*/ + val =AN8855_VA0_IVL_MAC |AN8855_VA0_EG_CON | +FIELD_PREP (AN8855_VA0_FID ,AN8855_FID_BRIDGED ) | +AN8855_VA0_PORT |AN8855_VA0_VLAN_VALID ; + ret =regmap_write (priv->regmap,AN8855_VAWD0 , val); +if (ret) +return ret; + +return an8855_vlan_cmd (priv,AN8855_VTCR_WR_VID , +AN8855_PORT_VID_DEFAULT ); +} + +static int an8855_setup (struct dsa_switch *ds) +{ +struct an8855_priv *priv = ds->priv; +struct dsa_port *dp; +int ret; + +/* Enable and reset MIB counters */ + ret =an8855_mib_init (priv); +if (ret) +return ret; + +dsa_switch_for_each_user_port (dp, ds) { +/* Disable MAC by default on all user ports */ + ret =an8855_port_set_status (priv, dp->index, false); +if (ret) +return ret; + +/* Individual user ports get connected to CPU port only */ + ret =regmap_write (priv->regmap,AN8855_PORTMATRIX_P (dp->index), +FIELD_PREP (AN8855_PORTMATRIX ,BIT (AN8855_CPU_PORT ))); +if (ret) +return ret; + +/* Disable Broadcast Forward on user ports */ + ret =regmap_clear_bits (priv->regmap,AN8855_BCF ,BIT (dp->index)); +if (ret) +return ret; + +/* Disable Unknown Unicast Forward on user ports */ + ret =regmap_clear_bits (priv->regmap,AN8855_UNUF ,BIT (dp->index)); +if (ret) +return ret; + +/* Disable Unknown Multicast Forward on user ports */ + ret =regmap_clear_bits (priv->regmap,AN8855_UNMF ,BIT (dp->index)); +if (ret) +return ret; + + ret =regmap_clear_bits (priv->regmap,AN8855_UNIPMF ,BIT (dp->index)); +if (ret) +return ret; + +/* Set default PVID to on all user ports */ + ret =an8855_port_set_pid (priv, dp->index,AN8855_PORT_VID_DEFAULT ); +if (ret) +return ret; + } + +/* Enable Airoha header mode on the cpu port */ + ret =regmap_write (priv->regmap,AN8855_PVC_P (AN8855_CPU_PORT ), +AN8855_PORT_SPEC_REPLACE_MODE |AN8855_PORT_SPEC_TAG ); +if (ret) +return ret; + +/* Unknown multicast frame forwarding to the cpu port */ + ret =regmap_write (priv->regmap,AN8855_UNMF ,BIT (AN8855_CPU_PORT )); +if (ret) +return ret; + +/* Set CPU port number */ + ret =regmap_update_bits (priv->regmap,AN8855_MFC , +AN8855_CPU_EN |AN8855_CPU_PORT_IDX , +AN8855_CPU_EN | +FIELD_PREP (AN8855_CPU_PORT_IDX ,AN8855_CPU_PORT )); +if (ret) +return ret; + +/* CPU port gets connected to all user ports of +* the switch. +*/ + ret =regmap_write (priv->regmap,AN8855_PORTMATRIX_P (AN8855_CPU_PORT ), +FIELD_PREP (AN8855_PORTMATRIX ,dsa_user_ports (ds))); +if (ret) +return ret; + +/* CPU port is set to fallback mode to let untagged +* frames pass through. +*/ + ret =regmap_update_bits (priv->regmap,AN8855_PCR_P (AN8855_CPU_PORT ), +AN8855_PORT_VLAN , +FIELD_PREP (AN8855_PORT_VLAN ,AN8855_PORT_FALLBACK_MODE )); +if (ret) +return ret; + +/* Enable Broadcast Forward on CPU port */ + ret =regmap_set_bits (priv->regmap,AN8855_BCF ,BIT (AN8855_CPU_PORT )); +if (ret) +return ret; + +/* Enable Unknown Unicast Forward on CPU port */ + ret =regmap_set_bits (priv->regmap,AN8855_UNUF ,BIT (AN8855_CPU_PORT )); +if (ret) +return ret; + +/* Enable Unknown Multicast Forward on CPU port */ + ret =regmap_set_bits (priv->regmap,AN8855_UNMF ,BIT (AN8855_CPU_PORT )); +if (ret) +return ret; + + ret =regmap_set_bits (priv->regmap,AN8855_UNIPMF ,BIT (AN8855_CPU_PORT )); +if (ret) +return ret; + +/* Setup Trap special frame to CPU rules */ + ret =an8855_trap_special_frames (priv); +if (ret) +return ret; + +dsa_switch_for_each_port (dp, ds) {
drivers/net/dsa/an8855.c line 1433
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+/* Disable Learning on all ports. +* Learning on CPU is disabled for fdb isolation and handled by +* assisted_learning_on_cpu_port. +*/ + ret =regmap_set_bits (priv->regmap,AN8855_PSC_P (dp->index), +AN8855_SA_DIS ); +if (ret) +return ret; + +/* Enable consistent egress tag (for VLAN unware VLAN-passtrough) */
Throughout the patch set:
s/passtrough/passthrough/
Quoted 11 lines
drivers/net/dsa/an8855.c new file +11
-0+ ret =regmap_update_bits (priv->regmap,AN8855_PVC_P (dp->index), +AN8855_PVC_EG_TAG , +FIELD_PREP (AN8855_PVC_EG_TAG ,AN8855_VLAN_EG_CONSISTENT )); +if (ret) +return ret; + } + +/* Setup VLAN for Default PVID */ + ret =an8855_setup_pvid_vlan (priv); +if (ret) +return ret;
drivers/net/dsa/an8855.c line 1454
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+ + ret =regmap_clear_bits (priv->regmap,AN8855_CKGCR , +AN8855_CKG_LNKDN_GLB_STOP |AN8855_CKG_LNKDN_PORT_STOP ); +if (ret) +return ret; + +/* Release global PHY power down */ + ret =regmap_write (priv->regmap,AN8855_RG_GPHY_AFE_PWD ,0x0 ); +if (ret) +return ret;
From the comment about PHY power handling, it sounds like this is problematic to do in the switch driver now, since that runs in parallel with the PHY drivers' probe sequence. Sounds like it should be moved to the central MFD driver, at a stage where there is no parallel child driver execution.
drivers/net/dsa/an8855.c line 1456
Quoted 2 lines
drivers/net/dsa/an8855.c new file +2
-0+ + ds->configure_vlan_while_not_filtering = true;
Unnecessary, this is the default value, please remove.
Quoted 4 lines
drivers/net/dsa/an8855.c new file +4
-0+ +/* Flush the FDB table */ + ret =an8855_fdb_cmd (priv,AN8855_FDB_FLUSH ,NULL ); +if (ret <0 )
drivers/net/dsa/an8855.c line 1470
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+return ret; + +/* Set min a max ageing value supported */ + ds->ageing_time_min =AN8855_L2_AGING_MS_CONSTANT ; + ds->ageing_time_max =FIELD_MAX (AN8855_AGE_CNT ) * +FIELD_MAX (AN8855_AGE_UNIT ) * +AN8855_L2_AGING_MS_CONSTANT ; + +/* Enable assisted learning for fdb isolation */ + ds->assisted_learning_on_cpu_port = true;
What FDB isolation? :)
Quoted 7 lines
drivers/net/dsa/an8855.c new file +7
-0+ +return 0 ; +} + +static int an8855_switch_probe (struct platform_device *pdev) +{ +struct an8855_priv *priv;
drivers/net/dsa/an8855.c line 2234
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+u32 val; +int ret; + + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv) +return -ENOMEM ; + + priv->dev = &pdev->dev; + priv->phy_require_calib =of_property_read_bool (priv->dev->of_node, +"airoha,ext-surge" );
Can this be moved to the DT bindings of individual PHYs instead? The switch is just a useless messenger here.
Quoted 11 lines
drivers/net/dsa/an8855.c new file +11
-0+ + priv->reset_gpio =devm_gpiod_get_optional (priv->dev,"reset" , +GPIOD_OUT_LOW ); +if (IS_ERR (priv->reset_gpio)) +return PTR_ERR (priv->reset_gpio); + +/* Get regmap from MFD */ + priv->regmap =dev_get_regmap (priv->dev->parent,NULL ); + +if (priv->reset_gpio) { +usleep_range (100000 ,150000 );
drivers/net/dsa/an8855.c line 2255
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+gpiod_set_value_cansleep (priv->reset_gpio,0 ); +usleep_range (100000 ,150000 ); +gpiod_set_value_cansleep (priv->reset_gpio,1 ); + +/* Poll HWTRAP reg to wait for Switch to fully Init */ + ret =regmap_read_poll_timeout (priv->regmap,AN8855_HWTRAP , val, + val,20 ,200000 ); +if (ret) +return ret; + }
As mentioned in the dt-bindings comment: this sounds like the type of thing which should only run from the context of the top-level MFD driver, in a very controlled manner (child drivers have not started).
Quoted 34 lines
drivers/net/dsa/an8855.c new file +34
-0+ + ret =an8855_read_switch_id (priv); +if (ret) +return ret; + + priv->ds =devm_kzalloc (priv->dev,sizeof (*priv->ds),GFP_KERNEL ); +if (!priv->ds) +return -ENOMEM ; + + priv->ds->dev = priv->dev; + priv->ds->num_ports =AN8855_NUM_PORTS ; + priv->ds->priv = priv; + priv->ds->ops = &an8855_switch_ops; +devm_mutex_init (priv->dev, &priv->reg_mutex); + priv->ds->phylink_mac_ops = &an8855_phylink_mac_ops; + + priv->pcs.ops = &an8855_pcs_ops; + priv->pcs.neg_mode = true; + priv->pcs.poll = true; + +dev_set_drvdata (priv->dev, priv); + +return dsa_register_switch (priv->ds); +} + +static void an8855_switch_remove (struct platform_device *pdev) +{ +struct an8855_priv *priv =dev_get_drvdata (&pdev->dev); + +if (!priv) +return ; + +dsa_unregister_switch (priv->ds); +}
drivers/net/dsa/an8855.c line 2299
Quoted 10 lines
drivers/net/dsa/an8855.c new file +10
-0+ +static const struct of_device_id an8855_switch_of_match[] = { + { .compatible ="airoha,an8855-switch" }, + {/* sentinel */ } +}; +MODULE_DEVICE_TABLE (of, an8855_switch_of_match); + +static struct platform_driver an8855_switch_driver = { + .probe = an8855_switch_probe, + .remove = an8855_switch_remove,
dsa_switch_shutdown() is non-optional - see commit 0650bf52b31f ("net:
dsa: be compatible with masters which unregister on shutdown") for more details. As a discrete DSA switch, don't get to choose which conduit interface this is paired with.
drivers/net/dsa/an8855.c
Quoted 8 lines
drivers/net/dsa/an8855.c new file +8
-0+ .driver = { + .name = "an8855-switch", + .of_match_table = an8855_switch_of_match, + }, +}; +module_platform_driver (an8855_switch_driver); +struct an8855_priv { +struct device *dev;
Nitpick: can retrieve the device as priv->ds->dev already.
Quoted 19 lines
drivers/net/dsa/an8855.c new file +16
-0+struct dsa_switch *ds; +struct regmap *regmap; +struct gpio_desc *reset_gpio; +/* Protect ATU or VLAN table access */ +struct mutex reg_mutex; + +struct phylink_pcs pcs; + +u8 mirror_rx; +u8 mirror_tx; +u8 port_isolated_map; + + bool phy_require_calib; +}; + +#endif /* __AN8855_H */ Signature · 1 line
2.45.2
This doesn't look bad IMO (sure, still needs work), we should focus on the selftests and make sure they pass.
PATCH v11 9/9 net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
In reply to Christian MarangiAdd support for Airoha AN8855 Internal Switch Gigabit PHY.
This is a simple PHY driver to configure and calibrate the PHY for the AN8855 Switch with the use of NVMEM cells.
--- MAINTAINERS | 1 + drivers/net/phy/Kconfig | 5 + drivers/net/phy/Makefile | 1 + drivers/net/phy/air_an8855.c | 267 +++++++++++++++++++++++++++++++++++ 4 files changed, 274 insertions(+) create mode 100644 drivers/net/phy/air_an8855.c
MAINTAINERS +1 -0
@@ -725,6 +725,7 @@ F: drivers/mfd/airoha-an8855.c F: drivers/net/dsa/an8855.c F: drivers/net/dsa/an8855.h F: drivers/net/mdio/mdio-an8855.c +F: drivers/net/phy/air_an8855.c F: drivers/nvmem/an8855-efuse.c AIROHA ETHERNET DRIVER
drivers/net/phy/Kconfig +5 -0
@@ -79,6 +79,11 @@ config SFP comment "MII PHY device drivers" +config AIR_AN8855_PHY + tristate "Airoha AN8855 Internal Gigabit PHY" + help + Currently supports the internal Airoha AN8855 Switch PHY. + config AIR_EN8811H_PHY tristate "Airoha EN8811H 2.5 Gigabit PHY" help
drivers/net/phy/Makefile +1 -0
@@ -35,6 +35,7 @@ obj-y += $(sfp-obj-y) $(sfp-obj-m) obj-$(CONFIG_ADIN_PHY) += adin.o obj-$(CONFIG_ADIN1100_PHY) += adin1100.o +obj-$(CONFIG_AIR_AN8855_PHY) += air_an8855.o obj-$(CONFIG_AIR_EN8811H_PHY) += air_en8811h.o obj-$(CONFIG_AMD_PHY) += amd.o obj-$(CONFIG_AMCC_QT2025_PHY) += qt2025.o
drivers/net/phy/air_an8855.c new file +267 -0
267 lines not on this page · raw message
Signature · 1 line
2.45.2
Andrew Lunn
maintainerRe: [net-next PATCH v11 9/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
drivers/net/phy/Kconfig config SFP · line 89
Quoted 8 lines
drivers/net/phy/Kconfig +5
-0+config AIR_AN8855_PHY + tristate "Airoha AN8855 Internal Gigabit PHY" + help + Currently supports the internal Airoha AN8855 Switch PHY. + config AIR_EN8811H_PHY tristate "Airoha EN8811H 2.5 Gigabit PHY" help
Do you have any idea why the new one is AN, and previous one is EN? I just like consistent naming, or an explanation why it is not consistent.
drivers/net/phy/air_an8855.c line 241
Quoted 4 lines
drivers/net/phy/air_an8855.c new file +4
-0+#define AN8855_PHY_ID 0xc0ff0410 +static struct phy_driver an8855_driver[] = { +{ +PHY_ID_MATCH_EXACT (AN8855_PHY_ID ),
Is there any documentation about the ID, and the lower nibble. Given it is 0, i'm wondering if PHY_ID_MATCH_EXACT() is correct.
Andrew
Re: [net-next PATCH v11 9/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
Quoted 4 lines · Andrew Lunn
Quoted 4 lines
drivers/net/phy/Kconfig +4
-0+config AIR_AN8855_PHY + tristate "Airoha AN8855 Internal Gigabit PHY" + help + Currently supports the internal Airoha AN8855 Switch PHY.
Quoted 9 lines
drivers/net/phy/Kconfig config SFP · line 89
Quoted 4 lines
drivers/net/phy/Kconfig +1
-0+ config AIR_EN8811H_PHY tristate "Airoha EN8811H 2.5 Gigabit PHY" helpDo you have any idea why the new one is AN, and previous one is EN? I just like consistent naming, or an explanation why it is not consistent.
EN EcoNet that was then absorbed by Airoha (AN). Hence it's the same thing. Airoha is suggesting to use AN for new submission. So it's just about timing.
Quoted 8 lines
drivers/net/phy/air_an8855.c line 241
Quoted 4 lines
drivers/net/phy/air_an8855.c new file +4
-0+#define AN8855_PHY_ID 0xc0ff0410 +static struct phy_driver an8855_driver[] = { +{ +PHY_ID_MATCH_EXACT (AN8855_PHY_ID ),Is there any documentation about the ID, and the lower nibble. Given it is 0, i'm wondering if
PHY_ID_MATCH_EXACT()is correct.
I will check this but I doubt there is any explaination. These are internal to the switch so my theory is that no exact logic was applied.
Signature · 1 line
Ansuel
Andrew Lunn
maintainerRe: [net-next PATCH v11 9/9] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
Quoted 15 lines · Christian Marangi
Quoted 4 lines · Andrew Lunn
Quoted 4 lines
drivers/net/phy/Kconfig +4
-0+config AIR_AN8855_PHY + tristate "Airoha AN8855 Internal Gigabit PHY" + help + Currently supports the internal Airoha AN8855 Switch PHY.Quoted 9 lines
drivers/net/phy/Kconfig config SFP · line 89
Quoted 4 lines
drivers/net/phy/Kconfig +1
-0+ config AIR_EN8811H_PHY tristate "Airoha EN8811H 2.5 Gigabit PHY" helpDo you have any idea why the new one is AN, and previous one is EN? I just like consistent naming, or an explanation why it is not consistent.
Quoted 3 lines
EN EcoNet that was then absorbed by Airoha (AN). Hence it's the same thing. Airoha is suggesting to use AN for new submission. So it's just about timing.
Thanks for the explanation.
Quoted 10 lines
Quoted 9 lines
drivers/net/phy/air_an8855.c line 241
Quoted 5 lines
drivers/net/phy/air_an8855.c new file +4
-0+#define AN8855_PHY_ID 0xc0ff0410 +static struct phy_driver an8855_driver[] = { +{ +PHY_ID_MATCH_EXACT (AN8855_PHY_ID ),Is there any documentation about the ID, and the lower nibble. Given it is 0, i'm wondering if
PHY_ID_MATCH_EXACT()is correct.
Quoted 2 lines
I will check this but I doubt there is any explaination. These are internal to the switch so my theory is that no exact logic was applied.
O.K. It can always be changed later, if a different revision of the PHY appears.
Andrew
Vladimir Oltean
maintainerQuoted 42 lines · Christian Marangi
TEST: lan2: 1588v2 over IPv4, Sync [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: lan2: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over L2 transport, Follow-Up [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv4, Sync [FAIL]
reception failed
;TEST: VLAN upper: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: VLAN upper: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv4, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: VLAN over vlan_filtering=0 bridged port: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv4, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv4, Follow-Up [FAIL]
reception failed
Quoted 8 lines
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv4, Peer Delay Request [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv6, Sync [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv6, Follow-Up [FAIL]
reception failed
TEST: VLAN over vlan_filtering=1 bridged port: 1588v2 over IPv6, Peer Delay Request [FAIL]
reception failed
Why do these fail? They are dropped on transmit? Could you see with ethtool -S where they are dropped? (DSA conduit, CPU port or user port)
Quoted 4 lines
TEST: VLAN over vlan_filtering=1 bridged port: Unicast IPv4 to unknown MAC address [FAIL]
reception succeeded, but should have failed
TEST: VLAN over vlan_filtering=1 bridged port: Unicast IPv4 to unknown MAC address, allmulti [FAIL]
reception succeeded, but should have failed
It is unexpected that these fail. The vlan_over_bridged_port() selftest sets has_unicast_flt to true or false, depending on whether the driver declares IFF_UNICAST_FLT, and depending on that, sets the expectation on whether unknown packets should be received.
There may be a bug in the selftest, but I doubt it.
I haven't looked at the patches yet, but from this behavior, it looks like you mechanically satisfied the requirements of dsa_switch_supports_uc_filtering() such that DSA will set IFF_UNICAST_FLT, but host addresses aren't actually correctly handled, or CPU flooding isn't turned off when it should (ds->ops->port_set_host_flood?).
Quoted 6 lines
TEST: FDB entry in PVID for VLAN-tagged with other TPID [FAIL]
FDB entry was not learned when it should
TEST: Reception of VLAN with other TPID as untagged [FAIL]
Packet was not forwarded when it should
TEST: Reception of VLAN with other TPID as untagged (no PVID) [FAIL]
Packet was forwarded when should not
We discussed off-list about this, a special configuration needs to exist to consider as VLAN-tagged only those packets with TPID == bridge vlan_protocol (i.e. 802.1Q).