netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 00/26] Phylink & SFP support
@ 2015-12-07 17:35 Russell King - ARM Linux
  2015-12-07 17:37 ` [PATCH RFC 01/26] phy: move fixed_phy MII register generation to a library Russell King
                   ` (27 more replies)
  0 siblings, 28 replies; 58+ messages in thread
From: Russell King - ARM Linux @ 2015-12-07 17:35 UTC (permalink / raw)
  To: Florian Fainelli, Thomas Petazzoni; +Cc: netdev

Hi,

SFP modules are hot-pluggable ethernet transceivers; they can be
detected at runtime and accordingly configured.  There are a range of
modules offering many different features.

Some SFP modules have PHYs conventional integrated into them, others
drive a laser diode from the Serdes bus.  Some have monitoring, others
do not.

Some SFP modules want to use SGMII over the Serdes link, others want
to use 1000base-X over the Serdes link.

This makes it non-trivial to support with the existing code structure.
Not wanting to write something specific to the mvneta driver, I decided
to have a go at coming up with something more generic.

My initial attempts were to provide a PHY driver, but I found that
phylib's state machine got in the way, and it was hard to support two
chained PHYs.  Conversely, having a fixed DT specified setup (via
the fixed phy infrastructure) would allow some SFP modules to work, but
not others.  The same is true of the "managed" in-band status (which
is SGMII.)

The result is that I came up with phylink - an infrastructure layer
which sits between the network driver and any attached PHY, and a
SFP module layer detects the SFP module, and configures phylink
accordingly.

Overall, this supports:

* switching the serdes mode at the NIC driver
* controlling autonegotiation and autoneg results
* allowing PHYs to be hotplugged
* allowing SFP modules to be hotplugged with proper link indication
* fixed-mode links without involving phylib
* flow control
* EEE support
* reading SFP module EEPROMs

Overall, phylink supports several link modes, with dynamic switching
possible between these:
* A true fixed link mode, where the parameters are set by DT.
* PHY mode, where we read the negotiation results from the PHY registers
  and pass them to the NIC driver.
* SGMII mode, where the in-band status indicates the speed, duplex and
  flow control settings of the link partner.
* 1000base-X mode, where the in-band status indicates only duplex and
  flow control settings (different, incompatible bit layout from SGMII.)

Ethtool support is included, as well as emulation of the MII registers
for situations where a PHY is not attached, giving compatible emulation
of existing user interfaces where required.

