Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 214767
b: refs/heads/master
c: a7855c7
h: refs/heads/master
i:
  214765: e32b9d9
  214763: 53c12a8
  214759: 6c0d510
  214751: 5297b90
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 27, 2010
1 parent 86d7363 commit 4bad590
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 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: 83180af0b0ea166adf8249f4513beb7355f9b4c9
refs/heads/master: a7855c78a24d6348e989bec616318e68c662e78b
20 changes: 5 additions & 15 deletions trunk/drivers/net/loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ struct pcpu_lstats {
static netdev_tx_t loopback_xmit(struct sk_buff *skb,
struct net_device *dev)
{
struct pcpu_lstats __percpu *pcpu_lstats;
struct pcpu_lstats *lb_stats;
int len;

Expand All @@ -83,8 +82,7 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
skb->protocol = eth_type_trans(skb, dev);

/* it's OK to use per_cpu_ptr() because BHs are off */
pcpu_lstats = (void __percpu __force *)dev->ml_priv;
lb_stats = this_cpu_ptr(pcpu_lstats);
lb_stats = this_cpu_ptr(dev->lstats);

len = skb->len;
if (likely(netif_rx(skb) == NET_RX_SUCCESS)) {
Expand All @@ -101,19 +99,17 @@ static netdev_tx_t loopback_xmit(struct sk_buff *skb,
static struct rtnl_link_stats64 *loopback_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats)
{
const struct pcpu_lstats __percpu *pcpu_lstats;
u64 bytes = 0;
u64 packets = 0;
u64 drops = 0;
int i;

pcpu_lstats = (void __percpu __force *)dev->ml_priv;
for_each_possible_cpu(i) {
const struct pcpu_lstats *lb_stats;
u64 tbytes, tpackets;
unsigned int start;

lb_stats = per_cpu_ptr(pcpu_lstats, i);
lb_stats = per_cpu_ptr(dev->lstats, i);
do {
start = u64_stats_fetch_begin(&lb_stats->syncp);
tbytes = lb_stats->bytes;
Expand Down Expand Up @@ -147,22 +143,16 @@ static const struct ethtool_ops loopback_ethtool_ops = {

static int loopback_dev_init(struct net_device *dev)
{
struct pcpu_lstats __percpu *lstats;

lstats = alloc_percpu(struct pcpu_lstats);
if (!lstats)
dev->lstats = alloc_percpu(struct pcpu_lstats);
if (!dev->lstats)
return -ENOMEM;

dev->ml_priv = (void __force *)lstats;
return 0;
}

static void loopback_dev_free(struct net_device *dev)
{
struct pcpu_lstats __percpu *lstats =
(void __percpu __force *)dev->ml_priv;

free_percpu(lstats);
free_percpu(dev->lstats);
free_netdev(dev);
}

Expand Down
6 changes: 4 additions & 2 deletions trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,10 @@ struct net_device {
#endif

/* mid-layer private */
void *ml_priv;

union {
void *ml_priv;
struct pcpu_lstats __percpu *lstats; /* loopback stats */
};
/* GARP */
struct garp_port *garp_port;

Expand Down

0 comments on commit 4bad590

Please sign in to comment.