blob: 5cece25c034e0038d29c5a4baba8e295e96b7572 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Name: skproc.c
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.11 $
6 * Date: $Date: 2003/12/11 16:03:57 $
7 * Purpose: Funktions to display statictic data
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * Created 22-Nov-2000
22 * Author: Mirko Lindner (mlindner@syskonnect.de)
23 *
24 * The information in this file is provided "AS IS" without warranty.
25 *
26 ******************************************************************************/
27#include <linux/proc_fs.h>
28#include <linux/seq_file.h>
29
30#include "h/skdrv1st.h"
31#include "h/skdrv2nd.h"
32#include "h/skversion.h"
33
34static int sk_seq_show(struct seq_file *seq, void *v);
35static int sk_proc_open(struct inode *inode, struct file *file);
36
37struct file_operations sk_proc_fops = {
38 .owner = THIS_MODULE,
39 .open = sk_proc_open,
40 .read = seq_read,
41 .llseek = seq_lseek,
42 .release = single_release,
43};
44
45
46/*****************************************************************************
47 *
48 * sk_seq_show - show proc information of a particular adapter
49 *
50 * Description:
51 * This function fills the proc entry with statistic data about
52 * the ethernet device. It invokes the generic sk_gen_browse() to
53 * print out all items one per one.
54 *
55 * Returns: 0
56 *
57 */
58static int sk_seq_show(struct seq_file *seq, void *v)
59{
60 struct net_device *dev = seq->private;
61 DEV_NET *pNet = netdev_priv(dev);
62 SK_AC *pAC = pNet->pAC;
63 SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
64 unsigned long Flags;
65 unsigned int Size;
66 char sens_msg[50];
67 int t;
68 int i;
69
70 /* NetIndex in GetStruct is now required, zero is only dummy */
71 for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
72 if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
73 t--;
74
75 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
76 Size = SK_PNMI_STRUCT_SIZE;
77#ifdef SK_DIAG_SUPPORT
78 if (pAC->BoardLevel == SK_INIT_DATA) {
79 SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
80 if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
81 pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
82 }
83 } else {
84 SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
85 }
86#else
87 SkPnmiGetStruct(pAC, pAC->IoBase,
88 pPnmiStruct, &Size, t-1);
89#endif
90 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
91
92 if (pAC->dev[t-1] == dev) {
93 SK_PNMI_STAT *pPnmiStat = &pPnmiStruct->Stat[0];
94
95 seq_printf(seq, "\nDetailed statistic for device %s\n",
96 pAC->dev[t-1]->name);
97 seq_printf(seq, "=======================================\n");
98
99 /* Board statistics */
100 seq_printf(seq, "\nBoard statistics\n\n");
101 seq_printf(seq, "Active Port %c\n",
102 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
103 Net[t-1].PrefPort]->PortNumber);
104 seq_printf(seq, "Preferred Port %c\n",
105 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
106 Net[t-1].PrefPort]->PortNumber);
107
108 seq_printf(seq, "Bus speed (MHz) %d\n",
109 pPnmiStruct->BusSpeed);
110
111 seq_printf(seq, "Bus width (Bit) %d\n",
112 pPnmiStruct->BusWidth);
113 seq_printf(seq, "Driver version %s\n",
114 VER_STRING);
115 seq_printf(seq, "Hardware revision v%d.%d\n",
116 (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
117 pAC->GIni.GIPciHwRev & 0x0F);
118
119 /* Print sensor informations */
120 for (i=0; i < pAC->I2c.MaxSens; i ++) {
121 /* Check type */
122 switch (pAC->I2c.SenTable[i].SenType) {
123 case 1:
124 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
125 strcat(sens_msg, " (C)");
126 seq_printf(seq, "%-25s %d.%02d\n",
127 sens_msg,
128 pAC->I2c.SenTable[i].SenValue / 10,
129 pAC->I2c.SenTable[i].SenValue % 10);
130
131 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
132 strcat(sens_msg, " (F)");
133 seq_printf(seq, "%-25s %d.%02d\n",
134 sens_msg,
135 ((((pAC->I2c.SenTable[i].SenValue)
136 *10)*9)/5 + 3200)/100,
137 ((((pAC->I2c.SenTable[i].SenValue)
138 *10)*9)/5 + 3200) % 10);
139 break;
140 case 2:
141 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
142 strcat(sens_msg, " (V)");
143 seq_printf(seq, "%-25s %d.%03d\n",
144 sens_msg,
145 pAC->I2c.SenTable[i].SenValue / 1000,
146 pAC->I2c.SenTable[i].SenValue % 1000);
147 break;
148 case 3:
149 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
150 strcat(sens_msg, " (rpm)");
151 seq_printf(seq, "%-25s %d\n",
152 sens_msg,
153 pAC->I2c.SenTable[i].SenValue);
154 break;
155 default:
156 break;
157 }
158 }
159
160 /*Receive statistics */
161 seq_printf(seq, "\nReceive statistics\n\n");
162
163 seq_printf(seq, "Received bytes %Lu\n",
164 (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
165 seq_printf(seq, "Received packets %Lu\n",
166 (unsigned long long) pPnmiStat->StatRxOkCts);
167#if 0
168 if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
169 pAC->HWRevision < 12) {
170 pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
171 pPnmiStat->StatRxShortsCts;
172 pPnmiStat->StatRxShortsCts = 0;
173 }
174#endif
175 if (dev->mtu > 1500)
176 pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
177 pPnmiStat->StatRxTooLongCts;
178
179 seq_printf(seq, "Receive errors %Lu\n",
180 (unsigned long long) pPnmiStruct->InErrorsCts);
181 seq_printf(seq, "Receive dropped %Lu\n",
182 (unsigned long long) pPnmiStruct->RxNoBufCts);
183 seq_printf(seq, "Received multicast %Lu\n",
184 (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
185 seq_printf(seq, "Receive error types\n");
186 seq_printf(seq, " length %Lu\n",
187 (unsigned long long) pPnmiStat->StatRxRuntCts);
188 seq_printf(seq, " buffer overflow %Lu\n",
189 (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
190 seq_printf(seq, " bad crc %Lu\n",
191 (unsigned long long) pPnmiStat->StatRxFcsCts);
192 seq_printf(seq, " framing %Lu\n",
193 (unsigned long long) pPnmiStat->StatRxFramingCts);
194 seq_printf(seq, " missed frames %Lu\n",
195 (unsigned long long) pPnmiStat->StatRxMissedCts);
196
197 if (dev->mtu > 1500)
198 pPnmiStat->StatRxTooLongCts = 0;
199
200 seq_printf(seq, " too long %Lu\n",
201 (unsigned long long) pPnmiStat->StatRxTooLongCts);
202 seq_printf(seq, " carrier extension %Lu\n",
203 (unsigned long long) pPnmiStat->StatRxCextCts);
204 seq_printf(seq, " too short %Lu\n",
205 (unsigned long long) pPnmiStat->StatRxShortsCts);
206 seq_printf(seq, " symbol %Lu\n",
207 (unsigned long long) pPnmiStat->StatRxSymbolCts);
208 seq_printf(seq, " LLC MAC size %Lu\n",
209 (unsigned long long) pPnmiStat->StatRxIRLengthCts);
210 seq_printf(seq, " carrier event %Lu\n",
211 (unsigned long long) pPnmiStat->StatRxCarrierCts);
212 seq_printf(seq, " jabber %Lu\n",
213 (unsigned long long) pPnmiStat->StatRxJabberCts);
214
215
216 /*Transmit statistics */
217 seq_printf(seq, "\nTransmit statistics\n\n");
218
219 seq_printf(seq, "Transmited bytes %Lu\n",
220 (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
221 seq_printf(seq, "Transmited packets %Lu\n",
222 (unsigned long long) pPnmiStat->StatTxOkCts);
223 seq_printf(seq, "Transmit errors %Lu\n",
224 (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
225 seq_printf(seq, "Transmit dropped %Lu\n",
226 (unsigned long long) pPnmiStruct->TxNoBufCts);
227 seq_printf(seq, "Transmit collisions %Lu\n",
228 (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
229 seq_printf(seq, "Transmit error types\n");
230 seq_printf(seq, " excessive collision %ld\n",
231 pAC->stats.tx_aborted_errors);
232 seq_printf(seq, " carrier %Lu\n",
233 (unsigned long long) pPnmiStat->StatTxCarrierCts);
234 seq_printf(seq, " fifo underrun %Lu\n",
235 (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
236 seq_printf(seq, " heartbeat %Lu\n",
237 (unsigned long long) pPnmiStat->StatTxCarrierCts);
238 seq_printf(seq, " window %ld\n",
239 pAC->stats.tx_window_errors);
240
241 }
242 }
243 return 0;
244}
245
246/*****************************************************************************
247 *
248 * sk_proc_open - register the show function when proc is open'ed
249 *
250 * Description:
251 * This function is called whenever a sk98lin proc file is queried.
252 *
253 * Returns: the return value of single_open()
254 *
255 */
256static int sk_proc_open(struct inode *inode, struct file *file)
257{
258 return single_open(file, sk_seq_show, PDE(inode)->data);
259}
260
261/*******************************************************************************
262 *
263 * End of file
264 *
265 ******************************************************************************/