Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 40047
b: refs/heads/master
c: 5175c37
h: refs/heads/master
i:
  40045: 1e25399
  40043: f98eb6d
  40039: ceb9549
  40031: 18b265a
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 19, 2006
1 parent 1b920dc commit c9b9da4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9ce8ade015a3f82dbdf856df7a685878dd1cc0e1
refs/heads/master: 5175c3786c244f8b689854db24c9e79b1c6a084f
35 changes: 19 additions & 16 deletions trunk/drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@
#include <linux/tcp.h>
#include <linux/percpu.h>

static DEFINE_PER_CPU(struct net_device_stats, loopback_stats);
struct pcpu_lstats {
unsigned long packets;
unsigned long bytes;
};
static DEFINE_PER_CPU(struct pcpu_lstats, pcpu_lstats);

#define LOOPBACK_OVERHEAD (128 + MAX_HEADER + 16 + 16)

Expand Down Expand Up @@ -128,7 +132,7 @@ static void emulate_large_send_offload(struct sk_buff *skb)
*/
static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct net_device_stats *lb_stats;
struct pcpu_lstats *lb_stats;

skb_orphan(skb);

Expand All @@ -149,11 +153,9 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev)
#endif
dev->last_rx = jiffies;

lb_stats = &per_cpu(loopback_stats, get_cpu());
lb_stats->rx_bytes += skb->len;
lb_stats->tx_bytes = lb_stats->rx_bytes;
lb_stats->rx_packets++;
lb_stats->tx_packets = lb_stats->rx_packets;
lb_stats = &per_cpu(pcpu_lstats, get_cpu());
lb_stats->bytes += skb->len;
lb_stats->packets++;
put_cpu();

netif_rx(skb);
Expand All @@ -166,20 +168,21 @@ static struct net_device_stats loopback_stats;
static struct net_device_stats *get_stats(struct net_device *dev)
{
struct net_device_stats *stats = &loopback_stats;
unsigned long bytes = 0;
unsigned long packets = 0;
int i;

memset(stats, 0, sizeof(struct net_device_stats));

for_each_possible_cpu(i) {
struct net_device_stats *lb_stats;
const struct pcpu_lstats *lb_stats;

lb_stats = &per_cpu(loopback_stats, i);
stats->rx_bytes += lb_stats->rx_bytes;
stats->tx_bytes += lb_stats->tx_bytes;
stats->rx_packets += lb_stats->rx_packets;
stats->tx_packets += lb_stats->tx_packets;
lb_stats = &per_cpu(pcpu_lstats, i);
bytes += lb_stats->bytes;
packets += lb_stats->packets;
}

stats->rx_packets = packets;
stats->tx_packets = packets;
stats->rx_bytes = bytes;
stats->tx_bytes = bytes;
return stats;
}

Expand Down

0 comments on commit c9b9da4

Please sign in to comment.