Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 121892
b: refs/heads/master
c: eeda3fd
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Nov 20, 2008
1 parent ec32014 commit 9358391
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 19 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: d314774cf2cd5dfeb39a00d37deee65d4c627927
refs/heads/master: eeda3fd64f75bcbfaa70ce946513abaf3f23b8e0
4 changes: 2 additions & 2 deletions trunk/arch/s390/appldata/appldata_net_sum.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ static void appldata_get_net_sum_data(void *data)
int i;
struct appldata_net_sum_data *net_data;
struct net_device *dev;
struct net_device_stats *stats;
unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes, rx_errors,
tx_errors, rx_dropped, tx_dropped, collisions;

Expand All @@ -86,7 +85,8 @@ static void appldata_get_net_sum_data(void *data)
collisions = 0;
read_lock(&dev_base_lock);
for_each_netdev(&init_net, dev) {
stats = dev->get_stats(dev);
const struct net_device_stats *stats = dev_get_stats(dev);

rx_packets += stats->rx_packets;
tx_packets += stats->tx_packets;
rx_bytes += stats->rx_bytes;
Expand Down
5 changes: 3 additions & 2 deletions trunk/drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3899,7 +3899,7 @@ static int bond_close(struct net_device *bond_dev)
static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
struct net_device_stats *stats = &(bond->stats), *sstats;
struct net_device_stats *stats = &bond->stats;
struct net_device_stats local_stats;
struct slave *slave;
int i;
Expand All @@ -3909,7 +3909,8 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
read_lock_bh(&bond->lock);

bond_for_each_slave(bond, slave, i) {
sstats = slave->dev->get_stats(slave->dev);
const struct net_device_stats *sstats = dev_get_stats(slave->dev);

local_stats.rx_packets += sstats->rx_packets;
local_stats.rx_bytes += sstats->rx_bytes;
local_stats.rx_errors += sstats->rx_errors;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/sfc/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);

/* Update MAC and NIC statistics */
net_dev->get_stats(net_dev);
dev_get_stats(net_dev);

/* Fill detailed statistics buffer */
for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/parisc/led.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,13 @@ static __inline__ int led_get_net_activity(void)
read_lock(&dev_base_lock);
rcu_read_lock();
for_each_netdev(&init_net, dev) {
struct net_device_stats *stats;
const struct net_device_stats *stats;
struct in_device *in_dev = __in_dev_get_rcu(dev);
if (!in_dev || !in_dev->ifa_list)
continue;
if (ipv4_is_loopback(in_dev->ifa_list->ifa_local))
continue;
stats = dev->get_stats(dev);
stats = dev_get_stats(dev);
rx_total += stats->rx_packets;
tx_total += stats->tx_packets;
}
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,9 @@ struct net_device
unsigned short vid);
#ifdef CONFIG_NET_POLL_CONTROLLER
void (*poll_controller)(struct net_device *dev);
#endif
#endif
};
#endif
};
#define to_net_dev(d) container_of(d, struct net_device, dev)

Expand Down Expand Up @@ -1780,6 +1780,8 @@ extern void netdev_features_change(struct net_device *dev);
/* Load a device via the kmod */
extern void dev_load(struct net *net, const char *name);
extern void dev_mcast_init(void);
extern const struct net_device_stats *dev_get_stats(struct net_device *dev);

extern int netdev_max_backlog;
extern int weight_p;
extern int netdev_set_master(struct net_device *dev, struct net_device *master);
Expand Down
23 changes: 18 additions & 5 deletions trunk/net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2620,7 +2620,7 @@ void dev_seq_stop(struct seq_file *seq, void *v)

static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
{
struct net_device_stats *stats = dev->get_stats(dev);
const struct net_device_stats *stats = dev_get_stats(dev);

seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
"%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
Expand Down Expand Up @@ -4288,10 +4288,24 @@ void netdev_run_todo(void)
}
}

static struct net_device_stats *internal_stats(struct net_device *dev)
{
return &dev->stats;
/**
* dev_get_stats - get network device statistics
* @dev: device to get statistics from
*
* Get network statistics from device. The device driver may provide
* its own method by setting dev->netdev_ops->get_stats; otherwise
* the internal statistics structure is used.
*/
const struct net_device_stats *dev_get_stats(struct net_device *dev)
{
const struct net_device_ops *ops = dev->netdev_ops;

if (ops->ndo_get_stats)
return ops->ndo_get_stats(dev);
else
return &dev->stats;
}
EXPORT_SYMBOL(dev_get_stats);

static void netdev_init_one_queue(struct net_device *dev,
struct netdev_queue *queue,
Expand Down Expand Up @@ -4370,7 +4384,6 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,

netdev_init_queues(dev);

dev->get_stats = internal_stats;
netpoll_netdev_init(dev);
setup(dev);
strcpy(dev->name, name);
Expand Down
3 changes: 1 addition & 2 deletions trunk/net/core/net-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,14 @@ static ssize_t netstat_show(const struct device *d,
unsigned long offset)
{
struct net_device *dev = to_net_dev(d);
struct net_device_stats *stats;
ssize_t ret = -EINVAL;

WARN_ON(offset > sizeof(struct net_device_stats) ||
offset % sizeof(unsigned long) != 0);

read_lock(&dev_base_lock);
if (dev_isalive(dev)) {
stats = dev->get_stats(dev);
const struct net_device_stats *stats = dev_get_stats(dev);
ret = sprintf(buf, fmt_ulong,
*(unsigned long *)(((u8 *) stats) + offset));
}
Expand Down
6 changes: 3 additions & 3 deletions trunk/net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static void set_operstate(struct net_device *dev, unsigned char transition)
}

static void copy_rtnl_link_stats(struct rtnl_link_stats *a,
struct net_device_stats *b)
const struct net_device_stats *b)
{
a->rx_packets = b->rx_packets;
a->tx_packets = b->tx_packets;
Expand Down Expand Up @@ -609,7 +609,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
struct netdev_queue *txq;
struct ifinfomsg *ifm;
struct nlmsghdr *nlh;
struct net_device_stats *stats;
const struct net_device_stats *stats;
struct nlattr *attr;

nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
Expand Down Expand Up @@ -666,7 +666,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
if (attr == NULL)
goto nla_put_failure;

stats = dev->get_stats(dev);
stats = dev_get_stats(dev);
copy_rtnl_link_stats(nla_data(attr), stats);

if (dev->rtnl_link_ops) {
Expand Down

0 comments on commit 9358391

Please sign in to comment.