etherdevice.cc revision 11263
15485SN/A/*
25485SN/A * Copyright (c) 2004-2005 The Regents of The University of Michigan
35485SN/A * All rights reserved.
45485SN/A *
55485SN/A * Redistribution and use in source and binary forms, with or without
65485SN/A * modification, are permitted provided that the following conditions are
75485SN/A * met: redistributions of source code must retain the above copyright
85485SN/A * notice, this list of conditions and the following disclaimer;
95485SN/A * redistributions in binary form must reproduce the above copyright
105485SN/A * notice, this list of conditions and the following disclaimer in the
115485SN/A * documentation and/or other materials provided with the distribution;
125485SN/A * neither the name of the copyright holders nor the names of its
135485SN/A * contributors may be used to endorse or promote products derived from
145485SN/A * this software without specific prior written permission.
155485SN/A *
165485SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175485SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185485SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195485SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205485SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215485SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225485SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235485SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245485SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255485SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265485SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275485SN/A *
285485SN/A * Authors: Nathan Binkert
295485SN/A *          Lisa Hsu
305485SN/A */
315485SN/A
3211263Sandreas.sandberg@arm.com#include "dev/net/etherdevice.hh"
3311263Sandreas.sandberg@arm.com
345485SN/A#include "sim/stats.hh"
355485SN/A
365485SN/Avoid
375485SN/AEtherDevice::regStats()
385485SN/A{
395485SN/A    txBytes
405485SN/A        .name(name() + ".txBytes")
415485SN/A        .desc("Bytes Transmitted")
425485SN/A        .prereq(txBytes)
435485SN/A        ;
445485SN/A
455485SN/A    rxBytes
465485SN/A        .name(name() + ".rxBytes")
475485SN/A        .desc("Bytes Received")
485485SN/A        .prereq(rxBytes)
495485SN/A        ;
505485SN/A
515485SN/A    txPackets
525485SN/A        .name(name() + ".txPackets")
535485SN/A        .desc("Number of Packets Transmitted")
545485SN/A        .prereq(txBytes)
555485SN/A        ;
565485SN/A
575485SN/A    rxPackets
585485SN/A        .name(name() + ".rxPackets")
595485SN/A        .desc("Number of Packets Received")
605485SN/A        .prereq(rxBytes)
615485SN/A        ;
625485SN/A
635485SN/A    txIpChecksums
645485SN/A        .name(name() + ".txIpChecksums")
655485SN/A        .desc("Number of tx IP Checksums done by device")
665485SN/A        .precision(0)
675485SN/A        .prereq(txBytes)
685485SN/A        ;
695485SN/A
705485SN/A    rxIpChecksums
715485SN/A        .name(name() + ".rxIpChecksums")
725485SN/A        .desc("Number of rx IP Checksums done by device")
735485SN/A        .precision(0)
745485SN/A        .prereq(rxBytes)
755485SN/A        ;
765485SN/A
775485SN/A    txTcpChecksums
785485SN/A        .name(name() + ".txTcpChecksums")
795485SN/A        .desc("Number of tx TCP Checksums done by device")
805485SN/A        .precision(0)
815485SN/A        .prereq(txBytes)
825485SN/A        ;
835485SN/A
845485SN/A    rxTcpChecksums
855485SN/A        .name(name() + ".rxTcpChecksums")
865485SN/A        .desc("Number of rx TCP Checksums done by device")
875485SN/A        .precision(0)
885485SN/A        .prereq(rxBytes)
895485SN/A        ;
905485SN/A
915485SN/A    txUdpChecksums
925485SN/A        .name(name() + ".txUdpChecksums")
935485SN/A        .desc("Number of tx UDP Checksums done by device")
945485SN/A        .precision(0)
955485SN/A        .prereq(txBytes)
965485SN/A        ;
975485SN/A
985485SN/A    rxUdpChecksums
995485SN/A        .name(name() + ".rxUdpChecksums")
1005485SN/A        .desc("Number of rx UDP Checksums done by device")
1015485SN/A        .precision(0)
1025485SN/A        .prereq(rxBytes)
1035485SN/A        ;
1045485SN/A
1055485SN/A    descDmaReads
1065485SN/A        .name(name() + ".descDMAReads")
1075485SN/A        .desc("Number of descriptors the device read w/ DMA")
1085485SN/A        .precision(0)
1095485SN/A        ;
1105485SN/A
1115485SN/A    descDmaWrites
1125485SN/A        .name(name() + ".descDMAWrites")
1135485SN/A        .desc("Number of descriptors the device wrote w/ DMA")
1145485SN/A        .precision(0)
1155485SN/A        ;
1165485SN/A
1175485SN/A    descDmaRdBytes
1185485SN/A        .name(name() + ".descDmaReadBytes")
1195485SN/A        .desc("number of descriptor bytes read w/ DMA")
1205485SN/A        .precision(0)
1215485SN/A        ;
1225485SN/A
1237461SN/A    descDmaWrBytes
1245485SN/A        .name(name() + ".descDmaWriteBytes")
1255485SN/A        .desc("number of descriptor bytes write w/ DMA")
1265485SN/A        .precision(0)
1275485SN/A        ;
1285485SN/A
1295485SN/A    txBandwidth
1305485SN/A        .name(name() + ".txBandwidth")
1315485SN/A        .desc("Transmit Bandwidth (bits/s)")
1325485SN/A        .precision(0)
1335485SN/A        .prereq(txBytes)
1345485SN/A        ;
1355485SN/A
1365485SN/A    rxBandwidth
1375485SN/A        .name(name() + ".rxBandwidth")
1385485SN/A        .desc("Receive Bandwidth (bits/s)")
1395485SN/A        .precision(0)
1405485SN/A        .prereq(rxBytes)
1415485SN/A        ;
1425485SN/A
1435485SN/A    totBandwidth
1445485SN/A        .name(name() + ".totBandwidth")
1455485SN/A        .desc("Total Bandwidth (bits/s)")
1465485SN/A        .precision(0)
1475485SN/A        .prereq(totBytes)
1485485SN/A        ;
1495485SN/A
1505485SN/A    totPackets
1515485SN/A        .name(name() + ".totPackets")
1525485SN/A        .desc("Total Packets")
1535485SN/A        .precision(0)
1545485SN/A        .prereq(totBytes)
1555485SN/A        ;
1565485SN/A
1575485SN/A    totBytes
1585485SN/A        .name(name() + ".totBytes")
1595485SN/A        .desc("Total Bytes")
1605485SN/A        .precision(0)
1615485SN/A        .prereq(totBytes)
1625485SN/A        ;
1635485SN/A
1645485SN/A    totPacketRate
1655485SN/A        .name(name() + ".totPPS")
1665485SN/A        .desc("Total Tranmission Rate (packets/s)")
1675485SN/A        .precision(0)
1685485SN/A        .prereq(totBytes)
1695485SN/A        ;
1705485SN/A
1715485SN/A    txPacketRate
1725485SN/A        .name(name() + ".txPPS")
1735485SN/A        .desc("Packet Tranmission Rate (packets/s)")
1745485SN/A        .precision(0)
1755485SN/A        .prereq(txBytes)
1765485SN/A        ;
1775485SN/A
1785485SN/A    rxPacketRate
1795485SN/A        .name(name() + ".rxPPS")
1805485SN/A        .desc("Packet Reception Rate (packets/s)")
1815485SN/A        .precision(0)
1825485SN/A        .prereq(rxBytes)
1835485SN/A        ;
1845485SN/A
1855485SN/A    postedSwi
1865485SN/A        .name(name() + ".postedSwi")
1875485SN/A        .desc("number of software interrupts posted to CPU")
1885485SN/A        .precision(0)
1895485SN/A        ;
1905485SN/A
1915485SN/A    totalSwi
1925485SN/A        .name(name() + ".totalSwi")
1935485SN/A        .desc("total number of Swi written to ISR")
1945485SN/A        .precision(0)
1955485SN/A        ;
1965485SN/A
1975485SN/A    coalescedSwi
1985485SN/A        .name(name() + ".coalescedSwi")
1995485SN/A        .desc("average number of Swi's coalesced into each post")
2005485SN/A        .precision(0)
2015485SN/A        ;
2025485SN/A
2035485SN/A    postedRxIdle
2045485SN/A        .name(name() + ".postedRxIdle")
2055485SN/A        .desc("number of rxIdle interrupts posted to CPU")
2065485SN/A        .precision(0)
2075485SN/A        ;
2085485SN/A
2095485SN/A    totalRxIdle
2105485SN/A        .name(name() + ".totalRxIdle")
2115485SN/A        .desc("total number of RxIdle written to ISR")
2125485SN/A        .precision(0)
2135485SN/A        ;
2145485SN/A
2155485SN/A    coalescedRxIdle
2165485SN/A        .name(name() + ".coalescedRxIdle")
2175485SN/A        .desc("average number of RxIdle's coalesced into each post")
2185485SN/A        .precision(0)
2195485SN/A        ;
2205485SN/A
2215485SN/A    postedRxOk
2225485SN/A        .name(name() + ".postedRxOk")
2235485SN/A        .desc("number of RxOk interrupts posted to CPU")
2245485SN/A        .precision(0)
2255485SN/A        ;
2265485SN/A
2275485SN/A    totalRxOk
2285485SN/A        .name(name() + ".totalRxOk")
2295485SN/A        .desc("total number of RxOk written to ISR")
2305485SN/A        .precision(0)
2315485SN/A        ;
2325485SN/A
2335485SN/A    coalescedRxOk
2345485SN/A        .name(name() + ".coalescedRxOk")
2355485SN/A        .desc("average number of RxOk's coalesced into each post")
2365485SN/A        .precision(0)
2375485SN/A        ;
2385485SN/A
2395485SN/A    postedRxDesc
2405485SN/A        .name(name() + ".postedRxDesc")
2415485SN/A        .desc("number of RxDesc interrupts posted to CPU")
2425485SN/A        .precision(0)
2435485SN/A        ;
2445485SN/A
2455485SN/A    totalRxDesc
2465485SN/A        .name(name() + ".totalRxDesc")
2475485SN/A        .desc("total number of RxDesc written to ISR")
2485485SN/A        .precision(0)
2495485SN/A        ;
2505485SN/A
2515485SN/A    coalescedRxDesc
2525485SN/A        .name(name() + ".coalescedRxDesc")
2535485SN/A        .desc("average number of RxDesc's coalesced into each post")
2545485SN/A        .precision(0)
2555485SN/A        ;
2565485SN/A
2575485SN/A    postedTxOk
2585485SN/A        .name(name() + ".postedTxOk")
2595485SN/A        .desc("number of TxOk interrupts posted to CPU")
2605485SN/A        .precision(0)
2615485SN/A        ;
2625485SN/A
2635485SN/A    totalTxOk
2645485SN/A        .name(name() + ".totalTxOk")
2655485SN/A        .desc("total number of TxOk written to ISR")
2665485SN/A        .precision(0)
2675485SN/A        ;
2685485SN/A
2695485SN/A    coalescedTxOk
2705485SN/A        .name(name() + ".coalescedTxOk")
2715485SN/A        .desc("average number of TxOk's coalesced into each post")
2725485SN/A        .precision(0)
2735485SN/A        ;
2745485SN/A
2755485SN/A    postedTxIdle
2765485SN/A        .name(name() + ".postedTxIdle")
2775485SN/A        .desc("number of TxIdle interrupts posted to CPU")
2785485SN/A        .precision(0)
2795485SN/A        ;
2805485SN/A
2815485SN/A    totalTxIdle
2825485SN/A        .name(name() + ".totalTxIdle")
2835485SN/A        .desc("total number of TxIdle written to ISR")
2845485SN/A        .precision(0)
2855485SN/A        ;
2865485SN/A
2875485SN/A    coalescedTxIdle
2885485SN/A        .name(name() + ".coalescedTxIdle")
2895485SN/A        .desc("average number of TxIdle's coalesced into each post")
2905485SN/A        .precision(0)
2915485SN/A        ;
2925485SN/A
2935485SN/A    postedTxDesc
2945485SN/A        .name(name() + ".postedTxDesc")
2955485SN/A        .desc("number of TxDesc interrupts posted to CPU")
2965485SN/A        .precision(0)
2975485SN/A        ;
2985485SN/A
2995485SN/A    totalTxDesc
3005485SN/A        .name(name() + ".totalTxDesc")
3015485SN/A        .desc("total number of TxDesc written to ISR")
3025485SN/A        .precision(0)
3035485SN/A        ;
3045485SN/A
3055485SN/A    coalescedTxDesc
3065485SN/A        .name(name() + ".coalescedTxDesc")
3075485SN/A        .desc("average number of TxDesc's coalesced into each post")
3085485SN/A        .precision(0)
3095485SN/A        ;
3105485SN/A
3115485SN/A    postedRxOrn
3125485SN/A        .name(name() + ".postedRxOrn")
3135485SN/A        .desc("number of RxOrn posted to CPU")
3145485SN/A        .precision(0)
3155485SN/A        ;
3165485SN/A
3175485SN/A    totalRxOrn
3185485SN/A        .name(name() + ".totalRxOrn")
3195485SN/A        .desc("total number of RxOrn written to ISR")
3205485SN/A        .precision(0)
3215485SN/A        ;
3225485SN/A
3235485SN/A    coalescedRxOrn
3245485SN/A        .name(name() + ".coalescedRxOrn")
3255485SN/A        .desc("average number of RxOrn's coalesced into each post")
3265485SN/A        .precision(0)
3275485SN/A        ;
3285485SN/A
3295485SN/A    coalescedTotal
3305485SN/A        .name(name() + ".coalescedTotal")
3315485SN/A        .desc("average number of interrupts coalesced into each post")
3325485SN/A        .precision(0)
3335485SN/A        ;
3345485SN/A
3355485SN/A    postedInterrupts
3365485SN/A        .name(name() + ".postedInterrupts")
3375485SN/A        .desc("number of posts to CPU")
3385485SN/A        .precision(0)
3395485SN/A        ;
3405485SN/A
3415485SN/A    droppedPackets
3425485SN/A        .name(name() + ".droppedPackets")
3435485SN/A        .desc("number of packets dropped")
3445485SN/A        .precision(0)
3455485SN/A        ;
3465485SN/A
3475485SN/A    coalescedSwi = totalSwi / postedInterrupts;
3485485SN/A    coalescedRxIdle = totalRxIdle / postedInterrupts;
3495485SN/A    coalescedRxOk = totalRxOk / postedInterrupts;
3505485SN/A    coalescedRxDesc = totalRxDesc / postedInterrupts;
3515485SN/A    coalescedTxOk = totalTxOk / postedInterrupts;
3525485SN/A    coalescedTxIdle = totalTxIdle / postedInterrupts;
3535485SN/A    coalescedTxDesc = totalTxDesc / postedInterrupts;
3545485SN/A    coalescedRxOrn = totalRxOrn / postedInterrupts;
3555485SN/A
3565485SN/A    coalescedTotal = (totalSwi + totalRxIdle + totalRxOk + totalRxDesc +
3575485SN/A                      totalTxOk + totalTxIdle + totalTxDesc +
3585485SN/A                      totalRxOrn) / postedInterrupts;
3595485SN/A
3605485SN/A    txBandwidth = txBytes * Stats::constant(8) / simSeconds;
3615485SN/A    rxBandwidth = rxBytes * Stats::constant(8) / simSeconds;
3625485SN/A    totBandwidth = txBandwidth + rxBandwidth;
3635485SN/A    totBytes = txBytes + rxBytes;
3645485SN/A    totPackets = txPackets + rxPackets;
3655485SN/A
3665485SN/A    txPacketRate = txPackets / simSeconds;
3675485SN/A    rxPacketRate = rxPackets / simSeconds;
3687461SN/A    totPacketRate = totPackets / simSeconds;
3695485SN/A}
370