-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bnxt_en: add debugfs support for DIM
This adds debugfs support for bnxt_en with the purpose of allowing users to examine the current DIM profile in use for each receive queue. This was instrumental in debugging issues found with DIM and ensuring that the profiles we expect to use are the profiles being used. Signed-off-by: Andy Gospodarek <gospo@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Andy Gospodarek
authored and
David S. Miller
committed
Apr 27, 2018
1 parent
9751e8e
commit cabfb09
Showing
5 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* Broadcom NetXtreme-C/E network driver. | ||
* | ||
* Copyright (c) 2017-2018 Broadcom Limited | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation. | ||
*/ | ||
|
||
#include <linux/debugfs.h> | ||
#include <linux/module.h> | ||
#include <linux/pci.h> | ||
#include "bnxt_hsi.h" | ||
#include <linux/net_dim.h> | ||
#include "bnxt.h" | ||
#include "bnxt_debugfs.h" | ||
|
||
static struct dentry *bnxt_debug_mnt; | ||
|
||
static ssize_t debugfs_dim_read(struct file *filep, | ||
char __user *buffer, | ||
size_t count, loff_t *ppos) | ||
{ | ||
struct net_dim *dim = filep->private_data; | ||
int len; | ||
char *buf; | ||
|
||
if (*ppos) | ||
return 0; | ||
if (!dim) | ||
return -ENODEV; | ||
buf = kasprintf(GFP_KERNEL, | ||
"state = %d\n" \ | ||
"profile_ix = %d\n" \ | ||
"mode = %d\n" \ | ||
"tune_state = %d\n" \ | ||
"steps_right = %d\n" \ | ||
"steps_left = %d\n" \ | ||
"tired = %d\n", | ||
dim->state, | ||
dim->profile_ix, | ||
dim->mode, | ||
dim->tune_state, | ||
dim->steps_right, | ||
dim->steps_left, | ||
dim->tired); | ||
if (!buf) | ||
return -ENOMEM; | ||
if (count < strlen(buf)) { | ||
kfree(buf); | ||
return -ENOSPC; | ||
} | ||
len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf)); | ||
kfree(buf); | ||
return len; | ||
} | ||
|
||
static const struct file_operations debugfs_dim_fops = { | ||
.owner = THIS_MODULE, | ||
.open = simple_open, | ||
.read = debugfs_dim_read, | ||
}; | ||
|
||
static struct dentry *debugfs_dim_ring_init(struct net_dim *dim, int ring_idx, | ||
struct dentry *dd) | ||
{ | ||
static char qname[16]; | ||
|
||
snprintf(qname, 10, "%d", ring_idx); | ||
return debugfs_create_file(qname, 0600, dd, | ||
dim, &debugfs_dim_fops); | ||
} | ||
|
||
void bnxt_debug_dev_init(struct bnxt *bp) | ||
{ | ||
const char *pname = pci_name(bp->pdev); | ||
struct dentry *pdevf; | ||
int i; | ||
|
||
bp->debugfs_pdev = debugfs_create_dir(pname, bnxt_debug_mnt); | ||
if (bp->debugfs_pdev) { | ||
pdevf = debugfs_create_dir("dim", bp->debugfs_pdev); | ||
if (!pdevf) { | ||
pr_err("failed to create debugfs entry %s/dim\n", | ||
pname); | ||
return; | ||
} | ||
bp->debugfs_dim = pdevf; | ||
/* create files for each rx ring */ | ||
for (i = 0; i < bp->cp_nr_rings; i++) { | ||
struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring; | ||
|
||
if (cpr && bp->bnapi[i]->rx_ring) { | ||
pdevf = debugfs_dim_ring_init(&cpr->dim, i, | ||
bp->debugfs_dim); | ||
if (!pdevf) | ||
pr_err("failed to create debugfs entry %s/dim/%d\n", | ||
pname, i); | ||
} | ||
} | ||
} else { | ||
pr_err("failed to create debugfs entry %s\n", pname); | ||
} | ||
} | ||
|
||
void bnxt_debug_dev_exit(struct bnxt *bp) | ||
{ | ||
if (bp) { | ||
debugfs_remove_recursive(bp->debugfs_pdev); | ||
bp->debugfs_pdev = NULL; | ||
} | ||
} | ||
|
||
void bnxt_debug_init(void) | ||
{ | ||
bnxt_debug_mnt = debugfs_create_dir("bnxt_en", NULL); | ||
if (!bnxt_debug_mnt) | ||
pr_err("failed to init bnxt_en debugfs\n"); | ||
} | ||
|
||
void bnxt_debug_exit(void) | ||
{ | ||
debugfs_remove_recursive(bnxt_debug_mnt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* Broadcom NetXtreme-C/E network driver. | ||
* | ||
* Copyright (c) 2017-2018 Broadcom Limited | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation. | ||
*/ | ||
|
||
#include "bnxt_hsi.h" | ||
#include "bnxt.h" | ||
|
||
#ifdef CONFIG_DEBUG_FS | ||
void bnxt_debug_init(void); | ||
void bnxt_debug_exit(void); | ||
void bnxt_debug_dev_init(struct bnxt *bp); | ||
void bnxt_debug_dev_exit(struct bnxt *bp); | ||
#else | ||
static inline void bnxt_debug_init(void) {} | ||
static inline void bnxt_debug_exit(void) {} | ||
static inline void bnxt_debug_dev_init(struct bnxt *bp) {} | ||
static inline void bnxt_debug_dev_exit(struct bnxt *bp) {} | ||
#endif |