Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 259709
b: refs/heads/master
c: 9079ce6
h: refs/heads/master
i:
  259707: 8d946af
v: v3
  • Loading branch information
K. Y. Srinivasan authored and Greg Kroah-Hartman committed Jul 5, 2011
1 parent fff7086 commit ce3913b
Show file tree
Hide file tree
Showing 2 changed files with 10 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: 46d2eb6d82ef44be58ae192c35e8cd52485f02eb
refs/heads/master: 9079ce691255792009c446d8c3382507b8d38635
16 changes: 9 additions & 7 deletions trunk/drivers/staging/hv/netvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include <linux/init.h>
#include <linux/atomic.h>
#include <linux/module.h>
#include <linux/highmem.h>
#include <linux/device.h>
Expand All @@ -45,7 +46,7 @@
struct net_device_context {
/* point back to our device context */
struct hv_device *device_ctx;
unsigned long avail;
atomic_t avail;
struct delayed_work dwork;
};

Expand Down Expand Up @@ -118,8 +119,9 @@ static void netvsc_xmit_completion(void *context)

dev_kfree_skb_any(skb);

net_device_ctx->avail += num_pages;
if (net_device_ctx->avail >= PACKET_PAGES_HIWATER)
atomic_add(num_pages, &net_device_ctx->avail);
if (atomic_read(&net_device_ctx->avail) >=
PACKET_PAGES_HIWATER)
netif_wake_queue(net);
}
}
Expand All @@ -133,7 +135,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)

/* Add 1 for skb->data and additional one for RNDIS */
num_pages = skb_shinfo(skb)->nr_frags + 1 + 1;
if (num_pages > net_device_ctx->avail)
if (num_pages > atomic_read(&net_device_ctx->avail))
return NETDEV_TX_BUSY;

/* Allocate a netvsc packet based on # of frags. */
Expand Down Expand Up @@ -185,8 +187,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
net->stats.tx_bytes += skb->len;
net->stats.tx_packets++;

net_device_ctx->avail -= num_pages;
if (net_device_ctx->avail < PACKET_PAGES_LOWATER)
atomic_sub(num_pages, &net_device_ctx->avail);
if (atomic_read(&net_device_ctx->avail) < PACKET_PAGES_LOWATER)
netif_stop_queue(net);
} else {
/* we are shutting down or bus overloaded, just drop packet */
Expand Down Expand Up @@ -345,7 +347,7 @@ static int netvsc_probe(struct hv_device *dev)

net_device_ctx = netdev_priv(net);
net_device_ctx->device_ctx = dev;
net_device_ctx->avail = ring_size;
atomic_set(&net_device_ctx->avail, ring_size);
dev_set_drvdata(&dev->device, net);
INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp);

Expand Down

0 comments on commit ce3913b

Please sign in to comment.