01d7b01c28c02833e00c63524b88fc643de571bf
[openwrt/staging/ynezz.git] /
1 From aa80ddbb30e9ffd75e2dcaa58abf6383a5520942 Mon Sep 17 00:00:00 2001
2 From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
3 Date: Wed, 13 Feb 2019 12:23:41 +0200
4 Subject: [PATCH] dpaa2-eth: Add reset controls for debugfs stats
5
6 Allow the user to reset statistics counters through debugfs entries.
7
8 Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
9 ---
10 .../ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c | 64 ++++++++++++++++++++++
11 1 file changed, 64 insertions(+)
12
13 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
14 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth-debugfs.c
15 @@ -167,6 +167,62 @@ static const struct file_operations dpaa
16 .release = single_release,
17 };
18
19 +static ssize_t dpaa2_dbg_reset_write(struct file *file, const char __user *buf,
20 + size_t count, loff_t *offset)
21 +{
22 + struct dpaa2_eth_priv *priv = file->private_data;
23 + struct rtnl_link_stats64 *percpu_stats;
24 + struct dpaa2_eth_drv_stats *percpu_extras;
25 + struct dpaa2_eth_fq *fq;
26 + struct dpaa2_eth_channel *ch;
27 + int i;
28 +
29 + for_each_online_cpu(i) {
30 + percpu_stats = per_cpu_ptr(priv->percpu_stats, i);
31 + memset(percpu_stats, 0, sizeof(*percpu_stats));
32 +
33 + percpu_extras = per_cpu_ptr(priv->percpu_extras, i);
34 + memset(percpu_extras, 0, sizeof(*percpu_extras));
35 + }
36 +
37 + for (i = 0; i < priv->num_fqs; i++) {
38 + fq = &priv->fq[i];
39 + memset(&fq->stats, 0, sizeof(fq->stats));
40 + }
41 +
42 + for (i = 0; i < priv->num_channels; i++) {
43 + ch = priv->channel[i];
44 + memset(&ch->stats, 0, sizeof(ch->stats));
45 + }
46 +
47 + return count;
48 +}
49 +
50 +static const struct file_operations dpaa2_dbg_reset_ops = {
51 + .open = simple_open,
52 + .write = dpaa2_dbg_reset_write,
53 +};
54 +
55 +static ssize_t dpaa2_dbg_reset_mc_write(struct file *file,
56 + const char __user *buf,
57 + size_t count, loff_t *offset)
58 +{
59 + struct dpaa2_eth_priv *priv = file->private_data;
60 + int err;
61 +
62 + err = dpni_reset_statistics(priv->mc_io, 0, priv->mc_token);
63 + if (err)
64 + netdev_err(priv->net_dev,
65 + "dpni_reset_statistics() failed %d\n", err);
66 +
67 + return count;
68 +}
69 +
70 +static const struct file_operations dpaa2_dbg_reset_mc_ops = {
71 + .open = simple_open,
72 + .write = dpaa2_dbg_reset_mc_write,
73 +};
74 +
75 void dpaa2_dbg_add(struct dpaa2_eth_priv *priv)
76 {
77 struct dentry *dir;
78 @@ -183,6 +239,14 @@ void dpaa2_dbg_add(struct dpaa2_eth_priv
79
80 /* per-fq stats file */
81 debugfs_create_file("ch_stats", 0444, dir, priv, &dpaa2_dbg_ch_ops);
82 +
83 + /* reset stats */
84 + debugfs_create_file("reset_stats", 0200, dir, priv,
85 + &dpaa2_dbg_reset_ops);
86 +
87 + /* reset MC stats */
88 + debugfs_create_file("reset_mc_stats", 0222, dir, priv,
89 + &dpaa2_dbg_reset_mc_ops);
90 }
91
92 void dpaa2_dbg_remove(struct dpaa2_eth_priv *priv)