ruby: Replace Time with Cycles in SequencerMessage
[gem5.git] / src / mem / packet_queue.cc
index 77fba8883d98fcbc6add66e3050e807ba172b973..e60e77453b4c1e99292eb18af308d9e797cd6c2b 100644 (file)
@@ -41,6 +41,7 @@
  *          Andreas Hansson
  */
 
+#include "base/trace.hh"
 #include "debug/Drain.hh"
 #include "debug/PacketQueue.hh"
 #include "mem/packet_queue.hh"
@@ -48,7 +49,7 @@
 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)
 {
 }
@@ -106,7 +107,18 @@ PacketQueue::schedSendEvent(Tick when)
 void
 PacketQueue::schedSendTiming(PacketPtr pkt, Tick when, bool send_as_snoop)
 {
-    assert(when > curTick());
+    // 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
@@ -169,11 +181,11 @@ PacketQueue::scheduleSend(Tick time)
             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;
         }
     }
 }
@@ -200,12 +212,12 @@ PacketQueue::processSendEvent()
 }
 
 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;
 }