Commit f16aeea0e679d5fd43fc02e99569c52d77d5e5d3
1 parent
9714284f83
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 4 changed files with 17 additions and 21 deletions Side-by-side Diff
drivers/net/ethernet/sfc/efx.c
... | ... | @@ -202,7 +202,7 @@ |
202 | 202 | |
203 | 203 | #define EFX_ASSERT_RESET_SERIALISED(efx) \ |
204 | 204 | do { \ |
205 | - if ((efx->state == STATE_RUNNING) || \ | |
205 | + if ((efx->state == STATE_READY) || \ | |
206 | 206 | (efx->state == STATE_DISABLED)) \ |
207 | 207 | ASSERT_RTNL(); \ |
208 | 208 | } while (0) |
... | ... | @@ -1556,7 +1556,7 @@ |
1556 | 1556 | * of these flags are safe to read under just the rtnl lock */ |
1557 | 1557 | if (efx->port_enabled) |
1558 | 1558 | return; |
1559 | - if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT)) | |
1559 | + if ((efx->state != STATE_READY) && (efx->state != STATE_UNINIT)) | |
1560 | 1560 | return; |
1561 | 1561 | if (!netif_running(efx->net_dev)) |
1562 | 1562 | return; |
1563 | 1563 | |
1564 | 1564 | |
... | ... | @@ -2286,11 +2286,11 @@ |
2286 | 2286 | if (!pending) |
2287 | 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 | 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 | 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 | 2294 | return; |
2295 | 2295 | } |
2296 | 2296 | |
... | ... | @@ -2402,7 +2402,7 @@ |
2402 | 2402 | INIT_DELAYED_WORK(&efx->selftest_work, efx_selftest_async_work); |
2403 | 2403 | efx->pci_dev = pci_dev; |
2404 | 2404 | efx->msg_enable = debug; |
2405 | - efx->state = STATE_INIT; | |
2405 | + efx->state = STATE_UNINIT; | |
2406 | 2406 | strlcpy(efx->name, pci_name(pci_dev), sizeof(efx->name)); |
2407 | 2407 | |
2408 | 2408 | efx->net_dev = net_dev; |
... | ... | @@ -2490,7 +2490,7 @@ |
2490 | 2490 | |
2491 | 2491 | /* Mark the NIC as fini, then stop the interface */ |
2492 | 2492 | rtnl_lock(); |
2493 | - efx->state = STATE_FINI; | |
2493 | + efx->state = STATE_UNINIT; | |
2494 | 2494 | dev_close(efx->net_dev); |
2495 | 2495 | |
2496 | 2496 | /* Allow any queued efx_resets() to complete */ |
2497 | 2497 | |
... | ... | @@ -2684,9 +2684,9 @@ |
2684 | 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 | 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 | 2691 | rc = efx_register_netdev(efx); |
2692 | 2692 | if (rc) |
... | ... | @@ -2727,7 +2727,7 @@ |
2727 | 2727 | { |
2728 | 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 | 2732 | netif_device_detach(efx->net_dev); |
2733 | 2733 | |
... | ... | @@ -2741,8 +2741,6 @@ |
2741 | 2741 | { |
2742 | 2742 | struct efx_nic *efx = pci_get_drvdata(to_pci_dev(dev)); |
2743 | 2743 | |
2744 | - efx->state = STATE_INIT; | |
2745 | - | |
2746 | 2744 | efx_start_interrupts(efx, false); |
2747 | 2745 | |
2748 | 2746 | mutex_lock(&efx->mac_lock); |
... | ... | @@ -2753,7 +2751,7 @@ |
2753 | 2751 | |
2754 | 2752 | netif_device_attach(efx->net_dev); |
2755 | 2753 | |
2756 | - efx->state = STATE_RUNNING; | |
2754 | + efx->state = STATE_READY; | |
2757 | 2755 | |
2758 | 2756 | efx->type->resume_wol(efx); |
2759 | 2757 |
drivers/net/ethernet/sfc/ethtool.c
drivers/net/ethernet/sfc/falcon_boards.c
... | ... | @@ -380,7 +380,7 @@ |
380 | 380 | new_mode = PHY_MODE_SPECIAL; |
381 | 381 | if (!((old_mode ^ new_mode) & PHY_MODE_SPECIAL)) { |
382 | 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 | 384 | err = -EBUSY; |
385 | 385 | } else { |
386 | 386 | /* Reset the PHY, reconfigure the MAC and enable/disable |
drivers/net/ethernet/sfc/net_driver.h
... | ... | @@ -430,11 +430,9 @@ |
430 | 430 | #define EFX_INT_MODE_USE_MSI(x) (((x)->interrupt_mode) <= EFX_INT_MODE_MSI) |
431 | 431 | |
432 | 432 | enum nic_state { |
433 | - STATE_INIT = 0, | |
434 | - STATE_RUNNING = 1, | |
435 | - STATE_FINI = 2, | |
436 | - STATE_DISABLED = 3, | |
437 | - STATE_MAX, | |
433 | + STATE_UNINIT = 0, /* device being probed/removed or is frozen */ | |
434 | + STATE_READY = 1, /* hardware ready and netdev registered */ | |
435 | + STATE_DISABLED = 2, /* device disabled due to hardware errors */ | |
438 | 436 | }; |
439 | 437 | |
440 | 438 | /* |
... | ... | @@ -654,7 +652,7 @@ |
654 | 652 | * @irq_rx_adaptive: Adaptive IRQ moderation enabled for RX event queues |
655 | 653 | * @irq_rx_moderation: IRQ moderation time for RX event queues |
656 | 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 | 656 | * @reset_pending: Bitmask for pending resets |
659 | 657 | * @tx_queue: TX DMA queues |
660 | 658 | * @rx_queue: RX DMA queues |