The patches here include modification of mvneta (against 4.4-rc1, so
probably won't apply to current development tips.)  It basically
hooks into the places where the phylib would hook into.

DT wise, the changes needed to support SFP look like this (example
taken from Clearfog):

 			ethernet@34000 {
+				managed = "in-band-status";
 				phy-mode = "sgmii";
 				status = "okay";
-
-				fixed-link {
-					speed = <1000>;
-					full-duplex;
-				};
 			};
...
+	sfp: sfp {
+		compatible = "sff,sfp";
+		i2c-bus = <&i2c1>;
+		los-gpio = <&expander0 12 GPIO_ACTIVE_HIGH>;
+		moddef0-gpio = <&expander0 15 GPIO_ACTIVE_LOW>;
+		sfp,ethernet = <&eth2>;
+		tx-disable-gpio = <&expander0 14 GPIO_ACTIVE_HIGH>;
+		tx-fault-gpio = <&expander0 13 GPIO_ACTIVE_HIGH>;
+	};

These DT changes are omitted from this patch set as the baseline DT
file is not in mainline yet (has been submitted.)

 drivers/net/ethernet/marvell/Kconfig  |    2 +-
 drivers/net/ethernet/marvell/mvneta.c |  537 +++++++++-----
 drivers/net/phy/Kconfig               |   29 +
 drivers/net/phy/Makefile              |    6 +-
 drivers/net/phy/fixed_phy.c           |  178 +----
 drivers/net/phy/marvell.c             |    2 +-
 drivers/net/phy/mdio-i2c.c            |   90 +++
 drivers/net/phy/mdio-i2c.h            |   19 +
 drivers/net/phy/phy.c                 |   46 +-
 drivers/net/phy/phy_device.c          |   15 +
 drivers/net/phy/phylink.c             | 1138 ++++++++++++++++++++++++++++++
 drivers/net/phy/sfp.c                 | 1235 +++++++++++++++++++++++++++++++++
 drivers/net/phy/swphy.c               |  179 +++++
 drivers/net/phy/swphy.h               |    9 +
 include/linux/phy.h                   |    4 +
 include/linux/phy_fixed.h             |    9 -
 include/linux/phylink.h               |  102 +++
 include/linux/sfp.h                   |  338 +++++++++
 18 files changed, 3577 insertions(+), 361 deletions(-)

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 58+ messages in thread

end of thread, other threads:[~2016-01-07 20:43 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-07 17:35 [PATCH RFC 00/26] Phylink & SFP support Russell King - ARM Linux
2015-12-07 17:37 ` [PATCH RFC 01/26] phy: move fixed_phy MII register generation to a library Russell King
2016-01-07 19:47   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 02/26] phy: convert swphy register generation to tabular form Russell King
2016-01-07 19:47   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 03/26] phy: separate swphy state validation from register generation Russell King
2016-01-07 19:48   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 04/26] phy: generate swphy registers on the fly Russell King
2016-01-07 19:49   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 05/26] phy: improve safety of fixed-phy MII register reading Russell King
2016-01-07 19:50   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 06/26] phy: provide a hook for link up/link down events Russell King
2016-01-07 19:53   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 07/26] phy: marvell: 88E1512: add flow control support Russell King
2016-01-07 19:53   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 08/26] phy: export phy_start_machine() for phylink Russell King
2016-01-07 19:53   ` Florian Fainelli
2015-12-07 17:37 ` [PATCH RFC 09/26] phy: export phy_speed_to_str() " Russell King
2016-01-07 19:54   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 10/26] phy: add I2C mdio bus Russell King
2015-12-08 18:15   ` Florian Fainelli
2015-12-11 10:25     ` Russell King - ARM Linux
2015-12-07 17:38 ` [PATCH RFC 11/26] phylink: add phylink infrastructure Russell King
2016-01-07 20:09   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 12/26] phylink: add hooks for SFP support Russell King
2016-01-07 20:05   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 13/26] sfp: add phylink based SFP module support Russell King
2016-01-07 20:23   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 14/26] sfp: display SFP module information Russell King
2016-01-07 20:23   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 15/26] net: mvneta: convert to phylink Russell King
2016-01-07 20:22   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 16/26] phy: fixed-phy: remove fixed_phy_update_state() Russell King
2016-01-07 20:15   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 17/26] phylink: add ethtool nway_reset support Russell King
2016-01-07 20:24   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 18/26] net: mvneta: add " Russell King
2016-01-07 20:19   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 19/26] phylink: add flow control support Russell King
2016-01-07 20:25   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 20/26] net: mvneta: add flow control support via phylink Russell King
2016-01-07 20:26   ` Florian Fainelli
2015-12-07 17:38 ` [PATCH RFC 21/26] net: mvneta: enable flow control for PHY connections Russell King
2016-01-07 20:31   ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 22/26] phylink: add EEE support Russell King
2016-01-07 20:34   ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 23/26] net: mvneta: " Russell King
2016-01-07 20:35   ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 24/26] phylink: add module EEPROM support Russell King
2016-01-07 20:36   ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 25/26] net: mvneta: add module EEPROM reading support Russell King
2016-01-07 20:36   ` Florian Fainelli
2015-12-07 17:39 ` [PATCH RFC 26/26] sfp/phylink: hook up eeprom functions Russell King
2015-12-15  7:26 ` [PATCH RFC 00/26] Phylink & SFP support Dustin Byford
2015-12-28  2:08   ` Florian Fainelli
2015-12-28 23:39     ` Dustin Byford
2016-01-07 20:42       ` Florian Fainelli
2015-12-28  1:56 ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).