ia64/linux-2.6.18-xen.hg

changeset 792:db9857bb0320

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@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 05 15:24:46 2009 +0000 (2009-02-05)
parents 4f998fd102e2
children 3aa9b8a7876b
files drivers/xen/netback/common.h drivers/xen/netback/interface.c drivers/xen/netback/netback.c
line diff
     1.1 --- a/drivers/xen/netback/common.h	Wed Feb 04 12:26:00 2009 +0000
     1.2 +++ b/drivers/xen/netback/common.h	Thu Feb 05 15:24:46 2009 +0000
     1.3 @@ -94,6 +94,9 @@ typedef struct netif_st {
     1.4  	/* Enforce draining of the transmit queue. */
     1.5  	struct timer_list tx_queue_timeout;
     1.6  
     1.7 +	/* Statistics */
     1.8 +	int nr_copied_skbs;
     1.9 +
    1.10  	/* Miscellaneous private stuff. */
    1.11  	struct list_head list;  /* scheduling list */
    1.12  	atomic_t         refcnt;
     2.1 --- a/drivers/xen/netback/interface.c	Wed Feb 04 12:26:00 2009 +0000
     2.2 +++ b/drivers/xen/netback/interface.c	Thu Feb 05 15:24:46 2009 +0000
     2.3 @@ -116,8 +116,51 @@ static int netbk_set_tso(struct net_devi
     2.4  	return ethtool_op_set_tso(dev, data);
     2.5  }
     2.6  
     2.7 +static void netbk_get_drvinfo(struct net_device *dev,
     2.8 +			      struct ethtool_drvinfo *info)
     2.9 +{
    2.10 +	strcpy(info->driver, "netbk");
    2.11 +}
    2.12 +
    2.13 +static const struct netif_stat {
    2.14 +	char name[ETH_GSTRING_LEN];
    2.15 +	u16 offset;
    2.16 +} netbk_stats[] = {
    2.17 +	{ "copied_skbs", offsetof(netif_t, nr_copied_skbs) },
    2.18 +};
    2.19 +
    2.20 +static int netbk_get_stats_count(struct net_device *dev)
    2.21 +{
    2.22 +	return ARRAY_SIZE(netbk_stats);
    2.23 +}
    2.24 +
    2.25 +static void netbk_get_ethtool_stats(struct net_device *dev,
    2.26 +				   struct ethtool_stats *stats, u64 * data)
    2.27 +{
    2.28 +	void *netif = netdev_priv(dev);
    2.29 +	int i;
    2.30 +
    2.31 +	for (i = 0; i < ARRAY_SIZE(netbk_stats); i++)
    2.32 +		data[i] = *(int *)(netif + netbk_stats[i].offset);
    2.33 +}
    2.34 +
    2.35 +static void netbk_get_strings(struct net_device *dev, u32 stringset, u8 * data)
    2.36 +{
    2.37 +	int i;
    2.38 +
    2.39 +	switch (stringset) {
    2.40 +	case ETH_SS_STATS:
    2.41 +		for (i = 0; i < ARRAY_SIZE(netbk_stats); i++)
    2.42 +			memcpy(data + i * ETH_GSTRING_LEN,
    2.43 +			       netbk_stats[i].name, ETH_GSTRING_LEN);
    2.44 +		break;
    2.45 +	}
    2.46 +}
    2.47 +
    2.48  static struct ethtool_ops network_ethtool_ops =
    2.49  {
    2.50 +	.get_drvinfo = netbk_get_drvinfo,
    2.51 +
    2.52  	.get_tx_csum = ethtool_op_get_tx_csum,
    2.53  	.set_tx_csum = ethtool_op_set_tx_csum,
    2.54  	.get_sg = ethtool_op_get_sg,
    2.55 @@ -125,6 +168,10 @@ static struct ethtool_ops network_ethtoo
    2.56  	.get_tso = ethtool_op_get_tso,
    2.57  	.set_tso = netbk_set_tso,
    2.58  	.get_link = ethtool_op_get_link,
    2.59 +
    2.60 +	.get_stats_count = netbk_get_stats_count,
    2.61 +	.get_ethtool_stats = netbk_get_ethtool_stats,
    2.62 +	.get_strings = netbk_get_strings,
    2.63  };
    2.64  
    2.65  netif_t *netif_alloc(domid_t domid, unsigned int handle)
     3.1 --- a/drivers/xen/netback/netback.c	Wed Feb 04 12:26:00 2009 +0000
     3.2 +++ b/drivers/xen/netback/netback.c	Thu Feb 05 15:24:46 2009 +0000
     3.3 @@ -914,7 +914,11 @@ inline static void net_tx_action_dealloc
     3.4  			if (time_after(inuse->alloc_time + HZ / 2, jiffies))
     3.5  				break;
     3.6  
     3.7 -			switch (copy_pending_req(inuse - pending_inuse)) {
     3.8 +			pending_idx = inuse - pending_inuse;
     3.9 +
    3.10 +			pending_tx_info[pending_idx].netif->nr_copied_skbs++;
    3.11 +
    3.12 +			switch (copy_pending_req(pending_idx)) {
    3.13  			case 0:
    3.14  				list_move_tail(&inuse->list, &list);
    3.15  				continue;