Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1384173

Re: [PATCH v3] IB/ipoib: Add readout of statistics using ethtool

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3] IB/ipoib: Add readout of statistics using ethtool
Date Thu, 21 Apr 2016 15:00:03 +0200
Message-ID <rqmn9-Rq-11@gated-at.bofh.it> (permalink)
References <ro910-1ni-17@gated-at.bofh.it> <rqkOm-8hw-17@gated-at.bofh.it>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Source-IP aserv0022.oracle.com [141.146.126.234]
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 115
Organization linux.* mail to news gateway
X-Original-Cc Doug Ledford <dledford@redhat.com>, Sean Hefty <sean.hefty@intel.com>, Hal Rosenstock <hal.rosenstock@gmail.com>, Or Gerlitz <ogerlitz@mellanox.com>, Santosh Shilimkar <santosh.shilimkar@oracle.com>, Yuval Shaia <yuval.shaia@oracle.com>, "open list:INFINIBAND SUBSYSTEM" <linux-rdma@vger.kernel.org>, open list <linux-kernel@vger.kernel.org>
X-Original-Date Thu, 21 Apr 2016 14:58:23 +0200
X-Original-Message-ID <5718CE6F.8080105@oracle.com>
X-Original-References <1460715468-16235-1-git-send-email-hans.westgaard.ry@oracle.com> <1461237201-25738-1-git-send-email-hans.westgaard.ry@oracle.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1384173

Show key headers only | View raw


The only difference between v2 and v3 of this patch is
"cosmetics"; When running checkpatch I got an error
  ERROR: code indent should use tabs where possible
#33: FILE: drivers/infiniband/ulp/ipoib/ipoib_ethtool.c:45:
+^I^I        .stat_string = #m, \$

So I decided to make yet another version ( I should of course have ran 
checkpatch before submitting v2)

Hans


On 04/21/2016 01:13 PM, Hans Westgaard Ry wrote:
> IPoIB collects statistics of traffic including number of packets
> sent/received, number of bytes transferred, and certain errors. This
> patch makes these statistics available to be queried by ethtool.
>
> Signed-off-by: Hans Westgaard Ry <hans.westgaard.ry@oracle.com>
> Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
> Reviewed-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
> Tested-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
>   drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 67 ++++++++++++++++++++++++++++
>   1 file changed, 67 insertions(+)
>
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
> index a53fa5f..1502199 100644
> --- a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
> +++ b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
> @@ -36,6 +36,27 @@
>   
>   #include "ipoib.h"
>   
> +struct ipoib_stats {
> +	char stat_string[ETH_GSTRING_LEN];
> +	int stat_offset;
> +};
> +
> +#define IPOIB_NETDEV_STAT(m) { \
> +		.stat_string = #m, \
> +		.stat_offset = offsetof(struct rtnl_link_stats64, m) }
> +
> +static const struct ipoib_stats ipoib_gstrings_stats[] = {
> +	IPOIB_NETDEV_STAT(rx_packets),
> +	IPOIB_NETDEV_STAT(tx_packets),
> +	IPOIB_NETDEV_STAT(rx_bytes),
> +	IPOIB_NETDEV_STAT(tx_bytes),
> +	IPOIB_NETDEV_STAT(tx_errors),
> +	IPOIB_NETDEV_STAT(rx_dropped),
> +	IPOIB_NETDEV_STAT(tx_dropped)
> +};
> +
> +#define IPOIB_GLOBAL_STATS_LEN	ARRAY_SIZE(ipoib_gstrings_stats)
> +
>   static void ipoib_get_drvinfo(struct net_device *netdev,
>   			      struct ethtool_drvinfo *drvinfo)
>   {
> @@ -92,11 +113,57 @@ static int ipoib_set_coalesce(struct net_device *dev,
>   
>   	return 0;
>   }
> +static void ipoib_get_ethtool_stats(struct net_device *dev,
> +				    struct ethtool_stats __always_unused *stats,
> +				    u64 *data)
> +{
> +	int i;
> +	struct net_device_stats *net_stats = &dev->stats;
> +	u8 *p = (u8 *)net_stats;
> +
> +	for (i = 0; i < IPOIB_GLOBAL_STATS_LEN; i++)
> +		data[i] = *(u64 *)(p + ipoib_gstrings_stats[i].stat_offset);
> +
> +}
> +static void ipoib_get_strings(struct net_device __always_unused *dev,
> +			      u32 stringset, u8 *data)
> +{
> +	u8 *p = data;
> +	int i;
> +
> +	switch (stringset) {
> +	case ETH_SS_STATS:
> +		for (i = 0; i < IPOIB_GLOBAL_STATS_LEN; i++) {
> +			memcpy(p, ipoib_gstrings_stats[i].stat_string,
> +				ETH_GSTRING_LEN);
> +			p += ETH_GSTRING_LEN;
> +		}
> +		break;
> +	case ETH_SS_TEST:
> +	default:
> +		break;
> +	}
> +}
> +static int ipoib_get_sset_count(struct net_device __always_unused *dev,
> +				 int sset)
> +{
> +	switch (sset) {
> +	case ETH_SS_STATS:
> +		return IPOIB_GLOBAL_STATS_LEN;
> +	case ETH_SS_TEST:
> +	default:
> +		break;
> +	}
> +	return -EOPNOTSUPP;
> +}
>   
>   static const struct ethtool_ops ipoib_ethtool_ops = {
>   	.get_drvinfo		= ipoib_get_drvinfo,
>   	.get_coalesce		= ipoib_get_coalesce,
>   	.set_coalesce		= ipoib_set_coalesce,
> +	.get_strings		= ipoib_get_strings,
> +	.get_ethtool_stats	= ipoib_get_ethtool_stats,
> +	.get_sset_count		= ipoib_get_sset_count,
>   };
>   
>   void ipoib_set_ethtool_ops(struct net_device *dev)

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v3] IB/ipoib: Add readout of statistics using ethtool Hans Westgaard Ry <hans.westgaard.ry@oracle.com> - 2016-04-21 13:20 +0200
  Re: [PATCH v3] IB/ipoib: Add readout of statistics using ethtool Hans Westgaard Ry <hans.westgaard.ry@oracle.com> - 2016-04-21 15:00 +0200

csiph-web