* [PATCH] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-15 10:17 ` Hans Westgaard Ry
0 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-15 10:17 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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 | 70 ++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index a53fa5f..52a1f30 100644
--- 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) }
+
+
+
+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)
+};
+
+#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 +117,56 @@ 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_TEST:
+ break;
+ 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;
+ }
+}
+static int ipoib_get_sset_count(struct net_device __always_unused *dev,
+ int sset)
+{
+ switch (sset) {
+ case ETH_SS_TEST:
+ return -EOPNOTSUPP;
+ case ETH_SS_STATS:
+ return IPOIB_GLOBAL_STATS_LEN;
+ default:
+ 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)
--
2.4.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-15 10:17 ` Hans Westgaard Ry
0 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-15 10:17 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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 | 70 ++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index a53fa5f..52a1f30 100644
--- 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) }
+
+
+
+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)
+};
+
+#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 +117,56 @@ 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_TEST:
+ break;
+ 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;
+ }
+}
+static int ipoib_get_sset_count(struct net_device __always_unused *dev,
+ int sset)
+{
+ switch (sset) {
+ case ETH_SS_TEST:
+ return -EOPNOTSUPP;
+ case ETH_SS_STATS:
+ return IPOIB_GLOBAL_STATS_LEN;
+ default:
+ 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)
--
2.4.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] IB/ipoib: Add readout of statistics using ethtool
2016-04-15 10:17 ` Hans Westgaard Ry
@ 2016-04-19 14:50 ` Erez Shitrit
-1 siblings, 0 replies; 17+ messages in thread
From: Erez Shitrit @ 2016-04-19 14:50 UTC (permalink / raw)
To: Hans Westgaard Ry
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Or Gerlitz,
Santosh Shilimkar, Yuval Shaia, open list:INFINIBAND SUBSYSTEM,
open list
On Fri, Apr 15, 2016 at 1:17 PM, Hans Westgaard Ry
<hans.westgaard.ry-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Santosh Shilimkar <santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Tested-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Acked-by: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> ---
> drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 70 ++++++++++++++++++++++++++++
> 1 file changed, 70 insertions(+)
>
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
> index a53fa5f..52a1f30 100644
> --- 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) }
> +
> +
> +
> +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)
> +};
> +
> +#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 +117,56 @@ 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_TEST:
> + break;
> + 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;
> + }
> +}
> +static int ipoib_get_sset_count(struct net_device __always_unused *dev,
> + int sset)
> +{
> + switch (sset) {
> + case ETH_SS_TEST:
> + return -EOPNOTSUPP;
> + case ETH_SS_STATS:
> + return IPOIB_GLOBAL_STATS_LEN;
> + default:
> + 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)
> --
> 2.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-19 14:50 ` Erez Shitrit
0 siblings, 0 replies; 17+ messages in thread
From: Erez Shitrit @ 2016-04-19 14:50 UTC (permalink / raw)
To: Hans Westgaard Ry
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Or Gerlitz,
Santosh Shilimkar, Yuval Shaia, open list:INFINIBAND SUBSYSTEM,
open list
On Fri, Apr 15, 2016 at 1:17 PM, Hans Westgaard Ry
<hans.westgaard.ry@oracle.com> 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>
Acked-by: Erez Shitrit <erezsh@mellanox.com>
> ---
> drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 70 ++++++++++++++++++++++++++++
> 1 file changed, 70 insertions(+)
>
> diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
> index a53fa5f..52a1f30 100644
> --- 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) }
> +
> +
> +
> +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)
> +};
> +
> +#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 +117,56 @@ 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_TEST:
> + break;
> + 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;
> + }
> +}
> +static int ipoib_get_sset_count(struct net_device __always_unused *dev,
> + int sset)
> +{
> + switch (sset) {
> + case ETH_SS_TEST:
> + return -EOPNOTSUPP;
> + case ETH_SS_STATS:
> + return IPOIB_GLOBAL_STATS_LEN;
> + default:
> + 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)
> --
> 2.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] IB/ipoib: Add readout of statistics using ethtool
2016-04-19 14:50 ` Erez Shitrit
@ 2016-04-19 17:33 ` Leon Romanovsky
-1 siblings, 0 replies; 17+ messages in thread
From: Leon Romanovsky @ 2016-04-19 17:33 UTC (permalink / raw)
To: Erez Shitrit
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
[-- Attachment #1: Type: text/plain, Size: 945 bytes --]
On Tue, Apr 19, 2016 at 05:50:23PM +0300, Erez Shitrit wrote:
> On Fri, Apr 15, 2016 at 1:17 PM, Hans Westgaard Ry
> <hans.westgaard.ry-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> 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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> > Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> > Reviewed-by: Santosh Shilimkar <santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> > Tested-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
>
> Acked-by: Erez Shitrit <erezsh-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Hans is planning to send slightly (cosmetic change) different
version of this patch.
Thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-19 17:33 ` Leon Romanovsky
0 siblings, 0 replies; 17+ messages in thread
From: Leon Romanovsky @ 2016-04-19 17:33 UTC (permalink / raw)
To: Erez Shitrit
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
[-- Attachment #1: Type: text/plain, Size: 773 bytes --]
On Tue, Apr 19, 2016 at 05:50:23PM +0300, Erez Shitrit wrote:
> On Fri, Apr 15, 2016 at 1:17 PM, Hans Westgaard Ry
> <hans.westgaard.ry@oracle.com> 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>
>
> Acked-by: Erez Shitrit <erezsh@mellanox.com>
Hans is planning to send slightly (cosmetic change) different
version of this patch.
Thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v1] IB/ipoib: Add readout of statistics using ethtool
2016-04-15 10:17 ` Hans Westgaard Ry
@ 2016-04-20 7:50 ` Hans Westgaard Ry
-1 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-20 7:50 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Tested-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
drivers/infiniband/ulp/ipoib/ipoib_ethtool.c | 69 ++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index a53fa5f..3240877 100644
--- 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) }
+
+
+
+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)
+};
+
+#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 +117,55 @@ 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_TEST:
+ break;
+ 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;
+ }
+}
+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;
+ }
+}
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)
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v1] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-20 7:50 ` Hans Westgaard Ry
0 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-20 7:50 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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 | 69 ++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index a53fa5f..3240877 100644
--- 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) }
+
+
+
+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)
+};
+
+#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 +117,55 @@ 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_TEST:
+ break;
+ 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;
+ }
+}
+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;
+ }
+}
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)
--
2.4.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v1] IB/ipoib: Add readout of statistics using ethtool
2016-04-20 7:50 ` Hans Westgaard Ry
(?)
@ 2016-04-20 7:58 ` Joe Perches
-1 siblings, 0 replies; 17+ messages in thread
From: Joe Perches @ 2016-04-20 7:58 UTC (permalink / raw)
To: Hans Westgaard Ry
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Or Gerlitz,
Santosh Shilimkar, Yuval Shaia, open list:INFINIBAND SUBSYSTEM,
open list
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?
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2] IB/ipoib: Add readout of statistics using ethtool
2016-04-15 10:17 ` Hans Westgaard Ry
@ 2016-04-20 10:09 ` Hans Westgaard Ry
-1 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-20 10:09 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Tested-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
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..f66440b 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)
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v2] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-20 10:09 ` Hans Westgaard Ry
0 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-20 10:09 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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..f66440b 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)
--
2.4.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3] IB/ipoib: Add readout of statistics using ethtool
2016-04-15 10:17 ` Hans Westgaard Ry
@ 2016-04-21 11:13 ` Hans Westgaard Ry
-1 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-21 11:13 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Reviewed-by: Santosh Shilimkar <santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Tested-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
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)
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-21 11:13 ` Hans Westgaard Ry
0 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-21 11:13 UTC (permalink / raw)
Cc: Hans Westgaard Ry, Doug Ledford, Sean Hefty, Hal Rosenstock,
Or Gerlitz, Santosh Shilimkar, Yuval Shaia,
open list:INFINIBAND SUBSYSTEM, open list
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)
--
2.4.3
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v3] IB/ipoib: Add readout of statistics using ethtool
2016-04-21 11:13 ` Hans Westgaard Ry
@ 2016-04-21 12:58 ` Hans Westgaard Ry
-1 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-21 12:58 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Or Gerlitz,
Santosh Shilimkar, Yuval Shaia, open list:INFINIBAND SUBSYSTEM,
open list
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-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Santosh Shilimkar <santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> Tested-by: Yuval Shaia <yuval.shaia-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> ---
> 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)
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3] IB/ipoib: Add readout of statistics using ethtool
@ 2016-04-21 12:58 ` Hans Westgaard Ry
0 siblings, 0 replies; 17+ messages in thread
From: Hans Westgaard Ry @ 2016-04-21 12:58 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, Or Gerlitz,
Santosh Shilimkar, Yuval Shaia, open list:INFINIBAND SUBSYSTEM,
open list
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)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3] IB/ipoib: Add readout of statistics using ethtool
2016-04-21 11:13 ` Hans Westgaard Ry
@ 2016-05-12 20:10 ` Doug Ledford
-1 siblings, 0 replies; 17+ messages in thread
From: Doug Ledford @ 2016-05-12 20:10 UTC (permalink / raw)
To: Hans Westgaard Ry
Cc: Sean Hefty, Hal Rosenstock, Or Gerlitz, Santosh Shilimkar,
Yuval Shaia, INFINIBAND SUBSYSTEM, open list
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
On 04/21/2016 07:13 AM, 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(+)
Thanks, applied.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: 0E572FDD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v3] IB/ipoib: Add readout of statistics using ethtool
@ 2016-05-12 20:10 ` Doug Ledford
0 siblings, 0 replies; 17+ messages in thread
From: Doug Ledford @ 2016-05-12 20:10 UTC (permalink / raw)
To: Hans Westgaard Ry
Cc: Sean Hefty, Hal Rosenstock, Or Gerlitz, Santosh Shilimkar,
Yuval Shaia, INFINIBAND SUBSYSTEM, open list,
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
On 04/21/2016 07:13 AM, 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(+)
Thanks, applied.
--
Doug Ledford <dledford@redhat.com>
GPG KeyID: 0E572FDD
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2016-05-12 20:10 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-15 10:17 [PATCH] IB/ipoib: Add readout of statistics using ethtool Hans Westgaard Ry
2016-04-15 10:17 ` Hans Westgaard Ry
[not found] ` <1460715468-16235-1-git-send-email-hans.westgaard.ry-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-04-19 14:50 ` Erez Shitrit
2016-04-19 14:50 ` Erez Shitrit
[not found] ` <CAAk-MO-RuWB_ecPr02Tr5brwv6E9dJWg+06=tpoxW1Ec=O3dUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-19 17:33 ` Leon Romanovsky
2016-04-19 17:33 ` Leon Romanovsky
2016-04-20 7:50 ` [PATCH v1] " Hans Westgaard Ry
2016-04-20 7:50 ` Hans Westgaard Ry
2016-04-20 7:58 ` Joe Perches
2016-04-20 10:09 ` [PATCH v2] " Hans Westgaard Ry
2016-04-20 10:09 ` Hans Westgaard Ry
2016-04-21 11:13 ` [PATCH v3] " Hans Westgaard Ry
2016-04-21 11:13 ` Hans Westgaard Ry
[not found] ` <1461237201-25738-1-git-send-email-hans.westgaard.ry-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2016-04-21 12:58 ` Hans Westgaard Ry
2016-04-21 12:58 ` Hans Westgaard Ry
2016-05-12 20:10 ` Doug Ledford
2016-05-12 20:10 ` Doug Ledford
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.