All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
@ 2020-07-28  9:48 Ioana Ciornei
  2020-07-28  9:48 ` [PATCH net-next 1/2] dpaa2-eth: add API for stats clear Ioana Ciornei
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Ioana Ciornei @ 2020-07-28  9:48 UTC (permalink / raw)
  To: davem, netdev; +Cc: Ioana Ciornei

This patch set adds debugfs controls for clearing the software and
hardware kept counters.  This is especially useful in the context of
debugging when there is a need for statistics per a run of the test.

Ioana Ciornei (2):
  dpaa2-eth: add API for stats clear
  dpaa2-eth: add reset control for debugfs statistics

 .../freescale/dpaa2/dpaa2-eth-debugfs.c       | 64 +++++++++++++++++++
 .../net/ethernet/freescale/dpaa2/dpni-cmd.h   |  1 +
 drivers/net/ethernet/freescale/dpaa2/dpni.c   | 23 +++++++
 drivers/net/ethernet/freescale/dpaa2/dpni.h   |  4 ++
 4 files changed, 92 insertions(+)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH net-next 1/2] dpaa2-eth: add API for stats clear
  2020-07-28  9:48 [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Ioana Ciornei
@ 2020-07-28  9:48 ` Ioana Ciornei
  2020-07-28  9:48 ` [PATCH net-next 2/2] dpaa2-eth: add reset control for debugfs statistics Ioana Ciornei
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2020-07-28  9:48 UTC (permalink / raw)
  To: davem, netdev; +Cc: Ioana Ciornei

Add the necessary MC API for resetting the DPNI HW counters.
This new function - dpni_reset_statistics - will be used in a subsequent
patch that adds the debugfs controls.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../net/ethernet/freescale/dpaa2/dpni-cmd.h   |  1 +
 drivers/net/ethernet/freescale/dpaa2/dpni.c   | 23 +++++++++++++++++++
 drivers/net/ethernet/freescale/dpaa2/dpni.h   |  4 ++++
 3 files changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
index 593e3812af93..a7c0a37c96d7 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
@@ -68,6 +68,7 @@
 #define DPNI_CMDID_CLR_FS_ENT				DPNI_CMD(0x246)
 
 #define DPNI_CMDID_GET_STATISTICS			DPNI_CMD(0x25D)
+#define DPNI_CMDID_RESET_STATISTICS			DPNI_CMD(0x25E)
 #define DPNI_CMDID_GET_QUEUE				DPNI_CMD(0x25F)
 #define DPNI_CMDID_SET_QUEUE				DPNI_CMD(0x260)
 #define DPNI_CMDID_GET_TAILDROP				DPNI_CMD(0x261)
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpni.c b/drivers/net/ethernet/freescale/dpaa2/dpni.c
index 68ed4c41b282..5a01451b04a6 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpni.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpni.c
@@ -1552,6 +1552,29 @@ int dpni_get_statistics(struct fsl_mc_io *mc_io,
 	return 0;
 }
 
+/**
+ * dpni_reset_statistics() - Clears DPNI statistics
+ * @mc_io:		Pointer to MC portal's I/O object
+ * @cmd_flags:		Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPNI object
+ *
+ * Return:  '0' on Success; Error code otherwise.
+ */
+int dpni_reset_statistics(struct fsl_mc_io *mc_io,
+			  u32 cmd_flags,
+			  u16 token)
+{
+	struct fsl_mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET_STATISTICS,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
 /**
  * dpni_set_taildrop() - Set taildrop per queue or TC
  * @mc_io:	Pointer to MC portal's I/O object
diff --git a/drivers/net/ethernet/freescale/dpaa2/dpni.h b/drivers/net/ethernet/freescale/dpaa2/dpni.h
index 39387991a1f9..bd95c597be3e 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpni.h
+++ b/drivers/net/ethernet/freescale/dpaa2/dpni.h
@@ -496,6 +496,10 @@ int dpni_get_statistics(struct fsl_mc_io	*mc_io,
 			u8			page,
 			union dpni_statistics	*stat);
 
+int dpni_reset_statistics(struct fsl_mc_io *mc_io,
+			  u32 cmd_flags,
+			  u16 token);
+
 /**
  * Enable auto-negotiation
  */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH net-next 2/2] dpaa2-eth: add reset control for debugfs statistics
  2020-07-28  9:48 [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Ioana Ciornei
  2020-07-28  9:48 ` [PATCH net-next 1/2] dpaa2-eth: add API for stats clear Ioana Ciornei
