blob: 2c2095e7cf1eaad0c6b49733ae75417a10bf24ad [file] [log] [blame]
Thomas Gleixnerdcc40862019-05-29 16:57:23 -07001// SPDX-License-Identifier: GPL-2.0-only
Taku Izumic7531192016-10-14 20:28:07 +09002/*
3 * FUJITSU Extended Socket Network Device driver
4 * Copyright (c) 2015-2016 FUJITSU LIMITED
Taku Izumic7531192016-10-14 20:28:07 +09005 */
6
7/* debugfs support for fjes driver */
8
9#ifdef CONFIG_DEBUG_FS
10
11#include <linux/debugfs.h>
12#include <linux/seq_file.h>
13#include <linux/platform_device.h>
14
15#include "fjes.h"
16
17static struct dentry *fjes_debug_root;
18
19static const char * const ep_status_string[] = {
20 "unshared",
21 "shared",
22 "waiting",
23 "complete",
24};
25
26static int fjes_dbg_status_show(struct seq_file *m, void *v)
27{
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;
33
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');
45 }
46 }
47
48 return 0;
49}
Yangtao Lia93f5b52018-12-10 10:57:38 -050050DEFINE_SHOW_ATTRIBUTE(fjes_dbg_status);
Taku Izumic7531192016-10-14 20:28:07 +090051
52void fjes_dbg_adapter_init(struct fjes_adapter *adapter)
53{
54 const char *name = dev_name(&adapter->plat_dev->dev);
Taku Izumic7531192016-10-14 20:28:07 +090055
56 adapter->dbg_adapter = debugfs_create_dir(name, fjes_debug_root);
Taku Izumic7531192016-10-14 20:28:07 +090057
Greg Kroah-Hartmande467c12019-06-20 09:31:06 +020058 debugfs_create_file("status", 0444, adapter->dbg_adapter, adapter,
59 &fjes_dbg_status_fops);
Taku Izumic7531192016-10-14 20:28:07 +090060}
61
62void fjes_dbg_adapter_exit(struct fjes_adapter *adapter)
63{
64 debugfs_remove_recursive(adapter->dbg_adapter);
65 adapter->dbg_adapter = NULL;
66}
67
68void fjes_dbg_init(void)
69{
70 fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL);
Taku Izumic7531192016-10-14 20:28:07 +090071}
72
73void fjes_dbg_exit(void)
74{
75 debugfs_remove_recursive(fjes_debug_root);
76 fjes_debug_root = NULL;
77}
78
79#endif /* CONFIG_DEBUG_FS */