Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[sfrench/cifs-2.6.git] / drivers / staging / octeon / ethernet-proc.c
1 /**********************************************************************
2  * Author: Cavium Networks
3  *
4  * Contact: support@caviumnetworks.com
5  * This file is part of the OCTEON SDK
6  *
7  * Copyright (c) 2003-2007 Cavium Networks
8  *
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.
12  *
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
17  * details.
18  *
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/.
23  *
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>
30 #include <net/dst.h>
31
32 #include <asm/octeon/octeon.h>
33
34 #include "octeon-ethernet.h"
35 #include "ethernet-defines.h"
36
37 #include "cvmx-helper.h"
38 #include "cvmx-pip.h"
39
40 /**
41  * User is reading /proc/octeon_ethernet_stats
42  *
43  * @m:
44  * @v:
45  * Returns
46  */
47 static int cvm_oct_stats_show(struct seq_file *m, void *v)
48 {
49         struct octeon_ethernet *priv;
50         int port;
51
52         for (port = 0; port < TOTAL_NUMBER_OF_PORTS; port++) {
53
54                 if (cvm_oct_device[port]) {
55                         priv = netdev_priv(cvm_oct_device[port]);
56
57                         seq_printf(m, "\nOcteon Port %d (%s)\n", port,
58                                    cvm_oct_device[port]->name);
59                         seq_printf(m,
60                                    "rx_packets:             %12lu\t"
61                                    "tx_packets:             %12lu\n",
62                                    priv->stats.rx_packets,
63                                    priv->stats.tx_packets);
64                         seq_printf(m,
65                                    "rx_bytes:               %12lu\t"
66                                    "tx_bytes:               %12lu\n",
67                                    priv->stats.rx_bytes, priv->stats.tx_bytes);
68                         seq_printf(m,
69                                    "rx_errors:              %12lu\t"
70                                    "tx_errors:              %12lu\n",
71                                    priv->stats.rx_errors,
72                                    priv->stats.tx_errors);
73                         seq_printf(m,
74                                    "rx_dropped:             %12lu\t"
75                                    "tx_dropped:             %12lu\n",
76                                    priv->stats.rx_dropped,
77                                    priv->stats.tx_dropped);
78                         seq_printf(m,
79                                    "rx_length_errors:       %12lu\t"
80                                    "tx_aborted_errors:      %12lu\n",
81                                    priv->stats.rx_length_errors,
82                                    priv->stats.tx_aborted_errors);
83                         seq_printf(m,
84                                    "rx_over_errors:         %12lu\t"
85                                    "tx_carrier_errors:      %12lu\n",
86                                    priv->stats.rx_over_errors,
87                                    priv->stats.tx_carrier_errors);
88                         seq_printf(m,
89                                    "rx_crc_errors:          %12lu\t"
90                                    "tx_fifo_errors:         %12lu\n",
91                                    priv->stats.rx_crc_errors,
92                                    priv->stats.tx_fifo_errors);
93                         seq_printf(m,
94                                    "rx_frame_errors:        %12lu\t"
95                                    "tx_heartbeat_errors:    %12lu\n",
96                                    priv->stats.rx_frame_errors,
97                                    priv->stats.tx_heartbeat_errors);
98                         seq_printf(m,
99                                    "rx_fifo_errors:         %12lu\t"
100                                    "tx_window_errors:       %12lu\n",
101                                    priv->stats.rx_fifo_errors,
102                                    priv->stats.tx_window_errors);
103                         seq_printf(m,
104                                    "rx_missed_errors:       %12lu\t"
105                                    "multicast:              %12lu\n",
106                                    priv->stats.rx_missed_errors,
107                                    priv->stats.multicast);
108                 }
109         }
110
111         return 0;
112 }
113
114 /**
115  * /proc/octeon_ethernet_stats was openned. Use the single_open iterator
116  *
117  * @inode:
118  * @file:
119  * Returns
120  */
121 static int cvm_oct_stats_open(struct inode *inode, struct file *file)
122 {
123         return single_open(file, cvm_oct_stats_show, NULL);
124 }
125
126 static const struct file_operations cvm_oct_stats_operations = {
127         .open = cvm_oct_stats_open,
128         .read = seq_read,
129         .llseek = seq_lseek,
130         .release = single_release,
131 };
132
133 void cvm_oct_proc_initialize(void)
134 {
135         struct proc_dir_entry *entry =
136             create_proc_entry("octeon_ethernet_stats", 0, NULL);
137         if (entry)
138                 entry->proc_fops = &cvm_oct_stats_operations;
139 }
140
141 void cvm_oct_proc_shutdown(void)
142 {
143         remove_proc_entry("octeon_ethernet_stats", NULL);
144 }