From 49407d76aaba6f347c4d7e6be45eccc43b4c05fc Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Mon, 9 Jul 2012 12:35:32 -0400 Subject: [PATCH] Port: Add isSnooping to slave port (asking master port) This patch adds isSnooping to the slave port, and thus avoids going through getMasterPort to be able to ask the master. Over the course of the next few patches, all getMasterPort/getSlavePort in Port and MemObject are to be protocol agnostic, and the snooping is part of the protocol layer. The function is already present on the master port, where it is implemented by the module itself, e.g. a cache. On the slave side, it is merely asking the connected master port. The same name is used by both functions despite their difference in behaviour. The initial design used isMasterSnooping on the slave port side, but the more verbose function name was later changed. --- src/mem/cache/cache_impl.hh | 2 +- src/mem/coherent_bus.cc | 3 ++- src/mem/comm_monitor.cc | 3 ++- src/mem/port.hh | 7 +++++++ src/mem/ruby/system/RubyPort.cc | 3 ++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mem/cache/cache_impl.hh b/src/mem/cache/cache_impl.hh index af32346bb..cc68bbd3d 100644 --- a/src/mem/cache/cache_impl.hh +++ b/src/mem/cache/cache_impl.hh @@ -795,7 +795,7 @@ Cache::functionalAccess(PacketPtr pkt, bool fromCpuSide) // continues towards the memory side if (fromCpuSide) { memSidePort->sendFunctional(pkt); - } else if (forwardSnoops && cpuSidePort->getMasterPort().isSnooping()) { + } else if (forwardSnoops && cpuSidePort->isSnooping()) { // if it came from the memory side, it must be a snoop request // and we should only forward it if we are forwarding snoops cpuSidePort->sendFunctionalSnoop(pkt); diff --git a/src/mem/coherent_bus.cc b/src/mem/coherent_bus.cc index b40e84762..ef8d68f00 100644 --- a/src/mem/coherent_bus.cc +++ b/src/mem/coherent_bus.cc @@ -92,7 +92,8 @@ CoherentBus::init() // neighbouring master ports are snooping and add them as snoopers for (SlavePortConstIter p = slavePorts.begin(); p != slavePorts.end(); ++p) { - if ((*p)->getMasterPort().isSnooping()) { + // check if the connected master port is snooping + if ((*p)->isSnooping()) { DPRINTF(BusAddrRanges, "Adding snooping master %s\n", (*p)->getMasterPort().name()); snoopPorts.push_back(*p); diff --git a/src/mem/comm_monitor.cc b/src/mem/comm_monitor.cc index 4255d58ad..d8d5806bb 100644 --- a/src/mem/comm_monitor.cc +++ b/src/mem/comm_monitor.cc @@ -328,7 +328,8 @@ CommMonitor::recvTimingSnoopResp(PacketPtr pkt) bool CommMonitor::isSnooping() const { - return slavePort.getMasterPort().isSnooping(); + // check if the connected master port is snooping + return slavePort.isSnooping(); } unsigned diff --git a/src/mem/port.hh b/src/mem/port.hh index b93d5d444..49b0e1846 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -355,6 +355,13 @@ class SlavePort : public Port */ unsigned peerBlockSize() const; + /** + * Find out if the peer master port is snooping or not. + * + * @return true if the peer master port is snooping + */ + bool isSnooping() const { return _masterPort->isSnooping(); } + /** * Called by the owner to send a range change */ diff --git a/src/mem/ruby/system/RubyPort.cc b/src/mem/ruby/system/RubyPort.cc index 3621cc9e3..285017a06 100644 --- a/src/mem/ruby/system/RubyPort.cc +++ b/src/mem/ruby/system/RubyPort.cc @@ -695,7 +695,8 @@ RubyPort::ruby_eviction_callback(const Address& address) // should this really be using funcMasterId? Request req(address.getAddress(), 0, 0, Request::funcMasterId); for (CpuPortIter p = slave_ports.begin(); p != slave_ports.end(); ++p) { - if ((*p)->getMasterPort().isSnooping()) { + // check if the connected master port is snooping + if ((*p)->isSnooping()) { Packet *pkt = new Packet(&req, MemCmd::InvalidationReq); // send as a snoop request (*p)->sendTimingSnoopReq(pkt);