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 <darinzon@amazon.com>
Link: https://patch.msgid.link/20250617110545.5659-8-darinzon@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
David Arinzon 2025-06-17 14:05:43 +03:00 committed by Jakub Kicinski
parent 816b52624c
commit 60e28350b1
6 changed files with 66 additions and 1 deletions

View 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:

View 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

View File

@ -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 */

View File

@ -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__ */

View 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.
*/

View 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);