etherdevice.cc revision 11263:8dcc6b40f164
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 txBytes 40 .name(name() + ".txBytes") 41 .desc("Bytes Transmitted") 42 .prereq(txBytes) 43 ; 44 45 rxBytes 46 .name(name() + ".rxBytes") 47 .desc("Bytes Received") 48 .prereq(rxBytes) 49 ; 50 51 txPackets 52 .name(name() + ".txPackets") 53 .desc("Number of Packets Transmitted") 54 .prereq(txBytes) 55 ; 56 57 rxPackets 58 .name(name() + ".rxPackets") 59 .desc("Number of Packets Received") 60 .prereq(rxBytes) 61 ; 62 63 txIpChecksums 64 .name(name() + ".txIpChecksums") 65 .desc("Number of tx IP Checksums done by device") 66 .precision(0) 67 .prereq(txBytes) 68 ; 69 70 rxIpChecksums 71 .name(name() + ".rxIpChecksums") 72 .desc("Number of rx IP Checksums done by device") 73 .precision(0) 74 .prereq(rxBytes) 75 ; 76 77 txTcpChecksums 78 .name(name() + ".txTcpChecksums") 79 .desc("Number of tx TCP Checksums done by device") 80 .precision(0) 81 .prereq(txBytes) 82 ; 83 84 rxTcpChecksums 85 .name(name() + ".rxTcpChecksums") 86 .desc("Number of rx TCP Checksums done by device") 87 .precision(0) 88 .prereq(rxBytes) 89 ; 90 91 txUdpChecksums 92 .name(name() + ".txUdpChecksums") 93 .desc("Number of tx UDP Checksums done by device") 94 .precision(0) 95 .prereq(txBytes) 96 ; 97 98 rxUdpChecksums 99 .name(name() + ".rxUdpChecksums") 100 .desc("Number of rx UDP Checksums done by device") 101 .precision(0) 102 .prereq(rxBytes) 103 ; 104 105 descDmaReads 106 .name(name() + ".descDMAReads") 107 .desc("Number of descriptors the device read w/ DMA") 108 .precision(0) 109 ; 110 111 descDmaWrites 112 .name(name() + ".descDMAWrites") 113 .desc("Number of descriptors the device wrote w/ DMA") 114 .precision(0) 115 ; 116 117 descDmaRdBytes 118 .name(name() + ".descDmaReadBytes") 119 .desc("number of descriptor bytes read w/ DMA") 120 .precision(0) 121 ; 122 123 descDmaWrBytes 124 .name(name() + ".descDmaWriteBytes") 125 .desc("number of descriptor bytes write w/ DMA") 126 .precision(0) 127 ; 128 129 txBandwidth 130 .name(name() + ".txBandwidth") 131 .desc("Transmit Bandwidth (bits/s)") 132 .precision(0) 133 .prereq(txBytes) 134 ; 135 136 rxBandwidth 137 .name(name() + ".rxBandwidth") 138 .desc("Receive Bandwidth (bits/s)") 139 .precision(0) 140 .prereq(rxBytes) 141 ; 142 143 totBandwidth 144 .name(name() + ".totBandwidth") 145 .desc("Total Bandwidth (bits/s)") 146 .precision(0) 147 .prereq(totBytes) 148 ; 149 150 totPackets 151 .name(name() + ".totPackets") 152 .desc("Total Packets") 153 .precision(0) 154 .prereq(totBytes) 155 ; 156 157 totBytes 158 .name(name() + ".totBytes") 159 .desc("Total Bytes") 160 .precision(0) 161 .prereq(totBytes) 162 ; 163 164 totPacketRate 165 .name(name() + ".totPPS") 166 .desc("Total Tranmission Rate (packets/s)") 167 .precision(0) 168 .prereq(totBytes) 169 ; 170 171 txPacketRate 172 .name(name() + ".txPPS") 173 .desc("Packet Tranmission Rate (packets/s)") 174 .precision(0) 175 .prereq(txBytes) 176 ; 177 178 rxPacketRate 179 .name(name() + ".rxPPS") 180 .desc("Packet Reception Rate (packets/s)") 181 .precision(0) 182 .prereq(rxBytes) 183 ; 184 185 postedSwi 186 .name(name() + ".postedSwi") 187 .desc("number of software interrupts posted to CPU") 188 .precision(0) 189 ; 190 191 totalSwi 192 .name(name() + ".totalSwi") 193 .desc("total number of Swi written to ISR") 194 .precision(0) 195 ; 196 197 coalescedSwi 198 .name(name() + ".coalescedSwi") 199 .desc("average number of Swi's coalesced into each post") 200 .precision(0) 201 ; 202 203 postedRxIdle 204 .name(name() + ".postedRxIdle") 205 .desc("number of rxIdle interrupts posted to CPU") 206 .precision(0) 207 ; 208 209 totalRxIdle 210 .name(name() + ".totalRxIdle") 211 .desc("total number of RxIdle written to ISR") 212 .precision(0) 213 ; 214 215 coalescedRxIdle 216 .name(name() + ".coalescedRxIdle") 217 .desc("average number of RxIdle's coalesced into each post") 218 .precision(0) 219 ; 220 221 postedRxOk 222 .name(name() + ".postedRxOk") 223 .desc("number of RxOk interrupts posted to CPU") 224 .precision(0) 225 ; 226 227 totalRxOk 228 .name(name() + ".totalRxOk") 229 .desc("total number of RxOk written to ISR") 230 .precision(0) 231 ; 232 233 coalescedRxOk 234 .name(name() + ".coalescedRxOk") 235 .desc("average number of RxOk's coalesced into each post") 236 .precision(0) 237 ; 238 239 postedRxDesc 240 .name(name() + ".postedRxDesc") 241 .desc("number of RxDesc interrupts posted to CPU") 242 .precision(0) 243 ; 244 245 totalRxDesc 246 .name(name() + ".totalRxDesc") 247 .desc("total number of RxDesc written to ISR") 248 .precision(0) 249 ; 250 251 coalescedRxDesc 252 .name(name() + ".coalescedRxDesc") 253 .desc("average number of RxDesc's coalesced into each post") 254 .precision(0) 255 ; 256 257 postedTxOk 258 .name(name() + ".postedTxOk") 259 .desc("number of TxOk interrupts posted to CPU") 260 .precision(0) 261 ; 262 263 totalTxOk 264 .name(name() + ".totalTxOk") 265 .desc("total number of TxOk written to ISR") 266 .precision(0) 267 ; 268 269 coalescedTxOk 270 .name(name() + ".coalescedTxOk") 271 .desc("average number of TxOk's coalesced into each post") 272 .precision(0) 273 ; 274 275 postedTxIdle 276 .name(name() + ".postedTxIdle") 277 .desc("number of TxIdle interrupts posted to CPU") 278 .precision(0) 279 ; 280 281 totalTxIdle 282 .name(name() + ".totalTxIdle") 283 .desc("total number of TxIdle written to ISR") 284 .precision(0) 285 ; 286 287 coalescedTxIdle 288 .name(name() + ".coalescedTxIdle") 289 .desc("average number of TxIdle's coalesced into each post") 290 .precision(0) 291 ; 292 293 postedTxDesc 294 .name(name() + ".postedTxDesc") 295 .desc("number of TxDesc interrupts posted to CPU") 296 .precision(0) 297 ; 298 299 totalTxDesc 300 .name(name() + ".totalTxDesc") 301 .desc("total number of TxDesc written to ISR") 302 .precision(0) 303 ; 304 305 coalescedTxDesc 306 .name(name() + ".coalescedTxDesc") 307 .desc("average number of TxDesc's coalesced into each post") 308 .precision(0) 309 ; 310 311 postedRxOrn 312 .name(name() + ".postedRxOrn") 313 .desc("number of RxOrn posted to CPU") 314 .precision(0) 315 ; 316 317 totalRxOrn 318 .name(name() + ".totalRxOrn") 319 .desc("total number of RxOrn written to ISR") 320 .precision(0) 321 ; 322 323 coalescedRxOrn 324 .name(name() + ".coalescedRxOrn") 325 .desc("average number of RxOrn's coalesced into each post") 326 .precision(0) 327 ; 328 329 coalescedTotal 330 .name(name() + ".coalescedTotal") 331 .desc("average number of interrupts coalesced into each post") 332 .precision(0) 333 ; 334 335 postedInterrupts 336 .name(name() + ".postedInterrupts") 337 .desc("number of posts to CPU") 338 .precision(0) 339 ; 340 341 droppedPackets 342 .name(name() + ".droppedPackets") 343 .desc("number of packets dropped") 344 .precision(0) 345 ; 346 347 coalescedSwi = totalSwi / postedInterrupts; 348 coalescedRxIdle = totalRxIdle / postedInterrupts; 349 coalescedRxOk = totalRxOk / postedInterrupts; 350 coalescedRxDesc = totalRxDesc / postedInterrupts; 351 coalescedTxOk = totalTxOk / postedInterrupts; 352 coalescedTxIdle = totalTxIdle / postedInterrupts; 353 coalescedTxDesc = totalTxDesc / postedInterrupts; 354 coalescedRxOrn = totalRxOrn / postedInterrupts; 355 356 coalescedTotal = (totalSwi + totalRxIdle + totalRxOk + totalRxDesc + 357 totalTxOk + totalTxIdle + totalTxDesc + 358 totalRxOrn) / postedInterrupts; 359 360 txBandwidth = txBytes * Stats::constant(8) / simSeconds; 361 rxBandwidth = rxBytes * Stats::constant(8) / simSeconds; 362 totBandwidth = txBandwidth + rxBandwidth; 363 totBytes = txBytes + rxBytes; 364 totPackets = txPackets + rxPackets; 365 366 txPacketRate = txPackets / simSeconds; 367 rxPacketRate = rxPackets / simSeconds; 368 totPacketRate = totPackets / simSeconds; 369} 370