Thomas Gleixner | dcc4086 | 2019-05-29 16:57:23 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Taku Izumi | c753119 | 2016-10-14 20:28:07 +0900 | [diff] [blame] | 2 | /* |
| 3 | * FUJITSU Extended Socket Network Device driver |
| 4 | * Copyright (c) 2015-2016 FUJITSU LIMITED |
Taku Izumi | c753119 | 2016-10-14 20:28:07 +0900 | [diff] [blame] | 5 | */ |
| 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 | |
| 17 | static struct dentry *fjes_debug_root; |
| 18 | |
| 19 | static const char * const ep_status_string[] = { |
| 20 | "unshared", |
| 21 | "shared", |
| 22 | "waiting", |
| 23 | "complete", |
| 24 | }; |
| 25 | |
| 26 | static 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 Li | a93f5b5 | 2018-12-10 10:57:38 -0500 | [diff] [blame] | 50 | DEFINE_SHOW_ATTRIBUTE(fjes_dbg_status); |
Taku Izumi | c753119 | 2016-10-14 20:28:07 +0900 | [diff] [blame] | 51 | |
| 52 | void fjes_dbg_adapter_init(struct fjes_adapter *adapter) |
| 53 | { |
| 54 | const char *name = dev_name(&adapter->plat_dev->dev); |
Taku Izumi | c753119 | 2016-10-14 20:28:07 +0900 | [diff] [blame] | 55 | |
| 56 | adapter->dbg_adapter = debugfs_create_dir(name, fjes_debug_root); |
Taku Izumi | c753119 | 2016-10-14 20:28:07 +0900 | [diff] [blame] | 57 | |
Greg Kroah-Hartman | de467c1 | 2019-06-20 09:31:06 +0200 | [diff] [blame] | 58 | debugfs_create_file("status", 0444, adapter->dbg_adapter, adapter, |
| 59 | &fjes_dbg_status_fops); |
Taku Izumi | c753119 | 2016-10-14 20:28:07 +0900 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | void fjes_dbg_adapter_exit(struct fjes_adapter *adapter) |
| 63 | { |
| 64 | debugfs_remove_recursive(adapter->dbg_adapter); |
| 65 | adapter->dbg_adapter = NULL; |
| 66 | } |
| 67 | |
| 68 | void fjes_dbg_init(void) |
| 69 | { |
| 70 | fjes_debug_root = debugfs_create_dir(fjes_driver_name, NULL); |
Taku Izumi | c753119 | 2016-10-14 20:28:07 +0900 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void fjes_dbg_exit(void) |
| 74 | { |
| 75 | debugfs_remove_recursive(fjes_debug_root); |
| 76 | fjes_debug_root = NULL; |
| 77 | } |
| 78 | |
| 79 | #endif /* CONFIG_DEBUG_FS */ |