diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-10-03 20:41:50 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:16 -0400 |
commit | 09f75cd7bf13720738e6a196cc0107ce9a5bd5a0 (patch) | |
tree | 4c85b0b395abe7f88c87162fc22570e5de255cb1 /drivers/net/tun.c | |
parent | ff8ac60948ba819b89e9c87083e8050fc2f89999 (diff) |
[NET] drivers/net: statistics cleanup #1 -- save memory and shrink code
We now have struct net_device_stats embedded in struct net_device,
and the default ->get_stats() hook does the obvious thing for us.
Run through drivers/net/* and remove the driver-local storage of
statistics, and driver-local ->get_stats() hook where applicable.
This was just the low-hanging fruit in drivers/net; plenty more drivers
remain to be updated.
[ Resolved conflicts with napi_struct changes and fix sunqe build
regression... -DaveM ]
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r-- | drivers/net/tun.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 8b3ec335385c..d279151f065d 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -110,7 +110,7 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev) | |||
110 | 110 | ||
111 | /* We won't see all dropped packets individually, so overrun | 111 | /* We won't see all dropped packets individually, so overrun |
112 | * error is more appropriate. */ | 112 | * error is more appropriate. */ |
113 | tun->stats.tx_fifo_errors++; | 113 | dev->stats.tx_fifo_errors++; |
114 | } else { | 114 | } else { |
115 | /* Single queue mode. | 115 | /* Single queue mode. |
116 | * Driver handles dropping of all packets itself. */ | 116 | * Driver handles dropping of all packets itself. */ |
@@ -129,7 +129,7 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev) | |||
129 | return 0; | 129 | return 0; |
130 | 130 | ||
131 | drop: | 131 | drop: |
132 | tun->stats.tx_dropped++; | 132 | dev->stats.tx_dropped++; |
133 | kfree_skb(skb); | 133 | kfree_skb(skb); |
134 | return 0; | 134 | return 0; |
135 | } | 135 | } |
@@ -172,12 +172,6 @@ tun_net_mclist(struct net_device *dev) | |||
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | static struct net_device_stats *tun_net_stats(struct net_device *dev) | ||
176 | { | ||
177 | struct tun_struct *tun = netdev_priv(dev); | ||
178 | return &tun->stats; | ||
179 | } | ||
180 | |||
181 | /* Initialize net device. */ | 175 | /* Initialize net device. */ |
182 | static void tun_net_init(struct net_device *dev) | 176 | static void tun_net_init(struct net_device *dev) |
183 | { | 177 | { |
@@ -250,14 +244,14 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv, | |||
250 | align = NET_IP_ALIGN; | 244 | align = NET_IP_ALIGN; |
251 | 245 | ||
252 | if (!(skb = alloc_skb(len + align, GFP_KERNEL))) { | 246 | if (!(skb = alloc_skb(len + align, GFP_KERNEL))) { |
253 | tun->stats.rx_dropped++; | 247 | tun->dev->stats.rx_dropped++; |
254 | return -ENOMEM; | 248 | return -ENOMEM; |
255 | } | 249 | } |
256 | 250 | ||
257 | if (align) | 251 | if (align) |
258 | skb_reserve(skb, align); | 252 | skb_reserve(skb, align); |
259 | if (memcpy_fromiovec(skb_put(skb, len), iv, len)) { | 253 | if (memcpy_fromiovec(skb_put(skb, len), iv, len)) { |
260 | tun->stats.rx_dropped++; | 254 | tun->dev->stats.rx_dropped++; |
261 | kfree_skb(skb); | 255 | kfree_skb(skb); |
262 | return -EFAULT; | 256 | return -EFAULT; |
263 | } | 257 | } |
@@ -279,8 +273,8 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv, | |||
279 | netif_rx_ni(skb); | 273 | netif_rx_ni(skb); |
280 | tun->dev->last_rx = jiffies; | 274 | tun->dev->last_rx = jiffies; |
281 | 275 | ||
282 | tun->stats.rx_packets++; | 276 | tun->dev->stats.rx_packets++; |
283 | tun->stats.rx_bytes += len; | 277 | tun->dev->stats.rx_bytes += len; |
284 | 278 | ||
285 | return count; | 279 | return count; |
286 | } | 280 | } |
@@ -336,8 +330,8 @@ static __inline__ ssize_t tun_put_user(struct tun_struct *tun, | |||
336 | skb_copy_datagram_iovec(skb, 0, iv, len); | 330 | skb_copy_datagram_iovec(skb, 0, iv, len); |
337 | total += len; | 331 | total += len; |
338 | 332 | ||
339 | tun->stats.tx_packets++; | 333 | tun->dev->stats.tx_packets++; |
340 | tun->stats.tx_bytes += len; | 334 | tun->dev->stats.tx_bytes += len; |
341 | 335 | ||
342 | return total; | 336 | return total; |
343 | } | 337 | } |
@@ -438,7 +432,6 @@ static void tun_setup(struct net_device *dev) | |||
438 | dev->open = tun_net_open; | 432 | dev->open = tun_net_open; |
439 | dev->hard_start_xmit = tun_net_xmit; | 433 | dev->hard_start_xmit = tun_net_xmit; |
440 | dev->stop = tun_net_close; | 434 | dev->stop = tun_net_close; |
441 | dev->get_stats = tun_net_stats; | ||
442 | dev->ethtool_ops = &tun_ethtool_ops; | 435 | dev->ethtool_ops = &tun_ethtool_ops; |
443 | dev->destructor = free_netdev; | 436 | dev->destructor = free_netdev; |
444 | } | 437 | } |