xref: /linux/drivers/net/ethernet/meta/fbnic/fbnic_debugfs.c (revision 25768de50b1f2dbb6ea44bd5148a87fe2c9c3688)
108606cb5SJakub Kicinski // SPDX-License-Identifier: GPL-2.0
208606cb5SJakub Kicinski /* Copyright (c) Meta Platforms, Inc. and affiliates. */
308606cb5SJakub Kicinski 
408606cb5SJakub Kicinski #include <linux/debugfs.h>
508606cb5SJakub Kicinski #include <linux/pci.h>
6*25ba596dSSanman Pradhan #include <linux/rtnetlink.h>
7*25ba596dSSanman Pradhan #include <linux/seq_file.h>
808606cb5SJakub Kicinski 
908606cb5SJakub Kicinski #include "fbnic.h"
1008606cb5SJakub Kicinski 
1108606cb5SJakub Kicinski static struct dentry *fbnic_dbg_root;
1208606cb5SJakub Kicinski 
13*25ba596dSSanman Pradhan static int fbnic_dbg_pcie_stats_show(struct seq_file *s, void *v)
14*25ba596dSSanman Pradhan {
15*25ba596dSSanman Pradhan 	struct fbnic_dev *fbd = s->private;
16*25ba596dSSanman Pradhan 
17*25ba596dSSanman Pradhan 	rtnl_lock();
18*25ba596dSSanman Pradhan 	fbnic_get_hw_stats(fbd);
19*25ba596dSSanman Pradhan 
20*25ba596dSSanman Pradhan 	seq_printf(s, "ob_rd_tlp: %llu\n", fbd->hw_stats.pcie.ob_rd_tlp.value);
21*25ba596dSSanman Pradhan 	seq_printf(s, "ob_rd_dword: %llu\n",
22*25ba596dSSanman Pradhan 		   fbd->hw_stats.pcie.ob_rd_dword.value);
23*25ba596dSSanman Pradhan 	seq_printf(s, "ob_wr_tlp: %llu\n", fbd->hw_stats.pcie.ob_wr_tlp.value);
24*25ba596dSSanman Pradhan 	seq_printf(s, "ob_wr_dword: %llu\n",
25*25ba596dSSanman Pradhan 		   fbd->hw_stats.pcie.ob_wr_dword.value);
26*25ba596dSSanman Pradhan 	seq_printf(s, "ob_cpl_tlp: %llu\n",
27*25ba596dSSanman Pradhan 		   fbd->hw_stats.pcie.ob_cpl_tlp.value);
28*25ba596dSSanman Pradhan 	seq_printf(s, "ob_cpl_dword: %llu\n",
29*25ba596dSSanman Pradhan 		   fbd->hw_stats.pcie.ob_cpl_dword.value);
30*25ba596dSSanman Pradhan 	seq_printf(s, "ob_rd_no_tag: %llu\n",
31*25ba596dSSanman Pradhan 		   fbd->hw_stats.pcie.ob_rd_no_tag.value);
32*25ba596dSSanman Pradhan 	seq_printf(s, "ob_rd_no_cpl_cred: %llu\n",
33*25ba596dSSanman Pradhan 		   fbd->hw_stats.pcie.ob_rd_no_cpl_cred.value);
34*25ba596dSSanman Pradhan 	seq_printf(s, "ob_rd_no_np_cred: %llu\n",
35*25ba596dSSanman Pradhan 		   fbd->hw_stats.pcie.ob_rd_no_np_cred.value);
36*25ba596dSSanman Pradhan 	rtnl_unlock();
37*25ba596dSSanman Pradhan 
38*25ba596dSSanman Pradhan 	return 0;
39*25ba596dSSanman Pradhan }
40*25ba596dSSanman Pradhan 
41*25ba596dSSanman Pradhan DEFINE_SHOW_ATTRIBUTE(fbnic_dbg_pcie_stats);
42*25ba596dSSanman Pradhan 
4308606cb5SJakub Kicinski void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
4408606cb5SJakub Kicinski {
4508606cb5SJakub Kicinski 	struct pci_dev *pdev = to_pci_dev(fbd->dev);
4608606cb5SJakub Kicinski 	const char *name = pci_name(pdev);
4708606cb5SJakub Kicinski 
4808606cb5SJakub Kicinski 	fbd->dbg_fbd = debugfs_create_dir(name, fbnic_dbg_root);
49*25ba596dSSanman Pradhan 	debugfs_create_file("pcie_stats", 0400, fbd->dbg_fbd, fbd,
50*25ba596dSSanman Pradhan 			    &fbnic_dbg_pcie_stats_fops);
5108606cb5SJakub Kicinski }
5208606cb5SJakub Kicinski 
5308606cb5SJakub Kicinski void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd)
5408606cb5SJakub Kicinski {
5508606cb5SJakub Kicinski 	debugfs_remove_recursive(fbd->dbg_fbd);
5608606cb5SJakub Kicinski 	fbd->dbg_fbd = NULL;
5708606cb5SJakub Kicinski }
5808606cb5SJakub Kicinski 
5908606cb5SJakub Kicinski void fbnic_dbg_init(void)
6008606cb5SJakub Kicinski {
6108606cb5SJakub Kicinski 	fbnic_dbg_root = debugfs_create_dir(fbnic_driver_name, NULL);
6208606cb5SJakub Kicinski }
6308606cb5SJakub Kicinski 
6408606cb5SJakub Kicinski void fbnic_dbg_exit(void)
6508606cb5SJakub Kicinski {
6608606cb5SJakub Kicinski 	debugfs_remove_recursive(fbnic_dbg_root);
6708606cb5SJakub Kicinski 	fbnic_dbg_root = NULL;
6808606cb5SJakub Kicinski }
69