28 #ifdef CONFIG_DEBUG_FS
31 #include <linux/module.h>
35 static struct dentry *ixgbe_dbg_root;
37 static char ixgbe_dbg_reg_ops_buf[256] =
"";
47 static int ixgbe_dbg_reg_ops_open(
struct inode *
inode,
struct file *filp)
61 size_t count, loff_t *ppos)
72 len =
snprintf(buf,
sizeof(buf),
"%s: %s\n",
73 adapter->
netdev->name, ixgbe_dbg_reg_ops_buf);
77 if (bytes_not_copied < 0)
78 return bytes_not_copied;
91 static ssize_t ixgbe_dbg_reg_ops_write(
struct file *filp,
92 const char __user *buffer,
93 size_t count, loff_t *ppos)
101 if (count >=
sizeof(ixgbe_dbg_reg_ops_buf))
104 bytes_not_copied =
copy_from_user(ixgbe_dbg_reg_ops_buf, buffer, count);
105 if (bytes_not_copied < 0)
106 return bytes_not_copied;
107 else if (bytes_not_copied < count)
108 count -= bytes_not_copied;
111 ixgbe_dbg_reg_ops_buf[
count] =
'\0';
113 if (
strncmp(ixgbe_dbg_reg_ops_buf,
"write", 5) == 0) {
116 cnt =
sscanf(&ixgbe_dbg_reg_ops_buf[5],
"%x %x", ®, &value);
120 e_dev_info(
"write: 0x%08x = 0x%08x\n", reg, value);
124 }
else if (
strncmp(ixgbe_dbg_reg_ops_buf,
"read", 4) == 0) {
127 cnt =
sscanf(&ixgbe_dbg_reg_ops_buf[4],
"%x", ®);
130 e_dev_info(
"read 0x%08x = 0x%08x\n", reg, value);
135 e_dev_info(
"Unknown command %s\n", ixgbe_dbg_reg_ops_buf);
145 .open = ixgbe_dbg_reg_ops_open,
146 .read = ixgbe_dbg_reg_ops_read,
147 .write = ixgbe_dbg_reg_ops_write,
150 static char ixgbe_dbg_netdev_ops_buf[256] =
"";
160 static int ixgbe_dbg_netdev_ops_open(
struct inode *
inode,
struct file *filp)
173 static ssize_t ixgbe_dbg_netdev_ops_read(
struct file *filp,
175 size_t count, loff_t *ppos)
179 int bytes_not_copied;
186 len =
snprintf(buf,
sizeof(buf),
"%s: %s\n",
187 adapter->
netdev->name, ixgbe_dbg_netdev_ops_buf);
191 if (bytes_not_copied < 0)
192 return bytes_not_copied;
205 static ssize_t ixgbe_dbg_netdev_ops_write(
struct file *filp,
206 const char __user *buffer,
207 size_t count, loff_t *ppos)
210 int bytes_not_copied;
215 if (count >=
sizeof(ixgbe_dbg_netdev_ops_buf))
220 if (bytes_not_copied < 0)
221 return bytes_not_copied;
222 else if (bytes_not_copied < count)
223 count -= bytes_not_copied;
226 ixgbe_dbg_netdev_ops_buf[
count] =
'\0';
228 if (
strncmp(ixgbe_dbg_netdev_ops_buf,
"tx_timeout", 10) == 0) {
229 adapter->
netdev->netdev_ops->ndo_tx_timeout(adapter->
netdev);
232 e_dev_info(
"Unknown command: %s\n", ixgbe_dbg_netdev_ops_buf);
241 .open = ixgbe_dbg_netdev_ops_open,
242 .read = ixgbe_dbg_netdev_ops_read,
243 .write = ixgbe_dbg_netdev_ops_write,
252 const char *
name = pci_name(adapter->
pdev);
255 if (adapter->ixgbe_dbg_adapter) {
257 adapter->ixgbe_dbg_adapter, adapter,
258 &ixgbe_dbg_reg_ops_fops);
260 e_dev_err(
"debugfs reg_ops for %s failed\n", name);
262 adapter->ixgbe_dbg_adapter, adapter,
263 &ixgbe_dbg_netdev_ops_fops);
265 e_dev_err(
"debugfs netdev_ops for %s failed\n", name);
267 e_dev_err(
"debugfs entry for %s failed\n", name);
277 if (adapter->ixgbe_dbg_adapter)
279 adapter->ixgbe_dbg_adapter =
NULL;
285 void ixgbe_dbg_init(
void)
288 if (ixgbe_dbg_root ==
NULL)
289 pr_err(
"init of debugfs failed\n");
295 void ixgbe_dbg_exit(
void)