Commit 60e28350 authored by David Arinzon's avatar David Arinzon Committed by Jakub Kicinski
Browse files

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: default avatarDavid Arinzon <darinzon@amazon.com>
Link: https://patch.msgid.link/20250617110545.5659-8-darinzon@amazon.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 816b5262
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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:
+1 −1
Original line number Diff line number Diff line
@@ -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
+27 −0
Original line number Diff line number Diff line
// 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 */
+27 −0
Original line number Diff line number Diff line
/* 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__ */
+6 −0
Original line number Diff line number Diff line
@@ -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.
	 */
Loading