Skip to content

Commit 60e2835

Browse files
davidarinzonkuba-moo
authored andcommitted
net: ena: Add debugfs support to the ENA driver
Adding the base directory of debugfs to the driver. In order for the folder to be unique per driver instantiation, the chosen name is the device name. This commit contains the initialization and the base folder. The creation of the base folder may fail, but is considered non-fatal. Signed-off-by: David Arinzon <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 816b526 commit 60e2835

File tree

6 files changed

+66
-1
lines changed

6 files changed

+66
-1
lines changed

Documentation/networking/device_drivers/ethernet/amazon/ena.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ena_xdp.[ch] XDP files
5858
ena_pci_id_tbl.h Supported device IDs.
5959
ena_phc.[ch] PTP hardware clock infrastructure (see `PHC`_ for more info)
6060
ena_devlink.[ch] devlink files.
61+
ena_debugfs.[ch] debugfs files.
6162
================= ======================================================
6263

6364
Management Interface:

drivers/net/ethernet/amazon/ena/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
obj-$(CONFIG_ENA_ETHERNET) += ena.o
77

8-
ena-y := ena_netdev.o ena_com.o ena_eth_com.o ena_ethtool.o ena_xdp.o ena_phc.o ena_devlink.o
8+
ena-y := ena_netdev.o ena_com.o ena_eth_com.o ena_ethtool.o ena_xdp.o ena_phc.o ena_devlink.o ena_debugfs.o
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
2+
/* Copyright (c) Amazon.com, Inc. or its affiliates.
3+
* All rights reserved.
4+
*/
5+
6+
#ifdef CONFIG_DEBUG_FS
7+
8+
#include <linux/seq_file.h>
9+
#include <linux/pci.h>
10+
#include "ena_debugfs.h"
11+
12+
void ena_debugfs_init(struct net_device *dev)
13+
{
14+
struct ena_adapter *adapter = netdev_priv(dev);
15+
16+
adapter->debugfs_base =
17+
debugfs_create_dir(dev_name(&adapter->pdev->dev), NULL);
18+
}
19+
20+
void ena_debugfs_terminate(struct net_device *dev)
21+
{
22+
struct ena_adapter *adapter = netdev_priv(dev);
23+
24+
debugfs_remove_recursive(adapter->debugfs_base);
25+
}
26+
27+
#endif /* CONFIG_DEBUG_FS */
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2+
/* Copyright (c) Amazon.com, Inc. or its affiliates.
3+
* All rights reserved.
4+
*/
5+
6+
#ifndef __ENA_DEBUGFS_H__
7+
#define __ENA_DEBUGFS_H__
8+
9+
#include <linux/debugfs.h>
10+
#include <linux/netdevice.h>
11+
#include "ena_netdev.h"
12+
13+
#ifdef CONFIG_DEBUG_FS
14+
15+
void ena_debugfs_init(struct net_device *dev);
16+
17+
void ena_debugfs_terminate(struct net_device *dev);
18+
19+
#else /* CONFIG_DEBUG_FS */
20+
21+
static inline void ena_debugfs_init(struct net_device *dev) {}
22+
23+
static inline void ena_debugfs_terminate(struct net_device *dev) {}
24+
25+
#endif /* CONFIG_DEBUG_FS */
26+
27+
#endif /* __ENA_DEBUGFS_H__ */

drivers/net/ethernet/amazon/ena/ena_netdev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include "ena_devlink.h"
2525

26+
#include "ena_debugfs.h"
27+
2628
MODULE_AUTHOR("Amazon.com, Inc. or its affiliates");
2729
MODULE_DESCRIPTION(DEVICE_NAME);
2830
MODULE_LICENSE("GPL");
@@ -4060,6 +4062,8 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40604062
goto err_rss;
40614063
}
40624064

4065+
ena_debugfs_init(netdev);
4066+
40634067
INIT_WORK(&adapter->reset_task, ena_fw_reset_device);
40644068

40654069
adapter->last_keep_alive_jiffies = jiffies;
@@ -4139,6 +4143,8 @@ static void __ena_shutoff(struct pci_dev *pdev, bool shutdown)
41394143
ena_dev = adapter->ena_dev;
41404144
netdev = adapter->netdev;
41414145

4146+
ena_debugfs_terminate(netdev);
4147+
41424148
/* Make sure timer and reset routine won't be called after
41434149
* freeing device resources.
41444150
*/

drivers/net/ethernet/amazon/ena/ena_netdev.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ struct ena_adapter {
391391

392392
struct devlink *devlink;
393393
struct devlink_port devlink_port;
394+
#ifdef CONFIG_DEBUG_FS
395+
396+
struct dentry *debugfs_base;
397+
#endif /* CONFIG_DEBUG_FS */
394398
};
395399

396400
void ena_set_ethtool_ops(struct net_device *netdev);

0 commit comments

Comments
 (0)