1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) Meta Platforms, Inc. and affiliates. */
4 #include <linux/debugfs.h>
6 #include <linux/rtnetlink.h>
7 #include <linux/seq_file.h>
11 static struct dentry
*fbnic_dbg_root
;
13 static int fbnic_dbg_pcie_stats_show(struct seq_file
*s
, void *v
)
15 struct fbnic_dev
*fbd
= s
->private;
18 fbnic_get_hw_stats(fbd
);
20 seq_printf(s
, "ob_rd_tlp: %llu\n", fbd
->hw_stats
.pcie
.ob_rd_tlp
.value
);
21 seq_printf(s
, "ob_rd_dword: %llu\n",
22 fbd
->hw_stats
.pcie
.ob_rd_dword
.value
);
23 seq_printf(s
, "ob_wr_tlp: %llu\n", fbd
->hw_stats
.pcie
.ob_wr_tlp
.value
);
24 seq_printf(s
, "ob_wr_dword: %llu\n",
25 fbd
->hw_stats
.pcie
.ob_wr_dword
.value
);
26 seq_printf(s
, "ob_cpl_tlp: %llu\n",
27 fbd
->hw_stats
.pcie
.ob_cpl_tlp
.value
);
28 seq_printf(s
, "ob_cpl_dword: %llu\n",
29 fbd
->hw_stats
.pcie
.ob_cpl_dword
.value
);
30 seq_printf(s
, "ob_rd_no_tag: %llu\n",
31 fbd
->hw_stats
.pcie
.ob_rd_no_tag
.value
);
32 seq_printf(s
, "ob_rd_no_cpl_cred: %llu\n",
33 fbd
->hw_stats
.pcie
.ob_rd_no_cpl_cred
.value
);
34 seq_printf(s
, "ob_rd_no_np_cred: %llu\n",
35 fbd
->hw_stats
.pcie
.ob_rd_no_np_cred
.value
);
41 DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_pcie_stats
);
43 void fbnic_dbg_fbd_init(struct fbnic_dev
*fbd
)
45 struct pci_dev
*pdev
= to_pci_dev(fbd
->dev
);
46 const char *name
= pci_name(pdev
);
48 fbd
->dbg_fbd
= debugfs_create_dir(name
, fbnic_dbg_root
);
49 debugfs_create_file("pcie_stats", 0400, fbd
->dbg_fbd
, fbd
,
50 &fbnic_dbg_pcie_stats_fops
);
53 void fbnic_dbg_fbd_exit(struct fbnic_dev
*fbd
)
55 debugfs_remove_recursive(fbd
->dbg_fbd
);
59 void fbnic_dbg_init(void)
61 fbnic_dbg_root
= debugfs_create_dir(fbnic_driver_name
, NULL
);
64 void fbnic_dbg_exit(void)
66 debugfs_remove_recursive(fbnic_dbg_root
);
67 fbnic_dbg_root
= NULL
;