diff options
| author | Ben Hutchings <bhutchings@solarflare.com> | 2012-07-27 14:31:16 -0400 |
|---|---|---|
| committer | Ben Hutchings <bhutchings@solarflare.com> | 2012-08-24 15:10:18 -0400 |
| commit | f16aeea0e679d5fd43fc02e99569c52d77d5e5d3 (patch) | |
| tree | a22f669f90d69705f56718130744d196876b95c7 | |
| parent | 9714284f83387d330496758e5c10a649fd9a677d (diff) | |
sfc: Change state names to be clearer, and comment them
STATE_INIT and STATE_FINI are equivalent and represent incompletely
initialised states; combine them as STATE_UNINIT.
Rename STATE_RUNNING to STATE_READY, to avoid confusion with
netif_running() and IFF_RUNNING.
The comments do not quite match current usage, but this will be
corrected in subsequent fixes.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
| -rw-r--r-- | drivers/net/ethernet/sfc/efx.c | 24 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/ethtool.c | 2 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/falcon_boards.c | 2 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 10 |
4 files changed, 17 insertions, 21 deletions
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 3b3f08489a5e..9f88ad86f4e3 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c | |||
| @@ -202,7 +202,7 @@ static void efx_stop_all(struct efx_nic *efx); | |||
| 202 | 202 | ||
| 203 | #define EFX_ASSERT_RESET_SERIALISED(efx) \ | 203 | #define EFX_ASSERT_RESET_SERIALISED(efx) \ |
| 204 | do { \ | 204 | do { \ |
| 205 | if ((efx->state == STATE_RUNNING) || \ | 205 | if ((efx->state == STATE_READY) || \ |
| 206 | (efx->state == STATE_DISABLED)) \ | 206 | (efx->state == STATE_DISABLED)) \ |
| 207 | ASSERT_RTNL(); \ | 207 | ASSERT_RTNL(); \ |
| 208 | } while (0) | 208 | } while (0) |
| @@ -1556,7 +1556,7 @@ static void efx_start_all(struct efx_nic *efx) | |||
| 1556 | * of these flags are safe to read under just the rtnl lock */ | 1556 | * of these flags are safe to read under just the rtnl lock */ |
| 1557 | if (efx->port_enabled) | 1557 | if (efx->port_enabled) |
| 1558 | return; | 1558 | return; |
| 1559 | if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT)) | 1559 | if ((efx->state != STATE_READY) && (efx->state != STATE_UNINIT)) |
| 1560 | return; | 1560 | return; |
| 1561 | if (!netif_running(efx->net_dev)) | 1561 | if (!netif_running(efx->net_dev)) |
| 1562 | return; | 1562 | return; |
| @@ -2286,11 +2286,11 @@ static void efx_reset_work(struct work_struct *data) | |||
| 2286 | if (!pending) | 2286 | if (!pending) |
| 2287 | return; | 2287 | return; |
| 2288 | 2288 | ||
| 2289 | /* If we're not RUNNING then don't reset. Leave the reset_pending | 2289 | /* If we're not READY then don't reset. Leave the reset_pending |
| 2290 | * flags set so that efx_pci_probe_main will be retried */ | 2290 | * flags set so that efx_pci_probe_main will be retried */ |
| 2291 | if (efx->state != STATE_RUNNING) { | 2291 | if (efx->state != STATE_READY) { |
| 2292 | netif_info(efx, drv, efx->net_dev, | 2292 | netif_info(efx, drv, efx->net_dev, |
| 2293 | "scheduled reset quenched. NIC not RUNNING\n"); | 2293 | "scheduled reset quenched; NIC not ready\n"); |
| 2294 | return; | 2294 | return; |
| 2295 | } | 2295 | } |
| 2296 | 2296 | ||
| @@ -2402,7 +2402,7 @@ static int efx_init_struct(struct efx_nic *efx, const struct efx_nic_type *type, | |||
| 2402 | INIT_DELAYED_WORK(&efx->selftest_work, efx_selftest_async_work); | 2402 | INIT_DELAYED_WORK(&efx->selftest_work, efx_selftest_async_work); |
| 2403 | efx->pci_dev = pci_dev; | 2403 | efx->pci_dev = pci_dev; |
| 2404 | efx->msg_enable = debug; | 2404 | efx->msg_enable = debug; |
| 2405 | efx->state = STATE_INIT; | 2405 | efx->state = STATE_UNINIT; |
| 2406 | strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); | 2406 | strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); |
| 2407 | 2407 | ||
| 2408 | efx->net_dev = net_dev; | 2408 | efx->net_dev = net_dev; |
| @@ -2490,7 +2490,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) | |||
| 2490 | 2490 | ||
| 2491 | /* Mark the NIC as fini, then stop the interface */ | 2491 | /* Mark the NIC as fini, then stop the interface */ |
| 2492 | rtnl_lock(); | 2492 | rtnl_lock(); |
| 2493 | efx->state = STATE_FINI; | 2493 | efx->state = STATE_UNINIT; |
| 2494 | dev_close(efx->net_dev); | 2494 | dev_close(efx->net_dev); |
| 2495 | 2495 | ||
| 2496 | /* Allow any queued efx_resets() to complete */ | 2496 | /* Allow any queued efx_resets() to complete */ |
| @@ -2684,9 +2684,9 @@ static int __devinit efx_pci_probe(struct pci_dev *pci_dev, | |||
| 2684 | goto fail4; | 2684 | goto fail4; |
| 2685 | } | 2685 | } |
| 2686 | 2686 | ||
| 2687 | /* Switch to the running state before we expose the device to the OS, | 2687 | /* Switch to the READY state before we expose the device to the OS, |
| 2688 | * so that dev_open()|efx_start_all() will actually start the device */ | 2688 | * so that dev_open()|efx_start_all() will actually start the device */ |
| 2689 | efx->state = STATE_RUNNING; | 2689 | efx->state = STATE_READY; |
| 2690 | 2690 | ||
| 2691 | rc = efx_register_netdev(efx); | 2691 | rc = efx_register_netdev(efx); |
| 2692 | if (rc) | 2692 | if (rc) |
| @@ -2727,7 +2727,7 @@ static int efx_pm_freeze(struct device *dev) | |||
| 2727 | { | 2727 | { |
| 2728 | struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); | 2728 | struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); |
| 2729 | 2729 | ||
| 2730 | efx->state = STATE_FINI; | 2730 | efx->state = STATE_UNINIT; |
| 2731 | 2731 | ||
| 2732 | netif_device_detach(efx->net_dev); | 2732 | netif_device_detach(efx->net_dev); |
| 2733 | 2733 | ||
| @@ -2741,8 +2741,6 @@ static int efx_pm_thaw(struct device *dev) | |||
| 2741 | { | 2741 | { |
| 2742 | struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); | 2742 | struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); |
| 2743 | 2743 | ||
| 2744 | efx->state = STATE_INIT; | ||
| 2745 | |||
| 2746 | efx_start_interrupts(efx, false); | 2744 | efx_start_interrupts(efx, false); |
| 2747 | 2745 | ||
| 2748 | mutex_lock(&efx->mac_lock); | 2746 | mutex_lock(&efx->mac_lock); |
| @@ -2753,7 +2751,7 @@ static int efx_pm_thaw(struct device *dev) | |||
| 2753 | 2751 | ||
| 2754 | netif_device_attach(efx->net_dev); | 2752 | netif_device_attach(efx->net_dev); |
| 2755 | 2753 | ||
| 2756 | efx->state = STATE_RUNNING; | 2754 | efx->state = STATE_READY; |
| 2757 | 2755 | ||
| 2758 | efx->type->resume_wol(efx); | 2756 | efx->type->resume_wol(efx); |
| 2759 | 2757 | ||
diff --git a/drivers/net/ethernet/sfc/ethtool.c b/drivers/net/ethernet/sfc/ethtool.c index 8cba2df82b18..5d0e2a3241b1 100644 --- a/drivers/net/ethernet/sfc/ethtool.c +++ b/drivers/net/ethernet/sfc/ethtool.c | |||
| @@ -531,7 +531,7 @@ static void efx_ethtool_self_test(struct net_device *net_dev, | |||
| 531 | 531 | ||
| 532 | 532 | ||
| 533 | ASSERT_RTNL(); | 533 | ASSERT_RTNL(); |
| 534 | if (efx->state != STATE_RUNNING) { | 534 | if (efx->state != STATE_READY) { |
| 535 | rc = -EIO; | 535 | rc = -EIO; |
| 536 | goto fail1; | 536 | goto fail1; |
| 537 | } | 537 | } |
diff --git a/drivers/net/ethernet/sfc/falcon_boards.c b/drivers/net/ethernet/sfc/falcon_boards.c index 8687a6c3db0d..ec1e99d0dcad 100644 --- a/drivers/net/ethernet/sfc/falcon_boards.c +++ b/drivers/net/ethernet/sfc/falcon_boards.c | |||
| @@ -380,7 +380,7 @@ static ssize_t set_phy_flash_cfg(struct device *dev, | |||
| 380 | new_mode = PHY_MODE_SPECIAL; | 380 | new_mode = PHY_MODE_SPECIAL; |
| 381 | if (!((old_mode ^ new_mode) & PHY_MODE_SPECIAL)) { | 381 | if (!((old_mode ^ new_mode) & PHY_MODE_SPECIAL)) { |
| 382 | err = 0; | 382 | err = 0; |
| 383 | } else if (efx->state != STATE_RUNNING || netif_running(efx->net_dev)) { | 383 | } else if (efx->state != STATE_READY || netif_running(efx->net_dev)) { |
| 384 | err = -EBUSY; | 384 | err = -EBUSY; |
| 385 | } else { | 385 | } else { |
| 386 | /* Reset the PHY, reconfigure the MAC and enable/disable | 386 | /* Reset the PHY, reconfigure the MAC and enable/disable |
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index a4fe9a786ef8..7ab1232494ef 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
| @@ -430,11 +430,9 @@ enum efx_int_mode { | |||
| 430 | #define EFX_INT_MODE_USE_MSI(x) (((x)->interrupt_mode) <= EFX_INT_MODE_MSI) | 430 | #define EFX_INT_MODE_USE_MSI(x) (((x)->interrupt_mode) <= EFX_INT_MODE_MSI) |
| 431 | 431 | ||
| 432 | enum nic_state { | 432 | enum nic_state { |
| 433 | STATE_INIT = 0, | 433 | STATE_UNINIT = 0, /* device being probed/removed or is frozen */ |
| 434 | STATE_RUNNING = 1, | 434 | STATE_READY = 1, /* hardware ready and netdev registered */ |
| 435 | STATE_FINI = 2, | 435 | STATE_DISABLED = 2, /* device disabled due to hardware errors */ |
| 436 | STATE_DISABLED = 3, | ||
| 437 | STATE_MAX, | ||
| 438 | }; | 436 | }; |
| 439 | 437 | ||
| 440 | /* | 438 | /* |
| @@ -654,7 +652,7 @@ struct vfdi_status; | |||
| 654 | * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues | 652 | * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues |
| 655 | * @irq_rx_moderation: IRQ moderation time for RX event queues | 653 | * @irq_rx_moderation: IRQ moderation time for RX event queues |
| 656 | * @msg_enable: Log message enable flags | 654 | * @msg_enable: Log message enable flags |
| 657 | * @state: Device state flag. Serialised by the rtnl_lock. | 655 | * @state: Device state number (%STATE_*). Serialised by the rtnl_lock. |
| 658 | * @reset_pending: Bitmask for pending resets | 656 | * @reset_pending: Bitmask for pending resets |
| 659 | * @tx_queue: TX DMA queues | 657 | * @tx_queue: TX DMA queues |
| 660 | * @rx_queue: RX DMA queues | 658 | * @rx_queue: RX DMA queues |
