direct-io.hg

view patches/linux-2.6.16.13/net-gso-0-base.patch @ 11329:3fdc31e91384

[IA64] Modify xc_ia64_hvm_build for using the new Xen event channels

Signed-off-by: Tsunehisa Doi <Doi.Tsunehisa@jp.fujitsu.com>
Signed-off-by: Tomonari Horikoshi <t.horikoshi@jp.fujitsu.com>
author awilliam@xenbuild.aw
date Wed Aug 23 13:21:02 2006 -0600 (2006-08-23)
parents d48322cddd87
children
line source
1 diff --git a/Documentation/networking/netdevices.txt b/Documentation/networking/netdevices.txt
2 index 3c0a5ba..847cedb 100644
3 --- a/Documentation/networking/netdevices.txt
4 +++ b/Documentation/networking/netdevices.txt
5 @@ -42,9 +42,9 @@ dev->get_stats:
6 Context: nominally process, but don't sleep inside an rwlock
8 dev->hard_start_xmit:
9 - Synchronization: dev->xmit_lock spinlock.
10 + Synchronization: netif_tx_lock spinlock.
11 When the driver sets NETIF_F_LLTX in dev->features this will be
12 - called without holding xmit_lock. In this case the driver
13 + called without holding netif_tx_lock. In this case the driver
14 has to lock by itself when needed. It is recommended to use a try lock
15 for this and return -1 when the spin lock fails.
16 The locking there should also properly protect against
17 @@ -62,12 +62,12 @@ dev->hard_start_xmit:
18 Only valid when NETIF_F_LLTX is set.
20 dev->tx_timeout:
21 - Synchronization: dev->xmit_lock spinlock.
22 + Synchronization: netif_tx_lock spinlock.
23 Context: BHs disabled
24 Notes: netif_queue_stopped() is guaranteed true
26 dev->set_multicast_list:
27 - Synchronization: dev->xmit_lock spinlock.
28 + Synchronization: netif_tx_lock spinlock.
29 Context: BHs disabled
31 dev->poll:
32 diff --git a/drivers/block/aoe/aoenet.c b/drivers/block/aoe/aoenet.c
33 index 4be9769..2e7cac7 100644
34 --- a/drivers/block/aoe/aoenet.c
35 +++ b/drivers/block/aoe/aoenet.c
36 @@ -95,9 +95,8 @@ mac_addr(char addr[6])
37 static struct sk_buff *
38 skb_check(struct sk_buff *skb)
39 {
40 - if (skb_is_nonlinear(skb))
41 if ((skb = skb_share_check(skb, GFP_ATOMIC)))
42 - if (skb_linearize(skb, GFP_ATOMIC) < 0) {
43 + if (skb_linearize(skb)) {
44 dev_kfree_skb(skb);
45 return NULL;
46 }
47 diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
48 index a2408d7..c90e620 100644
49 --- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
50 +++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
51 @@ -821,7 +821,8 @@ void ipoib_mcast_restart_task(void *dev_
53 ipoib_mcast_stop_thread(dev, 0);
55 - spin_lock_irqsave(&dev->xmit_lock, flags);
56 + local_irq_save(flags);
57 + netif_tx_lock(dev);
58 spin_lock(&priv->lock);
60 /*
61 @@ -896,7 +897,8 @@ void ipoib_mcast_restart_task(void *dev_
62 }
64 spin_unlock(&priv->lock);
65 - spin_unlock_irqrestore(&dev->xmit_lock, flags);
66 + netif_tx_unlock(dev);
67 + local_irq_restore(flags);
69 /* We have to cancel outside of the spinlock */
70 list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
71 diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
72 index 6711eb6..8d2351f 100644
73 --- a/drivers/media/dvb/dvb-core/dvb_net.c
74 +++ b/drivers/media/dvb/dvb-core/dvb_net.c
75 @@ -1052,7 +1052,7 @@ static void wq_set_multicast_list (void
77 dvb_net_feed_stop(dev);
78 priv->rx_mode = RX_MODE_UNI;
79 - spin_lock_bh(&dev->xmit_lock);
80 + netif_tx_lock_bh(dev);
82 if (dev->flags & IFF_PROMISC) {
83 dprintk("%s: promiscuous mode\n", dev->name);
84 @@ -1077,7 +1077,7 @@ static void wq_set_multicast_list (void
85 }
86 }
88 - spin_unlock_bh(&dev->xmit_lock);
89 + netif_tx_unlock_bh(dev);
90 dvb_net_feed_start(dev);
91 }
93 diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
94 index dd41049..6615583 100644
95 --- a/drivers/net/8139cp.c
96 +++ b/drivers/net/8139cp.c
97 @@ -794,7 +794,7 @@ #endif
98 entry = cp->tx_head;
99 eor = (entry == (CP_TX_RING_SIZE - 1)) ? RingEnd : 0;
100 if (dev->features & NETIF_F_TSO)
101 - mss = skb_shinfo(skb)->tso_size;
102 + mss = skb_shinfo(skb)->gso_size;
104 if (skb_shinfo(skb)->nr_frags == 0) {
105 struct cp_desc *txd = &cp->tx_ring[entry];
106 diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
107 index a24200d..b5e39a1 100644
108 --- a/drivers/net/bnx2.c
109 +++ b/drivers/net/bnx2.c
110 @@ -1593,7 +1593,7 @@ bnx2_tx_int(struct bnx2 *bp)
111 skb = tx_buf->skb;
112 #ifdef BCM_TSO
113 /* partial BD completions possible with TSO packets */
114 - if (skb_shinfo(skb)->tso_size) {
115 + if (skb_shinfo(skb)->gso_size) {
116 u16 last_idx, last_ring_idx;
118 last_idx = sw_cons +
119 @@ -1948,7 +1948,7 @@ bnx2_poll(struct net_device *dev, int *b
120 return 1;
121 }
123 -/* Called with rtnl_lock from vlan functions and also dev->xmit_lock
124 +/* Called with rtnl_lock from vlan functions and also netif_tx_lock
125 * from set_multicast.
126 */
127 static void
128 @@ -4403,7 +4403,7 @@ bnx2_vlan_rx_kill_vid(struct net_device
129 }
130 #endif
132 -/* Called with dev->xmit_lock.
133 +/* Called with netif_tx_lock.
134 * hard_start_xmit is pseudo-lockless - a lock is only required when
135 * the tx queue is full. This way, we get the benefit of lockless
136 * operations most of the time without the complexities to handle
137 @@ -4441,7 +4441,7 @@ bnx2_start_xmit(struct sk_buff *skb, str
138 (TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
139 }
140 #ifdef BCM_TSO
141 - if ((mss = skb_shinfo(skb)->tso_size) &&
142 + if ((mss = skb_shinfo(skb)->gso_size) &&
143 (skb->len > (bp->dev->mtu + ETH_HLEN))) {
144 u32 tcp_opt_len, ip_tcp_len;
146 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
147 index bcf9f17..e970921 100644
148 --- a/drivers/net/bonding/bond_main.c
149 +++ b/drivers/net/bonding/bond_main.c
150 @@ -1145,8 +1145,7 @@ int bond_sethwaddr(struct net_device *bo
151 }
153 #define BOND_INTERSECT_FEATURES \
154 - (NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM|\
155 - NETIF_F_TSO|NETIF_F_UFO)
156 + (NETIF_F_SG | NETIF_F_ALL_CSUM | NETIF_F_TSO | NETIF_F_UFO)
158 /*
159 * Compute the common dev->feature set available to all slaves. Some
160 @@ -1164,9 +1163,7 @@ static int bond_compute_features(struct
161 features &= (slave->dev->features & BOND_INTERSECT_FEATURES);
163 if ((features & NETIF_F_SG) &&
164 - !(features & (NETIF_F_IP_CSUM |
165 - NETIF_F_NO_CSUM |
166 - NETIF_F_HW_CSUM)))
167 + !(features & NETIF_F_ALL_CSUM))
168 features &= ~NETIF_F_SG;
170 /*
171 @@ -4147,7 +4144,7 @@ static int bond_init(struct net_device *
172 */
173 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
175 - /* don't acquire bond device's xmit_lock when
176 + /* don't acquire bond device's netif_tx_lock when
177 * transmitting */
178 bond_dev->features |= NETIF_F_LLTX;
180 diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
181 index 30ff8ea..7b7d360 100644
182 --- a/drivers/net/chelsio/sge.c
183 +++ b/drivers/net/chelsio/sge.c
184 @@ -1419,7 +1419,7 @@ int t1_start_xmit(struct sk_buff *skb, s
185 struct cpl_tx_pkt *cpl;
187 #ifdef NETIF_F_TSO
188 - if (skb_shinfo(skb)->tso_size) {
189 + if (skb_shinfo(skb)->gso_size) {
190 int eth_type;
191 struct cpl_tx_pkt_lso *hdr;
193 @@ -1434,7 +1434,7 @@ #ifdef NETIF_F_TSO
194 hdr->ip_hdr_words = skb->nh.iph->ihl;
195 hdr->tcp_hdr_words = skb->h.th->doff;
196 hdr->eth_type_mss = htons(MK_ETH_TYPE_MSS(eth_type,
197 - skb_shinfo(skb)->tso_size));
198 + skb_shinfo(skb)->gso_size));
199 hdr->len = htonl(skb->len - sizeof(*hdr));
200 cpl = (struct cpl_tx_pkt *)hdr;
201 sge->stats.tx_lso_pkts++;
202 diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
203 index fa29402..681d284 100644
204 --- a/drivers/net/e1000/e1000_main.c
205 +++ b/drivers/net/e1000/e1000_main.c
206 @@ -2526,7 +2526,7 @@ #ifdef NETIF_F_TSO
207 uint8_t ipcss, ipcso, tucss, tucso, hdr_len;
208 int err;
210 - if (skb_shinfo(skb)->tso_size) {
211 + if (skb_shinfo(skb)->gso_size) {
212 if (skb_header_cloned(skb)) {
213 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
214 if (err)
215 @@ -2534,7 +2534,7 @@ #ifdef NETIF_F_TSO
216 }
218 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
219 - mss = skb_shinfo(skb)->tso_size;
220 + mss = skb_shinfo(skb)->gso_size;
221 if (skb->protocol == ntohs(ETH_P_IP)) {
222 skb->nh.iph->tot_len = 0;
223 skb->nh.iph->check = 0;
224 @@ -2651,7 +2651,7 @@ #ifdef NETIF_F_TSO
225 * tso gets written back prematurely before the data is fully
226 * DMAd to the controller */
227 if (!skb->data_len && tx_ring->last_tx_tso &&
228 - !skb_shinfo(skb)->tso_size) {
229 + !skb_shinfo(skb)->gso_size) {
230 tx_ring->last_tx_tso = 0;
231 size -= 4;
232 }
233 @@ -2893,7 +2893,7 @@ #endif
234 }
236 #ifdef NETIF_F_TSO
237 - mss = skb_shinfo(skb)->tso_size;
238 + mss = skb_shinfo(skb)->gso_size;
239 /* The controller does a simple calculation to
240 * make sure there is enough room in the FIFO before
241 * initiating the DMA for each buffer. The calc is:
242 @@ -2935,7 +2935,7 @@ #endif
243 #ifdef NETIF_F_TSO
244 /* Controller Erratum workaround */
245 if (!skb->data_len && tx_ring->last_tx_tso &&
246 - !skb_shinfo(skb)->tso_size)
247 + !skb_shinfo(skb)->gso_size)
248 count++;
249 #endif
251 diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
252 index 3682ec6..c35f16e 100644
253 --- a/drivers/net/forcedeth.c
254 +++ b/drivers/net/forcedeth.c
255 @@ -482,9 +482,9 @@ #define LPA_1000HALF 0x0400
256 * critical parts:
257 * - rx is (pseudo-) lockless: it relies on the single-threading provided
258 * by the arch code for interrupts.
259 - * - tx setup is lockless: it relies on dev->xmit_lock. Actual submission
260 + * - tx setup is lockless: it relies on netif_tx_lock. Actual submission
261 * needs dev->priv->lock :-(
262 - * - set_multicast_list: preparation lockless, relies on dev->xmit_lock.
263 + * - set_multicast_list: preparation lockless, relies on netif_tx_lock.
264 */
266 /* in dev: base, irq */
267 @@ -1016,7 +1016,7 @@ static void drain_ring(struct net_device
269 /*
270 * nv_start_xmit: dev->hard_start_xmit function
271 - * Called with dev->xmit_lock held.
272 + * Called with netif_tx_lock held.
273 */
274 static int nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
275 {
276 @@ -1105,8 +1105,8 @@ static int nv_start_xmit(struct sk_buff
277 np->tx_skbuff[nr] = skb;
279 #ifdef NETIF_F_TSO
280 - if (skb_shinfo(skb)->tso_size)
281 - tx_flags_extra = NV_TX2_TSO | (skb_shinfo(skb)->tso_size << NV_TX2_TSO_SHIFT);
282 + if (skb_shinfo(skb)->gso_size)
283 + tx_flags_extra = NV_TX2_TSO | (skb_shinfo(skb)->gso_size << NV_TX2_TSO_SHIFT);
284 else
285 #endif
286 tx_flags_extra = (skb->ip_summed == CHECKSUM_HW ? (NV_TX2_CHECKSUM_L3|NV_TX2_CHECKSUM_L4) : 0);
287 @@ -1203,7 +1203,7 @@ static void nv_tx_done(struct net_device
289 /*
290 * nv_tx_timeout: dev->tx_timeout function
291 - * Called with dev->xmit_lock held.
292 + * Called with netif_tx_lock held.
293 */
294 static void nv_tx_timeout(struct net_device *dev)
295 {
296 @@ -1524,7 +1524,7 @@ static int nv_change_mtu(struct net_devi
297 * Changing the MTU is a rare event, it shouldn't matter.
298 */
299 disable_irq(dev->irq);
300 - spin_lock_bh(&dev->xmit_lock);
301 + netif_tx_lock_bh(dev);
302 spin_lock(&np->lock);
303 /* stop engines */
304 nv_stop_rx(dev);
305 @@ -1559,7 +1559,7 @@ static int nv_change_mtu(struct net_devi
306 nv_start_rx(dev);
307 nv_start_tx(dev);
308 spin_unlock(&np->lock);
309 - spin_unlock_bh(&dev->xmit_lock);
310 + netif_tx_unlock_bh(dev);
311 enable_irq(dev->irq);
312 }
313 return 0;
314 @@ -1594,7 +1594,7 @@ static int nv_set_mac_address(struct net
315 memcpy(dev->dev_addr, macaddr->sa_data, ETH_ALEN);
317 if (netif_running(dev)) {
318 - spin_lock_bh(&dev->xmit_lock);
319 + netif_tx_lock_bh(dev);
320 spin_lock_irq(&np->lock);
322 /* stop rx engine */
323 @@ -1606,7 +1606,7 @@ static int nv_set_mac_address(struct net
324 /* restart rx engine */
325 nv_start_rx(dev);
326 spin_unlock_irq(&np->lock);
327 - spin_unlock_bh(&dev->xmit_lock);
328 + netif_tx_unlock_bh(dev);
329 } else {
330 nv_copy_mac_to_hw(dev);
331 }
332 @@ -1615,7 +1615,7 @@ static int nv_set_mac_address(struct net
334 /*
335 * nv_set_multicast: dev->set_multicast function
336 - * Called with dev->xmit_lock held.
337 + * Called with netif_tx_lock held.
338 */
339 static void nv_set_multicast(struct net_device *dev)
340 {
341 diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
342 index 102c1f0..d12605f 100644
343 --- a/drivers/net/hamradio/6pack.c
344 +++ b/drivers/net/hamradio/6pack.c
345 @@ -308,9 +308,9 @@ static int sp_set_mac_address(struct net
346 {
347 struct sockaddr_ax25 *sa = addr;
349 - spin_lock_irq(&dev->xmit_lock);
350 + netif_tx_lock_bh(dev);
351 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN);
352 - spin_unlock_irq(&dev->xmit_lock);
353 + netif_tx_unlock_bh(dev);
355 return 0;
356 }
357 @@ -767,9 +767,9 @@ static int sixpack_ioctl(struct tty_stru
358 break;
359 }
361 - spin_lock_irq(&dev->xmit_lock);
362 + netif_tx_lock_bh(dev);
363 memcpy(dev->dev_addr, &addr, AX25_ADDR_LEN);
364 - spin_unlock_irq(&dev->xmit_lock);
365 + netif_tx_unlock_bh(dev);
367 err = 0;
368 break;
369 diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
370 index dc5e9d5..5c66f5a 100644
371 --- a/drivers/net/hamradio/mkiss.c
372 +++ b/drivers/net/hamradio/mkiss.c
373 @@ -357,9 +357,9 @@ static int ax_set_mac_address(struct net
374 {
375 struct sockaddr_ax25 *sa = addr;
377 - spin_lock_irq(&dev->xmit_lock);
378 + netif_tx_lock_bh(dev);
379 memcpy(dev->dev_addr, &sa->sax25_call, AX25_ADDR_LEN);
380 - spin_unlock_irq(&dev->xmit_lock);
381 + netif_tx_unlock_bh(dev);
383 return 0;
384 }
385 @@ -886,9 +886,9 @@ static int mkiss_ioctl(struct tty_struct
386 break;
387 }
389 - spin_lock_irq(&dev->xmit_lock);
390 + netif_tx_lock_bh(dev);
391 memcpy(dev->dev_addr, addr, AX25_ADDR_LEN);
392 - spin_unlock_irq(&dev->xmit_lock);
393 + netif_tx_unlock_bh(dev);
395 err = 0;
396 break;
397 diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
398 index 31fb2d7..2e222ef 100644
399 --- a/drivers/net/ifb.c
400 +++ b/drivers/net/ifb.c
401 @@ -76,13 +76,13 @@ static void ri_tasklet(unsigned long dev
402 dp->st_task_enter++;
403 if ((skb = skb_peek(&dp->tq)) == NULL) {
404 dp->st_txq_refl_try++;
405 - if (spin_trylock(&_dev->xmit_lock)) {
406 + if (netif_tx_trylock(_dev)) {
407 dp->st_rxq_enter++;
408 while ((skb = skb_dequeue(&dp->rq)) != NULL) {
409 skb_queue_tail(&dp->tq, skb);
410 dp->st_rx2tx_tran++;
411 }
412 - spin_unlock(&_dev->xmit_lock);
413 + netif_tx_unlock(_dev);
414 } else {
415 /* reschedule */
416 dp->st_rxq_notenter++;
417 @@ -110,7 +110,7 @@ static void ri_tasklet(unsigned long dev
418 }
419 }
421 - if (spin_trylock(&_dev->xmit_lock)) {
422 + if (netif_tx_trylock(_dev)) {
423 dp->st_rxq_check++;
424 if ((skb = skb_peek(&dp->rq)) == NULL) {
425 dp->tasklet_pending = 0;
426 @@ -118,10 +118,10 @@ static void ri_tasklet(unsigned long dev
427 netif_wake_queue(_dev);
428 } else {
429 dp->st_rxq_rsch++;
430 - spin_unlock(&_dev->xmit_lock);
431 + netif_tx_unlock(_dev);
432 goto resched;
433 }
434 - spin_unlock(&_dev->xmit_lock);
435 + netif_tx_unlock(_dev);
436 } else {
437 resched:
438 dp->tasklet_pending = 1;
439 diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
440 index a9f49f0..339d4a7 100644
441 --- a/drivers/net/irda/vlsi_ir.c
442 +++ b/drivers/net/irda/vlsi_ir.c
443 @@ -959,7 +959,7 @@ static int vlsi_hard_start_xmit(struct s
444 || (now.tv_sec==ready.tv_sec && now.tv_usec>=ready.tv_usec))
445 break;
446 udelay(100);
447 - /* must not sleep here - we are called under xmit_lock! */
448 + /* must not sleep here - called under netif_tx_lock! */
449 }
450 }
452 diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
453 index f9f77e4..bdab369 100644
454 --- a/drivers/net/ixgb/ixgb_main.c
455 +++ b/drivers/net/ixgb/ixgb_main.c
456 @@ -1163,7 +1163,7 @@ #ifdef NETIF_F_TSO
457 uint16_t ipcse, tucse, mss;
458 int err;
460 - if(likely(skb_shinfo(skb)->tso_size)) {
461 + if(likely(skb_shinfo(skb)->gso_size)) {
462 if (skb_header_cloned(skb)) {
463 err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
464 if (err)
465 @@ -1171,7 +1171,7 @@ #ifdef NETIF_F_TSO
466 }
468 hdr_len = ((skb->h.raw - skb->data) + (skb->h.th->doff << 2));
469 - mss = skb_shinfo(skb)->tso_size;
470 + mss = skb_shinfo(skb)->gso_size;
471 skb->nh.iph->tot_len = 0;
472 skb->nh.iph->check = 0;
473 skb->h.th->check = ~csum_tcpudp_magic(skb->nh.iph->saddr,
474 diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
475 index 690a1aa..9bcaa80 100644
476 --- a/drivers/net/loopback.c
477 +++ b/drivers/net/loopback.c
478 @@ -74,7 +74,7 @@ static void emulate_large_send_offload(s
479 struct iphdr *iph = skb->nh.iph;
480 struct tcphdr *th = (struct tcphdr*)(skb->nh.raw + (iph->ihl * 4));
481 unsigned int doffset = (iph->ihl + th->doff) * 4;
482 - unsigned int mtu = skb_shinfo(skb)->tso_size + doffset;
483 + unsigned int mtu = skb_shinfo(skb)->gso_size + doffset;
484 unsigned int offset = 0;
485 u32 seq = ntohl(th->seq);
486 u16 id = ntohs(iph->id);
487 @@ -139,7 +139,7 @@ #ifndef LOOPBACK_MUST_CHECKSUM
488 #endif
490 #ifdef LOOPBACK_TSO
491 - if (skb_shinfo(skb)->tso_size) {
492 + if (skb_shinfo(skb)->gso_size) {
493 BUG_ON(skb->protocol != htons(ETH_P_IP));
494 BUG_ON(skb->nh.iph->protocol != IPPROTO_TCP);
496 diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
497 index c0998ef..0fac9d5 100644
498 --- a/drivers/net/mv643xx_eth.c
499 +++ b/drivers/net/mv643xx_eth.c
500 @@ -1107,7 +1107,7 @@ static int mv643xx_eth_start_xmit(struct
502 #ifdef MV643XX_CHECKSUM_OFFLOAD_TX
503 if (has_tiny_unaligned_frags(skb)) {
504 - if ((skb_linearize(skb, GFP_ATOMIC) != 0)) {
505 + if (__skb_linearize(skb)) {
506 stats->tx_dropped++;
507 printk(KERN_DEBUG "%s: failed to linearize tiny "
508 "unaligned fragment\n", dev->name);
509 diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
510 index 9d6d254..c9ed624 100644
511 --- a/drivers/net/natsemi.c
512 +++ b/drivers/net/natsemi.c
513 @@ -323,12 +323,12 @@ performance critical codepaths:
514 The rx process only runs in the interrupt handler. Access from outside
515 the interrupt handler is only permitted after disable_irq().
517 -The rx process usually runs under the dev->xmit_lock. If np->intr_tx_reap
518 +The rx process usually runs under the netif_tx_lock. If np->intr_tx_reap
519 is set, then access is permitted under spin_lock_irq(&np->lock).
521 Thus configuration functions that want to access everything must call
522 disable_irq(dev->irq);
523 - spin_lock_bh(dev->xmit_lock);
524 + netif_tx_lock_bh(dev);
525 spin_lock_irq(&np->lock);
527 IV. Notes
528 diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
529 index 8cc0d0b..e53b313 100644
530 --- a/drivers/net/r8169.c
531 +++ b/drivers/net/r8169.c
532 @@ -2171,7 +2171,7 @@ static int rtl8169_xmit_frags(struct rtl
533 static inline u32 rtl8169_tso_csum(struct sk_buff *skb, struct net_device *dev)
534 {
535 if (dev->features & NETIF_F_TSO) {
536 - u32 mss = skb_shinfo(skb)->tso_size;
537 + u32 mss = skb_shinfo(skb)->gso_size;
539 if (mss)
540 return LargeSend | ((mss & MSSMask) << MSSShift);
541 diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
542 index b7f00d6..439f45f 100644
543 --- a/drivers/net/s2io.c
544 +++ b/drivers/net/s2io.c
545 @@ -3522,8 +3522,8 @@ #endif
546 txdp->Control_1 = 0;
547 txdp->Control_2 = 0;
548 #ifdef NETIF_F_TSO
549 - mss = skb_shinfo(skb)->tso_size;
550 - if (mss) {
551 + mss = skb_shinfo(skb)->gso_size;
552 + if (skb_shinfo(skb)->gso_type == SKB_GSO_TCPV4) {
553 txdp->Control_1 |= TXD_TCP_LSO_EN;
554 txdp->Control_1 |= TXD_TCP_LSO_MSS(mss);
555 }
556 @@ -3543,10 +3543,10 @@ #endif
557 }
559 frg_len = skb->len - skb->data_len;
560 - if (skb_shinfo(skb)->ufo_size) {
561 + if (skb_shinfo(skb)->gso_type == SKB_GSO_UDPV4) {
562 int ufo_size;
564 - ufo_size = skb_shinfo(skb)->ufo_size;
565 + ufo_size = skb_shinfo(skb)->gso_size;
566 ufo_size &= ~7;
567 txdp->Control_1 |= TXD_UFO_EN;
568 txdp->Control_1 |= TXD_UFO_MSS(ufo_size);
569 @@ -3572,7 +3572,7 @@ #endif
570 txdp->Host_Control = (unsigned long) skb;
571 txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len);
573 - if (skb_shinfo(skb)->ufo_size)
574 + if (skb_shinfo(skb)->gso_type == SKB_GSO_UDPV4)
575 txdp->Control_1 |= TXD_UFO_EN;
577 frg_cnt = skb_shinfo(skb)->nr_frags;
578 @@ -3587,12 +3587,12 @@ #endif
579 (sp->pdev, frag->page, frag->page_offset,
580 frag->size, PCI_DMA_TODEVICE);
581 txdp->Control_1 = TXD_BUFFER0_SIZE(frag->size);
582 - if (skb_shinfo(skb)->ufo_size)
583 + if (skb_shinfo(skb)->gso_type == SKB_GSO_UDPV4)
584 txdp->Control_1 |= TXD_UFO_EN;
585 }
586 txdp->Control_1 |= TXD_GATHER_CODE_LAST;
588 - if (skb_shinfo(skb)->ufo_size)
589 + if (skb_shinfo(skb)->gso_type == SKB_GSO_UDPV4)
590 frg_cnt++; /* as Txd0 was used for inband header */
592 tx_fifo = mac_control->tx_FIFO_start[queue];
593 @@ -3606,7 +3606,7 @@ #ifdef NETIF_F_TSO
594 if (mss)
595 val64 |= TX_FIFO_SPECIAL_FUNC;
596 #endif
597 - if (skb_shinfo(skb)->ufo_size)
598 + if (skb_shinfo(skb)->gso_type == SKB_GSO_UDPV4)
599 val64 |= TX_FIFO_SPECIAL_FUNC;
600 writeq(val64, &tx_fifo->List_Control);
602 diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
603 index 0618cd5..2a55eb3 100644
604 --- a/drivers/net/sky2.c
605 +++ b/drivers/net/sky2.c
606 @@ -1125,7 +1125,7 @@ static unsigned tx_le_req(const struct s
607 count = sizeof(dma_addr_t) / sizeof(u32);
608 count += skb_shinfo(skb)->nr_frags * count;
610 - if (skb_shinfo(skb)->tso_size)
611 + if (skb_shinfo(skb)->gso_size)
612 ++count;
614 if (skb->ip_summed == CHECKSUM_HW)
615 @@ -1197,7 +1197,7 @@ static int sky2_xmit_frame(struct sk_buf
616 }
618 /* Check for TCP Segmentation Offload */
619 - mss = skb_shinfo(skb)->tso_size;
620 + mss = skb_shinfo(skb)->gso_size;
621 if (mss != 0) {
622 /* just drop the packet if non-linear expansion fails */
623 if (skb_header_cloned(skb) &&
624 diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
625 index caf4102..fc9164a 100644
626 --- a/drivers/net/tg3.c
627 +++ b/drivers/net/tg3.c
628 @@ -3664,7 +3664,7 @@ static int tg3_start_xmit(struct sk_buff
629 #if TG3_TSO_SUPPORT != 0
630 mss = 0;
631 if (skb->len > (tp->dev->mtu + ETH_HLEN) &&
632 - (mss = skb_shinfo(skb)->tso_size) != 0) {
633 + (mss = skb_shinfo(skb)->gso_size) != 0) {
634 int tcp_opt_len, ip_tcp_len;
636 if (skb_header_cloned(skb) &&
637 diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
638 index 5b1af39..11de5af 100644
639 --- a/drivers/net/tulip/winbond-840.c
640 +++ b/drivers/net/tulip/winbond-840.c
641 @@ -1605,11 +1605,11 @@ #ifdef CONFIG_PM
642 * - get_stats:
643 * spin_lock_irq(np->lock), doesn't touch hw if not present
644 * - hard_start_xmit:
645 - * netif_stop_queue + spin_unlock_wait(&dev->xmit_lock);
646 + * synchronize_irq + netif_tx_disable;
647 * - tx_timeout:
648 - * netif_device_detach + spin_unlock_wait(&dev->xmit_lock);
649 + * netif_device_detach + netif_tx_disable;
650 * - set_multicast_list
651 - * netif_device_detach + spin_unlock_wait(&dev->xmit_lock);
652 + * netif_device_detach + netif_tx_disable;
653 * - interrupt handler
654 * doesn't touch hw if not present, synchronize_irq waits for
655 * running instances of the interrupt handler.
656 @@ -1635,11 +1635,10 @@ static int w840_suspend (struct pci_dev
657 netif_device_detach(dev);
658 update_csr6(dev, 0);
659 iowrite32(0, ioaddr + IntrEnable);
660 - netif_stop_queue(dev);
661 spin_unlock_irq(&np->lock);
663 - spin_unlock_wait(&dev->xmit_lock);
664 synchronize_irq(dev->irq);
665 + netif_tx_disable(dev);
667 np->stats.rx_missed_errors += ioread32(ioaddr + RxMissed) & 0xffff;
669 diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c
670 index 4c76cb7..30c48c9 100644
671 --- a/drivers/net/typhoon.c
672 +++ b/drivers/net/typhoon.c
673 @@ -340,7 +340,7 @@ #define typhoon_synchronize_irq(x) synch
674 #endif
676 #if defined(NETIF_F_TSO)
677 -#define skb_tso_size(x) (skb_shinfo(x)->tso_size)
678 +#define skb_tso_size(x) (skb_shinfo(x)->gso_size)
679 #define TSO_NUM_DESCRIPTORS 2
680 #define TSO_OFFLOAD_ON TYPHOON_OFFLOAD_TCP_SEGMENT
681 #else
682 diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
683 index ed1f837..2eb6b5f 100644
684 --- a/drivers/net/via-velocity.c
685 +++ b/drivers/net/via-velocity.c
686 @@ -1899,6 +1899,13 @@ static int velocity_xmit(struct sk_buff
688 int pktlen = skb->len;
690 +#ifdef VELOCITY_ZERO_COPY_SUPPORT
691 + if (skb_shinfo(skb)->nr_frags > 6 && __skb_linearize(skb)) {
692 + kfree_skb(skb);
693 + return 0;
694 + }
695 +#endif
696 +
697 spin_lock_irqsave(&vptr->lock, flags);
699 index = vptr->td_curr[qnum];
700 @@ -1914,8 +1921,6 @@ static int velocity_xmit(struct sk_buff
701 */
702 if (pktlen < ETH_ZLEN) {
703 /* Cannot occur until ZC support */
704 - if(skb_linearize(skb, GFP_ATOMIC))
705 - return 0;
706 pktlen = ETH_ZLEN;
707 memcpy(tdinfo->buf, skb->data, skb->len);
708 memset(tdinfo->buf + skb->len, 0, ETH_ZLEN - skb->len);
709 @@ -1933,7 +1938,6 @@ #ifdef VELOCITY_ZERO_COPY_SUPPORT
710 int nfrags = skb_shinfo(skb)->nr_frags;
711 tdinfo->skb = skb;
712 if (nfrags > 6) {
713 - skb_linearize(skb, GFP_ATOMIC);
714 memcpy(tdinfo->buf, skb->data, skb->len);
715 tdinfo->skb_dma[0] = tdinfo->buf_dma;
716 td_ptr->tdesc0.pktsize =
717 diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
718 index 6fd0bf7..75237c1 100644
719 --- a/drivers/net/wireless/orinoco.c
720 +++ b/drivers/net/wireless/orinoco.c
721 @@ -1835,7 +1835,9 @@ static int __orinoco_program_rids(struct
722 /* Set promiscuity / multicast*/
723 priv->promiscuous = 0;
724 priv->mc_count = 0;
725 - __orinoco_set_multicast_list(dev); /* FIXME: what about the xmit_lock */
726 +
727 + /* FIXME: what about netif_tx_lock */
728 + __orinoco_set_multicast_list(dev);
730 return 0;
731 }
732 diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
733 index 82cb4af..57cec40 100644
734 --- a/drivers/s390/net/qeth_eddp.c
735 +++ b/drivers/s390/net/qeth_eddp.c
736 @@ -421,7 +421,7 @@ #endif /* CONFIG_QETH_VLAN */
737 }
738 tcph = eddp->skb->h.th;
739 while (eddp->skb_offset < eddp->skb->len) {
740 - data_len = min((int)skb_shinfo(eddp->skb)->tso_size,
741 + data_len = min((int)skb_shinfo(eddp->skb)->gso_size,
742 (int)(eddp->skb->len - eddp->skb_offset));
743 /* prepare qdio hdr */
744 if (eddp->qh.hdr.l2.id == QETH_HEADER_TYPE_LAYER2){
745 @@ -516,20 +516,20 @@ qeth_eddp_calc_num_pages(struct qeth_edd
747 QETH_DBF_TEXT(trace, 5, "eddpcanp");
748 /* can we put multiple skbs in one page? */
749 - skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->tso_size + hdr_len);
750 + skbs_per_page = PAGE_SIZE / (skb_shinfo(skb)->gso_size + hdr_len);
751 if (skbs_per_page > 1){
752 - ctx->num_pages = (skb_shinfo(skb)->tso_segs + 1) /
753 + ctx->num_pages = (skb_shinfo(skb)->gso_segs + 1) /
754 skbs_per_page + 1;
755 ctx->elements_per_skb = 1;
756 } else {
757 /* no -> how many elements per skb? */
758 - ctx->elements_per_skb = (skb_shinfo(skb)->tso_size + hdr_len +
759 + ctx->elements_per_skb = (skb_shinfo(skb)->gso_size + hdr_len +
760 PAGE_SIZE) >> PAGE_SHIFT;
761 ctx->num_pages = ctx->elements_per_skb *
762 - (skb_shinfo(skb)->tso_segs + 1);
763 + (skb_shinfo(skb)->gso_segs + 1);
764 }
765 ctx->num_elements = ctx->elements_per_skb *
766 - (skb_shinfo(skb)->tso_segs + 1);
767 + (skb_shinfo(skb)->gso_segs + 1);
768 }
770 static inline struct qeth_eddp_context *
771 diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
772 index dba7f7f..d9cc997 100644
773 --- a/drivers/s390/net/qeth_main.c
774 +++ b/drivers/s390/net/qeth_main.c
775 @@ -4454,7 +4454,7 @@ qeth_send_packet(struct qeth_card *card,
776 queue = card->qdio.out_qs
777 [qeth_get_priority_queue(card, skb, ipv, cast_type)];
779 - if (skb_shinfo(skb)->tso_size)
780 + if (skb_shinfo(skb)->gso_size)
781 large_send = card->options.large_send;
783 /*are we able to do TSO ? If so ,prepare and send it from here */
784 @@ -4501,7 +4501,7 @@ qeth_send_packet(struct qeth_card *card,
785 card->stats.tx_packets++;
786 card->stats.tx_bytes += skb->len;
787 #ifdef CONFIG_QETH_PERF_STATS
788 - if (skb_shinfo(skb)->tso_size &&
789 + if (skb_shinfo(skb)->gso_size &&
790 !(large_send == QETH_LARGE_SEND_NO)) {
791 card->perf_stats.large_send_bytes += skb->len;
792 card->perf_stats.large_send_cnt++;
793 diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h
794 index 1286dde..89cbf34 100644
795 --- a/drivers/s390/net/qeth_tso.h
796 +++ b/drivers/s390/net/qeth_tso.h
797 @@ -51,7 +51,7 @@ qeth_tso_fill_header(struct qeth_card *c
798 hdr->ext.hdr_version = 1;
799 hdr->ext.hdr_len = 28;
800 /*insert non-fix values */
801 - hdr->ext.mss = skb_shinfo(skb)->tso_size;
802 + hdr->ext.mss = skb_shinfo(skb)->gso_size;
803 hdr->ext.dg_hdr_len = (__u16)(iph->ihl*4 + tcph->doff*4);
804 hdr->ext.payload_len = (__u16)(skb->len - hdr->ext.dg_hdr_len -
805 sizeof(struct qeth_hdr_tso));
806 diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
807 index 93535f0..9269df7 100644
808 --- a/include/linux/ethtool.h
809 +++ b/include/linux/ethtool.h
810 @@ -408,6 +408,8 @@ #define ETHTOOL_STSO 0x0000001f /* Set
811 #define ETHTOOL_GPERMADDR 0x00000020 /* Get permanent hardware address */
812 #define ETHTOOL_GUFO 0x00000021 /* Get UFO enable (ethtool_value) */
813 #define ETHTOOL_SUFO 0x00000022 /* Set UFO enable (ethtool_value) */
814 +#define ETHTOOL_GGSO 0x00000023 /* Get GSO enable (ethtool_value) */
815 +#define ETHTOOL_SGSO 0x00000024 /* Set GSO enable (ethtool_value) */
817 /* compatibility with older code */
818 #define SPARC_ETH_GSET ETHTOOL_GSET
819 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
820 index 7fda03d..47b0965 100644
821 --- a/include/linux/netdevice.h
822 +++ b/include/linux/netdevice.h
823 @@ -230,7 +230,8 @@ enum netdev_state_t
824 __LINK_STATE_SCHED,
825 __LINK_STATE_NOCARRIER,
826 __LINK_STATE_RX_SCHED,
827 - __LINK_STATE_LINKWATCH_PENDING
828 + __LINK_STATE_LINKWATCH_PENDING,
829 + __LINK_STATE_QDISC_RUNNING,
830 };
833 @@ -306,9 +307,17 @@ #define NETIF_F_HW_VLAN_TX 128 /* Transm
834 #define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
835 #define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
836 #define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
837 -#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
838 +#define NETIF_F_GSO 2048 /* Enable software GSO. */
839 #define NETIF_F_LLTX 4096 /* LockLess TX */
840 -#define NETIF_F_UFO 8192 /* Can offload UDP Large Send*/
841 +
842 + /* Segmentation offload features */
843 +#define NETIF_F_GSO_SHIFT 16
844 +#define NETIF_F_TSO (SKB_GSO_TCPV4 << NETIF_F_GSO_SHIFT)
845 +#define NETIF_F_UFO (SKB_GSO_UDPV4 << NETIF_F_GSO_SHIFT)
846 +#define NETIF_F_GSO_ROBUST (SKB_GSO_DODGY << NETIF_F_GSO_SHIFT)
847 +
848 +#define NETIF_F_GEN_CSUM (NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
849 +#define NETIF_F_ALL_CSUM (NETIF_F_IP_CSUM | NETIF_F_GEN_CSUM)
851 struct net_device *next_sched;
853 @@ -394,6 +403,9 @@ #define NETIF_F_UFO 8192
854 struct list_head qdisc_list;
855 unsigned long tx_queue_len; /* Max frames per queue allowed */
857 + /* Partially transmitted GSO packet. */
858 + struct sk_buff *gso_skb;
859 +
860 /* ingress path synchronizer */
861 spinlock_t ingress_lock;
862 struct Qdisc *qdisc_ingress;
863 @@ -402,7 +414,7 @@ #define NETIF_F_UFO 8192
864 * One part is mostly used on xmit path (device)
865 */
866 /* hard_start_xmit synchronizer */
867 - spinlock_t xmit_lock ____cacheline_aligned_in_smp;
868 + spinlock_t _xmit_lock ____cacheline_aligned_in_smp;
869 /* cpu id of processor entered to hard_start_xmit or -1,
870 if nobody entered there.
871 */
872 @@ -527,6 +539,8 @@ struct packet_type {
873 struct net_device *,
874 struct packet_type *,
875 struct net_device *);
876 + struct sk_buff *(*gso_segment)(struct sk_buff *skb,
877 + int features);
878 void *af_packet_priv;
879 struct list_head list;
880 };
881 @@ -693,7 +707,8 @@ extern int dev_change_name(struct net_d
882 extern int dev_set_mtu(struct net_device *, int);
883 extern int dev_set_mac_address(struct net_device *,
884 struct sockaddr *);
885 -extern void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev);
886 +extern int dev_hard_start_xmit(struct sk_buff *skb,
887 + struct net_device *dev);
889 extern void dev_init(void);
891 @@ -900,11 +915,43 @@ static inline void __netif_rx_complete(s
892 clear_bit(__LINK_STATE_RX_SCHED, &dev->state);
893 }
895 +static inline void netif_tx_lock(struct net_device *dev)
896 +{
897 + spin_lock(&dev->_xmit_lock);
898 + dev->xmit_lock_owner = smp_processor_id();
899 +}
900 +
901 +static inline void netif_tx_lock_bh(struct net_device *dev)
902 +{
903 + spin_lock_bh(&dev->_xmit_lock);
904 + dev->xmit_lock_owner = smp_processor_id();
905 +}
906 +
907 +static inline int netif_tx_trylock(struct net_device *dev)
908 +{
909 + int err = spin_trylock(&dev->_xmit_lock);
910 + if (!err)
911 + dev->xmit_lock_owner = smp_processor_id();
912 + return err;
913 +}
914 +
915 +static inline void netif_tx_unlock(struct net_device *dev)
916 +{
917 + dev->xmit_lock_owner = -1;
918 + spin_unlock(&dev->_xmit_lock);
919 +}
920 +
921 +static inline void netif_tx_unlock_bh(struct net_device *dev)
922 +{
923 + dev->xmit_lock_owner = -1;
924 + spin_unlock_bh(&dev->_xmit_lock);
925 +}
926 +
927 static inline void netif_tx_disable(struct net_device *dev)
928 {
929 - spin_lock_bh(&dev->xmit_lock);
930 + netif_tx_lock_bh(dev);
931 netif_stop_queue(dev);
932 - spin_unlock_bh(&dev->xmit_lock);
933 + netif_tx_unlock_bh(dev);
934 }
936 /* These functions live elsewhere (drivers/net/net_init.c, but related) */
937 @@ -932,6 +979,7 @@ extern int netdev_max_backlog;
938 extern int weight_p;
939 extern int netdev_set_master(struct net_device *dev, struct net_device *master);
940 extern int skb_checksum_help(struct sk_buff *skb, int inward);
941 +extern struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features);
942 #ifdef CONFIG_BUG
943 extern void netdev_rx_csum_fault(struct net_device *dev);
944 #else
945 @@ -951,6 +999,18 @@ #endif
947 extern void linkwatch_run_queue(void);
949 +static inline int skb_gso_ok(struct sk_buff *skb, int features)
950 +{
951 + int feature = skb_shinfo(skb)->gso_size ?
952 + skb_shinfo(skb)->gso_type << NETIF_F_GSO_SHIFT : 0;
953 + return (features & feature) == feature;
954 +}
955 +
956 +static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
957 +{
958 + return !skb_gso_ok(skb, dev->features);
959 +}
960 +
961 #endif /* __KERNEL__ */
963 #endif /* _LINUX_DEV_H */
964 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
965 index ad7cc22..b19d45d 100644
966 --- a/include/linux/skbuff.h
967 +++ b/include/linux/skbuff.h
968 @@ -134,9 +134,10 @@ struct skb_frag_struct {
969 struct skb_shared_info {
970 atomic_t dataref;
971 unsigned short nr_frags;
972 - unsigned short tso_size;
973 - unsigned short tso_segs;
974 - unsigned short ufo_size;
975 + unsigned short gso_size;
976 + /* Warning: this field is not always filled in (UFO)! */
977 + unsigned short gso_segs;
978 + unsigned short gso_type;
979 unsigned int ip6_frag_id;
980 struct sk_buff *frag_list;
981 skb_frag_t frags[MAX_SKB_FRAGS];
982 @@ -168,6 +169,14 @@ enum {
983 SKB_FCLONE_CLONE,
984 };
986 +enum {
987 + SKB_GSO_TCPV4 = 1 << 0,
988 + SKB_GSO_UDPV4 = 1 << 1,
989 +
990 + /* This indicates the skb is from an untrusted source. */
991 + SKB_GSO_DODGY = 1 << 2,
992 +};
993 +
994 /**
995 * struct sk_buff - socket buffer
996 * @next: Next buffer in list
997 @@ -1148,18 +1157,34 @@ static inline int skb_can_coalesce(struc
998 return 0;
999 }
1001 +static inline int __skb_linearize(struct sk_buff *skb)
1002 +{
1003 + return __pskb_pull_tail(skb, skb->data_len) ? 0 : -ENOMEM;
1004 +}
1006 /**
1007 * skb_linearize - convert paged skb to linear one
1008 * @skb: buffer to linarize
1009 - * @gfp: allocation mode
1011 * If there is no free memory -ENOMEM is returned, otherwise zero
1012 * is returned and the old skb data released.
1013 */
1014 -extern int __skb_linearize(struct sk_buff *skb, gfp_t gfp);
1015 -static inline int skb_linearize(struct sk_buff *skb, gfp_t gfp)
1016 +static inline int skb_linearize(struct sk_buff *skb)
1017 +{
1018 + return skb_is_nonlinear(skb) ? __skb_linearize(skb) : 0;
1019 +}
1021 +/**
1022 + * skb_linearize_cow - make sure skb is linear and writable
1023 + * @skb: buffer to process
1024 + *
1025 + * If there is no free memory -ENOMEM is returned, otherwise zero
1026 + * is returned and the old skb data released.
1027 + */
1028 +static inline int skb_linearize_cow(struct sk_buff *skb)
1030 - return __skb_linearize(skb, gfp);
1031 + return skb_is_nonlinear(skb) || skb_cloned(skb) ?
1032 + __skb_linearize(skb) : 0;
1035 /**
1036 @@ -1254,6 +1279,7 @@ extern void skb_split(struct sk_b
1037 struct sk_buff *skb1, const u32 len);
1039 extern void skb_release_data(struct sk_buff *skb);
1040 +extern struct sk_buff *skb_segment(struct sk_buff *skb, int features);
1042 static inline void *skb_header_pointer(const struct sk_buff *skb, int offset,
1043 int len, void *buffer)
1044 diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
1045 index b94d1ad..75b5b93 100644
1046 --- a/include/net/pkt_sched.h
1047 +++ b/include/net/pkt_sched.h
1048 @@ -218,12 +218,13 @@ extern struct qdisc_rate_table *qdisc_ge
1049 struct rtattr *tab);
1050 extern void qdisc_put_rtab(struct qdisc_rate_table *tab);
1052 -extern int qdisc_restart(struct net_device *dev);
1053 +extern void __qdisc_run(struct net_device *dev);
1055 static inline void qdisc_run(struct net_device *dev)
1057 - while (!netif_queue_stopped(dev) && qdisc_restart(dev) < 0)
1058 - /* NOTHING */;
1059 + if (!netif_queue_stopped(dev) &&
1060 + !test_and_set_bit(__LINK_STATE_QDISC_RUNNING, &dev->state))
1061 + __qdisc_run(dev);
1064 extern int tc_classify(struct sk_buff *skb, struct tcf_proto *tp,
1065 diff --git a/include/net/protocol.h b/include/net/protocol.h
1066 index 6dc5970..0d2dcdb 100644
1067 --- a/include/net/protocol.h
1068 +++ b/include/net/protocol.h
1069 @@ -37,6 +37,8 @@ #define MAX_INET_PROTOS 256 /* Must be
1070 struct net_protocol {
1071 int (*handler)(struct sk_buff *skb);
1072 void (*err_handler)(struct sk_buff *skb, u32 info);
1073 + struct sk_buff *(*gso_segment)(struct sk_buff *skb,
1074 + int features);
1075 int no_policy;
1076 };
1078 diff --git a/include/net/sock.h b/include/net/sock.h
1079 index f63d0d5..a8e8d21 100644
1080 --- a/include/net/sock.h
1081 +++ b/include/net/sock.h
1082 @@ -1064,9 +1064,13 @@ static inline void sk_setup_caps(struct
1084 __sk_dst_set(sk, dst);
1085 sk->sk_route_caps = dst->dev->features;
1086 + if (sk->sk_route_caps & NETIF_F_GSO)
1087 + sk->sk_route_caps |= NETIF_F_TSO;
1088 if (sk->sk_route_caps & NETIF_F_TSO) {
1089 if (sock_flag(sk, SOCK_NO_LARGESEND) || dst->header_len)
1090 sk->sk_route_caps &= ~NETIF_F_TSO;
1091 + else
1092 + sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM;
1096 diff --git a/include/net/tcp.h b/include/net/tcp.h
1097 index 77f21c6..70e1d5f 100644
1098 --- a/include/net/tcp.h
1099 +++ b/include/net/tcp.h
1100 @@ -552,13 +552,13 @@ #include <net/tcp_ecn.h>
1101 */
1102 static inline int tcp_skb_pcount(const struct sk_buff *skb)
1104 - return skb_shinfo(skb)->tso_segs;
1105 + return skb_shinfo(skb)->gso_segs;
1108 /* This is valid iff tcp_skb_pcount() > 1. */
1109 static inline int tcp_skb_mss(const struct sk_buff *skb)
1111 - return skb_shinfo(skb)->tso_size;
1112 + return skb_shinfo(skb)->gso_size;
1115 static inline void tcp_dec_pcount_approx(__u32 *count,
1116 @@ -1063,6 +1063,8 @@ extern struct request_sock_ops tcp_reque
1118 extern int tcp_v4_destroy_sock(struct sock *sk);
1120 +extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features);
1122 #ifdef CONFIG_PROC_FS
1123 extern int tcp4_proc_init(void);
1124 extern void tcp4_proc_exit(void);
1125 diff --git a/net/atm/clip.c b/net/atm/clip.c
1126 index 1842a4e..6dc21a7 100644
1127 --- a/net/atm/clip.c
1128 +++ b/net/atm/clip.c
1129 @@ -101,7 +101,7 @@ static void unlink_clip_vcc(struct clip_
1130 printk(KERN_CRIT "!clip_vcc->entry (clip_vcc %p)\n",clip_vcc);
1131 return;
1133 - spin_lock_bh(&entry->neigh->dev->xmit_lock); /* block clip_start_xmit() */
1134 + netif_tx_lock_bh(entry->neigh->dev); /* block clip_start_xmit() */
1135 entry->neigh->used = jiffies;
1136 for (walk = &entry->vccs; *walk; walk = &(*walk)->next)
1137 if (*walk == clip_vcc) {
1138 @@ -125,7 +125,7 @@ static void unlink_clip_vcc(struct clip_
1139 printk(KERN_CRIT "ATMARP: unlink_clip_vcc failed (entry %p, vcc "
1140 "0x%p)\n",entry,clip_vcc);
1141 out:
1142 - spin_unlock_bh(&entry->neigh->dev->xmit_lock);
1143 + netif_tx_unlock_bh(entry->neigh->dev);
1146 /* The neighbour entry n->lock is held. */
1147 diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
1148 index 0b33a7b..180e79b 100644
1149 --- a/net/bridge/br_device.c
1150 +++ b/net/bridge/br_device.c
1151 @@ -146,9 +146,9 @@ static int br_set_tx_csum(struct net_dev
1152 struct net_bridge *br = netdev_priv(dev);
1154 if (data)
1155 - br->feature_mask |= NETIF_F_IP_CSUM;
1156 + br->feature_mask |= NETIF_F_NO_CSUM;
1157 else
1158 - br->feature_mask &= ~NETIF_F_IP_CSUM;
1159 + br->feature_mask &= ~NETIF_F_ALL_CSUM;
1161 br_features_recompute(br);
1162 return 0;
1163 @@ -185,6 +185,6 @@ void br_dev_setup(struct net_device *dev
1164 dev->set_mac_address = br_set_mac_address;
1165 dev->priv_flags = IFF_EBRIDGE;
1167 - dev->features = NETIF_F_SG | NETIF_F_FRAGLIST
1168 - | NETIF_F_HIGHDMA | NETIF_F_TSO | NETIF_F_IP_CSUM;
1169 + dev->features = NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA |
1170 + NETIF_F_TSO | NETIF_F_NO_CSUM | NETIF_F_GSO_ROBUST;
1172 diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
1173 index 2d24fb4..00b1128 100644
1174 --- a/net/bridge/br_forward.c
1175 +++ b/net/bridge/br_forward.c
1176 @@ -32,7 +32,7 @@ static inline int should_deliver(const s
1177 int br_dev_queue_push_xmit(struct sk_buff *skb)
1179 /* drop mtu oversized packets except tso */
1180 - if (skb->len > skb->dev->mtu && !skb_shinfo(skb)->tso_size)
1181 + if (skb->len > skb->dev->mtu && !skb_shinfo(skb)->gso_size)
1182 kfree_skb(skb);
1183 else {
1184 #ifdef CONFIG_BRIDGE_NETFILTER
1185 diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
1186 index f36b35e..0617146 100644
1187 --- a/net/bridge/br_if.c
1188 +++ b/net/bridge/br_if.c
1189 @@ -385,17 +385,28 @@ void br_features_recompute(struct net_br
1190 struct net_bridge_port *p;
1191 unsigned long features, checksum;
1193 - features = br->feature_mask &~ NETIF_F_IP_CSUM;
1194 - checksum = br->feature_mask & NETIF_F_IP_CSUM;
1195 + checksum = br->feature_mask & NETIF_F_ALL_CSUM ? NETIF_F_NO_CSUM : 0;
1196 + features = br->feature_mask & ~NETIF_F_ALL_CSUM;
1198 list_for_each_entry(p, &br->port_list, list) {
1199 - if (!(p->dev->features
1200 - & (NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM)))
1201 + unsigned long feature = p->dev->features;
1203 + if (checksum & NETIF_F_NO_CSUM && !(feature & NETIF_F_NO_CSUM))
1204 + checksum ^= NETIF_F_NO_CSUM | NETIF_F_HW_CSUM;
1205 + if (checksum & NETIF_F_HW_CSUM && !(feature & NETIF_F_HW_CSUM))
1206 + checksum ^= NETIF_F_HW_CSUM | NETIF_F_IP_CSUM;
1207 + if (!(feature & NETIF_F_IP_CSUM))
1208 checksum = 0;
1209 - features &= p->dev->features;
1211 + if (feature & NETIF_F_GSO)
1212 + feature |= NETIF_F_TSO;
1213 + feature |= NETIF_F_GSO;
1215 + features &= feature;
1218 - br->dev->features = features | checksum | NETIF_F_LLTX;
1219 + br->dev->features = features | checksum | NETIF_F_LLTX |
1220 + NETIF_F_GSO_ROBUST;
1223 /* called with RTNL */
1224 diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
1225 index 9e27373..588207f 100644
1226 --- a/net/bridge/br_netfilter.c
1227 +++ b/net/bridge/br_netfilter.c
1228 @@ -743,7 +743,7 @@ static int br_nf_dev_queue_xmit(struct s
1230 if (skb->protocol == htons(ETH_P_IP) &&
1231 skb->len > skb->dev->mtu &&
1232 - !(skb_shinfo(skb)->ufo_size || skb_shinfo(skb)->tso_size))
1233 + !skb_shinfo(skb)->gso_size)
1234 return ip_fragment(skb, br_dev_queue_push_xmit);
1235 else
1236 return br_dev_queue_push_xmit(skb);
1237 diff --git a/net/core/dev.c b/net/core/dev.c
1238 index 12a214c..32e1056 100644
1239 --- a/net/core/dev.c
1240 +++ b/net/core/dev.c
1241 @@ -115,6 +115,7 @@ #include <linux/wireless.h> /* Note : w
1242 #include <net/iw_handler.h>
1243 #endif /* CONFIG_NET_RADIO */
1244 #include <asm/current.h>
1245 +#include <linux/err.h>
1247 /*
1248 * The list of packet types we will receive (as opposed to discard)
1249 @@ -1032,7 +1033,7 @@ static inline void net_timestamp(struct
1250 * taps currently in use.
1251 */
1253 -void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
1254 +static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
1256 struct packet_type *ptype;
1258 @@ -1106,6 +1107,45 @@ out:
1259 return ret;
1262 +/**
1263 + * skb_gso_segment - Perform segmentation on skb.
1264 + * @skb: buffer to segment
1265 + * @features: features for the output path (see dev->features)
1266 + *
1267 + * This function segments the given skb and returns a list of segments.
1268 + *
1269 + * It may return NULL if the skb requires no segmentation. This is
1270 + * only possible when GSO is used for verifying header integrity.
1271 + */
1272 +struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
1273 +{
1274 + struct sk_buff *segs = ERR_PTR(-EPROTONOSUPPORT);
1275 + struct packet_type *ptype;
1276 + int type = skb->protocol;
1278 + BUG_ON(skb_shinfo(skb)->frag_list);
1279 + BUG_ON(skb->ip_summed != CHECKSUM_HW);
1281 + skb->mac.raw = skb->data;
1282 + skb->mac_len = skb->nh.raw - skb->data;
1283 + __skb_pull(skb, skb->mac_len);
1285 + rcu_read_lock();
1286 + list_for_each_entry_rcu(ptype, &ptype_base[ntohs(type) & 15], list) {
1287 + if (ptype->type == type && !ptype->dev && ptype->gso_segment) {
1288 + segs = ptype->gso_segment(skb, features);
1289 + break;
1290 + }
1291 + }
1292 + rcu_read_unlock();
1294 + __skb_push(skb, skb->data - skb->mac.raw);
1296 + return segs;
1297 +}
1299 +EXPORT_SYMBOL(skb_gso_segment);
1301 /* Take action when hardware reception checksum errors are detected. */
1302 #ifdef CONFIG_BUG
1303 void netdev_rx_csum_fault(struct net_device *dev)
1304 @@ -1142,75 +1182,108 @@ #else
1305 #define illegal_highdma(dev, skb) (0)
1306 #endif
1308 -/* Keep head the same: replace data */
1309 -int __skb_linearize(struct sk_buff *skb, gfp_t gfp_mask)
1310 -{
1311 - unsigned int size;
1312 - u8 *data;
1313 - long offset;
1314 - struct skb_shared_info *ninfo;
1315 - int headerlen = skb->data - skb->head;
1316 - int expand = (skb->tail + skb->data_len) - skb->end;
1318 - if (skb_shared(skb))
1319 - BUG();
1321 - if (expand <= 0)
1322 - expand = 0;
1324 - size = skb->end - skb->head + expand;
1325 - size = SKB_DATA_ALIGN(size);
1326 - data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
1327 - if (!data)
1328 - return -ENOMEM;
1330 - /* Copy entire thing */
1331 - if (skb_copy_bits(skb, -headerlen, data, headerlen + skb->len))
1332 - BUG();
1334 - /* Set up shinfo */
1335 - ninfo = (struct skb_shared_info*)(data + size);
1336 - atomic_set(&ninfo->dataref, 1);
1337 - ninfo->tso_size = skb_shinfo(skb)->tso_size;
1338 - ninfo->tso_segs = skb_shinfo(skb)->tso_segs;
1339 - ninfo->nr_frags = 0;
1340 - ninfo->frag_list = NULL;
1342 - /* Offset between the two in bytes */
1343 - offset = data - skb->head;
1345 - /* Free old data. */
1346 - skb_release_data(skb);
1348 - skb->head = data;
1349 - skb->end = data + size;
1351 - /* Set up new pointers */
1352 - skb->h.raw += offset;
1353 - skb->nh.raw += offset;
1354 - skb->mac.raw += offset;
1355 - skb->tail += offset;
1356 - skb->data += offset;
1358 - /* We are no longer a clone, even if we were. */
1359 - skb->cloned = 0;
1361 - skb->tail += skb->data_len;
1362 - skb->data_len = 0;
1363 +struct dev_gso_cb {
1364 + void (*destructor)(struct sk_buff *skb);
1365 +};
1367 +#define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
1369 +static void dev_gso_skb_destructor(struct sk_buff *skb)
1370 +{
1371 + struct dev_gso_cb *cb;
1373 + do {
1374 + struct sk_buff *nskb = skb->next;
1376 + skb->next = nskb->next;
1377 + nskb->next = NULL;
1378 + kfree_skb(nskb);
1379 + } while (skb->next);
1381 + cb = DEV_GSO_CB(skb);
1382 + if (cb->destructor)
1383 + cb->destructor(skb);
1384 +}
1386 +/**
1387 + * dev_gso_segment - Perform emulated hardware segmentation on skb.
1388 + * @skb: buffer to segment
1389 + *
1390 + * This function segments the given skb and stores the list of segments
1391 + * in skb->next.
1392 + */
1393 +static int dev_gso_segment(struct sk_buff *skb)
1394 +{
1395 + struct net_device *dev = skb->dev;
1396 + struct sk_buff *segs;
1397 + int features = dev->features & ~(illegal_highdma(dev, skb) ?
1398 + NETIF_F_SG : 0);
1400 + segs = skb_gso_segment(skb, features);
1402 + /* Verifying header integrity only. */
1403 + if (!segs)
1404 + return 0;
1406 + if (unlikely(IS_ERR(segs)))
1407 + return PTR_ERR(segs);
1409 + skb->next = segs;
1410 + DEV_GSO_CB(skb)->destructor = skb->destructor;
1411 + skb->destructor = dev_gso_skb_destructor;
1413 + return 0;
1414 +}
1416 +int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
1417 +{
1418 + if (likely(!skb->next)) {
1419 + if (netdev_nit)
1420 + dev_queue_xmit_nit(skb, dev);
1422 + if (netif_needs_gso(dev, skb)) {
1423 + if (unlikely(dev_gso_segment(skb)))
1424 + goto out_kfree_skb;
1425 + if (skb->next)
1426 + goto gso;
1427 + }
1429 + return dev->hard_start_xmit(skb, dev);
1430 + }
1432 +gso:
1433 + do {
1434 + struct sk_buff *nskb = skb->next;
1435 + int rc;
1437 + skb->next = nskb->next;
1438 + nskb->next = NULL;
1439 + rc = dev->hard_start_xmit(nskb, dev);
1440 + if (unlikely(rc)) {
1441 + nskb->next = skb->next;
1442 + skb->next = nskb;
1443 + return rc;
1444 + }
1445 + if (unlikely(netif_queue_stopped(dev) && skb->next))
1446 + return NETDEV_TX_BUSY;
1447 + } while (skb->next);
1449 + skb->destructor = DEV_GSO_CB(skb)->destructor;
1451 +out_kfree_skb:
1452 + kfree_skb(skb);
1453 return 0;
1456 #define HARD_TX_LOCK(dev, cpu) { \
1457 if ((dev->features & NETIF_F_LLTX) == 0) { \
1458 - spin_lock(&dev->xmit_lock); \
1459 - dev->xmit_lock_owner = cpu; \
1460 + netif_tx_lock(dev); \
1461 } \
1464 #define HARD_TX_UNLOCK(dev) { \
1465 if ((dev->features & NETIF_F_LLTX) == 0) { \
1466 - dev->xmit_lock_owner = -1; \
1467 - spin_unlock(&dev->xmit_lock); \
1468 + netif_tx_unlock(dev); \
1469 } \
1472 @@ -1246,9 +1319,13 @@ int dev_queue_xmit(struct sk_buff *skb)
1473 struct Qdisc *q;
1474 int rc = -ENOMEM;
1476 + /* GSO will handle the following emulations directly. */
1477 + if (netif_needs_gso(dev, skb))
1478 + goto gso;
1480 if (skb_shinfo(skb)->frag_list &&
1481 !(dev->features & NETIF_F_FRAGLIST) &&
1482 - __skb_linearize(skb, GFP_ATOMIC))
1483 + __skb_linearize(skb))
1484 goto out_kfree_skb;
1486 /* Fragmented skb is linearized if device does not support SG,
1487 @@ -1257,25 +1334,26 @@ int dev_queue_xmit(struct sk_buff *skb)
1488 */
1489 if (skb_shinfo(skb)->nr_frags &&
1490 (!(dev->features & NETIF_F_SG) || illegal_highdma(dev, skb)) &&
1491 - __skb_linearize(skb, GFP_ATOMIC))
1492 + __skb_linearize(skb))
1493 goto out_kfree_skb;
1495 /* If packet is not checksummed and device does not support
1496 * checksumming for this protocol, complete checksumming here.
1497 */
1498 if (skb->ip_summed == CHECKSUM_HW &&
1499 - (!(dev->features & (NETIF_F_HW_CSUM | NETIF_F_NO_CSUM)) &&
1500 + (!(dev->features & NETIF_F_GEN_CSUM) &&
1501 (!(dev->features & NETIF_F_IP_CSUM) ||
1502 skb->protocol != htons(ETH_P_IP))))
1503 if (skb_checksum_help(skb, 0))
1504 goto out_kfree_skb;
1506 +gso:
1507 spin_lock_prefetch(&dev->queue_lock);
1509 /* Disable soft irqs for various locks below. Also
1510 * stops preemption for RCU.
1511 */
1512 - local_bh_disable();
1513 + rcu_read_lock_bh();
1515 /* Updates of qdisc are serialized by queue_lock.
1516 * The struct Qdisc which is pointed to by qdisc is now a
1517 @@ -1309,8 +1387,8 @@ #endif
1518 /* The device has no queue. Common case for software devices:
1519 loopback, all the sorts of tunnels...
1521 - Really, it is unlikely that xmit_lock protection is necessary here.
1522 - (f.e. loopback and IP tunnels are clean ignoring statistics
1523 + Really, it is unlikely that netif_tx_lock protection is necessary
1524 + here. (f.e. loopback and IP tunnels are clean ignoring statistics
1525 counters.)
1526 However, it is possible, that they rely on protection
1527 made by us here.
1528 @@ -1326,11 +1404,8 @@ #endif
1529 HARD_TX_LOCK(dev, cpu);
1531 if (!netif_queue_stopped(dev)) {
1532 - if (netdev_nit)
1533 - dev_queue_xmit_nit(skb, dev);
1535 rc = 0;
1536 - if (!dev->hard_start_xmit(skb, dev)) {
1537 + if (!dev_hard_start_xmit(skb, dev)) {
1538 HARD_TX_UNLOCK(dev);
1539 goto out;
1541 @@ -1349,13 +1424,13 @@ #endif
1544 rc = -ENETDOWN;
1545 - local_bh_enable();
1546 + rcu_read_unlock_bh();
1548 out_kfree_skb:
1549 kfree_skb(skb);
1550 return rc;
1551 out:
1552 - local_bh_enable();
1553 + rcu_read_unlock_bh();
1554 return rc;
1557 @@ -2670,7 +2745,7 @@ int register_netdevice(struct net_device
1558 BUG_ON(dev->reg_state != NETREG_UNINITIALIZED);
1560 spin_lock_init(&dev->queue_lock);
1561 - spin_lock_init(&dev->xmit_lock);
1562 + spin_lock_init(&dev->_xmit_lock);
1563 dev->xmit_lock_owner = -1;
1564 #ifdef CONFIG_NET_CLS_ACT
1565 spin_lock_init(&dev->ingress_lock);
1566 @@ -2714,9 +2789,7 @@ #endif
1568 /* Fix illegal SG+CSUM combinations. */
1569 if ((dev->features & NETIF_F_SG) &&
1570 - !(dev->features & (NETIF_F_IP_CSUM |
1571 - NETIF_F_NO_CSUM |
1572 - NETIF_F_HW_CSUM))) {
1573 + !(dev->features & NETIF_F_ALL_CSUM)) {
1574 printk("%s: Dropping NETIF_F_SG since no checksum feature.\n",
1575 dev->name);
1576 dev->features &= ~NETIF_F_SG;
1577 @@ -3268,7 +3341,6 @@ subsys_initcall(net_dev_init);
1578 EXPORT_SYMBOL(__dev_get_by_index);
1579 EXPORT_SYMBOL(__dev_get_by_name);
1580 EXPORT_SYMBOL(__dev_remove_pack);
1581 -EXPORT_SYMBOL(__skb_linearize);
1582 EXPORT_SYMBOL(dev_valid_name);
1583 EXPORT_SYMBOL(dev_add_pack);
1584 EXPORT_SYMBOL(dev_alloc_name);
1585 diff --git a/net/core/dev_mcast.c b/net/core/dev_mcast.c
1586 index 05d6085..c57d887 100644
1587 --- a/net/core/dev_mcast.c
1588 +++ b/net/core/dev_mcast.c
1589 @@ -62,7 +62,7 @@ #include <net/arp.h>
1590 * Device mc lists are changed by bh at least if IPv6 is enabled,
1591 * so that it must be bh protected.
1593 - * We block accesses to device mc filters with dev->xmit_lock.
1594 + * We block accesses to device mc filters with netif_tx_lock.
1595 */
1597 /*
1598 @@ -93,9 +93,9 @@ static void __dev_mc_upload(struct net_d
1600 void dev_mc_upload(struct net_device *dev)
1602 - spin_lock_bh(&dev->xmit_lock);
1603 + netif_tx_lock_bh(dev);
1604 __dev_mc_upload(dev);
1605 - spin_unlock_bh(&dev->xmit_lock);
1606 + netif_tx_unlock_bh(dev);
1609 /*
1610 @@ -107,7 +107,7 @@ int dev_mc_delete(struct net_device *dev
1611 int err = 0;
1612 struct dev_mc_list *dmi, **dmip;
1614 - spin_lock_bh(&dev->xmit_lock);
1615 + netif_tx_lock_bh(dev);
1617 for (dmip = &dev->mc_list; (dmi = *dmip) != NULL; dmip = &dmi->next) {
1618 /*
1619 @@ -139,13 +139,13 @@ int dev_mc_delete(struct net_device *dev
1620 */
1621 __dev_mc_upload(dev);
1623 - spin_unlock_bh(&dev->xmit_lock);
1624 + netif_tx_unlock_bh(dev);
1625 return 0;
1628 err = -ENOENT;
1629 done:
1630 - spin_unlock_bh(&dev->xmit_lock);
1631 + netif_tx_unlock_bh(dev);
1632 return err;
1635 @@ -160,7 +160,7 @@ int dev_mc_add(struct net_device *dev, v
1637 dmi1 = kmalloc(sizeof(*dmi), GFP_ATOMIC);
1639 - spin_lock_bh(&dev->xmit_lock);
1640 + netif_tx_lock_bh(dev);
1641 for (dmi = dev->mc_list; dmi != NULL; dmi = dmi->next) {
1642 if (memcmp(dmi->dmi_addr, addr, dmi->dmi_addrlen) == 0 &&
1643 dmi->dmi_addrlen == alen) {
1644 @@ -176,7 +176,7 @@ int dev_mc_add(struct net_device *dev, v
1647 if ((dmi = dmi1) == NULL) {
1648 - spin_unlock_bh(&dev->xmit_lock);
1649 + netif_tx_unlock_bh(dev);
1650 return -ENOMEM;
1652 memcpy(dmi->dmi_addr, addr, alen);
1653 @@ -189,11 +189,11 @@ int dev_mc_add(struct net_device *dev, v
1655 __dev_mc_upload(dev);
1657 - spin_unlock_bh(&dev->xmit_lock);
1658 + netif_tx_unlock_bh(dev);
1659 return 0;
1661 done:
1662 - spin_unlock_bh(&dev->xmit_lock);
1663 + netif_tx_unlock_bh(dev);
1664 kfree(dmi1);
1665 return err;
1667 @@ -204,7 +204,7 @@ done:
1669 void dev_mc_discard(struct net_device *dev)
1671 - spin_lock_bh(&dev->xmit_lock);
1672 + netif_tx_lock_bh(dev);
1674 while (dev->mc_list != NULL) {
1675 struct dev_mc_list *tmp = dev->mc_list;
1676 @@ -215,7 +215,7 @@ void dev_mc_discard(struct net_device *d
1678 dev->mc_count = 0;
1680 - spin_unlock_bh(&dev->xmit_lock);
1681 + netif_tx_unlock_bh(dev);
1684 #ifdef CONFIG_PROC_FS
1685 @@ -250,7 +250,7 @@ static int dev_mc_seq_show(struct seq_fi
1686 struct dev_mc_list *m;
1687 struct net_device *dev = v;
1689 - spin_lock_bh(&dev->xmit_lock);
1690 + netif_tx_lock_bh(dev);
1691 for (m = dev->mc_list; m; m = m->next) {
1692 int i;
1694 @@ -262,7 +262,7 @@ static int dev_mc_seq_show(struct seq_fi
1696 seq_putc(seq, '\n');
1698 - spin_unlock_bh(&dev->xmit_lock);
1699 + netif_tx_unlock_bh(dev);
1700 return 0;
1703 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
1704 index e6f7610..27ce168 100644
1705 --- a/net/core/ethtool.c
1706 +++ b/net/core/ethtool.c
1707 @@ -30,7 +30,7 @@ u32 ethtool_op_get_link(struct net_devic
1709 u32 ethtool_op_get_tx_csum(struct net_device *dev)
1711 - return (dev->features & (NETIF_F_IP_CSUM | NETIF_F_HW_CSUM)) != 0;
1712 + return (dev->features & NETIF_F_ALL_CSUM) != 0;
1715 int ethtool_op_set_tx_csum(struct net_device *dev, u32 data)
1716 @@ -551,9 +551,7 @@ static int ethtool_set_sg(struct net_dev
1717 return -EFAULT;
1719 if (edata.data &&
1720 - !(dev->features & (NETIF_F_IP_CSUM |
1721 - NETIF_F_NO_CSUM |
1722 - NETIF_F_HW_CSUM)))
1723 + !(dev->features & NETIF_F_ALL_CSUM))
1724 return -EINVAL;
1726 return __ethtool_set_sg(dev, edata.data);
1727 @@ -591,7 +589,7 @@ static int ethtool_set_tso(struct net_de
1729 static int ethtool_get_ufo(struct net_device *dev, char __user *useraddr)
1731 - struct ethtool_value edata = { ETHTOOL_GTSO };
1732 + struct ethtool_value edata = { ETHTOOL_GUFO };
1734 if (!dev->ethtool_ops->get_ufo)
1735 return -EOPNOTSUPP;
1736 @@ -600,6 +598,7 @@ static int ethtool_get_ufo(struct net_de
1737 return -EFAULT;
1738 return 0;
1741 static int ethtool_set_ufo(struct net_device *dev, char __user *useraddr)
1743 struct ethtool_value edata;
1744 @@ -615,6 +614,29 @@ static int ethtool_set_ufo(struct net_de
1745 return dev->ethtool_ops->set_ufo(dev, edata.data);
1748 +static int ethtool_get_gso(struct net_device *dev, char __user *useraddr)
1749 +{
1750 + struct ethtool_value edata = { ETHTOOL_GGSO };
1752 + edata.data = dev->features & NETIF_F_GSO;
1753 + if (copy_to_user(useraddr, &edata, sizeof(edata)))
1754 + return -EFAULT;
1755 + return 0;
1756 +}
1758 +static int ethtool_set_gso(struct net_device *dev, char __user *useraddr)
1759 +{
1760 + struct ethtool_value edata;
1762 + if (copy_from_user(&edata, useraddr, sizeof(edata)))
1763 + return -EFAULT;
1764 + if (edata.data)
1765 + dev->features |= NETIF_F_GSO;
1766 + else
1767 + dev->features &= ~NETIF_F_GSO;
1768 + return 0;
1769 +}
1771 static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
1773 struct ethtool_test test;
1774 @@ -906,6 +928,12 @@ int dev_ethtool(struct ifreq *ifr)
1775 case ETHTOOL_SUFO:
1776 rc = ethtool_set_ufo(dev, useraddr);
1777 break;
1778 + case ETHTOOL_GGSO:
1779 + rc = ethtool_get_gso(dev, useraddr);
1780 + break;
1781 + case ETHTOOL_SGSO:
1782 + rc = ethtool_set_gso(dev, useraddr);
1783 + break;
1784 default:
1785 rc = -EOPNOTSUPP;
1787 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
1788 index ea51f8d..ec28d3b 100644
1789 --- a/net/core/netpoll.c
1790 +++ b/net/core/netpoll.c
1791 @@ -273,24 +273,21 @@ static void netpoll_send_skb(struct netp
1793 do {
1794 npinfo->tries--;
1795 - spin_lock(&np->dev->xmit_lock);
1796 - np->dev->xmit_lock_owner = smp_processor_id();
1797 + netif_tx_lock(np->dev);
1799 /*
1800 * network drivers do not expect to be called if the queue is
1801 * stopped.
1802 */
1803 if (netif_queue_stopped(np->dev)) {
1804 - np->dev->xmit_lock_owner = -1;
1805 - spin_unlock(&np->dev->xmit_lock);
1806 + netif_tx_unlock(np->dev);
1807 netpoll_poll(np);
1808 udelay(50);
1809 continue;
1812 status = np->dev->hard_start_xmit(skb, np->dev);
1813 - np->dev->xmit_lock_owner = -1;
1814 - spin_unlock(&np->dev->xmit_lock);
1815 + netif_tx_unlock(np->dev);
1817 /* success */
1818 if(!status) {
1819 diff --git a/net/core/pktgen.c b/net/core/pktgen.c
1820 index da16f8f..2380347 100644
1821 --- a/net/core/pktgen.c
1822 +++ b/net/core/pktgen.c
1823 @@ -2582,7 +2582,7 @@ static __inline__ void pktgen_xmit(struc
1827 - spin_lock_bh(&odev->xmit_lock);
1828 + netif_tx_lock_bh(odev);
1829 if (!netif_queue_stopped(odev)) {
1831 atomic_inc(&(pkt_dev->skb->users));
1832 @@ -2627,7 +2627,7 @@ retry_now:
1833 pkt_dev->next_tx_ns = 0;
1836 - spin_unlock_bh(&odev->xmit_lock);
1837 + netif_tx_unlock_bh(odev);
1839 /* If pkt_dev->count is zero, then run forever */
1840 if ((pkt_dev->count != 0) && (pkt_dev->sofar >= pkt_dev->count)) {
1841 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
1842 index 2144952..46f56af 100644
1843 --- a/net/core/skbuff.c
1844 +++ b/net/core/skbuff.c
1845 @@ -164,9 +164,9 @@ struct sk_buff *__alloc_skb(unsigned int
1846 shinfo = skb_shinfo(skb);
1847 atomic_set(&shinfo->dataref, 1);
1848 shinfo->nr_frags = 0;
1849 - shinfo->tso_size = 0;
1850 - shinfo->tso_segs = 0;
1851 - shinfo->ufo_size = 0;
1852 + shinfo->gso_size = 0;
1853 + shinfo->gso_segs = 0;
1854 + shinfo->gso_type = 0;
1855 shinfo->ip6_frag_id = 0;
1856 shinfo->frag_list = NULL;
1858 @@ -230,8 +230,9 @@ struct sk_buff *alloc_skb_from_cache(kme
1860 atomic_set(&(skb_shinfo(skb)->dataref), 1);
1861 skb_shinfo(skb)->nr_frags = 0;
1862 - skb_shinfo(skb)->tso_size = 0;
1863 - skb_shinfo(skb)->tso_segs = 0;
1864 + skb_shinfo(skb)->gso_size = 0;
1865 + skb_shinfo(skb)->gso_segs = 0;
1866 + skb_shinfo(skb)->gso_type = 0;
1867 skb_shinfo(skb)->frag_list = NULL;
1868 out:
1869 return skb;
1870 @@ -501,8 +502,9 @@ #endif
1871 new->tc_index = old->tc_index;
1872 #endif
1873 atomic_set(&new->users, 1);
1874 - skb_shinfo(new)->tso_size = skb_shinfo(old)->tso_size;
1875 - skb_shinfo(new)->tso_segs = skb_shinfo(old)->tso_segs;
1876 + skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size;
1877 + skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs;
1878 + skb_shinfo(new)->gso_type = skb_shinfo(old)->gso_type;
1881 /**
1882 @@ -1777,6 +1779,133 @@ int skb_append_datato_frags(struct sock
1883 return 0;
1886 +/**
1887 + * skb_segment - Perform protocol segmentation on skb.
1888 + * @skb: buffer to segment
1889 + * @features: features for the output path (see dev->features)
1890 + *
1891 + * This function performs segmentation on the given skb. It returns
1892 + * the segment at the given position. It returns NULL if there are
1893 + * no more segments to generate, or when an error is encountered.
1894 + */
1895 +struct sk_buff *skb_segment(struct sk_buff *skb, int features)
1896 +{
1897 + struct sk_buff *segs = NULL;
1898 + struct sk_buff *tail = NULL;
1899 + unsigned int mss = skb_shinfo(skb)->gso_size;
1900 + unsigned int doffset = skb->data - skb->mac.raw;
1901 + unsigned int offset = doffset;
1902 + unsigned int headroom;
1903 + unsigned int len;
1904 + int sg = features & NETIF_F_SG;
1905 + int nfrags = skb_shinfo(skb)->nr_frags;
1906 + int err = -ENOMEM;
1907 + int i = 0;
1908 + int pos;
1910 + __skb_push(skb, doffset);
1911 + headroom = skb_headroom(skb);
1912 + pos = skb_headlen(skb);
1914 + do {
1915 + struct sk_buff *nskb;
1916 + skb_frag_t *frag;
1917 + int hsize, nsize;
1918 + int k;
1919 + int size;
1921 + len = skb->len - offset;
1922 + if (len > mss)
1923 + len = mss;
1925 + hsize = skb_headlen(skb) - offset;
1926 + if (hsize < 0)
1927 + hsize = 0;
1928 + nsize = hsize + doffset;
1929 + if (nsize > len + doffset || !sg)
1930 + nsize = len + doffset;
1932 + nskb = alloc_skb(nsize + headroom, GFP_ATOMIC);
1933 + if (unlikely(!nskb))
1934 + goto err;
1936 + if (segs)
1937 + tail->next = nskb;
1938 + else
1939 + segs = nskb;
1940 + tail = nskb;
1942 + nskb->dev = skb->dev;
1943 + nskb->priority = skb->priority;
1944 + nskb->protocol = skb->protocol;
1945 + nskb->dst = dst_clone(skb->dst);
1946 + memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
1947 + nskb->pkt_type = skb->pkt_type;
1948 + nskb->mac_len = skb->mac_len;
1950 + skb_reserve(nskb, headroom);
1951 + nskb->mac.raw = nskb->data;
1952 + nskb->nh.raw = nskb->data + skb->mac_len;
1953 + nskb->h.raw = nskb->nh.raw + (skb->h.raw - skb->nh.raw);
1954 + memcpy(skb_put(nskb, doffset), skb->data, doffset);
1956 + if (!sg) {
1957 + nskb->csum = skb_copy_and_csum_bits(skb, offset,
1958 + skb_put(nskb, len),
1959 + len, 0);
1960 + continue;
1961 + }
1963 + frag = skb_shinfo(nskb)->frags;
1964 + k = 0;
1966 + nskb->ip_summed = CHECKSUM_HW;
1967 + nskb->csum = skb->csum;
1968 + memcpy(skb_put(nskb, hsize), skb->data + offset, hsize);
1970 + while (pos < offset + len) {
1971 + BUG_ON(i >= nfrags);
1973 + *frag = skb_shinfo(skb)->frags[i];
1974 + get_page(frag->page);
1975 + size = frag->size;
1977 + if (pos < offset) {
1978 + frag->page_offset += offset - pos;
1979 + frag->size -= offset - pos;
1980 + }
1982 + k++;
1984 + if (pos + size <= offset + len) {
1985 + i++;
1986 + pos += size;
1987 + } else {
1988 + frag->size -= pos + size - (offset + len);
1989 + break;
1990 + }
1992 + frag++;
1993 + }
1995 + skb_shinfo(nskb)->nr_frags = k;
1996 + nskb->data_len = len - hsize;
1997 + nskb->len += nskb->data_len;
1998 + nskb->truesize += nskb->data_len;
1999 + } while ((offset += len) < skb->len);
2001 + return segs;
2003 +err:
2004 + while ((skb = segs)) {
2005 + segs = skb->next;
2006 + kfree(skb);
2007 + }
2008 + return ERR_PTR(err);
2009 +}
2011 +EXPORT_SYMBOL_GPL(skb_segment);
2013 void __init skb_init(void)
2015 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
2016 diff --git a/net/decnet/dn_nsp_in.c b/net/decnet/dn_nsp_in.c
2017 index 44bda85..2e3323a 100644
2018 --- a/net/decnet/dn_nsp_in.c
2019 +++ b/net/decnet/dn_nsp_in.c
2020 @@ -801,8 +801,7 @@ got_it:
2021 * We linearize everything except data segments here.
2022 */
2023 if (cb->nsp_flags & ~0x60) {
2024 - if (unlikely(skb_is_nonlinear(skb)) &&
2025 - skb_linearize(skb, GFP_ATOMIC) != 0)
2026 + if (unlikely(skb_linearize(skb)))
2027 goto free_out;
2030 diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
2031 index 3407f19..a0a25e0 100644
2032 --- a/net/decnet/dn_route.c
2033 +++ b/net/decnet/dn_route.c
2034 @@ -629,8 +629,7 @@ int dn_route_rcv(struct sk_buff *skb, st
2035 padlen);
2037 if (flags & DN_RT_PKT_CNTL) {
2038 - if (unlikely(skb_is_nonlinear(skb)) &&
2039 - skb_linearize(skb, GFP_ATOMIC) != 0)
2040 + if (unlikely(skb_linearize(skb)))
2041 goto dump_it;
2043 switch(flags & DN_RT_CNTL_MSK) {
2044 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
2045 index 97c276f..5ba719e 100644
2046 --- a/net/ipv4/af_inet.c
2047 +++ b/net/ipv4/af_inet.c
2048 @@ -68,6 +68,7 @@
2049 */
2051 #include <linux/config.h>
2052 +#include <linux/err.h>
2053 #include <linux/errno.h>
2054 #include <linux/types.h>
2055 #include <linux/socket.h>
2056 @@ -1084,6 +1085,54 @@ int inet_sk_rebuild_header(struct sock *
2058 EXPORT_SYMBOL(inet_sk_rebuild_header);
2060 +static struct sk_buff *inet_gso_segment(struct sk_buff *skb, int features)
2061 +{
2062 + struct sk_buff *segs = ERR_PTR(-EINVAL);
2063 + struct iphdr *iph;
2064 + struct net_protocol *ops;
2065 + int proto;
2066 + int ihl;
2067 + int id;
2069 + if (!pskb_may_pull(skb, sizeof(*iph)))
2070 + goto out;
2072 + iph = skb->nh.iph;
2073 + ihl = iph->ihl * 4;
2074 + if (ihl < sizeof(*iph))
2075 + goto out;
2077 + if (!pskb_may_pull(skb, ihl))
2078 + goto out;
2080 + skb->h.raw = __skb_pull(skb, ihl);
2081 + iph = skb->nh.iph;
2082 + id = ntohs(iph->id);
2083 + proto = iph->protocol & (MAX_INET_PROTOS - 1);
2084 + segs = ERR_PTR(-EPROTONOSUPPORT);
2086 + rcu_read_lock();
2087 + ops = rcu_dereference(inet_protos[proto]);
2088 + if (ops && ops->gso_segment)
2089 + segs = ops->gso_segment(skb, features);
2090 + rcu_read_unlock();
2092 + if (!segs || unlikely(IS_ERR(segs)))
2093 + goto out;
2095 + skb = segs;
2096 + do {
2097 + iph = skb->nh.iph;
2098 + iph->id = htons(id++);
2099 + iph->tot_len = htons(skb->len - skb->mac_len);
2100 + iph->check = 0;
2101 + iph->check = ip_fast_csum(skb->nh.raw, iph->ihl);
2102 + } while ((skb = skb->next));
2104 +out:
2105 + return segs;
2106 +}
2108 #ifdef CONFIG_IP_MULTICAST
2109 static struct net_protocol igmp_protocol = {
2110 .handler = igmp_rcv,
2111 @@ -1093,6 +1142,7 @@ #endif
2112 static struct net_protocol tcp_protocol = {
2113 .handler = tcp_v4_rcv,
2114 .err_handler = tcp_v4_err,
2115 + .gso_segment = tcp_tso_segment,
2116 .no_policy = 1,
2117 };
2119 @@ -1138,6 +1188,7 @@ static int ipv4_proc_init(void);
2120 static struct packet_type ip_packet_type = {
2121 .type = __constant_htons(ETH_P_IP),
2122 .func = ip_rcv,
2123 + .gso_segment = inet_gso_segment,
2124 };
2126 static int __init inet_init(void)
2127 diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
2128 index 8dcba38..19c3c73 100644
2129 --- a/net/ipv4/ip_output.c
2130 +++ b/net/ipv4/ip_output.c
2131 @@ -210,8 +210,7 @@ #if defined(CONFIG_NETFILTER) && defined
2132 return dst_output(skb);
2134 #endif
2135 - if (skb->len > dst_mtu(skb->dst) &&
2136 - !(skb_shinfo(skb)->ufo_size || skb_shinfo(skb)->tso_size))
2137 + if (skb->len > dst_mtu(skb->dst) && !skb_shinfo(skb)->gso_size)
2138 return ip_fragment(skb, ip_finish_output2);
2139 else
2140 return ip_finish_output2(skb);
2141 @@ -362,7 +361,7 @@ packet_routed:
2144 ip_select_ident_more(iph, &rt->u.dst, sk,
2145 - (skb_shinfo(skb)->tso_segs ?: 1) - 1);
2146 + (skb_shinfo(skb)->gso_segs ?: 1) - 1);
2148 /* Add an IP checksum. */
2149 ip_send_check(iph);
2150 @@ -743,7 +742,8 @@ static inline int ip_ufo_append_data(str
2151 (length - transhdrlen));
2152 if (!err) {
2153 /* specify the length of each IP datagram fragment*/
2154 - skb_shinfo(skb)->ufo_size = (mtu - fragheaderlen);
2155 + skb_shinfo(skb)->gso_size = mtu - fragheaderlen;
2156 + skb_shinfo(skb)->gso_type = SKB_GSO_UDPV4;
2157 __skb_queue_tail(&sk->sk_write_queue, skb);
2159 return 0;
2160 @@ -839,7 +839,7 @@ int ip_append_data(struct sock *sk,
2161 */
2162 if (transhdrlen &&
2163 length + fragheaderlen <= mtu &&
2164 - rt->u.dst.dev->features&(NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM) &&
2165 + rt->u.dst.dev->features & NETIF_F_ALL_CSUM &&
2166 !exthdrlen)
2167 csummode = CHECKSUM_HW;
2169 @@ -1086,14 +1086,16 @@ ssize_t ip_append_page(struct sock *sk,
2171 inet->cork.length += size;
2172 if ((sk->sk_protocol == IPPROTO_UDP) &&
2173 - (rt->u.dst.dev->features & NETIF_F_UFO))
2174 - skb_shinfo(skb)->ufo_size = (mtu - fragheaderlen);
2175 + (rt->u.dst.dev->features & NETIF_F_UFO)) {
2176 + skb_shinfo(skb)->gso_size = mtu - fragheaderlen;
2177 + skb_shinfo(skb)->gso_type = SKB_GSO_UDPV4;
2178 + }
2181 while (size > 0) {
2182 int i;
2184 - if (skb_shinfo(skb)->ufo_size)
2185 + if (skb_shinfo(skb)->gso_size)
2186 len = size;
2187 else {
2189 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
2190 index d64e2ec..7494823 100644
2191 --- a/net/ipv4/ipcomp.c
2192 +++ b/net/ipv4/ipcomp.c
2193 @@ -84,7 +84,7 @@ static int ipcomp_input(struct xfrm_stat
2194 struct xfrm_decap_state *decap, struct sk_buff *skb)
2196 u8 nexthdr;
2197 - int err = 0;
2198 + int err = -ENOMEM;
2199 struct iphdr *iph;
2200 union {
2201 struct iphdr iph;
2202 @@ -92,11 +92,8 @@ static int ipcomp_input(struct xfrm_stat
2203 } tmp_iph;
2206 - if ((skb_is_nonlinear(skb) || skb_cloned(skb)) &&
2207 - skb_linearize(skb, GFP_ATOMIC) != 0) {
2208 - err = -ENOMEM;
2209 + if (skb_linearize_cow(skb))
2210 goto out;
2211 - }
2213 skb->ip_summed = CHECKSUM_NONE;
2215 @@ -171,10 +168,8 @@ static int ipcomp_output(struct xfrm_sta
2216 goto out_ok;
2219 - if ((skb_is_nonlinear(skb) || skb_cloned(skb)) &&
2220 - skb_linearize(skb, GFP_ATOMIC) != 0) {
2221 + if (skb_linearize_cow(skb))
2222 goto out_ok;
2223 - }
2225 err = ipcomp_compress(x, skb);
2226 iph = skb->nh.iph;
2227 diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
2228 index 00aa80e..84130c9 100644
2229 --- a/net/ipv4/tcp.c
2230 +++ b/net/ipv4/tcp.c
2231 @@ -257,6 +257,7 @@ #include <linux/smp_lock.h>
2232 #include <linux/fs.h>
2233 #include <linux/random.h>
2234 #include <linux/bootmem.h>
2235 +#include <linux/err.h>
2237 #include <net/icmp.h>
2238 #include <net/tcp.h>
2239 @@ -570,7 +571,7 @@ new_segment:
2240 skb->ip_summed = CHECKSUM_HW;
2241 tp->write_seq += copy;
2242 TCP_SKB_CB(skb)->end_seq += copy;
2243 - skb_shinfo(skb)->tso_segs = 0;
2244 + skb_shinfo(skb)->gso_segs = 0;
2246 if (!copied)
2247 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_PSH;
2248 @@ -621,14 +622,10 @@ ssize_t tcp_sendpage(struct socket *sock
2249 ssize_t res;
2250 struct sock *sk = sock->sk;
2252 -#define TCP_ZC_CSUM_FLAGS (NETIF_F_IP_CSUM | NETIF_F_NO_CSUM | NETIF_F_HW_CSUM)
2254 if (!(sk->sk_route_caps & NETIF_F_SG) ||
2255 - !(sk->sk_route_caps & TCP_ZC_CSUM_FLAGS))
2256 + !(sk->sk_route_caps & NETIF_F_ALL_CSUM))
2257 return sock_no_sendpage(sock, page, offset, size, flags);
2259 -#undef TCP_ZC_CSUM_FLAGS
2261 lock_sock(sk);
2262 TCP_CHECK_TIMER(sk);
2263 res = do_tcp_sendpages(sk, &page, offset, size, flags);
2264 @@ -725,9 +722,7 @@ new_segment:
2265 /*
2266 * Check whether we can use HW checksum.
2267 */
2268 - if (sk->sk_route_caps &
2269 - (NETIF_F_IP_CSUM | NETIF_F_NO_CSUM |
2270 - NETIF_F_HW_CSUM))
2271 + if (sk->sk_route_caps & NETIF_F_ALL_CSUM)
2272 skb->ip_summed = CHECKSUM_HW;
2274 skb_entail(sk, tp, skb);
2275 @@ -823,7 +818,7 @@ new_segment:
2277 tp->write_seq += copy;
2278 TCP_SKB_CB(skb)->end_seq += copy;
2279 - skb_shinfo(skb)->tso_segs = 0;
2280 + skb_shinfo(skb)->gso_segs = 0;
2282 from += copy;
2283 copied += copy;
2284 @@ -2026,6 +2021,71 @@ int tcp_getsockopt(struct sock *sk, int
2288 +struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features)
2289 +{
2290 + struct sk_buff *segs = ERR_PTR(-EINVAL);
2291 + struct tcphdr *th;
2292 + unsigned thlen;
2293 + unsigned int seq;
2294 + unsigned int delta;
2295 + unsigned int oldlen;
2296 + unsigned int len;
2298 + if (!pskb_may_pull(skb, sizeof(*th)))
2299 + goto out;
2301 + th = skb->h.th;
2302 + thlen = th->doff * 4;
2303 + if (thlen < sizeof(*th))
2304 + goto out;
2306 + if (!pskb_may_pull(skb, thlen))
2307 + goto out;
2309 + segs = NULL;
2310 + if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST))
2311 + goto out;
2313 + oldlen = (u16)~skb->len;
2314 + __skb_pull(skb, thlen);
2316 + segs = skb_segment(skb, features);
2317 + if (IS_ERR(segs))
2318 + goto out;
2320 + len = skb_shinfo(skb)->gso_size;
2321 + delta = htonl(oldlen + (thlen + len));
2323 + skb = segs;
2324 + th = skb->h.th;
2325 + seq = ntohl(th->seq);
2327 + do {
2328 + th->fin = th->psh = 0;
2330 + th->check = ~csum_fold(th->check + delta);
2331 + if (skb->ip_summed != CHECKSUM_HW)
2332 + th->check = csum_fold(csum_partial(skb->h.raw, thlen,
2333 + skb->csum));
2335 + seq += len;
2336 + skb = skb->next;
2337 + th = skb->h.th;
2339 + th->seq = htonl(seq);
2340 + th->cwr = 0;
2341 + } while (skb->next);
2343 + delta = htonl(oldlen + (skb->tail - skb->h.raw) + skb->data_len);
2344 + th->check = ~csum_fold(th->check + delta);
2345 + if (skb->ip_summed != CHECKSUM_HW)
2346 + th->check = csum_fold(csum_partial(skb->h.raw, thlen,
2347 + skb->csum));
2349 +out:
2350 + return segs;
2351 +}
2353 extern void __skb_cb_too_small_for_tcp(int, int);
2354 extern struct tcp_congestion_ops tcp_reno;
2356 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
2357 index e9a54ae..defe77a 100644
2358 --- a/net/ipv4/tcp_input.c
2359 +++ b/net/ipv4/tcp_input.c
2360 @@ -1072,7 +1072,7 @@ tcp_sacktag_write_queue(struct sock *sk,
2361 else
2362 pkt_len = (end_seq -
2363 TCP_SKB_CB(skb)->seq);
2364 - if (tcp_fragment(sk, skb, pkt_len, skb_shinfo(skb)->tso_size))
2365 + if (tcp_fragment(sk, skb, pkt_len, skb_shinfo(skb)->gso_size))
2366 break;
2367 pcount = tcp_skb_pcount(skb);
2369 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
2370 index 310f2e6..ee01f69 100644
2371 --- a/net/ipv4/tcp_output.c
2372 +++ b/net/ipv4/tcp_output.c
2373 @@ -497,15 +497,17 @@ static void tcp_set_skb_tso_segs(struct
2374 /* Avoid the costly divide in the normal
2375 * non-TSO case.
2376 */
2377 - skb_shinfo(skb)->tso_segs = 1;
2378 - skb_shinfo(skb)->tso_size = 0;
2379 + skb_shinfo(skb)->gso_segs = 1;
2380 + skb_shinfo(skb)->gso_size = 0;
2381 + skb_shinfo(skb)->gso_type = 0;
2382 } else {
2383 unsigned int factor;
2385 factor = skb->len + (mss_now - 1);
2386 factor /= mss_now;
2387 - skb_shinfo(skb)->tso_segs = factor;
2388 - skb_shinfo(skb)->tso_size = mss_now;
2389 + skb_shinfo(skb)->gso_segs = factor;
2390 + skb_shinfo(skb)->gso_size = mss_now;
2391 + skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
2395 @@ -850,7 +852,7 @@ static int tcp_init_tso_segs(struct sock
2397 if (!tso_segs ||
2398 (tso_segs > 1 &&
2399 - skb_shinfo(skb)->tso_size != mss_now)) {
2400 + tcp_skb_mss(skb) != mss_now)) {
2401 tcp_set_skb_tso_segs(sk, skb, mss_now);
2402 tso_segs = tcp_skb_pcount(skb);
2404 @@ -1510,8 +1512,9 @@ int tcp_retransmit_skb(struct sock *sk,
2405 tp->snd_una == (TCP_SKB_CB(skb)->end_seq - 1)) {
2406 if (!pskb_trim(skb, 0)) {
2407 TCP_SKB_CB(skb)->seq = TCP_SKB_CB(skb)->end_seq - 1;
2408 - skb_shinfo(skb)->tso_segs = 1;
2409 - skb_shinfo(skb)->tso_size = 0;
2410 + skb_shinfo(skb)->gso_segs = 1;
2411 + skb_shinfo(skb)->gso_size = 0;
2412 + skb_shinfo(skb)->gso_type = 0;
2413 skb->ip_summed = CHECKSUM_NONE;
2414 skb->csum = 0;
2416 @@ -1716,8 +1719,9 @@ void tcp_send_fin(struct sock *sk)
2417 skb->csum = 0;
2418 TCP_SKB_CB(skb)->flags = (TCPCB_FLAG_ACK | TCPCB_FLAG_FIN);
2419 TCP_SKB_CB(skb)->sacked = 0;
2420 - skb_shinfo(skb)->tso_segs = 1;
2421 - skb_shinfo(skb)->tso_size = 0;
2422 + skb_shinfo(skb)->gso_segs = 1;
2423 + skb_shinfo(skb)->gso_size = 0;
2424 + skb_shinfo(skb)->gso_type = 0;
2426 /* FIN eats a sequence byte, write_seq advanced by tcp_queue_skb(). */
2427 TCP_SKB_CB(skb)->seq = tp->write_seq;
2428 @@ -1749,8 +1753,9 @@ void tcp_send_active_reset(struct sock *
2429 skb->csum = 0;
2430 TCP_SKB_CB(skb)->flags = (TCPCB_FLAG_ACK | TCPCB_FLAG_RST);
2431 TCP_SKB_CB(skb)->sacked = 0;
2432 - skb_shinfo(skb)->tso_segs = 1;
2433 - skb_shinfo(skb)->tso_size = 0;
2434 + skb_shinfo(skb)->gso_segs = 1;
2435 + skb_shinfo(skb)->gso_size = 0;
2436 + skb_shinfo(skb)->gso_type = 0;
2438 /* Send it off. */
2439 TCP_SKB_CB(skb)->seq = tcp_acceptable_seq(sk, tp);
2440 @@ -1833,8 +1838,9 @@ struct sk_buff * tcp_make_synack(struct
2441 TCP_SKB_CB(skb)->seq = tcp_rsk(req)->snt_isn;
2442 TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(skb)->seq + 1;
2443 TCP_SKB_CB(skb)->sacked = 0;
2444 - skb_shinfo(skb)->tso_segs = 1;
2445 - skb_shinfo(skb)->tso_size = 0;
2446 + skb_shinfo(skb)->gso_segs = 1;
2447 + skb_shinfo(skb)->gso_size = 0;
2448 + skb_shinfo(skb)->gso_type = 0;
2449 th->seq = htonl(TCP_SKB_CB(skb)->seq);
2450 th->ack_seq = htonl(tcp_rsk(req)->rcv_isn + 1);
2451 if (req->rcv_wnd == 0) { /* ignored for retransmitted syns */
2452 @@ -1937,8 +1943,9 @@ int tcp_connect(struct sock *sk)
2453 TCP_SKB_CB(buff)->flags = TCPCB_FLAG_SYN;
2454 TCP_ECN_send_syn(sk, tp, buff);
2455 TCP_SKB_CB(buff)->sacked = 0;
2456 - skb_shinfo(buff)->tso_segs = 1;
2457 - skb_shinfo(buff)->tso_size = 0;
2458 + skb_shinfo(buff)->gso_segs = 1;
2459 + skb_shinfo(buff)->gso_size = 0;
2460 + skb_shinfo(buff)->gso_type = 0;
2461 buff->csum = 0;
2462 TCP_SKB_CB(buff)->seq = tp->write_seq++;
2463 TCP_SKB_CB(buff)->end_seq = tp->write_seq;
2464 @@ -2042,8 +2049,9 @@ void tcp_send_ack(struct sock *sk)
2465 buff->csum = 0;
2466 TCP_SKB_CB(buff)->flags = TCPCB_FLAG_ACK;
2467 TCP_SKB_CB(buff)->sacked = 0;
2468 - skb_shinfo(buff)->tso_segs = 1;
2469 - skb_shinfo(buff)->tso_size = 0;
2470 + skb_shinfo(buff)->gso_segs = 1;
2471 + skb_shinfo(buff)->gso_size = 0;
2472 + skb_shinfo(buff)->gso_type = 0;
2474 /* Send it off, this clears delayed acks for us. */
2475 TCP_SKB_CB(buff)->seq = TCP_SKB_CB(buff)->end_seq = tcp_acceptable_seq(sk, tp);
2476 @@ -2078,8 +2086,9 @@ static int tcp_xmit_probe_skb(struct soc
2477 skb->csum = 0;
2478 TCP_SKB_CB(skb)->flags = TCPCB_FLAG_ACK;
2479 TCP_SKB_CB(skb)->sacked = urgent;
2480 - skb_shinfo(skb)->tso_segs = 1;
2481 - skb_shinfo(skb)->tso_size = 0;
2482 + skb_shinfo(skb)->gso_segs = 1;
2483 + skb_shinfo(skb)->gso_size = 0;
2484 + skb_shinfo(skb)->gso_type = 0;
2486 /* Use a previous sequence. This should cause the other
2487 * end to send an ack. Don't queue or clone SKB, just
2488 diff --git a/net/ipv4/xfrm4_output.c b/net/ipv4/xfrm4_output.c
2489 index 32ad229..737c1db 100644
2490 --- a/net/ipv4/xfrm4_output.c
2491 +++ b/net/ipv4/xfrm4_output.c
2492 @@ -9,6 +9,8 @@
2493 */
2495 #include <linux/compiler.h>
2496 +#include <linux/if_ether.h>
2497 +#include <linux/kernel.h>
2498 #include <linux/skbuff.h>
2499 #include <linux/spinlock.h>
2500 #include <linux/netfilter_ipv4.h>
2501 @@ -152,16 +154,10 @@ error_nolock:
2502 goto out_exit;
2505 -static int xfrm4_output_finish(struct sk_buff *skb)
2506 +static int xfrm4_output_finish2(struct sk_buff *skb)
2508 int err;
2510 -#ifdef CONFIG_NETFILTER
2511 - if (!skb->dst->xfrm) {
2512 - IPCB(skb)->flags |= IPSKB_REROUTED;
2513 - return dst_output(skb);
2514 - }
2515 -#endif
2516 while (likely((err = xfrm4_output_one(skb)) == 0)) {
2517 nf_reset(skb);
2519 @@ -174,7 +170,7 @@ #endif
2520 return dst_output(skb);
2522 err = nf_hook(PF_INET, NF_IP_POST_ROUTING, &skb, NULL,
2523 - skb->dst->dev, xfrm4_output_finish);
2524 + skb->dst->dev, xfrm4_output_finish2);
2525 if (unlikely(err != 1))
2526 break;
2528 @@ -182,6 +178,48 @@ #endif
2529 return err;
2532 +static int xfrm4_output_finish(struct sk_buff *skb)
2533 +{
2534 + struct sk_buff *segs;
2536 +#ifdef CONFIG_NETFILTER
2537 + if (!skb->dst->xfrm) {
2538 + IPCB(skb)->flags |= IPSKB_REROUTED;
2539 + return dst_output(skb);
2540 + }
2541 +#endif
2543 + if (!skb_shinfo(skb)->gso_size)
2544 + return xfrm4_output_finish2(skb);
2546 + skb->protocol = htons(ETH_P_IP);
2547 + segs = skb_gso_segment(skb, 0);
2548 + kfree_skb(skb);
2549 + if (unlikely(IS_ERR(segs)))
2550 + return PTR_ERR(segs);
2552 + do {
2553 + struct sk_buff *nskb = segs->next;
2554 + int err;
2556 + segs->next = NULL;
2557 + err = xfrm4_output_finish2(segs);
2559 + if (unlikely(err)) {
2560 + while ((segs = nskb)) {
2561 + nskb = segs->next;
2562 + segs->next = NULL;
2563 + kfree_skb(segs);
2564 + }
2565 + return err;
2566 + }
2568 + segs = nskb;
2569 + } while (segs);
2571 + return 0;
2572 +}
2574 int xfrm4_output(struct sk_buff *skb)
2576 return NF_HOOK_COND(PF_INET, NF_IP_POST_ROUTING, skb, NULL, skb->dst->dev,
2577 diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
2578 index 5bf70b1..cf5d17e 100644
2579 --- a/net/ipv6/ip6_output.c
2580 +++ b/net/ipv6/ip6_output.c
2581 @@ -147,7 +147,7 @@ static int ip6_output2(struct sk_buff *s
2583 int ip6_output(struct sk_buff *skb)
2585 - if ((skb->len > dst_mtu(skb->dst) && !skb_shinfo(skb)->ufo_size) ||
2586 + if ((skb->len > dst_mtu(skb->dst) && !skb_shinfo(skb)->gso_size) ||
2587 dst_allfrag(skb->dst))
2588 return ip6_fragment(skb, ip6_output2);
2589 else
2590 @@ -829,8 +829,9 @@ static inline int ip6_ufo_append_data(st
2591 struct frag_hdr fhdr;
2593 /* specify the length of each IP datagram fragment*/
2594 - skb_shinfo(skb)->ufo_size = (mtu - fragheaderlen) -
2595 - sizeof(struct frag_hdr);
2596 + skb_shinfo(skb)->gso_size = mtu - fragheaderlen -
2597 + sizeof(struct frag_hdr);
2598 + skb_shinfo(skb)->gso_type = SKB_GSO_UDPV4;
2599 ipv6_select_ident(skb, &fhdr);
2600 skb_shinfo(skb)->ip6_frag_id = fhdr.identification;
2601 __skb_queue_tail(&sk->sk_write_queue, skb);
2602 diff --git a/net/ipv6/ipcomp6.c b/net/ipv6/ipcomp6.c
2603 index d511a88..ef56d5d 100644
2604 --- a/net/ipv6/ipcomp6.c
2605 +++ b/net/ipv6/ipcomp6.c
2606 @@ -64,7 +64,7 @@ static LIST_HEAD(ipcomp6_tfms_list);
2608 static int ipcomp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_buff *skb)
2610 - int err = 0;
2611 + int err = -ENOMEM;
2612 u8 nexthdr = 0;
2613 int hdr_len = skb->h.raw - skb->nh.raw;
2614 unsigned char *tmp_hdr = NULL;
2615 @@ -75,11 +75,8 @@ static int ipcomp6_input(struct xfrm_sta
2616 struct crypto_tfm *tfm;
2617 int cpu;
2619 - if ((skb_is_nonlinear(skb) || skb_cloned(skb)) &&
2620 - skb_linearize(skb, GFP_ATOMIC) != 0) {
2621 - err = -ENOMEM;
2622 + if (skb_linearize_cow(skb))
2623 goto out;
2624 - }
2626 skb->ip_summed = CHECKSUM_NONE;
2628 @@ -158,10 +155,8 @@ static int ipcomp6_output(struct xfrm_st
2629 goto out_ok;
2632 - if ((skb_is_nonlinear(skb) || skb_cloned(skb)) &&
2633 - skb_linearize(skb, GFP_ATOMIC) != 0) {
2634 + if (skb_linearize_cow(skb))
2635 goto out_ok;
2636 - }
2638 /* compression */
2639 plen = skb->len - hdr_len;
2640 diff --git a/net/ipv6/xfrm6_output.c b/net/ipv6/xfrm6_output.c
2641 index 8024217..39bdeec 100644
2642 --- a/net/ipv6/xfrm6_output.c
2643 +++ b/net/ipv6/xfrm6_output.c
2644 @@ -151,7 +151,7 @@ error_nolock:
2645 goto out_exit;
2648 -static int xfrm6_output_finish(struct sk_buff *skb)
2649 +static int xfrm6_output_finish2(struct sk_buff *skb)
2651 int err;
2653 @@ -167,7 +167,7 @@ static int xfrm6_output_finish(struct sk
2654 return dst_output(skb);
2656 err = nf_hook(PF_INET6, NF_IP6_POST_ROUTING, &skb, NULL,
2657 - skb->dst->dev, xfrm6_output_finish);
2658 + skb->dst->dev, xfrm6_output_finish2);
2659 if (unlikely(err != 1))
2660 break;
2662 @@ -175,6 +175,41 @@ static int xfrm6_output_finish(struct sk
2663 return err;
2666 +static int xfrm6_output_finish(struct sk_buff *skb)
2667 +{
2668 + struct sk_buff *segs;
2670 + if (!skb_shinfo(skb)->gso_size)
2671 + return xfrm6_output_finish2(skb);
2673 + skb->protocol = htons(ETH_P_IP);
2674 + segs = skb_gso_segment(skb, 0);
2675 + kfree_skb(skb);
2676 + if (unlikely(IS_ERR(segs)))
2677 + return PTR_ERR(segs);
2679 + do {
2680 + struct sk_buff *nskb = segs->next;
2681 + int err;
2683 + segs->next = NULL;
2684 + err = xfrm6_output_finish2(segs);
2686 + if (unlikely(err)) {
2687 + while ((segs = nskb)) {
2688 + nskb = segs->next;
2689 + segs->next = NULL;
2690 + kfree_skb(segs);
2691 + }
2692 + return err;
2693 + }
2695 + segs = nskb;
2696 + } while (segs);
2698 + return 0;
2699 +}
2701 int xfrm6_output(struct sk_buff *skb)
2703 return NF_HOOK(PF_INET6, NF_IP6_POST_ROUTING, skb, NULL, skb->dst->dev,
2704 diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
2705 index 99ceb91..28c9efd 100644
2706 --- a/net/sched/sch_generic.c
2707 +++ b/net/sched/sch_generic.c
2708 @@ -72,9 +72,9 @@ void qdisc_unlock_tree(struct net_device
2709 dev->queue_lock serializes queue accesses for this device
2710 AND dev->qdisc pointer itself.
2712 - dev->xmit_lock serializes accesses to device driver.
2713 + netif_tx_lock serializes accesses to device driver.
2715 - dev->queue_lock and dev->xmit_lock are mutually exclusive,
2716 + dev->queue_lock and netif_tx_lock are mutually exclusive,
2717 if one is grabbed, another must be free.
2718 */
2720 @@ -90,14 +90,17 @@ void qdisc_unlock_tree(struct net_device
2721 NOTE: Called under dev->queue_lock with locally disabled BH.
2722 */
2724 -int qdisc_restart(struct net_device *dev)
2725 +static inline int qdisc_restart(struct net_device *dev)
2727 struct Qdisc *q = dev->qdisc;
2728 struct sk_buff *skb;
2730 /* Dequeue packet */
2731 - if ((skb = q->dequeue(q)) != NULL) {
2732 + if (((skb = dev->gso_skb)) || ((skb = q->dequeue(q)))) {
2733 unsigned nolock = (dev->features & NETIF_F_LLTX);
2735 + dev->gso_skb = NULL;
2737 /*
2738 * When the driver has LLTX set it does its own locking
2739 * in start_xmit. No need to add additional overhead by
2740 @@ -108,7 +111,7 @@ int qdisc_restart(struct net_device *dev
2741 * will be requeued.
2742 */
2743 if (!nolock) {
2744 - if (!spin_trylock(&dev->xmit_lock)) {
2745 + if (!netif_tx_trylock(dev)) {
2746 collision:
2747 /* So, someone grabbed the driver. */
2749 @@ -126,8 +129,6 @@ int qdisc_restart(struct net_device *dev
2750 __get_cpu_var(netdev_rx_stat).cpu_collision++;
2751 goto requeue;
2753 - /* Remember that the driver is grabbed by us. */
2754 - dev->xmit_lock_owner = smp_processor_id();
2758 @@ -136,14 +137,11 @@ int qdisc_restart(struct net_device *dev
2760 if (!netif_queue_stopped(dev)) {
2761 int ret;
2762 - if (netdev_nit)
2763 - dev_queue_xmit_nit(skb, dev);
2765 - ret = dev->hard_start_xmit(skb, dev);
2766 + ret = dev_hard_start_xmit(skb, dev);
2767 if (ret == NETDEV_TX_OK) {
2768 if (!nolock) {
2769 - dev->xmit_lock_owner = -1;
2770 - spin_unlock(&dev->xmit_lock);
2771 + netif_tx_unlock(dev);
2773 spin_lock(&dev->queue_lock);
2774 return -1;
2775 @@ -157,8 +155,7 @@ int qdisc_restart(struct net_device *dev
2776 /* NETDEV_TX_BUSY - we need to requeue */
2777 /* Release the driver */
2778 if (!nolock) {
2779 - dev->xmit_lock_owner = -1;
2780 - spin_unlock(&dev->xmit_lock);
2781 + netif_tx_unlock(dev);
2783 spin_lock(&dev->queue_lock);
2784 q = dev->qdisc;
2785 @@ -175,7 +172,10 @@ int qdisc_restart(struct net_device *dev
2786 */
2788 requeue:
2789 - q->ops->requeue(skb, q);
2790 + if (skb->next)
2791 + dev->gso_skb = skb;
2792 + else
2793 + q->ops->requeue(skb, q);
2794 netif_schedule(dev);
2795 return 1;
2797 @@ -183,11 +183,23 @@ requeue:
2798 return q->q.qlen;
2801 +void __qdisc_run(struct net_device *dev)
2802 +{
2803 + if (unlikely(dev->qdisc == &noop_qdisc))
2804 + goto out;
2806 + while (qdisc_restart(dev) < 0 && !netif_queue_stopped(dev))
2807 + /* NOTHING */;
2809 +out:
2810 + clear_bit(__LINK_STATE_QDISC_RUNNING, &dev->state);
2811 +}
2813 static void dev_watchdog(unsigned long arg)
2815 struct net_device *dev = (struct net_device *)arg;
2817 - spin_lock(&dev->xmit_lock);
2818 + netif_tx_lock(dev);
2819 if (dev->qdisc != &noop_qdisc) {
2820 if (netif_device_present(dev) &&
2821 netif_running(dev) &&
2822 @@ -201,7 +213,7 @@ static void dev_watchdog(unsigned long a
2823 dev_hold(dev);
2826 - spin_unlock(&dev->xmit_lock);
2827 + netif_tx_unlock(dev);
2829 dev_put(dev);
2831 @@ -225,17 +237,17 @@ void __netdev_watchdog_up(struct net_dev
2833 static void dev_watchdog_up(struct net_device *dev)
2835 - spin_lock_bh(&dev->xmit_lock);
2836 + netif_tx_lock_bh(dev);
2837 __netdev_watchdog_up(dev);
2838 - spin_unlock_bh(&dev->xmit_lock);
2839 + netif_tx_unlock_bh(dev);
2842 static void dev_watchdog_down(struct net_device *dev)
2844 - spin_lock_bh(&dev->xmit_lock);
2845 + netif_tx_lock_bh(dev);
2846 if (del_timer(&dev->watchdog_timer))
2847 __dev_put(dev);
2848 - spin_unlock_bh(&dev->xmit_lock);
2849 + netif_tx_unlock_bh(dev);
2852 void netif_carrier_on(struct net_device *dev)
2853 @@ -577,10 +589,17 @@ void dev_deactivate(struct net_device *d
2855 dev_watchdog_down(dev);
2857 - while (test_bit(__LINK_STATE_SCHED, &dev->state))
2858 + /* Wait for outstanding dev_queue_xmit calls. */
2859 + synchronize_rcu();
2861 + /* Wait for outstanding qdisc_run calls. */
2862 + while (test_bit(__LINK_STATE_QDISC_RUNNING, &dev->state))
2863 yield();
2865 - spin_unlock_wait(&dev->xmit_lock);
2866 + if (dev->gso_skb) {
2867 + kfree_skb(dev->gso_skb);
2868 + dev->gso_skb = NULL;
2869 + }
2872 void dev_init_scheduler(struct net_device *dev)
2873 @@ -622,6 +641,5 @@ EXPORT_SYMBOL(qdisc_create_dflt);
2874 EXPORT_SYMBOL(qdisc_alloc);
2875 EXPORT_SYMBOL(qdisc_destroy);
2876 EXPORT_SYMBOL(qdisc_reset);
2877 -EXPORT_SYMBOL(qdisc_restart);
2878 EXPORT_SYMBOL(qdisc_lock_tree);
2879 EXPORT_SYMBOL(qdisc_unlock_tree);
2880 diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
2881 index 79b8ef3..4c16ad5 100644
2882 --- a/net/sched/sch_teql.c
2883 +++ b/net/sched/sch_teql.c
2884 @@ -302,20 +302,17 @@ restart:
2886 switch (teql_resolve(skb, skb_res, slave)) {
2887 case 0:
2888 - if (spin_trylock(&slave->xmit_lock)) {
2889 - slave->xmit_lock_owner = smp_processor_id();
2890 + if (netif_tx_trylock(slave)) {
2891 if (!netif_queue_stopped(slave) &&
2892 slave->hard_start_xmit(skb, slave) == 0) {
2893 - slave->xmit_lock_owner = -1;
2894 - spin_unlock(&slave->xmit_lock);
2895 + netif_tx_unlock(slave);
2896 master->slaves = NEXT_SLAVE(q);
2897 netif_wake_queue(dev);
2898 master->stats.tx_packets++;
2899 master->stats.tx_bytes += len;
2900 return 0;
2902 - slave->xmit_lock_owner = -1;
2903 - spin_unlock(&slave->xmit_lock);
2904 + netif_tx_unlock(slave);
2906 if (netif_queue_stopped(dev))
2907 busy = 1;