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

Joe Perches
2016-04-20T07:58:42Z

On Wed, 2016-04-20 at 09:50 +0200, 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.

trivial notes:

> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
[]
> @@ -36,6 +36,31 @@
>
>  #include "ipoib.h"
>
> +struct ipoib_stats {
> + char stat_string[ETH_GSTRING_LEN];
> + int stat_offset;
> +};
> +
> +
> +#define IPOIB_NETDEV_STAT(str, m) { \
> + .stat_string = str, \
> + .stat_offset = offsetof(struct rtnl_link_stats64, m) }
> +
> +
> +

A few unnecessary extra blank lines

> +static const struct ipoib_stats ipoib_gstrings_stats[] = {
> + IPOIB_NETDEV_STAT("rx_packets", rx_packets),
> + IPOIB_NETDEV_STAT("tx_packets", tx_packets),
> + IPOIB_NETDEV_STAT("rx_bytes",   rx_bytes),
> + IPOIB_NETDEV_STAT("tx_bytes",   tx_bytes),
> + IPOIB_NETDEV_STAT("tx_errors",  tx_errors),
> + IPOIB_NETDEV_STAT("rx_dropped", rx_dropped),
> + IPOIB_NETDEV_STAT("tx_dropped", tx_dropped)
> +};

Couldn't the macro could be simplified by using # and
a single argument?

> +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:
> + return -EOPNOTSUPP;
> + }
> +}

Didn't some old versions of gcc complain about reaching
the end of a non-void function?