Commit 034de00b authored by Tobias Klauser's avatar Tobias Klauser Committed by David S. Miller

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: default avatarTobias Klauser <tklauser@distanz.ch>
Acked-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0fdf4d09
...@@ -271,7 +271,7 @@ static int sl_realloc_bufs(struct slip *sl, int mtu) ...@@ -271,7 +271,7 @@ static int sl_realloc_bufs(struct slip *sl, int mtu)
memcpy(sl->xbuff, sl->xhead, sl->xleft); memcpy(sl->xbuff, sl->xhead, sl->xleft);
} else { } else {
sl->xleft = 0; sl->xleft = 0;
sl->tx_dropped++; dev->stats.tx_dropped++;
} }
} }
sl->xhead = sl->xbuff; sl->xhead = sl->xbuff;
...@@ -281,7 +281,7 @@ static int sl_realloc_bufs(struct slip *sl, int mtu) ...@@ -281,7 +281,7 @@ static int sl_realloc_bufs(struct slip *sl, int mtu)
memcpy(sl->rbuff, rbuff, sl->rcount); memcpy(sl->rbuff, rbuff, sl->rcount);
} else { } else {
sl->rcount = 0; sl->rcount = 0;
sl->rx_over_errors++; dev->stats.rx_over_errors++;
set_bit(SLF_ERROR, &sl->flags); set_bit(SLF_ERROR, &sl->flags);
} }
} }
...@@ -319,6 +319,7 @@ static inline void sl_unlock(struct slip *sl) ...@@ -319,6 +319,7 @@ static inline void sl_unlock(struct slip *sl)
/* Send one completely decapsulated IP datagram to the IP layer. */ /* Send one completely decapsulated IP datagram to the IP layer. */
static void sl_bump(struct slip *sl) static void sl_bump(struct slip *sl)
{ {
struct net_device *dev = sl->dev;
struct sk_buff *skb; struct sk_buff *skb;
int count; int count;
...@@ -329,13 +330,13 @@ static void sl_bump(struct slip *sl) ...@@ -329,13 +330,13 @@ static void sl_bump(struct slip *sl)
if (c & SL_TYPE_COMPRESSED_TCP) { if (c & SL_TYPE_COMPRESSED_TCP) {
/* ignore compressed packets when CSLIP is off */ /* ignore compressed packets when CSLIP is off */
if (!(sl->mode & SL_MODE_CSLIP)) { if (!(sl->mode & SL_MODE_CSLIP)) {
printk(KERN_WARNING "%s: compressed packet ignored\n", sl->dev->name); printk(KERN_WARNING "%s: compressed packet ignored\n", dev->name);
return; return;
} }
/* make sure we've reserved enough space for uncompress /* make sure we've reserved enough space for uncompress
to use */ to use */
if (count + 80 > sl->buffsize) { if (count + 80 > sl->buffsize) {
sl->rx_over_errors++; dev->stats.rx_over_errors++;
return; return;
} }
count = slhc_uncompress(sl->slcomp, sl->rbuff, count); count = slhc_uncompress(sl->slcomp, sl->rbuff, count);
...@@ -346,7 +347,7 @@ static void sl_bump(struct slip *sl) ...@@ -346,7 +347,7 @@ static void sl_bump(struct slip *sl)
/* turn on header compression */ /* turn on header compression */
sl->mode |= SL_MODE_CSLIP; sl->mode |= SL_MODE_CSLIP;
sl->mode &= ~SL_MODE_ADAPTIVE; sl->mode &= ~SL_MODE_ADAPTIVE;
printk(KERN_INFO "%s: header compression turned on\n", sl->dev->name); printk(KERN_INFO "%s: header compression turned on\n", dev->name);
} }
sl->rbuff[0] &= 0x4f; sl->rbuff[0] &= 0x4f;
if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0) if (slhc_remember(sl->slcomp, sl->rbuff, count) <= 0)
...@@ -355,20 +356,20 @@ static void sl_bump(struct slip *sl) ...@@ -355,20 +356,20 @@ static void sl_bump(struct slip *sl)
} }
#endif /* SL_INCLUDE_CSLIP */ #endif /* SL_INCLUDE_CSLIP */
sl->rx_bytes += count; dev->stats.rx_bytes += count;
skb = dev_alloc_skb(count); skb = dev_alloc_skb(count);
if (skb == NULL) { if (skb == NULL) {
printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", sl->dev->name); printk(KERN_WARNING "%s: memory squeeze, dropping packet.\n", dev->name);
sl->rx_dropped++; dev->stats.rx_dropped++;
return; return;
} }
skb->dev = sl->dev; skb->dev = dev;
memcpy(skb_put(skb, count), sl->rbuff, count); memcpy(skb_put(skb, count), sl->rbuff, count);
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
skb->protocol = htons(ETH_P_IP); skb->protocol = htons(ETH_P_IP);
netif_rx(skb); netif_rx(skb);
sl->rx_packets++; dev->stats.rx_packets++;
} }
/* Encapsulate one IP datagram and stuff into a TTY queue. */ /* Encapsulate one IP datagram and stuff into a TTY queue. */
...@@ -379,7 +380,7 @@ static void sl_encaps(struct slip *sl, unsigned char *icp, int len) ...@@ -379,7 +380,7 @@ static void sl_encaps(struct slip *sl, unsigned char *icp, int len)
if (len > sl->mtu) { /* Sigh, shouldn't occur BUT ... */ if (len > sl->mtu) { /* Sigh, shouldn't occur BUT ... */
printk(KERN_WARNING "%s: truncating oversized transmit packet!\n", sl->dev->name); printk(KERN_WARNING "%s: truncating oversized transmit packet!\n", sl->dev->name);
sl->tx_dropped++; sl->dev->stats.tx_dropped++;
sl_unlock(sl); sl_unlock(sl);
return; return;
} }
...@@ -433,7 +434,7 @@ static void slip_write_wakeup(struct tty_struct *tty) ...@@ -433,7 +434,7 @@ static void slip_write_wakeup(struct tty_struct *tty)
if (sl->xleft <= 0) { if (sl->xleft <= 0) {
/* Now serial buffer is almost free & we can start /* Now serial buffer is almost free & we can start
* transmission of another packet */ * transmission of another packet */
sl->tx_packets++; sl->dev->stats.tx_packets++;
clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
sl_unlock(sl); sl_unlock(sl);
return; return;
...@@ -496,7 +497,7 @@ sl_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -496,7 +497,7 @@ sl_xmit(struct sk_buff *skb, struct net_device *dev)
} }
sl_lock(sl); sl_lock(sl);
sl->tx_bytes += skb->len; dev->stats.tx_bytes += skb->len;
sl_encaps(sl, skb->data, skb->len); sl_encaps(sl, skb->data, skb->len);
spin_unlock(&sl->lock); spin_unlock(&sl->lock);
...@@ -558,16 +559,16 @@ static int sl_change_mtu(struct net_device *dev, int new_mtu) ...@@ -558,16 +559,16 @@ static int sl_change_mtu(struct net_device *dev, int new_mtu)
/* Netdevice get statistics request */ /* Netdevice get statistics request */
static struct net_device_stats * static struct rtnl_link_stats64 *
sl_get_stats(struct net_device *dev) sl_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ {
struct net_device_stats *stats = &dev->stats; struct net_device_stats *devstats = &dev->stats;
struct slip *sl = netdev_priv(dev);
unsigned long c_rx_dropped = 0; unsigned long c_rx_dropped = 0;
#ifdef SL_INCLUDE_CSLIP #ifdef SL_INCLUDE_CSLIP
unsigned long c_rx_fifo_errors = 0; unsigned long c_rx_fifo_errors = 0;
unsigned long c_tx_fifo_errors = 0; unsigned long c_tx_fifo_errors = 0;
unsigned long c_collisions = 0; unsigned long c_collisions = 0;
struct slip *sl = netdev_priv(dev);
struct slcompress *comp = sl->slcomp; struct slcompress *comp = sl->slcomp;
if (comp) { if (comp) {
...@@ -580,16 +581,16 @@ sl_get_stats(struct net_device *dev) ...@@ -580,16 +581,16 @@ sl_get_stats(struct net_device *dev)
stats->tx_fifo_errors = sl->tx_compressed + c_tx_fifo_errors; stats->tx_fifo_errors = sl->tx_compressed + c_tx_fifo_errors;
stats->collisions = sl->tx_misses + c_collisions; stats->collisions = sl->tx_misses + c_collisions;
#endif #endif
stats->rx_packets = devstats->rx_packets;
stats->tx_packets = devstats->tx_packets;
stats->rx_bytes = devstats->rx_bytes;
stats->tx_bytes = devstats->tx_bytes;
stats->rx_dropped = devstats->rx_dropped + c_rx_dropped;
stats->tx_dropped = devstats->tx_dropped;
stats->tx_errors = devstats->tx_errors;
stats->rx_errors = devstats->rx_errors;
stats->rx_over_errors = devstats->rx_over_errors;
stats->rx_packets = sl->rx_packets;
stats->tx_packets = sl->tx_packets;
stats->rx_bytes = sl->rx_bytes;
stats->tx_bytes = sl->tx_bytes;
stats->rx_dropped = sl->rx_dropped + c_rx_dropped;
stats->tx_dropped = sl->tx_dropped;
stats->tx_errors = sl->tx_errors;
stats->rx_errors = sl->rx_errors;
stats->rx_over_errors = sl->rx_over_errors;
return stats; return stats;
} }
...@@ -633,7 +634,7 @@ static const struct net_device_ops sl_netdev_ops = { ...@@ -633,7 +634,7 @@ static const struct net_device_ops sl_netdev_ops = {
.ndo_open = sl_open, .ndo_open = sl_open,
.ndo_stop = sl_close, .ndo_stop = sl_close,
.ndo_start_xmit = sl_xmit, .ndo_start_xmit = sl_xmit,
.ndo_get_stats = sl_get_stats, .ndo_get_stats64 = sl_get_stats64,
.ndo_change_mtu = sl_change_mtu, .ndo_change_mtu = sl_change_mtu,
.ndo_tx_timeout = sl_tx_timeout, .ndo_tx_timeout = sl_tx_timeout,
#ifdef CONFIG_SLIP_SMART #ifdef CONFIG_SLIP_SMART
...@@ -681,7 +682,7 @@ static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, ...@@ -681,7 +682,7 @@ static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp,
while (count--) { while (count--) {
if (fp && *fp++) { if (fp && *fp++) {
if (!test_and_set_bit(SLF_ERROR, &sl->flags)) if (!test_and_set_bit(SLF_ERROR, &sl->flags))
sl->rx_errors++; sl->dev->stats.rx_errors++;
cp++; cp++;
continue; continue;
} }
...@@ -981,7 +982,7 @@ static void slip_unesc(struct slip *sl, unsigned char s) ...@@ -981,7 +982,7 @@ static void slip_unesc(struct slip *sl, unsigned char s)
sl->rbuff[sl->rcount++] = s; sl->rbuff[sl->rcount++] = s;
return; return;
} }
sl->rx_over_errors++; sl->dev->stats.rx_over_errors++;
set_bit(SLF_ERROR, &sl->flags); set_bit(SLF_ERROR, &sl->flags);
} }
} }
...@@ -1057,7 +1058,7 @@ static void slip_unesc6(struct slip *sl, unsigned char s) ...@@ -1057,7 +1058,7 @@ static void slip_unesc6(struct slip *sl, unsigned char s)
sl->rbuff[sl->rcount++] = c; sl->rbuff[sl->rcount++] = c;
return; return;
} }
sl->rx_over_errors++; sl->dev->stats.rx_over_errors++;
set_bit(SLF_ERROR, &sl->flags); set_bit(SLF_ERROR, &sl->flags);
} }
} }
......
...@@ -67,15 +67,6 @@ struct slip { ...@@ -67,15 +67,6 @@ struct slip {
int xleft; /* bytes left in XMIT queue */ int xleft; /* bytes left in XMIT queue */
/* SLIP interface statistics. */ /* SLIP interface statistics. */
unsigned long rx_packets; /* inbound frames counter */
unsigned long tx_packets; /* outbound frames counter */
unsigned long rx_bytes; /* inbound byte counte */
unsigned long tx_bytes; /* outbound byte counter */
unsigned long rx_errors; /* Parity, etc. errors */
unsigned long tx_errors; /* Planned stuff */
unsigned long rx_dropped; /* No memory for skb */
unsigned long tx_dropped; /* When MTU change */
unsigned long rx_over_errors; /* Frame bigger than SLIP buf. */
#ifdef SL_INCLUDE_CSLIP #ifdef SL_INCLUDE_CSLIP
unsigned long tx_compressed; unsigned long tx_compressed;
unsigned long rx_compressed; unsigned long rx_compressed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment