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{
3911522Sstephan.diestelhorst@arm.com    PciDevice::regStats();
4011522Sstephan.diestelhorst@arm.com
415485SN/A    txBytes
425485SN/A        .name(name() + ".txBytes")
435485SN/A        .desc("Bytes Transmitted")
445485SN/A        .prereq(txBytes)
455485SN/A        ;
465485SN/A
475485SN/A    rxBytes
485485SN/A        .name(name() + ".rxBytes")
495485SN/A        .desc("Bytes Received")
505485SN/A        .prereq(rxBytes)
515485SN/A        ;
525485SN/A
535485SN/A    txPackets
545485SN/A        .name(name() + ".txPackets")
555485SN/A        .desc("Number of Packets Transmitted")
565485SN/A        .prereq(txBytes)
575485SN/A        ;
585485SN/A
595485SN/A    rxPackets
605485SN/A        .name(name() + ".rxPackets")
615485SN/A        .desc("Number of Packets Received")
625485SN/A        .prereq(rxBytes)
635485SN/A        ;
645485SN/A
655485SN/A    txIpChecksums
665485SN/A        .name(name() + ".txIpChecksums")
675485SN/A        .desc("Number of tx IP Checksums done by device")
685485SN/A        .precision(0)
695485SN/A        .prereq(txBytes)
705485SN/A        ;
715485SN/A
725485SN/A    rxIpChecksums
735485SN/A        .name(name() + ".rxIpChecksums")
745485SN/A        .desc("Number of rx IP Checksums done by device")
755485SN/A        .precision(0)
765485SN/A        .prereq(rxBytes)
775485SN/A        ;
785485SN/A
795485SN/A    txTcpChecksums
805485SN/A        .name(name() + ".txTcpChecksums")
815485SN/A        .desc("Number of tx TCP Checksums done by device")
825485SN/A        .precision(0)
835485SN/A        .prereq(txBytes)
845485SN/A        ;
855485SN/A
865485SN/A    rxTcpChecksums
875485SN/A        .name(name() + ".rxTcpChecksums")
885485SN/A        .desc("Number of rx TCP Checksums done by device")
895485SN/A        .precision(0)
905485SN/A        .prereq(rxBytes)
915485SN/A        ;
925485SN/A
935485SN/A    txUdpChecksums
945485SN/A        .name(name() + ".txUdpChecksums")
955485SN/A        .desc("Number of tx UDP Checksums done by device")
965485SN/A        .precision(0)
975485SN/A        .prereq(txBytes)
985485SN/A        ;
995485SN/A
1005485SN/A    rxUdpChecksums
1015485SN/A        .name(name() + ".rxUdpChecksums")
1025485SN/A        .desc("Number of rx UDP Checksums done by device")
1035485SN/A        .precision(0)
1045485SN/A        .prereq(rxBytes)
1055485SN/A        ;
1065485SN/A
1075485SN/A    descDmaReads
1085485SN/A        .name(name() + ".descDMAReads")
1095485SN/A        .desc("Number of descriptors the device read w/ DMA")
1105485SN/A        .precision(0)
1115485SN/A        ;
1125485SN/A
1135485SN/A    descDmaWrites
1145485SN/A        .name(name() + ".descDMAWrites")
1155485SN/A        .desc("Number of descriptors the device wrote w/ DMA")
1165485SN/A        .precision(0)
1175485SN/A        ;
1185485SN/A
1195485SN/A    descDmaRdBytes
1205485SN/A        .name(name() + ".descDmaReadBytes")
1215485SN/A        .desc("number of descriptor bytes read w/ DMA")
1225485SN/A        .precision(0)
1235485SN/A        ;
1245485SN/A
1257461SN/A    descDmaWrBytes
1265485SN/A        .name(name() + ".descDmaWriteBytes")
1275485SN/A        .desc("number of descriptor bytes write w/ DMA")
1285485SN/A        .precision(0)
1295485SN/A        ;
1305485SN/A
1315485SN/A    txBandwidth
1325485SN/A        .name(name() + ".txBandwidth")
1335485SN/A        .desc("Transmit Bandwidth (bits/s)")
1345485SN/A        .precision(0)
1355485SN/A        .prereq(txBytes)
1365485SN/A        ;
1375485SN/A
1385485SN/A    rxBandwidth
1395485SN/A        .name(name() + ".rxBandwidth")
1405485SN/A        .desc("Receive Bandwidth (bits/s)")
1415485SN/A        .precision(0)
1425485SN/A        .prereq(rxBytes)
1435485SN/A        ;
1445485SN/A
1455485SN/A    totBandwidth
1465485SN/A        .name(name() + ".totBandwidth")
1475485SN/A        .desc("Total Bandwidth (bits/s)")
1485485SN/A        .precision(0)
1495485SN/A        .prereq(totBytes)
1505485SN/A        ;
1515485SN/A
1525485SN/A    totPackets
1535485SN/A        .name(name() + ".totPackets")
1545485SN/A        .desc("Total Packets")
1555485SN/A        .precision(0)
1565485SN/A        .prereq(totBytes)
1575485SN/A        ;
1585485SN/A
1595485SN/A    totBytes
1605485SN/A        .name(name() + ".totBytes")
1615485SN/A        .desc("Total Bytes")
1625485SN/A        .precision(0)
1635485SN/A        .prereq(totBytes)
1645485SN/A        ;
1655485SN/A
1665485SN/A    totPacketRate
1675485SN/A        .name(name() + ".totPPS")
1685485SN/A        .desc("Total Tranmission Rate (packets/s)")
1695485SN/A        .precision(0)
1705485SN/A        .prereq(totBytes)
1715485SN/A        ;
1725485SN/A
1735485SN/A    txPacketRate
1745485SN/A        .name(name() + ".txPPS")
1755485SN/A        .desc("Packet Tranmission Rate (packets/s)")
1765485SN/A        .precision(0)
1775485SN/A        .prereq(txBytes)
1785485SN/A        ;
1795485SN/A
1805485SN/A    rxPacketRate
1815485SN/A        .name(name() + ".rxPPS")
1825485SN/A        .desc("Packet Reception Rate (packets/s)")
1835485SN/A        .precision(0)
1845485SN/A        .prereq(rxBytes)
1855485SN/A        ;
1865485SN/A
1875485SN/A    postedSwi
1885485SN/A        .name(name() + ".postedSwi")
1895485SN/A        .desc("number of software interrupts posted to CPU")
1905485SN/A        .precision(0)
1915485SN/A        ;
1925485SN/A
1935485SN/A    totalSwi
1945485SN/A        .name(name() + ".totalSwi")
1955485SN/A        .desc("total number of Swi written to ISR")
1965485SN/A        .precision(0)
1975485SN/A        ;
1985485SN/A
1995485SN/A    coalescedSwi
2005485SN/A        .name(name() + ".coalescedSwi")
2015485SN/A        .desc("average number of Swi's coalesced into each post")
2025485SN/A        .precision(0)
2035485SN/A        ;
2045485SN/A
2055485SN/A    postedRxIdle
2065485SN/A        .name(name() + ".postedRxIdle")
2075485SN/A        .desc("number of rxIdle interrupts posted to CPU")
2085485SN/A        .precision(0)
2095485SN/A        ;
2105485SN/A
2115485SN/A    totalRxIdle
2125485SN/A        .name(name() + ".totalRxIdle")
2135485SN/A        .desc("total number of RxIdle written to ISR")
2145485SN/A        .precision(0)
2155485SN/A        ;
2165485SN/A
2175485SN/A    coalescedRxIdle
2185485SN/A        .name(name() + ".coalescedRxIdle")
2195485SN/A        .desc("average number of RxIdle's coalesced into each post")
2205485SN/A        .precision(0)
2215485SN/A        ;
2225485SN/A
2235485SN/A    postedRxOk
2245485SN/A        .name(name() + ".postedRxOk")
2255485SN/A        .desc("number of RxOk interrupts posted to CPU")
2265485SN/A        .precision(0)
2275485SN/A        ;
2285485SN/A
2295485SN/A    totalRxOk
2305485SN/A        .name(name() + ".totalRxOk")
2315485SN/A        .desc("total number of RxOk written to ISR")
2325485SN/A        .precision(0)
2335485SN/A        ;
2345485SN/A
2355485SN/A    coalescedRxOk
2365485SN/A        .name(name() + ".coalescedRxOk")
2375485SN/A        .desc("average number of RxOk's coalesced into each post")
2385485SN/A        .precision(0)
2395485SN/A        ;
2405485SN/A
2415485SN/A    postedRxDesc
2425485SN/A        .name(name() + ".postedRxDesc")
2435485SN/A        .desc("number of RxDesc interrupts posted to CPU")
2445485SN/A        .precision(0)
2455485SN/A        ;
2465485SN/A
2475485SN/A    totalRxDesc
2485485SN/A        .name(name() + ".totalRxDesc")
2495485SN/A        .desc("total number of RxDesc written to ISR")
2505485SN/A        .precision(0)
2515485SN/A        ;
2525485SN/A
2535485SN/A    coalescedRxDesc
2545485SN/A        .name(name() + ".coalescedRxDesc")
2555485SN/A        .desc("average number of RxDesc's coalesced into each post")
2565485SN/A        .precision(0)
2575485SN/A        ;
2585485SN/A
2595485SN/A    postedTxOk
2605485SN/A        .name(name() + ".postedTxOk")
2615485SN/A        .desc("number of TxOk interrupts posted to CPU")
2625485SN/A        .precision(0)
2635485SN/A        ;
2645485SN/A
2655485SN/A    totalTxOk
2665485SN/A        .name(name() + ".totalTxOk")
2675485SN/A        .desc("total number of TxOk written to ISR")
2685485SN/A        .precision(0)
2695485SN/A        ;
2705485SN/A
2715485SN/A    coalescedTxOk
2725485SN/A        .name(name() + ".coalescedTxOk")
2735485SN/A        .desc("average number of TxOk's coalesced into each post")
2745485SN/A        .precision(0)
2755485SN/A        ;
2765485SN/A
2775485SN/A    postedTxIdle
2785485SN/A        .name(name() + ".postedTxIdle")
2795485SN/A        .desc("number of TxIdle interrupts posted to CPU")
2805485SN/A        .precision(0)
2815485SN/A        ;
2825485SN/A
2835485SN/A    totalTxIdle
2845485SN/A        .name(name() + ".totalTxIdle")
2855485SN/A        .desc("total number of TxIdle written to ISR")
2865485SN/A        .precision(0)
2875485SN/A        ;
2885485SN/A
2895485SN/A    coalescedTxIdle
2905485SN/A        .name(name() + ".coalescedTxIdle")
2915485SN/A        .desc("average number of TxIdle's coalesced into each post")
2925485SN/A        .precision(0)
2935485SN/A        ;
2945485SN/A
2955485SN/A    postedTxDesc
2965485SN/A        .name(name() + ".postedTxDesc")
2975485SN/A        .desc("number of TxDesc interrupts posted to CPU")
2985485SN/A        .precision(0)
2995485SN/A        ;
3005485SN/A
3015485SN/A    totalTxDesc
3025485SN/A        .name(name() + ".totalTxDesc")
3035485SN/A        .desc("total number of TxDesc written to ISR")
3045485SN/A        .precision(0)
3055485SN/A        ;
3065485SN/A
3075485SN/A    coalescedTxDesc
3085485SN/A        .name(name() + ".coalescedTxDesc")
3095485SN/A        .desc("average number of TxDesc's coalesced into each post")
3105485SN/A        .precision(0)
3115485SN/A        ;
3125485SN/A
3135485SN/A    postedRxOrn
3145485SN/A        .name(name() + ".postedRxOrn")
3155485SN/A        .desc("number of RxOrn posted to CPU")
3165485SN/A        .precision(0)
3175485SN/A        ;
3185485SN/A
3195485SN/A    totalRxOrn
3205485SN/A        .name(name() + ".totalRxOrn")
3215485SN/A        .desc("total number of RxOrn written to ISR")
3225485SN/A        .precision(0)
3235485SN/A        ;
3245485SN/A
3255485SN/A    coalescedRxOrn
3265485SN/A        .name(name() + ".coalescedRxOrn")
3275485SN/A        .desc("average number of RxOrn's coalesced into each post")
3285485SN/A        .precision(0)
3295485SN/A        ;
3305485SN/A
3315485SN/A    coalescedTotal
3325485SN/A        .name(name() + ".coalescedTotal")
3335485SN/A        .desc("average number of interrupts coalesced into each post")
3345485SN/A        .precision(0)
3355485SN/A        ;
3365485SN/A
3375485SN/A    postedInterrupts
3385485SN/A        .name(name() + ".postedInterrupts")
3395485SN/A        .desc("number of posts to CPU")
3405485SN/A        .precision(0)
3415485SN/A        ;
3425485SN/A
3435485SN/A    droppedPackets
3445485SN/A        .name(name() + ".droppedPackets")
3455485SN/A        .desc("number of packets dropped")
3465485SN/A        .precision(0)
3475485SN/A        ;
3485485SN/A
3495485SN/A    coalescedSwi = totalSwi / postedInterrupts;
3505485SN/A    coalescedRxIdle = totalRxIdle / postedInterrupts;
3515485SN/A    coalescedRxOk = totalRxOk / postedInterrupts;
3525485SN/A    coalescedRxDesc = totalRxDesc / postedInterrupts;
3535485SN/A    coalescedTxOk = totalTxOk / postedInterrupts;
3545485SN/A    coalescedTxIdle = totalTxIdle / postedInterrupts;
3555485SN/A    coalescedTxDesc = totalTxDesc / postedInterrupts;
3565485SN/A    coalescedRxOrn = totalRxOrn / postedInterrupts;
3575485SN/A
3585485SN/A    coalescedTotal = (totalSwi + totalRxIdle + totalRxOk + totalRxDesc +
3595485SN/A                      totalTxOk + totalTxIdle + totalTxDesc +
3605485SN/A                      totalRxOrn) / postedInterrupts;
3615485SN/A
3625485SN/A    txBandwidth = txBytes * Stats::constant(8) / simSeconds;
3635485SN/A    rxBandwidth = rxBytes * Stats::constant(8) / simSeconds;
3645485SN/A    totBandwidth = txBandwidth + rxBandwidth;
3655485SN/A    totBytes = txBytes + rxBytes;
3665485SN/A    totPackets = txPackets + rxPackets;
3675485SN/A
3685485SN/A    txPacketRate = txPackets / simSeconds;
3695485SN/A    rxPacketRate = rxPackets / simSeconds;
3707461SN/A    totPacketRate = totPackets / simSeconds;
3715485SN/A}
372