* Andreas Hansson
*/
+#include "base/trace.hh"
#include "debug/Drain.hh"
#include "debug/PacketQueue.hh"
#include "mem/packet_queue.hh"
using namespace std;
PacketQueue::PacketQueue(EventManager& _em, const std::string& _label)
- : em(_em), sendEvent(this), drainEvent(NULL), label(_label),
+ : em(_em), sendEvent(this), drainManager(NULL), label(_label),
waitingOnRetry(false)
{
}
// we can still send a packet before the end of this tick
assert(when >= curTick());
+ // express snoops should never be queued
+ assert(!pkt->isExpressSnoop());
+
+ // add a very basic sanity check on the port to ensure the
+ // invisible buffer is not growing beyond reasonable limits
+ if (transmitList.size() > 100) {
+ panic("Packet queue %s has grown beyond 100 packets\n",
+ name());
+ }
+
// nothing on the list, or earlier than current front element,
// schedule an event
if (transmitList.empty() || when < transmitList.front().tick) {
em.schedule(&sendEvent, std::max(nextReady, curTick() + 1));
} else {
// no more to send, so if we're draining, we may be done
- if (drainEvent && transmitList.empty() && !sendEvent.scheduled()) {
+ if (drainManager && transmitList.empty() && !sendEvent.scheduled()) {
DPRINTF(Drain, "PacketQueue done draining,"
"processing drain event\n");
- drainEvent->process();
- drainEvent = NULL;
+ drainManager->signalDrainDone();
+ drainManager = NULL;
}
}
}
}
unsigned int
-PacketQueue::drain(Event *de)
+PacketQueue::drain(DrainManager *dm)
{
if (transmitList.empty() && !sendEvent.scheduled())
return 0;
DPRINTF(Drain, "PacketQueue not drained\n");
- drainEvent = de;
+ drainManager = dm;
return 1;
}