Skip to content

Commit 7437127

Browse files
joabreudavem330
authored andcommitted
net: stmmac: Convert to phylink and remove phylib logic
Convert everything to phylink. Signed-off-by: Jose Abreu <joabreu@synopsys.com> Cc: Joao Pinto <jpinto@synopsys.com> Cc: David S. Miller <davem@davemloft.net> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com> Cc: Alexandre Torgue <alexandre.torgue@st.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Andrew Lunn <andrew@lunn.ch> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent eeef2f6 commit 7437127

File tree

5 files changed

+132
-339
lines changed

5 files changed

+132
-339
lines changed

drivers/net/ethernet/stmicro/stmmac/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ config STMMAC_ETH
33
tristate "STMicroelectronics 10/100/1000/EQOS Ethernet driver"
44
depends on HAS_IOMEM && HAS_DMA
55
select MII
6-
select PHYLIB
76
select PHYLINK
87
select CRC32
98
imply PTP_1588_CLOCK
@@ -42,7 +41,6 @@ if STMMAC_PLATFORM
4241

4342
config DWMAC_DWC_QOS_ETH
4443
tristate "Support for snps,dwc-qos-ethernet.txt DT binding."
45-
select PHYLIB
4644
select CRC32
4745
select MII
4846
depends on OF && HAS_DMA

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
#include <linux/clk.h>
2626
#include <linux/stmmac.h>
27-
#include <linux/phy.h>
2827
#include <linux/phylink.h>
2928
#include <linux/pci.h>
3029
#include "common.h"
@@ -148,9 +147,7 @@ struct stmmac_priv {
148147
/* Generic channel for NAPI */
149148
struct stmmac_channel channel[STMMAC_CH_MAX];
150149

151-
bool oldlink;
152150
int speed;
153-
int oldduplex;
154151
unsigned int flow_ctrl;
155152
unsigned int pause;
156153
struct mii_bus *mii;

drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

Lines changed: 17 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
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

370358
static int
371359
stmmac_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

405389
static 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+
446437
static void
447438
stmmac_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

477453
static int
478454
stmmac_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

517470
static 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

700653
static 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

Comments
 (0)