Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d83345ad authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: add dev_txq_stats_fold() helper



Some drivers ndo_get_stats() method need to perform txqueue stats folding.

Move folding from dev_get_stats() to a new dev_txq_stats_fold() function

Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b038b040
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -1941,6 +1941,7 @@ extern void netdev_features_change(struct net_device *dev);
extern void		dev_load(struct net *net, const char *name);
extern void		dev_load(struct net *net, const char *name);
extern void		dev_mcast_init(void);
extern void		dev_mcast_init(void);
extern const struct net_device_stats *dev_get_stats(struct net_device *dev);
extern const struct net_device_stats *dev_get_stats(struct net_device *dev);
extern void		dev_txq_stats_fold(const struct net_device *dev, struct net_device_stats *stats);


extern int		netdev_max_backlog;
extern int		netdev_max_backlog;
extern int		weight_p;
extern int		weight_p;
+29 −19
Original line number Original line Diff line number Diff line
@@ -5169,22 +5169,14 @@ void netdev_run_todo(void)
}
}


/**
/**
 *	dev_get_stats	- get network device statistics
 *	dev_txq_stats_fold - fold tx_queues stats
 *	@dev: device to get statistics from
 *	@dev: device to get statistics from
 *
 *	@stats: struct net_device_stats to hold results
 *	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)
void dev_txq_stats_fold(const struct net_device *dev,
			struct net_device_stats *stats)
{
{
	const struct net_device_ops *ops = dev->netdev_ops;

	if (ops->ndo_get_stats)
		return ops->ndo_get_stats(dev);
	else {
	unsigned long tx_bytes = 0, tx_packets = 0, tx_dropped = 0;
	unsigned long tx_bytes = 0, tx_packets = 0, tx_dropped = 0;
		struct net_device_stats *stats = &dev->stats;
	unsigned int i;
	unsigned int i;
	struct netdev_queue *txq;
	struct netdev_queue *txq;


@@ -5199,8 +5191,26 @@ const struct net_device_stats *dev_get_stats(struct net_device *dev)
		stats->tx_packets = tx_packets;
		stats->tx_packets = tx_packets;
		stats->tx_dropped = tx_dropped;
		stats->tx_dropped = tx_dropped;
	}
	}
		return stats;
}
}
EXPORT_SYMBOL(dev_txq_stats_fold);

/**
 *	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);

	dev_txq_stats_fold(dev, &dev->stats);
	return &dev->stats;
}
}
EXPORT_SYMBOL(dev_get_stats);
EXPORT_SYMBOL(dev_get_stats);