Skip to content

Commit

Permalink
net: bcmgenet: rework bcmgenet_netif_start and bcmgenet_netif_stop
Browse files Browse the repository at this point in the history
This commit consolidates more common functionality from
bcmgenet_close and bcmgenet_suspend into bcmgenet_netif_stop and
modifies the start and stop sequences to better suit the design
of the GENET hardware.

Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Doug Berger authored and David S. Miller committed Oct 26, 2017
1 parent fbf557d commit d215dba
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions drivers/net/ethernet/broadcom/genet/bcmgenet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2763,11 +2763,11 @@ static void bcmgenet_netif_start(struct net_device *dev)

/* Start the network engine */
bcmgenet_enable_rx_napi(priv);
bcmgenet_enable_tx_napi(priv);

umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true);

netif_tx_start_all_queues(dev);
bcmgenet_enable_tx_napi(priv);

/* Monitor link interrupts now */
bcmgenet_link_intr_enable(priv);
Expand Down Expand Up @@ -2868,10 +2868,19 @@ static void bcmgenet_netif_stop(struct net_device *dev)
{
struct bcmgenet_priv *priv = netdev_priv(dev);

bcmgenet_disable_tx_napi(priv);
netif_tx_stop_all_queues(dev);

/* Disable MAC receive */
umac_enable_set(priv, CMD_RX_EN, false);

bcmgenet_dma_teardown(priv);

/* Disable MAC transmit. TX DMA disabled must be done before this */
umac_enable_set(priv, CMD_TX_EN, false);

phy_stop(priv->phydev);
bcmgenet_disable_rx_napi(priv);
bcmgenet_disable_tx_napi(priv);
bcmgenet_intr_disable(priv);

/* Wait for pending work items to complete. Since interrupts are
Expand All @@ -2883,12 +2892,16 @@ static void bcmgenet_netif_stop(struct net_device *dev)
priv->old_speed = -1;
priv->old_duplex = -1;
priv->old_pause = -1;

/* tx reclaim */
bcmgenet_tx_reclaim_all(dev);
bcmgenet_fini_dma(priv);
}

static int bcmgenet_close(struct net_device *dev)
{
struct bcmgenet_priv *priv = netdev_priv(dev);
int ret;
int ret = 0;

netif_dbg(priv, ifdown, dev, "bcmgenet_close\n");

Expand All @@ -2897,20 +2910,6 @@ static int bcmgenet_close(struct net_device *dev)
/* Really kill the PHY state machine and disconnect from it */
phy_disconnect(priv->phydev);

/* Disable MAC receive */
umac_enable_set(priv, CMD_RX_EN, false);

ret = bcmgenet_dma_teardown(priv);
if (ret)
return ret;

/* Disable MAC transmit. TX DMA disabled must be done before this */
umac_enable_set(priv, CMD_TX_EN, false);

/* tx reclaim */
bcmgenet_tx_reclaim_all(dev);
bcmgenet_fini_dma(priv);

free_irq(priv->irq0, priv);
free_irq(priv->irq1, priv);

Expand Down Expand Up @@ -3522,7 +3521,7 @@ static int bcmgenet_suspend(struct device *d)
{
struct net_device *dev = dev_get_drvdata(d);
struct bcmgenet_priv *priv = netdev_priv(dev);
int ret;
int ret = 0;

if (!netif_running(dev))
return 0;
Expand All @@ -3534,20 +3533,6 @@ static int bcmgenet_suspend(struct device *d)

netif_device_detach(dev);

/* Disable MAC receive */
umac_enable_set(priv, CMD_RX_EN, false);

ret = bcmgenet_dma_teardown(priv);
if (ret)
return ret;

/* Disable MAC transmit. TX DMA disabled must be done before this */
umac_enable_set(priv, CMD_TX_EN, false);

/* tx reclaim */
bcmgenet_tx_reclaim_all(dev);
bcmgenet_fini_dma(priv);

/* Prepare the device for Wake-on-LAN and switch to the slow clock */
if (device_may_wakeup(d) && priv->wolopts) {
ret = bcmgenet_power_down(priv, GENET_POWER_WOL_MAGIC);
Expand Down

0 comments on commit d215dba

Please sign in to comment.