1 /******************************************************************************
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
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
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.
22 * Author: Mirko Lindner (mlindner@syskonnect.de)
24 * The information in this file is provided "AS IS" without warranty.
26 ******************************************************************************/
27 #include <linux/proc_fs.h>
28 #include <linux/seq_file.h>
30 #include "h/skdrv1st.h"
31 #include "h/skdrv2nd.h"
32 #include "h/skversion.h"
34 extern struct SK_NET_DEVICE *SkGeRootDev;
35 static int sk_proc_print(void *writePtr, char *format, ...);
36 static void sk_gen_browse(void *buffer);
39 static int sk_seq_show(struct seq_file *seq, void *v);
40 static int sk_proc_open(struct inode *inode, struct file *file);
41 struct file_operations sk_proc_fops = {
46 .release = single_release,
48 struct net_device *currDev = NULL;
50 /*****************************************************************************
52 * sk_gen_browse -generic print "summaries" entry
55 * This function fills the proc entry with statistic data about
56 * the ethernet device.
61 static void sk_gen_browse(void *buffer)
63 struct SK_NET_DEVICE *SkgeProcDev = SkGeRootDev;
64 struct SK_NET_DEVICE *next;
65 SK_PNMI_STRUCT_DATA *pPnmiStruct;
66 SK_PNMI_STAT *pPnmiStat;
72 int MaxSecurityCount = 0;
78 if (MaxSecurityCount > 100) {
79 printk("Max limit for sk_proc_read security counter!\n");
82 pNet = (DEV_NET*) SkgeProcDev->priv;
85 pPnmiStruct = &pAC->PnmiStruct;
86 /* NetIndex in GetStruct is now required, zero is only dummy */
88 for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
89 if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
92 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
93 Size = SK_PNMI_STRUCT_SIZE;
94 #ifdef SK_DIAG_SUPPORT
95 if (pAC->BoardLevel == SK_INIT_DATA) {
96 SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
97 if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
98 pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
101 SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
104 SkPnmiGetStruct(pAC, pAC->IoBase,
105 pPnmiStruct, &Size, t-1);
107 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
109 if (strcmp(pAC->dev[t-1]->name, currDev->name) == 0) {
110 pPnmiStat = &pPnmiStruct->Stat[0];
111 len = sk_proc_print(buffer,
112 "\nDetailed statistic for device %s\n",
113 pAC->dev[t-1]->name);
114 len += sk_proc_print(buffer,
115 "=======================================\n");
117 /* Board statistics */
118 len += sk_proc_print(buffer,
119 "\nBoard statistics\n\n");
120 len += sk_proc_print(buffer,
122 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
123 Net[t-1].PrefPort]->PortNumber);
124 len += sk_proc_print(buffer,
125 "Preferred Port %c\n",
126 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
127 Net[t-1].PrefPort]->PortNumber);
129 len += sk_proc_print(buffer,
130 "Bus speed (MHz) %d\n",
131 pPnmiStruct->BusSpeed);
133 len += sk_proc_print(buffer,
134 "Bus width (Bit) %d\n",
135 pPnmiStruct->BusWidth);
136 len += sk_proc_print(buffer,
137 "Driver version %s\n",
139 len += sk_proc_print(buffer,
140 "Hardware revision v%d.%d\n",
141 (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
142 pAC->GIni.GIPciHwRev & 0x0F);
144 /* Print sensor informations */
145 for (i=0; i < pAC->I2c.MaxSens; i ++) {
147 switch (pAC->I2c.SenTable[i].SenType) {
149 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
150 strcat(sens_msg, " (C)");
151 len += sk_proc_print(buffer,
154 pAC->I2c.SenTable[i].SenValue / 10,
155 pAC->I2c.SenTable[i].SenValue % 10);
157 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
158 strcat(sens_msg, " (F)");
159 len += sk_proc_print(buffer,
162 ((((pAC->I2c.SenTable[i].SenValue)
163 *10)*9)/5 + 3200)/100,
164 ((((pAC->I2c.SenTable[i].SenValue)
165 *10)*9)/5 + 3200) % 10);
168 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
169 strcat(sens_msg, " (V)");
170 len += sk_proc_print(buffer,
173 pAC->I2c.SenTable[i].SenValue / 1000,
174 pAC->I2c.SenTable[i].SenValue % 1000);
177 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
178 strcat(sens_msg, " (rpm)");
179 len += sk_proc_print(buffer,
182 pAC->I2c.SenTable[i].SenValue);
189 /*Receive statistics */
190 len += sk_proc_print(buffer,
191 "\nReceive statistics\n\n");
193 len += sk_proc_print(buffer,
194 "Received bytes %Lu\n",
195 (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
196 len += sk_proc_print(buffer,
197 "Received packets %Lu\n",
198 (unsigned long long) pPnmiStat->StatRxOkCts);
200 if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
201 pAC->HWRevision < 12) {
202 pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
203 pPnmiStat->StatRxShortsCts;
204 pPnmiStat->StatRxShortsCts = 0;
207 if (pNet->Mtu > 1500)
208 pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
209 pPnmiStat->StatRxTooLongCts;
211 len += sk_proc_print(buffer,
212 "Receive errors %Lu\n",
213 (unsigned long long) pPnmiStruct->InErrorsCts);
214 len += sk_proc_print(buffer,
215 "Receive dropped %Lu\n",
216 (unsigned long long) pPnmiStruct->RxNoBufCts);
217 len += sk_proc_print(buffer,
218 "Received multicast %Lu\n",
219 (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
220 len += sk_proc_print(buffer,
221 "Receive error types\n");
222 len += sk_proc_print(buffer,
224 (unsigned long long) pPnmiStat->StatRxRuntCts);
225 len += sk_proc_print(buffer,
226 " buffer overflow %Lu\n",
227 (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
228 len += sk_proc_print(buffer,
230 (unsigned long long) pPnmiStat->StatRxFcsCts);
231 len += sk_proc_print(buffer,
233 (unsigned long long) pPnmiStat->StatRxFramingCts);
234 len += sk_proc_print(buffer,
235 " missed frames %Lu\n",
236 (unsigned long long) pPnmiStat->StatRxMissedCts);
238 if (pNet->Mtu > 1500)
239 pPnmiStat->StatRxTooLongCts = 0;
241 len += sk_proc_print(buffer,
243 (unsigned long long) pPnmiStat->StatRxTooLongCts);
244 len += sk_proc_print(buffer,
245 " carrier extension %Lu\n",
246 (unsigned long long) pPnmiStat->StatRxCextCts);
247 len += sk_proc_print(buffer,
249 (unsigned long long) pPnmiStat->StatRxShortsCts);
250 len += sk_proc_print(buffer,
252 (unsigned long long) pPnmiStat->StatRxSymbolCts);
253 len += sk_proc_print(buffer,
254 " LLC MAC size %Lu\n",
255 (unsigned long long) pPnmiStat->StatRxIRLengthCts);
256 len += sk_proc_print(buffer,
257 " carrier event %Lu\n",
258 (unsigned long long) pPnmiStat->StatRxCarrierCts);
259 len += sk_proc_print(buffer,
261 (unsigned long long) pPnmiStat->StatRxJabberCts);
264 /*Transmit statistics */
265 len += sk_proc_print(buffer,
266 "\nTransmit statistics\n\n");
268 len += sk_proc_print(buffer,
269 "Transmited bytes %Lu\n",
270 (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
271 len += sk_proc_print(buffer,
272 "Transmited packets %Lu\n",
273 (unsigned long long) pPnmiStat->StatTxOkCts);
274 len += sk_proc_print(buffer,
275 "Transmit errors %Lu\n",
276 (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
277 len += sk_proc_print(buffer,
278 "Transmit dropped %Lu\n",
279 (unsigned long long) pPnmiStruct->TxNoBufCts);
280 len += sk_proc_print(buffer,
281 "Transmit collisions %Lu\n",
282 (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
283 len += sk_proc_print(buffer,
284 "Transmit error types\n");
285 len += sk_proc_print(buffer,
286 " excessive collision %ld\n",
287 pAC->stats.tx_aborted_errors);
288 len += sk_proc_print(buffer,
290 (unsigned long long) pPnmiStat->StatTxCarrierCts);
291 len += sk_proc_print(buffer,
292 " fifo underrun %Lu\n",
293 (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
294 len += sk_proc_print(buffer,
296 (unsigned long long) pPnmiStat->StatTxCarrierCts);
297 len += sk_proc_print(buffer,
299 pAC->stats.tx_window_errors);
301 } /* if (strcmp(pACname, currDeviceName) == 0) */
307 /*****************************************************************************
309 * sk_proc_print -generic line print
312 * This function fills the proc entry with statistic data about
313 * the ethernet device.
315 * Returns: number of bytes written
318 static int sk_proc_print(void *writePtr, char *format, ...)
320 #define MAX_LEN_SINGLE_LINE 256
321 char str[MAX_LEN_SINGLE_LINE];
325 struct seq_file *seq = (struct seq_file *) writePtr;
327 SK_MEMSET(str, 0, MAX_LEN_SINGLE_LINE);
329 va_start(a_start, format);
330 vsprintf(str, format, a_start);
333 lenght = strlen(str);
335 seq_printf(seq, str);
339 /*****************************************************************************
341 * sk_seq_show - show proc information of a particular adapter
344 * This function fills the proc entry with statistic data about
345 * the ethernet device. It invokes the generic sk_gen_browse() to
346 * print out all items one per one.
348 * Returns: number of bytes written
351 static int sk_seq_show(struct seq_file *seq, void *v)
353 void *castedBuffer = (void *) seq;
354 currDev = seq->private;
355 sk_gen_browse(castedBuffer);
359 /*****************************************************************************
361 * sk_proc_open - register the show function when proc is open'ed
364 * This function is called whenever a sk98lin proc file is queried.
366 * Returns: the return value of single_open()
369 static int sk_proc_open(struct inode *inode, struct file *file)
371 return single_open(file, sk_seq_show, PDE(inode)->data);
374 /*******************************************************************************
378 ******************************************************************************/