gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
coherent_xbar.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2002-2005 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * Authors: Ron Dreslinski
41  * Ali Saidi
42  * Andreas Hansson
43  * William Wang
44  */
45 
51 #ifndef __MEM_COHERENT_XBAR_HH__
52 #define __MEM_COHERENT_XBAR_HH__
53 
54 #include <unordered_set>
55 
56 #include "mem/snoop_filter.hh"
57 #include "mem/xbar.hh"
58 #include "params/CoherentXBar.hh"
59 
71 class CoherentXBar : public BaseXBar
72 {
73 
74  protected:
75 
83 
90  {
91 
92  private:
93 
96 
99 
100  public:
101 
102  CoherentXBarSlavePort(const std::string &_name,
103  CoherentXBar &_xbar, PortID _id)
104  : QueuedSlavePort(_name, &_xbar, queue, _id), xbar(_xbar),
105  queue(_xbar, *this)
106  { }
107 
108  protected:
109 
113  virtual bool recvTimingReq(PacketPtr pkt)
114  { return xbar.recvTimingReq(pkt, id); }
115 
119  virtual bool recvTimingSnoopResp(PacketPtr pkt)
120  { return xbar.recvTimingSnoopResp(pkt, id); }
121 
125  virtual Tick recvAtomic(PacketPtr pkt)
126  { return xbar.recvAtomic(pkt, id); }
127 
131  virtual void recvFunctional(PacketPtr pkt)
132  { xbar.recvFunctional(pkt, id); }
133 
137  virtual AddrRangeList getAddrRanges() const
138  { return xbar.getAddrRanges(); }
139 
140  };
141 
148  {
149  private:
152 
153  public:
154 
155  CoherentXBarMasterPort(const std::string &_name,
156  CoherentXBar &_xbar, PortID _id)
157  : MasterPort(_name, &_xbar, _id), xbar(_xbar)
158  { }
159 
160  protected:
161 
168  virtual bool isSnooping() const
169  { return true; }
170 
174  virtual bool recvTimingResp(PacketPtr pkt)
175  { return xbar.recvTimingResp(pkt, id); }
176 
180  virtual void recvTimingSnoopReq(PacketPtr pkt)
181  { return xbar.recvTimingSnoopReq(pkt, id); }
182 
187  { return xbar.recvAtomicSnoop(pkt, id); }
188 
192  virtual void recvFunctionalSnoop(PacketPtr pkt)
193  { xbar.recvFunctionalSnoop(pkt, id); }
194 
197  virtual void recvRangeChange()
198  { xbar.recvRangeChange(id); }
199 
202  virtual void recvReqRetry()
203  { xbar.recvReqRetry(id); }
204 
205  };
206 
212  class SnoopRespPort : public MasterPort
213  {
214 
215  private:
216 
219 
220  public:
221 
226  MasterPort(slave_port.name() + ".snoopRespPort", &_xbar),
227  slavePort(slave_port) { }
228 
233  void sendRetryResp() {
234  // forward it as a snoop response retry
236  }
237 
241  void recvReqRetry() { panic("SnoopRespPort should never see retry\n"); }
242 
247  {
248  panic("SnoopRespPort should never see timing response\n");
249  return false;
250  }
251 
252  };
253 
255 
257 
263  std::unordered_set<RequestPtr> outstandingSnoop;
264 
270 
274 
277 
279  const bool pointOfCoherency;
280 
285  std::unique_ptr<Packet> pendingDelete;
286 
289  bool recvTimingReq(PacketPtr pkt, PortID slave_port_id);
290 
293  bool recvTimingResp(PacketPtr pkt, PortID master_port_id);
294 
297  void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id);
298 
301  bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id);
302 
305  void recvReqRetry(PortID master_port_id);
306 
315  void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id) {
316  forwardTiming(pkt, exclude_slave_port_id, snoopPorts);
317  }
318 
328  void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
329  const std::vector<QueuedSlavePort*>& dests);
330 
333  Tick recvAtomic(PacketPtr pkt, PortID slave_port_id);
334 
337  Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id);
338 
350  PortID exclude_slave_port_id)
351  {
352  return forwardAtomic(pkt, exclude_slave_port_id, InvalidPortID,
353  snoopPorts);
354  }
355 
369  PortID exclude_slave_port_id,
370  PortID source_master_port_id,
372  dests);
373 
376  void recvFunctional(PacketPtr pkt, PortID slave_port_id);
377 
380  void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id);
381 
390  void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id);
391 
396  bool sinkPacket(const PacketPtr pkt) const;
397 
401 
402  public:
403 
404  virtual void init();
405 
406  CoherentXBar(const CoherentXBarParams *p);
407 
408  virtual ~CoherentXBar();
409 
410  virtual void regStats();
411 };
412 
413 #endif //__MEM_COHERENT_XBAR_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
virtual ~CoherentXBar()
std::vector< SnoopRespLayer * > snoopLayers
SnoopRespPort(QueuedSlavePort &slave_port, CoherentXBar &_xbar)
Create a snoop response port that mirrors a given slave port.
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
std::vector< RespLayer * > respLayers
const PortID InvalidPortID
Definition: types.hh:182
STL pair class.
Definition: stl.hh:61
#define panic(...)
Definition: misc.hh:153
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:99
virtual void recvFunctionalSnoop(PacketPtr pkt)
When receiving a functional snoop request, pass it to the crossbar.
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
void recvReqRetry(PortID master_port_id)
Timing function called by port when it is once again able to process requests.
Stats::Distribution snoopFanout
Internal class to bridge between an incoming snoop response from a slave port and forwarding it throu...
virtual bool isSnooping() const
Determine if this port should be considered a snooper.
Definition: system.hh:83
Definition of a snoop filter.
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
Definition: qport.hh:59
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests, one for responses, and one for snoop re...
virtual Tick recvAtomic(PacketPtr pkt)
When receiving an atomic request, pass it to the crossbar.
Stats::Scalar snoopTraffic
const Cycles snoopResponseLatency
Cycles of snoop response latency.
Tick recvAtomic(PacketPtr pkt, PortID slave_port_id)
Function called by the port when the crossbar is recieving a Atomic transaction.
System * system
Keep a pointer to the system to be allow to querying memory system properties.
Declaration of the coherent crossbar slave port type, one will be instantiated for each of the master...
std::unordered_set< RequestPtr > outstandingSnoop
Store the outstanding requests that we are expecting snoop responses from so we can determine which s...
void sendRetrySnoopResp()
Send a retry to the master port that previously attempted a sendTimingSnoopResp to this slave port an...
Definition: port.cc:271
CoherentXBar & xbar
A reference to the crossbar to which this port belongs.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
virtual bool recvTimingResp(PacketPtr pkt)
When receiving a timing response, pass it to the crossbar.
void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id)
Function called by the port when the crossbar is recieving a functional snoop transaction.
CoherentXBar & xbar
A reference to the crossbar to which this port belongs.
bool recvTimingReq(PacketPtr pkt, PortID slave_port_id)
Function called by the port when the crossbar is recieving a Timing request packet.
CoherentXBarMasterPort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
virtual AddrRangeList getAddrRanges() const
Return the union of all adress ranges seen by this crossbar.
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
Definition: xbar.hh:73
void recvReqRetry()
Provided as necessary.
RespPacketQueue queue
A normal packet queue used to store responses.
uint64_t Tick
Tick count type.
Definition: types.hh:63
A simple distribution stat.
Definition: statistics.hh:2523
void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id)
Function called by the port when the crossbar is recieving a timing snoop request.
virtual bool recvTimingSnoopResp(PacketPtr pkt)
When receiving a timing snoop response, pass it to the crossbar.
CoherentXBar(const CoherentXBarParams *p)
SnoopFilter * snoopFilter
A snoop filter that tracks cache line residency and can restrict the broadcast needed for probes...
bool recvTimingResp(PacketPtr pkt)
Provided as necessary.
void sendRetryResp()
Override the sending of retries and pass them on through the mirrored slave port. ...
bool recvTimingResp(PacketPtr pkt, PortID master_port_id)
Function called by the port when the crossbar is recieving a Timing response packet.
void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id)
Forward a timing packet to our snoopers, potentially excluding one of the connected coherent masters ...
virtual Tick recvAtomicSnoop(PacketPtr pkt)
When receiving an atomic snoop request, pass it to the crossbar.
A coherent crossbar connects a number of (potentially) snooping masters and slaves, and routes the request and response packets based on the address, and also forwards all requests to the snoopers and deals with the snoop responses.
virtual void recvReqRetry()
When reciving a retry from the peer port (at id), pass it to the crossbar.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
QueuedSlavePort & slavePort
The port which we mirror internally.
Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id)
Function called by the port when the crossbar is recieving an atomic snoop transaction.
std::vector< SnoopRespPort * > snoopRespPorts
Stats::Scalar snoops
virtual void recvRangeChange()
When reciving a range change from the peer port (at id), pass it to the crossbar. ...
CoherentXBarSlavePort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id)
Forward a functional packet to our snoopers, potentially excluding one of the connected coherent mast...
std::pair< MemCmd, Tick > forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id)
Forward an atomic packet to our snoopers, potentially excluding one of the connected coherent masters...
virtual bool recvTimingReq(PacketPtr pkt)
When receiving a timing request, pass it to the crossbar.
virtual void regStats()
Register statistics for this object.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:181
virtual void recvTimingSnoopReq(PacketPtr pkt)
When receiving a timing snoop request, pass it to the crossbar.
AddrRangeList getAddrRanges() const
Return the address ranges the crossbar is responsible for.
Definition: xbar.cc:525
const bool pointOfCoherency
Is this crossbar the point of coherency?
virtual void recvFunctional(PacketPtr pkt)
When receiving a functional request, pass it to the crossbar.
bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id)
Function called by the port when the crossbar is recieving a timing snoop response.
This snoop filter keeps track of which connected port has a particular line of data.
Definition: snoop_filter.hh:87
Bitfield< 0 > p
Declaration of an abstract crossbar base class.
virtual void recvRangeChange(PortID master_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition: xbar.cc:364
Declaration of the coherent crossbar master port type, one will be instantiated for each of the slave...
void recvFunctional(PacketPtr pkt, PortID slave_port_id)
Function called by the port when the crossbar is recieving a Functional transaction.
bool sinkPacket(const PacketPtr pkt) const
Determine if the crossbar should sink the packet, as opposed to forwarding it, or responding...
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
std::vector< QueuedSlavePort * > snoopPorts

Generated on Fri Jun 9 2017 13:03:48 for gem5 by doxygen 1.8.6