Patchwork [v2] tile: handle 64-bit statistics in tilepro network driver

login
register
mail settings
Submitter Chris Metcalf
Date July 25, 2013, 4:41 p.m.
Message ID <201307251642.r6PGgHx2002404@farm-0012.internal.tilera.com>
Download mbox | patch
Permalink /patch/261793/
State Accepted
Delegated to: David Miller
Headers show

Comments

Chris Metcalf - July 25, 2013, 4:41 p.m.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
---
v2: use <linux/u64_stats_sync.h> primitives

 drivers/net/ethernet/tile/tilepro.c | 77 ++++++++++++++++++++++++++-----------
 1 file changed, 54 insertions(+), 23 deletions(-)
David Miller - July 30, 2013, 11:16 p.m.
From: Chris Metcalf <cmetcalf@tilera.com>
Date: Thu, 25 Jul 2013 12:41:15 -0400

> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>

Applied, thanks.

Your PTP patch for the Tile driver doesn't even come close to
applying properly to net-next, please respin it and report if
you want me to apply it.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Chris Metcalf - July 31, 2013, 12:34 a.m.
On 7/30/2013 7:16 PM, David Miller wrote:
> From: Chris Metcalf <cmetcalf@tilera.com>
> Date: Thu, 25 Jul 2013 12:41:15 -0400
>
>> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
> Applied, thanks.
>
> Your PTP patch for the Tile driver doesn't even come close to
> applying properly to net-next, please respin it and report if
> you want me to apply it.
>
> Thanks.

It might be easiest to pull the whole series from:

  git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile.git tile-net-next

Chris Metcalf (13):
      tile: handle 64-bit statistics in tilepro network driver
      tile: support rx_dropped/rx_errors in tilepro net driver
      tile: avoid bug in tilepro net driver built with old hypervisor
      tile: remove dead is_dup_ack() function from tilepro net driver
      tile: support jumbo frames in the tilegx network driver
      tile: update dev->stats directly in tilegx network driver
      tile: fix panic bug in napi support for tilegx network driver
      tile: enable GRO in the tilegx network driver
      tile: support multiple mPIPE shims in tilegx network driver
      tile: support TSO for IPv6 in tilegx network driver
      tile: make "tile_net.custom" a proper bool module parameter
      tile: remove deprecated NETIF_F_LLTX flag from tile drivers
      tile: support PTP using the tilegx mPIPE (IEEE 1588)

 arch/tile/gxio/iorpc_mpipe.c              |   66 ++
 arch/tile/gxio/iorpc_mpipe_info.c         |   18 +
 arch/tile/gxio/mpipe.c                    |   43 +-
 arch/tile/include/gxio/iorpc_mpipe.h      |   14 +-
 arch/tile/include/gxio/iorpc_mpipe_info.h |    4 +
 arch/tile/include/gxio/mpipe.h            |  143 +++-
 arch/tile/include/hv/drv_mpipe_intf.h     |    3 +
 drivers/net/ethernet/tile/Kconfig         |   11 +
 drivers/net/ethernet/tile/tilegx.c        | 1097 +++++++++++++++++++----------
 drivers/net/ethernet/tile/tilepro.c       |  206 ++----
 10 files changed, 1100 insertions(+), 505 deletions(-)

Aside from the tilepro 64-bit stats change, and the PTP change, the other
changes didn't receive any substantive feedback.  (Eric Dumazet pointed
out that explicit NETIF_F_GRO was unnecessary, so I removed it.)
David Miller - July 31, 2013, 12:36 a.m.
From: Chris Metcalf <cmetcalf@tilera.com>
Date: Tue, 30 Jul 2013 20:34:52 -0400

> On 7/30/2013 7:16 PM, David Miller wrote:
>> From: Chris Metcalf <cmetcalf@tilera.com>
>> Date: Thu, 25 Jul 2013 12:41:15 -0400
>>
>>> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
>> Applied, thanks.
>>
>> Your PTP patch for the Tile driver doesn't even come close to
>> applying properly to net-next, please respin it and report if
>> you want me to apply it.
>>
>> Thanks.
> 
> It might be easiest to pull the whole series from:

No Chris, you have to freshly post the patches as a series here when
you want me to pull something.

That way it actually can get reviewed.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/ethernet/tile/tilepro.c b/drivers/net/ethernet/tile/tilepro.c
index 3643549..f66ac20 100644
--- a/drivers/net/ethernet/tile/tilepro.c
+++ b/drivers/net/ethernet/tile/tilepro.c
@@ -31,6 +31,7 @@ 
 #include <linux/in6.h>
 #include <linux/timer.h>
 #include <linux/io.h>
+#include <linux/u64_stats_sync.h>
 #include <asm/checksum.h>
 #include <asm/homecache.h>
 
@@ -156,10 +157,13 @@  struct tile_netio_queue {
  * Statistics counters for a specific cpu and device.
  */
 struct tile_net_stats_t {
-	u32 rx_packets;
-	u32 rx_bytes;
-	u32 tx_packets;
-	u32 tx_bytes;
+	struct u64_stats_sync syncp;
+	u64 rx_packets;		/* total packets received	*/
+	u64 tx_packets;		/* total packets transmitted	*/
+	u64 rx_bytes;		/* total bytes received 	*/
+	u64 tx_bytes;		/* total bytes transmitted	*/
+	u64 rx_errors;		/* packets truncated or marked bad by hw */
+	u64 rx_dropped;		/* packets not for us or intf not up */
 };
 
 
@@ -218,8 +222,6 @@  struct tile_net_priv {
 	int network_cpus_count;
 	/* Credits per network cpu. */
 	int network_cpus_credits;
-	/* Network stats. */
-	struct net_device_stats stats;
 	/* For NetIO bringup retries. */
 	struct delayed_work retry_work;
 	/* Quick access to per cpu data. */
@@ -847,6 +849,8 @@  static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
 		}
 	}
 
