From a109296bdeaf43c76c2384c67b05d4b5bd484ff4 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 16 Nov 2004 23:59:51 -0500 Subject: [PATCH 1/2] Fix a bug where we would improperly calculate if the FIFO was full by adding a reserve feature to the packet fifo which allows us to reserve space in the fifo if only part of a packet was copied into the fifo. dev/ns_gige.cc: use the new reserve feature in the fifo to properly determine when we're full. assert that adding a packet to the fifo suceeds. dev/pktfifo.hh: add the ability to reserve space in the fifo. This is useful for partial writing of packets into the fifo. --HG-- extra : convert_revision : 83f871f34fac237bb464c9513cf6490b5c62420e --- dev/ns_gige.cc | 13 ++++++------- dev/pktfifo.hh | 20 +++++++++++++++----- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/dev/ns_gige.cc b/dev/ns_gige.cc index 401599126a..e51e14f1d0 100644 --- a/dev/ns_gige.cc +++ b/dev/ns_gige.cc @@ -1341,9 +1341,6 @@ NSGigE::rxKick() // sanity check - i think the driver behaves like this assert(rxDescCnt >= rxPktBytes); - - // Must clear the value before popping to decrement the - // reference count rxFifo.pop(); } @@ -1564,9 +1561,6 @@ NSGigE::transmit() * besides, it's functionally the same. */ devIntrPost(ISR_TXOK); - } else { - DPRINTF(Ethernet, - "May need to rethink always sending the descriptors back?\n"); } if (!txFifo.empty() && !txEvent.scheduled()) { @@ -1822,7 +1816,11 @@ NSGigE::txKick() // this is just because the receive can't handle a // packet bigger want to make sure assert(txPacket->length <= 1514); - txFifo.push(txPacket); +#ifndef NDEBUG + bool success = +#endif + txFifo.push(txPacket); + assert(success); /* * this following section is not tqo spec, but @@ -1903,6 +1901,7 @@ NSGigE::txKick() txPacketBufPtr += txXferLen; txFragPtr += txXferLen; txDescCnt -= txXferLen; + txFifo.reserve(txXferLen); txState = txFifoBlock; break; diff --git a/dev/pktfifo.hh b/dev/pktfifo.hh index a54a499966..0b2e95e2ab 100644 --- a/dev/pktfifo.hh +++ b/dev/pktfifo.hh @@ -43,6 +43,7 @@ class PacketFifo std::list fifo; int _maxsize; int _size; + int _reserved; public: explicit PacketFifo(int max) : _maxsize(max), _size(0) {} @@ -50,18 +51,27 @@ class PacketFifo int maxsize() const { return _maxsize; } int packets() const { return fifo.size(); } - int size() const { return _size; } - int avail() const { return _maxsize - _size; } - bool empty() const { return _size == 0; } - bool full() const { return _size >= _maxsize; } + int size() const { return _size + _reserved; } + int avail() const { return maxsize() - size(); } + bool empty() const { return size() == 0; } + bool full() const { return size() >= maxsize(); } + + int reserve(int len = 0) + { + _reserved += len; + assert(avail() >= 0); + return _reserved; + } bool push(PacketPtr ptr) { - if (avail() < ptr->length) + assert(_reserved <= ptr->length); + if (avail() < ptr->length - _reserved) return false; _size += ptr->length; fifo.push_back(ptr); + _reserved = 0; return true; } From ee962a6b0bf71b9ca8ce0b3cadc17938266fa162 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 17 Nov 2004 00:03:59 -0500 Subject: [PATCH 2/2] Fix some commands. util/stats/stats.py: we only need the system if we're issuing one of the commands that uses a stored formula. --HG-- extra : convert_revision : d129a00eeba46a03f7d600922d679aa0f43636be --- util/stats/stats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/stats/stats.py b/util/stats/stats.py index 233eab521a..8ec889f09b 100755 --- a/util/stats/stats.py +++ b/util/stats/stats.py @@ -132,8 +132,6 @@ def commands(options, command, args): info.source.connect() info.source.update_dict(globals()) - system = info.source.__dict__[options.system] - if type(options.get) is str: info.source.get = options.get @@ -232,6 +230,8 @@ def commands(options, command, args): if len(args): raise CommandException + system = info.source.__dict__[options.system] + if command == 'usertime': import copy kernel = copy.copy(system.full_cpu.numCycles)