Skip to content

Commit d215dba

Browse files
Doug Bergerdavem330
authored andcommitted
net: bcmgenet: rework bcmgenet_netif_start and bcmgenet_netif_stop
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>
1 parent fbf557d commit d215dba

File tree

1 file changed

+17
-32
lines changed

1 file changed

+17
-32
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,11 +2763,11 @@ static void bcmgenet_netif_start(struct net_device *dev)
27632763

27642764
/* Start the network engine */
27652765
bcmgenet_enable_rx_napi(priv);
2766-
bcmgenet_enable_tx_napi(priv);
27672766

27682767
umac_enable_set(priv, CMD_TX_EN | CMD_RX_EN, true);
27692768

27702769
netif_tx_start_all_queues(dev);
2770+
bcmgenet_enable_tx_napi(priv);
27712771

27722772
/* Monitor link interrupts now */
27732773
bcmgenet_link_intr_enable(priv);
@@ -2868,10 +2868,19 @@ static void bcmgenet_netif_stop(struct net_device *dev)
28682868
{
28692869
struct bcmgenet_priv *priv = netdev_priv(dev);
28702870

2871+
bcmgenet_disable_tx_napi(priv);
28712872
netif_tx_stop_all_queues(dev);
2873+
2874+
/* Disable MAC receive */
2875+
umac_enable_set(priv, CMD_RX_EN, false);
2876+
2877+
bcmgenet_dma_teardown(priv);
2878+
2879+
/* Disable MAC transmit. TX DMA disabled must be done before this */
2880+
umac_enable_set(priv, CMD_TX_EN, false);
2881+
28722882
phy_stop(priv->phydev);
28732883
bcmgenet_disable_rx_napi(priv);
2874-
bcmgenet_disable_tx_napi(priv);
28752884
bcmgenet_intr_disable(priv);
28762885

28772886
/* Wait for pending work items to complete. Since interrupts are
@@ -2883,12 +2892,16 @@ static void bcmgenet_netif_stop(struct net_device *dev)
28832892
priv->old_speed = -1;
28842893
priv->old_duplex = -1;
28852894
priv->old_pause = -1;
2895+
2896+
/* tx reclaim */
2897+
bcmgenet_tx_reclaim_all(dev);
2898+
bcmgenet_fini_dma(priv);
28862899
}
28872900

28882901
static int bcmgenet_close(struct net_device *dev)
28892902
{
28902903
struct bcmgenet_priv *priv = netdev_priv(dev);
2891-
int ret;
2904+
int ret = 0;
28922905

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

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

2900-
/* Disable MAC receive */
2901-
umac_enable_set(priv, CMD_RX_EN, false);
2902-
2903-
ret = bcmgenet_dma_teardown(priv);
2904-
if (ret)
2905-
return ret;
2906-
2907-
/* Disable MAC transmit. TX DMA disabled must be done before this */
2908-
umac_enable_set(priv, CMD_TX_EN, false);
2909-
2910-
/* tx reclaim */
2911-
bcmgenet_tx_reclaim_all(dev);
2912-
bcmgenet_fini_dma(priv);
2913-
29142913
free_irq(priv->irq0, priv);
29152914
free_irq(priv->irq1, priv);
29162915

@@ -3522,7 +3521,7 @@ static int bcmgenet_suspend(struct device *d)
35223521
{
35233522
struct net_device *dev = dev_get_drvdata(d);
35243523
struct bcmgenet_priv *priv = netdev_priv(dev);
3525-
int ret;
3524+
int ret = 0;
35263525

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

35353534
netif_device_detach(dev);
35363535

3537-
/* Disable MAC receive */
3538-
umac_enable_set(priv, CMD_RX_EN, false);
3539-
3540-
ret = bcmgenet_dma_teardown(priv);
3541-
if (ret)
3542-
return ret;
3543-
3544-
/* Disable MAC transmit. TX DMA disabled must be done before this */
3545-
umac_enable_set(priv, CMD_TX_EN, false);
3546-
3547-
/* tx reclaim */
3548-
bcmgenet_tx_reclaim_all(dev);
3549-
bcmgenet_fini_dma(priv);
3550-
35513536
/* Prepare the device for Wake-on-LAN and switch to the slow clock */
35523537
if (device_may_wakeup(d) && priv->wolopts) {
35533538
ret = bcmgenet_power_down(priv, GENET_POWER_WOL_MAGIC);

0 commit comments

Comments
 (0)