summaryrefslogtreecommitdiff
path: root/drivers
AgeCommit message (Collapse)Author
2022-06-21net: phy: add helpers for comparing phy IDsRussell King
There are several places which open code comparing PHY IDs. Provide a couple of helpers to assist with this, using a slightly simpler test than the original: - phy_id_compare() compares two arbitary PHY IDs and a mask of the significant bits in the ID. - phydev_id_compare() compares the bound phydev with the specified PHY ID, using the bound driver's mask. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: bcm_sf2: fix pause mode validationRussell King
The implementation appears not to appear to support pause modes on anything but RGMII, RGMII_TXID, MII and REVMII interface modes. Let phylink know that detail. Moreover, RGMII_RXID and RGMII_ID appears to be unsupported. (This may not be correct; particularly see the FIXMEs in this patch.) Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-06-21net: dpaa2-mac: populate supported_interfaces member (3)Russell King
Populate the phy interface mode bitmap for the Freescale DPAA2 driver with interfaces modes supported by the MAC. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-06-21net: pcs: xpcs: use mdiodev accessorsRussell King (Oracle)
Use mdiodev accessors rather than accessing the bus and address in the mdio_device structure and using the mdiobus accessors. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: remove calls to phylink_generic_validate()Russell King (Oracle)
All conventional network drivers are now converted to use phylink_generic_validate() - only DSA drivers remain. Prepare to move the MAC based validation entirely within phylink by defaulting to phylink_generic_validate() when the .validate method is NULL. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: add QSGMII support to phylink_mii_c22_pcs_encode_advertisement()Russell King (Oracle)
The QSGMII MAC-to-PHY reply is the same as the SGMII MAC-to-PHY reply. Add support for this to phylink_mii_c22_pcs_encode_advertisement(). Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: rename phylink_sfp_config()Russell King (Oracle)
phylink_sfp_config() now only deals with configuring the MAC for a SFP containing a PHY. Rename it to be specific. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: use phy_interface_t bitmaps for optical modulesRussell King
Where a MAC provides a phy_interface_t bitmap, use these bitmaps to select the operating interface mode for optical SFP modules, rather than using the linkmode bitmaps. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-06-21net: sfp: augment SFP parsing with phy_interface_t bitmapRussell King
We currently parse the SFP EEPROM to a bitmap of ethtool link modes, and then attempt to convert the link modes to a PHY interface mode. While this works at present, there are cases where this is sub-optimal. For example, where a module can operate with several different PHY interface modes. To start addressing this, arrange for the SFP EEPROM parsing to also provide a bitmap of the possible PHY interface modes. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: add ability to validate a set of interface modesRussell King (Oracle)
Rather than having the ability to validate all supported interface modes or a single interface mode, introduce the ability to validate a subset of supported modes. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: require supported_interfaces to be filledRussell King (Oracle)
Now that all MAC drivers supply a valid supported_interfaces mask, validate it and refuse drivers that do not. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: remove legacy mac_an_restart() methodRussell King (Oracle)
The mac_an_restart() method is now completely unused, and has been superseded by phylink_pcs support. Remove this method. Since phylink_pcs_mac_an_restart() now only deals with the PCS, rename the function to remove the _mac infix. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: remove legacy_pre_march2020 from driversRussell King (Oracle)
Since DSA no longer marks anything as phylink-legacy, there is now no need for DSA drivers to set this member to false. Remove all instances of this. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: cleanup after phylink_pcs conversionRussell King (Oracle)
Now that mv88e6xxx is completely converted to using phylink_pcs support, we have no need for the serdes methods. Remove all this infrastructure. Also remove the __maybe_unused from mv88e6xxx_pcs_select(). Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: convert 88e639x to phylink_pcsRussell King (Oracle)
Convert the 88E6390, 88E6390X, and 88E6393X family of switches to use the phylink_pcs infrastructure. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: convert 88e6352 to phylink_pcsRussell King
Convert the 88E6352 SERDES code to use the phylink_pcs infrastructure. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: convert 88e6185 to phylink_pcsRussell King (Oracle)
Convert the 88E6185 SERDES code to use the phylink_pcs infrastructure. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: export mv88e6xxx_pcs_decode_state()Russell King (Oracle)
Rename and export the PCS state decoding function so our PCS can make use of the functionality provided by this. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: add infrastructure for phylink_pcsRussell King (Oracle)
Add infrastructure for phylink_pcs to the mv88e6xxx driver. This involves adding a mac_select_pcs() hook so we can pass the PCS to phylink at the appropriate time, and a PCS initialisation function. As the various chip implementations are converted to use phylink_pcs, they are no longer reliant on the legacy phylink behaviour. We detect this by the use of this infrastructure, or the lack of any serdes. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: move link forcing to mac_prepare/mac_finishRussell King (Oracle)
Move the link forcing out of mac_config() and into the mac_prepare() and mac_finish() methods. This results in no change to the order in which these operations are performed, but does mean when we convert mv88e6xxx to phylink_pcs support, we will continue to preserve this ordering. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: mdio: add unlocked mdiobus and mdiodev bus accessorsRussell King (Oracle)
Add the following unlocked accessors to complete the set: __mdiobus_modify() __mdiodev_read() __mdiodev_write() __mdiodev_modify() __mdiodev_modify_changed() which we will need for Marvell DSA PCS conversion. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: add pcs_pre_config()/pcs_post_config() methodsRussell King (Oracle)
Add hooks that are called before and after the mac_config() call, which will be needed to deal with errata workarounds for the Marvell 88e639x DSA switches. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: add pcs_enable()/pcs_disable() methodsRussell King (Oracle)
Add phylink PCS enable/disable callbacks that will allow us to place IEEE 802.3 register compliant PCS in power-down mode while not being used. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: disable PCS polling over major configurationRussell King (Oracle)
While we are performing a major configuration, there is no point having the PCS polling timer running. Stop it before we begin preparing for the configuration change, and restart it only once we've successfully completed the change. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: remove pcs_ops memberRussell King (Oracle)
Remove the pcs_ops member from struct phylink, using the one stored in struct phylink_pcs instead. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: add phylink_pcs_inband()Russell King (Oracle)
Add phylink_pcs_inband() to indicate whether the PCS should be using inband signalling. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: fix SGMII inband autoneg enableRussell King (Oracle)
When we are operating in SGMII inband mode, it implies that there is a PHY connected, and the ethtool advertisement for autoneg applies to the PHY, not the SGMII link. When in 1000base-X mode, then this applies to the 802.3z link and needs to be applied to the PCS. Fix this. Fixes: 92817dad7dcb ("net: phylink: Support disabling autonegotiation for PCS") Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: switch to using phylink for cpu portsRussell King (Oracle)
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: add support for setting default speed and interfaceRussell King (Oracle)
Add support for retrieving the interface mode from the DSA driver, and derive the fastest speed from the MAC capabilities. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: phylink: add phylink_set_fixed_link()Russell King (Oracle)
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: get rid of SPEED_MAX settingRussell King
Currently, all the device specific speed setting functions convert SPEED_MAX to the actual speed of the port. Rather than having each of the mv88e6xxx chip specifics handling SPEED_MAX, derive it from the mac_capabilities instead. This is only needed for CPU and DSA ports, so move the logic up into mv88e6xxx_setup_port() - which allows us to kill off all users of SPEED_MAX throughout the driver. Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-06-21net: dsa: mv88e6xxx: remove mv88e6065 dead codeRussell King (Oracle)
Remove mv88e6065_port_set_speed_duplex() - this is never called, and thus is completely redundant. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: pcs: lynx: consolidate sgmii and 1000base-x config codeRussell King (Oracle)
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-21net: pcs: lynx: use mdiodev accessorsRussell King (Oracle)
Use the recently introduced mdiodev accessors for the lynx PCS. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-18net: pcs: pcs-xpcs: use mii_bmcr_encode_fixed()Russell King (Oracle)
Use the newly introduced mii_bmcr_encode_fixed() for the xpcs driver. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-18net: phy: marvell: use mii_bmcr_encode_fixed()Russell King (Oracle)
Make use of the newly introduced mii_bmcr_encode_fixed() to get the BMCR value when setting loopback mode for the 88e1510. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-18net: phy: use mii_bmcr_encode_fixed()Russell King (Oracle)
phylib can make use of the newly introduced mii_bmcr_encode_fixed() macro, so let's convert it over. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-06net: dsa: mv88e6xxx: correctly report serdes link failureRussell King (Oracle)
Phylink wants to know if the link has dropped since the last time state was retrieved, and the BMSR gives us that. Read the BMSR and use it when deciding the link state. Fill in the an_complete member as well for the emulated PHY state. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-06net: dsa: mv88e6xxx: fix BMSR error to be consistent with othersRussell King (Oracle)
Other errors accessing the registers in mv88e6352_serdes_pcs_get_state() print "PHY " before the register name, except for the BMSR. Make this consistent with the other error messages. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-06-06net: dsa: mv88e6xxx: use BMSR_ANEGCOMPLETE bit for filling an_completeMarek Behún
Commit ede359d8843a ("net: dsa: mv88e6xxx: Link in pcs_get_state() if AN is bypassed") added the ability to link if AN was bypassed, and added filling of state->an_complete field, but set it to true if AN was enabled in BMCR, not when AN was reported complete in BMSR. This was done because for some reason, when I wanted to use BMSR value to infer an_complete, I was looking at BMSR_ANEGCAPABLE bit (which was always 1), instead of BMSR_ANEGCOMPLETE bit. Use BMSR_ANEGCOMPLETE for filling state->an_complete. Fixes: ede359d8843a ("net: dsa: mv88e6xxx: Link in pcs_get_state() if AN is bypassed") Signed-off-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-24net: dsa: mt753x: fix pcs conversion regressionRussell King (Oracle)
Daniel Golle reports that the conversion of mt753x to phylink PCS caused an oops as below. The problem is with the placement of the PCS initialisation, which occurs after mt7531_setup() has been called. However, burited in this function is a call to setup the CPU port, which requires the PCS structure to be already setup. Fix this by changing the initialisation order. Unable to handle kernel NULL pointer dereference at virtual address 0000000000000020 Mem abort info: ESR = 0x96000005 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 FSC = 0x05: level 1 translation fault Data abort info: ISV = 0, ISS = 0x00000005 CM = 0, WnR = 0 user pgtable: 4k pages, 39-bit VAs, pgdp=0000000046057000 [0000000000000020] pgd=0000000000000000, p4d=0000000000000000, pud=0000000000000000 Internal error: Oops: 96000005 [#1] SMP Modules linked in: CPU: 0 PID: 32 Comm: kworker/u4:1 Tainted: G S 5.18.0-rc3-next-20220422+ #0 Hardware name: Bananapi BPI-R64 (DT) Workqueue: events_unbound deferred_probe_work_func pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : mt7531_cpu_port_config+0xcc/0x1b0 lr : mt7531_cpu_port_config+0xc0/0x1b0 sp : ffffffc008d5b980 x29: ffffffc008d5b990 x28: ffffff80060562c8 x27: 00000000f805633b x26: ffffff80001a8880 x25: 00000000000009c4 x24: 0000000000000016 x23: ffffff8005eb6470 x22: 0000000000003600 x21: ffffff8006948080 x20: 0000000000000000 x19: 0000000000000006 x18: 0000000000000000 x17: 0000000000000001 x16: 0000000000000001 x15: 02963607fcee069e x14: 0000000000000000 x13: 0000000000000030 x12: 0101010101010101 x11: ffffffc037302000 x10: 0000000000000870 x9 : ffffffc008d5b800 x8 : ffffff800028f950 x7 : 0000000000000001 x6 : 00000000662b3000 x5 : 00000000000002f0 x4 : 0000000000000000 x3 : ffffff800028f080 x2 : 0000000000000000 x1 : ffffff800028f080 x0 : 0000000000000000 Call trace: mt7531_cpu_port_config+0xcc/0x1b0 mt753x_cpu_port_enable+0x24/0x1f0 mt7531_setup+0x49c/0x5c0 mt753x_setup+0x20/0x31c dsa_register_switch+0x8bc/0x1020 mt7530_probe+0x118/0x200 mdio_probe+0x30/0x64 really_probe.part.0+0x98/0x280 __driver_probe_device+0x94/0x140 driver_probe_device+0x40/0x114 __device_attach_driver+0xb0/0x10c bus_for_each_drv+0x64/0xa0 __device_attach+0xa8/0x16c device_initial_probe+0x10/0x20 bus_probe_device+0x94/0x9c deferred_probe_work_func+0x80/0xb4 process_one_work+0x200/0x3a0 worker_thread+0x260/0x4c0 kthread+0xd4/0xe0 ret_from_fork+0x10/0x20 Code: 9409e911 937b7e60 8b0002a0 f9405800 (f9401005) ---[ end trace 0000000000000000 ]--- Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: partially convert to phylink_pcsRussell King (Oracle)
Partially convert mtk_eth_soc to phylink_pcs, moving the configuration, link up and AN restart over. However, it seems mac_pcs_get_state() doesn't actually get the state from the PCS, so we can't convert that over without a better understanding of the hardware. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: convert code structure to suit split PCS supportRussell King (Oracle)
Provide a mtk_pcs structure which encapsulates everything that the PCS functions need (the regmap and ana_rgc3 offset), and use this in the PCS functions. Provide shim functions to convert from the existing "mtk_sgmii_*" interface to the converted PCS functions. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: move restoration of SYSCFG0 to mac_finish()Russell King (Oracle)
The SGMIISYS configuration is performed while ETHSYS_SYSCFG0 is in a disabled state. In order to preserve this when we switch to phylink_pcs we need to move the restoration of this register to the mac_finish() callback. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: move MAC_MCR setting to mac_finish()Russell King (Oracle)
Move the setting of the MTK_MAC_MCR register from the end of mac_config into the phylink mac_finish() method, to keep it as the very last write that is done during configuration. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: add fixme comment for state->speed useRussell King (Oracle)
Add a fixme comment for the last remaining incorrect usage of state->speed in the mac_config() method, which is strangely in a code path which is only run when the PHY interface mode changes. This means if we are in RGMII mode, changes in state->speed will not cause the INTF_MODE, TRGMII_RCK_CTRL and TRGMII_TCK_CTRL registers to be set according to the speed, nor will the TRGPLL clock be set to the correct value. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: provide mtk_sgmii_config()Russell King (Oracle)
Provide mtk_sgmii_config() to wrap up the decisions about which SGMII configuration will be called. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: stop passing phylink state to sgmii setupRussell King (Oracle)
Now that mtk_sgmii_setup_mode_force() only uses the interface mode from the phylink state, pass just the interface mode into this function. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: correct 802.3z duplex settingRussell King
Phylink does not guarantee that state->duplex will be set correctly in the mac_config() call, so it's a bug that the driver makes use of it. Move the 802.3z PCS duplex configuration to mac_link_up(). Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2022-05-23net: mtk_eth_soc: correct 802.3z speed settingRussell King (Oracle)
Phylink does not guarantee that state->speed will be set correctly in the mac_config() call, so it's a bug that the driver makes use of it. Moreover, it is making use of it in a function that is only ever called for 1000BASE-X and 2500BASE-X which operate at a fixed speed which happens to be the same setting irrespective of the interface mode. We can simply remove the switch statement and just set the SGMII interface speed. Tested-by: Marek Behún <kabel@kernel.org> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>