gem5  v22.1.0.0
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 
56 namespace gem5
57 {
58 
70 class CoherentXBar : public BaseXBar
71 {
72 
73  protected:
74 
82 
89  {
90 
91  private:
92 
95 
98 
99  public:
100 
101  CoherentXBarResponsePort(const std::string &_name,
102  CoherentXBar &_xbar, PortID _id)
103  : QueuedResponsePort(_name, &_xbar, queue, _id), xbar(_xbar),
104  queue(_xbar, *this)
105  { }
106 
107  protected:
108 
109  bool
110  recvTimingReq(PacketPtr pkt) override
111  {
112  return xbar.recvTimingReq(pkt, id);
113  }
114 
115  bool
117  {
118  return xbar.recvTimingSnoopResp(pkt, id);
119  }
120 
121  Tick
122  recvAtomic(PacketPtr pkt) override
123  {
124  return xbar.recvAtomicBackdoor(pkt, id);
125  }
126 
127  Tick
128  recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) override
129  {
130  return xbar.recvAtomicBackdoor(pkt, id, &backdoor);
131  }
132 
133  void
134  recvFunctional(PacketPtr pkt) override
135  {
136  xbar.recvFunctional(pkt, id);
137  }
138 
140  getAddrRanges() const override
141  {
142  return xbar.getAddrRanges();
143  }
144 
145  };
146 
153  {
154  private:
157 
158  public:
159 
160  CoherentXBarRequestPort(const std::string &_name,
161  CoherentXBar &_xbar, PortID _id)
162  : RequestPort(_name, &_xbar, _id), xbar(_xbar)
163  { }
164 
165  protected:
166 
173  bool isSnooping() const override { return true; }
174 
175  bool
176  recvTimingResp(PacketPtr pkt) override
177  {
178  return xbar.recvTimingResp(pkt, id);
179  }
180 
181  void
183  {
184  return xbar.recvTimingSnoopReq(pkt, id);
185  }
186 
187  Tick
189  {
190  return xbar.recvAtomicSnoop(pkt, id);
191  }
192 
193  void
195  {
196  xbar.recvFunctionalSnoop(pkt, id);
197  }
198 
199  void recvRangeChange() override { xbar.recvRangeChange(id); }
200  void recvReqRetry() override { xbar.recvReqRetry(id); }
201 
202  };
203 
209  class SnoopRespPort : public RequestPort
210  {
211 
212  private:
213 
216 
217  public:
218 
223  CoherentXBar& _xbar) :
224  RequestPort(cpu_side_port.name() + ".snoopRespPort", &_xbar),
225  cpuSidePort(cpu_side_port) { }
226 
231  void
232  sendRetryResp() override
233  {
234  // forward it as a snoop response retry
236  }
237 
238  void
239  recvReqRetry() override
240  {
241  panic("SnoopRespPort should never see retry");
242  }
243 
244  bool
245  recvTimingResp(PacketPtr pkt) override
246  {
247  panic("SnoopRespPort should never see timing response");
248  }
249 
250  };
251 
253 
255 
261  std::unordered_set<RequestPtr> outstandingSnoop;
262 
268  std::unordered_map<PacketId, PacketPtr> outstandingCMO;
269 
275 
279 
282 
284  const unsigned int maxOutstandingSnoopCheck;
285 
287  const unsigned int maxRoutingTableSizeCheck;
288 
290  const bool pointOfCoherency;
291 
293  const bool pointOfUnification;
294 
299  std::unique_ptr<Packet> pendingDelete;
300 
301  bool recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id);
302  bool recvTimingResp(PacketPtr pkt, PortID mem_side_port_id);
303  void recvTimingSnoopReq(PacketPtr pkt, PortID mem_side_port_id);
304  bool recvTimingSnoopResp(PacketPtr pkt, PortID cpu_side_port_id);
305  void recvReqRetry(PortID mem_side_port_id);
306 
315  void
316  forwardTiming(PacketPtr pkt, PortID exclude_cpu_side_port_id)
317  {
318  forwardTiming(pkt, exclude_cpu_side_port_id, snoopPorts);
319  }
320 
330  void forwardTiming(PacketPtr pkt, PortID exclude_cpu_side_port_id,
331  const std::vector<QueuedResponsePort*>& dests);
332 
333  Tick recvAtomicBackdoor(PacketPtr pkt, PortID cpu_side_port_id,
334  MemBackdoorPtr *backdoor=nullptr);
335  Tick recvAtomicSnoop(PacketPtr pkt, PortID mem_side_port_id);
336 
348  forwardAtomic(PacketPtr pkt, PortID exclude_cpu_side_port_id)
349  {
350  return forwardAtomic(pkt, exclude_cpu_side_port_id, InvalidPortID,
351  snoopPorts);
352  }
353 
368  PortID exclude_cpu_side_port_id,
369  PortID source_mem_side_port_id,
371  dests);
372 
375  void recvFunctional(PacketPtr pkt, PortID cpu_side_port_id);
376 
379  void recvFunctionalSnoop(PacketPtr pkt, PortID mem_side_port_id);
380 
389  void forwardFunctional(PacketPtr pkt, PortID exclude_cpu_side_port_id);
390 
395  bool sinkPacket(const PacketPtr pkt) const;
396 
401  bool forwardPacket(const PacketPtr pkt);
402 
414  bool
415  isDestination(const PacketPtr pkt) const
416  {
417  return (pkt->req->isToPOC() && pointOfCoherency) ||
418  (pkt->req->isToPOU() && pointOfUnification);
419  }
420 
424 
425  public:
426 
427  virtual void init();
428 
429  CoherentXBar(const CoherentXBarParams &p);
430 
431  virtual ~CoherentXBar();
432 
433  virtual void regStats();
434 };
435 
436 } // namespace gem5
437 
438 #endif //__MEM_COHERENT_XBAR_HH__
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
Definition: xbar.hh:72
virtual void recvRangeChange(PortID mem_side_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition: xbar.cc:364
AddrRangeList getAddrRanges() const
Return the address ranges the crossbar is responsible for.
Definition: xbar.cc:526
Declaration of the coherent crossbar memory-side port type, one will be instantiated for each of the ...
bool isSnooping() const override
Determine if this port should be considered a snooper.
void recvRangeChange() override
Called to receive an address range change from the peer response port.
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
CoherentXBarRequestPort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
CoherentXBar & xbar
A reference to the crossbar to which this port belongs.
Tick recvAtomicSnoop(PacketPtr pkt) override
Receive an atomic snoop request packet from our peer.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
Declaration of the coherent crossbar CPU-side port type, one will be instantiated for each of the mem...
CoherentXBar & xbar
A reference to the crossbar to which this port belongs.
RespPacketQueue queue
A normal packet queue used to store responses.
CoherentXBarResponsePort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
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...
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
Internal class to bridge between an incoming snoop response from a CPU-side port and forwarding it th...
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
SnoopRespPort(QueuedResponsePort &cpu_side_port, CoherentXBar &_xbar)
Create a snoop response port that mirrors a given CPU-side port.
QueuedResponsePort & cpuSidePort
The port which we mirror internally.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
void sendRetryResp() override
Override the sending of retries and pass them on through the mirrored CPU-side port.
A coherent crossbar connects a number of (potentially) snooping requestors and responders,...
std::vector< RespLayer * > respLayers
void recvReqRetry(PortID mem_side_port_id)
bool recvTimingResp(PacketPtr pkt, PortID mem_side_port_id)
bool sinkPacket(const PacketPtr pkt) const
Determine if the crossbar should sink the packet, as opposed to forwarding it, or responding.
std::pair< MemCmd, Tick > forwardAtomic(PacketPtr pkt, PortID exclude_cpu_side_port_id)
Forward an atomic packet to our snoopers, potentially excluding one of the connected coherent request...
std::vector< SnoopRespLayer * > snoopLayers
bool recvTimingSnoopResp(PacketPtr pkt, PortID cpu_side_port_id)
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...
std::vector< SnoopRespPort * > snoopRespPorts
Tick recvAtomicSnoop(PacketPtr pkt, PortID mem_side_port_id)
bool recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
System * system
Keep a pointer to the system to be allow to querying memory system properties.
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests, one for responses, and one for snoop re...
std::vector< QueuedResponsePort * > snoopPorts
std::unordered_set< RequestPtr > outstandingSnoop
Store the outstanding requests that we are expecting snoop responses from so we can determine which s...
void forwardTiming(PacketPtr pkt, PortID exclude_cpu_side_port_id)
Forward a timing packet to our snoopers, potentially excluding one of the connected coherent requesto...
void recvTimingSnoopReq(PacketPtr pkt, PortID mem_side_port_id)
const Cycles snoopResponseLatency
Cycles of snoop response latency.
void recvFunctional(PacketPtr pkt, PortID cpu_side_port_id)
Function called by the port when the crossbar is receiving a Functional transaction.
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
CoherentXBar(const CoherentXBarParams &p)
virtual void regStats()
Callback to set stat parameters.
void forwardFunctional(PacketPtr pkt, PortID exclude_cpu_side_port_id)
Forward a functional packet to our snoopers, potentially excluding one of the connected coherent requ...
statistics::Scalar snoopTraffic
statistics::Scalar snoops
SnoopFilter * snoopFilter
A snoop filter that tracks cache line residency and can restrict the broadcast needed for probes.
bool isDestination(const PacketPtr pkt) const
Determine if the packet's destination is the memory below.
void recvFunctionalSnoop(PacketPtr pkt, PortID mem_side_port_id)
Function called by the port when the crossbar is receiving a functional snoop transaction.
const unsigned int maxOutstandingSnoopCheck
Maximum number of outstading snoops sanity check.
statistics::Distribution snoopFanout
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
bool forwardPacket(const PacketPtr pkt)
Determine if the crossbar should forward the packet, as opposed to responding to it.
const unsigned int maxRoutingTableSizeCheck
Maximum routing table size sanity check.
const bool pointOfCoherency
Is this crossbar the point of coherency?
Tick recvAtomicBackdoor(PacketPtr pkt, PortID cpu_side_port_id, MemBackdoorPtr *backdoor=nullptr)
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:79
const std::string _name
Definition: named.hh:41
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
RequestPtr req
A pointer to the original request.
Definition: packet.hh:376
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:111
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
Definition: qport.hh:62
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:79
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition: port.hh:415
This snoop filter keeps track of which connected port has a particular line of data.
Definition: snoop_filter.hh:90
A simple distribution stat.
Definition: statistics.hh:2085
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
STL pair class.
Definition: stl.hh:58
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
const PortID InvalidPortID
Definition: types.hh:246
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
uint64_t Tick
Tick count type.
Definition: types.hh:58
Definition of a snoop filter.
Declaration of an abstract crossbar base class.

Generated on Wed Dec 21 2022 10:22:37 for gem5 by doxygen 1.9.1