+	u64_stats_update_begin(&stats->syncp);
+
 	if (filter) {
 
 		/* ISSUE: Update "drop" statistics? */
@@ -881,6 +885,8 @@  static bool tile_net_poll_aux(struct tile_net_cpu *info, int index)
 		stats->rx_bytes += len;
 	}
 
+	u64_stats_update_end(&stats->syncp);
+
 	/* ISSUE: It would be nice to defer this until the packet has */
 	/* actually been processed. */
 	tile_net_return_credit(info);
@@ -1907,8 +1913,10 @@  busy:
 		kfree_skb(olds[i]);
 
 	/* Update stats. */
+	u64_stats_update_begin(&stats->syncp);
 	stats->tx_packets += num_segs;
 	stats->tx_bytes += (num_segs * sh_len) + d_len;
+	u64_stats_update_end(&stats->syncp);
 
 	/* Make sure the egress timer is scheduled. */
 	tile_net_schedule_egress_timer(info);
@@ -2089,8 +2097,10 @@  busy:
 		kfree_skb(olds[i]);
 
 	/* HACK: Track "expanded" size for short packets (e.g. 42 < 60). */
+	u64_stats_update_begin(&stats->syncp);
 	stats->tx_packets++;
 	stats->tx_bytes += ((len >= ETH_ZLEN) ? len : ETH_ZLEN);
+	u64_stats_update_end(&stats->syncp);
 
 	/* Make sure the egress timer is scheduled. */
 	tile_net_schedule_egress_timer(info);
@@ -2127,30 +2137,51 @@  static int tile_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  *
  * Returns the address of the device statistics structure.
  */
-static struct net_device_stats *tile_net_get_stats(struct net_device *dev)
+static struct rtnl_link_stats64 *tile_net_get_stats64(struct net_device *dev,
+		struct rtnl_link_stats64 *stats)
 {
 	struct tile_net_priv *priv = netdev_priv(dev);
-	u32 rx_packets = 0;
-	u32 tx_packets = 0;
-	u32 rx_bytes = 0;
-	u32 tx_bytes = 0;
+	u64 rx_packets = 0, tx_packets = 0;
+	u64 rx_bytes = 0, tx_bytes = 0;
+	u64 rx_errors = 0, rx_dropped = 0;
 	int i;
 
 	for_each_online_cpu(i) {
-		if (priv->cpu[i]) {
-			rx_packets += priv->cpu[i]->stats.rx_packets;
-			rx_bytes += priv->cpu[i]->stats.rx_bytes;
-			tx_packets += priv->cpu[i]->stats.tx_packets;
-			tx_bytes += priv->cpu[i]->stats.tx_bytes;
-		}
+		struct tile_net_stats_t *cpu_stats;
+		u64 trx_packets, ttx_packets, trx_bytes, ttx_bytes;
+		u64 trx_errors, trx_dropped;
+		unsigned int start;
+
+		if (priv->cpu[i] == NULL)
+			continue;
+		cpu_stats = &priv->cpu[i]->stats;
+
+		do {
+			start = u64_stats_fetch_begin_bh(&cpu_stats->syncp);
+			trx_packets = cpu_stats->rx_packets;
+			ttx_packets = cpu_stats->tx_packets;
+			trx_bytes   = cpu_stats->rx_bytes;
+			ttx_bytes   = cpu_stats->tx_bytes;
+			trx_errors  = cpu_stats->rx_errors;
+			trx_dropped = cpu_stats->rx_dropped;
+		} while (u64_stats_fetch_retry_bh(&cpu_stats->syncp, start));
+
+		rx_packets += trx_packets;
+		tx_packets += ttx_packets;
+		rx_bytes   += trx_bytes;
+		tx_bytes   += ttx_bytes;
+		rx_errors  += trx_errors;
+		rx_dropped += trx_dropped;
 	}
 
-	priv->stats.rx_packets = rx_packets;
-	priv->stats.rx_bytes = rx_bytes;
-	priv->stats.tx_packets = tx_packets;
-	priv->stats.tx_bytes = tx_bytes;
+	stats->rx_packets = rx_packets;
+	stats->tx_packets = tx_packets;
+	stats->rx_bytes   = rx_bytes;
+	stats->tx_bytes   = tx_bytes;
+	stats->rx_errors  = rx_errors;
+	stats->rx_dropped = rx_dropped;
 
-	return &priv->stats;
+	return stats;
 }
 
 
@@ -2287,7 +2318,7 @@  static const struct net_device_ops tile_net_ops = {
 	.ndo_stop = tile_net_stop,
 	.ndo_start_xmit = tile_net_tx,
 	.ndo_do_ioctl = tile_net_ioctl,
-	.ndo_get_stats = tile_net_get_stats,
+	.ndo_get_stats64 = tile_net_get_stats64,
 	.ndo_change_mtu = tile_net_change_mtu,
 	.ndo_tx_timeout = tile_net_tx_timeout,
 	.ndo_set_mac_address = tile_net_set_mac_address,