Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / net / fjes / fjes_debugfs.c
blob2c2095e7cf1eaad0c6b49733ae75417a10bf24ad
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * FUJITSU Extended Socket Network Device driver
4 * Copyright (c) 2015-2016 FUJITSU LIMITED
5 */
7 /* debugfs support for fjes driver */
9 #ifdef CONFIG_DEBUG_FS
11 #include <linux/debugfs.h>
12 #include <linux/seq_file.h>
13 #include <linux/platform_device.h>
15 #include "fjes.h"
17 static struct dentry *fjes_debug_root;
19 static const char * const ep_status_string[] = {
20 "unshared",
21 "shared",
22 "waiting",
23 "complete",
26 static int fjes_dbg_status_show(struct seq_file *m, void *v)
28 struct fjes_adapter *adapter = m->private;
29 struct fjes_hw *hw = &adapter->hw;
30 int max_epid = hw->max_epid;
31 int my_epid = hw->my_epid;
32 int epidx;
34 seq_puts(m, "EPID\tSTATUS SAME_ZONE CONNECTED\n");
35 for (epidx = 0; epidx < max_epid; epidx++) {
36 if (epidx == my_epid) {
37 seq_printf(m, "ep%d\t%-16c %-16c %-16c\n",
38 epidx, '-', '-', '-');
39 } else {
40 seq_printf(m, "ep%d\t%-16s %-16c %-16c\n",
41 epidx,
42 ep_status_string[fjes_hw_get_partner_ep_status(hw, epidx)],
43 fjes_hw_epid_is_same_zone(hw, epidx) ? 'Y' : 'N',
44 fjes_hw_epid_is_shared(hw->hw_info.share, epidx) ? 'Y' : 'N');
48 return 0;
50 DEFINE_SHOW_ATTRIBUTE(fjes_dbg_status);
52 void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
54 const char *name = dev_name(&adapter->plat_dev->dev);
56 adapter->dbg_adapter = debugfs_create_dir(name, fjes_debug_root);
58 debugfs_create_file("status", 0444, adapter->dbg_adapter, adapter,
59 &fjes_dbg_status_fops);
62 void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
64 debugfs_remove_recursive(adapter->dbg_adapter);
65 adapter->dbg_adapter = NULL;
68 void fjes_dbg_init(void)
70 fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL);
73 void fjes_dbg_exit(void)
75 debugfs_remove_recursive(fjes_debug_root);
76 fjes_debug_root = NULL;
79 #endif /* CONFIG_DEBUG_FS */