# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1233847486 0
# Node ID db9857bb03203fd02405fa446b9a63cd268be2b6
# Parent 4f998fd102e24daa471482730d1a3ff68faa1ad6
netback: add ethtool stat to track copied skbs.
Copied skbs should be rare but we have no way of verifying that.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
drivers/xen/netback/common.h | 3 ++
drivers/xen/netback/interface.c | 47 ++++++++++++++++++++++++++++++++++++++++
drivers/xen/netback/netback.c | 6 ++++-
3 files changed, 55 insertions(+), 1 deletion(-)
diff -r 4f998fd102e2 -r db9857bb0320 drivers/xen/netback/common.h
--- a/drivers/xen/netback/common.h Wed Feb 04 12:26:00 2009 +0000
+++ b/drivers/xen/netback/common.h Thu Feb 05 15:24:46 2009 +0000
@@ -94,6 +94,9 @@ typedef struct netif_st {
/* Enforce draining of the transmit queue. */
struct timer_list tx_queue_timeout;
+ /* Statistics */
+ int nr_copied_skbs;
+
/* Miscellaneous private stuff. */
struct list_head list; /* scheduling list */
atomic_t refcnt;
diff -r 4f998fd102e2 -r db9857bb0320 drivers/xen/netback/interface.c
--- a/drivers/xen/netback/interface.c Wed Feb 04 12:26:00 2009 +0000
+++ b/drivers/xen/netback/interface.c Thu Feb 05 15:24:46 2009 +0000
@@ -116,8 +116,51 @@ static int netbk_set_tso(struct net_devi
return ethtool_op_set_tso(dev, data);
}
+static void netbk_get_drvinfo(struct net_device *dev,
+ struct ethtool_drvinfo *info)
+{
+ strcpy(info->driver, "netbk");
+}
+
+static const struct netif_stat {
+ char name[ETH_GSTRING_LEN];
+ u16 offset;
+} netbk_stats[] = {
+ { "copied_skbs", offsetof(netif_t, nr_copied_skbs) },
+};
+
+static int netbk_get_stats_count(struct net_device *dev)
+{
+ return ARRAY_SIZE(netbk_stats);
+}
+
+static void netbk_get_ethtool_stats(struct net_device *dev,
+ struct ethtool_stats *stats, u64 * data)
+{
+ void *netif = netdev_priv(dev);
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(netbk_stats); i++)
+ data[i] = *(int *)(netif + netbk_stats[i].offset);
+}
+
+static void netbk_get_strings(struct net_device *dev, u32 stringset, u8 * data)
+{
+ int i;
+
+ switch (stringset) {
+ case ETH_SS_STATS:
+ for (i = 0; i < ARRAY_SIZE(netbk_stats); i++)
+ memcpy(data + i * ETH_GSTRING_LEN,
+ netbk_stats[i].name, ETH_GSTRING_LEN);
+ break;
+ }
+}
+
static struct ethtool_ops network_ethtool_ops =
{
+ .get_drvinfo = netbk_get_drvinfo,
+
.get_tx_csum = ethtool_op_get_tx_csum,
.set_tx_csum = ethtool_op_set_tx_csum,
.get_sg = ethtool_op_get_sg,
@@ -125,6 +168,10 @@ static struct ethtool_ops network_ethtoo
.get_tso = ethtool_op_get_tso,
.set_tso = netbk_set_tso,
.get_link = ethtool_op_get_link,
+
+ .get_stats_count = netbk_get_stats_count,
+ .get_ethtool_stats = netbk_get_ethtool_stats,
+ .get_strings = netbk_get_strings,
};
netif_t *netif_alloc(domid_t domid, unsigned int handle)
diff -r 4f998fd102e2 -r db9857bb0320 drivers/xen/netback/netback.c
--- a/drivers/xen/netback/netback.c Wed Feb 04 12:26:00 2009 +0000
+++ b/drivers/xen/netback/netback.c Thu Feb 05 15:24:46 2009 +0000
@@ -914,7 +914,11 @@ inline static void net_tx_action_dealloc
if (time_after(inuse->alloc_time + HZ / 2, jiffies))
break;
- switch (copy_pending_req(inuse - pending_inuse)) {
+ pending_idx = inuse - pending_inuse;
+
+ pending_tx_info[pending_idx].netif->nr_copied_skbs++;
+
+ switch (copy_pending_req(pending_idx)) {
case 0:
list_move_tail(&inuse->list, &list);
continue;
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|