]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: ena: Add debugfs support to the ENA driver
authorDavid Arinzon <darinzon@amazon.com>
Tue, 17 Jun 2025 11:05:43 +0000 (14:05 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 19 Jun 2025 01:57:29 +0000 (18:57 -0700)
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 <darinzon@amazon.com>
Link: https://patch.msgid.link/20250617110545.5659-8-darinzon@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Documentation/networking/device_drivers/ethernet/amazon/ena.rst
drivers/net/ethernet/amazon/ena/Makefile
drivers/net/ethernet/amazon/ena/ena_debugfs.c [new file with mode: 0644]
drivers/net/ethernet/amazon/ena/ena_debugfs.h [new file with mode: 0644]
drivers/net/ethernet/amazon/ena/ena_netdev.c
drivers/net/ethernet/amazon/ena/ena_netdev.h

index 112a3994bc8545ca415c02857be69c528933602f..7b7b8891cec9385af39d13fecc06215f764d34b5 100644 (file)
@@ -58,6 +58,7 @@ ena_xdp.[ch]        XDP files
 ena_pci_id_tbl.h    Supported device IDs.
 ena_phc.[ch]        PTP hardware clock infrastructure (see `PHC`_ for more info)
 ena_devlink.[ch]    devlink files.
+ena_debugfs.[ch]    debugfs files.
 =================   ======================================================
 
 Management Interface:
index 4b6511db873e041a046ad7723f66a9bbb437d779..6d8036bc18231031f01b3011960731a65ad3c2bc 100644 (file)
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_ENA_ETHERNET) += ena.o
 
-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-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
diff --git a/drivers/net/ethernet/amazon/ena/ena_debugfs.c b/drivers/net/ethernet/amazon/ena/ena_debugfs.c
new file mode 100644 (file)
index 0000000..d9327cd
--- /dev/null
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
+/* Copyright (c) Amazon.com, Inc. or its affiliates.
+ * All rights reserved.
+ */
+
+#ifdef CONFIG_DEBUG_FS
+
+#include <linux/seq_file.h>
+#include <linux/pci.h>
+#include "ena_debugfs.h"
+
+void ena_debugfs_init(struct net_device *dev)
+{
+       struct ena_adapter *adapter = netdev_priv(dev);
+
+       adapter->debugfs_base =
+               debugfs_create_dir(dev_name(&adapter->pdev->dev), NULL);
+}
+
+void ena_debugfs_terminate(struct net_device *dev)
+{
+       struct ena_adapter *adapter = netdev_priv(dev);
+
+       debugfs_remove_recursive(adapter->debugfs_base);
+}
+
+#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/net/ethernet/amazon/ena/ena_debugfs.h b/drivers/net/ethernet/amazon/ena/ena_debugfs.h
new file mode 100644 (file)
index 0000000..dc61dd9
--- /dev/null
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
+/* Copyright (c) Amazon.com, Inc. or its affiliates.
+ * All rights reserved.
+ */
+
+#ifndef __ENA_DEBUGFS_H__
+#define __ENA_DEBUGFS_H__
+
+#include <linux/debugfs.h>
+#include <linux/netdevice.h>
+#include "ena_netdev.h"
+
+#ifdef CONFIG_DEBUG_FS
+
+void ena_debugfs_init(struct net_device *dev);
+
+void ena_debugfs_terminate(struct net_device *dev);
+
+#else /* CONFIG_DEBUG_FS */
+
+static inline void ena_debugfs_init(struct net_device *dev) {}
+
+static inline void ena_debugfs_terminate(struct net_device *dev) {}
+
+#endif /* CONFIG_DEBUG_FS */
+
+#endif /* __ENA_DEBUGFS_H__ */
index cf1b817bf1e0863090ecb71c338192dc0d963c01..92d149d4f0917fd8641a4c904c86f82f371e05a3 100644 (file)
@@ -23,6 +23,8 @@
 
 #include "ena_devlink.h"
 
+#include "ena_debugfs.h"
+
 MODULE_AUTHOR("Amazon.com, Inc. or its affiliates");
 MODULE_DESCRIPTION(DEVICE_NAME);
 MODULE_LICENSE("GPL");
@@ -4060,6 +4062,8 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                goto err_rss;
        }
 
+       ena_debugfs_init(netdev);
+
        INIT_WORK(&adapter->reset_task, ena_fw_reset_device);
 
        adapter->last_keep_alive_jiffies = jiffies;
@@ -4139,6 +4143,8 @@ static void __ena_shutoff(struct pci_dev *pdev, bool shutdown)
        ena_dev = adapter->ena_dev;
        netdev = adapter->netdev;
 
+       ena_debugfs_terminate(netdev);
+
        /* Make sure timer and reset routine won't be called after
         * freeing device resources.
         */
index cba67867ccd2a48a4c54b71042bc9aa232aa86ad..006f9a3acea6cab503edd6afc4facabc4ec8816b 100644 (file)
@@ -391,6 +391,10 @@ struct ena_adapter {
 
        struct devlink *devlink;
        struct devlink_port devlink_port;
+#ifdef CONFIG_DEBUG_FS
+
+       struct dentry *debugfs_base;
+#endif /* CONFIG_DEBUG_FS */
 };
 
 void ena_set_ethtool_ops(struct net_device *netdev);