gem5  v20.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 
67 class CoherentXBar : public BaseXBar
68 {
69 
70  protected:
71 
79 
86  {
87 
88  private:
89 
92 
95 
96  public:
97 
98  CoherentXBarResponsePort(const std::string &_name,
99  CoherentXBar &_xbar, PortID _id)
100  : QueuedResponsePort(_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  CoherentXBarRequestPort(const std::string &_name,
158  CoherentXBar &_xbar, PortID _id)
159  : RequestPort(_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 RequestPort
207  {
208 
209  private:
210 
213 
214  public:
215 
220  CoherentXBar& _xbar) :
221  RequestPort(cpu_side_port.name() + ".snoopRespPort", &_xbar),
222  cpuSidePort(cpu_side_port) { }
223 
228  void
229  sendRetryResp() override
230  {
231  // forward it as a snoop response retry
233  }
234 
235  void
236  recvReqRetry() override
237  {
238  panic("SnoopRespPort should never see retry");
239  }
240 
241  bool
242  recvTimingResp(PacketPtr pkt) override
243  {
244  panic("SnoopRespPort should never see timing response");
245  }
246 
247  };
248 
250 
252 
258  std::unordered_set<RequestPtr> outstandingSnoop;
259 
265  std::unordered_map<PacketId, PacketPtr> outstandingCMO;
266 
272 
276 
279 
281  const unsigned int maxOutstandingSnoopCheck;
282 
284  const unsigned int maxRoutingTableSizeCheck;
285 
287  const bool pointOfCoherency;
288 
290  const bool pointOfUnification;
291 
296  std::unique_ptr<Packet> pendingDelete;
297 
298  bool recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id);
299  bool recvTimingResp(PacketPtr pkt, PortID mem_side_port_id);
300  void recvTimingSnoopReq(PacketPtr pkt, PortID mem_side_port_id);
301  bool recvTimingSnoopResp(PacketPtr pkt, PortID cpu_side_port_id);
302  void recvReqRetry(PortID mem_side_port_id);
303 
312  void
313  forwardTiming(PacketPtr pkt, PortID exclude_cpu_side_port_id)
314  {
315  forwardTiming(pkt, exclude_cpu_side_port_id, snoopPorts);
316  }
317 
327  void forwardTiming(PacketPtr pkt, PortID exclude_cpu_side_port_id,
328  const std::vector<QueuedResponsePort*>& dests);
329 
330  Tick recvAtomicBackdoor(PacketPtr pkt, PortID cpu_side_port_id,
331  MemBackdoorPtr *backdoor=nullptr);
332  Tick recvAtomicSnoop(PacketPtr pkt, PortID mem_side_port_id);
333 
345  forwardAtomic(PacketPtr pkt, PortID exclude_cpu_side_port_id)
346  {
347  return forwardAtomic(pkt, exclude_cpu_side_port_id, InvalidPortID,
348  snoopPorts);
349  }
350 
365  PortID exclude_cpu_side_port_id,
366  PortID source_mem_side_port_id,
368  dests);
369 
372  void recvFunctional(PacketPtr pkt, PortID cpu_side_port_id);
373 
376  void recvFunctionalSnoop(PacketPtr pkt, PortID mem_side_port_id);
377 
386  void forwardFunctional(PacketPtr pkt, PortID exclude_cpu_side_port_id);
387 
392  bool sinkPacket(const PacketPtr pkt) const;
393 
398  bool forwardPacket(const PacketPtr pkt);
399 
411  bool
412  isDestination(const PacketPtr pkt) const
413  {
414  return (pkt->req->isToPOC() && pointOfCoherency) ||
415  (pkt->req->isToPOU() && pointOfUnification);
416  }
417 
421 
422  public:
423 
424  virtual void init();
425 
426  CoherentXBar(const CoherentXBarParams *p);
427 
428  virtual ~CoherentXBar();
429 
430  virtual void regStats();
431 };
432 
433 #endif //__MEM_COHERENT_XBAR_HH__
CoherentXBar::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt, PortID mem_side_port_id)
Function called by the port when the crossbar is receiving a functional snoop transaction.
Definition: coherent_xbar.cc:1032
CoherentXBar::CoherentXBarRequestPort::CoherentXBarRequestPort
CoherentXBarRequestPort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
Definition: coherent_xbar.hh:157
CoherentXBar::CoherentXBarRequestPort::recvRangeChange
void recvRangeChange() override
Called to receive an address range change from the peer response port.
Definition: coherent_xbar.hh:196
MemBackdoor
Definition: backdoor.hh:38
CoherentXBar::recvTimingResp
bool recvTimingResp(PacketPtr pkt, PortID mem_side_port_id)
Definition: coherent_xbar.cc:442
CoherentXBar::forwardPacket
bool forwardPacket(const PacketPtr pkt)
Determine if the crossbar should forward the packet, as opposed to responding to it.
Definition: coherent_xbar.cc:1099
xbar.hh
CoherentXBar::CoherentXBarResponsePort::recvTimingReq
bool recvTimingReq(PacketPtr pkt) override
Receive a timing request from the peer.
Definition: coherent_xbar.hh:107
CoherentXBar::recvTimingReq
bool recvTimingReq(PacketPtr pkt, PortID cpu_side_port_id)
Definition: coherent_xbar.cc:144
CoherentXBar::~CoherentXBar
virtual ~CoherentXBar()
Definition: coherent_xbar.cc:106
CoherentXBar::SnoopRespPort::SnoopRespPort
SnoopRespPort(QueuedResponsePort &cpu_side_port, CoherentXBar &_xbar)
Create a snoop response port that mirrors a given CPU-side port.
Definition: coherent_xbar.hh:219
CoherentXBar::snoopFanout
Stats::Distribution snoopFanout
Definition: coherent_xbar.hh:420
InvalidPortID
const PortID InvalidPortID
Definition: types.hh:238
CoherentXBar::CoherentXBarRequestPort::isSnooping
bool isSnooping() const override
Determine if this port should be considered a snooper.
Definition: coherent_xbar.hh:170
CoherentXBar::pointOfUnification
const bool pointOfUnification
Is this crossbar the point of unification?
Definition: coherent_xbar.hh:290
CoherentXBar::CoherentXBarResponsePort::recvAtomicBackdoor
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...
Definition: coherent_xbar.hh:125
CoherentXBar::system
System * system
Keep a pointer to the system to be allow to querying memory system properties.
Definition: coherent_xbar.hh:271
CoherentXBar::CoherentXBarResponsePort::CoherentXBarResponsePort
CoherentXBarResponsePort(const std::string &_name, CoherentXBar &_xbar, PortID _id)
Definition: coherent_xbar.hh:98
CoherentXBar::snoops
Stats::Scalar snoops
Definition: coherent_xbar.hh:418
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
CoherentXBar::SnoopRespPort
Internal class to bridge between an incoming snoop response from a CPU-side port and forwarding it th...
Definition: coherent_xbar.hh:206
PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:237
CoherentXBar::CoherentXBarRequestPort::recvReqRetry
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: coherent_xbar.hh:197
Packet::req
RequestPtr req
A pointer to the original request.
Definition: packet.hh:340
CoherentXBar::sinkPacket
bool sinkPacket(const PacketPtr pkt) const
Determine if the crossbar should sink the packet, as opposed to forwarding it, or responding.
Definition: coherent_xbar.cc:1075
std::vector< ReqLayer * >
CoherentXBar::CoherentXBarResponsePort::recvTimingSnoopResp
bool recvTimingSnoopResp(PacketPtr pkt) override
Receive a timing snoop response from the peer.
Definition: coherent_xbar.hh:113
BaseXBar::getAddrRanges
AddrRangeList getAddrRanges() const
Return the address ranges the crossbar is responsible for.
Definition: xbar.cc:522
CoherentXBar::CoherentXBarRequestPort::recvFunctionalSnoop
void recvFunctionalSnoop(PacketPtr pkt) override
Receive a functional snoop request packet from the peer.
Definition: coherent_xbar.hh:191
CoherentXBar::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt, PortID mem_side_port_id)
Definition: coherent_xbar.cc:884
Stats::Scalar
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2533
CoherentXBar::recvReqRetry
void recvReqRetry(PortID mem_side_port_id)
Definition: coherent_xbar.cc:723
CoherentXBar::respLayers
std::vector< RespLayer * > respLayers
Definition: coherent_xbar.hh:77
CoherentXBar::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt, PortID mem_side_port_id)
Definition: coherent_xbar.cc:505
CoherentXBar::recvFunctional
void recvFunctional(PacketPtr pkt, PortID cpu_side_port_id)
Function called by the port when the crossbar is receiving a Functional transaction.
Definition: coherent_xbar.cc:996
System
Definition: system.hh:73
CoherentXBar::pendingDelete
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
Definition: coherent_xbar.hh:296
CoherentXBar::CoherentXBar
CoherentXBar(const CoherentXBarParams *p)
Definition: coherent_xbar.cc:54
CoherentXBar::CoherentXBarRequestPort
Declaration of the coherent crossbar memory-side port type, one will be instantiated for each of the ...
Definition: coherent_xbar.hh:149
CoherentXBar::snoopLayers
std::vector< SnoopRespLayer * > snoopLayers
Definition: coherent_xbar.hh:78
CoherentXBar::init
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
Definition: coherent_xbar.cc:119
CoherentXBar::outstandingCMO
std::unordered_map< PacketId, PacketPtr > outstandingCMO
Store the outstanding cache maintenance that we are expecting snoop responses from so we can determin...
Definition: coherent_xbar.hh:265
CoherentXBar::CoherentXBarRequestPort::xbar
CoherentXBar & xbar
A reference to the crossbar to which this port belongs.
Definition: coherent_xbar.hh:153
CoherentXBar::CoherentXBarResponsePort::queue
RespPacketQueue queue
A normal packet queue used to store responses.
Definition: coherent_xbar.hh:94
QueuedResponsePort
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
Definition: qport.hh:58
CoherentXBar::CoherentXBarRequestPort::recvAtomicSnoop
Tick recvAtomicSnoop(PacketPtr pkt) override
Receive an atomic snoop request packet from our peer.
Definition: coherent_xbar.hh:185
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
std::pair
STL pair class.
Definition: stl.hh:58
CoherentXBar::reqLayers
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests, one for responses, and one for snoop re...
Definition: coherent_xbar.hh:76
CoherentXBar::SnoopRespPort::recvReqRetry
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
Definition: coherent_xbar.hh:236
Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
Stats::Distribution
A simple distribution stat.
Definition: statistics.hh:2617
CoherentXBar::pointOfCoherency
const bool pointOfCoherency
Is this crossbar the point of coherency?
Definition: coherent_xbar.hh:287
RespPacketQueue
Definition: packet_queue.hh:296
CoherentXBar::CoherentXBarResponsePort::recvFunctional
void recvFunctional(PacketPtr pkt) override
Receive a functional request packet from the peer.
Definition: coherent_xbar.hh:131
CoherentXBar::snoopFilter
SnoopFilter * snoopFilter
A snoop filter that tracks cache line residency and can restrict the broadcast needed for probes.
Definition: coherent_xbar.hh:275
CoherentXBar::recvTimingSnoopResp
bool recvTimingSnoopResp(PacketPtr pkt, PortID cpu_side_port_id)
Definition: coherent_xbar.cc:565
CoherentXBar::regStats
virtual void regStats()
Callback to set stat parameters.
Definition: coherent_xbar.cc:1114
CoherentXBar::SnoopRespPort::cpuSidePort
QueuedResponsePort & cpuSidePort
The port which we mirror internally.
Definition: coherent_xbar.hh:212
CoherentXBar::recvAtomicBackdoor
Tick recvAtomicBackdoor(PacketPtr pkt, PortID cpu_side_port_id, MemBackdoorPtr *backdoor=nullptr)
Definition: coherent_xbar.cc:732
CoherentXBar::forwardTiming
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...
Definition: coherent_xbar.hh:313
CoherentXBar::maxOutstandingSnoopCheck
const unsigned int maxOutstandingSnoopCheck
Maximum number of outstading snoops sanity check.
Definition: coherent_xbar.hh:281
SnoopFilter
This snoop filter keeps track of which connected port has a particular line of data.
Definition: snoop_filter.hh:86
CoherentXBar::CoherentXBarResponsePort::getAddrRanges
AddrRangeList getAddrRanges() const override
Get a list of the non-overlapping address ranges the owner is responsible for.
Definition: coherent_xbar.hh:137
CoherentXBar::snoopRespPorts
std::vector< SnoopRespPort * > snoopRespPorts
Definition: coherent_xbar.hh:249
BaseXBar::recvRangeChange
virtual void recvRangeChange(PortID mem_side_port_id)
Function called by the port when the crossbar is recieving a range change.
Definition: xbar.cc:360
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
CoherentXBar::maxRoutingTableSizeCheck
const unsigned int maxRoutingTableSizeCheck
Maximum routing table size sanity check.
Definition: coherent_xbar.hh:284
CoherentXBar::isDestination
bool isDestination(const PacketPtr pkt) const
Determine if the packet's destination is the memory below.
Definition: coherent_xbar.hh:412
CoherentXBar::CoherentXBarRequestPort::recvTimingResp
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
Definition: coherent_xbar.hh:173
CoherentXBar::snoopResponseLatency
const Cycles snoopResponseLatency
Cycles of snoop response latency.
Definition: coherent_xbar.hh:278
ResponsePort::sendRetrySnoopResp
void sendRetrySnoopResp()
Send a retry to the request port that previously attempted a sendTimingSnoopResp to this response por...
Definition: port.hh:412
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
CoherentXBar::CoherentXBarResponsePort::xbar
CoherentXBar & xbar
A reference to the crossbar to which this port belongs.
Definition: coherent_xbar.hh:91
CoherentXBar::SnoopRespPort::recvTimingResp
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
Definition: coherent_xbar.hh:242
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< AddrRange >
snoop_filter.hh
CoherentXBar::snoopPorts
std::vector< QueuedResponsePort * > snoopPorts
Definition: coherent_xbar.hh:251
BaseXBar
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
Definition: xbar.hh:68
CoherentXBar
A coherent crossbar connects a number of (potentially) snooping requestors and responders,...
Definition: coherent_xbar.hh:67
CoherentXBar::outstandingSnoop
std::unordered_set< RequestPtr > outstandingSnoop
Store the outstanding requests that we are expecting snoop responses from so we can determine which s...
Definition: coherent_xbar.hh:258
CoherentXBar::SnoopRespPort::sendRetryResp
void sendRetryResp() override
Override the sending of retries and pass them on through the mirrored CPU-side port.
Definition: coherent_xbar.hh:229
CoherentXBar::CoherentXBarResponsePort::recvAtomic
Tick recvAtomic(PacketPtr pkt) override
Receive an atomic request packet from the peer.
Definition: coherent_xbar.hh:119
CoherentXBar::forwardAtomic
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...
Definition: coherent_xbar.hh:345
CoherentXBar::snoopTraffic
Stats::Scalar snoopTraffic
Definition: coherent_xbar.hh:419
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
CoherentXBar::CoherentXBarRequestPort::recvTimingSnoopReq
void recvTimingSnoopReq(PacketPtr pkt) override
Receive a timing snoop request from the peer.
Definition: coherent_xbar.hh:179
CoherentXBar::CoherentXBarResponsePort
Declaration of the coherent crossbar CPU-side port type, one will be instantiated for each of the mem...
Definition: coherent_xbar.hh:85
CoherentXBar::forwardFunctional
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...
Definition: coherent_xbar.cc:1053

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17