diff options
| author | David S. Miller <davem@davemloft.net> | 2012-08-24 16:35:43 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2012-08-24 16:35:43 -0400 |
| commit | 255e87657a84e21986e5d9070f3dee4aa8d1d531 (patch) | |
| tree | c20e26ce24779333d927fa4b172deb2d9df59ebf | |
| parent | 85c21049fc588e0a51b443fe2bad348d18f4992c (diff) | |
| parent | 8f8b3d518999fd1c342310910aa1e49112c86d05 (diff) | |
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/bwh/sfc-next
Ben Hutchings says:
====================
1. Change the TX path to stop queues earlier and avoid returning
NETDEV_TX_BUSY.
2. Remove some inefficiencies in soft-TSO.
3. Fix various bugs involving device state transitions and/or reset
scheduling by error handlers.
4. Take advantage of my previous change to operstate initialisation.
5. Miscellaneous cleanup.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | drivers/net/ethernet/sfc/efx.c | 235 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/ethtool.c | 4 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/falcon_boards.c | 2 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 49 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/nic.c | 6 | ||||
| -rw-r--r-- | drivers/net/ethernet/sfc/tx.c | 621 |
6 files changed, 410 insertions, 507 deletions
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 65a8d49106a4..a606db43c5ba 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c | |||
| @@ -202,11 +202,21 @@ 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) |
| 209 | 209 | ||
| 210 | static int efx_check_disabled(struct efx_nic *efx) | ||
| 211 | { | ||
| 212 | if (efx->state == STATE_DISABLED) { | ||
| 213 | netif_err(efx, drv, efx->net_dev, | ||
| 214 | "device is disabled due to earlier errors\n"); | ||
| 215 | return -EIO; | ||
| 216 | } | ||
| 217 | return 0; | ||
| 218 | } | ||
| 219 | |||
| 210 | /************************************************************************** | 220 | /************************************************************************** |
| 211 | * | 221 | * |
| 212 | * Event queue processing | 222 | * Event queue processing |
| @@ -630,6 +640,16 @@ static void efx_start_datapath(struct efx_nic *efx) | |||
| 630 | efx->rx_buffer_order = get_order(efx->rx_buffer_len + | 640 | efx->rx_buffer_order = get_order(efx->rx_buffer_len + |
| 631 | sizeof(struct efx_rx_page_state)); | 641 | sizeof(struct efx_rx_page_state)); |
| 632 | 642 | ||
| 643 | /* We must keep at least one descriptor in a TX ring empty. | ||
| 644 | * We could avoid this when the queue size does not exactly | ||
| 645 | * match the hardware ring size, but it's not that important. | ||
| 646 | * Therefore we stop the queue when one more skb might fill | ||
| 647 | * the ring completely. We wake it when half way back to | ||
| 648 | * empty. | ||
| 649 | */ | ||
| 650 | efx->txq_stop_thresh = efx->txq_entries - efx_tx_max_skb_descs(efx); | ||
| 651 | efx->txq_wake_thresh = efx->txq_stop_thresh / 2; | ||
| 652 | |||
| 633 | /* Initialise the channels */ | 653 | /* Initialise the channels */ |
| 634 | efx_for_each_channel(channel, efx) { | 654 | efx_for_each_channel(channel, efx) { |
| 635 | efx_for_each_channel_tx_queue(tx_queue, channel) | 655 | efx_for_each_channel_tx_queue(tx_queue, channel) |
| @@ -730,7 +750,11 @@ efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries) | |||
| 730 | struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel; | 750 | struct efx_channel *other_channel[EFX_MAX_CHANNELS], *channel; |
| 731 | u32 old_rxq_entries, old_txq_entries; | 751 | u32 old_rxq_entries, old_txq_entries; |
| 732 | unsigned i, next_buffer_table = 0; | 752 | unsigned i, next_buffer_table = 0; |
| 733 | int rc = 0; | 753 | int rc; |
| 754 | |||
| 755 | rc = efx_check_disabled(efx); | ||
| 756 | if (rc) | ||
| 757 | return rc; | ||
| 734 | 758 | ||
| 735 | /* Not all channels should be reallocated. We must avoid | 759 | /* Not all channels should be reallocated. We must avoid |
| 736 | * reallocating their buffer table entries. | 760 | * reallocating their buffer table entries. |
| @@ -1365,6 +1389,8 @@ static void efx_start_interrupts(struct efx_nic *efx, bool may_keep_eventq) | |||
| 1365 | { | 1389 | { |
| 1366 | struct efx_channel *channel; | 1390 | struct efx_channel *channel; |
| 1367 | 1391 | ||
| 1392 | BUG_ON(efx->state == STATE_DISABLED); | ||
| 1393 | |||
| 1368 | if (efx->legacy_irq) | 1394 | if (efx->legacy_irq) |
| 1369 | efx->legacy_irq_enabled = true; | 1395 | efx->legacy_irq_enabled = true; |
| 1370 | efx_nic_enable_interrupts(efx); | 1396 | efx_nic_enable_interrupts(efx); |
| @@ -1382,6 +1408,9 @@ static void efx_stop_interrupts(struct efx_nic *efx, bool may_keep_eventq) | |||
| 1382 | { | 1408 | { |
| 1383 | struct efx_channel *channel; | 1409 | struct efx_channel *channel; |
| 1384 | 1410 | ||
| 1411 | if (efx->state == STATE_DISABLED) | ||
| 1412 | return; | ||
| 1413 | |||
| 1385 | efx_mcdi_mode_poll(efx); | 1414 | efx_mcdi_mode_poll(efx); |
| 1386 | 1415 | ||
| 1387 | efx_nic_disable_interrupts(efx); | 1416 | efx_nic_disable_interrupts(efx); |
| @@ -1533,22 +1562,21 @@ static int efx_probe_all(struct efx_nic *efx) | |||
| 1533 | return rc; | 1562 | return rc; |
| 1534 | } | 1563 | } |
| 1535 | 1564 | ||
| 1536 | /* Called after previous invocation(s) of efx_stop_all, restarts the port, | 1565 | /* If the interface is supposed to be running but is not, start |
| 1537 | * kernel transmit queues and NAPI processing, and ensures that the port is | 1566 | * the hardware and software data path, regular activity for the port |
| 1538 | * scheduled to be reconfigured. This function is safe to call multiple | 1567 | * (MAC statistics, link polling, etc.) and schedule the port to be |
| 1539 | * times when the NIC is in any state. | 1568 | * reconfigured. Interrupts must already be enabled. This function |
| 1569 | * is safe to call multiple times, so long as the NIC is not disabled. | ||
| 1570 | * Requires the RTNL lock. | ||
| 1540 | */ | 1571 | */ |
| 1541 | static void efx_start_all(struct efx_nic *efx) | 1572 | static void efx_start_all(struct efx_nic *efx) |
| 1542 | { | 1573 | { |
| 1543 | EFX_ASSERT_RESET_SERIALISED(efx); | 1574 | EFX_ASSERT_RESET_SERIALISED(efx); |
| 1575 | BUG_ON(efx->state == STATE_DISABLED); | ||
| 1544 | 1576 | ||
| 1545 | /* Check that it is appropriate to restart the interface. All | 1577 | /* Check that it is appropriate to restart the interface. All |
| 1546 | * of these flags are safe to read under just the rtnl lock */ | 1578 | * of these flags are safe to read under just the rtnl lock */ |
| 1547 | if (efx->port_enabled) | 1579 | if (efx->port_enabled || !netif_running(efx->net_dev)) |
| 1548 | return; | ||
| 1549 | if ((efx->state != STATE_RUNNING) && (efx->state != STATE_INIT)) | ||
| 1550 | return; | ||
| 1551 | if (!netif_running(efx->net_dev)) | ||
| 1552 | return; | 1580 | return; |
| 1553 | 1581 | ||
| 1554 | efx_start_port(efx); | 1582 | efx_start_port(efx); |
| @@ -1582,11 +1610,11 @@ static void efx_flush_all(struct efx_nic *efx) | |||
| 1582 | cancel_work_sync(&efx->mac_work); | 1610 | cancel_work_sync(&efx->mac_work); |
| 1583 | } | 1611 | } |
| 1584 | 1612 | ||
| 1585 | /* Quiesce hardware and software without bringing the link down. | 1613 | /* Quiesce the hardware and software data path, and regular activity |
| 1586 | * Safe to call multiple times, when the nic and interface is in any | 1614 | * for the port without bringing the link down. Safe to call multiple |
| 1587 | * state. The caller is guaranteed to subsequently be in a position | 1615 | * times with the NIC in almost any state, but interrupts should be |
| 1588 | * to modify any hardware and software state they see fit without | 1616 | * enabled. Requires the RTNL lock. |
| 1589 | * taking locks. */ | 1617 | */ |
| 1590 | static void efx_stop_all(struct efx_nic *efx) | 1618 | static void efx_stop_all(struct efx_nic *efx) |
| 1591 | { | 1619 | { |
| 1592 | EFX_ASSERT_RESET_SERIALISED(efx); | 1620 | EFX_ASSERT_RESET_SERIALISED(efx); |
| @@ -1739,8 +1767,6 @@ static int efx_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd) | |||
| 1739 | struct efx_nic *efx = netdev_priv(net_dev); | 1767 | struct efx_nic *efx = netdev_priv(net_dev); |
| 1740 | struct mii_ioctl_data *data = if_mii(ifr); | 1768 | struct mii_ioctl_data *data = if_mii(ifr); |
| 1741 | 1769 | ||
| 1742 | EFX_ASSERT_RESET_SERIALISED(efx); | ||
| 1743 | |||
| 1744 | /* Convert phy_id from older PRTAD/DEVAD format */ | 1770 | /* Convert phy_id from older PRTAD/DEVAD format */ |
| 1745 | if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) && | 1771 | if ((cmd == SIOCGMIIREG || cmd == SIOCSMIIREG) && |
| 1746 | (data->phy_id & 0xfc00) == 0x0400) | 1772 | (data->phy_id & 0xfc00) == 0x0400) |
| @@ -1820,13 +1846,14 @@ static void efx_netpoll(struct net_device *net_dev) | |||
| 1820 | static int efx_net_open(struct net_device *net_dev) | 1846 | static int efx_net_open(struct net_device *net_dev) |
| 1821 | { | 1847 | { |
| 1822 | struct efx_nic *efx = netdev_priv(net_dev); | 1848 | struct efx_nic *efx = netdev_priv(net_dev); |
| 1823 | EFX_ASSERT_RESET_SERIALISED(efx); | 1849 | int rc; |
| 1824 | 1850 | ||
| 1825 | netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n", | 1851 | netif_dbg(efx, ifup, efx->net_dev, "opening device on CPU %d\n", |
| 1826 | raw_smp_processor_id()); | 1852 | raw_smp_processor_id()); |
| 1827 | 1853 | ||
| 1828 | if (efx->state == STATE_DISABLED) | 1854 | rc = efx_check_disabled(efx); |
| 1829 | return -EIO; | 1855 | if (rc) |
