1 /****************************************************************************
2 * Solarflare driver for Xen network acceleration
4 * Copyright 2006-2008: Solarflare Communications Inc,
5 * 9501 Jeronimo Road, Suite 250,
6 * Irvine, CA 92618, USA
8 * Maintained by Solarflare Communications <linux-xen-drivers@solarflare.com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation, incorporated herein by reference.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 ****************************************************************************
26 #include <linux/debugfs.h>
30 #if defined(CONFIG_DEBUG_FS)
31 static struct dentry *sfc_debugfs_root = NULL;
34 #if NETBACK_ACCEL_STATS
35 struct netback_accel_global_stats global_stats;
36 #if defined(CONFIG_DEBUG_FS)
37 static struct netback_accel_global_dbfs global_dbfs;
41 void netback_accel_debugfs_init(void)
43 #if defined(CONFIG_DEBUG_FS)
44 sfc_debugfs_root = debugfs_create_dir("sfc_netback", NULL);
45 if (sfc_debugfs_root == NULL)
48 global_dbfs.num_fwds = debugfs_create_u32
49 ("num_fwds", S_IRUSR | S_IRGRP | S_IROTH,
50 sfc_debugfs_root, &global_stats.num_fwds);
51 global_dbfs.dl_tx_packets = debugfs_create_u64
52 ("dl_tx_packets", S_IRUSR | S_IRGRP | S_IROTH,
53 sfc_debugfs_root, &global_stats.dl_tx_packets);
54 global_dbfs.dl_rx_packets = debugfs_create_u64
55 ("dl_rx_packets", S_IRUSR | S_IRGRP | S_IROTH,
56 sfc_debugfs_root, &global_stats.dl_rx_packets);
57 global_dbfs.dl_tx_bad_packets = debugfs_create_u64
58 ("dl_tx_bad_packets", S_IRUSR | S_IRGRP | S_IROTH,
59 sfc_debugfs_root, &global_stats.dl_tx_bad_packets);
64 void netback_accel_debugfs_fini(void)
66 #if defined(CONFIG_DEBUG_FS)
67 debugfs_remove(global_dbfs.num_fwds);
68 debugfs_remove(global_dbfs.dl_tx_packets);
69 debugfs_remove(global_dbfs.dl_rx_packets);
70 debugfs_remove(global_dbfs.dl_tx_bad_packets);
72 debugfs_remove(sfc_debugfs_root);
77 int netback_accel_debugfs_create(struct netback_accel *bend)
79 #if defined(CONFIG_DEBUG_FS)
80 /* Smallest length is 7 (vif0.0\n) */
83 if (sfc_debugfs_root == NULL)
86 /* Work out length of string representation of far_end and vif_num */
98 bend->dbfs_dir_name = kmalloc(length, GFP_KERNEL);
99 if (bend->dbfs_dir_name == NULL)
101 sprintf(bend->dbfs_dir_name, "vif%d.%d", bend->far_end, bend->vif_num);
103 bend->dbfs_dir = debugfs_create_dir(bend->dbfs_dir_name,
105 if (bend->dbfs_dir == NULL) {
106 kfree(bend->dbfs_dir_name);
110 #if NETBACK_ACCEL_STATS
111 bend->dbfs.evq_wakeups = debugfs_create_u64
112 ("evq_wakeups", S_IRUSR | S_IRGRP | S_IROTH,
113 bend->dbfs_dir, &bend->stats.evq_wakeups);
114 bend->dbfs.evq_timeouts = debugfs_create_u64
115 ("evq_timeouts", S_IRUSR | S_IRGRP | S_IROTH,
116 bend->dbfs_dir, &bend->stats.evq_timeouts);
117 bend->dbfs.num_filters = debugfs_create_u32
118 ("num_filters", S_IRUSR | S_IRGRP | S_IROTH,
119 bend->dbfs_dir, &bend->stats.num_filters);
120 bend->dbfs.num_buffer_pages = debugfs_create_u32
121 ("num_buffer_pages", S_IRUSR | S_IRGRP | S_IROTH,
122 bend->dbfs_dir, &bend->stats.num_buffer_pages);
129 int netback_accel_debugfs_remove(struct netback_accel *bend)
131 #if defined(CONFIG_DEBUG_FS)
132 if (bend->dbfs_dir != NULL) {
133 #if NETBACK_ACCEL_STATS
134 debugfs_remove(bend->dbfs.evq_wakeups);
135 debugfs_remove(bend->dbfs.evq_timeouts);
136 debugfs_remove(bend->dbfs.num_filters);
137 debugfs_remove(bend->dbfs.num_buffer_pages);
139 debugfs_remove(bend->dbfs_dir);
142 if (bend->dbfs_dir_name)
143 kfree(bend->dbfs_dir_name);