Skip to content

Commit 08606cb

Browse files
committed
eth: fbnic: add basic debugfs structure
Add the usual debugfs structure: fbnic/ $pci-id/ device-fileA device-fileB This patch only adds the directories, subsequent changes will add files. Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Kalesh AP <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2a0d6c1 commit 08606cb

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

drivers/net/ethernet/meta/fbnic/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
obj-$(CONFIG_FBNIC) += fbnic.o
99

1010
fbnic-y := fbnic_csr.o \
11+
fbnic_debugfs.o \
1112
fbnic_devlink.o \
1213
fbnic_ethtool.o \
1314
fbnic_fw.o \

drivers/net/ethernet/meta/fbnic/fbnic.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
struct fbnic_dev {
2020
struct device *dev;
2121
struct net_device *netdev;
22+
struct dentry *dbg_fbd;
2223
struct device *hwmon;
2324

2425
u32 __iomem *uc_addr0;
@@ -156,6 +157,11 @@ int fbnic_alloc_irqs(struct fbnic_dev *fbd);
156157
void fbnic_get_fw_ver_commit_str(struct fbnic_dev *fbd, char *fw_version,
157158
const size_t str_sz);
158159

160+
void fbnic_dbg_fbd_init(struct fbnic_dev *fbd);
161+
void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd);
162+
void fbnic_dbg_init(void);
163+
void fbnic_dbg_exit(void);
164+
159165
void fbnic_csr_get_regs(struct fbnic_dev *fbd, u32 *data, u32 *regs_version);
160166
int fbnic_csr_regs_len(struct fbnic_dev *fbd);
161167

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
3+
4+
#include <linux/debugfs.h>
5+
#include <linux/pci.h>
6+
7+
#include "fbnic.h"
8+
9+
static struct dentry *fbnic_dbg_root;
10+
11+
void fbnic_dbg_fbd_init(struct fbnic_dev *fbd)
12+
{
13+
struct pci_dev *pdev = to_pci_dev(fbd->dev);
14+
const char *name = pci_name(pdev);
15+
16+
fbd->dbg_fbd = debugfs_create_dir(name, fbnic_dbg_root);
17+
}
18+
19+
void fbnic_dbg_fbd_exit(struct fbnic_dev *fbd)
20+
{
21+
debugfs_remove_recursive(fbd->dbg_fbd);
22+
fbd->dbg_fbd = NULL;
23+
}
24+
25+
void fbnic_dbg_init(void)
26+
{
27+
fbnic_dbg_root = debugfs_create_dir(fbnic_driver_name, NULL);
28+
}
29+
30+
void fbnic_dbg_exit(void)
31+
{
32+
debugfs_remove_recursive(fbnic_dbg_root);
33+
fbnic_dbg_root = NULL;
34+
}

drivers/net/ethernet/meta/fbnic/fbnic_pci.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ static int fbnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
288288
}
289289

290290
fbnic_devlink_register(fbd);
291+
fbnic_dbg_fbd_init(fbd);
291292

292293
fbnic_hwmon_register(fbd);
293294

@@ -355,6 +356,7 @@ static void fbnic_remove(struct pci_dev *pdev)
355356
}
356357

357358
fbnic_hwmon_unregister(fbd);
359+
fbnic_dbg_fbd_exit(fbd);
358360
fbnic_devlink_unregister(fbd);
359361
fbnic_fw_disable_mbx(fbd);
360362
fbnic_free_irqs(fbd);
@@ -552,9 +554,13 @@ static int __init fbnic_init_module(void)
552554
{
553555
int err;
554556

557+
fbnic_dbg_init();
558+
555559
err = pci_register_driver(&fbnic_driver);
556-
if (err)
560+
if (err) {
561+
fbnic_dbg_exit();
557562
goto out;
563+
}
558564

559565
pr_info(DRV_SUMMARY " (%s)", fbnic_driver.name);
560566
out:
@@ -570,5 +576,7 @@ module_init(fbnic_init_module);
570576
static void __exit fbnic_exit_module(void)
571577
{
572578
pci_unregister_driver(&fbnic_driver);
579+
580+
fbnic_dbg_exit();
573581
}
574582
module_exit(fbnic_exit_module);

0 commit comments

Comments
 (0)