etherdevice.cc revision 7461
12400SN/A/*
28706Sandreas.hansson@arm.com * Copyright (c) 2004-2005 The Regents of The University of Michigan
38706Sandreas.hansson@arm.com * All rights reserved.
48706Sandreas.hansson@arm.com *
58706Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
68706Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
78706Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
88706Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
98706Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
108706Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
118706Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
128706Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
138706Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
142400SN/A * this software without specific prior written permission.
152400SN/A *
162400SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172400SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182400SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192400SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202400SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212400SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222400SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232400SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242400SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252400SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262400SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272400SN/A *
282400SN/A * Authors: Nathan Binkert
292400SN/A *          Lisa Hsu
302400SN/A */
312400SN/A
322400SN/A#include "dev/etherdevice.hh"
332400SN/A#include "sim/stats.hh"
342400SN/A
352400SN/Avoid
362400SN/AEtherDevice::regStats()
372400SN/A{
382400SN/A    txBytes
392665SN/A        .name(name() + ".txBytes")
402665SN/A        .desc("Bytes Transmitted")
412665SN/A        .prereq(txBytes)
428706Sandreas.hansson@arm.com        ;
432400SN/A
442400SN/A    rxBytes
458706Sandreas.hansson@arm.com        .name(name() + ".rxBytes")
468706Sandreas.hansson@arm.com        .desc("Bytes Received")
472400SN/A        .prereq(rxBytes)
488706Sandreas.hansson@arm.com        ;
498852Sandreas.hansson@arm.com
5012448Sgabeblack@google.com    txPackets
518852Sandreas.hansson@arm.com        .name(name() + ".txPackets")
522519SN/A        .desc("Number of Packets Transmitted")
538706Sandreas.hansson@arm.com        .prereq(txBytes)
548706Sandreas.hansson@arm.com        ;
558706Sandreas.hansson@arm.com
568706Sandreas.hansson@arm.com    rxPackets
578706Sandreas.hansson@arm.com        .name(name() + ".rxPackets")
588706Sandreas.hansson@arm.com        .desc("Number of Packets Received")
598706Sandreas.hansson@arm.com        .prereq(rxBytes)
608706Sandreas.hansson@arm.com        ;
618706Sandreas.hansson@arm.com
628706Sandreas.hansson@arm.com    txIpChecksums
638706Sandreas.hansson@arm.com        .name(name() + ".txIpChecksums")
648706Sandreas.hansson@arm.com        .desc("Number of tx IP Checksums done by device")
658706Sandreas.hansson@arm.com        .precision(0)
668706Sandreas.hansson@arm.com        .prereq(txBytes)
678706Sandreas.hansson@arm.com        ;
688706Sandreas.hansson@arm.com
692400SN/A    rxIpChecksums
704434SN/A        .name(name() + ".rxIpChecksums")
714434SN/A        .desc("Number of rx IP Checksums done by device")
724434SN/A        .precision(0)
734434SN/A        .prereq(rxBytes)
744434SN/A        ;
754434SN/A
764434SN/A    txTcpChecksums
772400SN/A        .name(name() + ".txTcpChecksums")
7812448Sgabeblack@google.com        .desc("Number of tx TCP Checksums done by device")
794434SN/A        .precision(0)
804434SN/A        .prereq(txBytes)
812400SN/A        ;
822400SN/A
838922Swilliam.wang@arm.com    rxTcpChecksums
848706Sandreas.hansson@arm.com        .name(name() + ".rxTcpChecksums")
852400SN/A        .desc("Number of rx TCP Checksums done by device")
8612448Sgabeblack@google.com        .precision(0)
8711886Sbrandon.potter@amd.com        .prereq(rxBytes)
888861Sandreas.hansson@arm.com        ;
8910564Sandreas.hansson@arm.com
908861Sandreas.hansson@arm.com    txUdpChecksums
918861Sandreas.hansson@arm.com        .name(name() + ".txUdpChecksums")
928861Sandreas.hansson@arm.com        .desc("Number of tx UDP Checksums done by device")
932445SN/A        .precision(0)
948861Sandreas.hansson@arm.com        .prereq(txBytes)
9510564Sandreas.hansson@arm.com        ;
968861Sandreas.hansson@arm.com
972640SN/A    rxUdpChecksums
988861Sandreas.hansson@arm.com        .name(name() + ".rxUdpChecksums")
998861Sandreas.hansson@arm.com        .desc("Number of rx UDP Checksums done by device")
1002400SN/A        .precision(0)
1012400SN/A        .prereq(rxBytes)
1028706Sandreas.hansson@arm.com        ;
103
104    descDmaReads
105        .name(name() + ".descDMAReads")
106        .desc("Number of descriptors the device read w/ DMA")
107        .precision(0)
108        ;
109
110    descDmaWrites
111        .name(name() + ".descDMAWrites")
112        .desc("Number of descriptors the device wrote w/ DMA")
113        .precision(0)
114        ;
115
116    descDmaRdBytes
117        .name(name() + ".descDmaReadBytes")
118        .desc("number of descriptor bytes read w/ DMA")
119        .precision(0)
120        ;
121
122    descDmaWrBytes
123        .name(name() + ".descDmaWriteBytes")
124        .desc("number of descriptor bytes write w/ DMA")
125        .precision(0)
126        ;
127
128    txBandwidth
129        .name(name() + ".txBandwidth")
130        .desc("Transmit Bandwidth (bits/s)")
131        .precision(0)
132        .prereq(txBytes)
133        ;
134
135    rxBandwidth
136        .name(name() + ".rxBandwidth")
137        .desc("Receive Bandwidth (bits/s)")
138        .precision(0)
139        .prereq(rxBytes)
140        ;
141
142    totBandwidth
143        .name(name() + ".totBandwidth")
144        .desc("Total Bandwidth (bits/s)")
145        .precision(0)
146        .prereq(totBytes)
147        ;
148
149    totPackets
150        .name(name() + ".totPackets")
151        .desc("Total Packets")
152        .precision(0)
153        .prereq(totBytes)
154        ;
155
156    totBytes
157        .name(name() + ".totBytes")
158        .desc("Total Bytes")
159        .precision(0)
160        .prereq(totBytes)
161        ;
162
163    totPacketRate
164        .name(name() + ".totPPS")
165        .desc("Total Tranmission Rate (packets/s)")
166        .precision(0)
167        .prereq(totBytes)
168        ;
169
170    txPacketRate
171        .name(name() + ".txPPS")
172        .desc("Packet Tranmission Rate (packets/s)")
173        .precision(0)
174        .prereq(txBytes)
175        ;
176
177    rxPacketRate
178        .name(name() + ".rxPPS")
179        .desc("Packet Reception Rate (packets/s)")
180        .precision(0)
181        .prereq(rxBytes)
182        ;
183
184    postedSwi
185        .name(name() + ".postedSwi")
186        .desc("number of software interrupts posted to CPU")
187        .precision(0)
188        ;
189
190    totalSwi
191        .name(name() + ".totalSwi")
192        .desc("total number of Swi written to ISR")
193        .precision(0)
194        ;
195
196    coalescedSwi
197        .name(name() + ".coalescedSwi")
198        .desc("average number of Swi's coalesced into each post")
199        .precision(0)
200        ;
201
202    postedRxIdle
203        .name(name() + ".postedRxIdle")
204        .desc("number of rxIdle interrupts posted to CPU")
205        .precision(0)
206        ;
207
208    totalRxIdle
209        .name(name() + ".totalRxIdle")
210        .desc("total number of RxIdle written to ISR")
211        .precision(0)
212        ;
213
214    coalescedRxIdle
215        .name(name() + ".coalescedRxIdle")
216        .desc("average number of RxIdle's coalesced into each post")
217        .precision(0)
218        ;
219
220    postedRxOk
221        .name(name() + ".postedRxOk")
222        .desc("number of RxOk interrupts posted to CPU")
223        .precision(0)
224        ;
225
226    totalRxOk
227        .name(name() + ".totalRxOk")
228        .desc("total number of RxOk written to ISR")
229        .precision(0)
230        ;
231
232    coalescedRxOk
233        .name(name() + ".coalescedRxOk")
234        .desc("average number of RxOk's coalesced into each post")
235        .precision(0)
236        ;
237
238    postedRxDesc
239        .name(name() + ".postedRxDesc")
240        .desc("number of RxDesc interrupts posted to CPU")
241        .precision(0)
242        ;
243
244    totalRxDesc
245        .name(name() + ".totalRxDesc")
246        .desc("total number of RxDesc written to ISR")
247        .precision(0)
248        ;
249
250    coalescedRxDesc
251        .name(name() + ".coalescedRxDesc")
252        .desc("average number of RxDesc's coalesced into each post")
253        .precision(0)
254        ;
255
256    postedTxOk
257        .name(name() + ".postedTxOk")
258        .desc("number of TxOk interrupts posted to CPU")
259        .precision(0)
260        ;
261
262    totalTxOk
263        .name(name() + ".totalTxOk")
264        .desc("total number of TxOk written to ISR")
265        .precision(0)
266        ;
267
268    coalescedTxOk
269        .name(name() + ".coalescedTxOk")
270        .desc("average number of TxOk's coalesced into each post")
271        .precision(0)
272        ;
273
274    postedTxIdle
275        .name(name() + ".postedTxIdle")
276        .desc("number of TxIdle interrupts posted to CPU")
277        .precision(0)
278        ;
279
280    totalTxIdle
281        .name(name() + ".totalTxIdle")
282        .desc("total number of TxIdle written to ISR")
283        .precision(0)
284        ;
285
286    coalescedTxIdle
287        .name(name() + ".coalescedTxIdle")
288        .desc("average number of TxIdle's coalesced into each post")
289        .precision(0)
290        ;
291
292    postedTxDesc
293        .name(name() + ".postedTxDesc")
294        .desc("number of TxDesc interrupts posted to CPU")
295        .precision(0)
296        ;
297
298    totalTxDesc
299        .name(name() + ".totalTxDesc")
300        .desc("total number of TxDesc written to ISR")
301        .precision(0)
302        ;
303
304    coalescedTxDesc
305        .name(name() + ".coalescedTxDesc")
306        .desc("average number of TxDesc's coalesced into each post")
307        .precision(0)
308        ;
309
310    postedRxOrn
311        .name(name() + ".postedRxOrn")
312        .desc("number of RxOrn posted to CPU")
313        .precision(0)
314        ;
315
316    totalRxOrn
317        .name(name() + ".totalRxOrn")
318        .desc("total number of RxOrn written to ISR")
319        .precision(0)
320        ;
321
322    coalescedRxOrn
323        .name(name() + ".coalescedRxOrn")
324        .desc("average number of RxOrn's coalesced into each post")
325        .precision(0)
326        ;
327
328    coalescedTotal
329        .name(name() + ".coalescedTotal")
330        .desc("average number of interrupts coalesced into each post")
331        .precision(0)
332        ;
333
334    postedInterrupts
335        .name(name() + ".postedInterrupts")
336        .desc("number of posts to CPU")
337        .precision(0)
338        ;
339
340    droppedPackets
341        .name(name() + ".droppedPackets")
342        .desc("number of packets dropped")
343        .precision(0)
344        ;
345
346    coalescedSwi = totalSwi / postedInterrupts;
347    coalescedRxIdle = totalRxIdle / postedInterrupts;
348    coalescedRxOk = totalRxOk / postedInterrupts;
349    coalescedRxDesc = totalRxDesc / postedInterrupts;
350    coalescedTxOk = totalTxOk / postedInterrupts;
351    coalescedTxIdle = totalTxIdle / postedInterrupts;
352    coalescedTxDesc = totalTxDesc / postedInterrupts;
353    coalescedRxOrn = totalRxOrn / postedInterrupts;
354
355    coalescedTotal = (totalSwi + totalRxIdle + totalRxOk + totalRxDesc +
356                      totalTxOk + totalTxIdle + totalTxDesc +
357                      totalRxOrn) / postedInterrupts;
358
359    txBandwidth = txBytes * Stats::constant(8) / simSeconds;
360    rxBandwidth = rxBytes * Stats::constant(8) / simSeconds;
361    totBandwidth = txBandwidth + rxBandwidth;
362    totBytes = txBytes + rxBytes;
363    totPackets = txPackets + rxPackets;
364
365    txPacketRate = txPackets / simSeconds;
366    rxPacketRate = rxPackets / simSeconds;
367    totPacketRate = totPackets / simSeconds;
368}
369