2222#include <linux/ethtool.h>
2323#include <linux/interrupt.h>
2424#include <linux/mii.h>
25- #include <linux/phy .h>
25+ #include <linux/phylink .h>
2626#include <linux/net_tstamp.h>
2727#include <asm/io.h>
2828
@@ -274,7 +274,6 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev,
274274 struct ethtool_link_ksettings * cmd )
275275{
276276 struct stmmac_priv * priv = netdev_priv (dev );
277- struct phy_device * phy = dev -> phydev ;
278277
279278 if (priv -> hw -> pcs & STMMAC_PCS_RGMII ||
280279 priv -> hw -> pcs & STMMAC_PCS_SGMII ) {
@@ -353,27 +352,14 @@ static int stmmac_ethtool_get_link_ksettings(struct net_device *dev,
353352 return 0 ;
354353 }
355354
356- if (phy == NULL ) {
357- pr_err ("%s: %s: PHY is not registered\n" ,
358- __func__ , dev -> name );
359- return - ENODEV ;
360- }
361- if (!netif_running (dev )) {
362- pr_err ("%s: interface is disabled: we cannot track "
363- "link speed / duplex setting\n" , dev -> name );
364- return - EBUSY ;
365- }
366- phy_ethtool_ksettings_get (phy , cmd );
367- return 0 ;
355+ return phylink_ethtool_ksettings_get (priv -> phylink , cmd );
368356}
369357
370358static int
371359stmmac_ethtool_set_link_ksettings (struct net_device * dev ,
372360 const struct ethtool_link_ksettings * cmd )
373361{
374362 struct stmmac_priv * priv = netdev_priv (dev );
375- struct phy_device * phy = dev -> phydev ;
376- int rc ;
377363
378364 if (priv -> hw -> pcs & STMMAC_PCS_RGMII ||
379365 priv -> hw -> pcs & STMMAC_PCS_SGMII ) {
@@ -397,9 +383,7 @@ stmmac_ethtool_set_link_ksettings(struct net_device *dev,
397383 return 0 ;
398384 }
399385
400- rc = phy_ethtool_ksettings_set (phy , cmd );
401-
402- return rc ;
386+ return phylink_ethtool_ksettings_set (priv -> phylink , cmd );
403387}
404388
405389static u32 stmmac_ethtool_getmsglevel (struct net_device * dev )
@@ -443,75 +427,44 @@ static void stmmac_ethtool_gregs(struct net_device *dev,
443427 NUM_DWMAC1000_DMA_REGS * 4 );
444428}
445429
430+ static int stmmac_nway_reset (struct net_device * dev )
431+ {
432+ struct stmmac_priv * priv = netdev_priv (dev );
433+
434+ return phylink_ethtool_nway_reset (priv -> phylink );
435+ }
436+
446437static void
447438stmmac_get_pauseparam (struct net_device * netdev ,
448439 struct ethtool_pauseparam * pause )
449440{
450441 struct stmmac_priv * priv = netdev_priv (netdev );
451442 struct rgmii_adv adv_lp ;
452443
453- pause -> rx_pause = 0 ;
454- pause -> tx_pause = 0 ;
455-
456444 if (priv -> hw -> pcs && !stmmac_pcs_get_adv_lp (priv , priv -> ioaddr , & adv_lp )) {
457445 pause -> autoneg = 1 ;
458446 if (!adv_lp .pause )
459447 return ;
460448 } else {
461- if (!linkmode_test_bit (ETHTOOL_LINK_MODE_Pause_BIT ,
462- netdev -> phydev -> supported ) ||
463- !linkmode_test_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT ,
464- netdev -> phydev -> supported ))
465- return ;
449+ phylink_ethtool_get_pauseparam (priv -> phylink , pause );
466450 }
467-
468- pause -> autoneg = netdev -> phydev -> autoneg ;
469-
470- if (priv -> flow_ctrl & FLOW_RX )
471- pause -> rx_pause = 1 ;
472- if (priv -> flow_ctrl & FLOW_TX )
473- pause -> tx_pause = 1 ;
474-
475451}
476452
477453static int
478454stmmac_set_pauseparam (struct net_device * netdev ,
479455 struct ethtool_pauseparam * pause )
480456{
481457 struct stmmac_priv * priv = netdev_priv (netdev );
482- u32 tx_cnt = priv -> plat -> tx_queues_to_use ;
483- struct phy_device * phy = netdev -> phydev ;
484- int new_pause = FLOW_OFF ;
485458 struct rgmii_adv adv_lp ;
486459
487460 if (priv -> hw -> pcs && !stmmac_pcs_get_adv_lp (priv , priv -> ioaddr , & adv_lp )) {
488461 pause -> autoneg = 1 ;
489462 if (!adv_lp .pause )
490463 return - EOPNOTSUPP ;
464+ return 0 ;
491465 } else {
492- if (!linkmode_test_bit (ETHTOOL_LINK_MODE_Pause_BIT ,
493- phy -> supported ) ||
494- !linkmode_test_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT ,
495- phy -> supported ))
496- return - EOPNOTSUPP ;
466+ return phylink_ethtool_set_pauseparam (priv -> phylink , pause );
497467 }
498-
499- if (pause -> rx_pause )
500- new_pause |= FLOW_RX ;
501- if (pause -> tx_pause )
502- new_pause |= FLOW_TX ;
503-
504- priv -> flow_ctrl = new_pause ;
505- phy -> autoneg = pause -> autoneg ;
506-
507- if (phy -> autoneg ) {
508- if (netif_running (netdev ))
509- return phy_start_aneg (phy );
510- }
511-
512- stmmac_flow_ctrl (priv , priv -> hw , phy -> duplex , priv -> flow_ctrl ,
513- priv -> pause , tx_cnt );
514- return 0 ;
515468}
516469
517470static void stmmac_get_ethtool_stats (struct net_device * dev ,
@@ -549,7 +502,7 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
549502 }
550503 }
551504 if (priv -> eee_enabled ) {
552- int val = phy_get_eee_err ( dev -> phydev );
505+ int val = phylink_get_eee_err ( priv -> phylink );
553506 if (val )
554507 priv -> xstats .phy_eee_wakeup_error_n = val ;
555508 }
@@ -694,7 +647,7 @@ static int stmmac_ethtool_op_get_eee(struct net_device *dev,
694647 edata -> eee_active = priv -> eee_active ;
695648 edata -> tx_lpi_timer = priv -> tx_lpi_timer ;
696649
697- return phy_ethtool_get_eee ( dev -> phydev , edata );
650+ return phylink_ethtool_get_eee ( priv -> phylink , edata );
698651}
699652
700653static int stmmac_ethtool_op_set_eee (struct net_device * dev ,
@@ -715,7 +668,7 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev,
715668 return - EOPNOTSUPP ;
716669 }
717670
718- ret = phy_ethtool_set_eee ( dev -> phydev , edata );
671+ ret = phylink_ethtool_set_eee ( priv -> phylink , edata );
719672 if (ret )
720673 return ret ;
721674
@@ -892,7 +845,7 @@ static const struct ethtool_ops stmmac_ethtool_ops = {
892845 .get_regs = stmmac_ethtool_gregs ,
893846 .get_regs_len = stmmac_ethtool_get_regs_len ,
894847 .get_link = ethtool_op_get_link ,
895- .nway_reset = phy_ethtool_nway_reset ,
848+ .nway_reset = stmmac_nway_reset ,
896849 .get_pauseparam = stmmac_get_pauseparam ,
897850 .set_pauseparam = stmmac_set_pauseparam ,
898851 .self_test = stmmac_selftest_run ,
0 commit comments