mem-cache: Add match functions to QueueEntry
[gem5.git] / src / mem / qport.hh
index 6ee71a572d36cc48bfc0c1712cea44875e02cbab..77d8dfafa18b0e60a097e9118616af7c9d5909be 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 ARM Limited
+ * Copyright (c) 2012,2015 ARM Limited
  * All rights reserved.
  *
  * The license below extends only to copyright in the software and shall
@@ -61,12 +61,10 @@ class QueuedSlavePort : public SlavePort
 
   protected:
 
-    /** Packet queue used to store outgoing requests and responses. */
-    PacketQueue &queue;
+    /** Packet queue used to store outgoing responses. */
+    RespPacketQueue &respQueue;
 
-     /** This function is notification that the device should attempt to send a
-      * packet again. */
-    virtual void recvRetry() { queue.retry(); }
+    void recvRespRetry() { respQueue.retry(); }
 
   public:
 
@@ -78,64 +76,93 @@ class QueuedSlavePort : public SlavePort
      * QueuePort constructor.
      */
     QueuedSlavePort(const std::string& name, MemObject* owner,
-                    PacketQueue &queue) :
-        SlavePort(name, owner), queue(queue)
+                    RespPacketQueue &resp_queue, PortID id = InvalidPortID) :
+        SlavePort(name, owner, id), respQueue(resp_queue)
     { }
 
     virtual ~QueuedSlavePort() { }
 
-    /** Check the list of buffered packets against the supplied
-     * functional request. */
-    bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); }
-
     /**
-     * Hook for draining the queued port.
+     * Schedule the sending of a timing response.
      *
-     * @param de an event which is used to signal back to the caller
-     * @returns a number indicating how many times process will be called
+     * @param pkt Packet to send
+     * @param when Absolute time (in ticks) to send packet
      */
-    unsigned int drain(Event *de) { return queue.drain(de); }
+    void schedTimingResp(PacketPtr pkt, Tick when)
+    { respQueue.schedSendTiming(pkt, when); }
+
+    /** Check the list of buffered packets against the supplied
+     * functional request. */
+    bool trySatisfyFunctional(PacketPtr pkt)
+    { return respQueue.trySatisfyFunctional(pkt); }
 };
 
+/**
+ * The QueuedMasterPort combines two queues, a request queue and a
+ * snoop response queue, that both share the same port. The flow
+ * control for requests and snoop responses are completely
+ * independent, and so each queue manages its own flow control
+ * (retries).
+ */
 class QueuedMasterPort : public MasterPort
 {
 
   protected:
 
-    /** Packet queue used to store outgoing requests and responses. */
-    PacketQueue &queue;
+    /** Packet queue used to store outgoing requests. */
+    ReqPacketQueue &reqQueue;
+
+    /** Packet queue used to store outgoing snoop responses. */
+    SnoopRespPacketQueue &snoopRespQueue;
+
+    void recvReqRetry() { reqQueue.retry(); }
 
-     /** This function is notification that the device should attempt to send a
-      * packet again. */
-    virtual void recvRetry() { queue.retry(); }
+    void recvRetrySnoopResp() { snoopRespQueue.retry(); }
 
   public:
 
     /**
      * Create a QueuedPort with a given name, owner, and a supplied
-     * implementation of a packet queue. The external definition of
-     * the queue enables e.g. the cache to implement a specific queue
+     * implementation of two packet queues. The external definition of
+     * the queues enables e.g. the cache to implement a specific queue
      * behaviuor in a subclass, and provide the latter to the
      * QueuePort constructor.
      */
     QueuedMasterPort(const std::string& name, MemObject* owner,
-                    PacketQueue &queue) :
-        MasterPort(name, owner), queue(queue)
+                     ReqPacketQueue &req_queue,
+                     SnoopRespPacketQueue &snoop_resp_queue,
+                     PortID id = InvalidPortID) :
+        MasterPort(name, owner, id), reqQueue(req_queue),
+        snoopRespQueue(snoop_resp_queue)
     { }
 
     virtual ~QueuedMasterPort() { }
 
-    /** Check the list of buffered packets against the supplied
-     * functional request. */
-    bool checkFunctional(PacketPtr pkt) { return queue.checkFunctional(pkt); }
+    /**
+     * Schedule the sending of a timing request.
+     *
+     * @param pkt Packet to send
+     * @param when Absolute time (in ticks) to send packet
+     */
+    void schedTimingReq(PacketPtr pkt, Tick when)
+    { reqQueue.schedSendTiming(pkt, when); }
 
     /**
-     * Hook for draining the queued port.
+     * Schedule the sending of a timing snoop response.
      *
-     * @param de an event which is used to signal back to the caller
-     * @returns a number indicating how many times process will be called
+     * @param pkt Packet to send
+     * @param when Absolute time (in ticks) to send packet
      */
-    unsigned int drain(Event *de) { return queue.drain(de); }
+    void schedTimingSnoopResp(PacketPtr pkt, Tick when)
+    { snoopRespQueue.schedSendTiming(pkt, when); }
+
+    /** Check the list of buffered packets against the supplied
+     * functional request. */
+    bool trySatisfyFunctional(PacketPtr pkt)
+    {
+        return reqQueue.trySatisfyFunctional(pkt) ||
+            snoopRespQueue.trySatisfyFunctional(pkt);
+    }
 };
 
 #endif // __MEM_QPORT_HH__