Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: sfp: avoid tx-fault with Nokia GPON module

The Nokia GPON module can hold tx-fault active while it is initialising
which can take up to 60s. Avoid this causing the module to be declared
faulty after the SFP MSA defined non-cooled module timeout.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Russell King and committed by
David S. Miller
26c97a2d e70ac628

+30 -12
+30 -12
drivers/net/phy/sfp.c
··· 155 155 GPIOD_ASIS, 156 156 }; 157 157 158 - #define T_WAIT msecs_to_jiffies(50) 159 - #define T_INIT_JIFFIES msecs_to_jiffies(300) 160 - #define T_RESET_US 10 161 - #define T_FAULT_RECOVER msecs_to_jiffies(1000) 158 + /* t_start_up (SFF-8431) or t_init (SFF-8472) is the time required for a 159 + * non-cooled module to initialise its laser safety circuitry. We wait 160 + * an initial T_WAIT period before we check the tx fault to give any PHY 161 + * on board (for a copper SFP) time to initialise. 162 + */ 163 + #define T_WAIT msecs_to_jiffies(50) 164 + #define T_START_UP msecs_to_jiffies(300) 165 + #define T_START_UP_BAD_GPON msecs_to_jiffies(60000) 166 + 167 + /* t_reset is the time required to assert the TX_DISABLE signal to reset 168 + * an indicated TX_FAULT. 169 + */ 170 + #define T_RESET_US 10 171 + #define T_FAULT_RECOVER msecs_to_jiffies(1000) 162 172 163 173 /* SFP module presence detection is poor: the three MOD DEF signals are 164 174 * the same length on the PCB, which means it's possible for MOD DEF 0 to ··· 228 218 229 219 struct sfp_eeprom_id id; 230 220 unsigned int module_power_mW; 221 + unsigned int module_t_start_up; 231 222 232 223 #if IS_ENABLED(CONFIG_HWMON) 233 224 struct sfp_diag diag; ··· 1666 1655 if (ret < 0) 1667 1656 return ret; 1668 1657 1658 + if (!memcmp(id.base.vendor_name, "ALCATELLUCENT ", 16) && 1659 + !memcmp(id.base.vendor_pn, "3FE46541AA ", 16)) 1660 + sfp->module_t_start_up = T_START_UP_BAD_GPON; 1661 + else 1662 + sfp->module_t_start_up = T_START_UP; 1663 + 1669 1664 return 0; 1670 1665 } 1671 1666 ··· 1872 1855 break; 1873 1856 1874 1857 if (sfp->state & SFP_F_TX_FAULT) { 1875 - /* Wait t_init before indicating that the link is up, 1876 - * provided the current state indicates no TX_FAULT. If 1877 - * TX_FAULT clears before this time, that's fine too. 1858 + /* Wait up to t_init (SFF-8472) or t_start_up (SFF-8431) 1859 + * from the TX_DISABLE deassertion for the module to 1860 + * initialise, which is indicated by TX_FAULT 1861 + * deasserting. 1878 1862 */ 1879 - timeout = T_INIT_JIFFIES; 1863 + timeout = sfp->module_t_start_up; 1880 1864 if (timeout > T_WAIT) 1881 1865 timeout -= T_WAIT; 1882 1866 else ··· 1894 1876 1895 1877 case SFP_S_INIT: 1896 1878 if (event == SFP_E_TIMEOUT && sfp->state & SFP_F_TX_FAULT) { 1897 - /* TX_FAULT is still asserted after t_init, so assume 1898 - * there is a fault. 1879 + /* TX_FAULT is still asserted after t_init or 1880 + * or t_start_up, so assume there is a fault. 1899 1881 */ 1900 1882 sfp_sm_fault(sfp, SFP_S_INIT_TX_FAULT, 1901 1883 sfp->sm_retries == 5); ··· 1914 1896 case SFP_S_INIT_TX_FAULT: 1915 1897 if (event == SFP_E_TIMEOUT) { 1916 1898 sfp_module_tx_fault_reset(sfp); 1917 - sfp_sm_next(sfp, SFP_S_INIT, T_INIT_JIFFIES); 1899 + sfp_sm_next(sfp, SFP_S_INIT, sfp->module_t_start_up); 1918 1900 } 1919 1901 break; 1920 1902 ··· 1938 1920 case SFP_S_TX_FAULT: 1939 1921 if (event == SFP_E_TIMEOUT) { 1940 1922 sfp_module_tx_fault_reset(sfp); 1941 - sfp_sm_next(sfp, SFP_S_REINIT, T_INIT_JIFFIES); 1923 + sfp_sm_next(sfp, SFP_S_REINIT, sfp->module_t_start_up); 1942 1924 } 1943 1925 break; 1944 1926