aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/efx.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2008-12-26 16:48:51 -0500
committerDavid S. Miller <davem@davemloft.net>2008-12-26 16:48:51 -0500
commitf4bd954e7c24063b15fa9abc8b4b1242772928ed (patch)
treefc4d54812802e29120ab0e3afac42f4722f0c4ab /drivers/net/sfc/efx.c
parent307505e9a4ce0b13b2f996385669039806e07390 (diff)
sfc: When disabling the NIC, close the device rather than unregistering it
This should reduce user confusion and may also aid recovery (ioctls will still be available). Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc/efx.c')
-rw-r--r--drivers/net/sfc/efx.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 46c2a8b0a88..5cc59e654d7 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1332,6 +1332,8 @@ static int efx_net_open(struct net_device *net_dev)
1332 EFX_LOG(efx, "opening device %s on CPU %d\n", net_dev->name, 1332 EFX_LOG(efx, "opening device %s on CPU %d\n", net_dev->name,
1333 raw_smp_processor_id()); 1333 raw_smp_processor_id());
1334 1334
1335 if (efx->state == STATE_DISABLED)
1336 return -EIO;
1335 if (efx->phy_mode & PHY_MODE_SPECIAL) 1337 if (efx->phy_mode & PHY_MODE_SPECIAL)
1336 return -EBUSY; 1338 return -EBUSY;
1337 1339
@@ -1350,10 +1352,12 @@ static int efx_net_stop(struct net_device *net_dev)
1350 EFX_LOG(efx, "closing %s on CPU %d\n", net_dev->name, 1352 EFX_LOG(efx, "closing %s on CPU %d\n", net_dev->name,
1351 raw_smp_processor_id()); 1353 raw_smp_processor_id());
1352 1354
1353 /* Stop the device and flush all the channels */ 1355 if (efx->state != STATE_DISABLED) {
1354 efx_stop_all(efx); 1356 /* Stop the device and flush all the channels */
1355 efx_fini_channels(efx); 1357 efx_stop_all(efx);
1356 efx_init_channels(efx); 1358 efx_fini_channels(efx);
1359 efx_init_channels(efx);
1360 }
1357 1361
1358 return 0; 1362 return 0;
1359} 1363}
@@ -1685,7 +1689,7 @@ static int efx_reset(struct efx_nic *efx)
1685{ 1689{
1686 struct ethtool_cmd ecmd; 1690 struct ethtool_cmd ecmd;
1687 enum reset_type method = efx->reset_pending; 1691 enum reset_type method = efx->reset_pending;
1688 int rc; 1692 int rc = 0;
1689 1693
1690 /* Serialise with kernel interfaces */ 1694 /* Serialise with kernel interfaces */
1691 rtnl_lock(); 1695 rtnl_lock();
@@ -1694,7 +1698,7 @@ static int efx_reset(struct efx_nic *efx)
1694 * flag set so that efx_pci_probe_main will be retried */ 1698 * flag set so that efx_pci_probe_main will be retried */
1695 if (efx->state != STATE_RUNNING) { 1699 if (efx->state != STATE_RUNNING) {
1696 EFX_INFO(efx, "scheduled reset quenched. NIC not RUNNING\n"); 1700 EFX_INFO(efx, "scheduled reset quenched. NIC not RUNNING\n");
1697 goto unlock_rtnl; 1701 goto out_unlock;
1698 } 1702 }
1699 1703
1700 EFX_INFO(efx, "resetting (%d)\n", method); 1704 EFX_INFO(efx, "resetting (%d)\n", method);
@@ -1704,7 +1708,7 @@ static int efx_reset(struct efx_nic *efx)
1704 rc = falcon_reset_hw(efx, method); 1708 rc = falcon_reset_hw(efx, method);
1705 if (rc) { 1709 if (rc) {
1706 EFX_ERR(efx, "failed to reset hardware\n"); 1710 EFX_ERR(efx, "failed to reset hardware\n");
1707 goto fail; 1711 goto out_disable;
1708 } 1712 }
1709 1713
1710 /* Allow resets to be rescheduled. */ 1714 /* Allow resets to be rescheduled. */
@@ -1718,28 +1722,23 @@ static int efx_reset(struct efx_nic *efx)
1718 1722
1719 /* Leave device stopped if necessary */ 1723 /* Leave device stopped if necessary */
1720 if (method == RESET_TYPE_DISABLE) { 1724 if (method == RESET_TYPE_DISABLE) {
1725 efx_reset_up(efx, &ecmd, false);
1721 rc = -EIO; 1726 rc = -EIO;
1722 goto fail; 1727 } else {
1728 rc = efx_reset_up(efx, &ecmd, true);
1723 } 1729 }
1724 1730
1725 rc = efx_reset_up(efx, &ecmd, true); 1731out_disable:
1726 if (rc) 1732 if (rc) {
1727 goto disable; 1733 EFX_ERR(efx, "has been disabled\n");
1728 1734 efx->state = STATE_DISABLED;
1729 EFX_LOG(efx, "reset complete\n"); 1735 dev_close(efx->net_dev);
1730 unlock_rtnl: 1736 } else {
1731 rtnl_unlock(); 1737 EFX_LOG(efx, "reset complete\n");
1732 return 0; 1738 }
1733
1734 fail:
1735 efx_reset_up(efx, &ecmd, false);
1736 disable:
1737 EFX_ERR(efx, "has been disabled\n");
1738 efx->state = STATE_DISABLED;
1739 1739
1740out_unlock:
1740 rtnl_unlock(); 1741 rtnl_unlock();
1741 efx_unregister_netdev(efx);
1742 efx_fini_port(efx);
1743 return rc; 1742 return rc;
1744} 1743}
1745 1744