diff options
Diffstat (limited to 'drivers/net/sfc/efx.c')
-rw-r--r-- | drivers/net/sfc/efx.c | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index 101c00a7bb73..847e9bb0098f 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -676,9 +676,8 @@ static int efx_init_port(struct efx_nic *efx) | |||
676 | rc = efx->phy_op->init(efx); | 676 | rc = efx->phy_op->init(efx); |
677 | if (rc) | 677 | if (rc) |
678 | return rc; | 678 | return rc; |
679 | efx->phy_op->reconfigure(efx); | ||
680 | |||
681 | mutex_lock(&efx->mac_lock); | 679 | mutex_lock(&efx->mac_lock); |
680 | efx->phy_op->reconfigure(efx); | ||
682 | rc = falcon_switch_mac(efx); | 681 | rc = falcon_switch_mac(efx); |
683 | mutex_unlock(&efx->mac_lock); | 682 | mutex_unlock(&efx->mac_lock); |
684 | if (rc) | 683 | if (rc) |
@@ -686,7 +685,7 @@ static int efx_init_port(struct efx_nic *efx) | |||
686 | efx->mac_op->reconfigure(efx); | 685 | efx->mac_op->reconfigure(efx); |
687 | 686 | ||
688 | efx->port_initialized = true; | 687 | efx->port_initialized = true; |
689 | efx->stats_enabled = true; | 688 | efx_stats_enable(efx); |
690 | return 0; | 689 | return 0; |
691 | 690 | ||
692 | fail: | 691 | fail: |
@@ -735,6 +734,7 @@ static void efx_fini_port(struct efx_nic *efx) | |||
735 | if (!efx->port_initialized) | 734 | if (!efx->port_initialized) |
736 | return; | 735 | return; |
737 | 736 | ||
737 | efx_stats_disable(efx); | ||
738 | efx->phy_op->fini(efx); | 738 | efx->phy_op->fini(efx); |
739 | efx->port_initialized = false; | 739 | efx->port_initialized = false; |
740 | 740 | ||
@@ -1368,6 +1368,20 @@ static int efx_net_stop(struct net_device *net_dev) | |||
1368 | return 0; | 1368 | return 0; |
1369 | } | 1369 | } |
1370 | 1370 | ||
1371 | void efx_stats_disable(struct efx_nic *efx) | ||
1372 | { | ||
1373 | spin_lock(&efx->stats_lock); | ||
1374 | ++efx->stats_disable_count; | ||
1375 | spin_unlock(&efx->stats_lock); | ||
1376 | } | ||
1377 | |||
1378 | void efx_stats_enable(struct efx_nic *efx) | ||
1379 | { | ||
1380 | spin_lock(&efx->stats_lock); | ||
1381 | --efx->stats_disable_count; | ||
1382 | spin_unlock(&efx->stats_lock); | ||
1383 | } | ||
1384 | |||
1371 | /* Context: process, dev_base_lock or RTNL held, non-blocking. */ | 1385 | /* Context: process, dev_base_lock or RTNL held, non-blocking. */ |
1372 | static struct net_device_stats *efx_net_stats(struct net_device *net_dev) | 1386 | static struct net_device_stats *efx_net_stats(struct net_device *net_dev) |
1373 | { | 1387 | { |
@@ -1376,12 +1390,12 @@ static struct net_device_stats *efx_net_stats(struct net_device *net_dev) | |||
1376 | struct net_device_stats *stats = &net_dev->stats; | 1390 | struct net_device_stats *stats = &net_dev->stats; |
1377 | 1391 | ||
1378 | /* Update stats if possible, but do not wait if another thread | 1392 | /* Update stats if possible, but do not wait if another thread |
1379 | * is updating them (or resetting the NIC); slightly stale | 1393 | * is updating them or if MAC stats fetches are temporarily |
1380 | * stats are acceptable. | 1394 | * disabled; slightly stale stats are acceptable. |
1381 | */ | 1395 | */ |
1382 | if (!spin_trylock(&efx->stats_lock)) | 1396 | if (!spin_trylock(&efx->stats_lock)) |
1383 | return stats; | 1397 | return stats; |
1384 | if (efx->stats_enabled) { | 1398 | if (!efx->stats_disable_count) { |
1385 | efx->mac_op->update_stats(efx); | 1399 | efx->mac_op->update_stats(efx); |
1386 | falcon_update_nic_stats(efx); | 1400 | falcon_update_nic_stats(efx); |
1387 | } | 1401 | } |
@@ -1629,16 +1643,12 @@ static void efx_unregister_netdev(struct efx_nic *efx) | |||
1629 | 1643 | ||
1630 | /* Tears down the entire software state and most of the hardware state | 1644 | /* Tears down the entire software state and most of the hardware state |
1631 | * before reset. */ | 1645 | * before reset. */ |
1632 | void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd) | 1646 | void efx_reset_down(struct efx_nic *efx, enum reset_type method, |
1647 | struct ethtool_cmd *ecmd) | ||
1633 | { | 1648 | { |
1634 | EFX_ASSERT_RESET_SERIALISED(efx); | 1649 | EFX_ASSERT_RESET_SERIALISED(efx); |
1635 | 1650 | ||
1636 | /* The net_dev->get_stats handler is quite slow, and will fail | 1651 | efx_stats_disable(efx); |
1637 | * if a fetch is pending over reset. Serialise against it. */ | ||
1638 | spin_lock(&efx->stats_lock); | ||
1639 | efx->stats_enabled = false; | ||
1640 | spin_unlock(&efx->stats_lock); | ||
1641 | |||
1642 | efx_stop_all(efx); | 1652 | efx_stop_all(efx); |
1643 | mutex_lock(&efx->mac_lock); | 1653 | mutex_lock(&efx->mac_lock); |
1644 | mutex_lock(&efx->spi_lock); | 1654 | mutex_lock(&efx->spi_lock); |
@@ -1646,6 +1656,8 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd) | |||
1646 | efx->phy_op->get_settings(efx, ecmd); | 1656 | efx->phy_op->get_settings(efx, ecmd); |
1647 | 1657 | ||
1648 | efx_fini_channels(efx); | 1658 | efx_fini_channels(efx); |
1659 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) | ||
1660 | efx->phy_op->fini(efx); | ||
1649 | } | 1661 | } |
1650 | 1662 | ||
1651 | /* This function will always ensure that the locks acquired in | 1663 | /* This function will always ensure that the locks acquired in |
@@ -1653,7 +1665,8 @@ void efx_reset_down(struct efx_nic *efx, struct ethtool_cmd *ecmd) | |||
1653 | * that we were unable to reinitialise the hardware, and the | 1665 | * that we were unable to reinitialise the hardware, and the |
1654 | * driver should be disabled. If ok is false, then the rx and tx | 1666 | * driver should be disabled. If ok is false, then the rx and tx |
1655 | * engines are not restarted, pending a RESET_DISABLE. */ | 1667 | * engines are not restarted, pending a RESET_DISABLE. */ |
1656 | int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok) | 1668 | int efx_reset_up(struct efx_nic *efx, enum reset_type method, |
1669 | struct ethtool_cmd *ecmd, bool ok) | ||
1657 | { | 1670 | { |
1658 | int rc; | 1671 | int rc; |
1659 | 1672 | ||
@@ -1665,6 +1678,15 @@ int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok) | |||
1665 | ok = false; | 1678 | ok = false; |
1666 | } | 1679 | } |
1667 | 1680 | ||
1681 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) { | ||
1682 | if (ok) { | ||
1683 | rc = efx->phy_op->init(efx); | ||
1684 | if (rc) | ||
1685 | ok = false; | ||
1686 | } else | ||
1687 | efx->port_initialized = false; | ||
1688 | } | ||
1689 | |||
1668 | if (ok) { | 1690 | if (ok) { |
1669 | efx_init_channels(efx); | 1691 | efx_init_channels(efx); |
1670 | 1692 | ||
@@ -1677,7 +1699,7 @@ int efx_reset_up(struct efx_nic *efx, struct ethtool_cmd *ecmd, bool ok) | |||
1677 | 1699 | ||
1678 | if (ok) { | 1700 | if (ok) { |
1679 | efx_start_all(efx); | 1701 | efx_start_all(efx); |
1680 | efx->stats_enabled = true; | 1702 | efx_stats_enable(efx); |
1681 | } | 1703 | } |
1682 | return rc; | 1704 | return rc; |
1683 | } | 1705 | } |
@@ -1709,7 +1731,7 @@ static int efx_reset(struct efx_nic *efx) | |||
1709 | 1731 | ||
1710 | EFX_INFO(efx, "resetting (%d)\n", method); | 1732 | EFX_INFO(efx, "resetting (%d)\n", method); |
1711 | 1733 | ||
1712 | efx_reset_down(efx, &ecmd); | 1734 | efx_reset_down(efx, method, &ecmd); |
1713 | 1735 | ||
1714 | rc = falcon_reset_hw(efx, method); | 1736 | rc = falcon_reset_hw(efx, method); |
1715 | if (rc) { | 1737 | if (rc) { |
@@ -1728,10 +1750,10 @@ static int efx_reset(struct efx_nic *efx) | |||
1728 | 1750 | ||
1729 | /* Leave device stopped if necessary */ | 1751 | /* Leave device stopped if necessary */ |
1730 | if (method == RESET_TYPE_DISABLE) { | 1752 | if (method == RESET_TYPE_DISABLE) { |
1731 | efx_reset_up(efx, &ecmd, false); | 1753 | efx_reset_up(efx, method, &ecmd, false); |
1732 | rc = -EIO; | 1754 | rc = -EIO; |
1733 | } else { | 1755 | } else { |
1734 | rc = efx_reset_up(efx, &ecmd, true); | 1756 | rc = efx_reset_up(efx, method, &ecmd, true); |
1735 | } | 1757 | } |
1736 | 1758 | ||
1737 | out_disable: | 1759 | out_disable: |
@@ -1883,6 +1905,7 @@ static int efx_init_struct(struct efx_nic *efx, struct efx_nic_type *type, | |||
1883 | efx->rx_checksum_enabled = true; | 1905 | efx->rx_checksum_enabled = true; |
1884 | spin_lock_init(&efx->netif_stop_lock); | 1906 | spin_lock_init(&efx->netif_stop_lock); |
1885 | spin_lock_init(&efx->stats_lock); | 1907 | spin_lock_init(&efx->stats_lock); |
1908 | efx->stats_disable_count = 1; | ||
1886 | mutex_init(&efx->mac_lock); | 1909 | mutex_init(&efx->mac_lock); |
1887 | efx->mac_op = &efx_dummy_mac_operations; | 1910 | efx->mac_op = &efx_dummy_mac_operations; |
1888 | efx->phy_op = &efx_dummy_phy_operations; | 1911 | efx->phy_op = &efx_dummy_phy_operations; |