coherent_xbar.cc (12345:70c783a93195) coherent_xbar.cc (12346:9b1144d046ca)
1/*
2 * Copyright (c) 2011-2017 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) 2006 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: Ali Saidi
41 * Andreas Hansson
42 * William Wang
43 */
44
45/**
46 * @file
47 * Definition of a crossbar object.
48 */
49
50#include "mem/coherent_xbar.hh"
51
52#include "base/logging.hh"
53#include "base/trace.hh"
54#include "debug/AddrRanges.hh"
55#include "debug/CoherentXBar.hh"
56#include "sim/system.hh"
57
58CoherentXBar::CoherentXBar(const CoherentXBarParams *p)
59 : BaseXBar(p), system(p->system), snoopFilter(p->snoop_filter),
60 snoopResponseLatency(p->snoop_response_latency),
61 pointOfCoherency(p->point_of_coherency),
62 pointOfUnification(p->point_of_unification)
63{
64 // create the ports based on the size of the master and slave
65 // vector ports, and the presence of the default port, the ports
66 // are enumerated starting from zero
67 for (int i = 0; i < p->port_master_connection_count; ++i) {
68 std::string portName = csprintf("%s.master[%d]", name(), i);
69 MasterPort* bp = new CoherentXBarMasterPort(portName, *this, i);
70 masterPorts.push_back(bp);
71 reqLayers.push_back(new ReqLayer(*bp, *this,
72 csprintf(".reqLayer%d", i)));
73 snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
74 csprintf(".snoopLayer%d", i)));
75 }
76
77 // see if we have a default slave device connected and if so add
78 // our corresponding master port
79 if (p->port_default_connection_count) {
80 defaultPortID = masterPorts.size();
81 std::string portName = name() + ".default";
82 MasterPort* bp = new CoherentXBarMasterPort(portName, *this,
83 defaultPortID);
84 masterPorts.push_back(bp);
85 reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d",
86 defaultPortID)));
87 snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
88 csprintf(".snoopLayer%d",
89 defaultPortID)));
90 }
91
92 // create the slave ports, once again starting at zero
93 for (int i = 0; i < p->port_slave_connection_count; ++i) {
94 std::string portName = csprintf("%s.slave[%d]", name(), i);
95 QueuedSlavePort* bp = new CoherentXBarSlavePort(portName, *this, i);
96 slavePorts.push_back(bp);
97 respLayers.push_back(new RespLayer(*bp, *this,
98 csprintf(".respLayer%d", i)));
99 snoopRespPorts.push_back(new SnoopRespPort(*bp, *this));
100 }
101
102 clearPortCache();
103}
104
105CoherentXBar::~CoherentXBar()
106{
107 for (auto l: reqLayers)
108 delete l;
109 for (auto l: respLayers)
110 delete l;
111 for (auto l: snoopLayers)
112 delete l;
113 for (auto p: snoopRespPorts)
114 delete p;
115}
116
117void
118CoherentXBar::init()
119{
120 BaseXBar::init();
121
122 // iterate over our slave ports and determine which of our
123 // neighbouring master ports are snooping and add them as snoopers
124 for (const auto& p: slavePorts) {
125 // check if the connected master port is snooping
126 if (p->isSnooping()) {
127 DPRINTF(AddrRanges, "Adding snooping master %s\n",
128 p->getMasterPort().name());
129 snoopPorts.push_back(p);
130 }
131 }
132
133 if (snoopPorts.empty())
134 warn("CoherentXBar %s has no snooping ports attached!\n", name());
135
136 // inform the snoop filter about the slave ports so it can create
137 // its own internal representation
138 if (snoopFilter)
139 snoopFilter->setSlavePorts(slavePorts);
140}
141
142bool
143CoherentXBar::recvTimingReq(PacketPtr pkt, PortID slave_port_id)
144{
145 // determine the source port based on the id
146 SlavePort *src_port = slavePorts[slave_port_id];
147
148 // remember if the packet is an express snoop
149 bool is_express_snoop = pkt->isExpressSnoop();
150 bool cache_responding = pkt->cacheResponding();
151 // for normal requests, going downstream, the express snoop flag
152 // and the cache responding flag should always be the same
153 assert(is_express_snoop == cache_responding);
154
155 // determine the destination based on the address
156 PortID master_port_id = findPort(pkt->getAddr());
157
158 // test if the crossbar should be considered occupied for the current
159 // port, and exclude express snoops from the check
160 if (!is_express_snoop && !reqLayers[master_port_id]->tryTiming(src_port)) {
161 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
162 src_port->name(), pkt->print());
163 return false;
164 }
165
166 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
167 src_port->name(), pkt->print());
168
169 // store size and command as they might be modified when
170 // forwarding the packet
171 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
172 unsigned int pkt_cmd = pkt->cmdToIndex();
173
174 // store the old header delay so we can restore it if needed
175 Tick old_header_delay = pkt->headerDelay;
176
177 // a request sees the frontend and forward latency
178 Tick xbar_delay = (frontendLatency + forwardLatency) * clockPeriod();
179
180 // set the packet header and payload delay
181 calcPacketTiming(pkt, xbar_delay);
182
183 // determine how long to be crossbar layer is busy
184 Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
185
1/*
2 * Copyright (c) 2011-2017 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) 2006 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: Ali Saidi
41 * Andreas Hansson
42 * William Wang
43 */
44
45/**
46 * @file
47 * Definition of a crossbar object.
48 */
49
50#include "mem/coherent_xbar.hh"
51
52#include "base/logging.hh"
53#include "base/trace.hh"
54#include "debug/AddrRanges.hh"
55#include "debug/CoherentXBar.hh"
56#include "sim/system.hh"
57
58CoherentXBar::CoherentXBar(const CoherentXBarParams *p)
59 : BaseXBar(p), system(p->system), snoopFilter(p->snoop_filter),
60 snoopResponseLatency(p->snoop_response_latency),
61 pointOfCoherency(p->point_of_coherency),
62 pointOfUnification(p->point_of_unification)
63{
64 // create the ports based on the size of the master and slave
65 // vector ports, and the presence of the default port, the ports
66 // are enumerated starting from zero
67 for (int i = 0; i < p->port_master_connection_count; ++i) {
68 std::string portName = csprintf("%s.master[%d]", name(), i);
69 MasterPort* bp = new CoherentXBarMasterPort(portName, *this, i);
70 masterPorts.push_back(bp);
71 reqLayers.push_back(new ReqLayer(*bp, *this,
72 csprintf(".reqLayer%d", i)));
73 snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
74 csprintf(".snoopLayer%d", i)));
75 }
76
77 // see if we have a default slave device connected and if so add
78 // our corresponding master port
79 if (p->port_default_connection_count) {
80 defaultPortID = masterPorts.size();
81 std::string portName = name() + ".default";
82 MasterPort* bp = new CoherentXBarMasterPort(portName, *this,
83 defaultPortID);
84 masterPorts.push_back(bp);
85 reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d",
86 defaultPortID)));
87 snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
88 csprintf(".snoopLayer%d",
89 defaultPortID)));
90 }
91
92 // create the slave ports, once again starting at zero
93 for (int i = 0; i < p->port_slave_connection_count; ++i) {
94 std::string portName = csprintf("%s.slave[%d]", name(), i);
95 QueuedSlavePort* bp = new CoherentXBarSlavePort(portName, *this, i);
96 slavePorts.push_back(bp);
97 respLayers.push_back(new RespLayer(*bp, *this,
98 csprintf(".respLayer%d", i)));
99 snoopRespPorts.push_back(new SnoopRespPort(*bp, *this));
100 }
101
102 clearPortCache();
103}
104
105CoherentXBar::~CoherentXBar()
106{
107 for (auto l: reqLayers)
108 delete l;
109 for (auto l: respLayers)
110 delete l;
111 for (auto l: snoopLayers)
112 delete l;
113 for (auto p: snoopRespPorts)
114 delete p;
115}
116
117void
118CoherentXBar::init()
119{
120 BaseXBar::init();
121
122 // iterate over our slave ports and determine which of our
123 // neighbouring master ports are snooping and add them as snoopers
124 for (const auto& p: slavePorts) {
125 // check if the connected master port is snooping
126 if (p->isSnooping()) {
127 DPRINTF(AddrRanges, "Adding snooping master %s\n",
128 p->getMasterPort().name());
129 snoopPorts.push_back(p);
130 }
131 }
132
133 if (snoopPorts.empty())
134 warn("CoherentXBar %s has no snooping ports attached!\n", name());
135
136 // inform the snoop filter about the slave ports so it can create
137 // its own internal representation
138 if (snoopFilter)
139 snoopFilter->setSlavePorts(slavePorts);
140}
141
142bool
143CoherentXBar::recvTimingReq(PacketPtr pkt, PortID slave_port_id)
144{
145 // determine the source port based on the id
146 SlavePort *src_port = slavePorts[slave_port_id];
147
148 // remember if the packet is an express snoop
149 bool is_express_snoop = pkt->isExpressSnoop();
150 bool cache_responding = pkt->cacheResponding();
151 // for normal requests, going downstream, the express snoop flag
152 // and the cache responding flag should always be the same
153 assert(is_express_snoop == cache_responding);
154
155 // determine the destination based on the address
156 PortID master_port_id = findPort(pkt->getAddr());
157
158 // test if the crossbar should be considered occupied for the current
159 // port, and exclude express snoops from the check
160 if (!is_express_snoop && !reqLayers[master_port_id]->tryTiming(src_port)) {
161 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
162 src_port->name(), pkt->print());
163 return false;
164 }
165
166 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
167 src_port->name(), pkt->print());
168
169 // store size and command as they might be modified when
170 // forwarding the packet
171 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
172 unsigned int pkt_cmd = pkt->cmdToIndex();
173
174 // store the old header delay so we can restore it if needed
175 Tick old_header_delay = pkt->headerDelay;
176
177 // a request sees the frontend and forward latency
178 Tick xbar_delay = (frontendLatency + forwardLatency) * clockPeriod();
179
180 // set the packet header and payload delay
181 calcPacketTiming(pkt, xbar_delay);
182
183 // determine how long to be crossbar layer is busy
184 Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
185
186 // is this the destination point for this packet? (e.g. true if
187 // this xbar is the PoC for a cache maintenance operation to the
188 // PoC) otherwise the destination is any cache that can satisfy
189 // the request
190 const bool is_destination = isDestination(pkt);
191
186 const bool snoop_caches = !system->bypassCaches() &&
187 pkt->cmd != MemCmd::WriteClean;
188 if (snoop_caches) {
189 assert(pkt->snoopDelay == 0);
190
191 // the packet is a memory-mapped request and should be
192 // broadcasted to our snoopers but the source
193 if (snoopFilter) {
194 // check with the snoop filter where to forward this packet
195 auto sf_res = snoopFilter->lookupRequest(pkt, *src_port);
196 // the time required by a packet to be delivered through
197 // the xbar has to be charged also with to lookup latency
198 // of the snoop filter
199 pkt->headerDelay += sf_res.second * clockPeriod();
200 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
201 __func__, src_port->name(), pkt->print(),
202 sf_res.first.size(), sf_res.second);
203
204 if (pkt->isEviction()) {
205 // for block-evicting packets, i.e. writebacks and
206 // clean evictions, there is no need to snoop up, as
207 // all we do is determine if the block is cached or
208 // not, instead just set it here based on the snoop
209 // filter result
210 if (!sf_res.first.empty())
211 pkt->setBlockCached();
212 } else {
213 forwardTiming(pkt, slave_port_id, sf_res.first);
214 }
215 } else {
216 forwardTiming(pkt, slave_port_id);
217 }
218
219 // add the snoop delay to our header delay, and then reset it
220 pkt->headerDelay += pkt->snoopDelay;
221 pkt->snoopDelay = 0;
222 }
223
224 // set up a sensible starting point
225 bool success = true;
226
227 // remember if the packet will generate a snoop response by
228 // checking if a cache set the cacheResponding flag during the
229 // snooping above
230 const bool expect_snoop_resp = !cache_responding && pkt->cacheResponding();
231 bool expect_response = pkt->needsResponse() && !pkt->cacheResponding();
232
233 const bool sink_packet = sinkPacket(pkt);
234
235 // in certain cases the crossbar is responsible for responding
236 bool respond_directly = false;
237 // store the original address as an address mapper could possibly
238 // modify the address upon a sendTimingRequest
239 const Addr addr(pkt->getAddr());
240 if (sink_packet) {
241 DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
242 pkt->print());
243 } else {
244 // determine if we are forwarding the packet, or responding to
245 // it
192 const bool snoop_caches = !system->bypassCaches() &&
193 pkt->cmd != MemCmd::WriteClean;
194 if (snoop_caches) {
195 assert(pkt->snoopDelay == 0);
196
197 // the packet is a memory-mapped request and should be
198 // broadcasted to our snoopers but the source
199 if (snoopFilter) {
200 // check with the snoop filter where to forward this packet
201 auto sf_res = snoopFilter->lookupRequest(pkt, *src_port);
202 // the time required by a packet to be delivered through
203 // the xbar has to be charged also with to lookup latency
204 // of the snoop filter
205 pkt->headerDelay += sf_res.second * clockPeriod();
206 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
207 __func__, src_port->name(), pkt->print(),
208 sf_res.first.size(), sf_res.second);
209
210 if (pkt->isEviction()) {
211 // for block-evicting packets, i.e. writebacks and
212 // clean evictions, there is no need to snoop up, as
213 // all we do is determine if the block is cached or
214 // not, instead just set it here based on the snoop
215 // filter result
216 if (!sf_res.first.empty())
217 pkt->setBlockCached();
218 } else {
219 forwardTiming(pkt, slave_port_id, sf_res.first);
220 }
221 } else {
222 forwardTiming(pkt, slave_port_id);
223 }
224
225 // add the snoop delay to our header delay, and then reset it
226 pkt->headerDelay += pkt->snoopDelay;
227 pkt->snoopDelay = 0;
228 }
229
230 // set up a sensible starting point
231 bool success = true;
232
233 // remember if the packet will generate a snoop response by
234 // checking if a cache set the cacheResponding flag during the
235 // snooping above
236 const bool expect_snoop_resp = !cache_responding && pkt->cacheResponding();
237 bool expect_response = pkt->needsResponse() && !pkt->cacheResponding();
238
239 const bool sink_packet = sinkPacket(pkt);
240
241 // in certain cases the crossbar is responsible for responding
242 bool respond_directly = false;
243 // store the original address as an address mapper could possibly
244 // modify the address upon a sendTimingRequest
245 const Addr addr(pkt->getAddr());
246 if (sink_packet) {
247 DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
248 pkt->print());
249 } else {
250 // determine if we are forwarding the packet, or responding to
251 // it
246 if (!pointOfCoherency || pkt->isRead() || pkt->isWrite()) {
252 if (forwardPacket(pkt)) {
247 // if we are passing on, rather than sinking, a packet to
248 // which an upstream cache has committed to responding,
249 // the line was needs writable, and the responding only
250 // had an Owned copy, so we need to immidiately let the
251 // downstream caches know, bypass any flow control
252 if (pkt->cacheResponding()) {
253 pkt->setExpressSnoop();
254 }
255
253 // if we are passing on, rather than sinking, a packet to
254 // which an upstream cache has committed to responding,
255 // the line was needs writable, and the responding only
256 // had an Owned copy, so we need to immidiately let the
257 // downstream caches know, bypass any flow control
258 if (pkt->cacheResponding()) {
259 pkt->setExpressSnoop();
260 }
261
262 // make sure that the write request (e.g., WriteClean)
263 // will stop at the memory below if this crossbar is its
264 // destination
265 if (pkt->isWrite() && is_destination) {
266 pkt->clearWriteThrough();
267 }
268
256 // since it is a normal request, attempt to send the packet
257 success = masterPorts[master_port_id]->sendTimingReq(pkt);
258 } else {
259 // no need to forward, turn this packet around and respond
260 // directly
261 assert(pkt->needsResponse());
262
263 respond_directly = true;
264 assert(!expect_snoop_resp);
265 expect_response = false;
266 }
267 }
268
269 if (snoopFilter && snoop_caches) {
270 // Let the snoop filter know about the success of the send operation
271 snoopFilter->finishRequest(!success, addr, pkt->isSecure());
272 }
273
274 // check if we were successful in sending the packet onwards
275 if (!success) {
276 // express snoops should never be forced to retry
277 assert(!is_express_snoop);
278
279 // restore the header delay
280 pkt->headerDelay = old_header_delay;
281
282 DPRINTF(CoherentXBar, "%s: src %s packet %s RETRY\n", __func__,
283 src_port->name(), pkt->print());
284
285 // update the layer state and schedule an idle event
286 reqLayers[master_port_id]->failedTiming(src_port,
287 clockEdge(Cycles(1)));
288 } else {
289 // express snoops currently bypass the crossbar state entirely
290 if (!is_express_snoop) {
291 // if this particular request will generate a snoop
292 // response
293 if (expect_snoop_resp) {
294 // we should never have an exsiting request outstanding
295 assert(outstandingSnoop.find(pkt->req) ==
296 outstandingSnoop.end());
297 outstandingSnoop.insert(pkt->req);
298
299 // basic sanity check on the outstanding snoops
300 panic_if(outstandingSnoop.size() > 512,
301 "Outstanding snoop requests exceeded 512\n");
302 }
303
304 // remember where to route the normal response to
305 if (expect_response || expect_snoop_resp) {
306 assert(routeTo.find(pkt->req) == routeTo.end());
307 routeTo[pkt->req] = slave_port_id;
308
309 panic_if(routeTo.size() > 512,
310 "Routing table exceeds 512 packets\n");
311 }
312
313 // update the layer state and schedule an idle event
314 reqLayers[master_port_id]->succeededTiming(packetFinishTime);
315 }
316
317 // stats updates only consider packets that were successfully sent
318 pktCount[slave_port_id][master_port_id]++;
319 pktSize[slave_port_id][master_port_id] += pkt_size;
320 transDist[pkt_cmd]++;
321
322 if (is_express_snoop) {
323 snoops++;
324 snoopTraffic += pkt_size;
325 }
326 }
327
328 if (sink_packet)
329 // queue the packet for deletion
330 pendingDelete.reset(pkt);
331
332 if (respond_directly) {
333 assert(pkt->needsResponse());
334 assert(success);
335
336 pkt->makeResponse();
337
338 if (snoopFilter && !system->bypassCaches()) {
339 // let the snoop filter inspect the response and update its state
340 snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
341 }
342
343 Tick response_time = clockEdge() + pkt->headerDelay;
344 pkt->headerDelay = 0;
345
346 slavePorts[slave_port_id]->schedTimingResp(pkt, response_time);
347 }
348
349 return success;
350}
351
352bool
353CoherentXBar::recvTimingResp(PacketPtr pkt, PortID master_port_id)
354{
355 // determine the source port based on the id
356 MasterPort *src_port = masterPorts[master_port_id];
357
358 // determine the destination
359 const auto route_lookup = routeTo.find(pkt->req);
360 assert(route_lookup != routeTo.end());
361 const PortID slave_port_id = route_lookup->second;
362 assert(slave_port_id != InvalidPortID);
363 assert(slave_port_id < respLayers.size());
364
365 // test if the crossbar should be considered occupied for the
366 // current port
367 if (!respLayers[slave_port_id]->tryTiming(src_port)) {
368 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
369 src_port->name(), pkt->print());
370 return false;
371 }
372
373 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
374 src_port->name(), pkt->print());
375
376 // store size and command as they might be modified when
377 // forwarding the packet
378 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
379 unsigned int pkt_cmd = pkt->cmdToIndex();
380
381 // a response sees the response latency
382 Tick xbar_delay = responseLatency * clockPeriod();
383
384 // set the packet header and payload delay
385 calcPacketTiming(pkt, xbar_delay);
386
387 // determine how long to be crossbar layer is busy
388 Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
389
390 if (snoopFilter && !system->bypassCaches()) {
391 // let the snoop filter inspect the response and update its state
392 snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
393 }
394
395 // send the packet through the destination slave port and pay for
396 // any outstanding header delay
397 Tick latency = pkt->headerDelay;
398 pkt->headerDelay = 0;
399 slavePorts[slave_port_id]->schedTimingResp(pkt, curTick() + latency);
400
401 // remove the request from the routing table
402 routeTo.erase(route_lookup);
403
404 respLayers[slave_port_id]->succeededTiming(packetFinishTime);
405
406 // stats updates
407 pktCount[slave_port_id][master_port_id]++;
408 pktSize[slave_port_id][master_port_id] += pkt_size;
409 transDist[pkt_cmd]++;
410
411 return true;
412}
413
414void
415CoherentXBar::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id)
416{
417 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
418 masterPorts[master_port_id]->name(), pkt->print());
419
420 // update stats here as we know the forwarding will succeed
421 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
422 transDist[pkt->cmdToIndex()]++;
423 snoops++;
424 snoopTraffic += pkt_size;
425
426 // we should only see express snoops from caches
427 assert(pkt->isExpressSnoop());
428
429 // set the packet header and payload delay, for now use forward latency
430 // @todo Assess the choice of latency further
431 calcPacketTiming(pkt, forwardLatency * clockPeriod());
432
433 // remember if a cache has already committed to responding so we
434 // can see if it changes during the snooping
435 const bool cache_responding = pkt->cacheResponding();
436
437 assert(pkt->snoopDelay == 0);
438
439 if (snoopFilter) {
440 // let the Snoop Filter work its magic and guide probing
441 auto sf_res = snoopFilter->lookupSnoop(pkt);
442 // the time required by a packet to be delivered through
443 // the xbar has to be charged also with to lookup latency
444 // of the snoop filter
445 pkt->headerDelay += sf_res.second * clockPeriod();
446 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
447 __func__, masterPorts[master_port_id]->name(), pkt->print(),
448 sf_res.first.size(), sf_res.second);
449
450 // forward to all snoopers
451 forwardTiming(pkt, InvalidPortID, sf_res.first);
452 } else {
453 forwardTiming(pkt, InvalidPortID);
454 }
455
456 // add the snoop delay to our header delay, and then reset it
457 pkt->headerDelay += pkt->snoopDelay;
458 pkt->snoopDelay = 0;
459
460 // if we can expect a response, remember how to route it
461 if (!cache_responding && pkt->cacheResponding()) {
462 assert(routeTo.find(pkt->req) == routeTo.end());
463 routeTo[pkt->req] = master_port_id;
464 }
465
466 // a snoop request came from a connected slave device (one of
467 // our master ports), and if it is not coming from the slave
468 // device responsible for the address range something is
469 // wrong, hence there is nothing further to do as the packet
470 // would be going back to where it came from
471 assert(master_port_id == findPort(pkt->getAddr()));
472}
473
474bool
475CoherentXBar::recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id)
476{
477 // determine the source port based on the id
478 SlavePort* src_port = slavePorts[slave_port_id];
479
480 // get the destination
481 const auto route_lookup = routeTo.find(pkt->req);
482 assert(route_lookup != routeTo.end());
483 const PortID dest_port_id = route_lookup->second;
484 assert(dest_port_id != InvalidPortID);
485
486 // determine if the response is from a snoop request we
487 // created as the result of a normal request (in which case it
488 // should be in the outstandingSnoop), or if we merely forwarded
489 // someone else's snoop request
490 const bool forwardAsSnoop = outstandingSnoop.find(pkt->req) ==
491 outstandingSnoop.end();
492
493 // test if the crossbar should be considered occupied for the
494 // current port, note that the check is bypassed if the response
495 // is being passed on as a normal response since this is occupying
496 // the response layer rather than the snoop response layer
497 if (forwardAsSnoop) {
498 assert(dest_port_id < snoopLayers.size());
499 if (!snoopLayers[dest_port_id]->tryTiming(src_port)) {
500 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
501 src_port->name(), pkt->print());
502 return false;
503 }
504 } else {
505 // get the master port that mirrors this slave port internally
506 MasterPort* snoop_port = snoopRespPorts[slave_port_id];
507 assert(dest_port_id < respLayers.size());
508 if (!respLayers[dest_port_id]->tryTiming(snoop_port)) {
509 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
510 snoop_port->name(), pkt->print());
511 return false;
512 }
513 }
514
515 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
516 src_port->name(), pkt->print());
517
518 // store size and command as they might be modified when
519 // forwarding the packet
520 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
521 unsigned int pkt_cmd = pkt->cmdToIndex();
522
523 // responses are never express snoops
524 assert(!pkt->isExpressSnoop());
525
526 // a snoop response sees the snoop response latency, and if it is
527 // forwarded as a normal response, the response latency
528 Tick xbar_delay =
529 (forwardAsSnoop ? snoopResponseLatency : responseLatency) *
530 clockPeriod();
531
532 // set the packet header and payload delay
533 calcPacketTiming(pkt, xbar_delay);
534
535 // determine how long to be crossbar layer is busy
536 Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
537
538 // forward it either as a snoop response or a normal response
539 if (forwardAsSnoop) {
540 // this is a snoop response to a snoop request we forwarded,
541 // e.g. coming from the L1 and going to the L2, and it should
542 // be forwarded as a snoop response
543
544 if (snoopFilter) {
545 // update the probe filter so that it can properly track the line
546 snoopFilter->updateSnoopForward(pkt, *slavePorts[slave_port_id],
547 *masterPorts[dest_port_id]);
548 }
549
550 bool success M5_VAR_USED =
551 masterPorts[dest_port_id]->sendTimingSnoopResp(pkt);
552 pktCount[slave_port_id][dest_port_id]++;
553 pktSize[slave_port_id][dest_port_id] += pkt_size;
554 assert(success);
555
556 snoopLayers[dest_port_id]->succeededTiming(packetFinishTime);
557 } else {
558 // we got a snoop response on one of our slave ports,
559 // i.e. from a coherent master connected to the crossbar, and
560 // since we created the snoop request as part of recvTiming,
561 // this should now be a normal response again
562 outstandingSnoop.erase(pkt->req);
563
564 // this is a snoop response from a coherent master, hence it
565 // should never go back to where the snoop response came from,
566 // but instead to where the original request came from
567 assert(slave_port_id != dest_port_id);
568
569 if (snoopFilter) {
570 // update the probe filter so that it can properly track the line
571 snoopFilter->updateSnoopResponse(pkt, *slavePorts[slave_port_id],
572 *slavePorts[dest_port_id]);
573 }
574
575 DPRINTF(CoherentXBar, "%s: src %s packet %s FWD RESP\n", __func__,
576 src_port->name(), pkt->print());
577
578 // as a normal response, it should go back to a master through
579 // one of our slave ports, we also pay for any outstanding
580 // header latency
581 Tick latency = pkt->headerDelay;
582 pkt->headerDelay = 0;
583 slavePorts[dest_port_id]->schedTimingResp(pkt, curTick() + latency);
584
585 respLayers[dest_port_id]->succeededTiming(packetFinishTime);
586 }
587
588 // remove the request from the routing table
589 routeTo.erase(route_lookup);
590
591 // stats updates
592 transDist[pkt_cmd]++;
593 snoops++;
594 snoopTraffic += pkt_size;
595
596 return true;
597}
598
599
600void
601CoherentXBar::forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
602 const std::vector<QueuedSlavePort*>& dests)
603{
604 DPRINTF(CoherentXBar, "%s for %s\n", __func__, pkt->print());
605
606 // snoops should only happen if the system isn't bypassing caches
607 assert(!system->bypassCaches());
608
609 unsigned fanout = 0;
610
611 for (const auto& p: dests) {
612 // we could have gotten this request from a snooping master
613 // (corresponding to our own slave port that is also in
614 // snoopPorts) and should not send it back to where it came
615 // from
616 if (exclude_slave_port_id == InvalidPortID ||
617 p->getId() != exclude_slave_port_id) {
618 // cache is not allowed to refuse snoop
619 p->sendTimingSnoopReq(pkt);
620 fanout++;
621 }
622 }
623
624 // Stats for fanout of this forward operation
625 snoopFanout.sample(fanout);
626}
627
628void
629CoherentXBar::recvReqRetry(PortID master_port_id)
630{
631 // responses and snoop responses never block on forwarding them,
632 // so the retry will always be coming from a port to which we
633 // tried to forward a request
634 reqLayers[master_port_id]->recvRetry();
635}
636
637Tick
638CoherentXBar::recvAtomic(PacketPtr pkt, PortID slave_port_id)
639{
640 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
641 slavePorts[slave_port_id]->name(), pkt->print());
642
643 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
644 unsigned int pkt_cmd = pkt->cmdToIndex();
645
646 MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
647 Tick snoop_response_latency = 0;
648
269 // since it is a normal request, attempt to send the packet
270 success = masterPorts[master_port_id]->sendTimingReq(pkt);
271 } else {
272 // no need to forward, turn this packet around and respond
273 // directly
274 assert(pkt->needsResponse());
275
276 respond_directly = true;
277 assert(!expect_snoop_resp);
278 expect_response = false;
279 }
280 }
281
282 if (snoopFilter && snoop_caches) {
283 // Let the snoop filter know about the success of the send operation
284 snoopFilter->finishRequest(!success, addr, pkt->isSecure());
285 }
286
287 // check if we were successful in sending the packet onwards
288 if (!success) {
289 // express snoops should never be forced to retry
290 assert(!is_express_snoop);
291
292 // restore the header delay
293 pkt->headerDelay = old_header_delay;
294
295 DPRINTF(CoherentXBar, "%s: src %s packet %s RETRY\n", __func__,
296 src_port->name(), pkt->print());
297
298 // update the layer state and schedule an idle event
299 reqLayers[master_port_id]->failedTiming(src_port,
300 clockEdge(Cycles(1)));
301 } else {
302 // express snoops currently bypass the crossbar state entirely
303 if (!is_express_snoop) {
304 // if this particular request will generate a snoop
305 // response
306 if (expect_snoop_resp) {
307 // we should never have an exsiting request outstanding
308 assert(outstandingSnoop.find(pkt->req) ==
309 outstandingSnoop.end());
310 outstandingSnoop.insert(pkt->req);
311
312 // basic sanity check on the outstanding snoops
313 panic_if(outstandingSnoop.size() > 512,
314 "Outstanding snoop requests exceeded 512\n");
315 }
316
317 // remember where to route the normal response to
318 if (expect_response || expect_snoop_resp) {
319 assert(routeTo.find(pkt->req) == routeTo.end());
320 routeTo[pkt->req] = slave_port_id;
321
322 panic_if(routeTo.size() > 512,
323 "Routing table exceeds 512 packets\n");
324 }
325
326 // update the layer state and schedule an idle event
327 reqLayers[master_port_id]->succeededTiming(packetFinishTime);
328 }
329
330 // stats updates only consider packets that were successfully sent
331 pktCount[slave_port_id][master_port_id]++;
332 pktSize[slave_port_id][master_port_id] += pkt_size;
333 transDist[pkt_cmd]++;
334
335 if (is_express_snoop) {
336 snoops++;
337 snoopTraffic += pkt_size;
338 }
339 }
340
341 if (sink_packet)
342 // queue the packet for deletion
343 pendingDelete.reset(pkt);
344
345 if (respond_directly) {
346 assert(pkt->needsResponse());
347 assert(success);
348
349 pkt->makeResponse();
350
351 if (snoopFilter && !system->bypassCaches()) {
352 // let the snoop filter inspect the response and update its state
353 snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
354 }
355
356 Tick response_time = clockEdge() + pkt->headerDelay;
357 pkt->headerDelay = 0;
358
359 slavePorts[slave_port_id]->schedTimingResp(pkt, response_time);
360 }
361
362 return success;
363}
364
365bool
366CoherentXBar::recvTimingResp(PacketPtr pkt, PortID master_port_id)
367{
368 // determine the source port based on the id
369 MasterPort *src_port = masterPorts[master_port_id];
370
371 // determine the destination
372 const auto route_lookup = routeTo.find(pkt->req);
373 assert(route_lookup != routeTo.end());
374 const PortID slave_port_id = route_lookup->second;
375 assert(slave_port_id != InvalidPortID);
376 assert(slave_port_id < respLayers.size());
377
378 // test if the crossbar should be considered occupied for the
379 // current port
380 if (!respLayers[slave_port_id]->tryTiming(src_port)) {
381 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
382 src_port->name(), pkt->print());
383 return false;
384 }
385
386 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
387 src_port->name(), pkt->print());
388
389 // store size and command as they might be modified when
390 // forwarding the packet
391 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
392 unsigned int pkt_cmd = pkt->cmdToIndex();
393
394 // a response sees the response latency
395 Tick xbar_delay = responseLatency * clockPeriod();
396
397 // set the packet header and payload delay
398 calcPacketTiming(pkt, xbar_delay);
399
400 // determine how long to be crossbar layer is busy
401 Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
402
403 if (snoopFilter && !system->bypassCaches()) {
404 // let the snoop filter inspect the response and update its state
405 snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
406 }
407
408 // send the packet through the destination slave port and pay for
409 // any outstanding header delay
410 Tick latency = pkt->headerDelay;
411 pkt->headerDelay = 0;
412 slavePorts[slave_port_id]->schedTimingResp(pkt, curTick() + latency);
413
414 // remove the request from the routing table
415 routeTo.erase(route_lookup);
416
417 respLayers[slave_port_id]->succeededTiming(packetFinishTime);
418
419 // stats updates
420 pktCount[slave_port_id][master_port_id]++;
421 pktSize[slave_port_id][master_port_id] += pkt_size;
422 transDist[pkt_cmd]++;
423
424 return true;
425}
426
427void
428CoherentXBar::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id)
429{
430 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
431 masterPorts[master_port_id]->name(), pkt->print());
432
433 // update stats here as we know the forwarding will succeed
434 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
435 transDist[pkt->cmdToIndex()]++;
436 snoops++;
437 snoopTraffic += pkt_size;
438
439 // we should only see express snoops from caches
440 assert(pkt->isExpressSnoop());
441
442 // set the packet header and payload delay, for now use forward latency
443 // @todo Assess the choice of latency further
444 calcPacketTiming(pkt, forwardLatency * clockPeriod());
445
446 // remember if a cache has already committed to responding so we
447 // can see if it changes during the snooping
448 const bool cache_responding = pkt->cacheResponding();
449
450 assert(pkt->snoopDelay == 0);
451
452 if (snoopFilter) {
453 // let the Snoop Filter work its magic and guide probing
454 auto sf_res = snoopFilter->lookupSnoop(pkt);
455 // the time required by a packet to be delivered through
456 // the xbar has to be charged also with to lookup latency
457 // of the snoop filter
458 pkt->headerDelay += sf_res.second * clockPeriod();
459 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
460 __func__, masterPorts[master_port_id]->name(), pkt->print(),
461 sf_res.first.size(), sf_res.second);
462
463 // forward to all snoopers
464 forwardTiming(pkt, InvalidPortID, sf_res.first);
465 } else {
466 forwardTiming(pkt, InvalidPortID);
467 }
468
469 // add the snoop delay to our header delay, and then reset it
470 pkt->headerDelay += pkt->snoopDelay;
471 pkt->snoopDelay = 0;
472
473 // if we can expect a response, remember how to route it
474 if (!cache_responding && pkt->cacheResponding()) {
475 assert(routeTo.find(pkt->req) == routeTo.end());
476 routeTo[pkt->req] = master_port_id;
477 }
478
479 // a snoop request came from a connected slave device (one of
480 // our master ports), and if it is not coming from the slave
481 // device responsible for the address range something is
482 // wrong, hence there is nothing further to do as the packet
483 // would be going back to where it came from
484 assert(master_port_id == findPort(pkt->getAddr()));
485}
486
487bool
488CoherentXBar::recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id)
489{
490 // determine the source port based on the id
491 SlavePort* src_port = slavePorts[slave_port_id];
492
493 // get the destination
494 const auto route_lookup = routeTo.find(pkt->req);
495 assert(route_lookup != routeTo.end());
496 const PortID dest_port_id = route_lookup->second;
497 assert(dest_port_id != InvalidPortID);
498
499 // determine if the response is from a snoop request we
500 // created as the result of a normal request (in which case it
501 // should be in the outstandingSnoop), or if we merely forwarded
502 // someone else's snoop request
503 const bool forwardAsSnoop = outstandingSnoop.find(pkt->req) ==
504 outstandingSnoop.end();
505
506 // test if the crossbar should be considered occupied for the
507 // current port, note that the check is bypassed if the response
508 // is being passed on as a normal response since this is occupying
509 // the response layer rather than the snoop response layer
510 if (forwardAsSnoop) {
511 assert(dest_port_id < snoopLayers.size());
512 if (!snoopLayers[dest_port_id]->tryTiming(src_port)) {
513 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
514 src_port->name(), pkt->print());
515 return false;
516 }
517 } else {
518 // get the master port that mirrors this slave port internally
519 MasterPort* snoop_port = snoopRespPorts[slave_port_id];
520 assert(dest_port_id < respLayers.size());
521 if (!respLayers[dest_port_id]->tryTiming(snoop_port)) {
522 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
523 snoop_port->name(), pkt->print());
524 return false;
525 }
526 }
527
528 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
529 src_port->name(), pkt->print());
530
531 // store size and command as they might be modified when
532 // forwarding the packet
533 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
534 unsigned int pkt_cmd = pkt->cmdToIndex();
535
536 // responses are never express snoops
537 assert(!pkt->isExpressSnoop());
538
539 // a snoop response sees the snoop response latency, and if it is
540 // forwarded as a normal response, the response latency
541 Tick xbar_delay =
542 (forwardAsSnoop ? snoopResponseLatency : responseLatency) *
543 clockPeriod();
544
545 // set the packet header and payload delay
546 calcPacketTiming(pkt, xbar_delay);
547
548 // determine how long to be crossbar layer is busy
549 Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
550
551 // forward it either as a snoop response or a normal response
552 if (forwardAsSnoop) {
553 // this is a snoop response to a snoop request we forwarded,
554 // e.g. coming from the L1 and going to the L2, and it should
555 // be forwarded as a snoop response
556
557 if (snoopFilter) {
558 // update the probe filter so that it can properly track the line
559 snoopFilter->updateSnoopForward(pkt, *slavePorts[slave_port_id],
560 *masterPorts[dest_port_id]);
561 }
562
563 bool success M5_VAR_USED =
564 masterPorts[dest_port_id]->sendTimingSnoopResp(pkt);
565 pktCount[slave_port_id][dest_port_id]++;
566 pktSize[slave_port_id][dest_port_id] += pkt_size;
567 assert(success);
568
569 snoopLayers[dest_port_id]->succeededTiming(packetFinishTime);
570 } else {
571 // we got a snoop response on one of our slave ports,
572 // i.e. from a coherent master connected to the crossbar, and
573 // since we created the snoop request as part of recvTiming,
574 // this should now be a normal response again
575 outstandingSnoop.erase(pkt->req);
576
577 // this is a snoop response from a coherent master, hence it
578 // should never go back to where the snoop response came from,
579 // but instead to where the original request came from
580 assert(slave_port_id != dest_port_id);
581
582 if (snoopFilter) {
583 // update the probe filter so that it can properly track the line
584 snoopFilter->updateSnoopResponse(pkt, *slavePorts[slave_port_id],
585 *slavePorts[dest_port_id]);
586 }
587
588 DPRINTF(CoherentXBar, "%s: src %s packet %s FWD RESP\n", __func__,
589 src_port->name(), pkt->print());
590
591 // as a normal response, it should go back to a master through
592 // one of our slave ports, we also pay for any outstanding
593 // header latency
594 Tick latency = pkt->headerDelay;
595 pkt->headerDelay = 0;
596 slavePorts[dest_port_id]->schedTimingResp(pkt, curTick() + latency);
597
598 respLayers[dest_port_id]->succeededTiming(packetFinishTime);
599 }
600
601 // remove the request from the routing table
602 routeTo.erase(route_lookup);
603
604 // stats updates
605 transDist[pkt_cmd]++;
606 snoops++;
607 snoopTraffic += pkt_size;
608
609 return true;
610}
611
612
613void
614CoherentXBar::forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
615 const std::vector<QueuedSlavePort*>& dests)
616{
617 DPRINTF(CoherentXBar, "%s for %s\n", __func__, pkt->print());
618
619 // snoops should only happen if the system isn't bypassing caches
620 assert(!system->bypassCaches());
621
622 unsigned fanout = 0;
623
624 for (const auto& p: dests) {
625 // we could have gotten this request from a snooping master
626 // (corresponding to our own slave port that is also in
627 // snoopPorts) and should not send it back to where it came
628 // from
629 if (exclude_slave_port_id == InvalidPortID ||
630 p->getId() != exclude_slave_port_id) {
631 // cache is not allowed to refuse snoop
632 p->sendTimingSnoopReq(pkt);
633 fanout++;
634 }
635 }
636
637 // Stats for fanout of this forward operation
638 snoopFanout.sample(fanout);
639}
640
641void
642CoherentXBar::recvReqRetry(PortID master_port_id)
643{
644 // responses and snoop responses never block on forwarding them,
645 // so the retry will always be coming from a port to which we
646 // tried to forward a request
647 reqLayers[master_port_id]->recvRetry();
648}
649
650Tick
651CoherentXBar::recvAtomic(PacketPtr pkt, PortID slave_port_id)
652{
653 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
654 slavePorts[slave_port_id]->name(), pkt->print());
655
656 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
657 unsigned int pkt_cmd = pkt->cmdToIndex();
658
659 MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
660 Tick snoop_response_latency = 0;
661
662 // is this the destination point for this packet? (e.g. true if
663 // this xbar is the PoC for a cache maintenance operation to the
664 // PoC) otherwise the destination is any cache that can satisfy
665 // the request
666 const bool is_destination = isDestination(pkt);
667
649 const bool snoop_caches = !system->bypassCaches() &&
650 pkt->cmd != MemCmd::WriteClean;
651 if (snoop_caches) {
652 // forward to all snoopers but the source
653 std::pair<MemCmd, Tick> snoop_result;
654 if (snoopFilter) {
655 // check with the snoop filter where to forward this packet
656 auto sf_res =
657 snoopFilter->lookupRequest(pkt, *slavePorts[slave_port_id]);
658 snoop_response_latency += sf_res.second * clockPeriod();
659 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
660 __func__, slavePorts[slave_port_id]->name(), pkt->print(),
661 sf_res.first.size(), sf_res.second);
662
663 // let the snoop filter know about the success of the send
664 // operation, and do it even before sending it onwards to
665 // avoid situations where atomic upward snoops sneak in
666 // between and change the filter state
667 snoopFilter->finishRequest(false, pkt->getAddr(), pkt->isSecure());
668
669 if (pkt->isEviction()) {
670 // for block-evicting packets, i.e. writebacks and
671 // clean evictions, there is no need to snoop up, as
672 // all we do is determine if the block is cached or
673 // not, instead just set it here based on the snoop
674 // filter result
675 if (!sf_res.first.empty())
676 pkt->setBlockCached();
677 } else {
678 snoop_result = forwardAtomic(pkt, slave_port_id, InvalidPortID,
679 sf_res.first);
680 }
681 } else {
682 snoop_result = forwardAtomic(pkt, slave_port_id);
683 }
684 snoop_response_cmd = snoop_result.first;
685 snoop_response_latency += snoop_result.second;
686 }
687
688 // set up a sensible default value
689 Tick response_latency = 0;
690
691 const bool sink_packet = sinkPacket(pkt);
692
693 // even if we had a snoop response, we must continue and also
694 // perform the actual request at the destination
695 PortID master_port_id = findPort(pkt->getAddr());
696
697 if (sink_packet) {
698 DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
699 pkt->print());
700 } else {
668 const bool snoop_caches = !system->bypassCaches() &&
669 pkt->cmd != MemCmd::WriteClean;
670 if (snoop_caches) {
671 // forward to all snoopers but the source
672 std::pair<MemCmd, Tick> snoop_result;
673 if (snoopFilter) {
674 // check with the snoop filter where to forward this packet
675 auto sf_res =
676 snoopFilter->lookupRequest(pkt, *slavePorts[slave_port_id]);
677 snoop_response_latency += sf_res.second * clockPeriod();
678 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
679 __func__, slavePorts[slave_port_id]->name(), pkt->print(),
680 sf_res.first.size(), sf_res.second);
681
682 // let the snoop filter know about the success of the send
683 // operation, and do it even before sending it onwards to
684 // avoid situations where atomic upward snoops sneak in
685 // between and change the filter state
686 snoopFilter->finishRequest(false, pkt->getAddr(), pkt->isSecure());
687
688 if (pkt->isEviction()) {
689 // for block-evicting packets, i.e. writebacks and
690 // clean evictions, there is no need to snoop up, as
691 // all we do is determine if the block is cached or
692 // not, instead just set it here based on the snoop
693 // filter result
694 if (!sf_res.first.empty())
695 pkt->setBlockCached();
696 } else {
697 snoop_result = forwardAtomic(pkt, slave_port_id, InvalidPortID,
698 sf_res.first);
699 }
700 } else {
701 snoop_result = forwardAtomic(pkt, slave_port_id);
702 }
703 snoop_response_cmd = snoop_result.first;
704 snoop_response_latency += snoop_result.second;
705 }
706
707 // set up a sensible default value
708 Tick response_latency = 0;
709
710 const bool sink_packet = sinkPacket(pkt);
711
712 // even if we had a snoop response, we must continue and also
713 // perform the actual request at the destination
714 PortID master_port_id = findPort(pkt->getAddr());
715
716 if (sink_packet) {
717 DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
718 pkt->print());
719 } else {
701 if (!pointOfCoherency || pkt->isRead() || pkt->isWrite()) {
720 if (forwardPacket(pkt)) {
721 // make sure that the write request (e.g., WriteClean)
722 // will stop at the memory below if this crossbar is its
723 // destination
724 if (pkt->isWrite() && is_destination) {
725 pkt->clearWriteThrough();
726 }
727
702 // forward the request to the appropriate destination
703 response_latency = masterPorts[master_port_id]->sendAtomic(pkt);
704 } else {
705 // if it does not need a response we sink the packet above
706 assert(pkt->needsResponse());
707
708 pkt->makeResponse();
709 }
710 }
711
712 // stats updates for the request
713 pktCount[slave_port_id][master_port_id]++;
714 pktSize[slave_port_id][master_port_id] += pkt_size;
715 transDist[pkt_cmd]++;
716
717
718 // if lower levels have replied, tell the snoop filter
719 if (!system->bypassCaches() && snoopFilter && pkt->isResponse()) {
720 snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
721 }
722
723 // if we got a response from a snooper, restore it here
724 if (snoop_response_cmd != MemCmd::InvalidCmd) {
725 // no one else should have responded
726 assert(!pkt->isResponse());
727 pkt->cmd = snoop_response_cmd;
728 response_latency = snoop_response_latency;
729 }
730
731 // add the response data
732 if (pkt->isResponse()) {
733 pkt_size = pkt->hasData() ? pkt->getSize() : 0;
734 pkt_cmd = pkt->cmdToIndex();
735
736 // stats updates
737 pktCount[slave_port_id][master_port_id]++;
738 pktSize[slave_port_id][master_port_id] += pkt_size;
739 transDist[pkt_cmd]++;
740 }
741
742 // @todo: Not setting header time
743 pkt->payloadDelay = response_latency;
744 return response_latency;
745}
746
747Tick
748CoherentXBar::recvAtomicSnoop(PacketPtr pkt, PortID master_port_id)
749{
750 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
751 masterPorts[master_port_id]->name(), pkt->print());
752
753 // add the request snoop data
754 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
755 snoops++;
756 snoopTraffic += pkt_size;
757
758 // forward to all snoopers
759 std::pair<MemCmd, Tick> snoop_result;
760 Tick snoop_response_latency = 0;
761 if (snoopFilter) {
762 auto sf_res = snoopFilter->lookupSnoop(pkt);
763 snoop_response_latency += sf_res.second * clockPeriod();
764 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
765 __func__, masterPorts[master_port_id]->name(), pkt->print(),
766 sf_res.first.size(), sf_res.second);
767 snoop_result = forwardAtomic(pkt, InvalidPortID, master_port_id,
768 sf_res.first);
769 } else {
770 snoop_result = forwardAtomic(pkt, InvalidPortID);
771 }
772 MemCmd snoop_response_cmd = snoop_result.first;
773 snoop_response_latency += snoop_result.second;
774
775 if (snoop_response_cmd != MemCmd::InvalidCmd)
776 pkt->cmd = snoop_response_cmd;
777
778 // add the response snoop data
779 if (pkt->isResponse()) {
780 snoops++;
781 }
782
783 // @todo: Not setting header time
784 pkt->payloadDelay = snoop_response_latency;
785 return snoop_response_latency;
786}
787
788std::pair<MemCmd, Tick>
789CoherentXBar::forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id,
790 PortID source_master_port_id,
791 const std::vector<QueuedSlavePort*>& dests)
792{
793 // the packet may be changed on snoops, record the original
794 // command to enable us to restore it between snoops so that
795 // additional snoops can take place properly
796 MemCmd orig_cmd = pkt->cmd;
797 MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
798 Tick snoop_response_latency = 0;
799
800 // snoops should only happen if the system isn't bypassing caches
801 assert(!system->bypassCaches());
802
803 unsigned fanout = 0;
804
805 for (const auto& p: dests) {
806 // we could have gotten this request from a snooping master
807 // (corresponding to our own slave port that is also in
808 // snoopPorts) and should not send it back to where it came
809 // from
810 if (exclude_slave_port_id != InvalidPortID &&
811 p->getId() == exclude_slave_port_id)
812 continue;
813
814 Tick latency = p->sendAtomicSnoop(pkt);
815 fanout++;
816
817 // in contrast to a functional access, we have to keep on
818 // going as all snoopers must be updated even if we get a
819 // response
820 if (!pkt->isResponse())
821 continue;
822
823 // response from snoop agent
824 assert(pkt->cmd != orig_cmd);
825 assert(pkt->cacheResponding());
826 // should only happen once
827 assert(snoop_response_cmd == MemCmd::InvalidCmd);
828 // save response state
829 snoop_response_cmd = pkt->cmd;
830 snoop_response_latency = latency;
831
832 if (snoopFilter) {
833 // Handle responses by the snoopers and differentiate between
834 // responses to requests from above and snoops from below
835 if (source_master_port_id != InvalidPortID) {
836 // Getting a response for a snoop from below
837 assert(exclude_slave_port_id == InvalidPortID);
838 snoopFilter->updateSnoopForward(pkt, *p,
839 *masterPorts[source_master_port_id]);
840 } else {
841 // Getting a response for a request from above
842 assert(source_master_port_id == InvalidPortID);
843 snoopFilter->updateSnoopResponse(pkt, *p,
844 *slavePorts[exclude_slave_port_id]);
845 }
846 }
847 // restore original packet state for remaining snoopers
848 pkt->cmd = orig_cmd;
849 }
850
851 // Stats for fanout
852 snoopFanout.sample(fanout);
853
854 // the packet is restored as part of the loop and any potential
855 // snoop response is part of the returned pair
856 return std::make_pair(snoop_response_cmd, snoop_response_latency);
857}
858
859void
860CoherentXBar::recvFunctional(PacketPtr pkt, PortID slave_port_id)
861{
862 if (!pkt->isPrint()) {
863 // don't do DPRINTFs on PrintReq as it clutters up the output
864 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
865 slavePorts[slave_port_id]->name(), pkt->print());
866 }
867
868 if (!system->bypassCaches()) {
869 // forward to all snoopers but the source
870 forwardFunctional(pkt, slave_port_id);
871 }
872
873 // there is no need to continue if the snooping has found what we
874 // were looking for and the packet is already a response
875 if (!pkt->isResponse()) {
876 // since our slave ports are queued ports we need to check them as well
877 for (const auto& p : slavePorts) {
878 // if we find a response that has the data, then the
879 // downstream caches/memories may be out of date, so simply stop
880 // here
881 if (p->checkFunctional(pkt)) {
882 if (pkt->needsResponse())
883 pkt->makeResponse();
884 return;
885 }
886 }
887
888 PortID dest_id = findPort(pkt->getAddr());
889
890 masterPorts[dest_id]->sendFunctional(pkt);
891 }
892}
893
894void
895CoherentXBar::recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id)
896{
897 if (!pkt->isPrint()) {
898 // don't do DPRINTFs on PrintReq as it clutters up the output
899 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
900 masterPorts[master_port_id]->name(), pkt->print());
901 }
902
903 for (const auto& p : slavePorts) {
904 if (p->checkFunctional(pkt)) {
905 if (pkt->needsResponse())
906 pkt->makeResponse();
907 return;
908 }
909 }
910
911 // forward to all snoopers
912 forwardFunctional(pkt, InvalidPortID);
913}
914
915void
916CoherentXBar::forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id)
917{
918 // snoops should only happen if the system isn't bypassing caches
919 assert(!system->bypassCaches());
920
921 for (const auto& p: snoopPorts) {
922 // we could have gotten this request from a snooping master
923 // (corresponding to our own slave port that is also in
924 // snoopPorts) and should not send it back to where it came
925 // from
926 if (exclude_slave_port_id == InvalidPortID ||
927 p->getId() != exclude_slave_port_id)
928 p->sendFunctionalSnoop(pkt);
929
930 // if we get a response we are done
931 if (pkt->isResponse()) {
932 break;
933 }
934 }
935}
936
937bool
938CoherentXBar::sinkPacket(const PacketPtr pkt) const
939{
940 // we can sink the packet if:
941 // 1) the crossbar is the point of coherency, and a cache is
942 // responding after being snooped
943 // 2) the crossbar is the point of coherency, and the packet is a
944 // coherency packet (not a read or a write) that does not
945 // require a response
946 // 3) this is a clean evict or clean writeback, but the packet is
947 // found in a cache above this crossbar
948 // 4) a cache is responding after being snooped, and the packet
949 // either does not need the block to be writable, or the cache
950 // that has promised to respond (setting the cache responding
951 // flag) is providing writable and thus had a Modified block,
952 // and no further action is needed
953 return (pointOfCoherency && pkt->cacheResponding()) ||
954 (pointOfCoherency && !(pkt->isRead() || pkt->isWrite()) &&
955 !pkt->needsResponse()) ||
956 (pkt->isCleanEviction() && pkt->isBlockCached()) ||
957 (pkt->cacheResponding() &&
958 (!pkt->needsWritable() || pkt->responderHadWritable()));
959}
960
728 // forward the request to the appropriate destination
729 response_latency = masterPorts[master_port_id]->sendAtomic(pkt);
730 } else {
731 // if it does not need a response we sink the packet above
732 assert(pkt->needsResponse());
733
734 pkt->makeResponse();
735 }
736 }
737
738 // stats updates for the request
739 pktCount[slave_port_id][master_port_id]++;
740 pktSize[slave_port_id][master_port_id] += pkt_size;
741 transDist[pkt_cmd]++;
742
743
744 // if lower levels have replied, tell the snoop filter
745 if (!system->bypassCaches() && snoopFilter && pkt->isResponse()) {
746 snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
747 }
748
749 // if we got a response from a snooper, restore it here
750 if (snoop_response_cmd != MemCmd::InvalidCmd) {
751 // no one else should have responded
752 assert(!pkt->isResponse());
753 pkt->cmd = snoop_response_cmd;
754 response_latency = snoop_response_latency;
755 }
756
757 // add the response data
758 if (pkt->isResponse()) {
759 pkt_size = pkt->hasData() ? pkt->getSize() : 0;
760 pkt_cmd = pkt->cmdToIndex();
761
762 // stats updates
763 pktCount[slave_port_id][master_port_id]++;
764 pktSize[slave_port_id][master_port_id] += pkt_size;
765 transDist[pkt_cmd]++;
766 }
767
768 // @todo: Not setting header time
769 pkt->payloadDelay = response_latency;
770 return response_latency;
771}
772
773Tick
774CoherentXBar::recvAtomicSnoop(PacketPtr pkt, PortID master_port_id)
775{
776 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
777 masterPorts[master_port_id]->name(), pkt->print());
778
779 // add the request snoop data
780 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
781 snoops++;
782 snoopTraffic += pkt_size;
783
784 // forward to all snoopers
785 std::pair<MemCmd, Tick> snoop_result;
786 Tick snoop_response_latency = 0;
787 if (snoopFilter) {
788 auto sf_res = snoopFilter->lookupSnoop(pkt);
789 snoop_response_latency += sf_res.second * clockPeriod();
790 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
791 __func__, masterPorts[master_port_id]->name(), pkt->print(),
792 sf_res.first.size(), sf_res.second);
793 snoop_result = forwardAtomic(pkt, InvalidPortID, master_port_id,
794 sf_res.first);
795 } else {
796 snoop_result = forwardAtomic(pkt, InvalidPortID);
797 }
798 MemCmd snoop_response_cmd = snoop_result.first;
799 snoop_response_latency += snoop_result.second;
800
801 if (snoop_response_cmd != MemCmd::InvalidCmd)
802 pkt->cmd = snoop_response_cmd;
803
804 // add the response snoop data
805 if (pkt->isResponse()) {
806 snoops++;
807 }
808
809 // @todo: Not setting header time
810 pkt->payloadDelay = snoop_response_latency;
811 return snoop_response_latency;
812}
813
814std::pair<MemCmd, Tick>
815CoherentXBar::forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id,
816 PortID source_master_port_id,
817 const std::vector<QueuedSlavePort*>& dests)
818{
819 // the packet may be changed on snoops, record the original
820 // command to enable us to restore it between snoops so that
821 // additional snoops can take place properly
822 MemCmd orig_cmd = pkt->cmd;
823 MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
824 Tick snoop_response_latency = 0;
825
826 // snoops should only happen if the system isn't bypassing caches
827 assert(!system->bypassCaches());
828
829 unsigned fanout = 0;
830
831 for (const auto& p: dests) {
832 // we could have gotten this request from a snooping master
833 // (corresponding to our own slave port that is also in
834 // snoopPorts) and should not send it back to where it came
835 // from
836 if (exclude_slave_port_id != InvalidPortID &&
837 p->getId() == exclude_slave_port_id)
838 continue;
839
840 Tick latency = p->sendAtomicSnoop(pkt);
841 fanout++;
842
843 // in contrast to a functional access, we have to keep on
844 // going as all snoopers must be updated even if we get a
845 // response
846 if (!pkt->isResponse())
847 continue;
848
849 // response from snoop agent
850 assert(pkt->cmd != orig_cmd);
851 assert(pkt->cacheResponding());
852 // should only happen once
853 assert(snoop_response_cmd == MemCmd::InvalidCmd);
854 // save response state
855 snoop_response_cmd = pkt->cmd;
856 snoop_response_latency = latency;
857
858 if (snoopFilter) {
859 // Handle responses by the snoopers and differentiate between
860 // responses to requests from above and snoops from below
861 if (source_master_port_id != InvalidPortID) {
862 // Getting a response for a snoop from below
863 assert(exclude_slave_port_id == InvalidPortID);
864 snoopFilter->updateSnoopForward(pkt, *p,
865 *masterPorts[source_master_port_id]);
866 } else {
867 // Getting a response for a request from above
868 assert(source_master_port_id == InvalidPortID);
869 snoopFilter->updateSnoopResponse(pkt, *p,
870 *slavePorts[exclude_slave_port_id]);
871 }
872 }
873 // restore original packet state for remaining snoopers
874 pkt->cmd = orig_cmd;
875 }
876
877 // Stats for fanout
878 snoopFanout.sample(fanout);
879
880 // the packet is restored as part of the loop and any potential
881 // snoop response is part of the returned pair
882 return std::make_pair(snoop_response_cmd, snoop_response_latency);
883}
884
885void
886CoherentXBar::recvFunctional(PacketPtr pkt, PortID slave_port_id)
887{
888 if (!pkt->isPrint()) {
889 // don't do DPRINTFs on PrintReq as it clutters up the output
890 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
891 slavePorts[slave_port_id]->name(), pkt->print());
892 }
893
894 if (!system->bypassCaches()) {
895 // forward to all snoopers but the source
896 forwardFunctional(pkt, slave_port_id);
897 }
898
899 // there is no need to continue if the snooping has found what we
900 // were looking for and the packet is already a response
901 if (!pkt->isResponse()) {
902 // since our slave ports are queued ports we need to check them as well
903 for (const auto& p : slavePorts) {
904 // if we find a response that has the data, then the
905 // downstream caches/memories may be out of date, so simply stop
906 // here
907 if (p->checkFunctional(pkt)) {
908 if (pkt->needsResponse())
909 pkt->makeResponse();
910 return;
911 }
912 }
913
914 PortID dest_id = findPort(pkt->getAddr());
915
916 masterPorts[dest_id]->sendFunctional(pkt);
917 }
918}
919
920void
921CoherentXBar::recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id)
922{
923 if (!pkt->isPrint()) {
924 // don't do DPRINTFs on PrintReq as it clutters up the output
925 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
926 masterPorts[master_port_id]->name(), pkt->print());
927 }
928
929 for (const auto& p : slavePorts) {
930 if (p->checkFunctional(pkt)) {
931 if (pkt->needsResponse())
932 pkt->makeResponse();
933 return;
934 }
935 }
936
937 // forward to all snoopers
938 forwardFunctional(pkt, InvalidPortID);
939}
940
941void
942CoherentXBar::forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id)
943{
944 // snoops should only happen if the system isn't bypassing caches
945 assert(!system->bypassCaches());
946
947 for (const auto& p: snoopPorts) {
948 // we could have gotten this request from a snooping master
949 // (corresponding to our own slave port that is also in
950 // snoopPorts) and should not send it back to where it came
951 // from
952 if (exclude_slave_port_id == InvalidPortID ||
953 p->getId() != exclude_slave_port_id)
954 p->sendFunctionalSnoop(pkt);
955
956 // if we get a response we are done
957 if (pkt->isResponse()) {
958 break;
959 }
960 }
961}
962
963bool
964CoherentXBar::sinkPacket(const PacketPtr pkt) const
965{
966 // we can sink the packet if:
967 // 1) the crossbar is the point of coherency, and a cache is
968 // responding after being snooped
969 // 2) the crossbar is the point of coherency, and the packet is a
970 // coherency packet (not a read or a write) that does not
971 // require a response
972 // 3) this is a clean evict or clean writeback, but the packet is
973 // found in a cache above this crossbar
974 // 4) a cache is responding after being snooped, and the packet
975 // either does not need the block to be writable, or the cache
976 // that has promised to respond (setting the cache responding
977 // flag) is providing writable and thus had a Modified block,
978 // and no further action is needed
979 return (pointOfCoherency && pkt->cacheResponding()) ||
980 (pointOfCoherency && !(pkt->isRead() || pkt->isWrite()) &&
981 !pkt->needsResponse()) ||
982 (pkt->isCleanEviction() && pkt->isBlockCached()) ||
983 (pkt->cacheResponding() &&
984 (!pkt->needsWritable() || pkt->responderHadWritable()));
985}
986
987bool
988CoherentXBar::forwardPacket(const PacketPtr pkt)
989{
990 // we are forwarding the packet if:
991 // 1) this is a read or a write
992 // 2) this crossbar is above the point of coherency
993 return pkt->isRead() || pkt->isWrite() || !pointOfCoherency;
994}
995
996
961void
962CoherentXBar::regStats()
963{
964 // register the stats of the base class and our layers
965 BaseXBar::regStats();
966 for (auto l: reqLayers)
967 l->regStats();
968 for (auto l: respLayers)
969 l->regStats();
970 for (auto l: snoopLayers)
971 l->regStats();
972
973 snoops
974 .name(name() + ".snoops")
975 .desc("Total snoops (count)")
976 ;
977
978 snoopTraffic
979 .name(name() + ".snoopTraffic")
980 .desc("Total snoop traffic (bytes)")
981 ;
982
983 snoopFanout
984 .init(0, snoopPorts.size(), 1)
985 .name(name() + ".snoop_fanout")
986 .desc("Request fanout histogram")
987 ;
988}
989
990CoherentXBar *
991CoherentXBarParams::create()
992{
993 return new CoherentXBar(this);
994}
997void
998CoherentXBar::regStats()
999{
1000 // register the stats of the base class and our layers
1001 BaseXBar::regStats();
1002 for (auto l: reqLayers)
1003 l->regStats();
1004 for (auto l: respLayers)
1005 l->regStats();
1006 for (auto l: snoopLayers)
1007 l->regStats();
1008
1009 snoops
1010 .name(name() + ".snoops")
1011 .desc("Total snoops (count)")
1012 ;
1013
1014 snoopTraffic
1015 .name(name() + ".snoopTraffic")
1016 .desc("Total snoop traffic (bytes)")
1017 ;
1018
1019 snoopFanout
1020 .init(0, snoopPorts.size(), 1)
1021 .name(name() + ".snoop_fanout")
1022 .desc("Request fanout histogram")
1023 ;
1024}
1025
1026CoherentXBar *
1027CoherentXBarParams::create()
1028{
1029 return new CoherentXBar(this);
1030}