Commit cc98419a authored by David S. Miller's avatar David S. Miller

Merge branch 'mvpp2-add-debugfs-interface'

Maxime Chevallier says:

====================
net: mvpp2: add debugfs interface

The PPv2 Header Parser and Classifier are not straightforward to debug,
having easy access to some of the many lookup tables configuration is
helpful during development and debug.

This series adds a basic debugfs interface, allowing to read data from
the Header Parser and some of the Classifier tables.

For now, the interface is read-only, and contains only some basic info.

This was actually used during RSS development, and might be useful to
troubleshoot some issues we might find.

The first patch of the series converts the mvpp2 files to SPDX, which
eases adding the new debugfs dedicated file.

The second patch adds the interface, and exposes basic Header Parser data.

The 3rd patch adds a hit counter for the Header Parser TCAM.

The 4th patch exposes classifier info.

The 5th patch adds some hit counters for some of the classifier engines.

Changes since V1:
- Rebased on the lastest net-next
- Made cls_flow_get non static so that it can be used in mvpp2_debugfs
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 2aa4a337 f9d30d5b
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
# #
obj-$(CONFIG_MVPP2) := mvpp2.o obj-$(CONFIG_MVPP2) := mvpp2.o
mvpp2-objs := mvpp2_main.o mvpp2_prs.o mvpp2_cls.o mvpp2-objs := mvpp2_main.o mvpp2_prs.o mvpp2_cls.o mvpp2_debugfs.o
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* Definitions for Marvell PPv2 network controller for Armada 375 SoC. * Definitions for Marvell PPv2 network controller for Armada 375 SoC.
* *
* Copyright (C) 2014 Marvell * Copyright (C) 2014 Marvell
* *
* Marcin Wojtas <mw@semihalf.com> * Marcin Wojtas <mw@semihalf.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/ */
#ifndef _MVPP2_H_ #ifndef _MVPP2_H_
#define _MVPP2_H_ #define _MVPP2_H_
...@@ -67,6 +64,9 @@ ...@@ -67,6 +64,9 @@
#define MVPP2_PRS_SRAM_DATA_REG(idx) (0x1204 + (idx) * 4) #define MVPP2_PRS_SRAM_DATA_REG(idx) (0x1204 + (idx) * 4)
#define MVPP2_PRS_TCAM_CTRL_REG 0x1230 #define MVPP2_PRS_TCAM_CTRL_REG 0x1230
#define MVPP2_PRS_TCAM_EN_MASK BIT(0) #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 */ /* RSS Registers */
#define MVPP22_RSS_INDEX 0x1500 #define MVPP22_RSS_INDEX 0x1500
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
#define MVPP22_CLS_C2_TCAM_DATA3 0x1b1c #define MVPP22_CLS_C2_TCAM_DATA3 0x1b1c
#define MVPP22_CLS_C2_TCAM_DATA4 0x1b20 #define MVPP22_CLS_C2_TCAM_DATA4 0x1b20
#define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8) #define MVPP22_CLS_C2_PORT_ID(port) ((port) << 8)
#define MVPP22_CLS_C2_HIT_CTR 0x1b50
#define MVPP22_CLS_C2_ACT 0x1b60 #define MVPP22_CLS_C2_ACT 0x1b60
#define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19) #define MVPP22_CLS_C2_ACT_RSS_EN(act) (((act) & 0x3) << 19)
#define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13) #define MVPP22_CLS_C2_ACT_FWD(act) (((act) & 0x7) << 13)
...@@ -132,8 +133,10 @@ ...@@ -132,8 +133,10 @@
#define MVPP22_CLS_C2_ATTR0 0x1b64 #define MVPP22_CLS_C2_ATTR0 0x1b64
#define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24) #define MVPP22_CLS_C2_ATTR0_QHIGH(qh) (((qh) & 0x1f) << 24)
#define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f #define MVPP22_CLS_C2_ATTR0_QHIGH_MASK 0x1f
#define MVPP22_CLS_C2_ATTR0_QHIGH_OFFS 24
#define MVPP22_CLS_C2_ATTR0_QLOW(ql) (((ql) & 0x7) << 21) #define MVPP22_CLS_C2_ATTR0_QLOW(ql) (((ql) & 0x7) << 21)
#define MVPP22_CLS_C2_ATTR0_QLOW_MASK 0x7 #define MVPP22_CLS_C2_ATTR0_QLOW_MASK 0x7
#define MVPP22_CLS_C2_ATTR0_QLOW_OFFS 21
#define MVPP22_CLS_C2_ATTR1 0x1b68 #define MVPP22_CLS_C2_ATTR1 0x1b68
#define MVPP22_CLS_C2_ATTR2 0x1b6c #define MVPP22_CLS_C2_ATTR2 0x1b6c
#define MVPP22_CLS_C2_ATTR2_RSS_EN BIT(30) #define MVPP22_CLS_C2_ATTR2_RSS_EN BIT(30)
...@@ -316,6 +319,11 @@ ...@@ -316,6 +319,11 @@
#define MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK 0xff00 #define MVPP22_BM_ADDR_HIGH_VIRT_RLS_MASK 0xff00
#define MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT 8 #define MVPP22_BM_ADDR_HIGH_VIRT_RLS_SHIFT 8
/* Hit counters registers */
#define MVPP2_CTRS_IDX 0x7040
#define MVPP2_CLS_DEC_TBL_HIT_CTR 0x7700
#define MVPP2_CLS_FLOW_TBL_HIT_CTR 0x7704
/* TX Scheduler registers */ /* TX Scheduler registers */
#define MVPP2_TXP_SCHED_PORT_INDEX_REG 0x8000 #define MVPP2_TXP_SCHED_PORT_INDEX_REG 0x8000
#define MVPP2_TXP_SCHED_Q_CMD_REG 0x8004 #define MVPP2_TXP_SCHED_Q_CMD_REG 0x8004
...@@ -749,6 +757,9 @@ struct mvpp2 { ...@@ -749,6 +757,9 @@ struct mvpp2 {
/* Workqueue to gather hardware statistics */ /* Workqueue to gather hardware statistics */
char queue_name[30]; char queue_name[30];
struct workqueue_struct *stats_queue; struct workqueue_struct *stats_queue;
/* Debugfs root entry */
struct dentry *dbgfs_dir;
}; };
struct mvpp2_pcpu_stats { struct mvpp2_pcpu_stats {
...@@ -1092,4 +1103,8 @@ u32 mvpp2_percpu_read(struct mvpp2 *priv, int cpu, u32 offset); ...@@ -1092,4 +1103,8 @@ u32 mvpp2_percpu_read(struct mvpp2 *priv, int cpu, u32 offset);
void mvpp2_percpu_write_relaxed(struct mvpp2 *priv, int cpu, u32 offset, void mvpp2_percpu_write_relaxed(struct mvpp2 *priv, int cpu, u32 offset,
u32 data); u32 data);
void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name);
void mvpp2_dbgfs_cleanup(struct mvpp2 *priv);
#endif #endif
// SPDX-License-Identifier: GPL-2.0
/* /*
* RSS and Classifier helpers for Marvell PPv2 Network Controller * RSS and Classifier helpers for Marvell PPv2 Network Controller
* *
* Copyright (C) 2014 Marvell * Copyright (C) 2014 Marvell
* *
* Marcin Wojtas <mw@semihalf.com> * Marcin Wojtas <mw@semihalf.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/ */
#include "mvpp2.h" #include "mvpp2.h"
...@@ -325,7 +322,14 @@ static struct mvpp2_cls_flow cls_flows[MVPP2_N_FLOWS] = { ...@@ -325,7 +322,14 @@ static struct mvpp2_cls_flow cls_flows[MVPP2_N_FLOWS] = {
0, 0), 0, 0),
}; };
static void mvpp2_cls_flow_read(struct mvpp2 *priv, int index, u32 mvpp2_cls_flow_hits(struct mvpp2 *priv, int index)
{
mvpp2_write(priv, MVPP2_CTRS_IDX, index);
return mvpp2_read(priv, MVPP2_CLS_FLOW_TBL_HIT_CTR);
}
void mvpp2_cls_flow_read(struct mvpp2 *priv, int index,
struct mvpp2_cls_flow_entry *fe) struct mvpp2_cls_flow_entry *fe)
{ {
fe->index = index; fe->index = index;
...@@ -345,6 +349,25 @@ static void mvpp2_cls_flow_write(struct mvpp2 *priv, ...@@ -345,6 +349,25 @@ static void mvpp2_cls_flow_write(struct mvpp2 *priv,
mvpp2_write(priv, MVPP2_CLS_FLOW_TBL2_REG, fe->data[2]); mvpp2_write(priv, MVPP2_CLS_FLOW_TBL2_REG, fe->data[2]);
} }
u32 mvpp2_cls_lookup_hits(struct mvpp2 *priv, int index)
{
mvpp2_write(priv, MVPP2_CTRS_IDX, index);
return mvpp2_read(priv, MVPP2_CLS_DEC_TBL_HIT_CTR);
}
void mvpp2_cls_lookup_read(struct mvpp2 *priv, int lkpid, int way,
struct mvpp2_cls_lookup_entry *le)
{
u32 val;
val = (way << MVPP2_CLS_LKP_INDEX_WAY_OFFS) | lkpid;
mvpp2_write(priv, MVPP2_CLS_LKP_INDEX_REG, val);
le->way = way;
le->lkpid = lkpid;
le->data = mvpp2_read(priv, MVPP2_CLS_LKP_TBL_REG);
}
/* Update classification lookup table register */ /* Update classification lookup table register */
static void mvpp2_cls_lookup_write(struct mvpp2 *priv, static void mvpp2_cls_lookup_write(struct mvpp2 *priv,
struct mvpp2_cls_lookup_entry *le) struct mvpp2_cls_lookup_entry *le)
...@@ -391,6 +414,12 @@ static void mvpp2_cls_flow_eng_set(struct mvpp2_cls_flow_entry *fe, ...@@ -391,6 +414,12 @@ static void mvpp2_cls_flow_eng_set(struct mvpp2_cls_flow_entry *fe,
fe->data[0] |= MVPP2_CLS_FLOW_TBL0_ENG(engine); fe->data[0] |= MVPP2_CLS_FLOW_TBL0_ENG(engine);
} }
int mvpp2_cls_flow_eng_get(struct mvpp2_cls_flow_entry *fe)
{
return (fe->data[0] >> MVPP2_CLS_FLOW_TBL0_OFFS) &
MVPP2_CLS_FLOW_TBL0_ENG_MASK;
}
static void mvpp2_cls_flow_port_id_sel(struct mvpp2_cls_flow_entry *fe, static void mvpp2_cls_flow_port_id_sel(struct mvpp2_cls_flow_entry *fe,
bool from_packet) bool from_packet)
{ {
...@@ -557,7 +586,7 @@ static int mvpp2_flow_set_hek_fields(struct mvpp2_cls_flow_entry *fe, ...@@ -557,7 +586,7 @@ static int mvpp2_flow_set_hek_fields(struct mvpp2_cls_flow_entry *fe,
return 0; return 0;
} }
static struct mvpp2_cls_flow *mvpp2_cls_flow_get(int flow) struct mvpp2_cls_flow *mvpp2_cls_flow_get(int flow)
{ {
if (flow >= MVPP2_N_FLOWS) if (flow >= MVPP2_N_FLOWS)
return NULL; return NULL;
...@@ -728,7 +757,7 @@ static void mvpp2_cls_c2_write(struct mvpp2 *priv, ...@@ -728,7 +757,7 @@ static void mvpp2_cls_c2_write(struct mvpp2 *priv,
mvpp2_write(priv, MVPP22_CLS_C2_ATTR3, c2->attr[3]); mvpp2_write(priv, MVPP22_CLS_C2_ATTR3, c2->attr[3]);
} }
static void mvpp2_cls_c2_read(struct mvpp2 *priv, int index, void mvpp2_cls_c2_read(struct mvpp2 *priv, int index,
struct mvpp2_cls_c2_entry *c2) struct mvpp2_cls_c2_entry *c2)
{ {
mvpp2_write(priv, MVPP22_CLS_C2_TCAM_IDX, index); mvpp2_write(priv, MVPP22_CLS_C2_TCAM_IDX, index);
...@@ -844,6 +873,13 @@ void mvpp2_cls_port_config(struct mvpp2_port *port) ...@@ -844,6 +873,13 @@ void mvpp2_cls_port_config(struct mvpp2_port *port)
mvpp2_port_c2_cls_init(port); mvpp2_port_c2_cls_init(port);
} }
u32 mvpp2_cls_c2_hit_count(struct mvpp2 *priv, int c2_index)
{
mvpp2_write(priv, MVPP22_CLS_C2_TCAM_IDX, c2_index);
return mvpp2_read(priv, MVPP22_CLS_C2_HIT_CTR);
}
static void mvpp2_rss_port_c2_enable(struct mvpp2_port *port) static void mvpp2_rss_port_c2_enable(struct mvpp2_port *port)
{ {
struct mvpp2_cls_c2_entry c2; struct mvpp2_cls_c2_entry c2;
......
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* RSS and Classifier definitions for Marvell PPv2 Network Controller * RSS and Classifier definitions for Marvell PPv2 Network Controller
* *
* Copyright (C) 2014 Marvell * Copyright (C) 2014 Marvell
* *
* Marcin Wojtas <mw@semihalf.com> * Marcin Wojtas <mw@semihalf.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/ */
#ifndef _MVPP2_CLS_H_ #ifndef _MVPP2_CLS_H_
...@@ -212,4 +209,25 @@ void mvpp2_cls_port_config(struct mvpp2_port *port); ...@@ -212,4 +209,25 @@ void mvpp2_cls_port_config(struct mvpp2_port *port);
void mvpp2_cls_oversize_rxq_set(struct mvpp2_port *port); void mvpp2_cls_oversize_rxq_set(struct mvpp2_port *port);
int mvpp2_cls_flow_eng_get(struct mvpp2_cls_flow_entry *fe);
u16 mvpp2_flow_get_hek_fields(struct mvpp2_cls_flow_entry *fe);
struct mvpp2_cls_flow *mvpp2_cls_flow_get(int flow);
u32 mvpp2_cls_flow_hits(struct mvpp2 *priv, int index);
void mvpp2_cls_flow_read(struct mvpp2 *priv, int index,
struct mvpp2_cls_flow_entry *fe);
u32 mvpp2_cls_lookup_hits(struct mvpp2 *priv, int index);
void mvpp2_cls_lookup_read(struct mvpp2 *priv, int lkpid, int way,
struct mvpp2_cls_lookup_entry *le);
u32 mvpp2_cls_c2_hit_count(struct mvpp2 *priv, int c2_index);
void mvpp2_cls_c2_read(struct mvpp2 *priv, int index,
struct mvpp2_cls_c2_entry *c2);
#endif #endif
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* Driver for Marvell PPv2 network controller for Armada 375 SoC. * Driver for Marvell PPv2 network controller for Armada 375 SoC.
* *
* Copyright (C) 2014 Marvell * Copyright (C) 2014 Marvell
* *
* Marcin Wojtas <mw@semihalf.com> * Marcin Wojtas <mw@semihalf.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
...@@ -5292,6 +5289,8 @@ static int mvpp2_probe(struct platform_device *pdev) ...@@ -5292,6 +5289,8 @@ static int mvpp2_probe(struct platform_device *pdev)
goto err_port_probe; goto err_port_probe;
} }
mvpp2_dbgfs_init(priv, pdev->name);
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
return 0; return 0;
...@@ -5325,6 +5324,8 @@ static int mvpp2_remove(struct platform_device *pdev) ...@@ -5325,6 +5324,8 @@ static int mvpp2_remove(struct platform_device *pdev)
struct fwnode_handle *port_fwnode; struct fwnode_handle *port_fwnode;
int i = 0; int i = 0;
mvpp2_dbgfs_cleanup(priv);
flush_workqueue(priv->stats_queue); flush_workqueue(priv->stats_queue);
destroy_workqueue(priv->stats_queue); destroy_workqueue(priv->stats_queue);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Header Parser helpers for Marvell PPv2 Network Controller * Header Parser helpers for Marvell PPv2 Network Controller
* *
* Copyright (C) 2014 Marvell * Copyright (C) 2014 Marvell
* *
* Marcin Wojtas <mw@semihalf.com> * Marcin Wojtas <mw@semihalf.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
...@@ -46,8 +43,8 @@ static int mvpp2_prs_hw_write(struct mvpp2 *priv, struct mvpp2_prs_entry *pe) ...@@ -46,8 +43,8 @@ static int mvpp2_prs_hw_write(struct mvpp2 *priv, struct mvpp2_prs_entry *pe)
} }
/* Initialize tcam entry from hw */ /* Initialize tcam entry from hw */
static int mvpp2_prs_init_from_hw(struct mvpp2 *priv, int mvpp2_prs_init_from_hw(struct mvpp2 *priv, struct mvpp2_prs_entry *pe,
struct mvpp2_prs_entry *pe, int tid) int tid)
{ {
int i; int i;
...@@ -129,7 +126,7 @@ static void mvpp2_prs_tcam_port_map_set(struct mvpp2_prs_entry *pe, ...@@ -129,7 +126,7 @@ static void mvpp2_prs_tcam_port_map_set(struct mvpp2_prs_entry *pe,
} }
/* Obtain port map from tcam sw entry */ /* Obtain port map from tcam sw entry */
static unsigned int mvpp2_prs_tcam_port_map_get(struct mvpp2_prs_entry *pe) unsigned int mvpp2_prs_tcam_port_map_get(struct mvpp2_prs_entry *pe)
{ {
return (~pe->tcam[MVPP2_PRS_TCAM_PORT_WORD] >> 24) & MVPP2_PRS_PORT_MASK; return (~pe->tcam[MVPP2_PRS_TCAM_PORT_WORD] >> 24) & MVPP2_PRS_PORT_MASK;
} }
...@@ -148,7 +145,7 @@ static void mvpp2_prs_tcam_data_byte_set(struct mvpp2_prs_entry *pe, ...@@ -148,7 +145,7 @@ static void mvpp2_prs_tcam_data_byte_set(struct mvpp2_prs_entry *pe,
} }
/* Get byte of data and its enable bits from tcam sw entry */ /* Get byte of data and its enable bits from tcam sw entry */
static void mvpp2_prs_tcam_data_byte_get(struct mvpp2_prs_entry *pe, void mvpp2_prs_tcam_data_byte_get(struct mvpp2_prs_entry *pe,
unsigned int offs, unsigned char *byte, unsigned int offs, unsigned char *byte,
unsigned char *enable) unsigned char *enable)
{ {
...@@ -2481,3 +2478,19 @@ int mvpp2_prs_def_flow(struct mvpp2_port *port) ...@@ -2481,3 +2478,19 @@ int mvpp2_prs_def_flow(struct mvpp2_port *port)
return 0; 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;
}
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* Header Parser definitions for Marvell PPv2 Network Controller * Header Parser definitions for Marvell PPv2 Network Controller
* *
* Copyright (C) 2014 Marvell * Copyright (C) 2014 Marvell
* *
* Marcin Wojtas <mw@semihalf.com> * Marcin Wojtas <mw@semihalf.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/ */
#ifndef _MVPP2_PRS_H_ #ifndef _MVPP2_PRS_H_
#define _MVPP2_PRS_H_ #define _MVPP2_PRS_H_
...@@ -297,6 +294,15 @@ struct mvpp2_prs_shadow { ...@@ -297,6 +294,15 @@ struct mvpp2_prs_shadow {
int mvpp2_prs_default_init(struct platform_device *pdev, struct mvpp2 *priv); int mvpp2_prs_default_init(struct platform_device *pdev, struct mvpp2 *priv);
int mvpp2_prs_init_from_hw(struct mvpp2 *priv, struct mvpp2_prs_entry *pe,
int tid);
unsigned int mvpp2_prs_tcam_port_map_get(struct mvpp2_prs_entry *pe);
void mvpp2_prs_tcam_data_byte_get(struct mvpp2_prs_entry *pe,
unsigned int offs, unsigned char *byte,
unsigned char *enable);
int mvpp2_prs_mac_da_accept(struct mvpp2_port *port, const u8 *da, bool add); int mvpp2_prs_mac_da_accept(struct mvpp2_port *port, const u8 *da, bool add);
int mvpp2_prs_tag_mode_set(struct mvpp2 *priv, int port, int type); int mvpp2_prs_tag_mode_set(struct mvpp2 *priv, int port, int type);
...@@ -322,4 +328,6 @@ void mvpp2_prs_mac_del_all(struct mvpp2_port *port); ...@@ -322,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_update_mac_da(struct net_device *dev, const u8 *da);
int mvpp2_prs_hits(struct mvpp2 *priv, int index);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment