diff options
author | Catherine Sullivan <catherine.sullivan@intel.com> | 2012-08-09 21:59:15 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2012-09-15 19:26:20 -0400 |
commit | 826ff0de1178669eac123d706f78b455aa0f2c4d (patch) | |
tree | 97627a6954ef2fbbfeed3b4724ec4ae7bdd9e9fd /drivers/net/ethernet/intel | |
parent | 00949167d6f34f83e9e185ab4f7a3a94bf4c5a1c (diff) |
ixgbe: added netdev_ops file to debugfs
Added the netdev_ops file to debugfs with a command to call the
ndo_tx_timeout function to give users the ability to simulate a
tx_timeout call made by the kernel.
Signed-off-by: Catherine Sullivan <catherine.sullivan@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel')
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c | 107 |
1 files changed, 105 insertions, 2 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c index 0b08b6c7497c..2dd169ee5e68 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c | |||
@@ -34,6 +34,102 @@ | |||
34 | 34 | ||
35 | static struct dentry *ixgbe_dbg_root; | 35 | static struct dentry *ixgbe_dbg_root; |
36 | 36 | ||
37 | static char ixgbe_dbg_netdev_ops_buf[256] = ""; | ||
38 | |||
39 | /** | ||
40 | * ixgbe_dbg_netdev_ops_open - prep the debugfs netdev_ops data item | ||
41 | * @inode: inode that was opened | ||
42 | * @filp: file info | ||
43 | * | ||
44 | * Stash the adapter pointer hiding in the inode into the file pointer | ||
45 | * where we can find it later in the read and write calls | ||
46 | **/ | ||
47 | static int ixgbe_dbg_netdev_ops_open(struct inode *inode, struct file *filp) | ||
48 | { | ||
49 | filp->private_data = inode->i_private; | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | /** | ||
54 | * ixgbe_dbg_netdev_ops_read - read for netdev_ops datum | ||
55 | * @filp: the opened file | ||
56 | * @buffer: where to write the data for the user to read | ||
57 | * @count: the size of the user's buffer | ||
58 | * @ppos: file position offset | ||
59 | **/ | ||
60 | static ssize_t ixgbe_dbg_netdev_ops_read(struct file *filp, | ||
61 | char __user *buffer, | ||
62 | size_t count, loff_t *ppos) | ||
63 | { | ||
64 | struct ixgbe_adapter *adapter = filp->private_data; | ||
65 | char buf[256]; | ||
66 | int bytes_not_copied; | ||
67 | int len; | ||
68 | |||
69 | /* don't allow partial reads */ | ||
70 | if (*ppos != 0) | ||
71 | return 0; | ||
72 | |||
73 | len = snprintf(buf, sizeof(buf), "%s: %s\n", | ||
74 | adapter->netdev->name, ixgbe_dbg_netdev_ops_buf); | ||
75 | if (count < len) | ||
76 | return -ENOSPC; | ||
77 | bytes_not_copied = copy_to_user(buffer, buf, len); | ||
78 | if (bytes_not_copied < 0) | ||
79 | return bytes_not_copied; | ||
80 | |||
81 | *ppos = len; | ||
82 | return len; | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * ixgbe_dbg_netdev_ops_write - write into netdev_ops datum | ||
87 | * @filp: the opened file | ||
88 | * @buffer: where to find the user's data | ||
89 | * @count: the length of the user's data | ||
90 | * @ppos: file position offset | ||
91 | **/ | ||
92 | static ssize_t ixgbe_dbg_netdev_ops_write(struct file *filp, | ||
93 | const char __user *buffer, | ||
94 | size_t count, loff_t *ppos) | ||
95 | { | ||
96 | struct ixgbe_adapter *adapter = filp->private_data; | ||
97 | int bytes_not_copied; | ||
98 | |||
99 | /* don't allow partial writes */ | ||
100 | if (*ppos != 0) | ||
101 | return 0; | ||
102 | if (count >= sizeof(ixgbe_dbg_netdev_ops_buf)) | ||
103 | return -ENOSPC; | ||
104 | |||
105 | bytes_not_copied = copy_from_user(ixgbe_dbg_netdev_ops_buf, | ||
106 | buffer, count); | ||
107 | if (bytes_not_copied < 0) | ||
108 | return bytes_not_copied; | ||
109 | else if (bytes_not_copied < count) | ||
110 | count -= bytes_not_copied; | ||
111 | else | ||
112 | return -ENOSPC; | ||
113 | ixgbe_dbg_netdev_ops_buf[count] = '\0'; | ||
114 | |||
115 | if (strncmp(ixgbe_dbg_netdev_ops_buf, "tx_timeout", 10) == 0) { | ||
116 | adapter->netdev->netdev_ops->ndo_tx_timeout(adapter->netdev); | ||
117 | e_dev_info("tx_timeout called\n"); | ||
118 | } else { | ||
119 | e_dev_info("Unknown command: %s\n", ixgbe_dbg_netdev_ops_buf); | ||
120 | e_dev_info("Available commands:\n"); | ||
121 | e_dev_info(" tx_timeout\n"); | ||
122 | } | ||
123 | return count; | ||
124 | } | ||
125 | |||
126 | static const struct file_operations ixgbe_dbg_netdev_ops_fops = { | ||
127 | .owner = THIS_MODULE, | ||
128 | .open = ixgbe_dbg_netdev_ops_open, | ||
129 | .read = ixgbe_dbg_netdev_ops_read, | ||
130 | .write = ixgbe_dbg_netdev_ops_write, | ||
131 | }; | ||
132 | |||
37 | /** | 133 | /** |
38 | * ixgbe_dbg_adapter_init - setup the debugfs directory for the adapter | 134 | * ixgbe_dbg_adapter_init - setup the debugfs directory for the adapter |
39 | * @adapter: the adapter that is starting up | 135 | * @adapter: the adapter that is starting up |
@@ -41,10 +137,17 @@ static struct dentry *ixgbe_dbg_root; | |||
41 | void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) | 137 | void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter) |
42 | { | 138 | { |
43 | const char *name = pci_name(adapter->pdev); | 139 | const char *name = pci_name(adapter->pdev); |
44 | 140 | struct dentry *pfile; | |
45 | adapter->ixgbe_dbg_adapter = debugfs_create_dir(name, ixgbe_dbg_root); | 141 | adapter->ixgbe_dbg_adapter = debugfs_create_dir(name, ixgbe_dbg_root); |
46 | if (!adapter->ixgbe_dbg_adapter) | 142 | if (adapter->ixgbe_dbg_adapter) { |
143 | pfile = debugfs_create_file("netdev_ops", 0600, | ||
144 | adapter->ixgbe_dbg_adapter, adapter, | ||
145 | &ixgbe_dbg_netdev_ops_fops); | ||
146 | if (!pfile) | ||
147 | e_dev_err("debugfs netdev_ops for %s failed\n", name); | ||
148 | } else { | ||
47 | e_dev_err("debugfs entry for %s failed\n", name); | 149 | e_dev_err("debugfs entry for %s failed\n", name); |
150 | } | ||
48 | } | 151 | } |
49 | 152 | ||
50 | /** | 153 | /** |