aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2009-11-15 02:20:12 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-16 01:08:33 -0500
commit9a1654ba0b50402a6bd03c7b0fe9b0200a5ea7b1 (patch)
tree3defd37672da2069e6c0ffd86b0b99c694324985 /include/linux/netdevice.h
parentcb43e23435a66d5ed90f804af9efe9096503979f (diff)
net: Optimize hard_start_xmit() return checking
Recent changes in the TX error propagation require additional checking and masking of values returned from hard_start_xmit(), mainly to separate cases where skb was consumed. This aim can be simplified by changing the order of NETDEV_TX and NET_XMIT codes, because the latter are treated similarly to negative (ERRNO) values. After this change much simpler dev_xmit_complete() is also used in sch_direct_xmit(), so it is moved to netdevice.h. Additionally NET_RX definitions in netdevice.h are moved up from between TX codes to avoid confusion while reading the TX comment. Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h42
1 files changed, 30 insertions, 12 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 61425d0c6123..7043f85e643d 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -63,6 +63,10 @@ struct wireless_dev;
63#define HAVE_FREE_NETDEV /* free_netdev() */ 63#define HAVE_FREE_NETDEV /* free_netdev() */
64#define HAVE_NETDEV_PRIV /* netdev_priv() */ 64#define HAVE_NETDEV_PRIV /* netdev_priv() */
65 65
66/* Backlog congestion levels */
67#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
68#define NET_RX_DROP 1 /* packet dropped */
69
66/* 70/*
67 * Transmit return codes: transmit return codes originate from three different 71 * Transmit return codes: transmit return codes originate from three different
68 * namespaces: 72 * namespaces:
@@ -82,14 +86,10 @@ struct wireless_dev;
82 86
83/* qdisc ->enqueue() return codes. */ 87/* qdisc ->enqueue() return codes. */
84#define NET_XMIT_SUCCESS 0x00 88#define NET_XMIT_SUCCESS 0x00
85#define NET_XMIT_DROP 0x10 /* skb dropped */ 89#define NET_XMIT_DROP 0x01 /* skb dropped */
86#define NET_XMIT_CN 0x20 /* congestion notification */ 90#define NET_XMIT_CN 0x02 /* congestion notification */
87#define NET_XMIT_POLICED 0x30 /* skb is shot by police */ 91#define NET_XMIT_POLICED 0x03 /* skb is shot by police */
88#define NET_XMIT_MASK 0xf0 /* qdisc flags in net/sch_generic.h */ 92#define NET_XMIT_MASK 0x0f /* qdisc flags in net/sch_generic.h */
89
90/* Backlog congestion levels */
91#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
92#define NET_RX_DROP 1 /* packet dropped */
93 93
94/* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It 94/* NET_XMIT_CN is special. It does not guarantee that this packet is lost. It
95 * indicates that the device will soon be dropping packets, or already drops 95 * indicates that the device will soon be dropping packets, or already drops
@@ -98,16 +98,34 @@ struct wireless_dev;
98#define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0) 98#define net_xmit_errno(e) ((e) != NET_XMIT_CN ? -ENOBUFS : 0)
99 99
100/* Driver transmit return codes */ 100/* Driver transmit return codes */
101#define NETDEV_TX_MASK 0xf 101#define NETDEV_TX_MASK 0xf0
102 102
103enum netdev_tx { 103enum netdev_tx {
104 __NETDEV_TX_MIN = INT_MIN, /* make sure enum is signed */ 104 __NETDEV_TX_MIN = INT_MIN, /* make sure enum is signed */
105 NETDEV_TX_OK = 0, /* driver took care of packet */ 105 NETDEV_TX_OK = 0x00, /* driver took care of packet */
106 NETDEV_TX_BUSY = 1, /* driver tx path was busy*/ 106 NETDEV_TX_BUSY = 0x10, /* driver tx path was busy*/
107 NETDEV_TX_LOCKED = 2, /* driver tx lock was already taken */ 107 NETDEV_TX_LOCKED = 0x20, /* driver tx lock was already taken */
108}; 108};
109typedef enum netdev_tx netdev_tx_t; 109typedef enum netdev_tx netdev_tx_t;
110 110
111/*
112 * Current order: NETDEV_TX_MASK > NET_XMIT_MASK >= 0 is significant;
113 * hard_start_xmit() return < NET_XMIT_MASK means skb was consumed.
114 */
115static inline bool dev_xmit_complete(int rc)
116{
117 /*
118 * Positive cases with an skb consumed by a driver:
119 * - successful transmission (rc == NETDEV_TX_OK)
120 * - error while transmitting (rc < 0)
121 * - error while queueing to a different device (rc & NET_XMIT_MASK)
122 */
123 if (likely(rc < NET_XMIT_MASK))
124 return true;
125
126 return false;
127}
128
111#endif 129#endif
112 130
113#define MAX_ADDR_LEN 32 /* Largest hardware address length */ 131#define MAX_ADDR_LEN 32 /* Largest hardware address length */