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/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 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 void debugfs_dim_ring_init(struct dim *dim, int ring_idx,
67 static char qname[16];
69 snprintf(qname, 10, "%d", ring_idx);
70 debugfs_create_file(qname, 0600, dd, dim, &debugfs_dim_fops);
73 void bnxt_debug_dev_init(struct bnxt *bp)
75 const char *pname = pci_name(bp->pdev);
79 bp->debugfs_pdev = debugfs_create_dir(pname, bnxt_debug_mnt);
80 dir = debugfs_create_dir("dim", bp->debugfs_pdev);
82 /* create files for each rx ring */
83 for (i = 0; i < bp->cp_nr_rings; i++) {
84 struct bnxt_cp_ring_info *cpr = &bp->bnapi[i]->cp_ring;
86 if (cpr && bp->bnapi[i]->rx_ring)
87 debugfs_dim_ring_init(&cpr->dim, i, dir);
91 void bnxt_debug_dev_exit(struct bnxt *bp)
94 debugfs_remove_recursive(bp->debugfs_pdev);
95 bp->debugfs_pdev = NULL;
99 void bnxt_debug_init(void)
101 bnxt_debug_mnt = debugfs_create_dir("bnxt_en", NULL);
104 void bnxt_debug_exit(void)
106 debugfs_remove_recursive(bnxt_debug_mnt);