aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMathieu Olivari <mathieu@codeaurora.org>2015-05-22 22:03:29 -0400
committerDavid S. Miller <davem@davemloft.net>2015-05-25 17:38:23 -0400
commit466c5ac8bdf29a382d064923a60ef302dd3b2aeb (patch)
tree0ba40de0a9fe79eaa992746efb300ef4f0c0dbb8
parent5369c71f7ca24f6472f8fa883e05fa7469fab284 (diff)
net: stmmac: create one debugfs dir per net-device
stmmac DebugFS entries are currently global to the driver. As a result, having more than one stmmac device in the system creates the following error: * ERROR stmmaceth, debugfs create directory failed * stmmac_hw_setup: failed debugFS registration This also results in being able to access the debugfs information for the first registered device only. This patch changes the debugfs structure to have one sub-directory per net-device. Files under "/sys/kernel/debug/stmmaceth" will now show-up under /sys/kernel/debug/stmmaceth/ethN/. Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac.h6
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c76
2 files changed, 59 insertions, 23 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index 2ac9552d1fa3..73bab983edd9 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -117,6 +117,12 @@ struct stmmac_priv {
117 int use_riwt; 117 int use_riwt;
118 int irq_wake; 118 int irq_wake;
119 spinlock_t ptp_lock; 119 spinlock_t ptp_lock;
120
121#ifdef CONFIG_DEBUG_FS
122 struct dentry *dbgfs_dir;
123 struct dentry *dbgfs_rings_status;
124 struct dentry *dbgfs_dma_cap;
125#endif
120}; 126};
121 127
122int stmmac_mdio_unregister(struct net_device *ndev); 128int stmmac_mdio_unregister(struct net_device *ndev);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 05c146f718a3..2c5ce2baca87 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -118,7 +118,7 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id);
118 118
119#ifdef CONFIG_DEBUG_FS 119#ifdef CONFIG_DEBUG_FS
120static int stmmac_init_fs(struct net_device *dev); 120static int stmmac_init_fs(struct net_device *dev);
121static void stmmac_exit_fs(void); 121static void stmmac_exit_fs(struct net_device *dev);
122#endif 122#endif
123 123
124#define STMMAC_COAL_TIMER(x) (jiffies + usecs_to_jiffies(x)) 124#define STMMAC_COAL_TIMER(x) (jiffies + usecs_to_jiffies(x))
@@ -1916,7 +1916,7 @@ static int stmmac_release(struct net_device *dev)
1916 netif_carrier_off(dev); 1916 netif_carrier_off(dev);
1917 1917
1918#ifdef CONFIG_DEBUG_FS 1918#ifdef CONFIG_DEBUG_FS
1919 stmmac_exit_fs(); 1919 stmmac_exit_fs(dev);
1920#endif 1920#endif
1921 1921
1922 stmmac_release_ptp(priv); 1922 stmmac_release_ptp(priv);
@@ -2508,8 +2508,6 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2508 2508
2509#ifdef CONFIG_DEBUG_FS 2509#ifdef CONFIG_DEBUG_FS
2510static struct dentry *stmmac_fs_dir; 2510static struct dentry *stmmac_fs_dir;
2511static struct dentry *stmmac_rings_status;
2512static struct dentry *stmmac_dma_cap;
2513 2511
2514static void sysfs_display_ring(void *head, int size, int extend_desc, 2512static void sysfs_display_ring(void *head, int size, int extend_desc,
2515 struct seq_file *seq) 2513 struct seq_file *seq)
@@ -2648,36 +2646,39 @@ static const struct file_operations stmmac_dma_cap_fops = {
2648 2646
2649static int stmmac_init_fs(struct net_device *dev) 2647static int stmmac_init_fs(struct net_device *dev)
2650{ 2648{
2651 /* Create debugfs entries */ 2649 struct stmmac_priv *priv = netdev_priv(dev);
2652 stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL); 2650
2651 /* Create per netdev entries */
2652 priv->dbgfs_dir = debugfs_create_dir(dev->name, stmmac_fs_dir);
2653 2653
2654 if (!stmmac_fs_dir || IS_ERR(stmmac_fs_dir)) { 2654 if (!priv->dbgfs_dir || IS_ERR(priv->dbgfs_dir)) {
2655 pr_err("ERROR %s, debugfs create directory failed\n", 2655 pr_err("ERROR %s/%s, debugfs create directory failed\n",
2656 STMMAC_RESOURCE_NAME); 2656 STMMAC_RESOURCE_NAME, dev->name);
2657 2657
2658 return -ENOMEM; 2658 return -ENOMEM;
2659 } 2659 }
2660 2660
2661 /* Entry to report DMA RX/TX rings */ 2661 /* Entry to report DMA RX/TX rings */
2662 stmmac_rings_status = debugfs_create_file("descriptors_status", 2662 priv->dbgfs_rings_status =
2663 S_IRUGO, stmmac_fs_dir, dev, 2663 debugfs_create_file("descriptors_status", S_IRUGO,
2664 &stmmac_rings_status_fops); 2664 priv->dbgfs_dir, dev,
2665 &stmmac_rings_status_fops);
2665 2666
2666 if (!stmmac_rings_status || IS_ERR(stmmac_rings_status)) { 2667 if (!priv->dbgfs_rings_status || IS_ERR(priv->dbgfs_rings_status)) {
2667 pr_info("ERROR creating stmmac ring debugfs file\n"); 2668 pr_info("ERROR creating stmmac ring debugfs file\n");
2668 debugfs_remove(stmmac_fs_dir); 2669 debugfs_remove_recursive(priv->dbgfs_dir);
2669 2670
2670 return -ENOMEM; 2671 return -ENOMEM;
2671 } 2672 }
2672 2673
2673 /* Entry to report the DMA HW features */ 2674 /* Entry to report the DMA HW features */
2674 stmmac_dma_cap = debugfs_create_file("dma_cap", S_IRUGO, stmmac_fs_dir, 2675 priv->dbgfs_dma_cap = debugfs_create_file("dma_cap", S_IRUGO,
2675 dev, &stmmac_dma_cap_fops); 2676 priv->dbgfs_dir,
2677 dev, &stmmac_dma_cap_fops);
2676 2678
2677 if (!stmmac_dma_cap || IS_ERR(stmmac_dma_cap)) { 2679 if (!priv->dbgfs_dma_cap || IS_ERR(priv->dbgfs_dma_cap)) {
2678 pr_info("ERROR creating stmmac MMC debugfs file\n"); 2680 pr_info("ERROR creating stmmac MMC debugfs file\n");
2679 debugfs_remove(stmmac_rings_status); 2681 debugfs_remove_recursive(priv->dbgfs_dir);
2680 debugfs_remove(stmmac_fs_dir);
2681 2682
2682 return -ENOMEM; 2683 return -ENOMEM;
2683 } 2684 }
@@ -2685,11 +2686,11 @@ static int stmmac_init_fs(struct net_device *dev)
2685 return 0; 2686 return 0;
2686} 2687}
2687 2688
2688static void stmmac_exit_fs(void) 2689static void stmmac_exit_fs(struct net_device *dev)
2689{ 2690{
2690 debugfs_remove(stmmac_rings_status); 2691 struct stmmac_priv *priv = netdev_priv(dev);
2691 debugfs_remove(stmmac_dma_cap); 2692
2692 debugfs_remove(stmmac_fs_dir); 2693 debugfs_remove_recursive(priv->dbgfs_dir);
2693} 2694}
2694#endif /* CONFIG_DEBUG_FS */ 2695#endif /* CONFIG_DEBUG_FS */
2695 2696
@@ -3149,6 +3150,35 @@ err:
3149__setup("stmmaceth=", stmmac_cmdline_opt); 3150__setup("stmmaceth=", stmmac_cmdline_opt);
3150#endif /* MODULE */ 3151#endif /* MODULE */
3151 3152
3153static int __init stmmac_init(void)
3154{
3155#ifdef CONFIG_DEBUG_FS
3156 /* Create debugfs main directory if it doesn't exist yet */
3157 if (!stmmac_fs_dir) {
3158 stmmac_fs_dir = debugfs_create_dir(STMMAC_RESOURCE_NAME, NULL);
3159
3160 if (!stmmac_fs_dir || IS_ERR(stmmac_fs_dir)) {
3161 pr_err("ERROR %s, debugfs create directory failed\n",
3162 STMMAC_RESOURCE_NAME);
3163
3164 return -ENOMEM;
3165 }
3166 }
3167#endif
3168
3169 return 0;
3170}
3171
3172static void __exit stmmac_exit(void)
3173{
3174#ifdef CONFIG_DEBUG_FS
3175 debugfs_remove_recursive(stmmac_fs_dir);
3176#endif
3177}
3178
3179module_init(stmmac_init)
3180module_exit(stmmac_exit)
3181
3152MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet device driver"); 3182MODULE_DESCRIPTION("STMMAC 10/100/1000 Ethernet device driver");
3153MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>"); 3183MODULE_AUTHOR("Giuseppe Cavallaro <peppe.cavallaro@st.com>");
3154MODULE_LICENSE("GPL"); 3184MODULE_LICENSE("GPL");