From 71932a360da6107f934cbb78cdcc20e7bbd582fe Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Tue, 19 Jan 2021 10:05:47 -0800 Subject: [PATCH] dev: Fixing EtherDevice stats initialization order Previously, the stat `totalBandwidth` is initialized before `txBandwidth` and `rxBandwidth`. However, `totalBandwith` is of type Stats::Formula and `totalBandwidth = txBandwidth + rxBandwidth`. Therefore, `totalBandwidth` should be initialized after the other two. This change fixes the variable and stats initialization order accordingly. The bug was reported here: https://github.com/gem5/gem5/commit/3db48cbbc6e475592e6608b52a870d92ac2214aa#commitcomment-46094633. Jira: https://gem5.atlassian.net/browse/GEM5-894 Change-Id: I2c7cc4120df672edf15b9a3ab6becc0bbebb778b Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/39395 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/dev/net/etherdevice.cc | 8 ++++---- src/dev/net/etherdevice.hh | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dev/net/etherdevice.cc b/src/dev/net/etherdevice.cc index 64ab438d4..e279a9cba 100644 --- a/src/dev/net/etherdevice.cc +++ b/src/dev/net/etherdevice.cc @@ -37,6 +37,10 @@ EtherDevice::EtherDeviceStats::EtherDeviceStats(Stats::Group *parent) ADD_STAT(rxBytes, "Bytes Received"), ADD_STAT(txPackets, "Number of Packets Transmitted"), ADD_STAT(rxPackets, "Number of Packets Received"), + ADD_STAT(txBandwidth, "Transmit Bandwidth (bits/s)", + txBytes * Stats::constant(8) / simSeconds), + ADD_STAT(rxBandwidth, "Receive Bandwidth (bits/s)", + rxBytes * Stats::constant(8) / simSeconds), ADD_STAT(txIpChecksums, "Number of tx IP Checksums done by device"), ADD_STAT(rxIpChecksums, "Number of rx IP Checksums done by device"), ADD_STAT(txTcpChecksums, "Number of tx TCP Checksums done by device"), @@ -53,10 +57,6 @@ EtherDevice::EtherDeviceStats::EtherDeviceStats(Stats::Group *parent) ADD_STAT(totBytes, "Total Bytes", txBytes + rxBytes), ADD_STAT(totPacketRate, "Total Tranmission Rate (packets/s)", totPackets / simSeconds), - ADD_STAT(txBandwidth, "Transmit Bandwidth (bits/s)", - txBytes * Stats::constant(8) / simSeconds), - ADD_STAT(rxBandwidth, "Receive Bandwidth (bits/s)", - rxBytes * Stats::constant(8) / simSeconds), ADD_STAT(txPacketRate, "Packet Tranmission Rate (packets/s)", txPackets / simSeconds), ADD_STAT(rxPacketRate, "Packet Reception Rate (packets/s)", diff --git a/src/dev/net/etherdevice.hh b/src/dev/net/etherdevice.hh index 0cc54d02a..a853cd898 100644 --- a/src/dev/net/etherdevice.hh +++ b/src/dev/net/etherdevice.hh @@ -70,6 +70,9 @@ class EtherDevice : public PciDevice Stats::Scalar txPackets; Stats::Scalar rxPackets; + Stats::Formula txBandwidth; + Stats::Formula rxBandwidth; + Stats::Scalar txIpChecksums; Stats::Scalar rxIpChecksums; @@ -90,9 +93,6 @@ class EtherDevice : public PciDevice Stats::Formula totBytes; Stats::Formula totPacketRate; - Stats::Formula txBandwidth; - Stats::Formula rxBandwidth; - Stats::Formula txPacketRate; Stats::Formula rxPacketRate; -- 2.30.2