Stephen Hemminger
2011-Jun-09 00:53 UTC
[Xen-devel] [PATCH 2/9] xen: convert to 64 bit stats interface
Convert xen driver to 64 bit statistics interface.
This driver was already counting packet per queue in a 64 bit value so not
a huge change.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
--- a/drivers/net/xen-netfront.c 2011-06-07 19:34:20.752647705 +0900
+++ b/drivers/net/xen-netfront.c 2011-06-07 20:02:11.028930158 +0900
@@ -122,7 +122,14 @@ struct netfront_info {
struct mmu_update rx_mmu[NET_RX_RING_SIZE];
/* Statistics */
- unsigned long rx_gso_checksum_fixup;
+ u64 rx_packets;
+ u64 rx_bytes;
+ u64 rx_errors;
+ u64 rx_gso_checksum_fixup;
+
+ u64 tx_packets;
+ u64 tx_bytes;
+ u64 tx_dropped;
};
struct netfront_rx_info {
@@ -552,8 +559,8 @@ static int xennet_start_xmit(struct sk_b
if (notify)
notify_remote_via_irq(np->netdev->irq);
- dev->stats.tx_bytes += skb->len;
- dev->stats.tx_packets++;
+ np->tx_bytes += skb->len;
+ np->tx_packets++;
/* Note: It is not safe to access skb after xennet_tx_buf_gc()! */
xennet_tx_buf_gc(dev);
@@ -566,7 +573,7 @@ static int xennet_start_xmit(struct sk_b
return NETDEV_TX_OK;
drop:
- dev->stats.tx_dropped++;
+ np->tx_dropped++;
dev_kfree_skb(skb);
return NETDEV_TX_OK;
}
@@ -847,6 +854,7 @@ out:
static int handle_incoming_queue(struct net_device *dev,
struct sk_buff_head *rxq)
{
+ struct netfront_info *np = netdev_priv(dev);
int packets_dropped = 0;
struct sk_buff *skb;
@@ -867,12 +875,11 @@ static int handle_incoming_queue(struct
if (checksum_setup(dev, skb)) {
kfree_skb(skb);
packets_dropped++;
- dev->stats.rx_errors++;
continue;
}
- dev->stats.rx_packets++;
- dev->stats.rx_bytes += skb->len;
+ np->rx_packets++;
+ np->rx_bytes += skb->len;
/* Pass it up. */
netif_receive_skb(skb);
@@ -919,7 +926,7 @@ static int xennet_poll(struct napi_struc
err:
while ((skb = __skb_dequeue(&tmpq)))
__skb_queue_tail(&errq, skb);
- dev->stats.rx_errors++;
+ np->rx_errors++;
i = np->rx.rsp_cons;
continue;
}
@@ -1034,6 +1041,22 @@ static int xennet_change_mtu(struct net_
return 0;
}
+static struct rtnl_link_stats64 *xennet_get_stats64(struct net_device *dev,
+ struct rtnl_link_stats64 *stats)
+{
+ struct netfront_info *np = netdev_priv(dev);
+
+ stats->rx_packets = np->rx_packets;
+ stats->rx_bytes = np->rx_bytes;
+ stats->rx_errors = np->rx_errors;
+
+ stats->tx_packets = np->tx_packets;
+ stats->tx_bytes = np->tx_bytes;
+ stats->tx_bytes = np->tx_dropped;
+
+ return stats;
+}
+
static void xennet_release_tx_bufs(struct netfront_info *np)
{
struct sk_buff *skb;
@@ -1182,6 +1205,7 @@ static const struct net_device_ops xenne
.ndo_stop = xennet_close,
.ndo_start_xmit = xennet_start_xmit,
.ndo_change_mtu = xennet_change_mtu,
+ .ndo_get_stats64 = xennet_get_stats64,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
.ndo_fix_features = xennet_fix_features,
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Ben Hutchings
2011-Jun-09 01:56 UTC
[Xen-devel] Re: [PATCH 2/9] xen: convert to 64 bit stats interface
On Wed, 2011-06-08 at 17:53 -0700, Stephen Hemminger wrote:> Convert xen driver to 64 bit statistics interface. > This driver was already counting packet per queue in a 64 bit value so not > a huge change.[...] I think this driver will need to use u64_stats_sync. Ben. -- Ben Hutchings, Senior Software Engineer, Solarflare Not speaking for my employer; that''s the marketing department''s job. They asked us to note that Solarflare product names are trademarked. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Konrad Rzeszutek Wilk
2011-Jun-14 21:07 UTC
Re: [Xen-devel] Re: [PATCH 2/9] xen: convert to 64 bit stats interface
On Thu, Jun 09, 2011 at 02:56:45AM +0100, Ben Hutchings wrote:> On Wed, 2011-06-08 at 17:53 -0700, Stephen Hemminger wrote: > > Convert xen driver to 64 bit statistics interface. > > This driver was already counting packet per queue in a 64 bit value so not > > a huge change. > [...] > > I think this driver will need to use u64_stats_sync.Ian? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Ian Campbell
2011-Jun-15 08:38 UTC
Re: [Xen-devel] Re: [PATCH 2/9] xen: convert to 64 bit stats interface
On Tue, 2011-06-14 at 22:07 +0100, Konrad Rzeszutek Wilk wrote:> On Thu, Jun 09, 2011 at 02:56:45AM +0100, Ben Hutchings wrote: > > On Wed, 2011-06-08 at 17:53 -0700, Stephen Hemminger wrote: > > > Convert xen driver to 64 bit statistics interface. > > > This driver was already counting packet per queue in a 64 bit value so not > > > a huge change. > > [...] > > > > I think this driver will need to use u64_stats_sync. > > Ian?I''ll defer to Ben on this, but the case for needing u64_stats_sync for 64 bit values seems reasonable to me. Ian. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel