diff mbox series

[net-next,2/3] octeontx2-af: Add support for CPT1 in debugfs

Message ID 20210113152007.30293-3-schalla@marvell.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Support for OcteonTX2 98xx CPT block. | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: lcherian@marvell.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 96 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Srujana Challa Jan. 13, 2021, 3:20 p.m. UTC
Adds support to display block CPT1 stats at
"/sys/kernel/debug/octeontx2/cpt1".

Signed-off-by: Mahipal Challa <mchalla@marvell.com>
Signed-off-by: Srujana Challa <schalla@marvell.com>
---
 .../marvell/octeontx2/af/rvu_debugfs.c        | 45 +++++++++++--------
 1 file changed, 26 insertions(+), 19 deletions(-)

Comments

Saeed Mahameed Jan. 14, 2021, 11:50 p.m. UTC | #1
On Wed, 2021-01-13 at 20:50 +0530, Srujana Challa wrote:
> Adds support to display block CPT1 stats at
> "/sys/kernel/debug/octeontx2/cpt1".
> 
> Signed-off-by: Mahipal Challa <mchalla@marvell.com>
> Signed-off-by: Srujana Challa <schalla@marvell.com>
> ---
>  .../marvell/octeontx2/af/rvu_debugfs.c        | 45 +++++++++++----
> ----
>  1 file changed, 26 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> index d27543c1a166..158876366dd3 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> @@ -1904,6 +1904,18 @@ static void rvu_dbg_npc_init(struct rvu *rvu)
>  }
>  
>  /* CPT debugfs APIs */
> +static int cpt_get_blkaddr(struct seq_file *filp)
> +{
> +	struct dentry *current_dir;
> +	int blkaddr;
> +
> +	current_dir = filp->file->f_path.dentry->d_parent;
> +	blkaddr = (!strcmp(current_dir->d_name.name, "cpt1") ?
> +			   BLKADDR_CPT1 : BLKADDR_CPT0);
> +

This is very fragile piece of code! it assumes static debugfs directory
structure and naming, why don't you store the CPT context in the
sqe_file private ? as you already have in rvu_dbg_nix_init  for nix_hw
type
Srujana Challa Jan. 19, 2021, 8:57 a.m. UTC | #2
> On Wed, 2021-01-13 at 20:50 +0530, Srujana Challa wrote:
> > Adds support to display block CPT1 stats at
> > "/sys/kernel/debug/octeontx2/cpt1".
> >
> > Signed-off-by: Mahipal Challa <mchalla@marvell.com>
> > Signed-off-by: Srujana Challa <schalla@marvell.com>
> > ---
> >  .../marvell/octeontx2/af/rvu_debugfs.c        | 45 +++++++++++----
> > ----
> >  1 file changed, 26 insertions(+), 19 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> > b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> > index d27543c1a166..158876366dd3 100644
> > --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> > @@ -1904,6 +1904,18 @@ static void rvu_dbg_npc_init(struct rvu *rvu)
> > }
> >
> >  /* CPT debugfs APIs */
> > +static int cpt_get_blkaddr(struct seq_file *filp) {
> > +	struct dentry *current_dir;
> > +	int blkaddr;
> > +
> > +	current_dir = filp->file->f_path.dentry->d_parent;
> > +	blkaddr = (!strcmp(current_dir->d_name.name, "cpt1") ?
> > +			   BLKADDR_CPT1 : BLKADDR_CPT0);
> > +
> 
> This is very fragile piece of code! it assumes static debugfs directory structure
> and naming, why don't you store the CPT context in the sqe_file private ? as
> you already have in rvu_dbg_nix_init  for nix_hw type
> 
Okay, I will do the changes accordingly and submit next version.
Thanks.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index d27543c1a166..158876366dd3 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -1904,6 +1904,18 @@  static void rvu_dbg_npc_init(struct rvu *rvu)
 }
 
 /* CPT debugfs APIs */
