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 static int sk_seq_show(struct seq_file *seq, void *v);
35 static int sk_proc_open(struct inode *inode, struct file *file);
37 struct file_operations sk_proc_fops = {
42 .release = single_release,
46 /*****************************************************************************
48 * sk_seq_show - show proc information of a particular adapter
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.
58 static int sk_seq_show(struct seq_file *seq, void *v)
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;
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)
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;
84 SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
87 SkPnmiGetStruct(pAC, pAC->IoBase,
88 pPnmiStruct, &Size, t-1);
90 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
92 if (pAC->dev[t-1] == dev) {
93 SK_PNMI_STAT *pPnmiStat = &pPnmiStruct->Stat[0];
95 seq_printf(seq, "\nDetailed statistic for device %s\n",
97 seq_printf(seq, "=======================================\n");
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);
108 seq_printf(seq, "Bus speed (MHz) %d\n",
109 pPnmiStruct->BusSpeed);
111 seq_printf(seq, "Bus width (Bit) %d\n",
112 pPnmiStruct->BusWidth);
113 seq_printf(seq, "Driver version %s\n",
115 seq_printf(seq, "Hardware revision v%d.%d\n",
116 (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
117 pAC->GIni.GIPciHwRev & 0x0F);
119 /* Print sensor informations */
120 for (i=0; i < pAC->I2c.MaxSens; i ++) {
122 switch (pAC->I2c.SenTable[i].SenType) {
124 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
125 strcat(sens_msg, " (C)");
126 seq_printf(seq, "%-25s %d.%02d\n",
128 pAC->I2c.SenTable[i].SenValue / 10,
129 pAC->I2c.SenTable[i].SenValue % 10);
131 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
132 strcat(sens_msg, " (F)");
133 seq_printf(seq, "%-25s %d.%02d\n",
135 ((((pAC->I2c.SenTable[i].SenValue)
136 *10)*9)/5 + 3200)/100,
137 ((((pAC->I2c.SenTable[i].SenValue)
138 *10)*9)/5 + 3200) % 10);
141 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
142 strcat(sens_msg, " (V)");
143 seq_printf(seq, "%-25s %d.%03d\n",
145 pAC->I2c.SenTable[i].SenValue / 1000,
146 pAC->I2c.SenTable[i].SenValue % 1000);
149 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
150 strcat(sens_msg, " (rpm)");
151 seq_printf(seq, "%-25s %d\n",
153 pAC->I2c.SenTable[i].SenValue);
160 /*Receive statistics */
161 seq_printf(seq, "\nReceive statistics\n\n");
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);
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;
176 pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
177 pPnmiStat->StatRxTooLongCts;
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);
198 pPnmiStat->StatRxTooLongCts = 0;
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);
216 /*Transmit statistics */
217 seq_printf(seq, "\nTransmit statistics\n\n");
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);
246 /*****************************************************************************
248 * sk_proc_open - register the show function when proc is open'ed
251 * This function is called whenever a sk98lin proc file is queried.
253 * Returns: the return value of single_open()
256 static int sk_proc_open(struct inode *inode, struct file *file)
258 return single_open(file, sk_seq_show, PDE(inode)->data);
261 /*******************************************************************************
265 ******************************************************************************/