@ 2020-07-28  9:48 ` Ioana Ciornei
  2020-07-28 19:03 ` [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Jakub Kicinski
  2020-07-28 20:26 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2020-07-28  9:48 UTC (permalink / raw)
  To: davem, netdev; +Cc: Ioana Ciornei

Export two debugfs control files through which the user can reset the
software kept statistics per CPU, per FQ, per channel - reset_stats - as
well as those kept by HW - reset_mc_stats.
This is especially useful in the context of debugging when there is a
need for precise statistics per a run of the test.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 .../freescale/dpaa2/dpaa2-eth-debugfs.c       | 64 +++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
index 56d9927fbfda..b1264ddb1ed2 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
@@ -170,6 +170,62 @@ static const struct file_operations dpaa2_dbg_ch_ops = {
 	.release = single_release,
 };
 
+static ssize_t dpaa2_dbg_reset_write(struct file *file, const char __user *buf,
+				     size_t count, loff_t *offset)
+{
+	struct dpaa2_eth_priv *priv = file->private_data;
+	struct dpaa2_eth_drv_stats *percpu_extras;
+	struct rtnl_link_stats64 *percpu_stats;
+	struct dpaa2_eth_channel *ch;
+	struct dpaa2_eth_fq *fq;
+	int i;
+
+	for_each_online_cpu(i) {
+		percpu_stats = per_cpu_ptr(priv->percpu_stats, i);
+		memset(percpu_stats, 0, sizeof(*percpu_stats));
+
+		percpu_extras = per_cpu_ptr(priv->percpu_extras, i);
+		memset(percpu_extras, 0, sizeof(*percpu_extras));
+	}
+
+	for (i = 0; i < priv->num_fqs; i++) {
+		fq = &priv->fq[i];
+		memset(&fq->stats, 0, sizeof(fq->stats));
+	}
+
+	for (i = 0; i < priv->num_channels; i++) {
+		ch = priv->channel[i];
+		memset(&ch->stats, 0, sizeof(ch->stats));
+	}
+
+	return count;
+}
+
+static const struct file_operations dpaa2_dbg_reset_ops = {
+	.open = simple_open,
+	.write = dpaa2_dbg_reset_write,
+};
+
+static ssize_t dpaa2_dbg_reset_mc_write(struct file *file,
+					const char __user *buf,
+					size_t count, loff_t *offset)
+{
+	struct dpaa2_eth_priv *priv = file->private_data;
+	int err;
+
+	err = dpni_reset_statistics(priv->mc_io, 0, priv->mc_token);
+	if (err)
+		netdev_err(priv->net_dev,
+			   "dpni_reset_statistics() failed %d\n", err);
+
+	return count;
+}
+
+static const struct file_operations dpaa2_dbg_reset_mc_ops = {
+	.open = simple_open,
+	.write = dpaa2_dbg_reset_mc_write,
+};
+
 void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
 {
 	struct dentry *dir;
@@ -186,6 +242,14 @@ void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
 
 	/* per-fq stats file */
 	debugfs_create_file("ch_stats", 0444, dir, priv, &dpaa2_dbg_ch_ops);
+
+	/* reset stats */
+	debugfs_create_file("reset_stats", 0200, dir, priv,
+			    &dpaa2_dbg_reset_ops);
+
+	/* reset MC stats */
+	debugfs_create_file("reset_mc_stats", 0200, dir, priv,
+			    &dpaa2_dbg_reset_mc_ops);
 }
 
 void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
  2020-07-28  9:48 [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Ioana Ciornei
  2020-07-28  9:48 ` [PATCH net-next 1/2] dpaa2-eth: add API for stats clear Ioana Ciornei
  2020-07-28  9:48 ` [PATCH net-next 2/2] dpaa2-eth: add reset control for debugfs statistics Ioana Ciornei
@ 2020-07-28 19:03 ` Jakub Kicinski
  2020-07-28 19:33   ` Ioana Ciornei
  2020-07-28 20:26 ` David Miller
  3 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2020-07-28 19:03 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, netdev

On Tue, 28 Jul 2020 12:48:10 +0300 Ioana Ciornei wrote:
> This patch set adds debugfs controls for clearing the software and
> hardware kept counters.  This is especially useful in the context of
> debugging when there is a need for statistics per a run of the test.

No, come on, you know what we're going to say to a debugfs patch like
this...

Is there anything dpaa2-specific here?  We should be able to add a
common API for this.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
  2020-07-28 19:03 ` [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Jakub Kicinski
@ 2020-07-28 19:33   ` Ioana Ciornei
  2020-07-28 19:53     ` Jakub Kicinski
  0 siblings, 1 reply; 8+ messages in thread
From: Ioana Ciornei @ 2020-07-28 19:33 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev

> Subject: Re: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
> 
> On Tue, 28 Jul 2020 12:48:10 +0300 Ioana Ciornei wrote:
> > This patch set adds debugfs controls for clearing the software and
> > hardware kept counters.  This is especially useful in the context of
> > debugging when there is a need for statistics per a run of the test.
> 
> No, come on, you know what we're going to say to a debugfs patch like this...
> 

Eh, I figured it was worth a try since I saw that i40e also supports clearing
the stats through debugfs.

> Is there anything dpaa2-specific here?  We should be able to add a common API
> for this.

No, there is nothing dpaa2-specific. The common API would be in the
'ethtool --reset' area or do you have anything other in mind?

Ioana

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
  2020-07-28 19:33   ` Ioana Ciornei
@ 2020-07-28 19:53     ` Jakub Kicinski
  2020-07-28 20:03       ` Ioana Ciornei
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2020-07-28 19:53 UTC (permalink / raw)
  To: Ioana Ciornei; +Cc: davem, netdev

On Tue, 28 Jul 2020 19:33:46 +0000 Ioana Ciornei wrote:
> > Subject: Re: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
> > No, come on, you know what we're going to say to a debugfs patch like this...
> 
> Eh, I figured it was worth a try since I saw that i40e also supports clearing
> the stats through debugfs.

The stuff that got snuck into i40e is the reason I pay very close
attention to Intel patches these days.

> > Is there anything dpaa2-specific here?  We should be able to add a common API
> > for this.  
> 
> No, there is nothing dpaa2-specific. The common API would be in the
> 'ethtool --reset' area or do you have anything other in mind?

We have this huge ongoing discussion about devlink reset/reload:

https://lore.kernel.org/netdev/1590908625-10952-1-git-send-email-vasundhara-v.volam@broadcom.com/
https://lore.kernel.org/netdev/1595847753-2234-1-git-send-email-moshe@mellanox.com/

Perhaps it could fit in there? I presume your reset is on the device
level? If it's per netdev, I'd personally not be opposed to extending
the ethtool API.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
  2020-07-28 19:53     ` Jakub Kicinski
@ 2020-07-28 20:03       ` Ioana Ciornei
  0 siblings, 0 replies; 8+ messages in thread
From: Ioana Ciornei @ 2020-07-28 20:03 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: davem, netdev

> Subject: Re: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
> 
> On Tue, 28 Jul 2020 19:33:46 +0000 Ioana Ciornei wrote:
> > > Subject: Re: [PATCH net-next 0/2] dpaa2-eth: add reset control for
> > > debugfs stats No, come on, you know what we're going to say to a debugfs
> patch like this...
> >
> > Eh, I figured it was worth a try since I saw that i40e also supports
> > clearing the stats through debugfs.
> 
> The stuff that got snuck into i40e is the reason I pay very close attention to Intel
> patches these days.
> 
> > > Is there anything dpaa2-specific here?  We should be able to add a
> > > common API for this.
> >
> > No, there is nothing dpaa2-specific. The common API would be in the
> > 'ethtool --reset' area or do you have anything other in mind?
> 
> We have this huge ongoing discussion about devlink reset/reload:
> 
> https://lore.kernel.org/netdev/1595847753-2234-1-git-send-email-moshe@mellanox.com/
> 
> Perhaps it could fit in there? I presume your reset is on the device level? If it's
> per netdev, I'd personally not be opposed to extending the ethtool API.

The reset available is per netdev, that is why I was thinking about ethtool rather than devlink.

Ioana





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats
  2020-07-28  9:48 [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Ioana Ciornei
                   ` (2 preceding siblings ...)
  2020-07-28 19:03 ` [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Jakub Kicinski
@ 2020-07-28 20:26 ` David Miller
  3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2020-07-28 20:26 UTC (permalink / raw)
  To: ioana.ciornei; +Cc: netdev

From: Ioana Ciornei <ioana.ciornei@nxp.com>
Date: Tue, 28 Jul 2020 12:48:10 +0300

> This patch set adds debugfs controls for clearing the software and
> hardware kept counters.  This is especially useful in the context of
> debugging when there is a need for statistics per a run of the test.

This is not necessary.

Sample the statistics at the beginning of your test and calculate the
difference at the end of your test.

I'm not applying this, it is not justified at all.

Thank you.



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-28 20:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28  9:48 [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Ioana Ciornei
2020-07-28  9:48 ` [PATCH net-next 1/2] dpaa2-eth: add API for stats clear Ioana Ciornei
2020-07-28  9:48 ` [PATCH net-next 2/2] dpaa2-eth: add reset control for debugfs statistics Ioana Ciornei
2020-07-28 19:03 ` [PATCH net-next 0/2] dpaa2-eth: add reset control for debugfs stats Jakub Kicinski
2020-07-28 19:33   ` Ioana Ciornei
2020-07-28 19:53     ` Jakub Kicinski
2020-07-28 20:03       ` Ioana Ciornei
2020-07-28 20:26 ` David Miller

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.