WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] netback: add ethtool stat to track copied skbs

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] netback: add ethtool stat to track copied skbs
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 05 Feb 2009 15:12:08 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Thu, 05 Feb 2009 07:12:35 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1233846695 0
# Node ID 7a24febd95d5abfc03e05de7fa991b11cef14eef
# 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>

diff -r 4f998fd102e2 -r 7a24febd95d5 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:11:35 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 7a24febd95d5 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:11:35 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 7a24febd95d5 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:11:35 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] netback: add ethtool stat to track copied skbs, Ian Campbell <=