@@ -262,14 +262,14 @@ static int tsnep_tx_ring_init(struct tsnep_tx *tx)
262262 return retval ;
263263}
264264
265- static void tsnep_tx_activate (struct tsnep_tx * tx , int index , bool last )
265+ static void tsnep_tx_activate (struct tsnep_tx * tx , int index , int length ,
266+ bool last )
266267{
267268 struct tsnep_tx_entry * entry = & tx -> entry [index ];
268269
269270 entry -> properties = 0 ;
270271 if (entry -> skb ) {
271- entry -> properties =
272- skb_pagelen (entry -> skb ) & TSNEP_DESC_LENGTH_MASK ;
272+ entry -> properties = length & TSNEP_DESC_LENGTH_MASK ;
273273 entry -> properties |= TSNEP_DESC_INTERRUPT_FLAG ;
274274 if (skb_shinfo (entry -> skb )-> tx_flags & SKBTX_IN_PROGRESS )
275275 entry -> properties |= TSNEP_DESC_EXTENDED_WRITEBACK_FLAG ;
@@ -334,6 +334,7 @@ static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
334334 struct tsnep_tx_entry * entry ;
335335 unsigned int len ;
336336 dma_addr_t dma ;
337+ int map_len = 0 ;
337338 int i ;
338339
339340 for (i = 0 ; i < count ; i ++ ) {
@@ -356,15 +357,18 @@ static int tsnep_tx_map(struct sk_buff *skb, struct tsnep_tx *tx, int count)
356357 dma_unmap_addr_set (entry , dma , dma );
357358
358359 entry -> desc -> tx = __cpu_to_le64 (dma );
360+
361+ map_len += len ;
359362 }
360363
361- return 0 ;
364+ return map_len ;
362365}
363366
364- static void tsnep_tx_unmap (struct tsnep_tx * tx , int index , int count )
367+ static int tsnep_tx_unmap (struct tsnep_tx * tx , int index , int count )
365368{
366369 struct device * dmadev = tx -> adapter -> dmadev ;
367370 struct tsnep_tx_entry * entry ;
371+ int map_len = 0 ;
368372 int i ;
369373
370374 for (i = 0 ; i < count ; i ++ ) {
@@ -381,9 +385,12 @@ static void tsnep_tx_unmap(struct tsnep_tx *tx, int index, int count)
381385 dma_unmap_addr (entry , dma ),
382386 dma_unmap_len (entry , len ),
383387 DMA_TO_DEVICE );
388+ map_len += entry -> len ;
384389 entry -> len = 0 ;
385390 }
386391 }
392+
393+ return map_len ;
387394}
388395
389396static netdev_tx_t tsnep_xmit_frame_ring (struct sk_buff * skb ,
@@ -392,6 +399,7 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
392399 unsigned long flags ;
393400 int count = 1 ;
394401 struct tsnep_tx_entry * entry ;
402+ int length ;
395403 int i ;
396404 int retval ;
397405
@@ -415,7 +423,7 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
415423 entry -> skb = skb ;
416424
417425 retval = tsnep_tx_map (skb , tx , count );
418- if (retval != 0 ) {
426+ if (retval < 0 ) {
419427 tsnep_tx_unmap (tx , tx -> write , count );
420428 dev_kfree_skb_any (entry -> skb );
421429 entry -> skb = NULL ;
@@ -428,12 +436,13 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
428436
429437 return NETDEV_TX_OK ;
430438 }
439+ length = retval ;
431440
432441 if (skb_shinfo (skb )-> tx_flags & SKBTX_HW_TSTAMP )
433442 skb_shinfo (skb )-> tx_flags |= SKBTX_IN_PROGRESS ;
434443
435444 for (i = 0 ; i < count ; i ++ )
436- tsnep_tx_activate (tx , (tx -> write + i ) % TSNEP_RING_SIZE ,
445+ tsnep_tx_activate (tx , (tx -> write + i ) % TSNEP_RING_SIZE , length ,
437446 i == (count - 1 ));
438447 tx -> write = (tx -> write + count ) % TSNEP_RING_SIZE ;
439448
@@ -449,9 +458,6 @@ static netdev_tx_t tsnep_xmit_frame_ring(struct sk_buff *skb,
449458 netif_stop_queue (tx -> adapter -> netdev );
450459 }
451460
452- tx -> packets ++ ;
453- tx -> bytes += skb_pagelen (entry -> skb ) + ETH_FCS_LEN ;
454-
455461 spin_unlock_irqrestore (& tx -> lock , flags );
456462
457463 return NETDEV_TX_OK ;
@@ -463,6 +469,7 @@ static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi_budget)
463469 int budget = 128 ;
464470 struct tsnep_tx_entry * entry ;
465471 int count ;
472+ int length ;
466473
467474 spin_lock_irqsave (& tx -> lock , flags );
468475
@@ -485,7 +492,7 @@ static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi_budget)
485492 if (skb_shinfo (entry -> skb )-> nr_frags > 0 )
486493 count += skb_shinfo (entry -> skb )-> nr_frags ;
487494
488- tsnep_tx_unmap (tx , tx -> read , count );
495+ length = tsnep_tx_unmap (tx , tx -> read , count );
489496
490497 if ((skb_shinfo (entry -> skb )-> tx_flags & SKBTX_IN_PROGRESS ) &&
491498 (__le32_to_cpu (entry -> desc_wb -> properties ) &
@@ -512,6 +519,9 @@ static bool tsnep_tx_poll(struct tsnep_tx *tx, int napi_budget)
512519
513520 tx -> read = (tx -> read + count ) % TSNEP_RING_SIZE ;
514521
522+ tx -> packets ++ ;
523+ tx -> bytes += length + ETH_FCS_LEN ;
524+
515525 budget -- ;
516526 } while (likely (budget ));
517527
0 commit comments