Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 265747
b: refs/heads/master
c: 7ac2905
h: refs/heads/master
i:
  265745: 4e683ff
  265743: 7abb2a3
v: v3
  • Loading branch information
Giuseppe CAVALLARO authored and David S. Miller committed Sep 15, 2011
1 parent c8fc0af commit 5eefac6
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1c901a46d576926287b05fc145bd3fd31a3e65de
refs/heads/master: 7ac2905511063376ef59baae0e570bfebeea8004
7 changes: 7 additions & 0 deletions trunk/drivers/net/ethernet/stmicro/stmmac/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ config STMMAC_ETH

if STMMAC_ETH

config STMMAC_DEBUG_FS
bool "Enable monitoring via sysFS "
default n
depends on STMMAC_ETH && DEBUG_FS
-- help
The stmmac entry in /sys reports DMA TX/RX rings.

config STMMAC_DA
bool "STMMAC DMA arbitration scheme"
default n
Expand Down
105 changes: 105 additions & 0 deletions trunk/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#include <linux/slab.h>
#include <linux/prefetch.h>
#include "stmmac.h"
#ifdef CONFIG_STMMAC_DEBUG_FS
#include <linux/debugfs.h>
#include <linux/seq_file.h>
#endif

#define STMMAC_RESOURCE_NAME "stmmaceth"

Expand Down Expand Up @@ -1425,6 +1429,96 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return ret;
}

#ifdef CONFIG_STMMAC_DEBUG_FS
static struct dentry *stmmac_fs_dir;
static struct dentry *stmmac_rings_status;

static int stmmac_sysfs_ring_read(struct seq_file *seq, void *v)
{
struct tmp_s {
u64 a;
unsigned int b;
unsigned int c;
};
int i;
struct net_device *dev = seq->private;
struct stmmac_priv *priv = netdev_priv(dev);

seq_printf(seq, "=======================\n");
seq_printf(seq, " RX descriptor ring\n");
seq_printf(seq, "=======================\n");

for (i = 0; i < priv->dma_rx_size; i++) {
struct tmp_s *x = (struct tmp_s *)(priv->dma_rx + i);
seq_printf(seq, "[%d] DES0=0x%x DES1=0x%x BUF1=0x%x BUF2=0x%x",
i, (unsigned int)(x->a),
(unsigned int)((x->a) >> 32), x->b, x->c);
seq_printf(seq, "\n");
}

seq_printf(seq, "\n");
seq_printf(seq, "=======================\n");
seq_printf(seq, " TX descriptor ring\n");
seq_printf(seq, "=======================\n");

for (i = 0; i < priv->dma_tx_size; i++) {
struct tmp_s *x = (struct tmp_s *)(priv->dma_tx + i);
seq_printf(seq, "[%d] DES0=0x%x DES1=0x%x BUF1=0x%x BUF2=0x%x",
i, (unsigned int)(x->a),
(unsigned int)((x->a) >> 32), x->b, x->c);
seq_printf(seq, "\n");
}

return 0;
}

static int stmmac_sysfs_ring_open(struct inode *inode, struct file *file)
{
return single_open(file, stmmac_sysfs_ring_read, inode->i_private);
}

static const struct file_operations stmmac_rings_status_fops = {
.owner = THIS_MODULE,
.open = stmmac_sysfs_ring_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};

static int stmmac_init_fs(struct net_device *dev)
{
/* Create debugfs entries */
stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL);

if (!stmmac_fs_dir || IS_ERR(stmmac_fs_dir)) {
pr_err("ERROR %s, debugfs create directory failed\n",
STMMAC_RESOURCE_NAME);

return -ENOMEM;
}

/* Entry to report DMA RX/TX rings */
stmmac_rings_status = debugfs_create_file("descriptors_status",
S_IRUGO, stmmac_fs_dir, dev,
&stmmac_rings_status_fops);

if (!stmmac_rings_status || IS_ERR(stmmac_rings_status)) {
pr_info("ERROR creating stmmac ring debugfs file\n");
debugfs_remove(stmmac_fs_dir);

return -ENOMEM;
}

return 0;
}

static void stmmac_exit_fs(void)
{
debugfs_remove(stmmac_rings_status);
debugfs_remove(stmmac_fs_dir);
}
#endif /* CONFIG_STMMAC_DEBUG_FS */

static const struct net_device_ops stmmac_netdev_ops = {
.ndo_open = stmmac_open,
.ndo_start_xmit = stmmac_xmit,
Expand Down Expand Up @@ -1651,6 +1745,13 @@ static int stmmac_dvr_probe(struct platform_device *pdev)
if (ret < 0)
goto out_unregister;
pr_debug("registered!\n");

#ifdef CONFIG_STMMAC_DEBUG_FS
ret = stmmac_init_fs(ndev);
if (ret < 0)
pr_warning("\tFailed debugFS registration");
#endif

return 0;

out_unregister:
Expand Down Expand Up @@ -1703,6 +1804,10 @@ static int stmmac_dvr_remove(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
release_mem_region(res->start, resource_size(res));

#ifdef CONFIG_STMMAC_DEBUG_FS
stmmac_exit_fs();
#endif

free_netdev(ndev);

return 0;
Expand Down

0 comments on commit 5eefac6

Please sign in to comment.