phylink and sfp support
Subsystems (4)
Russell King - ARM Linux
maintainercover phylink and sfp support
Hi,
This patch series introduces generic support for SFP sockets found on various Marvell based platforms. The idea here is to provide common SFP socket support which can be re-used by network drivers as appropriate, rather than each network driver having to re-implement SFP socket support.
SFP sockets typically use other system resources, eg, I2C buses to read identifying information, and GPIOs to monitor socket state and control the socket. Meanwhile, some network drivers drive multiple ethernet ports from one instantiation of the driver.
It is not desirable to block the initialisation of a network driver (thus denying other ports from being operational) if the resources for the SFP socket are not yet available. This means that an element of independence between the SFP support code and the driver is required.
More than that, SFP modules effectively bring hotplug PHYs to networking - SFP copper modules normally contain a standard PHY accessed over the I2C bus, and it is desirable to read their state so network drivers can be appropriately configured.
To add to the complexity, SFP modules can be connected in at least two places:
1. Directly to the serdes output of a MAC with no intervening PHY. For example:
mvneta ----> SFP socket
2. To a PHY, for example:
mvpp2 ---> PHY ---> copper
|
`-----> SFP socketThis code supports both setups, although it's not fully implemented with scenario (2).
Moreover, the link presented by the SFP module can be one of the 10Gbase-R family (for SFP+ sockets), SGMII or 1000base-X (for SFP sockets) depending on the module, and network drivers need to reconfigure themselves accordingly for the link to come up.
For example, if the MAC is configured for SGMII and a fibre module is plugged in, the link won't come up until the MAC is reconfigured for 1000base-X mode.
The SFP code manages the SFP socket - detecting the module, reading the identifying information, and managing the control and status signals. Importantly, it disables the SFP module transmitter when the MAC is down, so that the laser is turned off (but that is not a guarantee.)
phylink provides the mechanisms necessary to manage the link modes, based on the SFP module type, and supports hot-plugging of the PHY without needing the MAC driver to be brought up and down on transitions. phylink also supports the classical static PHY and fixed-link modes.
I currently (but not included in this series) have code to convert mvneta to use phylink, and the out of tree mvpp2x driver. I have nothing for the mvpp2 driver at present as that driver is only recently becoming functional on 10G hardware, and is missing a lot of features that are necessary to make things work correctly.
drivers/net/phy/Kconfig | 25 + drivers/net/phy/Makefile | 6 + drivers/net/phy/mdio-i2c.c | 109 ++++ drivers/net/phy/mdio-i2c.h | 19 + drivers/net/phy/phy-core.c | 180 ++++++ drivers/net/phy/phy.c | 217 +------ drivers/net/phy/phy_device.c | 15 + drivers/net/phy/phylink.c | 1462 ++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/sfp-bus.c | 475 ++++++++++++++ drivers/net/phy/sfp.c | 915 ++++++++++++++++++++++++++ drivers/net/phy/sfp.h | 28 + include/linux/phy.h | 21 + include/linux/phylink.h | 148 +++++ include/linux/sfp.h | 434 +++++++++++++ 14 files changed, 3867 insertions(+), 187 deletions(-)
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
RFC PATCH 1/13 net: phy: allow settings table to support more than 32 link modes
Allow the phy settings table to support more than 32 link modes by switching to the ethtool link mode bit number representation, rather than storing the mask. This will allow phylink and other ethtool code to share the settings table to look up settings.
--- drivers/net/phy/phy.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-)
drivers/net/phy/phy.c +26 -18
@@ -200,7 +200,7 @@ EXPORT_SYMBOL(phy_aneg_done);struct phy_setting {int speed;int duplex; -u32 setting; +int bit; };/* A mapping of all SUPPORTED settings to speed/duplex. This table
@@ -210,57 +210,57 @@ static const struct phy_setting settings[] = { { .speed = SPEED_10000, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_10000baseKR_Full, + .bit = ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, }, { .speed = SPEED_10000, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_10000baseKX4_Full, + .bit = ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, }, { .speed = SPEED_10000, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_10000baseT_Full, + .bit = ETHTOOL_LINK_MODE_10000baseT_Full_BIT, }, { .speed = SPEED_2500, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_2500baseX_Full, + .bit = ETHTOOL_LINK_MODE_2500baseX_Full_BIT, }, { .speed = SPEED_1000, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_1000baseKX_Full, + .bit = ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, }, { .speed = SPEED_1000, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_1000baseT_Full, + .bit = ETHTOOL_LINK_MODE_1000baseT_Full_BIT, }, { .speed = SPEED_1000, .duplex = DUPLEX_HALF, - .setting = SUPPORTED_1000baseT_Half, + .bit = ETHTOOL_LINK_MODE_1000baseT_Half_BIT, }, { .speed = SPEED_100, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_100baseT_Full, + .bit = ETHTOOL_LINK_MODE_100baseT_Full_BIT, }, { .speed = SPEED_100, .duplex = DUPLEX_HALF, - .setting = SUPPORTED_100baseT_Half, + .bit = ETHTOOL_LINK_MODE_100baseT_Half_BIT, }, { .speed = SPEED_10, .duplex = DUPLEX_FULL, - .setting = SUPPORTED_10baseT_Full, + .bit = ETHTOOL_LINK_MODE_10baseT_Full_BIT, }, { .speed = SPEED_10, .duplex = DUPLEX_HALF, - .setting = SUPPORTED_10baseT_Half, + .bit = ETHTOOL_LINK_MODE_10baseT_Half_BIT, }, };
@@ -268,7 +268,8 @@ static const struct phy_setting settings[] = {* phy_lookup_setting - lookup a PHY setting * @speed: speed to match * @duplex: duplex to match -* @features: allowed link modes +* @mask: allowed link modes +* @maxbit: bit size of link modes * @exact: an exact match is required * * Search the settings array for a setting that matches the speed and
@@ -282,13 +283,14 @@ static const struct phy_setting settings[] = {* they all fail, %NULL will be returned. */ static const struct phy_setting * -phy_lookup_setting (int speed,int duplex,u32 features,bool exact) +phy_lookup_setting (int speed,int duplex,const unsigned long *mask, +size_t maxbit,bool exact) {const struct phy_setting *p, *match =NULL , *last =NULL ;int i;for (i =0 , p = settings; i <ARRAY_SIZE (settings); i++, p++) { -if (p->setting & features) { +if (p->bit < maxbit &&test_bit (p->bit, mask)) { last = p;if (p->speed == speed && p->duplex == duplex) {/* Exact match for speed and duplex */
@@ -327,7 +329,9 @@ phy_lookup_setting(int speed, int duplex, u32 features, bool exact)static const struct phy_setting *phy_find_valid (int speed,int duplex,u32 supported) { -return phy_lookup_setting (speed, duplex, supported, false); +unsigned long mask = supported; + +return phy_lookup_setting (speed, duplex, &mask,BITS_PER_LONG , false); }/**
@@ -344,12 +348,14 @@ unsigned int phy_supported_speeds(struct phy_device *phy, unsigned int *speeds, unsigned int size) { +unsigned long supported = phy->supported;unsigned int count =0 ;unsigned int idx =0 ;for (idx =0 ; idx <ARRAY_SIZE (settings) && count < size; idx++)/* Assumes settings are grouped by speed */ -if ((settings[idx].setting & phy->supported) && +if (settings[idx].bit <BITS_PER_LONG && + !test_bit (settings[idx].bit, &supported) && (count ==0 || speeds[count -1 ] != settings[idx].speed)) speeds[count++] = settings[idx].speed;
@@ -367,7 +373,9 @@ unsigned int phy_supported_speeds(struct phy_device *phy,*/ static inline bool phy_check_valid (int speed,int duplex,u32 features) { -return !!phy_lookup_setting (speed, duplex, features, true); +unsigned long mask = features; + +return !!phy_lookup_setting (speed, duplex, &mask,BITS_PER_LONG , true); }/**
Signature · 1 line
2.7.4
Re: [PATCH RFC 01/13] net: phy: allow settings table to support more than 32 link modes
Quoted 6 lines · Russell King
Allow the phy settings table to support more than 32 link modes by switching to the ethtool link mode bit number representation, rather than storing the mask. This will allow phylink and other ethtool code to share the settings table to look up settings.
Signed-off-by Russell King <[email protected]>
Signature · 1 line
Florian
RFC PATCH 2/13 net: phy: split out PHY speed and duplex string generation
In reply to Russell King - ARM LinuxOther code would like to make use of this, so make the speed and duplex string generation visible, and place it in a separate file.
--- drivers/net/phy/phy-core.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 38 +---------------------------------- include/linux/phy.h | 3 +++ 3 files changed, 53 insertions(+), 37 deletions(-)
drivers/net/phy/phy-core.c +49 -0
@@ -9,6 +9,55 @@#include <linux/export.h> #include <linux/phy.h> +const char *phy_speed_to_str (int speed) +{ +switch (speed) { +case SPEED_10 : +return "10Mbps" ; +case SPEED_100 : +return "100Mbps" ; +case SPEED_1000 : +return "1Gbps" ; +case SPEED_2500 : +return "2.5Gbps" ; +case SPEED_5000 : +return "5Gbps" ; +case SPEED_10000 : +return "10Gbps" ; +case SPEED_14000 : +return "14Gbps" ; +case SPEED_20000 : +return "20Gbps" ; +case SPEED_25000 : +return "25Gbps" ; +case SPEED_40000 : +return "40Gbps" ; +case SPEED_50000 : +return "50Gbps" ; +case SPEED_56000 : +return "56Gbps" ; +case SPEED_100000 : +return "100Gbps" ; +case SPEED_UNKNOWN : +return "Unknown" ; +default : +return "Unsupported (update phy-core.c)" ; + } +} +EXPORT_SYMBOL_GPL (phy_speed_to_str); + +const char *phy_duplex_to_str (unsigned int duplex) +{ +if (duplex ==DUPLEX_HALF ) +return "Half" ; +if (duplex ==DUPLEX_FULL ) +return "Full" ; +if (duplex ==DUPLEX_UNKNOWN ) +return "Unknown" ; +return "Unsupported (update phy-core.c)" ; +} +EXPORT_SYMBOL_GPL (phy_duplex_to_str); +static void mmd_phy_indirect (struct mii_bus *bus,int phy_addr,int devad,u16 regnum) {
drivers/net/phy/phy.c +1 -37
@@ -39,42 +39,6 @@#include <asm/irq.h> -static const char *phy_speed_to_str (int speed) -{ -switch (speed) { -case SPEED_10 : -return "10Mbps" ; -case SPEED_100 : -return "100Mbps" ; -case SPEED_1000 : -return "1Gbps" ; -case SPEED_2500 : -return "2.5Gbps" ; -case SPEED_5000 : -return "5Gbps" ; -case SPEED_10000 : -return "10Gbps" ; -case SPEED_14000 : -return "14Gbps" ; -case SPEED_20000 : -return "20Gbps" ; -case SPEED_25000 : -return "25Gbps" ; -case SPEED_40000 : -return "40Gbps" ; -case SPEED_50000 : -return "50Gbps" ; -case SPEED_56000 : -return "56Gbps" ; -case SPEED_100000 : -return "100Gbps" ; -case SPEED_UNKNOWN : -return "Unknown" ; -default : -return "Unsupported (update phy.c)" ; - } -} -#define PHY_STATE_STR (_state) \ case PHY_##_state: \ return __stringify(_state); \
@@ -110,7 +74,7 @@ void phy_print_status(struct phy_device *phydev)netdev_info (phydev->attached_dev,"Link is Up - %s/%s - flow control %s\n" ,phy_speed_to_str (phydev->speed), -DUPLEX_FULL == phydev->duplex ?"Full" :"Half" , +phy_duplex_to_str (phydev->duplex), phydev->pause ?"rx/tx" :"off" ); }else {netdev_info (phydev->attached_dev,"Link is Down\n" );
include/linux/phy.h +3 -0
@@ -667,6 +667,9 @@ struct phy_fixup {int (*run)(struct phy_device *phydev); }; +const char *phy_speed_to_str (int speed); +const char *phy_duplex_to_str (unsigned int duplex); +/** * phy_read_mmd - Convenience function for reading a register * from an MMD on a given PHY.
Signature · 1 line
2.7.4
Re: [PATCH RFC 02/13] net: phy: split out PHY speed and duplex string generation
Quoted 4 lines · Russell King
Other code would like to make use of this, so make the speed and duplex string generation visible, and place it in a separate file.
Signed-off-by Russell King <[email protected]>
Andrew
Re: [PATCH RFC 02/13] net: phy: split out PHY speed and duplex string generation
In reply to Russell KingQuoted 4 lines · Russell King
Other code would like to make use of this, so make the speed and duplex string generation visible, and place it in a separate file.
Signed-off-by Russell King <[email protected]>
Signature · 1 line
Florian
RFC PATCH 3/13 net: phy: move phy_lookup_setting() and guts of phy_supported_speeds() to phy-core
In reply to Russell King - ARM Linuxphy_lookup_setting() provides useful functionality in ethtool code outside phylib. Move it to phy-core and allow it to be re-used (eg, in phylink) rather than duplicated elsewhere. Note that this supports the larger linkmode space.
As we move the phy settings table, we also need to move the guts of phy_supported_speeds() as well.
--- drivers/net/phy/phy-core.c | 126 +++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/phy.c | 130 +-------------------------------------------- include/linux/phy.h | 15 ++++++ 3 files changed, 142 insertions(+), 129 deletions(-)
drivers/net/phy/phy-core.c +126 -0
@@ -58,6 +58,132 @@ const char *phy_duplex_to_str(unsigned int duplex) }EXPORT_SYMBOL_GPL (phy_duplex_to_str); +/* A mapping of all SUPPORTED settings to speed/duplex. This table +* must be grouped by speed and sorted in descending match priority +* - iow, descending speed. */ +static const struct phy_setting settings[] = { + { + .speed =SPEED_10000 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_10000baseKR_Full_BIT, + }, + { + .speed =SPEED_10000 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT, + }, + { + .speed =SPEED_10000 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_10000baseT_Full_BIT, + }, + { + .speed =SPEED_2500 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_2500baseX_Full_BIT, + }, + { + .speed =SPEED_1000 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_1000baseKX_Full_BIT, + }, + { + .speed =SPEED_1000 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_1000baseT_Full_BIT, + }, + { + .speed =SPEED_1000 , + .duplex =DUPLEX_HALF , + .bit = ETHTOOL_LINK_MODE_1000baseT_Half_BIT, + }, + { + .speed =SPEED_100 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_100baseT_Full_BIT, + }, + { + .speed =SPEED_100 , + .duplex =DUPLEX_HALF , + .bit = ETHTOOL_LINK_MODE_100baseT_Half_BIT, + }, + { + .speed =SPEED_10 , + .duplex =DUPLEX_FULL , + .bit = ETHTOOL_LINK_MODE_10baseT_Full_BIT, + }, + { + .speed =SPEED_10 , + .duplex =DUPLEX_HALF , + .bit = ETHTOOL_LINK_MODE_10baseT_Half_BIT, + }, +}; + +/** +* phy_lookup_setting - lookup a PHY setting +* @speed: speed to match +* @duplex: duplex to match +* @mask: allowed link modes +* @maxbit: bit size of link modes +* @exact: an exact match is required +* +* Search the settings array for a setting that matches the speed and +* duplex, and which is supported. +* +* If @exact is unset, either an exact match or %NULL for no match will +* be returned. +* +* If @exact is set, an exact match, the fastest supported setting at +* or below the specified speed, the slowest supported setting, or if +* they all fail, %NULL will be returned. +*/ +const struct phy_setting * +phy_lookup_setting (int speed,int duplex,const unsigned long *mask, +size_t maxbit,bool exact) +{ +const struct phy_setting *p, *match =NULL , *last =NULL ; +int i; + +for (i =0 , p = settings; i <ARRAY_SIZE (settings); i++, p++) { +if (p->bit < maxbit &&test_bit (p->bit, mask)) { + last = p; +if (p->speed == speed && p->duplex == duplex) { +/* Exact match for speed and duplex */ + match = p; +break ; + }else if (!exact) { +if (!match && p->speed <= speed) +/* Candidate */ + match = p; + +if (p->speed < speed) +break ; + } + } + } + +if (!match && !exact) + match = last; + +return match; +} +EXPORT_SYMBOL_GPL (phy_lookup_setting); + +size_t phy_speeds (unsigned int *speeds,size_t size, +unsigned long *mask,size_t maxbit) +{ +size_t count; +int i; + +for (i =0 , count =0 ; i <ARRAY_SIZE (settings) && count < size; i++) +if (settings[i].bit < maxbit && +test_bit (settings[i].bit, mask) && + (count ==0 || speeds[count -1 ] != settings[i].speed)) + speeds[count++] = settings[i].speed; + +return count; +} +static void mmd_phy_indirect (struct mii_bus *bus,int phy_addr,int devad,u16 regnum) {
drivers/net/phy/phy.c +1 -129
143 lines not on this page · raw message
include/linux/phy.h +15 -0
@@ -670,6 +670,21 @@ struct phy_fixup {const char *phy_speed_to_str (int speed);const char *phy_duplex_to_str (unsigned int duplex); +/* A structure for mapping a particular speed and duplex +* combination to a particular SUPPORTED and ADVERTISED value +*/ +struct phy_setting { +u32 speed; +u8 duplex; +u8 bit; +}; + +const struct phy_setting * +phy_lookup_setting (int speed,int duplex,const unsigned long *mask, +size_t maxbit,bool exact); +size_t phy_speeds (unsigned int *speeds,size_t size, +unsigned long *mask,size_t maxbit); +/** * phy_read_mmd - Convenience function for reading a register * from an MMD on a given PHY.
Signature · 1 line
2.7.4
Re: [PATCH RFC 03/13] net: phy: move phy_lookup_setting() and guts of phy_supported_speeds() to phy-core
Quoted 9 lines · Russell King
phy_lookup_setting()provides useful functionality in ethtool code outside phylib. Move it to phy-core and allow it to be re-used (eg, in phylink) rather than duplicated elsewhere. Note that this supports the larger linkmode space.As we move the phy settings table, we also need to move the guts of
phy_supported_speeds()as well.Signed-off-by Russell King <[email protected]>
Andrew
RFC PATCH 4/13 net: phy: add 1000Base-X to phy settings table
In reply to Russell King - ARM LinuxAdd the missing 1000Base-X entry to the phy settings table. This was not included because the original code could not cope with more than 32 bits of link mode mask.
--- drivers/net/phy/phy-core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/phy/phy-core.c +5 -0
@@ -90,6 +90,11 @@ static const struct phy_setting settings[] = { { .speed = SPEED_1000, .duplex = DUPLEX_FULL, + .bit = ETHTOOL_LINK_MODE_1000baseX_Full_BIT, + }, + { + .speed = SPEED_1000, + .duplex = DUPLEX_FULL, .bit = ETHTOOL_LINK_MODE_1000baseT_Full_BIT, }, {
Signature · 1 line
2.7.4
Re: [PATCH RFC 04/13] net: phy: add 1000Base-X to phy settings table
Quoted 5 lines · Russell King
Add the missing 1000Base-X entry to the phy settings table. This was not included because the original code could not cope with more than 32 bits of link mode mask.
Signed-off-by Russell King <[email protected]>
Hi Russell
Looks like there are another 15 to add to the table. But that can wait for another time when somebody needs them.
Andrew
RFC PATCH 5/13 net: phy: provide a hook for link up/link down events
In reply to Russell King - ARM LinuxSometimes, we need to do additional work between the PHY coming up and marking the carrier present - for example, we may need to wait for the PHY to MAC link to finish negotiation. This changes phylib to provide a notification function pointer which avoids the built-in netif_carrier_on() and netif_carrier_off() functions.
Standard ->adjust_link functionality is provided by hooking a helper into the new ->phy_link_change method.
--- drivers/net/phy/phy.c | 42 ++++++++++++++++++++---------------------- drivers/net/phy/phy_device.c | 14 ++++++++++++++ include/linux/phy.h | 1 + 3 files changed, 35 insertions(+), 22 deletions(-)
drivers/net/phy/phy.c +20 -22
@@ -863,9 +863,15 @@ void phy_start(struct phy_device *phydev) }EXPORT_SYMBOL (phy_start); -static void phy_adjust_link (struct phy_device *phydev) +static void phy_link_up (struct phy_device *phydev) { - phydev->adjust_link (phydev->attached_dev); + phydev->phy_link_change (phydev, true, true); +phy_led_trigger_change_speed (phydev); +} + +static void phy_link_down (struct phy_device *phydev,bool do_carrier) +{ + phydev->phy_link_change (phydev, false, do_carrier);phy_led_trigger_change_speed (phydev); }
@@ -910,8 +916,7 @@ void phy_state_machine(struct work_struct *work)/* If the link is down, give up on negotiation for now */ if (!phydev->link) { phydev->state =PHY_NOLINK ; -netif_carrier_off (phydev->attached_dev); -phy_adjust_link (phydev); +phy_link_down (phydev, true);break ; }
@@ -923,9 +928,7 @@ void phy_state_machine(struct work_struct *work)/* If AN is done, we're running */ if (err >0 ) { phydev->state =PHY_RUNNING ; -netif_carrier_on (phydev->attached_dev); -phy_adjust_link (phydev); - +phy_link_up (phydev); }else if (0 == phydev->link_timeout--) needs_aneg = true;break ;
@@ -950,8 +953,7 @@ void phy_state_machine(struct work_struct *work) } } phydev->state =PHY_RUNNING ; -netif_carrier_on (phydev->attached_dev); -phy_adjust_link (phydev); +phy_link_up (phydev); }break ;case PHY_FORCING :
@@ -961,13 +963,12 @@ void phy_state_machine(struct work_struct *work)if (phydev->link) { phydev->state =PHY_RUNNING ; -netif_carrier_on (phydev->attached_dev); +phy_link_up (phydev); }else {if (0 == phydev->link_timeout--) needs_aneg = true; +phy_link_down (phydev, false); } - -phy_adjust_link (phydev);break ;case PHY_RUNNING :/* Only register a CHANGE if we are polling and link changed
@@ -999,14 +1000,12 @@ void phy_state_machine(struct work_struct *work)if (phydev->link) { phydev->state =PHY_RUNNING ; -netif_carrier_on (phydev->attached_dev); +phy_link_up (phydev); }else { phydev->state =PHY_NOLINK ; -netif_carrier_off (phydev->attached_dev); +phy_link_down (phydev, true); } -phy_adjust_link (phydev); -if (phy_interrupt_is_valid (phydev)) err =phy_config_interrupt (phydev,PHY_INTERRUPT_ENABLED );
@@ -1014,8 +1013,7 @@ void phy_state_machine(struct work_struct *work)case PHY_HALTED :if (phydev->link) { phydev->link =0 ; -netif_carrier_off (phydev->attached_dev); -phy_adjust_link (phydev); +phy_link_down (phydev, true); do_suspend = true; }break ;
@@ -1035,11 +1033,11 @@ void phy_state_machine(struct work_struct *work)if (phydev->link) { phydev->state =PHY_RUNNING ; -netif_carrier_on (phydev->attached_dev); +phy_link_up (phydev); }else { phydev->state =PHY_NOLINK ; +phy_link_down (phydev, false); } -phy_adjust_link (phydev); }else { phydev->state =PHY_AN ; phydev->link_timeout =PHY_AN_TIMEOUT ;
@@ -1051,11 +1049,11 @@ void phy_state_machine(struct work_struct *work)if (phydev->link) { phydev->state =PHY_RUNNING ; -netif_carrier_on (phydev->attached_dev); +phy_link_up (phydev); }else { phydev->state =PHY_NOLINK ; +phy_link_down (phydev, false); } -phy_adjust_link (phydev); }break ; }
drivers/net/phy/phy_device.c +14 -0
@@ -688,6 +688,19 @@ struct phy_device *phy_find_first(struct mii_bus *bus) }EXPORT_SYMBOL (phy_find_first); +static void phy_link_change (struct phy_device *phydev,bool up,bool do_carrier) +{ +struct net_device *netdev = phydev->attached_dev; + +if (do_carrier) { +if (up) +netif_carrier_on (netdev); +else +netif_carrier_off (netdev); + } + phydev->adjust_link (netdev); +} +/** * phy_prepare_link - prepares the PHY layer to monitor link status * @phydev: target phy_device struct
@@ -951,6 +964,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, goto error; } + phydev->phy_link_change = phy_link_change; phydev->attached_dev = dev; dev->phydev = phydev;
include/linux/phy.h +1 -0
@@ -474,6 +474,7 @@ struct phy_device {u8 mdix;u8 mdix_ctrl; +void (*phy_link_change)(struct phy_device *,bool up,bool do_carrier);void (*adjust_link)(struct net_device *dev); };#define to_phy_device (d) container_of(to_mdio_device(d), \
Signature · 1 line
2.7.4
RFC PATCH 6/13 net: phy: export phy_start_machine() for phylink
In reply to Russell King - ARM Linuxphylink will need phy_start_machine exported, so lets export it as a GPL symbol. Documentation/networking/phy.txt indicates that this should be a PHY API function.
--- drivers/net/phy/phy.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/phy.c +1 -0
@@ -557,6 +557,7 @@ void phy_start_machine(struct phy_device *phydev) {queue_delayed_work (system_power_efficient_wq, &phydev->state_queue,HZ ); } +EXPORT_SYMBOL_GPL (phy_start_machine);/** * phy_trigger_machine - trigger the state machine to run
Signature · 1 line
2.7.4
RFC PATCH 7/13 net: phy: add I2C mdio bus
In reply to Russell King - ARM LinuxAdd an I2C MDIO bus bridge library, to allow phylib to access PHYs which are connected to an I2C bus instead of the more conventional MDIO bus. Such PHYs can be found in SFP adapters and SFF modules.
Since PHYs appear at I2C bus address 0x40..0x5f, and 0x50/0x51 are reserved for SFP EEPROMs/diagnostics, we must not allow the MDIO bus to access these I2C addresses.
--- drivers/net/phy/Kconfig | 10 +++++ drivers/net/phy/Makefile | 1 + drivers/net/phy/mdio-i2c.c | 109 +++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/mdio-i2c.h | 19 ++++++++ 4 files changed, 139 insertions(+) create mode 100644 drivers/net/phy/mdio-i2c.c create mode 100644 drivers/net/phy/mdio-i2c.h
drivers/net/phy/Kconfig +10 -0
@@ -98,6 +98,16 @@ config MDIO_HISI_FEMAC This module provides a driver for the MDIO busses found in the Hisilicon SoC that have an Fast Ethernet MAC. +config MDIO_I2C + tristate + depends on I2C + help + Support I2C based PHYs. This provides a MDIO bus bridged + to I2C to allow PHYs connected in I2C mode to be accessed + using the existing infrastructure. + + This is library mode. + config MDIO_MOXART tristate "MOXA ART MDIO interface support" depends on ARCH_MOXART
drivers/net/phy/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_MDIO_BUS_MUX_MMIOREG) += mdio-mux-mmioreg.o obj-$(CONFIG_MDIO_CAVIUM) += mdio-cavium.o obj-$(CONFIG_MDIO_GPIO) += mdio-gpio.o obj-$(CONFIG_MDIO_HISI_FEMAC) += mdio-hisi-femac.o +obj-$(CONFIG_MDIO_I2C) += mdio-i2c.o obj-$(CONFIG_MDIO_MOXART) += mdio-moxart.o obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o
drivers/net/phy/mdio-i2c.c new file +109 -0
109 lines not on this page · raw message
drivers/net/phy/mdio-i2c.h new file +19 -0
@@ -0,0 +1,19 @@ +/* +* MDIO I2C bridge +* +* Copyright (C) 2015 Russell King +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +*/ +#ifndef MDIO_I2C_H +#define MDIO_I2C_H + +struct device ; +struct i2c_adapter ; +struct mii_bus ; + +struct mii_bus *mdio_i2c_alloc (struct device *parent,struct i2c_adapter *i2c); + +#endif
Signature · 1 line
2.7.4
Re: [PATCH RFC 07/13] net: phy: add I2C mdio bus
Quoted 9 lines · Russell King
Add an I2C MDIO bus bridge library, to allow phylib to access PHYs which are connected to an I2C bus instead of the more conventional MDIO bus. Such PHYs can be found in SFP adapters and SFF modules.
Since PHYs appear at I2C bus address 0x40..0x5f, and 0x50/0x51 are reserved for SFP EEPROMs/diagnostics, we must not allow the MDIO bus to access these I2C addresses.
Signed-off-by Russell King <[email protected]>
Andrew
Re: [PATCH RFC 07/13] net: phy: add I2C mdio bus
In reply to Russell KingQuoted 9 lines · Russell King
Add an I2C MDIO bus bridge library, to allow phylib to access PHYs which are connected to an I2C bus instead of the more conventional MDIO bus. Such PHYs can be found in SFP adapters and SFF modules.
Since PHYs appear at I2C bus address 0x40..0x5f, and 0x50/0x51 are reserved for SFP EEPROMs/diagnostics, we must not allow the MDIO bus to access these I2C addresses.
Signed-off-by Russell King <[email protected]>
Signature · 1 line
Florian
RFC PATCH 8/13 phylink: add phylink infrastructure
In reply to Russell King - ARM LinuxThe link between the ethernet MAC and its PHY has become more complex as the interface evolves. This is especially true with serdes links, where the part of the PHY is effectively integrated into the MAC.
Serdes links can be connected to a variety of devices, including SFF modules soldered down onto the board with the MAC, a SFP cage with a hotpluggable SFP module which may contain a PHY or directly modulate the serdes signals onto optical media with or without a PHY, or even a classical PHY connection.
Moreover, the negotiation information on serdes links comes in two varieties - SGMII mode, where the PHY provides its speed/duplex/flow control information to the MAC, and 1000base-X mode where both ends exchange their abilities and each resolve the link capabilities.
This means we need a more flexible means to support these arrangements, particularly with the hotpluggable nature of SFP, where the PHY can be attached or detached after the network device has been brought up.
Ethtool information can come from multiple sources:
- we may have a PHY operating in either SGMII or 1000base-X mode, in which case we take ethtool/mii data directly from the PHY.
- we may have a optical SFP module without a PHY, with the MAC operating in 1000base-X mode - the ethtool/mii data needs to come from the MAC.
- we may have a copper SFP module with a PHY whic can't be accessed, which means we need to take ethtool/mii data from the MAC.
Phylink aims to solve this by providing an intermediary between the MAC and PHY, providing a safe way for PHYs to be hotplugged, and allowing a SFP driver to reconfigure the serdes connection.
Phylink also takes over support of fixed link connections, where the speed/duplex/flow control are fixed, but link status may be controlled by a GPIO signal. By avoiding the fixed-phy implementation, phylink can provide a faster response to link events: fixed-phy has to wait for phylib to operate its state machine, which can take several seconds. In comparison, phylink takes milliseconds.
- remove sync status
- rework supported and advertisment handling
- add 1000base-x speed for fixed links
- use functionality exported from phy-core, reworking __phylink_ethtool_ksettings_set for it
--- drivers/net/phy/Kconfig | 10 + drivers/net/phy/Makefile | 1 + drivers/net/phy/phy_device.c | 1 + drivers/net/phy/phylink.c | 1169 ++++++++++++++++++++++++++++++++++++++++++ include/linux/phy.h | 2 + include/linux/phylink.h | 145 ++++++ 6 files changed, 1328 insertions(+) create mode 100644 drivers/net/phy/phylink.c create mode 100644 include/linux/phylink.h
drivers/net/phy/Kconfig +10 -0
@@ -162,6 +162,16 @@ menuconfig PHYLIB devices. This option provides infrastructure for managing PHY devices. +config PHYLINK + tristate + depends on NETDEVICES + select PHYLIB + select SWPHY + help + PHYlink models the link between the PHY and MAC, allowing fixed + configuration links, PHYs, and Serdes links with MAC level + autonegotiation modes. + if PHYLIB config SWPHY
drivers/net/phy/Makefile +1 -0
@@ -18,6 +18,7 @@ endif libphy-$(CONFIG_SWPHY) += swphy.o libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o +obj-$(CONFIG_PHYLINK) += phylink.o obj-$(CONFIG_PHYLIB) += libphy.o obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o
drivers/net/phy/phy_device.c +1 -0
@@ -1084,6 +1084,7 @@ void phy_detach(struct phy_device *phydev) phydev->attached_dev->phydev =NULL ; phydev->attached_dev =NULL ;phy_suspend (phydev); + phydev->phylink =NULL ;phy_led_triggers_unregister (phydev);
drivers/net/phy/phylink.c new file +1169 -0
1,169 lines not on this page · raw message
include/linux/phy.h +2 -0
@@ -182,6 +182,7 @@ static inline const char *phy_modes(phy_interface_t interface)#define MII_ADDR_C45 (1<<30)struct device ; +struct phylink ;struct sk_buff ;/*
@@ -469,6 +470,7 @@ struct phy_device {struct mutex lock; +struct phylink *phylink;struct net_device *attached_dev;u8 mdix;
include/linux/phylink.h new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH RFC 08/13] phylink: add phylink infrastructure
Quoted 32 lines · Russell King
The link between the ethernet MAC and its PHY has become more complex as the interface evolves. This is especially true with serdes links, where the part of the PHY is effectively integrated into the MAC.
Serdes links can be connected to a variety of devices, including SFF modules soldered down onto the board with the MAC, a SFP cage with a hotpluggable SFP module which may contain a PHY or directly modulate the serdes signals onto optical media with or without a PHY, or even a classical PHY connection.
Moreover, the negotiation information on serdes links comes in two varieties - SGMII mode, where the PHY provides its speed/duplex/flow control information to the MAC, and 1000base-X mode where both ends exchange their abilities and each resolve the link capabilities.
This means we need a more flexible means to support these arrangements, particularly with the hotpluggable nature of SFP, where the PHY can be attached or detached after the network device has been brought up.
Ethtool information can come from multiple sources:
- we may have a PHY operating in either SGMII or 1000base-X mode, in which case we take ethtool/mii data directly from the PHY.
- we may have a optical SFP module without a PHY, with the MAC operating in 1000base-X mode - the ethtool/mii data needs to come from the MAC.
- we may have a copper SFP module with a PHY whic can't be accessed, which means we need to take ethtool/mii data from the MAC.Phylink aims to solve this by providing an intermediary between the MAC and PHY, providing a safe way for PHYs to be hotplugged, and allowing a SFP driver to reconfigure the serdes connection.
Quoted 8 lines
Phylink also takes over support of fixed link connections, where the speed/duplex/flow control are fixed, but link status may be controlled by a GPIO signal. By avoiding the fixed-phy implementation, phylink can provide a faster response to link events: fixed-phy has to wait for phylib to operate its state machine, which can take several seconds. In comparison, phylink takes milliseconds.
Signed-off-by Russell King <[email protected]>
Andrew
RFC PATCH 9/13 sfp: add sfp-bus to bridge between network devices and sfp cages
In reply to Russell King - ARM Linux--- drivers/net/phy/Makefile | 3 + drivers/net/phy/phylink.c | 157 +++++++++++++++ drivers/net/phy/sfp-bus.c | 475 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/net/phy/sfp.h | 28 +++ include/linux/sfp.h | 434 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1097 insertions(+) create mode 100644 drivers/net/phy/sfp-bus.c create mode 100644 drivers/net/phy/sfp.h create mode 100644 include/linux/sfp.h
drivers/net/phy/Makefile +3 -0
@@ -38,6 +38,9 @@ obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o obj-$(CONFIG_MDIO_THUNDER) += mdio-thunder.o obj-$(CONFIG_MDIO_XGENE) += mdio-xgene.o +sfp-obj-$(CONFIG_SFP) += sfp-bus.o +obj-y += $(sfp-obj-y) $(sfp-obj-m) + obj-$(CONFIG_AMD_PHY) += amd.o obj-$(CONFIG_AQUANTIA_PHY) += aquantia.o obj-$(CONFIG_AT803X_PHY) += at803x.o
drivers/net/phy/phylink.c +157 -0
209 lines not on this page · raw message
drivers/net/phy/sfp-bus.c new file +475 -0
475 lines not on this page · raw message
drivers/net/phy/sfp.h new file +28 -0
@@ -0,0 +1,28 @@ +#ifndef SFP_H +#define SFP_H + +#include <linux/ethtool.h> +#include <linux/sfp.h> + +struct sfp ; + +struct sfp_socket_ops { +void (*start)(struct sfp *sfp); +void (*stop)(struct sfp *sfp); +int (*module_info)(struct sfp *sfp,struct ethtool_modinfo *modinfo); +int (*module_eeprom)(struct sfp *sfp,struct ethtool_eeprom *ee, +u8 *data); +}; + +int sfp_add_phy (struct sfp_bus *bus,struct phy_device *phydev); +void sfp_remove_phy (struct sfp_bus *bus); +void sfp_link_up (struct sfp_bus *bus); +void sfp_link_down (struct sfp_bus *bus); +int sfp_module_insert (struct sfp_bus *bus,const struct sfp_eeprom_id *id); +void sfp_module_remove (struct sfp_bus *bus); +int sfp_link_configure (struct sfp_bus *bus,const struct sfp_eeprom_id *id); +struct sfp_bus *sfp_register_socket (struct device *dev,struct sfp *sfp, +const struct sfp_socket_ops *ops); +void sfp_unregister_socket (struct sfp_bus *bus); + +#endif
include/linux/sfp.h new file +434 -0
434 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH RFC 09/13] sfp: add sfp-bus to bridge between network devices and sfp cages
Quoted 1 line · Russell King
Signed-off-by Russell King <[email protected]>
Andrew
RFC PATCH 10/13 phylink: add module EEPROM support
In reply to Russell King - ARM LinuxAdd support for reading module EEPROMs through phylink.
--- drivers/net/phy/phylink.c | 28 ++++++++++++++++++++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 31 insertions(+)
drivers/net/phy/phylink.c +28 -0
@@ -1020,6 +1020,34 @@ int phylink_ethtool_set_pauseparam(struct phylink *pl, }EXPORT_SYMBOL_GPL (phylink_ethtool_set_pauseparam); +int phylink_ethtool_get_module_info (struct phylink *pl, +struct ethtool_modinfo *modinfo) +{ +int ret = -EOPNOTSUPP ; + +WARN_ON (!lockdep_rtnl_is_held ()); + +if (pl->sfp_bus) + ret =sfp_get_module_info (pl->sfp_bus, modinfo); + +return ret; +} +EXPORT_SYMBOL_GPL (phylink_ethtool_get_module_info); + +int phylink_ethtool_get_module_eeprom (struct phylink *pl, +struct ethtool_eeprom *ee,u8 *buf) +{ +int ret = -EOPNOTSUPP ; + +WARN_ON (!lockdep_rtnl_is_held ()); + +if (pl->sfp_bus) + ret =sfp_get_module_eeprom (pl->sfp_bus, ee, buf); + +return ret; +} +EXPORT_SYMBOL_GPL (phylink_ethtool_get_module_eeprom); +int phylink_init_eee (struct phylink *pl,bool clk_stop_enable) {int ret = -EPROTONOSUPPORT ;
include/linux/phylink.h +3 -0
@@ -125,6 +125,9 @@ void phylink_ethtool_get_pauseparam(struct phylink *, struct ethtool_pauseparam *);int phylink_ethtool_set_pauseparam (struct phylink *,struct ethtool_pauseparam *); +int phylink_ethtool_get_module_info (struct phylink *,struct ethtool_modinfo *); +int phylink_ethtool_get_module_eeprom (struct phylink *, +struct ethtool_eeprom *,u8 *);int phylink_init_eee (struct phylink *,bool );int phylink_get_eee_err (struct phylink *);int phylink_ethtool_get_eee (struct phylink *,struct ethtool_eee *);
Signature · 1 line
2.7.4
RFC PATCH 11/13 phylink: add support for MII ioctl access to Clause 45 PHYs
In reply to Russell King - ARM LinuxAdd support for reading and writing the clause 45 MII registers.
--- drivers/net/phy/phylink.c | 157 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 124 insertions(+), 33 deletions(-)
drivers/net/phy/phylink.c +124 -33
@@ -1127,16 +1127,93 @@ static int phylink_mii_emul_read(struct net_device *ndev, unsigned int reg,return val; } +static int phylink_phy_read (struct phylink *pl,unsigned int phy_id, +unsigned int reg) +{ +struct phy_device *phydev = pl->phydev; +int prtad, devad; + +if (mdio_phy_id_is_c45 (phy_id)) { + prtad =mdio_phy_id_prtad (phy_id); + devad =mdio_phy_id_devad (phy_id); + devad =MII_ADDR_C45 | devad <<16 | reg; + }else if (phydev->is_c45) { +switch (reg) { +case MII_BMCR : +case MII_BMSR : +case MII_PHYSID1 : +case MII_PHYSID2 : + devad =__ffs (phydev->c45_ids.devices_in_package); +break ; +case MII_ADVERTISE : +case MII_LPA : +if (!(phydev->c45_ids.devices_in_package &MDIO_DEVS_AN )) +return -EINVAL ; + devad =MDIO_MMD_AN ; +if (reg ==MII_ADVERTISE ) + reg =MDIO_AN_ADVERTISE ; +else + reg =MDIO_AN_LPA ; +break ; +default : +return -EINVAL ; + } + prtad = phy_id; + devad =MII_ADDR_C45 | devad <<16 | reg; + }else { + prtad = phy_id; + devad = reg; + } +return mdiobus_read (pl->phydev->mdio.bus, prtad, devad); +} + +static int phylink_phy_write (struct phylink *pl,unsigned int phy_id, +unsigned int reg,unsigned int val) +{ +struct phy_device *phydev = pl->phydev; +int prtad, devad; + +if (mdio_phy_id_is_c45 (phy_id)) { + prtad =mdio_phy_id_prtad (phy_id); + devad =mdio_phy_id_devad (phy_id); + devad =MII_ADDR_C45 | devad <<16 | reg; + }else if (phydev->is_c45) { +switch (reg) { +case MII_BMCR : +case MII_BMSR : +case MII_PHYSID1 : +case MII_PHYSID2 : + devad =__ffs (phydev->c45_ids.devices_in_package); +break ; +case MII_ADVERTISE : +case MII_LPA : +if (!(phydev->c45_ids.devices_in_package &MDIO_DEVS_AN )) +return -EINVAL ; + devad =MDIO_MMD_AN ; +if (reg ==MII_ADVERTISE ) + reg =MDIO_AN_ADVERTISE ; +else + reg =MDIO_AN_LPA ; +break ; +default : +return -EINVAL ; + } + prtad = phy_id; + devad =MII_ADDR_C45 | devad <<16 | reg; + }else { + prtad = phy_id; + devad = reg; + } + +return mdiobus_write (phydev->mdio.bus, prtad, devad, val); +} +static int phylink_mii_read (struct phylink *pl,unsigned int phy_id,unsigned int reg) {struct phylink_link_state state;int val =0xffff ; -/* PHYs only exist for MLO_AN_PHY and MLO_AN_SGMII */ -if (pl->phydev) -return mdiobus_read (pl->phydev->mdio.bus, phy_id, reg); -switch (pl->link_an_mode) {case MLO_AN_FIXED :if (phy_id ==0 ) {
@@ -1169,12 +1246,6 @@ static int phylink_mii_read(struct phylink *pl, unsigned int phy_id,static int phylink_mii_write (struct phylink *pl,unsigned int phy_id,unsigned int reg,unsigned int val) { -/* PHYs only exist for MLO_AN_PHY and MLO_AN_SGMII */ -if (pl->phydev) { -mdiobus_write (pl->phydev->mdio.bus, phy_id, reg, val); -return 0 ; - } -switch (pl->link_an_mode) {case MLO_AN_FIXED :break ;
@@ -1193,36 +1264,56 @@ static int phylink_mii_write(struct phylink *pl, unsigned int phy_id,int phylink_mii_ioctl (struct phylink *pl,struct ifreq *ifr,int cmd) { -struct mii_ioctl_data *mii_data =if_mii (ifr); -int val, ret; +struct mii_ioctl_data *mii =if_mii (ifr); +int ret;WARN_ON (!lockdep_rtnl_is_held ()); -switch (cmd) { -case SIOCGMIIPHY : - mii_data->phy_id = pl->phydev ? pl->phydev->mdio.addr :0 ; -/* fallthrough */ +if (pl->phydev) { +/* PHYs only exist for MLO_AN_PHY and MLO_AN_SGMII */ +switch (cmd) { +case SIOCGMIIPHY : + mii->phy_id = pl->phydev->mdio.addr; + +case SIOCGMIIREG : + ret =phylink_phy_read (pl, mii->phy_id, mii->reg_num); +if (ret >=0 ) { + mii->val_out = ret; + ret =0 ; + } +break ; -case SIOCGMIIREG : - val =phylink_mii_read (pl, mii_data->phy_id, mii_data->reg_num); -if (val <0 ) { - ret = val; - }else { - mii_data->val_out = val; - ret =0 ; +case SIOCSMIIREG : + ret =phylink_phy_write (pl, mii->phy_id, mii->reg_num, + mii->val_in); +break ; + +default : + ret =phy_mii_ioctl (pl->phydev, ifr, cmd); +break ; } -break ; + }else { +switch (cmd) { +case SIOCGMIIPHY : + mii->phy_id =0 ; + +case SIOCGMIIREG : + ret =phylink_mii_read (pl, mii->phy_id, mii->reg_num); +if (ret >=0 ) { + mii->val_out = ret; + ret =0 ; + } +break ; -case SIOCSMIIREG : - ret =phylink_mii_write (pl, mii_data->phy_id, mii_data->reg_num, - mii_data->val_in); -break ; +case SIOCSMIIREG : + ret =phylink_mii_write (pl, mii->phy_id, mii->reg_num, + mii->val_in); +break ; -default : - ret = -EOPNOTSUPP ; -if (pl->phydev) - ret =phy_mii_ioctl (pl->phydev, ifr, cmd); -break ; +default : + ret = -EOPNOTSUPP ; +break ; + } }return ret;
Signature · 1 line
2.7.4
Re: [PATCH RFC 11/13] phylink: add support for MII ioctl access to Clause 45 PHYs
Quoted 3 lines · Russell King
Add support for reading and writing the clause 45 MII registers.
Signed-off-by Russell King <[email protected]>
Andrew
RFC PATCH 12/13 phylink: add in-band autonegotiation support for 10GBase-KR mode.
In reply to Russell King - ARM LinuxAdd in-band autonegotation support for 10GBase-KR mode.
--- drivers/net/phy/phylink.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/phy/phylink.c +17 -0
@@ -266,6 +266,23 @@ static int phylink_parse_mode(struct phylink *pl, struct device_node *np) pl->link_an_mode =MLO_AN_8023Z ;break ; +case PHY_INTERFACE_MODE_10GKR : + phylink_set(pl->supported, 10baseT_Half); + phylink_set(pl->supported, 10baseT_Full); + phylink_set(pl->supported, 100baseT_Half); + phylink_set(pl->supported, 100baseT_Full); + phylink_set(pl->supported, 1000baseT_Half); + phylink_set(pl->supported, 1000baseT_Full); + phylink_set(pl->supported, 1000baseX_Full); + phylink_set(pl->supported, 10000baseKR_Full); + phylink_set(pl->supported, 10000baseCR_Full); + phylink_set(pl->supported, 10000baseSR_Full); + phylink_set(pl->supported, 10000baseLR_Full); + phylink_set(pl->supported, 10000baseLRM_Full); + phylink_set(pl->supported, 10000baseER_Full); + pl->link_an_mode =MLO_AN_SGMII ; +break ; +default : netdev_err(pl->netdev, "incorrect link mode %s for in-band status\n",
Signature · 1 line
2.7.4
Re: [PATCH RFC 12/13] phylink: add in-band autonegotiation support for 10GBase-KR mode.
Quoted 3 lines · Russell King
Add in-band autonegotation support for 10GBase-KR mode.
Signed-off-by Russell King <[email protected]>
Andrew
RFC PATCH 13/13 sfp: add SFP module support
In reply to Russell King - ARM LinuxAdd support for SFP hotpluggable modules via sfp-bus and phylink. This supports both copper and optical SFP modules, which require different Serdes modes in order to properly negotiate the link.
Optical SFP modules typically require the Serdes link to be talking 1000BaseX mode - this is the gigabit ethernet mode defined by the 802.3 standard.
Copper SFP modules typically integrate a PHY in the module to convert from Serdes to copper, and the PHY will be configured by the vendor to either present a 1000BaseX Serdes link (for fixed 1000BaseT) or a SGMII Serdes link. However, this is vendor defined, so we instead detect the PHY, switch the link to SGMII mode, and use traditional PHY based negotiation.
--- drivers/net/phy/Kconfig | 5 + drivers/net/phy/Makefile | 1 + drivers/net/phy/sfp.c | 915 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 921 insertions(+) create mode 100644 drivers/net/phy/sfp.c
drivers/net/phy/Kconfig +5 -0
@@ -193,6 +193,11 @@ config LED_TRIGGER_PHY comment "MII PHY device drivers" +config SFP + tristate "SFP cage support" + depends on I2C && PHYLINK + select MDIO_I2C + config AMD_PHY tristate "AMD PHYs" ---help---
drivers/net/phy/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_MDIO_SUN4I) += mdio-sun4i.o obj-$(CONFIG_MDIO_THUNDER) += mdio-thunder.o obj-$(CONFIG_MDIO_XGENE) += mdio-xgene.o +obj-$(CONFIG_SFP) += sfp.o sfp-obj-$(CONFIG_SFP) += sfp-bus.o obj-y += $(sfp-obj-y) $(sfp-obj-m)
drivers/net/phy/sfp.c new file +915 -0
915 lines not on this page · raw message
Signature · 1 line
2.7.4
Andrew Lunn
maintainerQuoted 7 lines · Russell King - ARM Linux
Hi,
This patch series introduces generic support for SFP sockets found on various Marvell based platforms. The idea here is to provide common SFP socket support which can be re-used by network drivers as appropriate, rather than each network driver having to re-implement SFP socket support.
Hi Russell
Thanks for posting these patches. I will review them once i catch up with my backlog.
...
Quoted 2 lines
I currently (but not included in this series) have code to convert mvneta to use phylink
Do you have a git branch we can look at to see these changes. It helps understand the API when you can see both sides of it.
Thanks
Andrew
Russell King - ARM Linux
maintainerQuoted 2 lines · Andrew Lunn
Do you have a git branch we can look at to see these changes. It helps understand the API when you can see both sides of it.
git://git.armlinux.org.uk/~rmk/linux-arm.git phy
or head to the cgit at:
git.armlinux.org.uk/cgit/linux-arm.git/log/?h=phy
Not only does that include the mvneta changes, but also the changes to the 88x3310 driver (although incomplete, but functional.)
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Andrew Lunn
maintainerQuoted 7 lines · Russell King - ARM Linux
Hi,
This patch series introduces generic support for SFP sockets found on various Marvell based platforms. The idea here is to provide common SFP socket support which can be re-used by network drivers as appropriate, rather than each network driver having to re-implement SFP socket support.
There is a lot of code here, and i'm not really going to understand it until i use it. I have a couple of boards with SFFs connected to switches, so i will spend some time over the next month or so to make DSA use phylink. As is usual, we can sort out any issues as we go along.
David, if it still applies cleanly, can you add it to net-next?
Thanks
Andrew
Quoted 9 lines · Andrew Lunn
Quoted 7 lines · Russell King - ARM Linux
Hi,
This patch series introduces generic support for SFP sockets found on various Marvell based platforms. The idea here is to provide common SFP socket support which can be re-used by network drivers as appropriate, rather than each network driver having to re-implement SFP socket support.
Quoted 7 lines
There is a lot of code here, and i'm not really going to understand it until i use it. I have a couple of boards with SFFs connected to switches, so i will spend some time over the next month or so to make DSA use phylink. As is usual, we can sort out any issues as we go along.
David, if it still applies cleanly, can you add it to net-next?
Agreed, this is in a good shape and the more people we can have testing this, the better. It may be nice to include a consumer of the PHYLINK API for other people to start copying from.
Signature · 1 line
Florian
Andrew Lunn
maintainerQuoted 7 lines · Russell King - ARM Linux
Hi,
This patch series introduces generic support for SFP sockets found on various Marvell based platforms. The idea here is to provide common SFP socket support which can be re-used by network drivers as appropriate, rather than each network driver having to re-implement SFP socket support.
Hi Russell
Please could you repost with all the Reviewed-By added and RFC removed. The code should get merged then.
Thanks
Andrew
David Miller
maintainerFrom: Andrew Lunn <[email protected]>
Date: Sun, 6 Aug 2017 20:26:22 +0200
Quoted 9 lines · Russell King - ARM Linux
Quoted 7 lines
Hi,
This patch series introduces generic support for SFP sockets found on various Marvell based platforms. The idea here is to provide common SFP socket support which can be re-used by network drivers as appropriate, rather than each network driver having to re-implement SFP socket support.
Quoted 4 lines
Hi Russell
Please could you repost with all the Reviewed-By added and RFC removed. The code should get merged then.
No need, I just merged the series into net-next.
Thanks.