@@ -81,19 +81,18 @@ static void appldata_get_net_sum_data(void *data)
netif_lists_lock(&init_net);
for_each_netdev(&init_net, dev) {
- const struct rtnl_link_stats64 *stats;
- struct rtnl_link_stats64 temp;
-
- stats = dev_get_stats(dev, &temp);
- rx_packets += stats->rx_packets;
- tx_packets += stats->tx_packets;
- rx_bytes += stats->rx_bytes;
- tx_bytes += stats->tx_bytes;
- rx_errors += stats->rx_errors;
- tx_errors += stats->tx_errors;
- rx_dropped += stats->rx_dropped;
- tx_dropped += stats->tx_dropped;
- collisions += stats->collisions;
+ struct rtnl_link_stats64 stats;
+
+ dev_get_stats(dev, &stats);
+ rx_packets += stats.rx_packets;
+ tx_packets += stats.tx_packets;
+ rx_bytes += stats.rx_bytes;
+ tx_bytes += stats.tx_bytes;
+ rx_errors += stats.rx_errors;
+ tx_errors += stats.tx_errors;
+ rx_dropped += stats.rx_dropped;
+ tx_dropped += stats.tx_dropped;
+ collisions += stats.collisions;
i++;
}
@@ -347,9 +347,8 @@ static void netdev_trig_work(struct work_struct *work)
{
struct led_netdev_data *trigger_data =
container_of(work, struct led_netdev_data, work.work);
- struct rtnl_link_stats64 *dev_stats;
+ struct rtnl_link_stats64 dev_stats;
unsigned int new_activity;
- struct rtnl_link_stats64 temp;
unsigned long interval;
int invert;
@@ -364,12 +363,12 @@ static void netdev_trig_work(struct work_struct *work)
!test_bit(NETDEV_LED_RX, &trigger_data->mode))
return;
- dev_stats = dev_get_stats(trigger_data->net_dev, &temp);
+ dev_get_stats(trigger_data->net_dev, &dev_stats);
new_activity =
(test_bit(NETDEV_LED_TX, &trigger_data->mode) ?
- dev_stats->tx_packets : 0) +
+ dev_stats.tx_packets : 0) +
(test_bit(NETDEV_LED_RX, &trigger_data->mode) ?
- dev_stats->rx_packets : 0);
+ dev_stats.rx_packets : 0);
if (trigger_data->last_activity != new_activity) {
led_stop_software_blink(trigger_data->led_cdev);
@@ -3753,13 +3753,12 @@ static void bond_get_stats(struct net_device *bond_dev,
memcpy(stats, &bond->bond_stats, sizeof(*stats));
bond_for_each_slave_rcu(bond, slave, iter) {
- const struct rtnl_link_stats64 *new =
- dev_get_stats(slave->dev, &temp);
+ dev_get_stats(slave->dev, &temp);
- bond_fold_stats(stats, new, &slave->slave_stats);
+ bond_fold_stats(stats, &temp, &slave->slave_stats);
/* save off the slave stats for the next run */
- memcpy(&slave->slave_stats, new, sizeof(*new));
+ memcpy(&slave->slave_stats, &temp, sizeof(temp));
}
memcpy(&bond->bond_stats, stats, sizeof(*stats));
@@ -839,8 +839,7 @@ static void hns_get_ethtool_stats(struct net_device *netdev,
u64 *p = data;
struct hns_nic_priv *priv = netdev_priv(netdev);
struct hnae_handle *h = priv->ae_handle;
- const struct rtnl_link_stats64 *net_stats;
- struct rtnl_link_stats64 temp;
+ struct rtnl_link_stats64 net_stats;
if (!h->dev->ops->get_stats || !h->dev->ops->update_stats) {
netdev_err(netdev, "get_stats or update_stats is null!\n");
@@ -849,32 +848,32 @@ static void hns_get_ethtool_stats(struct net_device *netdev,
h->dev->ops->update_stats(h, &netdev->stats);
- net_stats = dev_get_stats(netdev, &temp);
+ dev_get_stats(netdev, &net_stats);
/* get netdev statistics */
- p[0] = net_stats->rx_packets;
- p[1] = net_stats->tx_packets;
- p[2] = net_stats->rx_bytes;
- p[3] = net_stats->tx_bytes;
- p[4] = net_stats->rx_errors;
- p[5] = net_stats->tx_errors;
- p[6] = net_stats->rx_dropped;
- p[7] = net_stats->tx_dropped;
- p[8] = net_stats->multicast;
- p[9] = net_stats->collisions;
- p[10] = net_stats->rx_over_errors;
- p[11] = net_stats->rx_crc_errors;
- p[12] = net_stats->rx_frame_errors;
- p[13] = net_stats->rx_fifo_errors;
- p[14] = net_stats->rx_missed_errors;
- p[15] = net_stats->tx_aborted_errors;
- p[16] = net_stats->tx_carrier_errors;
- p[17] = net_stats->tx_fifo_errors;
- p[18] = net_stats->tx_heartbeat_errors;
- p[19] = net_stats->rx_length_errors;
- p[20] = net_stats->tx_window_errors;
- p[21] = net_stats->rx_compressed;
- p[22] = net_stats->tx_compressed;
+ p[0] = net_stats.rx_packets;
+ p[1] = net_stats.tx_packets;
+ p[2] = net_stats.rx_bytes;
+ p[3] = net_stats.tx_bytes;
+ p[4] = net_stats.rx_errors;
+ p[5] = net_stats.tx_errors;
+ p[6] = net_stats.rx_dropped;
+ p[7] = net_stats.tx_dropped;
+ p[8] = net_stats.multicast;
+ p[9] = net_stats.collisions;
+ p[10] = net_stats.rx_over_errors;
+ p[11] = net_stats.rx_crc_errors;
+ p[12] = net_stats.rx_frame_errors;
+ p[13] = net_stats.rx_fifo_errors;
+ p[14] = net_stats.rx_missed_errors;
+ p[15] = net_stats.tx_aborted_errors;
+ p[16] = net_stats.tx_carrier_errors;
+ p[17] = net_stats.tx_fifo_errors;
+ p[18] = net_stats.tx_heartbeat_errors;
+ p[19] = net_stats.rx_length_errors;
+ p[20] = net_stats.tx_window_errors;
+ p[21] = net_stats.rx_compressed;
+ p[22] = net_stats.tx_compressed;
p[23] = netdev->rx_dropped.counter;
p[24] = netdev->tx_dropped.counter;
@@ -1295,19 +1295,18 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data)
{
struct ixgbe_adapter *adapter = netdev_priv(netdev);
- struct rtnl_link_stats64 temp;
- const struct rtnl_link_stats64 *net_stats;
+ struct rtnl_link_stats64 net_stats;
unsigned int start;
struct ixgbe_ring *ring;
int i, j;
char *p = NULL;
ixgbe_update_stats(adapter);
- net_stats = dev_get_stats(netdev, &temp);
+ dev_get_stats(netdev, &net_stats);
for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) {
switch (ixgbe_gstrings_stats[i].type) {
case NETDEV_STATS:
- p = (char *) net_stats +
+ p = (char *) &net_stats +
ixgbe_gstrings_stats[i].stat_offset;
break;
case IXGBE_STATS:
@@ -420,19 +420,18 @@ static void ixgbevf_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data)
{
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
- struct rtnl_link_stats64 temp;
- const struct rtnl_link_stats64 *net_stats;
+ struct rtnl_link_stats64 net_stats;
unsigned int start;
struct ixgbevf_ring *ring;
int i, j;
char *p;
ixgbevf_update_stats(adapter);
- net_stats = dev_get_stats(netdev, &temp);
+ dev_get_stats(netdev, &net_stats);
for (i = 0; i < IXGBEVF_GLOBAL_STATS_LEN; i++) {
switch (ixgbevf_gstrings_stats[i].type) {
case NETDEV_STATS:
- p = (char *)net_stats +
+ p = (char *)&net_stats +
ixgbevf_gstrings_stats[i].stat_offset;
break;
case IXGBEVF_STATS:
@@ -183,7 +183,6 @@ static void net_failover_get_stats(struct net_device *dev,
struct rtnl_link_stats64 *stats)
{
struct net_failover_info *nfo_info = netdev_priv(dev);
- const struct rtnl_link_stats64 *new;
struct rtnl_link_stats64 temp;
struct net_device *slave_dev;
@@ -194,16 +193,16 @@ static void net_failover_get_stats(struct net_device *dev,
slave_dev = rcu_dereference(nfo_info->primary_dev);
if (slave_dev) {
- new = dev_get_stats(slave_dev, &temp);
- net_failover_fold_stats(stats, new, &nfo_info->primary_stats);
- memcpy(&nfo_info->primary_stats, new, sizeof(*new));
+ dev_get_stats(slave_dev, &temp);
+ net_failover_fold_stats(stats, &temp, &nfo_info->primary_stats);
+ memcpy(&nfo_info->primary_stats, &temp, sizeof(temp));
}
slave_dev = rcu_dereference(nfo_info->standby_dev);
if (slave_dev) {
- new = dev_get_stats(slave_dev, &temp);
- net_failover_fold_stats(stats, new, &nfo_info->standby_stats);
- memcpy(&nfo_info->standby_stats, new, sizeof(*new));
+ dev_get_stats(slave_dev, &temp);
+ net_failover_fold_stats(stats, &temp, &nfo_info->standby_stats);
+ memcpy(&nfo_info->standby_stats, &temp, sizeof(temp));
}
rcu_read_unlock();
@@ -360,8 +360,7 @@ static __inline__ int led_get_net_activity(void)
for_each_netdev(&init_net, dev) {
struct in_device *in_dev = in_dev_get(dev);
- const struct rtnl_link_stats64 *stats;
- struct rtnl_link_stats64 temp;
+ struct rtnl_link_stats64 stats;
if (!in_dev || !in_dev->ifa_list ||
ipv4_is_loopback(in_dev->ifa_list->ifa_local)) {
@@ -371,9 +370,9 @@ static __inline__ int led_get_net_activity(void)
in_dev_put(in_dev);
- stats = dev_get_stats(dev, &temp);
- rx_total += stats->rx_packets;
- tx_total += stats->tx_packets;
+ dev_get_stats(dev, &stats);
+ rx_total += stats.rx_packets;
+ tx_total += stats.tx_packets;
}
netif_lists_unlock(&init_net);
@@ -170,11 +170,11 @@ void __fcoe_get_lesb(struct fc_lport *lport,
struct fc_els_lesb *fc_lesb,
struct net_device *netdev)
{
+ struct rtnl_link_stats64 dev_stats;
unsigned int cpu;
u32 lfc, vlfc, mdac;
struct fc_stats *stats;
struct fcoe_fc_els_lesb *lesb;
- struct rtnl_link_stats64 temp;
lfc = 0;
vlfc = 0;
@@ -190,8 +190,8 @@ void __fcoe_get_lesb(struct fc_lport *lport,
lesb->lesb_link_fail = htonl(lfc);
lesb->lesb_vlink_fail = htonl(vlfc);
lesb->lesb_miss_fka = htonl(mdac);
- lesb->lesb_fcs_error =
- htonl(dev_get_stats(netdev, &temp)->rx_crc_errors);
+ dev_get_stats(netdev, &dev_stats);
+ lesb->lesb_fcs_error = htonl(dev_stats.rx_crc_errors);
}
EXPORT_SYMBOL_GPL(__fcoe_get_lesb);
@@ -169,14 +169,13 @@ static const u32 oid_supported_list[] = {
static int gen_ndis_query_resp(struct rndis_params *params, u32 OID, u8 *buf,
unsigned buf_len, rndis_resp_t *r)
{
+ struct rtnl_link_stats64 stats;
int retval = -ENOTSUPP;
u32 length = 4; /* usually */
__le32 *outbuf;
int i, count;
rndis_query_cmplt_type *resp;
struct net_device *net;
- struct rtnl_link_stats64 temp;
- const struct rtnl_link_stats64 *stats;
if (!r) return -ENOMEM;
resp = (rndis_query_cmplt_type *)r->buf;
@@ -199,7 +198,7 @@ static int gen_ndis_query_resp(struct rndis_params *params, u32 OID, u8 *buf,
resp->InformationBufferOffset = cpu_to_le32(16);
net = params->dev;
- stats = dev_get_stats(net, &temp);
+ dev_get_stats(net, &stats);
switch (OID) {
@@ -353,51 +352,41 @@ static int gen_ndis_query_resp(struct rndis_params *params, u32 OID, u8 *buf,
case RNDIS_OID_GEN_XMIT_OK:
if (rndis_debug > 1)
pr_debug("%s: RNDIS_OID_GEN_XMIT_OK\n", __func__);
- if (stats) {
- *outbuf = cpu_to_le32(stats->tx_packets
- - stats->tx_errors - stats->tx_dropped);
- retval = 0;
- }
+ *outbuf = cpu_to_le32(stats.tx_packets - stats.tx_errors -
+ stats.tx_dropped);
+ retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_RCV_OK:
if (rndis_debug > 1)
pr_debug("%s: RNDIS_OID_GEN_RCV_OK\n", __func__);
- if (stats) {
- *outbuf = cpu_to_le32(stats->rx_packets
- - stats->rx_errors - stats->rx_dropped);
- retval = 0;
- }
+ *outbuf = cpu_to_le32(stats.rx_packets - stats.rx_errors -
+ stats.rx_dropped);
+ retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_XMIT_ERROR:
if (rndis_debug > 1)
pr_debug("%s: RNDIS_OID_GEN_XMIT_ERROR\n", __func__);
- if (stats) {
- *outbuf = cpu_to_le32(stats->tx_errors);
- retval = 0;
- }
+ *outbuf = cpu_to_le32(stats.tx_errors);
+ retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_RCV_ERROR:
if (rndis_debug > 1)
pr_debug("%s: RNDIS_OID_GEN_RCV_ERROR\n", __func__);
- if (stats) {
- *outbuf = cpu_to_le32(stats->rx_errors);
- retval = 0;
- }
+ *outbuf = cpu_to_le32(stats.rx_errors);
+ retval = 0;
break;
/* mandatory */
case RNDIS_OID_GEN_RCV_NO_BUFFER:
pr_debug("%s: RNDIS_OID_GEN_RCV_NO_BUFFER\n", __func__);
- if (stats) {
- *outbuf = cpu_to_le32(stats->rx_dropped);
- retval = 0;
- }
+ *outbuf = cpu_to_le32(stats.rx_dropped);
+ retval = 0;
break;
/* ieee802.3 OIDs (table 4-3) */
@@ -449,10 +438,8 @@ static int gen_ndis_query_resp(struct rndis_params *params, u32 OID, u8 *buf,
/* mandatory */
case RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT:
pr_debug("%s: RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT\n", __func__);
- if (stats) {
- *outbuf = cpu_to_le32(stats->rx_frame_errors);
- retval = 0;
- }
+ *outbuf = cpu_to_le32(stats.rx_frame_errors);
+ retval = 0;
break;
/* mandatory */
@@ -4545,8 +4545,7 @@ void netdev_notify_peers(struct net_device *dev);
void netdev_features_change(struct net_device *dev);
/* Load a device via the kmod */
void dev_load(struct net *net, const char *name);
-struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
- struct rtnl_link_stats64 *storage);
+void dev_get_stats(struct net_device *dev, struct rtnl_link_stats64 *storage);
void netdev_stats_to_stats64(struct rtnl_link_stats64 *stats64,
const struct net_device_stats *netdev_stats);
void dev_fetch_sw_netstats(struct rtnl_link_stats64 *s,
@@ -242,26 +242,25 @@ static int vlandev_seq_show(struct seq_file *seq, void *offset)
{
struct net_device *vlandev = (struct net_device *) seq->private;
const struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
- struct rtnl_link_stats64 temp;
- const struct rtnl_link_stats64 *stats;
static const char fmt64[] = "%30s %12llu\n";
+ struct rtnl_link_stats64 stats;
int i;
if (!is_vlan_dev(vlandev))
return 0;
- stats = dev_get_stats(vlandev, &temp);
+ dev_get_stats(vlandev, &stats);
seq_printf(seq,
"%s VID: %d REORDER_HDR: %i dev->priv_flags: %hx\n",
vlandev->name, vlan->vlan_id,
(int)(vlan->flags & 1), vlandev->priv_flags);
- seq_printf(seq, fmt64, "total frames received", stats->rx_packets);
- seq_printf(seq, fmt64, "total bytes received", stats->rx_bytes);
- seq_printf(seq, fmt64, "Broadcast/Multicast Rcvd", stats->multicast);
+ seq_printf(seq, fmt64, "total frames received", stats.rx_packets);
+ seq_printf(seq, fmt64, "total bytes received", stats.rx_bytes);
+ seq_printf(seq, fmt64, "Broadcast/Multicast Rcvd", stats.multicast);
seq_puts(seq, "\n");
- seq_printf(seq, fmt64, "total frames transmitted", stats->tx_packets);
- seq_printf(seq, fmt64, "total bytes transmitted", stats->tx_bytes);
+ seq_printf(seq, fmt64, "total frames transmitted", stats.tx_packets);
+ seq_printf(seq, fmt64, "total bytes transmitted", stats.tx_bytes);
seq_printf(seq, "Device: %s", vlan->real_dev->name);
/* now show all PRIORITY mappings relating to this VLAN */
seq_printf(seq, "\nINGRESS priority mappings: "
@@ -10398,13 +10398,12 @@ EXPORT_SYMBOL(netdev_stats_to_stats64);
* @dev: device to get statistics from
* @storage: place to store stats
*
- * Get network statistics from device. Return @storage.
+ * Get network statistics from device.
* The device driver may provide its own method by setting
* dev->netdev_ops->get_stats64 or dev->netdev_ops->get_stats;
* otherwise the internal statistics structure is used.
*/
-struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
- struct rtnl_link_stats64 *storage)
+void dev_get_stats(struct net_device *dev, struct rtnl_link_stats64 *storage)
{
const struct net_device_ops *ops = dev->netdev_ops;
@@ -10419,7 +10418,6 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
storage->rx_dropped += (unsigned long)atomic_long_read(&dev->rx_dropped);
storage->tx_dropped += (unsigned long)atomic_long_read(&dev->tx_dropped);
storage->rx_nohandler += (unsigned long)atomic_long_read(&dev->rx_nohandler);
- return storage;
}
EXPORT_SYMBOL(dev_get_stats);
@@ -80,26 +80,27 @@ static 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 rtnl_link_stats64 temp;
- const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
+ struct rtnl_link_stats64 stats;
+
+ dev_get_stats(dev, &stats);
seq_printf(seq, "%6s: %7llu %7llu %4llu %4llu %4llu %5llu %10llu %9llu "
"%8llu %7llu %4llu %4llu %4llu %5llu %7llu %10llu\n",
- dev->name, stats->rx_bytes, stats->rx_packets,
- stats->rx_errors,
- stats->rx_dropped + stats->rx_missed_errors,
- stats->rx_fifo_errors,
- stats->rx_length_errors + stats->rx_over_errors +
- stats->rx_crc_errors + stats->rx_frame_errors,
- stats->rx_compressed, stats->multicast,
- stats->tx_bytes, stats->tx_packets,
- stats->tx_errors, stats->tx_dropped,
- stats->tx_fifo_errors, stats->collisions,
- stats->tx_carrier_errors +
- stats->tx_aborted_errors +
- stats->tx_window_errors +
- stats->tx_heartbeat_errors,
- stats->tx_compressed);
+ dev->name, stats.rx_bytes, stats.rx_packets,
+ stats.rx_errors,
+ stats.rx_dropped + stats.rx_missed_errors,
+ stats.rx_fifo_errors,
+ stats.rx_length_errors + stats.rx_over_errors +
+ stats.rx_crc_errors + stats.rx_frame_errors,
+ stats.rx_compressed, stats.multicast,
+ stats.tx_bytes, stats.tx_packets,
+ stats.tx_errors, stats.tx_dropped,
+ stats.tx_fifo_errors, stats.collisions,
+ stats.tx_carrier_errors +
+ stats.tx_aborted_errors +
+ stats.tx_window_errors +
+ stats.tx_heartbeat_errors,
+ stats.tx_compressed);
}
/*
@@ -586,10 +586,11 @@ static ssize_t netstat_show(const struct device *d,
offset % sizeof(u64) != 0);
if (dev_isalive(dev)) {
- struct rtnl_link_stats64 temp;
- const struct rtnl_link_stats64 *stats = dev_get_stats(dev, &temp);
+ struct rtnl_link_stats64 stats;
- ret = sprintf(buf, fmt_u64, *(u64 *)(((u8 *)stats) + offset));
+ dev_get_stats(dev, &stats);
+
+ ret = sprintf(buf, fmt_u64, *(u64 *)(((u8 *)&stats) + offset));
}
return ret;
@@ -269,19 +269,18 @@ void ovs_vport_del(struct vport *vport)
*/
void ovs_vport_get_stats(struct vport *vport, struct ovs_vport_stats *stats)
{
- const struct rtnl_link_stats64 *dev_stats;
- struct rtnl_link_stats64 temp;
-
- dev_stats = dev_get_stats(vport->dev, &temp);
- stats->rx_errors = dev_stats->rx_errors;
- stats->tx_errors = dev_stats->tx_errors;
- stats->tx_dropped = dev_stats->tx_dropped;
- stats->rx_dropped = dev_stats->rx_dropped;
-
- stats->rx_bytes = dev_stats->rx_bytes;
- stats->rx_packets = dev_stats->rx_packets;
- stats->tx_bytes = dev_stats->tx_bytes;
- stats->tx_packets = dev_stats->tx_packets;
+ struct rtnl_link_stats64 dev_stats;
+
+ dev_get_stats(vport->dev, &dev_stats);
+ stats->rx_errors = dev_stats.rx_errors;
+ stats->tx_errors = dev_stats.tx_errors;
+ stats->tx_dropped = dev_stats.tx_dropped;
+ stats->rx_dropped = dev_stats.rx_dropped;
+
+ stats->rx_bytes = dev_stats.rx_bytes;
+ stats->rx_packets = dev_stats.rx_packets;
+ stats->tx_bytes = dev_stats.tx_bytes;
+ stats->tx_packets = dev_stats.tx_packets;
}
/**