coherent_xbar.hh (11564:dac4b77b5a49) coherent_xbar.hh (11859:76c36516e0ae)
1/*
2 * Copyright (c) 2011-2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2002-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Ron Dreslinski
41 * Ali Saidi
42 * Andreas Hansson
43 * William Wang
44 */
45
46/**
47 * @file
48 * Declaration of a coherent crossbar.
49 */
50
51#ifndef __MEM_COHERENT_XBAR_HH__
52#define __MEM_COHERENT_XBAR_HH__
53
1/*
2 * Copyright (c) 2011-2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2002-2005 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Authors: Ron Dreslinski
41 * Ali Saidi
42 * Andreas Hansson
43 * William Wang
44 */
45
46/**
47 * @file
48 * Declaration of a coherent crossbar.
49 */
50
51#ifndef __MEM_COHERENT_XBAR_HH__
52#define __MEM_COHERENT_XBAR_HH__
53
54#include <unordered_set>
55
54#include "mem/snoop_filter.hh"
55#include "mem/xbar.hh"
56#include "params/CoherentXBar.hh"
57
58/**
59 * A coherent crossbar connects a number of (potentially) snooping
60 * masters and slaves, and routes the request and response packets
61 * based on the address, and also forwards all requests to the
62 * snoopers and deals with the snoop responses.
63 *
64 * The coherent crossbar can be used as a template for modelling QPI,
65 * HyperTransport, ACE and coherent OCP buses, and is typically used
66 * for the L1-to-L2 buses and as the main system interconnect. @sa
67 * \ref gem5MemorySystem "gem5 Memory System"
68 */
69class CoherentXBar : public BaseXBar
70{
71
72 protected:
73
74 /**
75 * Declare the layers of this crossbar, one vector for requests,
76 * one for responses, and one for snoop responses
77 */
78 std::vector<ReqLayer*> reqLayers;
79 std::vector<RespLayer*> respLayers;
80 std::vector<SnoopRespLayer*> snoopLayers;
81
82 /**
83 * Declaration of the coherent crossbar slave port type, one will
84 * be instantiated for each of the master ports connecting to the
85 * crossbar.
86 */
87 class CoherentXBarSlavePort : public QueuedSlavePort
88 {
89
90 private:
91
92 /** A reference to the crossbar to which this port belongs. */
93 CoherentXBar &xbar;
94
95 /** A normal packet queue used to store responses. */
96 RespPacketQueue queue;
97
98 public:
99
100 CoherentXBarSlavePort(const std::string &_name,
101 CoherentXBar &_xbar, PortID _id)
102 : QueuedSlavePort(_name, &_xbar, queue, _id), xbar(_xbar),
103 queue(_xbar, *this)
104 { }
105
106 protected:
107
108 /**
109 * When receiving a timing request, pass it to the crossbar.
110 */
111 virtual bool recvTimingReq(PacketPtr pkt)
112 { return xbar.recvTimingReq(pkt, id); }
113
114 /**
115 * When receiving a timing snoop response, pass it to the crossbar.
116 */
117 virtual bool recvTimingSnoopResp(PacketPtr pkt)
118 { return xbar.recvTimingSnoopResp(pkt, id); }
119
120 /**
121 * When receiving an atomic request, pass it to the crossbar.
122 */
123 virtual Tick recvAtomic(PacketPtr pkt)
124 { return xbar.recvAtomic(pkt, id); }
125
126 /**
127 * When receiving a functional request, pass it to the crossbar.
128 */
129 virtual void recvFunctional(PacketPtr pkt)
130 { xbar.recvFunctional(pkt, id); }
131
132 /**
133 * Return the union of all adress ranges seen by this crossbar.
134 */
135 virtual AddrRangeList getAddrRanges() const
136 { return xbar.getAddrRanges(); }
137
138 };
139
140 /**
141 * Declaration of the coherent crossbar master port type, one will be
142 * instantiated for each of the slave interfaces connecting to the
143 * crossbar.
144 */
145 class CoherentXBarMasterPort : public MasterPort
146 {
147 private:
148 /** A reference to the crossbar to which this port belongs. */
149 CoherentXBar &xbar;
150
151 public:
152
153 CoherentXBarMasterPort(const std::string &_name,
154 CoherentXBar &_xbar, PortID _id)
155 : MasterPort(_name, &_xbar, _id), xbar(_xbar)
156 { }
157
158 protected:
159
160 /**
161 * Determine if this port should be considered a snooper. For
162 * a coherent crossbar master port this is always true.
163 *
164 * @return a boolean that is true if this port is snooping
165 */
166 virtual bool isSnooping() const
167 { return true; }
168
169 /**
170 * When receiving a timing response, pass it to the crossbar.
171 */
172 virtual bool recvTimingResp(PacketPtr pkt)
173 { return xbar.recvTimingResp(pkt, id); }
174
175 /**
176 * When receiving a timing snoop request, pass it to the crossbar.
177 */
178 virtual void recvTimingSnoopReq(PacketPtr pkt)
179 { return xbar.recvTimingSnoopReq(pkt, id); }
180
181 /**
182 * When receiving an atomic snoop request, pass it to the crossbar.
183 */
184 virtual Tick recvAtomicSnoop(PacketPtr pkt)
185 { return xbar.recvAtomicSnoop(pkt, id); }
186
187 /**
188 * When receiving a functional snoop request, pass it to the crossbar.
189 */
190 virtual void recvFunctionalSnoop(PacketPtr pkt)
191 { xbar.recvFunctionalSnoop(pkt, id); }
192
193 /** When reciving a range change from the peer port (at id),
194 pass it to the crossbar. */
195 virtual void recvRangeChange()
196 { xbar.recvRangeChange(id); }
197
198 /** When reciving a retry from the peer port (at id),
199 pass it to the crossbar. */
200 virtual void recvReqRetry()
201 { xbar.recvReqRetry(id); }
202
203 };
204
205 /**
206 * Internal class to bridge between an incoming snoop response
207 * from a slave port and forwarding it through an outgoing slave
208 * port. It is effectively a dangling master port.
209 */
210 class SnoopRespPort : public MasterPort
211 {
212
213 private:
214
215 /** The port which we mirror internally. */
216 QueuedSlavePort& slavePort;
217
218 public:
219
220 /**
221 * Create a snoop response port that mirrors a given slave port.
222 */
223 SnoopRespPort(QueuedSlavePort& slave_port, CoherentXBar& _xbar) :
224 MasterPort(slave_port.name() + ".snoopRespPort", &_xbar),
225 slavePort(slave_port) { }
226
227 /**
228 * Override the sending of retries and pass them on through
229 * the mirrored slave port.
230 */
231 void sendRetryResp() {
232 // forward it as a snoop response retry
233 slavePort.sendRetrySnoopResp();
234 }
235
236 /**
237 * Provided as necessary.
238 */
239 void recvReqRetry() { panic("SnoopRespPort should never see retry\n"); }
240
241 /**
242 * Provided as necessary.
243 */
244 bool recvTimingResp(PacketPtr pkt)
245 {
246 panic("SnoopRespPort should never see timing response\n");
247 return false;
248 }
249
250 };
251
252 std::vector<SnoopRespPort*> snoopRespPorts;
253
254 std::vector<QueuedSlavePort*> snoopPorts;
255
256 /**
257 * Store the outstanding requests that we are expecting snoop
258 * responses from so we can determine which snoop responses we
259 * generated and which ones were merely forwarded.
260 */
261 std::unordered_set<RequestPtr> outstandingSnoop;
262
263 /**
264 * Keep a pointer to the system to be allow to querying memory system
265 * properties.
266 */
267 System *system;
268
269 /** A snoop filter that tracks cache line residency and can restrict the
270 * broadcast needed for probes. NULL denotes an absent filter. */
271 SnoopFilter *snoopFilter;
272
273 /** Cycles of snoop response latency.*/
274 const Cycles snoopResponseLatency;
275
276 /** Is this crossbar the point of coherency? **/
277 const bool pointOfCoherency;
278
279 /**
280 * Upstream caches need this packet until true is returned, so
281 * hold it for deletion until a subsequent call
282 */
283 std::unique_ptr<Packet> pendingDelete;
284
285 /** Function called by the port when the crossbar is recieving a Timing
286 request packet.*/
287 bool recvTimingReq(PacketPtr pkt, PortID slave_port_id);
288
289 /** Function called by the port when the crossbar is recieving a Timing
290 response packet.*/
291 bool recvTimingResp(PacketPtr pkt, PortID master_port_id);
292
293 /** Function called by the port when the crossbar is recieving a timing
294 snoop request.*/
295 void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id);
296
297 /** Function called by the port when the crossbar is recieving a timing
298 snoop response.*/
299 bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id);
300
301 /** Timing function called by port when it is once again able to process
302 * requests. */
303 void recvReqRetry(PortID master_port_id);
304
305 /**
306 * Forward a timing packet to our snoopers, potentially excluding
307 * one of the connected coherent masters to avoid sending a packet
308 * back to where it came from.
309 *
310 * @param pkt Packet to forward
311 * @param exclude_slave_port_id Id of slave port to exclude
312 */
313 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id) {
314 forwardTiming(pkt, exclude_slave_port_id, snoopPorts);
315 }
316
317 /**
318 * Forward a timing packet to a selected list of snoopers, potentially
319 * excluding one of the connected coherent masters to avoid sending a packet
320 * back to where it came from.
321 *
322 * @param pkt Packet to forward
323 * @param exclude_slave_port_id Id of slave port to exclude
324 * @param dests Vector of destination ports for the forwarded pkt
325 */
326 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
327 const std::vector<QueuedSlavePort*>& dests);
328
329 /** Function called by the port when the crossbar is recieving a Atomic
330 transaction.*/
331 Tick recvAtomic(PacketPtr pkt, PortID slave_port_id);
332
333 /** Function called by the port when the crossbar is recieving an
334 atomic snoop transaction.*/
335 Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id);
336
337 /**
338 * Forward an atomic packet to our snoopers, potentially excluding
339 * one of the connected coherent masters to avoid sending a packet
340 * back to where it came from.
341 *
342 * @param pkt Packet to forward
343 * @param exclude_slave_port_id Id of slave port to exclude
344 *
345 * @return a pair containing the snoop response and snoop latency
346 */
347 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt,
348 PortID exclude_slave_port_id)
349 {
350 return forwardAtomic(pkt, exclude_slave_port_id, InvalidPortID,
351 snoopPorts);
352 }
353
354 /**
355 * Forward an atomic packet to a selected list of snoopers, potentially
356 * excluding one of the connected coherent masters to avoid sending a packet
357 * back to where it came from.
358 *
359 * @param pkt Packet to forward
360 * @param exclude_slave_port_id Id of slave port to exclude
361 * @param source_master_port_id Id of the master port for snoops from below
362 * @param dests Vector of destination ports for the forwarded pkt
363 *
364 * @return a pair containing the snoop response and snoop latency
365 */
366 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt,
367 PortID exclude_slave_port_id,
368 PortID source_master_port_id,
369 const std::vector<QueuedSlavePort*>&
370 dests);
371
372 /** Function called by the port when the crossbar is recieving a Functional
373 transaction.*/
374 void recvFunctional(PacketPtr pkt, PortID slave_port_id);
375
376 /** Function called by the port when the crossbar is recieving a functional
377 snoop transaction.*/
378 void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id);
379
380 /**
381 * Forward a functional packet to our snoopers, potentially
382 * excluding one of the connected coherent masters to avoid
383 * sending a packet back to where it came from.
384 *
385 * @param pkt Packet to forward
386 * @param exclude_slave_port_id Id of slave port to exclude
387 */
388 void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id);
389
390 /**
391 * Determine if the crossbar should sink the packet, as opposed to
392 * forwarding it, or responding.
393 */
394 bool sinkPacket(const PacketPtr pkt) const;
395
396 Stats::Scalar snoops;
397 Stats::Scalar snoopTraffic;
398 Stats::Distribution snoopFanout;
399
400 public:
401
402 virtual void init();
403
404 CoherentXBar(const CoherentXBarParams *p);
405
406 virtual ~CoherentXBar();
407
408 virtual void regStats();
409};
410
411#endif //__MEM_COHERENT_XBAR_HH__
56#include "mem/snoop_filter.hh"
57#include "mem/xbar.hh"
58#include "params/CoherentXBar.hh"
59
60/**
61 * A coherent crossbar connects a number of (potentially) snooping
62 * masters and slaves, and routes the request and response packets
63 * based on the address, and also forwards all requests to the
64 * snoopers and deals with the snoop responses.
65 *
66 * The coherent crossbar can be used as a template for modelling QPI,
67 * HyperTransport, ACE and coherent OCP buses, and is typically used
68 * for the L1-to-L2 buses and as the main system interconnect. @sa
69 * \ref gem5MemorySystem "gem5 Memory System"
70 */
71class CoherentXBar : public BaseXBar
72{
73
74 protected:
75
76 /**
77 * Declare the layers of this crossbar, one vector for requests,
78 * one for responses, and one for snoop responses
79 */
80 std::vector<ReqLayer*> reqLayers;
81 std::vector<RespLayer*> respLayers;
82 std::vector<SnoopRespLayer*> snoopLayers;
83
84 /**
85 * Declaration of the coherent crossbar slave port type, one will
86 * be instantiated for each of the master ports connecting to the
87 * crossbar.
88 */
89 class CoherentXBarSlavePort : public QueuedSlavePort
90 {
91
92 private:
93
94 /** A reference to the crossbar to which this port belongs. */
95 CoherentXBar &xbar;
96
97 /** A normal packet queue used to store responses. */
98 RespPacketQueue queue;
99
100 public:
101
102 CoherentXBarSlavePort(const std::string &_name,
103 CoherentXBar &_xbar, PortID _id)
104 : QueuedSlavePort(_name, &_xbar, queue, _id), xbar(_xbar),
105 queue(_xbar, *this)
106 { }
107
108 protected:
109
110 /**
111 * When receiving a timing request, pass it to the crossbar.
112 */
113 virtual bool recvTimingReq(PacketPtr pkt)
114 { return xbar.recvTimingReq(pkt, id); }
115
116 /**
117 * When receiving a timing snoop response, pass it to the crossbar.
118 */
119 virtual bool recvTimingSnoopResp(PacketPtr pkt)
120 { return xbar.recvTimingSnoopResp(pkt, id); }
121
122 /**
123 * When receiving an atomic request, pass it to the crossbar.
124 */
125 virtual Tick recvAtomic(PacketPtr pkt)
126 { return xbar.recvAtomic(pkt, id); }
127
128 /**
129 * When receiving a functional request, pass it to the crossbar.
130 */
131 virtual void recvFunctional(PacketPtr pkt)
132 { xbar.recvFunctional(pkt, id); }
133
134 /**
135 * Return the union of all adress ranges seen by this crossbar.
136 */
137 virtual AddrRangeList getAddrRanges() const
138 { return xbar.getAddrRanges(); }
139
140 };
141
142 /**
143 * Declaration of the coherent crossbar master port type, one will be
144 * instantiated for each of the slave interfaces connecting to the
145 * crossbar.
146 */
147 class CoherentXBarMasterPort : public MasterPort
148 {
149 private:
150 /** A reference to the crossbar to which this port belongs. */
151 CoherentXBar &xbar;
152
153 public:
154
155 CoherentXBarMasterPort(const std::string &_name,
156 CoherentXBar &_xbar, PortID _id)
157 : MasterPort(_name, &_xbar, _id), xbar(_xbar)
158 { }
159
160 protected:
161
162 /**
163 * Determine if this port should be considered a snooper. For
164 * a coherent crossbar master port this is always true.
165 *
166 * @return a boolean that is true if this port is snooping
167 */
168 virtual bool isSnooping() const
169 { return true; }
170
171 /**
172 * When receiving a timing response, pass it to the crossbar.
173 */
174 virtual bool recvTimingResp(PacketPtr pkt)
175 { return xbar.recvTimingResp(pkt, id); }
176
177 /**
178 * When receiving a timing snoop request, pass it to the crossbar.
179 */
180 virtual void recvTimingSnoopReq(PacketPtr pkt)
181 { return xbar.recvTimingSnoopReq(pkt, id); }
182
183 /**
184 * When receiving an atomic snoop request, pass it to the crossbar.
185 */
186 virtual Tick recvAtomicSnoop(PacketPtr pkt)
187 { return xbar.recvAtomicSnoop(pkt, id); }
188
189 /**
190 * When receiving a functional snoop request, pass it to the crossbar.
191 */
192 virtual void recvFunctionalSnoop(PacketPtr pkt)
193 { xbar.recvFunctionalSnoop(pkt, id); }
194
195 /** When reciving a range change from the peer port (at id),
196 pass it to the crossbar. */
197 virtual void recvRangeChange()
198 { xbar.recvRangeChange(id); }
199
200 /** When reciving a retry from the peer port (at id),
201 pass it to the crossbar. */
202 virtual void recvReqRetry()
203 { xbar.recvReqRetry(id); }
204
205 };
206
207 /**
208 * Internal class to bridge between an incoming snoop response
209 * from a slave port and forwarding it through an outgoing slave
210 * port. It is effectively a dangling master port.
211 */
212 class SnoopRespPort : public MasterPort
213 {
214
215 private:
216
217 /** The port which we mirror internally. */
218 QueuedSlavePort& slavePort;
219
220 public:
221
222 /**
223 * Create a snoop response port that mirrors a given slave port.
224 */
225 SnoopRespPort(QueuedSlavePort& slave_port, CoherentXBar& _xbar) :
226 MasterPort(slave_port.name() + ".snoopRespPort", &_xbar),
227 slavePort(slave_port) { }
228
229 /**
230 * Override the sending of retries and pass them on through
231 * the mirrored slave port.
232 */
233 void sendRetryResp() {
234 // forward it as a snoop response retry
235 slavePort.sendRetrySnoopResp();
236 }
237
238 /**
239 * Provided as necessary.
240 */
241 void recvReqRetry() { panic("SnoopRespPort should never see retry\n"); }
242
243 /**
244 * Provided as necessary.
245 */
246 bool recvTimingResp(PacketPtr pkt)
247 {
248 panic("SnoopRespPort should never see timing response\n");
249 return false;
250 }
251
252 };
253
254 std::vector<SnoopRespPort*> snoopRespPorts;
255
256 std::vector<QueuedSlavePort*> snoopPorts;
257
258 /**
259 * Store the outstanding requests that we are expecting snoop
260 * responses from so we can determine which snoop responses we
261 * generated and which ones were merely forwarded.
262 */
263 std::unordered_set<RequestPtr> outstandingSnoop;
264
265 /**
266 * Keep a pointer to the system to be allow to querying memory system
267 * properties.
268 */
269 System *system;
270
271 /** A snoop filter that tracks cache line residency and can restrict the
272 * broadcast needed for probes. NULL denotes an absent filter. */
273 SnoopFilter *snoopFilter;
274
275 /** Cycles of snoop response latency.*/
276 const Cycles snoopResponseLatency;
277
278 /** Is this crossbar the point of coherency? **/
279 const bool pointOfCoherency;
280
281 /**
282 * Upstream caches need this packet until true is returned, so
283 * hold it for deletion until a subsequent call
284 */
285 std::unique_ptr<Packet> pendingDelete;
286
287 /** Function called by the port when the crossbar is recieving a Timing
288 request packet.*/
289 bool recvTimingReq(PacketPtr pkt, PortID slave_port_id);
290
291 /** Function called by the port when the crossbar is recieving a Timing
292 response packet.*/
293 bool recvTimingResp(PacketPtr pkt, PortID master_port_id);
294
295 /** Function called by the port when the crossbar is recieving a timing
296 snoop request.*/
297 void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id);
298
299 /** Function called by the port when the crossbar is recieving a timing
300 snoop response.*/
301 bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id);
302
303 /** Timing function called by port when it is once again able to process
304 * requests. */
305 void recvReqRetry(PortID master_port_id);
306
307 /**
308 * Forward a timing packet to our snoopers, potentially excluding
309 * one of the connected coherent masters to avoid sending a packet
310 * back to where it came from.
311 *
312 * @param pkt Packet to forward
313 * @param exclude_slave_port_id Id of slave port to exclude
314 */
315 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id) {
316 forwardTiming(pkt, exclude_slave_port_id, snoopPorts);
317 }
318
319 /**
320 * Forward a timing packet to a selected list of snoopers, potentially
321 * excluding one of the connected coherent masters to avoid sending a packet
322 * back to where it came from.
323 *
324 * @param pkt Packet to forward
325 * @param exclude_slave_port_id Id of slave port to exclude
326 * @param dests Vector of destination ports for the forwarded pkt
327 */
328 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
329 const std::vector<QueuedSlavePort*>& dests);
330
331 /** Function called by the port when the crossbar is recieving a Atomic
332 transaction.*/
333 Tick recvAtomic(PacketPtr pkt, PortID slave_port_id);
334
335 /** Function called by the port when the crossbar is recieving an
336 atomic snoop transaction.*/
337 Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id);
338
339 /**
340 * Forward an atomic packet to our snoopers, potentially excluding
341 * one of the connected coherent masters to avoid sending a packet
342 * back to where it came from.
343 *
344 * @param pkt Packet to forward
345 * @param exclude_slave_port_id Id of slave port to exclude
346 *
347 * @return a pair containing the snoop response and snoop latency
348 */
349 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt,
350 PortID exclude_slave_port_id)
351 {
352 return forwardAtomic(pkt, exclude_slave_port_id, InvalidPortID,
353 snoopPorts);
354 }
355
356 /**
357 * Forward an atomic packet to a selected list of snoopers, potentially
358 * excluding one of the connected coherent masters to avoid sending a packet
359 * back to where it came from.
360 *
361 * @param pkt Packet to forward
362 * @param exclude_slave_port_id Id of slave port to exclude
363 * @param source_master_port_id Id of the master port for snoops from below
364 * @param dests Vector of destination ports for the forwarded pkt
365 *
366 * @return a pair containing the snoop response and snoop latency
367 */
368 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt,
369 PortID exclude_slave_port_id,
370 PortID source_master_port_id,
371 const std::vector<QueuedSlavePort*>&
372 dests);
373
374 /** Function called by the port when the crossbar is recieving a Functional
375 transaction.*/
376 void recvFunctional(PacketPtr pkt, PortID slave_port_id);
377
378 /** Function called by the port when the crossbar is recieving a functional
379 snoop transaction.*/
380 void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id);
381
382 /**
383 * Forward a functional packet to our snoopers, potentially
384 * excluding one of the connected coherent masters to avoid
385 * sending a packet back to where it came from.
386 *
387 * @param pkt Packet to forward
388 * @param exclude_slave_port_id Id of slave port to exclude
389 */
390 void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id);
391
392 /**
393 * Determine if the crossbar should sink the packet, as opposed to
394 * forwarding it, or responding.
395 */
396 bool sinkPacket(const PacketPtr pkt) const;
397
398 Stats::Scalar snoops;
399 Stats::Scalar snoopTraffic;
400 Stats::Distribution snoopFanout;
401
402 public:
403
404 virtual void init();
405
406 CoherentXBar(const CoherentXBarParams *p);
407
408 virtual ~CoherentXBar();
409
410 virtual void regStats();
411};
412
413#endif //__MEM_COHERENT_XBAR_HH__