+static int cpt_get_blkaddr(struct seq_file *filp)
+{
+	struct dentry *current_dir;
+	int blkaddr;
+
+	current_dir = filp->file->f_path.dentry->d_parent;
+	blkaddr = (!strcmp(current_dir->d_name.name, "cpt1") ?
+			   BLKADDR_CPT1 : BLKADDR_CPT0);
+
+	return blkaddr;
+}
+
 static int cpt_eng_sts_display(struct seq_file *filp, u8 eng_type)
 {
 	struct rvu *rvu = filp->private;
@@ -1913,9 +1925,7 @@  static int cpt_eng_sts_display(struct seq_file *filp, u8 eng_type)
 	int blkaddr;
 	u64 reg;
 
-	blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
-	if (blkaddr < 0)
-		return -ENODEV;
+	blkaddr = cpt_get_blkaddr(filp);
 
 	reg = rvu_read64(rvu, blkaddr, CPT_AF_CONSTANTS1);
 	max_ses = reg & 0xffff;
@@ -1982,9 +1992,7 @@  static int rvu_dbg_cpt_engines_info_display(struct seq_file *filp, void *unused)
 	int blkaddr;
 	u64 reg;
 
-	blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
-	if (blkaddr < 0)
-		return -ENODEV;
+	blkaddr = cpt_get_blkaddr(filp);
 
 	reg = rvu_read64(rvu, blkaddr, CPT_AF_CONSTANTS1);
 	max_ses = reg & 0xffff;
@@ -2020,9 +2028,7 @@  static int rvu_dbg_cpt_lfs_info_display(struct seq_file *filp, void *unused)
 	u64 reg;
 	u32 lf;
 
-	blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
-	if (blkaddr < 0)
-		return -ENODEV;
+	blkaddr = cpt_get_blkaddr(filp);
 
 	block = &hw->block[blkaddr];
 	if (!block->lf.bmap)
@@ -2052,9 +2058,7 @@  static int rvu_dbg_cpt_err_info_display(struct seq_file *filp, void *unused)
 	u64 reg0, reg1;
 	int blkaddr;
 
-	blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
-	if (blkaddr < 0)
-		return -ENODEV;
+	blkaddr = cpt_get_blkaddr(filp);
 
 	reg0 = rvu_read64(rvu, blkaddr, CPT_AF_FLTX_INT(0));
 	reg1 = rvu_read64(rvu, blkaddr, CPT_AF_FLTX_INT(1));
@@ -2083,9 +2087,7 @@  static int rvu_dbg_cpt_pc_display(struct seq_file *filp, void *unused)
 	u64 reg;
 
 	rvu = filp->private;
-	blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_CPT, 0);
-	if (blkaddr < 0)
-		return -ENODEV;
+	blkaddr = cpt_get_blkaddr(filp);
 
 	reg = rvu_read64(rvu, blkaddr, CPT_AF_INST_REQ_PC);
 	seq_printf(filp, "CPT instruction requests   %llu\n", reg);
@@ -2107,12 +2109,16 @@  static int rvu_dbg_cpt_pc_display(struct seq_file *filp, void *unused)
 
 RVU_DEBUG_SEQ_FOPS(cpt_pc, cpt_pc_display, NULL);
 
-static void rvu_dbg_cpt_init(struct rvu *rvu)
+static void rvu_dbg_cpt_init(struct rvu *rvu, int blkaddr)
 {
-	if (!is_block_implemented(rvu->hw, BLKADDR_CPT0))
+	if (!is_block_implemented(rvu->hw, blkaddr))
 		return;
 
-	rvu->rvu_dbg.cpt = debugfs_create_dir("cpt", rvu->rvu_dbg.root);
+	if (blkaddr == BLKADDR_NIX0)
+		rvu->rvu_dbg.cpt = debugfs_create_dir("cpt", rvu->rvu_dbg.root);
+	else
+		rvu->rvu_dbg.cpt = debugfs_create_dir("cpt1",
+						      rvu->rvu_dbg.root);
 
 	debugfs_create_file("cpt_pc", 0600, rvu->rvu_dbg.cpt, rvu,
 			    &rvu_dbg_cpt_pc_fops);
@@ -2145,7 +2151,8 @@  void rvu_dbg_init(struct rvu *rvu)
 	rvu_dbg_nix_init(rvu, BLKADDR_NIX1);
 	rvu_dbg_cgx_init(rvu);
 	rvu_dbg_npc_init(rvu);
-	rvu_dbg_cpt_init(rvu);
+	rvu_dbg_cpt_init(rvu, BLKADDR_CPT0);
+	rvu_dbg_cpt_init(rvu, BLKADDR_CPT1);
 }
 
 void rvu_dbg_exit(struct rvu *rvu)