From 856d66d9ba7fbb2740bed0c85ebcf50bb82792ab Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Thu, 22 Oct 2020 02:10:33 -0700 Subject: [PATCH] dev,stats: Update stats style for CopyEngine and IdeDisk Change-Id: Ib757b00864bc144b20adef974e3443ddba2945f0 Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36436 Reviewed-by: Gabe Black Maintainer: Bobby R. Bruce Tested-by: kokoro --- src/dev/pci/copy_engine.cc | 30 ++++++++++----------- src/dev/pci/copy_engine.hh | 11 +++++--- src/dev/storage/ide_disk.cc | 54 +++++++++++++------------------------ src/dev/storage/ide_disk.hh | 22 +++++++-------- 4 files changed, 50 insertions(+), 67 deletions(-) diff --git a/src/dev/pci/copy_engine.cc b/src/dev/pci/copy_engine.cc index 5673e63ad..02d3d8670 100644 --- a/src/dev/pci/copy_engine.cc +++ b/src/dev/pci/copy_engine.cc @@ -58,7 +58,8 @@ using namespace CopyEngineReg; CopyEngine::CopyEngine(const Params &p) - : PciDevice(p) + : PciDevice(p), + copyEngineStats(this, p.ChanCnt) { // All Reg regs are initialized to 0 by default regs.chanCount = p.ChanCnt; @@ -425,23 +426,20 @@ CopyEngine::CopyEngineChannel::channelWrite(Packet *pkt, Addr daddr, int size) } } -void -CopyEngine::regStats() +CopyEngine:: +CopyEngineStats::CopyEngineStats(Stats::Group *parent, + const uint8_t &channel_count) + : Stats::Group(parent, "CopyEngine"), + ADD_STAT(bytesCopied, "Number of bytes copied by each engine"), + ADD_STAT(copiesProcessed, "Number of copies processed by each engine") { - PciDevice::regStats(); - - using namespace Stats; bytesCopied - .init(regs.chanCount) - .name(name() + ".bytes_copied") - .desc("Number of bytes copied by each engine") - .flags(total) + .init(channel_count) + .flags(Stats::total) ; copiesProcessed - .init(regs.chanCount) - .name(name() + ".copies_processed") - .desc("Number of copies processed by each engine") - .flags(total) + .init(channel_count) + .flags(Stats::total) ; } @@ -521,8 +519,8 @@ CopyEngine::CopyEngineChannel::writeCopyBytes() cePort.dmaAction(MemCmd::WriteReq, ce->pciToDma(curDmaDesc->dest), curDmaDesc->len, &writeCompleteEvent, copyBuffer, 0); - ce->bytesCopied[channelId] += curDmaDesc->len; - ce->copiesProcessed[channelId]++; + ce->copyEngineStats.bytesCopied[channelId] += curDmaDesc->len; + ce->copyEngineStats.copiesProcessed[channelId]++; } void diff --git a/src/dev/pci/copy_engine.hh b/src/dev/pci/copy_engine.hh index ec3c45304..17d0eb8f2 100644 --- a/src/dev/pci/copy_engine.hh +++ b/src/dev/pci/copy_engine.hh @@ -139,8 +139,13 @@ class CopyEngine : public PciDevice private: - Stats::Vector bytesCopied; - Stats::Vector copiesProcessed; + struct CopyEngineStats : public Stats::Group + { + CopyEngineStats(Stats::Group *parent, const uint8_t& channel_count); + + Stats::Vector bytesCopied; + Stats::Vector copiesProcessed; + } copyEngineStats; // device registers CopyEngineReg::Regs regs; @@ -158,8 +163,6 @@ class CopyEngine : public PciDevice CopyEngine(const Params ¶ms); ~CopyEngine(); - void regStats() override; - Port &getPort(const std::string &if_name, PortID idx = InvalidPortID) override; diff --git a/src/dev/storage/ide_disk.cc b/src/dev/storage/ide_disk.cc index 3f297754f..808c70586 100644 --- a/src/dev/storage/ide_disk.cc +++ b/src/dev/storage/ide_disk.cc @@ -60,6 +60,7 @@ IdeDisk::IdeDisk(const Params &p) : SimObject(p), ctrl(NULL), image(p.image), diskDelay(p.delay), + ideDiskStats(this), dmaTransferEvent([this]{ doDmaTransfer(); }, name()), dmaReadCG(NULL), dmaReadWaitEvent([this]{ doDmaRead(); }, name()), @@ -386,37 +387,18 @@ IdeDisk::doDmaDataRead() schedule(dmaReadWaitEvent, curTick() + totalDiskDelay); } -void -IdeDisk::regStats() +IdeDisk:: +IdeDiskStats::IdeDiskStats(Stats::Group *parent) + : Stats::Group(parent, "IdeDisk"), + ADD_STAT(dmaReadFullPages, + "Number of full page size DMA reads (not PRD)."), + ADD_STAT(dmaReadBytes, + "Number of bytes transfered via DMA reads (not PRD)."), + ADD_STAT(dmaReadTxs, "Number of DMA read transactions (not PRD)."), + ADD_STAT(dmaWriteFullPages, "Number of full page size DMA writes."), + ADD_STAT(dmaWriteBytes, "Number of bytes transfered via DMA writes."), + ADD_STAT(dmaWriteTxs, "Number of DMA write transactions.") { - SimObject::regStats(); - - using namespace Stats; - dmaReadFullPages - .name(name() + ".dma_read_full_pages") - .desc("Number of full page size DMA reads (not PRD).") - ; - dmaReadBytes - .name(name() + ".dma_read_bytes") - .desc("Number of bytes transfered via DMA reads (not PRD).") - ; - dmaReadTxs - .name(name() + ".dma_read_txs") - .desc("Number of DMA read transactions (not PRD).") - ; - - dmaWriteFullPages - .name(name() + ".dma_write_full_pages") - .desc("Number of full page size DMA writes.") - ; - dmaWriteBytes - .name(name() + ".dma_write_bytes") - .desc("Number of bytes transfered via DMA writes.") - ; - dmaWriteTxs - .name(name() + ".dma_write_txs") - .desc("Number of DMA write transactions.") - ; } void @@ -445,10 +427,10 @@ IdeDisk::doDmaRead() assert(dmaReadCG->complete() < MAX_DMA_SIZE); ctrl->dmaRead(pciToDma(dmaReadCG->addr()), dmaReadCG->size(), &dmaReadWaitEvent, dataBuffer + dmaReadCG->complete()); - dmaReadBytes += dmaReadCG->size(); - dmaReadTxs++; + ideDiskStats.dmaReadBytes += dmaReadCG->size(); + ideDiskStats.dmaReadTxs++; if (dmaReadCG->size() == chunkBytes) - dmaReadFullPages++; + ideDiskStats.dmaReadFullPages++; dmaReadCG->next(); } else { assert(dmaReadCG->done()); @@ -530,10 +512,10 @@ IdeDisk::doDmaWrite() &dmaWriteWaitEvent, dataBuffer + dmaWriteCG->complete()); DPRINTF(IdeDisk, "doDmaWrite: not done curPrd byte count %d, eot %#x\n", curPrd.getByteCount(), curPrd.getEOT()); - dmaWriteBytes += dmaWriteCG->size(); - dmaWriteTxs++; + ideDiskStats.dmaWriteBytes += dmaWriteCG->size(); + ideDiskStats.dmaWriteTxs++; if (dmaWriteCG->size() == chunkBytes) - dmaWriteFullPages++; + ideDiskStats.dmaWriteFullPages++; dmaWriteCG->next(); } else { DPRINTF(IdeDisk, "doDmaWrite: done curPrd byte count %d, eot %#x\n", diff --git a/src/dev/storage/ide_disk.hh b/src/dev/storage/ide_disk.hh index ba2bad2a1..a0e02ce08 100644 --- a/src/dev/storage/ide_disk.hh +++ b/src/dev/storage/ide_disk.hh @@ -252,12 +252,17 @@ class IdeDisk : public SimObject /** DMA Aborted */ bool dmaAborted; - Stats::Scalar dmaReadFullPages; - Stats::Scalar dmaReadBytes; - Stats::Scalar dmaReadTxs; - Stats::Scalar dmaWriteFullPages; - Stats::Scalar dmaWriteBytes; - Stats::Scalar dmaWriteTxs; + struct IdeDiskStats : public Stats::Group + { + IdeDiskStats(Stats::Group *parent); + + Stats::Scalar dmaReadFullPages; + Stats::Scalar dmaReadBytes; + Stats::Scalar dmaReadTxs; + Stats::Scalar dmaWriteFullPages; + Stats::Scalar dmaWriteBytes; + Stats::Scalar dmaWriteTxs; + } ideDiskStats; public: typedef IdeDiskParams Params; @@ -273,11 +278,6 @@ class IdeDisk : public SimObject */ void reset(int id); - /** - * Register Statistics - */ - void regStats() override; - /** * Set the controller for this device * @param c The IDE controller -- 2.30.2