Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 310757
b: refs/heads/master
c: 83a2705
h: refs/heads/master
i:
  310755: c8277de
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jun 11, 2012
1 parent 150bc4a commit e2451b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 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: 7dbb491878a2c51d372a8890fa45a8ff80358af1
refs/heads/master: 83a27052c3376793bc879e00e6e6805d6fb7aab9
19 changes: 12 additions & 7 deletions trunk/drivers/net/virtio_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ module_param(gso, bool, 0444);
#define VIRTNET_DRIVER_VERSION "1.0.0"

struct virtnet_stats {
struct u64_stats_sync syncp;
struct u64_stats_sync tx_syncp;
struct u64_stats_sync rx_syncp;
u64 tx_bytes;
u64 tx_packets;

Expand Down Expand Up @@ -300,10 +301,10 @@ static void receive_buf(struct net_device *dev, void *buf, unsigned int len)

hdr = skb_vnet_hdr(skb);

u64_stats_update_begin(&stats->syncp);
u64_stats_update_begin(&stats->rx_syncp);
stats->rx_bytes += skb->len;
stats->rx_packets++;
u64_stats_update_end(&stats->syncp);
u64_stats_update_end(&stats->rx_syncp);

if (hdr->hdr.flags & VIRTIO_NET_HDR_F_NEEDS_CSUM) {
pr_debug("Needs csum!\n");
Expand Down Expand Up @@ -565,10 +566,10 @@ static unsigned int free_old_xmit_skbs(struct virtnet_info *vi)
while ((skb = virtqueue_get_buf(vi->svq, &len)) != NULL) {
pr_debug("Sent skb %p\n", skb);

u64_stats_update_begin(&stats->syncp);
u64_stats_update_begin(&stats->tx_syncp);
stats->tx_bytes += skb->len;
stats->tx_packets++;
u64_stats_update_end(&stats->syncp);
u64_stats_update_end(&stats->tx_syncp);

tot_sgs += skb_vnet_hdr(skb)->num_sg;
dev_kfree_skb_any(skb);
Expand Down Expand Up @@ -703,12 +704,16 @@ static struct rtnl_link_stats64 *virtnet_stats(struct net_device *dev,
u64 tpackets, tbytes, rpackets, rbytes;

do {
start = u64_stats_fetch_begin(&stats->syncp);
start = u64_stats_fetch_begin(&stats->tx_syncp);
tpackets = stats->tx_packets;
tbytes = stats->tx_bytes;
} while (u64_stats_fetch_retry(&stats->tx_syncp, start));

do {
start = u64_stats_fetch_begin(&stats->rx_syncp);
rpackets = stats->rx_packets;
rbytes = stats->rx_bytes;
} while (u64_stats_fetch_retry(&stats->syncp, start));
} while (u64_stats_fetch_retry(&stats->rx_syncp, start));

tot->rx_packets += rpackets;
tot->tx_packets += tpackets;
Expand Down

0 comments on commit e2451b2

Please sign in to comment.