aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/netdevice.h42
-rw-r--r--net/core/dev.c17
-rw-r--r--net/sched/sch_generic.c23
3 files changed, 35 insertions, 47 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 */
diff --git a/net/core/dev.c b/net/core/dev.c
index 32045df1da5c..4b24d79414e3 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1924,23 +1924,6 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
1924 return rc; 1924 return rc;
1925} 1925}
1926 1926
1927static inline bool dev_xmit_complete(int rc)
1928{
1929 /* successful transmission */
1930 if (rc == NETDEV_TX_OK)
1931 return true;
1932
1933 /* error while transmitting, driver consumed skb */
1934 if (rc < 0)
1935 return true;
1936
1937 /* error while queueing to a different device, driver consumed skb */
1938 if (rc & NET_XMIT_MASK)
1939 return true;
1940
1941 return false;
1942}
1943
1944/** 1927/**
1945 * dev_queue_xmit - transmit a buffer 1928 * dev_queue_xmit - transmit a buffer
1946 * @skb: buffer to transmit 1929 * @skb: buffer to transmit
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index b13821ad2fb6..5173c1e1b19c 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -119,39 +119,26 @@ int sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
119 spin_unlock(root_lock); 119 spin_unlock(root_lock);
120 120
121 HARD_TX_LOCK(dev, txq, smp_processor_id()); 121 HARD_TX_LOCK(dev, txq, smp_processor_id());
122 if (!netif_tx_queue_stopped(txq) && 122 if (!netif_tx_queue_stopped(txq) && !netif_tx_queue_frozen(txq))
123 !netif_tx_queue_frozen(txq)) {
124 ret = dev_hard_start_xmit(skb, dev, txq); 123 ret = dev_hard_start_xmit(skb, dev, txq);
125 124
126 /* an error implies that the skb was consumed */
127 if (ret < 0)
128 ret = NETDEV_TX_OK;
129 /* all NET_XMIT codes map to NETDEV_TX_OK */
130 ret &= ~NET_XMIT_MASK;
131 }
132 HARD_TX_UNLOCK(dev, txq); 125 HARD_TX_UNLOCK(dev, txq);
133 126
134 spin_lock(root_lock); 127 spin_lock(root_lock);
135 128
136 switch (ret) { 129 if (dev_xmit_complete(ret)) {
137 case NETDEV_TX_OK: 130 /* Driver sent out skb successfully or skb was consumed */
138 /* Driver sent out skb successfully */
139 ret = qdisc_qlen(q); 131 ret = qdisc_qlen(q);
140 break; 132 } else if (ret == NETDEV_TX_LOCKED) {
141
142 case NETDEV_TX_LOCKED:
143 /* Driver try lock failed */ 133 /* Driver try lock failed */
144 ret = handle_dev_cpu_collision(skb, txq, q); 134 ret = handle_dev_cpu_collision(skb, txq, q);
145 break; 135 } else {
146
147 default:
148 /* Driver returned NETDEV_TX_BUSY - requeue skb */ 136 /* Driver returned NETDEV_TX_BUSY - requeue skb */
149 if (unlikely (ret != NETDEV_TX_BUSY && net_ratelimit())) 137 if (unlikely (ret != NETDEV_TX_BUSY && net_ratelimit()))
150 printk(KERN_WARNING "BUG %s code %d qlen %d\n", 138 printk(KERN_WARNING "BUG %s code %d qlen %d\n",
151 dev->name, ret, q->q.qlen); 139 dev->name, ret, q->q.qlen);
152 140
153 ret = dev_requeue_skb(skb, q); 141 ret = dev_requeue_skb(skb, q);
154 break;
155 } 142 }
156 143
157 if (ret && (netif_tx_queue_stopped(txq) || 144 if (ret && (netif_tx_queue_stopped(txq) ||