Merge ARM into the head. ARM will compile but may not actually work.
[gem5.git] / src / dev / etherdevice.cc
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/etherdevice.hh"
33 #include "sim/stats.hh"
34
35 void
36 EtherDevice::regStats()
37 {
38 txBytes
39 .name(name() + ".txBytes")
40 .desc("Bytes Transmitted")
41 .prereq(txBytes)
42 ;
43
44 rxBytes
45 .name(name() + ".rxBytes")
46 .desc("Bytes Received")
47 .prereq(rxBytes)
48 ;
49
50 txPackets
51 .name(name() + ".txPackets")
52 .desc("Number of Packets Transmitted")
53 .prereq(txBytes)
54 ;
55
56 rxPackets
57 .name(name() + ".rxPackets")
58 .desc("Number of Packets Received")
59 .prereq(rxBytes)
60 ;
61
62 txIpChecksums
63 .name(name() + ".txIpChecksums")
64 .desc("Number of tx IP Checksums done by device")
65 .precision(0)
66 .prereq(txBytes)
67 ;
68
69 rxIpChecksums
70 .name(name() + ".rxIpChecksums")
71 .desc("Number of rx IP Checksums done by device")
72 .precision(0)
73 .prereq(rxBytes)
74 ;
75
76 txTcpChecksums
77 .name(name() + ".txTcpChecksums")
78 .desc("Number of tx TCP Checksums done by device")
79 .precision(0)
80 .prereq(txBytes)
81 ;
82
83 rxTcpChecksums
84 .name(name() + ".rxTcpChecksums")
85 .desc("Number of rx TCP Checksums done by device")
86 .precision(0)
87 .prereq(rxBytes)
88 ;
89
90 txUdpChecksums
91 .name(name() + ".txUdpChecksums")
92 .desc("Number of tx UDP Checksums done by device")
93 .precision(0)
94 .prereq(txBytes)
95 ;
96
97 rxUdpChecksums
98 .name(name() + ".rxUdpChecksums")
99 .desc("Number of rx UDP Checksums done by device")
100 .precision(0)
101 .prereq(rxBytes)
102 ;
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 }