1 /**********************************************************************
2 * Author: Cavium Networks
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
7 * Copyright (c) 2003-2007 Cavium Networks
9 * This file is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License, Version 2, as
11 * published by the Free Software Foundation.
13 * This file is distributed in the hope that it will be useful, but
14 * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
16 * NONINFRINGEMENT. See the GNU General Public License for more
19 * You should have received a copy of the GNU General Public License
20 * along with this file; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 * or visit http://www.gnu.org/licenses/.
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 **********************************************************************/
27 #include <linux/kernel.h>
28 #include <linux/seq_file.h>
29 #include <linux/proc_fs.h>
32 #include <asm/octeon/octeon.h>
34 #include "octeon-ethernet.h"
35 #include "ethernet-defines.h"
37 #include "cvmx-helper.h"
41 * User is reading /proc/octeon_ethernet_stats
47 static int cvm_oct_stats_show(struct seq_file *m, void *v)
49 struct octeon_ethernet *priv;
52 for (port = 0; port < TOTAL_NUMBER_OF_PORTS; port++) {
54 if (cvm_oct_device[port]) {
55 priv = netdev_priv(cvm_oct_device[port]);
57 seq_printf(m, "\nOcteon Port %d (%s)\n", port,
58 cvm_oct_device[port]->name);
61 "tx_packets: %12lu\n",
62 priv->stats.rx_packets,
63 priv->stats.tx_packets);
67 priv->stats.rx_bytes, priv->stats.tx_bytes);
71 priv->stats.rx_errors,
72 priv->stats.tx_errors);
75 "tx_dropped: %12lu\n",
76 priv->stats.rx_dropped,
77 priv->stats.tx_dropped);
79 "rx_length_errors: %12lu\t"
80 "tx_aborted_errors: %12lu\n",
81 priv->stats.rx_length_errors,
82 priv->stats.tx_aborted_errors);
84 "rx_over_errors: %12lu\t"
85 "tx_carrier_errors: %12lu\n",
86 priv->stats.rx_over_errors,
87 priv->stats.tx_carrier_errors);
89 "rx_crc_errors: %12lu\t"
90 "tx_fifo_errors: %12lu\n",
91 priv->stats.rx_crc_errors,
92 priv->stats.tx_fifo_errors);
94 "rx_frame_errors: %12lu\t"
95 "tx_heartbeat_errors: %12lu\n",
96 priv->stats.rx_frame_errors,
97 priv->stats.tx_heartbeat_errors);
99 "rx_fifo_errors: %12lu\t"
100 "tx_window_errors: %12lu\n",
101 priv->stats.rx_fifo_errors,
102 priv->stats.tx_window_errors);
104 "rx_missed_errors: %12lu\t"
105 "multicast: %12lu\n",
106 priv->stats.rx_missed_errors,
107 priv->stats.multicast);
115 * /proc/octeon_ethernet_stats was openned. Use the single_open iterator
121 static int cvm_oct_stats_open(struct inode *inode, struct file *file)
123 return single_open(file, cvm_oct_stats_show, NULL);
126 static const struct file_operations cvm_oct_stats_operations = {
127 .open = cvm_oct_stats_open,
130 .release = single_release,
133 void cvm_oct_proc_initialize(void)
135 struct proc_dir_entry *entry =
136 create_proc_entry("octeon_ethernet_stats", 0, NULL);
138 entry->proc_fops = &cvm_oct_stats_operations;
141 void cvm_oct_proc_shutdown(void)
143 remove_proc_entry("octeon_ethernet_stats", NULL);