aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 00:04:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-21 00:04:47 -0400
commit3b59bf081622b6446db77ad06c93fe23677bc533 (patch)
tree3f4bb5a27c90cc86994a1f6d3c53fbf9208003cb /include/linux/netdevice.h
parente45836fafe157df137a837093037f741ad8f4c90 (diff)
parentbbdb32cb5b73597386913d052165423b9d736145 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking merge from David Miller: "1) Move ixgbe driver over to purely page based buffering on receive. From Alexander Duyck. 2) Add receive packet steering support to e1000e, from Bruce Allan. 3) Convert TCP MD5 support over to RCU, from Eric Dumazet. 4) Reduce cpu usage in handling out-of-order TCP packets on modern systems, also from Eric Dumazet. 5) Support the IP{,V6}_UNICAST_IF socket options, making the wine folks happy, from Erich Hoover. 6) Support VLAN trunking from guests in hyperv driver, from Haiyang Zhang. 7) Support byte-queue-limtis in r8169, from Igor Maravic. 8) Outline code intended for IP_RECVTOS in IP_PKTOPTIONS existed but was never properly implemented, Jiri Benc fixed that. 9) 64-bit statistics support in r8169 and 8139too, from Junchang Wang. 10) Support kernel side dump filtering by ctmark in netfilter ctnetlink, from Pablo Neira Ayuso. 11) Support byte-queue-limits in gianfar driver, from Paul Gortmaker. 12) Add new peek socket options to assist with socket migration, from Pavel Emelyanov. 13) Add sch_plug packet scheduler whose queue is controlled by userland daemons using explicit freeze and release commands. From Shriram Rajagopalan. 14) Fix FCOE checksum offload handling on transmit, from Yi Zou." * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1846 commits) Fix pppol2tp getsockname() Remove printk from rds_sendmsg ipv6: fix incorrent ipv6 ipsec packet fragment cpsw: Hook up default ndo_change_mtu. net: qmi_wwan: fix build error due to cdc-wdm dependecy netdev: driver: ethernet: Add TI CPSW driver netdev: driver: ethernet: add cpsw address lookup engine support phy: add am79c874 PHY support mlx4_core: fix race on comm channel bonding: send igmp report for its master fs_enet: Add MPC5125 FEC support and PHY interface selection net: bpf_jit: fix BPF_S_LDX_B_MSH compilation net: update the usage of CHECKSUM_UNNECESSARY fcoe: use CHECKSUM_UNNECESSARY instead of CHECKSUM_PARTIAL on tx net: do not do gso for CHECKSUM_UNNECESSARY in netif_needs_gso ixgbe: Fix issues with SR-IOV loopback when flow control is disabled net/hyperv: Fix the code handling tx busy ixgbe: fix namespace issues when FCoE/DCB is not enabled rtlwifi: Remove unused ETH_ADDR_LEN defines igbvf: Use ETH_ALEN ... Fix up fairly trivial conflicts in drivers/isdn/gigaset/interface.c and drivers/net/usb/{Kconfig,qmi_wwan.c} as per David.
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h117
1 files changed, 72 insertions, 45 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 3e5cb2546e4f..8debe299676d 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -417,7 +417,7 @@ typedef rx_handler_result_t rx_handler_func_t(struct sk_buff **pskb);
417 417
418extern void __napi_schedule(struct napi_struct *n); 418extern void __napi_schedule(struct napi_struct *n);
419 419
420static inline int napi_disable_pending(struct napi_struct *n) 420static inline bool napi_disable_pending(struct napi_struct *n)
421{ 421{
422 return test_bit(NAPI_STATE_DISABLE, &n->state); 422 return test_bit(NAPI_STATE_DISABLE, &n->state);
423} 423}
@@ -431,7 +431,7 @@ static inline int napi_disable_pending(struct napi_struct *n)
431 * insure only one NAPI poll instance runs. We also make 431 * insure only one NAPI poll instance runs. We also make
432 * sure there is no pending NAPI disable. 432 * sure there is no pending NAPI disable.
433 */ 433 */
434static inline int napi_schedule_prep(struct napi_struct *n) 434static inline bool napi_schedule_prep(struct napi_struct *n)
435{ 435{
436 return !napi_disable_pending(n) && 436 return !napi_disable_pending(n) &&
437 !test_and_set_bit(NAPI_STATE_SCHED, &n->state); 437 !test_and_set_bit(NAPI_STATE_SCHED, &n->state);
@@ -451,13 +451,13 @@ static inline void napi_schedule(struct napi_struct *n)
451} 451}
452 452
453/* Try to reschedule poll. Called by dev->poll() after napi_complete(). */ 453/* Try to reschedule poll. Called by dev->poll() after napi_complete(). */
454static inline int napi_reschedule(struct napi_struct *napi) 454static inline bool napi_reschedule(struct napi_struct *napi)
455{ 455{
456 if (napi_schedule_prep(napi)) { 456 if (napi_schedule_prep(napi)) {
457 __napi_schedule(napi); 457 __napi_schedule(napi);
458 return 1; 458 return true;
459 } 459 }
460 return 0; 460 return false;
461} 461}
462 462
463/** 463/**
@@ -1082,7 +1082,8 @@ struct net_device {
1082 const struct header_ops *header_ops; 1082 const struct header_ops *header_ops;
1083 1083
1084 unsigned int flags; /* interface flags (a la BSD) */ 1084 unsigned int flags; /* interface flags (a la BSD) */
1085 unsigned int priv_flags; /* Like 'flags' but invisible to userspace. */ 1085 unsigned int priv_flags; /* Like 'flags' but invisible to userspace.
1086 * See if.h for definitions. */
1086 unsigned short gflags; 1087 unsigned short gflags;
1087 unsigned short padded; /* How much padding added by alloc_netdev() */ 1088 unsigned short padded; /* How much padding added by alloc_netdev() */
1088 1089
@@ -1867,7 +1868,7 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev)
1867 } 1868 }
1868} 1869}
1869 1870
1870static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue) 1871static inline bool netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
1871{ 1872{
1872 return test_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state); 1873 return test_bit(__QUEUE_STATE_DRV_XOFF, &dev_queue->state);
1873} 1874}
@@ -1878,17 +1879,17 @@ static inline int netif_tx_queue_stopped(const struct netdev_queue *dev_queue)
1878 * 1879 *
1879 * Test if transmit queue on device is currently unable to send. 1880 * Test if transmit queue on device is currently unable to send.
1880 */ 1881 */
1881static inline int netif_queue_stopped(const struct net_device *dev) 1882static inline bool netif_queue_stopped(const struct net_device *dev)
1882{ 1883{
1883 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0)); 1884 return netif_tx_queue_stopped(netdev_get_tx_queue(dev, 0));
1884} 1885}
1885 1886
1886static inline int netif_xmit_stopped(const struct netdev_queue *dev_queue) 1887static inline bool netif_xmit_stopped(const struct netdev_queue *dev_queue)
1887{ 1888{
1888 return dev_queue->state & QUEUE_STATE_ANY_XOFF; 1889 return dev_queue->state & QUEUE_STATE_ANY_XOFF;
1889} 1890}
1890 1891
1891static inline int netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue) 1892static inline bool netif_xmit_frozen_or_stopped(const struct netdev_queue *dev_queue)
1892{ 1893{
1893 return dev_queue->state & QUEUE_STATE_ANY_XOFF_OR_FROZEN; 1894 return dev_queue->state & QUEUE_STATE_ANY_XOFF_OR_FROZEN;
1894} 1895}
@@ -1898,12 +1899,22 @@ static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue,
1898{ 1899{
1899#ifdef CONFIG_BQL 1900#ifdef CONFIG_BQL
1900 dql_queued(&dev_queue->dql, bytes); 1901 dql_queued(&dev_queue->dql, bytes);
1901 if (unlikely(dql_avail(&dev_queue->dql) < 0)) { 1902
1902 set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state); 1903 if (likely(dql_avail(&dev_queue->dql) >= 0))
1903 if (unlikely(dql_avail(&dev_queue->dql) >= 0)) 1904 return;
1904 clear_bit(__QUEUE_STATE_STACK_XOFF, 1905
1905 &dev_queue->state); 1906 set_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state);
1906 } 1907
1908 /*
1909 * The XOFF flag must be set before checking the dql_avail below,
1910 * because in netdev_tx_completed_queue we update the dql_completed
1911 * before checking the XOFF flag.
1912 */
1913 smp_mb();
1914
1915 /* check again in case another CPU has just made room avail */
1916 if (unlikely(dql_avail(&dev_queue->dql) >= 0))
1917 clear_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state);
1907#endif 1918#endif
1908} 1919}
1909 1920
@@ -1916,16 +1927,23 @@ static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue,
1916 unsigned pkts, unsigned bytes) 1927 unsigned pkts, unsigned bytes)
1917{ 1928{
1918#ifdef CONFIG_BQL 1929#ifdef CONFIG_BQL
1919 if (likely(bytes)) { 1930 if (unlikely(!bytes))
1920 dql_completed(&dev_queue->dql, bytes); 1931 return;
1921 if (unlikely(test_bit(__QUEUE_STATE_STACK_XOFF, 1932
1922 &dev_queue->state) && 1933 dql_completed(&dev_queue->dql, bytes);
1923 dql_avail(&dev_queue->dql) >= 0)) { 1934
1924 if (test_and_clear_bit(__QUEUE_STATE_STACK_XOFF, 1935 /*
1925 &dev_queue->state)) 1936 * Without the memory barrier there is a small possiblity that
1926 netif_schedule_queue(dev_queue); 1937 * netdev_tx_sent_queue will miss the update and cause the queue to
1927 } 1938 * be stopped forever
1928 } 1939 */
1940 smp_mb();
1941
1942 if (dql_avail(&dev_queue->dql) < 0)
1943 return;
1944
1945 if (test_and_clear_bit(__QUEUE_STATE_STACK_XOFF, &dev_queue->state))
1946 netif_schedule_queue(dev_queue);
1929#endif 1947#endif
1930} 1948}
1931 1949
@@ -1938,6 +1956,7 @@ static inline void netdev_completed_queue(struct net_device *dev,
1938static inline void netdev_tx_reset_queue(struct netdev_queue *q) 1956static inline void netdev_tx_reset_queue(struct netdev_queue *q)
1939{ 1957{
1940#ifdef CONFIG_BQL 1958#ifdef CONFIG_BQL
1959 clear_bit(__QUEUE_STATE_STACK_XOFF, &q->state);
1941 dql_reset(&q->dql); 1960 dql_reset(&q->dql);
1942#endif 1961#endif
1943} 1962}
@@ -1953,7 +1972,7 @@ static inline void netdev_reset_queue(struct net_device *dev_queue)
1953 * 1972 *
1954 * Test if the device has been brought up. 1973 * Test if the device has been brought up.
1955 */ 1974 */
1956static inline int netif_running(const struct net_device *dev) 1975static inline bool netif_running(const struct net_device *dev)
1957{ 1976{
1958 return test_bit(__LINK_STATE_START, &dev->state); 1977 return test_bit(__LINK_STATE_START, &dev->state);
1959} 1978}
@@ -2003,16 +2022,16 @@ static inline void netif_stop_subqueue(struct net_device *dev, u16 queue_index)
2003 * 2022 *
2004 * Check individual transmit queue of a device with multiple transmit queues. 2023 * Check individual transmit queue of a device with multiple transmit queues.
2005 */ 2024 */
2006static inline int __netif_subqueue_stopped(const struct net_device *dev, 2025static inline bool __netif_subqueue_stopped(const struct net_device *dev,
2007 u16 queue_index) 2026 u16 queue_index)
2008{ 2027{
2009 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index); 2028 struct netdev_queue *txq = netdev_get_tx_queue(dev, queue_index);
2010 2029
2011 return netif_tx_queue_stopped(txq); 2030 return netif_tx_queue_stopped(txq);
2012} 2031}
2013