Commit 034de00b06fe2b2c451f7435414f15c1b625e6b0
Committed by
David S. Miller
1 parent
0fdf4d0961
Exists in
master
and in
39 other branches
slip: Use net_device_stats from struct net_device
Use net_device->stats for stats instead of private variable copies in struct slip. Use ndo_get_stat64 so the additions can be performed on a private destination buffer. Cc: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Acked-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 2 changed files with 31 additions and 39 deletions Side-by-side Diff
drivers/net/slip.c
... | ... | @@ -271,7 +271,7 @@ |
271 | 271 | memcpy(sl->xbuff, sl->xhead, sl->xleft); |
272 | 272 | } else { |
273 | 273 | sl->xleft = 0; |
274 | - sl->tx_dropped++; | |
274 | + dev->stats.tx_dropped++; | |
275 | 275 | } |
276 | 276 | } |
277 | 277 | sl->xhead = sl->xbuff; |
... | ... | @@ -281,7 +281,7 @@ |
281 | 281 | memcpy(sl->rbuff, rbuff, sl->rcount); |
282 | 282 | } else { |
283 | 283 | sl->rcount = 0; |
284 | - sl->rx_over_errors++; | |
284 | + dev->stats.rx_over_errors++; | |
285 | 285 | set_bit(SLF_ERROR, &sl->flags); |
286 | 286 | } |
287 | 287 | } |
... | ... | @@ -319,6 +319,7 @@ |
319 | 319 | /* Send one completely decapsulated IP datagram to the IP layer. */ |
320 | 320 | static void sl_bump(struct slip *sl) |
321 | 321 | { |
322 | + struct net_device *dev = sl->dev; | |
322 | 323 | struct sk_buff *skb; |
323 | 324 | int count; |
324 | 325 | |
325 | 326 | |
... | ... | @@ -329,13 +330,13 @@ |
329 | 330 | if (c & SL_TYPE_COMPRESSED_TCP) { |
330 | 331 | /* ignore compressed packets when CSLIP is off */ |
331 | 332 | if (!(sl->mode & SL_MODE_CSLIP)) { |
332 | - printk(KERN_WARNING "%s: compressed packet ignored\n", sl->dev->name); | |
333 | + printk(KERN_WARNING "%s: compressed packet ignored\n", dev->name); | |
333 | 334 | return; |
334 | 335 | } |
335 | 336 | /* make sure we've reserved enough space for uncompress |
336 | 337 | to use */ |
337 | 338 | if (count + 80 > sl->buffsize) { |
338 | - sl->rx_over_errors++; | |
339 | + dev->stats.rx_over_errors++; | |
339 | 340 | return; |
340 | 341 | } |
341 | 342 | count = slhc_uncompress(sl->slcomp, sl->rbuff, count); |
... | ... | @@ -346,7 +347,7 @@ |
346 | 347 | /* turn on header compression */ |
347 | 348 | sl->mode |= SL_MODE_CSLIP; |
348 | 349 | sl->mode &= ~SL_MODE_ADAPTIVE; |
349 | - printk(KERN_INFO "%s: header compression turned on\n", sl->dev->name); | |
350 | + printk(KERN_INFO "%s: header compression turned on\n", dev->name); | |
350 | 351 | } |
351 | 352 | sl->rbuff[0] &= 0x4f; |
352 | 353 | if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0) |
353 | 354 | |
354 | 355 | |
355 | 356 | |
... | ... | @@ -355,20 +356,20 @@ |
355 | 356 | } |
356 | 357 | #endif /* SL_INCLUDE_CSLIP */ |
357 | 358 | |
358 | - sl->rx_bytes += count; | |
359 | + dev->stats.rx_bytes += count; | |
359 | 360 | |
360 | 361 | skb = dev_alloc_skb(count); |
361 | 362 | if (skb == NULL) { |
362 | - printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", sl->dev->name); | |
363 | - sl->rx_dropped++; | |
363 | + printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", dev->name); | |
364 | + dev->stats.rx_dropped++; | |
364 | 365 | return; |
365 | 366 | } |
366 | - skb->dev = sl->dev; | |
367 | + skb->dev = dev; | |
367 | 368 | memcpy(skb_put(skb, count), sl->rbuff, count); |
368 | 369 | skb_reset_mac_header(skb); |
369 | 370 | skb->protocol = htons(ETH_P_IP); |
370 | 371 | netif_rx(skb); |
371 | - sl->rx_packets++; | |
372 | + dev->stats.rx_packets++; | |
372 | 373 | } |
373 | 374 | |
374 | 375 | /* Encapsulate one IP datagram and stuff into a TTY queue. */ |
... | ... | @@ -379,7 +380,7 @@ |
379 | 380 | |
380 | 381 | if (len > sl->mtu) { /* Sigh, shouldn't occur BUT ... */ |
381 | 382 | printk(KERN_WARNING "%s: truncating oversized transmit packet!\n", sl->dev->name); |
382 | - sl->tx_dropped++; | |
383 | + sl->dev->stats.tx_dropped++; | |
383 | 384 | sl_unlock(sl); |
384 | 385 | return; |
385 | 386 | } |
... | ... | @@ -433,7 +434,7 @@ |
433 | 434 | if (sl->xleft <= 0) { |
434 | 435 | /* Now serial buffer is almost free & we can start |
435 | 436 | * transmission of another packet */ |
436 | - sl->tx_packets++; | |
437 | + sl->dev->stats.tx_packets++; | |
437 | 438 | clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); |
438 | 439 | sl_unlock(sl); |
439 | 440 | return; |
... | ... | @@ -496,7 +497,7 @@ |
496 | 497 | } |
497 | 498 | |
498 | 499 | sl_lock(sl); |
499 | - sl->tx_bytes += skb->len; | |
500 | + dev->stats.tx_bytes += skb->len; | |
500 | 501 | sl_encaps(sl, skb->data, skb->len); |
501 | 502 | spin_unlock(&sl->lock); |
502 | 503 | |
503 | 504 | |
504 | 505 | |
... | ... | @@ -558,16 +559,16 @@ |
558 | 559 | |
559 | 560 | /* Netdevice get statistics request */ |
560 | 561 | |
561 | -static struct net_device_stats * | |
562 | -sl_get_stats(struct net_device *dev) | |
562 | +static struct rtnl_link_stats64 * | |
563 | +sl_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats) | |
563 | 564 | { |
564 | - struct net_device_stats *stats = &dev->stats; | |
565 | - struct slip *sl = netdev_priv(dev); | |
565 | + struct net_device_stats *devstats = &dev->stats; | |
566 | 566 | unsigned long c_rx_dropped = 0; |
567 | 567 | #ifdef SL_INCLUDE_CSLIP |
568 | 568 | unsigned long c_rx_fifo_errors = 0; |
569 | 569 | unsigned long c_tx_fifo_errors = 0; |
570 | 570 | unsigned long c_collisions = 0; |
571 | + struct slip *sl = netdev_priv(dev); | |
571 | 572 | struct slcompress *comp = sl->slcomp; |
572 | 573 | |
573 | 574 | if (comp) { |
574 | 575 | |
... | ... | @@ -580,16 +581,16 @@ |
580 | 581 | stats->tx_fifo_errors = sl->tx_compressed + c_tx_fifo_errors; |
581 | 582 | stats->collisions = sl->tx_misses + c_collisions; |
582 | 583 | #endif |
584 | + stats->rx_packets = devstats->rx_packets; | |
585 | + stats->tx_packets = devstats->tx_packets; | |
586 | + stats->rx_bytes = devstats->rx_bytes; | |
587 | + stats->tx_bytes = devstats->tx_bytes; | |
588 | + stats->rx_dropped = devstats->rx_dropped + c_rx_dropped; | |
589 | + stats->tx_dropped = devstats->tx_dropped; | |
590 | + stats->tx_errors = devstats->tx_errors; | |
591 | + stats->rx_errors = devstats->rx_errors; | |
592 | + stats->rx_over_errors = devstats->rx_over_errors; | |
583 | 593 | |
584 | - stats->rx_packets = sl->rx_packets; | |
585 | - stats->tx_packets = sl->tx_packets; | |
586 | - stats->rx_bytes = sl->rx_bytes; | |
587 | - stats->tx_bytes = sl->tx_bytes; | |
588 | - stats->rx_dropped = sl->rx_dropped + c_rx_dropped; | |
589 | - stats->tx_dropped = sl->tx_dropped; | |
590 | - stats->tx_errors = sl->tx_errors; | |
591 | - stats->rx_errors = sl->rx_errors; | |
592 | - stats->rx_over_errors = sl->rx_over_errors; | |
593 | 594 | return stats; |
594 | 595 | } |
595 | 596 | |
... | ... | @@ -633,7 +634,7 @@ |
633 | 634 | .ndo_open = sl_open, |
634 | 635 | .ndo_stop = sl_close, |
635 | 636 | .ndo_start_xmit = sl_xmit, |
636 | - .ndo_get_stats = sl_get_stats, | |
637 | + .ndo_get_stats64 = sl_get_stats64, | |
637 | 638 | .ndo_change_mtu = sl_change_mtu, |
638 | 639 | .ndo_tx_timeout = sl_tx_timeout, |
639 | 640 | #ifdef CONFIG_SLIP_SMART |
... | ... | @@ -681,7 +682,7 @@ |
681 | 682 | while (count--) { |
682 | 683 | if (fp && *fp++) { |
683 | 684 | if (!test_and_set_bit(SLF_ERROR, &sl->flags)) |
684 | - sl->rx_errors++; | |
685 | + sl->dev->stats.rx_errors++; | |
685 | 686 | cp++; |
686 | 687 | continue; |
687 | 688 | } |
... | ... | @@ -981,7 +982,7 @@ |
981 | 982 | sl->rbuff[sl->rcount++] = s; |
982 | 983 | return; |
983 | 984 | } |
984 | - sl->rx_over_errors++; | |
985 | + sl->dev->stats.rx_over_errors++; | |
985 | 986 | set_bit(SLF_ERROR, &sl->flags); |
986 | 987 | } |
987 | 988 | } |
... | ... | @@ -1057,7 +1058,7 @@ |
1057 | 1058 | sl->rbuff[sl->rcount++] = c; |
1058 | 1059 | return; |
1059 | 1060 | } |
1060 | - sl->rx_over_errors++; | |
1061 | + sl->dev->stats.rx_over_errors++; | |
1061 | 1062 | set_bit(SLF_ERROR, &sl->flags); |
1062 | 1063 | } |
1063 | 1064 | } |
drivers/net/slip.h
... | ... | @@ -67,15 +67,6 @@ |
67 | 67 | int xleft; /* bytes left in XMIT queue */ |
68 | 68 | |
69 | 69 | /* SLIP interface statistics. */ |
70 | - unsigned long rx_packets; /* inbound frames counter */ | |
71 | - unsigned long tx_packets; /* outbound frames counter */ | |
72 | - unsigned long rx_bytes; /* inbound byte counte */ | |
73 | - unsigned long tx_bytes; /* outbound byte counter */ | |
74 | - unsigned long rx_errors; /* Parity, etc. errors */ | |
75 | - unsigned long tx_errors; /* Planned stuff */ | |
76 | - unsigned long rx_dropped; /* No memory for skb */ | |
77 | - unsigned long tx_dropped; /* When MTU change */ | |
78 | - unsigned long rx_over_errors; /* Frame bigger than SLIP buf. */ | |
79 | 70 | #ifdef SL_INCLUDE_CSLIP |
80 | 71 | unsigned long tx_compressed; |
81 | 72 | unsigned long rx_compressed; |