aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatherine Sullivan <catherine.sullivan@intel.com>2012-08-09 21:59:10 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-09-15 19:15:00 -0400
commit00949167d6f34f83e9e185ab4f7a3a94bf4c5a1c (patch)
tree7e830a22a0f673ca8ee97337f5f76dd923d07652
parentd6ea07545226cd2590fc21601051dc1493c5ef9e (diff)
ixgbe: add debugfs support
This patch adds debugfs support to the ixgbe driver to give users the ability to access kernel information and to simulate kernel events. The filesystem is set up in the following driver/PCI-instance hierarchy: <debugfs> |-- ixgbe |-- PCI instance | |-- attribute files Signed-off-by: Catherine Sullivan <catherine.sullivan@intel.com> Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/Makefile2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h10
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c79
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c17
4 files changed, 106 insertions, 2 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/Makefile b/drivers/net/ethernet/intel/ixgbe/Makefile
index 5fd5d04c26c9..89f40e51fc13 100644
--- a/drivers/net/ethernet/intel/ixgbe/Makefile
+++ b/drivers/net/ethernet/intel/ixgbe/Makefile
@@ -32,7 +32,7 @@
32 32
33obj-$(CONFIG_IXGBE) += ixgbe.o 33obj-$(CONFIG_IXGBE) += ixgbe.o
34 34
35ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \ 35ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o ixgbe_debugfs.o\
36 ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \ 36 ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \
37 ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o 37 ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o
38 38
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index bffcf1f2357a..5bd26763554c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -597,6 +597,9 @@ struct ixgbe_adapter {
597#ifdef CONFIG_IXGBE_HWMON 597#ifdef CONFIG_IXGBE_HWMON
598 struct hwmon_buff ixgbe_hwmon_buff; 598 struct hwmon_buff ixgbe_hwmon_buff;
599#endif /* CONFIG_IXGBE_HWMON */ 599#endif /* CONFIG_IXGBE_HWMON */
600#ifdef CONFIG_DEBUG_FS
601 struct dentry *ixgbe_dbg_adapter;
602#endif /*CONFIG_DEBUG_FS*/
600}; 603};
601 604
602struct ixgbe_fdir_filter { 605struct ixgbe_fdir_filter {
@@ -725,7 +728,12 @@ extern int ixgbe_fcoe_get_hbainfo(struct net_device *netdev,
725 struct netdev_fcoe_hbainfo *info); 728 struct netdev_fcoe_hbainfo *info);
726extern u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter); 729extern u8 ixgbe_fcoe_get_tc(struct ixgbe_adapter *adapter);
727#endif /* IXGBE_FCOE */ 730#endif /* IXGBE_FCOE */
728 731#ifdef CONFIG_DEBUG_FS
732extern void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter);
733extern void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter);
734extern void ixgbe_dbg_init(void);
735extern void ixgbe_dbg_exit(void);
736#endif /* CONFIG_DEBUG_FS */
729static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring) 737static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)
730{ 738{
731 return netdev_get_tx_queue(ring->netdev, ring->queue_index); 739 return netdev_get_tx_queue(ring->netdev, ring->queue_index);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
new file mode 100644
index 000000000000..0b08b6c7497c
--- /dev/null
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c
@@ -0,0 +1,79 @@
1/*******************************************************************************
2
3 Intel 10 Gigabit PCI Express Linux driver
4 Copyright(c) 1999 - 2012 Intel Corporation.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25
26*******************************************************************************/
27
28#ifdef CONFIG_DEBUG_FS
29
30#include <linux/debugfs.h>
31#include <linux/module.h>
32
33#include "ixgbe.h"
34
35static struct dentry *ixgbe_dbg_root;
36
37/**
38 * ixgbe_dbg_adapter_init - setup the debugfs directory for the adapter
39 * @adapter: the adapter that is starting up
40 **/
41void ixgbe_dbg_adapter_init(struct ixgbe_adapter *adapter)
42{
43 const char *name = pci_name(adapter->pdev);
44
45 adapter->ixgbe_dbg_adapter = debugfs_create_dir(name, ixgbe_dbg_root);
46 if (!adapter->ixgbe_dbg_adapter)
47 e_dev_err("debugfs entry for %s failed\n", name);
48}
49
50/**
51 * ixgbe_dbg_adapter_exit - clear out the adapter's debugfs entries
52 * @pf: the pf that is stopping
53 **/
54void ixgbe_dbg_adapter_exit(struct ixgbe_adapter *adapter)
55{
56 if (adapter->ixgbe_dbg_adapter)
57 debugfs_remove_recursive(adapter->ixgbe_dbg_adapter);
58 adapter->ixgbe_dbg_adapter = NULL;
59}
60
61/**
62 * ixgbe_dbg_init - start up debugfs for the driver
63 **/
64void ixgbe_dbg_init(void)
65{
66 ixgbe_dbg_root = debugfs_create_dir(ixgbe_driver_name, NULL);
67 if (ixgbe_dbg_root == NULL)
68 pr_err("init of debugfs failed\n");
69}
70
71/**
72 * ixgbe_dbg_exit - clean out the driver's debugfs entries
73 **/
74void ixgbe_dbg_exit(void)
75{
76 debugfs_remove_recursive(ixgbe_dbg_root);
77}
78
79#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index e641f14eddcd..b3b846b32deb 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7448,6 +7448,10 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
7448 e_err(probe, "failed to allocate sysfs resources\n"); 7448 e_err(probe, "failed to allocate sysfs resources\n");
7449#endif /* CONFIG_IXGBE_HWMON */ 7449#endif /* CONFIG_IXGBE_HWMON */
7450 7450
7451#ifdef CONFIG_DEBUG_FS
7452 ixgbe_dbg_adapter_init(adapter);
7453#endif /* CONFIG_DEBUG_FS */
7454
7451 return 0; 7455 return 0;
7452 7456
7453err_register: 7457err_register:
@@ -7482,6 +7486,10 @@ static void __devexit ixgbe_remove(struct pci_dev *pdev)
7482 struct ixgbe_adapter *adapter = pci_get_drvdata(pdev); 7486 struct ixgbe_adapter *adapter = pci_get_drvdata(pdev);
7483 struct net_device *netdev = adapter->netdev; 7487 struct net_device *netdev = adapter->netdev;
7484 7488
7489#ifdef CONFIG_DEBUG_FS
7490 ixgbe_dbg_adapter_exit(adapter);
7491#endif /*CONFIG_DEBUG_FS */
7492
7485 set_bit(__IXGBE_DOWN, &adapter->state); 7493 set_bit(__IXGBE_DOWN, &adapter->state);
7486 cancel_work_sync(&adapter->service_task); 7494 cancel_work_sync(&adapter->service_task);
7487 7495
@@ -7737,6 +7745,10 @@ static int __init ixgbe_init_module(void)
7737 pr_info("%s - version %s\n", ixgbe_driver_string, ixgbe_driver_version); 7745 pr_info("%s - version %s\n", ixgbe_driver_string, ixgbe_driver_version);
7738 pr_info("%s\n", ixgbe_copyright); 7746 pr_info("%s\n", ixgbe_copyright);
7739 7747
7748#ifdef CONFIG_DEBUG_FS
7749 ixgbe_dbg_init();
7750#endif /* CONFIG_DEBUG_FS */
7751
7740#ifdef CONFIG_IXGBE_DCA 7752#ifdef CONFIG_IXGBE_DCA
7741 dca_register_notify(&dca_notifier); 7753 dca_register_notify(&dca_notifier);
7742#endif 7754#endif
@@ -7759,6 +7771,11 @@ static void __exit ixgbe_exit_module(void)
7759 dca_unregister_notify(&dca_notifier); 7771 dca_unregister_notify(&dca_notifier);
7760#endif 7772#endif
7761 pci_unregister_driver(&ixgbe_driver); 7773 pci_unregister_driver(&ixgbe_driver);
7774
7775#ifdef CONFIG_DEBUG_FS
7776 ixgbe_dbg_exit();
7777#endif /* CONFIG_DEBUG_FS */
7778
7762 rcu_barrier(); /* Wait for completion of call_rcu()'s */ 7779 rcu_barrier(); /* Wait for completion of call_rcu()'s */
7763} 7780}
7764 7781