diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2012-05-01 13:40:42 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2012-05-01 13:40:42 -0400 |
commit | 3fea59e1629f5dac55a7d36752e822bee7fd7fa7 (patch) | |
tree | 5fd0076b5920a217f8463c66be3df9effe8e4324 /src/mem/port.hh | |
parent | 8966e6d36d17acce3ddac13b309eeb12c7711f27 (diff) | |
download | gem5-3fea59e1629f5dac55a7d36752e822bee7fd7fa7.tar.xz |
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
Diffstat (limited to 'src/mem/port.hh')
-rw-r--r-- | src/mem/port.hh | 187 |
1 files changed, 112 insertions, 75 deletions
diff --git a/src/mem/port.hh b/src/mem/port.hh index e1f643e8e..840952354 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -73,8 +73,7 @@ class MemObject; * opposite role. * * Each port has a name and an owner, and enables three basic types of - * accesses to the peer port: sendFunctional, sendAtomic and - * sendTiming. + * accesses to the peer port: functional, atomic and timing. */ class Port { @@ -130,61 +129,18 @@ class Port protected: - /** These functions are protected because they should only be - * called by a peer port, never directly by any outside object. */ - - /** - * Receive a timing request or response packet from the peer port. - */ - virtual bool recvTiming(PacketPtr pkt) = 0; - - /** - * Receive a timing snoop request or snoop response packet from - * the peer port. - */ - virtual bool recvTimingSnoop(PacketPtr pkt) - { - panic("%s was not expecting a timing snoop\n", name()); - return false; - } - /** - * Called by a peer port if sendTiming or sendTimingSnoop was - * unsuccesful, and had to wait. + * Called by a peer port if sendTimingReq, sendTimingResp or + * sendTimingSnoopResp was unsuccesful, and had to wait. */ virtual void recvRetry() = 0; public: /** - * Attempt to send a timing request or response packet to the peer - * port by calling its receive function. If the send does not - * succeed, as indicated by the return value, then the sender must - * wait for a recvRetry at which point it can re-issue a - * sendTiming. - * - * @param pkt Packet to send. - * - * @return If the send was succesful or not. - */ - bool sendTiming(PacketPtr pkt) { return peer->recvTiming(pkt); } - - /** - * Attempt to send a timing snoop request or snoop response packet - * to the peer port by calling its receive function. If the send - * does not succeed, as indicated by the return value, then the - * sender must wait for a recvRetry at which point it can re-issue - * a sendTimingSnoop. - * - * @param pkt Packet to send. - * - * @return If the send was succesful or not. - */ - bool sendTimingSnoop(PacketPtr pkt) { return peer->recvTimingSnoop(pkt); } - - /** * Send a retry to a peer port that previously attempted a - * sendTiming or sendTimingSnoop which was unsuccessful. + * sendTimingReq, sendTimingResp or sendTimingSnoopResp which was + * unsuccessful. */ void sendRetry() { return peer->recvRetry(); } @@ -202,6 +158,8 @@ class SlavePort; class MasterPort : public Port { + friend class SlavePort; + private: SlavePort* _slavePort; @@ -237,30 +195,28 @@ class MasterPort : public Port void sendFunctional(PacketPtr pkt); /** - * Receive an atomic snoop request packet from the slave port. - */ - virtual Tick recvAtomicSnoop(PacketPtr pkt) - { - panic("%s was not expecting an atomic snoop\n", name()); - return 0; - } - - /** - * Receive a functional snoop request packet from the slave port. - */ - virtual void recvFunctionalSnoop(PacketPtr pkt) - { - panic("%s was not expecting a functional snoop\n", name()); - } + * Attempt to send a timing request to the slave port by calling + * its corresponding receive function. If the send does not + * succeed, as indicated by the return value, then the sender must + * wait for a recvRetry at which point it can re-issue a + * sendTimingReq. + * + * @param pkt Packet to send. + * + * @return If the send was succesful or not. + */ + bool sendTimingReq(PacketPtr pkt); /** - * Called to receive an address range change from the peer slave - * port. the default implementation ignored the change and does - * nothing. Override this function in a derived class if the owner - * needs to be aware of he laesddress ranges, e.g. in an - * interconnect component like a bus. + * Attempt to send a timing snoop response packet to the slave + * port by calling its corresponding receive function. If the send + * does not succeed, as indicated by the return value, then the + * sender must wait for a recvRetry at which point it can re-issue + * a sendTimingSnoopResp. + * + * @param pkt Packet to send. */ - virtual void recvRangeChange() { } + bool sendTimingSnoopResp(PacketPtr pkt); /** * Determine if this master port is snooping or not. The default @@ -288,6 +244,47 @@ class MasterPort : public Port * that address throughout the memory system. For debugging. */ void printAddr(Addr a); + + protected: + + /** + * Receive an atomic snoop request packet from the slave port. + */ + virtual Tick recvAtomicSnoop(PacketPtr pkt) + { + panic("%s was not expecting an atomic snoop request\n", name()); + return 0; + } + + /** + * Receive a functional snoop request packet from the slave port. + */ + virtual void recvFunctionalSnoop(PacketPtr pkt) + { + panic("%s was not expecting a functional snoop request\n", name()); + } + + /** + * Receive a timing response from the slave port. + */ + virtual bool recvTimingResp(PacketPtr pkt) = 0; + + /** + * Receive a timing snoop request from the slave port. + */ + virtual void recvTimingSnoopReq(PacketPtr pkt) + { + panic("%s was not expecting a timing snoop request\n", name()); + } + + /** + * Called to receive an address range change from the peer slave + * port. the default implementation ignored the change and does + * nothing. Override this function in a derived class if the owner + * needs to be aware of he laesddress ranges, e.g. in an + * interconnect component like a bus. + */ + virtual void recvRangeChange() { } }; /** @@ -299,6 +296,8 @@ class MasterPort : public Port class SlavePort : public Port { + friend class MasterPort; + private: MasterPort* _masterPort; @@ -334,14 +333,26 @@ class SlavePort : public Port void sendFunctionalSnoop(PacketPtr pkt); /** - * Receive an atomic request packet from the master port. - */ - virtual Tick recvAtomic(PacketPtr pkt) = 0; + * Attempt to send a timing response to the master port by calling + * its corresponding receive function. If the send does not + * succeed, as indicated by the return value, then the sender must + * wait for a recvRetry at which point it can re-issue a + * sendTimingResp. + * + * @param pkt Packet to send. + * + * @return If the send was succesful or not. + */ + bool sendTimingResp(PacketPtr pkt); /** - * Receive a functional request packet from the master port. + * Attempt to send a timing snoop request packet to the master port + * by calling its corresponding receive function. Snoop requests + * always succeed and hence no return value is needed. + * + * @param pkt Packet to send. */ - virtual void recvFunctional(PacketPtr pkt) = 0; + void sendTimingSnoopReq(PacketPtr pkt); /** * Called by a peer port in order to determine the block size of @@ -367,6 +378,32 @@ class SlavePort : public Port * @return a list of ranges responded to */ virtual AddrRangeList getAddrRanges() = 0; + + protected: + + /** + * Receive an atomic request packet from the master port. + */ + virtual Tick recvAtomic(PacketPtr pkt) = 0; + + /** + * Receive a functional request packet from the master port. + */ + virtual void recvFunctional(PacketPtr pkt) = 0; + + /** + * Receive a timing request from the master port. + */ + virtual bool recvTimingReq(PacketPtr pkt) = 0; + + /** + * Receive a timing snoop response from the master port. + */ + virtual bool recvTimingSnoopResp(PacketPtr pkt) + { + panic("%s was not expecting a timing snoop response\n", name()); + } + }; #endif //__MEM_PORT_HH__ |