gem5  v20.0.0.3
coherent_xbar.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2015, 2017, 2019 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 
46 #ifndef __MEM_COHERENT_XBAR_HH__
47 #define __MEM_COHERENT_XBAR_HH__
48 
49 #include <unordered_map>
50 #include <unordered_set>
51 
52 #include "mem/snoop_filter.hh"
53 #include "mem/xbar.hh"
54 #include "params/CoherentXBar.hh"
55 
67 class CoherentXBar : public BaseXBar
68 {
69 
70  protected:
71 
79 
86  {
87 
88  private:
89 
92 
95 
96  public:
97 
98  CoherentXBarSlavePort(const std::string &_name,
99  CoherentXBar &_xbar, PortID _id)
100  : QueuedSlavePort(_name, &_xbar, queue, _id), xbar(_xbar),
101  queue(_xbar, *this)
102  { }
103 
104  protected:
105 
106  bool
107  recvTimingReq(PacketPtr pkt) override
108  {
109  return xbar.recvTimingReq(pkt, id);
110  }
111 
112  bool
114  {
115  return xbar.recvTimingSnoopResp(pkt, id);
116  }
117 
118  Tick
119  recvAtomic(PacketPtr pkt) override
120  {
121  return xbar.recvAtomicBackdoor(pkt, id);
122  }
123 
124  Tick
125  recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
126  {
127  return xbar.recvAtomicBackdoor(pkt, id, &backdoor);
128  }
129 
130  void
131  recvFunctional(PacketPtr pkt) override
132  {
133  xbar.recvFunctional(pkt, id);
134  }
135 
137  getAddrRanges() const override
138  {
139  return xbar.getAddrRanges();
140  }
141 
142  };
143 
150  {
151  private:
154 
155  public:
156 
157  CoherentXBarMasterPort(const std::string &_name,
158  CoherentXBar &_xbar, PortID _id)
159  : MasterPort(_name, &_xbar, _id), xbar(_xbar)
160  { }
161 
162  protected:
163 
170  bool isSnooping() const override { return true; }
171 
172  bool
173  recvTimingResp(PacketPtr pkt) override
174  {
175  return xbar.recvTimingResp(pkt, id);
176  }
177 
178  void
180  {
181  return xbar.recvTimingSnoopReq(pkt, id);
182  }
183 
184  Tick
186  {
187  return xbar.recvAtomicSnoop(pkt, id);
188  }
189 
190  void
192  {
193  xbar.recvFunctionalSnoop(pkt, id);
194  }
195 
196  void recvRangeChange() override { xbar.recvRangeChange(id); }
197  void recvReqRetry() override { xbar.recvReqRetry(id); }
198 
199  };
200 
206  class SnoopRespPort : public MasterPort
207  {
208 
209  private:
210 
213 
214  public:
215 
220  MasterPort(slave_port.name() + ".snoopRespPort", &_xbar),
221  slavePort(slave_port) { }
222 
227  void
228  sendRetryResp() override
229  {
230  // forward it as a snoop response retry
231  slavePort.sendRetrySnoopResp();
232  }
233 
234  void
235  recvReqRetry() override
236  {
237  panic("SnoopRespPort should never see retry");
238  }
239 
240  bool
241  recvTimingResp(PacketPtr pkt) override
242  {
243  panic("SnoopRespPort should never see timing response");
244  }
245 
246  };
247 
249 
251 
257  std::unordered_set<RequestPtr> outstandingSnoop;
258 
264  std::unordered_map<PacketId, PacketPtr> outstandingCMO;
265 
271 
275 
278 
280  const unsigned int maxOutstandingSnoopCheck;
281 
283  const unsigned int maxRoutingTableSizeCheck;
284 
286  const bool pointOfCoherency;
287 
289  const bool pointOfUnification;
290 
295  std::unique_ptr<Packet> pendingDelete;
296 
297  bool recvTimingReq(PacketPtr pkt, PortID slave_port_id);
298  bool recvTimingResp(PacketPtr pkt, PortID master_port_id);
299  void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id);
300  bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id);
301  void recvReqRetry(PortID master_port_id);
302 
311  void
312  forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id)
313  {
314  forwardTiming(pkt, exclude_slave_port_id, snoopPorts);
315  }
316 
326  void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
327  const std::vector<QueuedSlavePort*>& dests);
328 
329  Tick recvAtomicBackdoor(PacketPtr pkt, PortID slave_port_id,
330  MemBackdoorPtr *backdoor=nullptr);
331  Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id);
332 
344  forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id)
345  {
346  return forwardAtomic(pkt, exclude_slave_port_id, InvalidPortID,
347  snoopPorts);
348  }
349 
363  PortID exclude_slave_port_id,
364  PortID source_master_port_id,
366  dests);
367 
370  void recvFunctional(PacketPtr pkt, PortID slave_port_id);
371 
374  void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id);
375 
384  void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id);
385 
390  bool sinkPacket(const PacketPtr pkt) const;
391 
396  bool forwardPacket(const PacketPtr pkt);
397 
409  bool
410  isDestination(const PacketPtr pkt) const
411  {
412  return (pkt->req->isToPOC() && pointOfCoherency) ||
413  (pkt->req->isToPOU() && pointOfUnification);
414  }
415 
419 
420  public:
421 
422  virtual void init();
423 
424  CoherentXBar(const CoherentXBarParams *p);
425 
426  virtual ~CoherentXBar();
427 
428  virtual void regStats();
429 };
430 
431 #endif //__MEM_COHERENT_XBAR_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:71
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
virtual ~CoherentXBar()
std::vector< SnoopRespLayer * > snoopLayers
SnoopRespPort(QueuedSlavePort &slave_port, CoherentXBar &_xbar)
Create a snoop response port that mirrors a given slave port.
bool isSnooping() const override
Determine if this port should be considered a snooper.
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:81
std::vector< RespLayer * > respLayers
const PortID InvalidPortID
Definition: types.hh:236
STL pair class.
Definition: stl.hh:58
Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
Receive an atomic request packet from the peer, and optionally provide a backdoor to the data being a...
const unsigned int maxOutstandingSnoopCheck
Maximum number of outstading snoops sanity check.
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)
Stats::Distribution snoopFanout
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Internal class to bridge between an incoming snoop response from a slave port and forwarding it throu...
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition: system.hh:72
AddrRangeList getAddrRanges() const
Return the address ranges the crossbar is responsible for.
Definition: xbar.cc:518
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:58
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests, one for responses, and one for snoop re...
Stats::Scalar snoopTraffic
const Cycles snoopResponseLatency
Cycles of snoop response latency.
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.hh:386
CoherentXBar & xbar
A reference to the crossbar to which this port belongs.
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2505
bool sinkPacket(const PacketPtr pkt) const
Determine if the crossbar should sink the packet, as opposed to forwarding it, or responding...
STL vector class.
Definition: stl.hh:37
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)
CoherentXBarMasterPort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
Definition: xbar.hh:68
RequestPtr req
A pointer to the original request.
Definition: packet.hh:321
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
RespPacketQueue queue
A normal packet queue used to store responses.
uint64_t Tick
Tick count type.
Definition: types.hh:61
void recvRangeChange() override
Called to receive an address range change from the peer slave port.
bool isDestination(const PacketPtr pkt) const
Determine if the packet&#39;s destination is the memory below.
A simple distribution stat.
Definition: statistics.hh:2589
void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id)
const unsigned int maxRoutingTableSizeCheck
Maximum routing table size sanity check.
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
CoherentXBar(const CoherentXBarParams *p)
SnoopFilter * snoopFilter
A snoop filter that tracks cache line residency and can restrict the broadcast needed for probes...
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
bool recvTimingResp(PacketPtr pkt, PortID master_port_id)
void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id)
Forward a timing packet to our snoopers, potentially excluding one of the connected coherent masters ...
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.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:249
QueuedSlavePort & slavePort
The port which we mirror internally.
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id)
std::vector< SnoopRespPort * > snoopRespPorts
Stats::Scalar snoops
void sendRetryResp() override
Override the sending of retries and pass them on through the mirrored slave port. ...
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
CoherentXBarSlavePort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:102
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...
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
virtual void regStats()
Callback to set stat parameters.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:235
bool forwardPacket(const PacketPtr pkt)
Determine if the crossbar should forward the packet, as opposed to responding to it.
const bool pointOfCoherency
Is this crossbar the point of coherency?
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id)
This snoop filter keeps track of which connected port has a particular line of data.
Definition: snoop_filter.hh:86
Bitfield< 0 > p
const bool pointOfUnification
Is this crossbar the point of unification?
std::unordered_map< PacketId, PacketPtr > outstandingCMO
Store the outstanding cache maintenance that we are expecting snoop responses from so we can determin...
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:358
Declaration of the coherent crossbar master port type, one will be instantiated for each of the slave...
Tick recvAtomicBackdoor(PacketPtr pkt, PortID slave_port_id, MemBackdoorPtr *backdoor=nullptr)
void recvFunctional(PacketPtr pkt, PortID slave_port_id)
Function called by the port when the crossbar is recieving a Functional transaction.
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Tick recvAtomicSnoop(PacketPtr pkt) override
Receive an atomic snoop request packet from our peer.
std::vector< QueuedSlavePort * > snoopPorts

Generated on Fri Jul 3 2020 15:53:03 for gem5 by doxygen 1.8.13