]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: mvpp2: debugfs: add hit counter stats for Header Parser entries
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Sat, 14 Jul 2018 11:29:26 +0000 (13:29 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Jul 2018 07:10:01 +0000 (00:10 -0700)
One helpful feature to help debug the Header Parser TCAM filter in PPv2
is to be able to see if the entries did match something when a packet
comes in. This can be done by using the built-in hit counter for TCAM
entries.

This commit implements reading the counter, and exposing its value on
debugfs for each filter entry.

The counter is a 16-bits clear-on-read value, located at:
 .../mvpp2/<controller>/parser/XXX/hits

Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mvpp2/mvpp2.h
drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.h

index 439f14192b08635029c2fba4cb7f7092008c8227..70b3e9cd0d84ba1505345b137376850f76898f53 100644 (file)
@@ -64,6 +64,9 @@
 #define MVPP2_PRS_SRAM_DATA_REG(idx)           (0x1204 + (idx) * 4)
 #define MVPP2_PRS_TCAM_CTRL_REG                        0x1230
 #define     MVPP2_PRS_TCAM_EN_MASK             BIT(0)
+#define MVPP2_PRS_TCAM_HIT_IDX_REG             0x1240
+#define MVPP2_PRS_TCAM_HIT_CNT_REG             0x1244
+#define     MVPP2_PRS_TCAM_HIT_CNT_MASK                GENMASK(15, 0)
 
 /* RSS Registers */
 #define MVPP22_RSS_INDEX                       0x1500
index e8a242b5651915d001ad83d4d881dc4280fa8c4b..af8fb93a8ae2af9385ba94d8a9e45d4776d0167f 100644 (file)
@@ -192,6 +192,22 @@ static int mvpp2_dbgfs_prs_sram_show(struct seq_file *s, void *unused)
 
 DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_sram);
 
+static int mvpp2_dbgfs_prs_hits_show(struct seq_file *s, void *unused)
+{
+       struct mvpp2_dbgfs_prs_entry *entry = s->private;
+       int val;
+
+       val = mvpp2_prs_hits(entry->priv, entry->tid);
+       if (val < 0)
+               return val;
+
+       seq_printf(s, "%d\n", val);
+
+       return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(mvpp2_dbgfs_prs_hits);
+
 static int mvpp2_dbgfs_prs_valid_show(struct seq_file *s, void *unused)
 {
        struct mvpp2_dbgfs_prs_entry *entry = s->private;
@@ -263,6 +279,9 @@ static int mvpp2_dbgfs_prs_entry_init(struct dentry *parent,
        debugfs_create_file("header_data", 0644, prs_entry_dir, entry,
                            &mvpp2_dbgfs_prs_hdata_fops);
 
+       debugfs_create_file("hits", 0444, prs_entry_dir, entry,
+                           &mvpp2_dbgfs_prs_hits_fops);
+
        return 0;
 }
 
index f133d820f0fa043d36377a5c9ab35181096259a5..392fd895f27826e81153f230603fa37b8e921fcc 100644 (file)
@@ -2478,3 +2478,19 @@ int mvpp2_prs_def_flow(struct mvpp2_port *port)
 
        return 0;
 }
+
+int mvpp2_prs_hits(struct mvpp2 *priv, int index)
+{
+       u32 val;
+
+       if (index > MVPP2_PRS_TCAM_SRAM_SIZE)
+               return -EINVAL;
+
+       mvpp2_write(priv, MVPP2_PRS_TCAM_HIT_IDX_REG, index);
+
+       val = mvpp2_read(priv, MVPP2_PRS_TCAM_HIT_CNT_REG);
+
+       val &= MVPP2_PRS_TCAM_HIT_CNT_MASK;
+
+       return val;
+}
index 67b67ccb387d4825d1090e7685b8459cce4ebf82..e22f6c85d380346312147daf531bf6c3626e9589 100644 (file)
@@ -328,4 +328,6 @@ void mvpp2_prs_mac_del_all(struct mvpp2_port *port);
 
 int mvpp2_prs_update_mac_da(struct net_device *dev, const u8 *da);
 
+int mvpp2_prs_hits(struct mvpp2 *priv, int index);
+
 #endif