etherdevice.cc revision 11522
1/*
2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 *          Lisa Hsu
30 */
31
32#include "dev/net/etherdevice.hh"
33
34#include "sim/stats.hh"
35
36void
37EtherDevice::regStats()
38{
39    PciDevice::regStats();
40
41    txBytes
42        .name(name() + ".txBytes")
43        .desc("Bytes Transmitted")
44        .prereq(txBytes)
45        ;
46
47    rxBytes
48        .name(name() + ".rxBytes")
49        .desc("Bytes Received")
50        .prereq(rxBytes)
51        ;
52
53    txPackets
54        .name(name() + ".txPackets")
55        .desc("Number of Packets Transmitted")
56        .prereq(txBytes)
57        ;
58
59    rxPackets
60        .name(name() + ".rxPackets")
61        .desc("Number of Packets Received")
62        .prereq(rxBytes)
63        ;
64
65    txIpChecksums
66        .name(name() + ".txIpChecksums")
67        .desc("Number of tx IP Checksums done by device")
68        .precision(0)
69        .prereq(txBytes)
70        ;
71
72    rxIpChecksums
73        .name(name() + ".rxIpChecksums")
74        .desc("Number of rx IP Checksums done by device")
75        .precision(0)
76        .prereq(rxBytes)
77        ;
78
79    txTcpChecksums
80        .name(name() + ".txTcpChecksums")
81        .desc("Number of tx TCP Checksums done by device")
82        .precision(0)
83        .prereq(txBytes)
84        ;
85
86    rxTcpChecksums
87        .name(name() + ".rxTcpChecksums")
88        .desc("Number of rx TCP Checksums done by device")
89        .precision(0)
90        .prereq(rxBytes)
91        ;
92
93    txUdpChecksums
94        .name(name() + ".txUdpChecksums")
95        .desc("Number of tx UDP Checksums done by device")
96        .precision(0)
97        .prereq(txBytes)
98        ;
99
100    rxUdpChecksums
101        .name(name() + ".rxUdpChecksums")
102        .desc("Number of rx UDP Checksums done by device")
103        .precision(0)
104        .prereq(rxBytes)
105        ;
106
107    descDmaReads
108        .name(name() + ".descDMAReads")
109        .desc("Number of descriptors the device read w/ DMA")
110        .precision(0)
111        ;
112
113    descDmaWrites
114        .name(name() + ".descDMAWrites")
115        .desc("Number of descriptors the device wrote w/ DMA")
116        .precision(0)
117        ;
118
119    descDmaRdBytes
120        .name(name() + ".descDmaReadBytes")
121        .desc("number of descriptor bytes read w/ DMA")
122        .precision(0)
123        ;
124
125    descDmaWrBytes
126        .name(name() + ".descDmaWriteBytes")
127        .desc("number of descriptor bytes write w/ DMA")
128        .precision(0)
129        ;
130
131    txBandwidth
132        .name(name() + ".txBandwidth")
133        .desc("Transmit Bandwidth (bits/s)")
134        .precision(0)
135        .prereq(txBytes)
136        ;
137
138    rxBandwidth
139        .name(name() + ".rxBandwidth")
140        .desc("Receive Bandwidth (bits/s)")
141        .precision(0)
142        .prereq(rxBytes)
143        ;
144
145    totBandwidth
146        .name(name() + ".totBandwidth")
147        .desc("Total Bandwidth (bits/s)")
148        .precision(0)
149        .prereq(totBytes)
150        ;
151
152    totPackets
153        .name(name() + ".totPackets")
154        .desc("Total Packets")
155        .precision(0)
156        .prereq(totBytes)
157        ;
158
159    totBytes
160        .name(name() + ".totBytes")
161        .desc("Total Bytes")
162        .precision(0)
163        .prereq(totBytes)
164        ;
165
166    totPacketRate
167        .name(name() + ".totPPS")
168        .desc("Total Tranmission Rate (packets/s)")
169        .precision(0)
170        .prereq(totBytes)
171        ;
172
173    txPacketRate
174        .name(name() + ".txPPS")
175        .desc("Packet Tranmission Rate (packets/s)")
176        .precision(0)
177        .prereq(txBytes)
178        ;
179
180    rxPacketRate
181        .name(name() + ".rxPPS")
182        .desc("Packet Reception Rate (packets/s)")
183        .precision(0)
184        .prereq(rxBytes)
185        ;
186
187    postedSwi
188        .name(name() + ".postedSwi")
189        .desc("number of software interrupts posted to CPU")
190        .precision(0)
191        ;
192
193    totalSwi
194        .name(name() + ".totalSwi")
195        .desc("total number of Swi written to ISR")
196        .precision(0)
197        ;
198
199    coalescedSwi
200        .name(name() + ".coalescedSwi")
201        .desc("average number of Swi's coalesced into each post")
202        .precision(0)
203        ;
204
205    postedRxIdle
206        .name(name() + ".postedRxIdle")
207        .desc("number of rxIdle interrupts posted to CPU")
208        .precision(0)
209        ;
210
211    totalRxIdle
212        .name(name() + ".totalRxIdle")
213        .desc("total number of RxIdle written to ISR")
214        .precision(0)
215        ;
216
217    coalescedRxIdle
218        .name(name() + ".coalescedRxIdle")
219        .desc("average number of RxIdle's coalesced into each post")
220        .precision(0)
221        ;
222
223    postedRxOk
224        .name(name() + ".postedRxOk")
225        .desc("number of RxOk interrupts posted to CPU")
226        .precision(0)
227        ;
228
229    totalRxOk
230        .name(name() + ".totalRxOk")
231        .desc("total number of RxOk written to ISR")
232        .precision(0)
233        ;
234
235    coalescedRxOk
236        .name(name() + ".coalescedRxOk")
237        .desc("average number of RxOk's coalesced into each post")
238        .precision(0)
239        ;
240
241    postedRxDesc
242        .name(name() + ".postedRxDesc")
243        .desc("number of RxDesc interrupts posted to CPU")
244        .precision(0)
245        ;
246
247    totalRxDesc
248        .name(name() + ".totalRxDesc")
249        .desc("total number of RxDesc written to ISR")
250        .precision(0)
251        ;
252
253    coalescedRxDesc
254        .name(name() + ".coalescedRxDesc")
255        .desc("average number of RxDesc's coalesced into each post")
256        .precision(0)
257        ;
258
259    postedTxOk
260        .name(name() + ".postedTxOk")
261        .desc("number of TxOk interrupts posted to CPU")
262        .precision(0)
263        ;
264
265    totalTxOk
266        .name(name() + ".totalTxOk")
267        .desc("total number of TxOk written to ISR")
268        .precision(0)
269        ;
270
271    coalescedTxOk
272        .name(name() + ".coalescedTxOk")
273        .desc("average number of TxOk's coalesced into each post")
274        .precision(0)
275        ;
276
277    postedTxIdle
278        .name(name() + ".postedTxIdle")
279        .desc("number of TxIdle interrupts posted to CPU")
280        .precision(0)
281        ;
282
283    totalTxIdle
284        .name(name() + ".totalTxIdle")
285        .desc("total number of TxIdle written to ISR")
286        .precision(0)
287        ;
288
289    coalescedTxIdle
290        .name(name() + ".coalescedTxIdle")
291        .desc("average number of TxIdle's coalesced into each post")
292        .precision(0)
293        ;
294
295    postedTxDesc
296        .name(name() + ".postedTxDesc")
297        .desc("number of TxDesc interrupts posted to CPU")
298        .precision(0)
299        ;
300
301    totalTxDesc
302        .name(name() + ".totalTxDesc")
303        .desc("total number of TxDesc written to ISR")
304        .precision(0)
305        ;
306
307    coalescedTxDesc
308        .name(name() + ".coalescedTxDesc")
309        .desc("average number of TxDesc's coalesced into each post")
310        .precision(0)
311        ;
312
313    postedRxOrn
314        .name(name() + ".postedRxOrn")
315        .desc("number of RxOrn posted to CPU")
316        .precision(0)
317        ;
318
319    totalRxOrn
320        .name(name() + ".totalRxOrn")
321        .desc("total number of RxOrn written to ISR")
322        .precision(0)
323        ;
324
325    coalescedRxOrn
326        .name(name() + ".coalescedRxOrn")
327        .desc("average number of RxOrn's coalesced into each post")
328        .precision(0)
329        ;
330
331    coalescedTotal
332        .name(name() + ".coalescedTotal")
333        .desc("average number of interrupts coalesced into each post")
334        .precision(0)
335        ;
336
337    postedInterrupts
338        .name(name() + ".postedInterrupts")
339        .desc("number of posts to CPU")
340        .precision(0)
341        ;
342
343    droppedPackets
344        .name(name() + ".droppedPackets")
345        .desc("number of packets dropped")
346        .precision(0)
347        ;
348
349    coalescedSwi = totalSwi / postedInterrupts;
350    coalescedRxIdle = totalRxIdle / postedInterrupts;
351    coalescedRxOk = totalRxOk / postedInterrupts;
352    coalescedRxDesc = totalRxDesc / postedInterrupts;
353    coalescedTxOk = totalTxOk / postedInterrupts;
354    coalescedTxIdle = totalTxIdle / postedInterrupts;
355    coalescedTxDesc = totalTxDesc / postedInterrupts;
356    coalescedRxOrn = totalRxOrn / postedInterrupts;
357
358    coalescedTotal = (totalSwi + totalRxIdle + totalRxOk + totalRxDesc +
359                      totalTxOk + totalTxIdle + totalTxDesc +
360                      totalRxOrn) / postedInterrupts;
361
362    txBandwidth = txBytes * Stats::constant(8) / simSeconds;
363    rxBandwidth = rxBytes * Stats::constant(8) / simSeconds;
364    totBandwidth = txBandwidth + rxBandwidth;
365    totBytes = txBytes + rxBytes;
366    totPackets = txPackets + rxPackets;
367
368    txPacketRate = txPackets / simSeconds;
369    rxPacketRate = rxPackets / simSeconds;
370    totPacketRate = totPackets / simSeconds;
371}
372