diff options
author | Tom Herbert <therbert@google.com> | 2011-11-28 11:32:44 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-11-29 12:46:19 -0500 |
commit | 7346649826382b769cfadf4a2fe8a84d060c55e9 (patch) | |
tree | 0241cce453992881f61d3fbc4f9baf7eb0578135 /include/linux/netdevice.h | |
parent | 75957ba36c05b979701e9ec64b37819adc12f830 (diff) |
net: Add queue state xoff flag for stack
Create separate queue state flags so that either the stack or drivers
can turn on XOFF. Added a set of functions used in the stack to determine
if a queue is really stopped (either by stack or driver)
Signed-off-by: Tom Herbert <therbert@google.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r-- | include/linux/netdevice.h | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index ac9a4b9344ca..d19f93265cac 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h | |||
@@ -517,11 +517,23 @@ static inline void napi_synchronize(const struct napi_struct *n) | |||
517 | #endif | 517 | #endif |
518 | 518 | ||
519 | enum netdev_queue_state_t { | 519 | enum netdev_queue_state_t { |
520 | __QUEUE_STATE_XOFF, | 520 | __QUEUE_STATE_DRV_XOFF, |
521 | __QUEUE_STATE_STACK_XOFF, | ||
521 | __QUEUE_STATE_FROZEN, | 522 | __QUEUE_STATE_FROZEN, |
522 | #define QUEUE_STATE_XOFF_OR_FROZEN ((1 << __QUEUE_STATE_XOFF) | \ | 523 | #define QUEUE_STATE_ANY_XOFF ((1 << __QUEUE_STATE_DRV_XOFF) | \ |
523 | (1 << __QUEUE_STATE_FROZEN)) | 524 | (1 << __QUEUE_STATE_STACK_XOFF)) |
525 | #define QUEUE_STATE_ANY_XOFF_OR_FROZEN (QUEUE_STATE_ANY_XOFF | \ | ||
526 | (1 << __QUEUE_STATE_FROZEN)) | ||
524 | }; | 527 | }; |
528 | /* | ||
529 | * __QUEUE_STATE_DRV_XOFF is used by drivers to stop the transmit queue. The | ||
530 | * netif_tx_* functions below are used to manipulate this flag. The | ||
531 | * __QUEUE_STATE_STACK_XOFF flag is used by the stack to stop the transmit | ||
532 | * queue independently. The netif_xmit_*stopped functions below are called | ||
533 | * to check if the queue has been stopped by the driver or stack (either | ||
534 | * of the XOFF bits are set in the state). Drivers should not need to call | ||
535 | * netif_xmit*stopped functions, they should only be using netif_tx_*. | ||
536 | */ | ||
525 | 537 | ||
526 | struct netdev_queue { | 538 | struct netdev_queue { |
527 | /* | 539 | /* |
@@ -1718,7 +1730,7 @@ extern void __netif_schedule(struct Qdisc *q); | |||
1718 | 1730 | ||
1719 | static inline void netif_schedule_queue(struct netdev_queue *txq) | 1731 | static inline void netif_schedule_queue(struct netdev_queue *txq) |
1720 | { | 1732 | { |
1721 | if (!test_bit(__QUEUE_STATE_XOFF, &txq->state)) | 1733 | if (!(txq->state & QUEUE_STATE_ANY_XOFF)) |
1722 | __netif_schedule(txq->qdisc); | 1734 | __netif_schedule(txq->qdisc); |
1723 | } | 1735 | } |
1724 | 1736 | ||
@@ -1732,7 +1744,7 @@ static inline void netif_tx_schedule_all(struct net_device *dev) | |||
1732 | 1744 | ||
1733 | static inline void netif_tx_start_queue(struct netdev_queue *dev_queue) | 1745 | static inline void netif_tx_start_queue(struct netdev_queue *dev_queue) |
1734 | { | 1746 | { |
1735 | clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state); | 1747 | clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state); |
1736 | } | 1748 | } |
1737 | 1749 | ||
1738 | /** | 1750 | /** |
@@ -1764,7 +1776,7 @@ static inline void netif_tx_wake_queue(struct netdev_queue *dev_queue) | |||
1764 | return; | 1776 | return; |
1765 | } | 1777 | } |
1766 | #endif | 1778 | #endif |
1767 | if (test_and_clear_bit(__QUEUE_STATE_XOFF, &dev_queue->state)) | 1779 | if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state)) |
1768 | __netif_schedule(dev_queue->qdisc); | 1780 | __netif_schedule(dev_queue->qdisc); |
1769 | } | 1781 | } |
1770 | 1782 | ||
@@ -1796,7 +1808,7 @@ static inline void netif_tx_stop_queue(struct netdev_queue *dev_queue) | |||
1796 | pr_info("netif_stop_queue() cannot be called before register_netdev()\n"); | 1808 | pr_info("netif_stop_queue() cannot be called before register_netdev()\n"); |
1797 | return; | 1809 | return; |
1798 | } | 1810 | } |
1799 | set_bit(__QUEUE_STATE_XOFF, &dev_queue->state); | 1811 | set_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state); |
1800 | } | 1812 | } |
1801 | 1813 | ||
1802 | /** | 1814 | /** |
@@ -1823,7 +1835,7 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev) | |||
1823 | 1835 | ||
1824 | static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue) | 1836 | static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue) |
1825 | { | 1837 | { |
1826 | return test_bit(__QUEUE_STATE_XOFF, &dev_queue->state); | 1838 | return test_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state); |
1827 | } | 1839 | } |
1828 | 1840 | ||
1829 | /** | 1841 | /** |
@@ -1837,9 +1849,16 @@ static inline int netif_queue_stopped(const struct net_device *dev) | |||
1837 | return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); | 1849 | return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); |
1838 | } | 1850 | } |
1839 | 1851 | ||
1840 | static inline int netif_tx_queue_frozen_or_stopped(const struct netdev_queue *dev_queue) | 1852 | static inline int netif_xmit_stopped(const struct netdev_queue *dev_queue) |
1841 | { | 1853 | { |
1842 | return dev_queue->state & QUEUE_STATE_XOFF_OR_FROZEN; | 1854 | return dev_queue->state & QUEUE_STATE_ANY_XOFF; |
1855 | } | ||
1856 | |||
1857 | static inline int netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue) | ||
1858 | { | ||
1859 | return dev_queue->state & QUEUE_STATE_ANY_XOFF_OR_FROZEN; | ||
1860 | } | ||
1861 | |||
1843 | } | 1862 | } |
1844 | 1863 | ||
1845 | /** | 1864 | /** |
@@ -1926,7 +1945,7 @@ static inline void netif_wake_subqueue(struct net_device *dev, u16 queue_index) | |||
1926 | if (netpoll_trap()) | 1945 | if (netpoll_trap()) |
1927 | return; | 1946 | return; |
1928 | #endif | 1947 | #endif |
1929 | if (test_and_clear_bit(__QUEUE_STATE_XOFF, &txq->state)) | 1948 | if (test_and_clear_bit(__QUEUE_STATE_DRV_XOFF, &txq->state)) |
1930 | __netif_schedule(txq->qdisc); | 1949 | __netif_schedule(txq->qdisc); |
1931 | } | 1950 | } |
1932 | 1951 | ||