1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2017-2018 Broadcom Limited
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation.
10 #include <linux/debugfs.h>
11 #include <linux/module.h>
12 #include <linux/pci.h>
14 #include <linux/net_dim.h>
16 #include "bnxt_debugfs.h"
18 static struct dentry
*bnxt_debug_mnt
;
20 static ssize_t
debugfs_dim_read(struct file
*filep
,
22 size_t count
, loff_t
*ppos
)
24 struct net_dim
*dim
= filep
->private_data
;
32 buf
= kasprintf(GFP_KERNEL
,
37 "steps_right = %d\n" \
49 if (count
< strlen(buf
)) {
53 len
= simple_read_from_buffer(buffer
, count
, ppos
, buf
, strlen(buf
));
58 static const struct file_operations debugfs_dim_fops
= {
61 .read
= debugfs_dim_read
,
64 static struct dentry
*debugfs_dim_ring_init(struct net_dim
*dim
, int ring_idx
,
67 static char qname
[16];
69 snprintf(qname
, 10, "%d", ring_idx
);
70 return debugfs_create_file(qname
, 0600, dd
,
71 dim
, &debugfs_dim_fops
);
74 void bnxt_debug_dev_init(struct bnxt
*bp
)
76 const char *pname
= pci_name(bp
->pdev
);
80 bp
->debugfs_pdev
= debugfs_create_dir(pname
, bnxt_debug_mnt
);
81 if (bp
->debugfs_pdev
) {
82 pdevf
= debugfs_create_dir("dim", bp
->debugfs_pdev
);
84 pr_err("failed to create debugfs entry %s/dim\n",
88 bp
->debugfs_dim
= pdevf
;
89 /* create files for each rx ring */
90 for (i
= 0; i
< bp
->cp_nr_rings
; i
++) {
91 struct bnxt_cp_ring_info
*cpr
= &bp
->bnapi
[i
]->cp_ring
;
93 if (cpr
&& bp
->bnapi
[i
]->rx_ring
) {
94 pdevf
= debugfs_dim_ring_init(&cpr
->dim
, i
,
97 pr_err("failed to create debugfs entry %s/dim/%d\n",
102 pr_err("failed to create debugfs entry %s\n", pname
);
106 void bnxt_debug_dev_exit(struct bnxt
*bp
)
109 debugfs_remove_recursive(bp
->debugfs_pdev
);
110 bp
->debugfs_pdev
= NULL
;
114 void bnxt_debug_init(void)
116 bnxt_debug_mnt
= debugfs_create_dir("bnxt_en", NULL
);
118 pr_err("failed to init bnxt_en debugfs\n");
121 void bnxt_debug_exit(void)
123 debugfs_remove_recursive(bnxt_debug_mnt
);