mm-only debug patch...
[mmotm.git] / drivers / staging / octeon / ethernet-proc.c
blob8fa88fc419b7b6f144bf9f4cf6a83c25cdb6c556
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
17 * details.
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/mii.h>
29 #include <linux/seq_file.h>
30 #include <linux/proc_fs.h>
31 #include <net/dst.h>
33 #include <asm/octeon/octeon.h>
35 #include "octeon-ethernet.h"
36 #include "ethernet-defines.h"
38 #include "cvmx-helper.h"
39 #include "cvmx-pip.h"
41 static unsigned long long cvm_oct_stats_read_switch(struct net_device *dev,
42 int phy_id, int offset)
44 struct octeon_ethernet *priv = netdev_priv(dev);
46 priv->mii_info.mdio_write(dev, phy_id, 0x1d, 0xcc00 | offset);
47 return ((uint64_t) priv->mii_info.
48 mdio_read(dev, phy_id,
49 0x1e) << 16) | (uint64_t) priv->mii_info.
50 mdio_read(dev, phy_id, 0x1f);
53 static int cvm_oct_stats_switch_show(struct seq_file *m, void *v)
55 static const int ports[] = { 0, 1, 2, 3, 9, -1 };
56 struct net_device *dev = cvm_oct_device[0];
57 int index = 0;
59 while (ports[index] != -1) {
61 /* Latch port */
62 struct octeon_ethernet *priv = netdev_priv(dev);
64 priv->mii_info.mdio_write(dev, 0x1b, 0x1d,
65 0xdc00 | ports[index]);
66 seq_printf(m, "\nSwitch Port %d\n", ports[index]);
67 seq_printf(m, "InGoodOctets: %12llu\t"
68 "OutOctets: %12llu\t"
69 "64 Octets: %12llu\n",
70 cvm_oct_stats_read_switch(dev, 0x1b,
71 0x00) |
72 (cvm_oct_stats_read_switch(dev, 0x1b, 0x01) << 32),
73 cvm_oct_stats_read_switch(dev, 0x1b,
74 0x0E) |
75 (cvm_oct_stats_read_switch(dev, 0x1b, 0x0F) << 32),
76 cvm_oct_stats_read_switch(dev, 0x1b, 0x08));
78 seq_printf(m, "InBadOctets: %12llu\t"
79 "OutUnicast: %12llu\t"
80 "65-127 Octets: %12llu\n",
81 cvm_oct_stats_read_switch(dev, 0x1b, 0x02),
82 cvm_oct_stats_read_switch(dev, 0x1b, 0x10),
83 cvm_oct_stats_read_switch(dev, 0x1b, 0x09));
85 seq_printf(m, "InUnicast: %12llu\t"
86 "OutBroadcasts: %12llu\t"
87 "128-255 Octets: %12llu\n",
88 cvm_oct_stats_read_switch(dev, 0x1b, 0x04),
89 cvm_oct_stats_read_switch(dev, 0x1b, 0x13),
90 cvm_oct_stats_read_switch(dev, 0x1b, 0x0A));
92 seq_printf(m, "InBroadcasts: %12llu\t"
93 "OutMulticasts: %12llu\t"
94 "256-511 Octets: %12llu\n",
95 cvm_oct_stats_read_switch(dev, 0x1b, 0x06),
96 cvm_oct_stats_read_switch(dev, 0x1b, 0x12),
97 cvm_oct_stats_read_switch(dev, 0x1b, 0x0B));
99 seq_printf(m, "InMulticasts: %12llu\t"
100 "OutPause: %12llu\t"
101 "512-1023 Octets:%12llu\n",
102 cvm_oct_stats_read_switch(dev, 0x1b, 0x07),
103 cvm_oct_stats_read_switch(dev, 0x1b, 0x15),
104 cvm_oct_stats_read_switch(dev, 0x1b, 0x0C));
106 seq_printf(m, "InPause: %12llu\t"
107 "Excessive: %12llu\t"
108 "1024-Max Octets:%12llu\n",
109 cvm_oct_stats_read_switch(dev, 0x1b, 0x16),
110 cvm_oct_stats_read_switch(dev, 0x1b, 0x11),
111 cvm_oct_stats_read_switch(dev, 0x1b, 0x0D));
113 seq_printf(m, "InUndersize: %12llu\t"
114 "Collisions: %12llu\n",
115 cvm_oct_stats_read_switch(dev, 0x1b, 0x18),
116 cvm_oct_stats_read_switch(dev, 0x1b, 0x1E));
118 seq_printf(m, "InFragments: %12llu\t"
119 "Deferred: %12llu\n",
120 cvm_oct_stats_read_switch(dev, 0x1b, 0x19),
121 cvm_oct_stats_read_switch(dev, 0x1b, 0x05));
123 seq_printf(m, "InOversize: %12llu\t"
124 "Single: %12llu\n",
125 cvm_oct_stats_read_switch(dev, 0x1b, 0x1A),
126 cvm_oct_stats_read_switch(dev, 0x1b, 0x14));
128 seq_printf(m, "InJabber: %12llu\t"
129 "Multiple: %12llu\n",
130 cvm_oct_stats_read_switch(dev, 0x1b, 0x1B),
131 cvm_oct_stats_read_switch(dev, 0x1b, 0x17));
133 seq_printf(m, "In RxErr: %12llu\t"
134 "OutFCSErr: %12llu\n",
135 cvm_oct_stats_read_switch(dev, 0x1b, 0x1C),
136 cvm_oct_stats_read_switch(dev, 0x1b, 0x03));
138 seq_printf(m, "InFCSErr: %12llu\t"
139 "Late: %12llu\n",
140 cvm_oct_stats_read_switch(dev, 0x1b, 0x1D),
141 cvm_oct_stats_read_switch(dev, 0x1b, 0x1F));
142 index++;
144 return 0;
148 * User is reading /proc/octeon_ethernet_stats
150 * @m:
151 * @v:
152 * Returns
154 static int cvm_oct_stats_show(struct seq_file *m, void *v)
156 struct octeon_ethernet *priv;
157 int port;
159 for (port = 0; port < TOTAL_NUMBER_OF_PORTS; port++) {
161 if (cvm_oct_device[port]) {
162 priv = netdev_priv(cvm_oct_device[port]);
164 seq_printf(m, "\nOcteon Port %d (%s)\n", port,
165 cvm_oct_device[port]->name);
166 seq_printf(m,
167 "rx_packets: %12lu\t"
168 "tx_packets: %12lu\n",
169 priv->stats.rx_packets,
170 priv->stats.tx_packets);
171 seq_printf(m,
172 "rx_bytes: %12lu\t"
173 "tx_bytes: %12lu\n",
174 priv->stats.rx_bytes, priv->stats.tx_bytes);
175 seq_printf(m,
176 "rx_errors: %12lu\t"
177 "tx_errors: %12lu\n",
178 priv->stats.rx_errors,
179 priv->stats.tx_errors);
180 seq_printf(m,
181 "rx_dropped: %12lu\t"
182 "tx_dropped: %12lu\n",
183 priv->stats.rx_dropped,
184 priv->stats.tx_dropped);
185 seq_printf(m,
186 "rx_length_errors: %12lu\t"
187 "tx_aborted_errors: %12lu\n",
188 priv->stats.rx_length_errors,
189 priv->stats.tx_aborted_errors);
190 seq_printf(m,
191 "rx_over_errors: %12lu\t"
192 "tx_carrier_errors: %12lu\n",
193 priv->stats.rx_over_errors,
194 priv->stats.tx_carrier_errors);
195 seq_printf(m,
196 "rx_crc_errors: %12lu\t"
197 "tx_fifo_errors: %12lu\n",
198 priv->stats.rx_crc_errors,
199 priv->stats.tx_fifo_errors);
200 seq_printf(m,
201 "rx_frame_errors: %12lu\t"
202 "tx_heartbeat_errors: %12lu\n",
203 priv->stats.rx_frame_errors,
204 priv->stats.tx_heartbeat_errors);
205 seq_printf(m,
206 "rx_fifo_errors: %12lu\t"
207 "tx_window_errors: %12lu\n",
208 priv->stats.rx_fifo_errors,
209 priv->stats.tx_window_errors);
210 seq_printf(m,
211 "rx_missed_errors: %12lu\t"
212 "multicast: %12lu\n",
213 priv->stats.rx_missed_errors,
214 priv->stats.multicast);
218 if (cvm_oct_device[0]) {
219 priv = netdev_priv(cvm_oct_device[0]);
220 if (priv->imode == CVMX_HELPER_INTERFACE_MODE_GMII)
221 cvm_oct_stats_switch_show(m, v);
223 return 0;
227 * /proc/octeon_ethernet_stats was openned. Use the single_open iterator
229 * @inode:
230 * @file:
231 * Returns
233 static int cvm_oct_stats_open(struct inode *inode, struct file *file)
235 return single_open(file, cvm_oct_stats_show, NULL);
238 static const struct file_operations cvm_oct_stats_operations = {
239 .open = cvm_oct_stats_open,
240 .read = seq_read,
241 .llseek = seq_lseek,
242 .release = single_release,
245 void cvm_oct_proc_initialize(void)
247 struct proc_dir_entry *entry =
248 create_proc_entry("octeon_ethernet_stats", 0, NULL);
249 if (entry)
250 entry->proc_fops = &cvm_oct_stats_operations;
253 void cvm_oct_proc_shutdown(void)
255 remove_proc_entry("octeon_ethernet_stats", NULL);