1/* 2 * Copyright (c) 2011-2015, 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) 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, 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) 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_map>
|
54#include <unordered_set> 55 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 /**
| 55#include <unordered_set> 56 57#include "mem/snoop_filter.hh" 58#include "mem/xbar.hh" 59#include "params/CoherentXBar.hh" 60 61/** 62 * A coherent crossbar connects a number of (potentially) snooping 63 * masters and slaves, and routes the request and response packets 64 * based on the address, and also forwards all requests to the 65 * snoopers and deals with the snoop responses. 66 * 67 * The coherent crossbar can be used as a template for modelling QPI, 68 * HyperTransport, ACE and coherent OCP buses, and is typically used 69 * for the L1-to-L2 buses and as the main system interconnect. @sa 70 * \ref gem5MemorySystem "gem5 Memory System" 71 */ 72class CoherentXBar : public BaseXBar 73{ 74 75 protected: 76 77 /** 78 * Declare the layers of this crossbar, one vector for requests, 79 * one for responses, and one for snoop responses 80 */ 81 std::vector<ReqLayer*> reqLayers; 82 std::vector<RespLayer*> respLayers; 83 std::vector<SnoopRespLayer*> snoopLayers; 84 85 /** 86 * Declaration of the coherent crossbar slave port type, one will 87 * be instantiated for each of the master ports connecting to the 88 * crossbar. 89 */ 90 class CoherentXBarSlavePort : public QueuedSlavePort 91 { 92 93 private: 94 95 /** A reference to the crossbar to which this port belongs. */ 96 CoherentXBar &xbar; 97 98 /** A normal packet queue used to store responses. */ 99 RespPacketQueue queue; 100 101 public: 102 103 CoherentXBarSlavePort(const std::string &_name, 104 CoherentXBar &_xbar, PortID _id) 105 : QueuedSlavePort(_name, &_xbar, queue, _id), xbar(_xbar), 106 queue(_xbar, *this) 107 { } 108 109 protected: 110 111 /** 112 * When receiving a timing request, pass it to the crossbar. 113 */ 114 virtual bool recvTimingReq(PacketPtr pkt) 115 { return xbar.recvTimingReq(pkt, id); } 116 117 /** 118 * When receiving a timing snoop response, pass it to the crossbar. 119 */ 120 virtual bool recvTimingSnoopResp(PacketPtr pkt) 121 { return xbar.recvTimingSnoopResp(pkt, id); } 122 123 /** 124 * When receiving an atomic request, pass it to the crossbar. 125 */ 126 virtual Tick recvAtomic(PacketPtr pkt) 127 { return xbar.recvAtomic(pkt, id); } 128 129 /** 130 * When receiving a functional request, pass it to the crossbar. 131 */ 132 virtual void recvFunctional(PacketPtr pkt) 133 { xbar.recvFunctional(pkt, id); } 134 135 /** 136 * Return the union of all adress ranges seen by this crossbar. 137 */ 138 virtual AddrRangeList getAddrRanges() const 139 { return xbar.getAddrRanges(); } 140 141 }; 142 143 /** 144 * Declaration of the coherent crossbar master port type, one will be 145 * instantiated for each of the slave interfaces connecting to the 146 * crossbar. 147 */ 148 class CoherentXBarMasterPort : public MasterPort 149 { 150 private: 151 /** A reference to the crossbar to which this port belongs. */ 152 CoherentXBar &xbar; 153 154 public: 155 156 CoherentXBarMasterPort(const std::string &_name, 157 CoherentXBar &_xbar, PortID _id) 158 : MasterPort(_name, &_xbar, _id), xbar(_xbar) 159 { } 160 161 protected: 162 163 /** 164 * Determine if this port should be considered a snooper. For 165 * a coherent crossbar master port this is always true. 166 * 167 * @return a boolean that is true if this port is snooping 168 */ 169 virtual bool isSnooping() const 170 { return true; } 171 172 /** 173 * When receiving a timing response, pass it to the crossbar. 174 */ 175 virtual bool recvTimingResp(PacketPtr pkt) 176 { return xbar.recvTimingResp(pkt, id); } 177 178 /** 179 * When receiving a timing snoop request, pass it to the crossbar. 180 */ 181 virtual void recvTimingSnoopReq(PacketPtr pkt) 182 { return xbar.recvTimingSnoopReq(pkt, id); } 183 184 /** 185 * When receiving an atomic snoop request, pass it to the crossbar. 186 */ 187 virtual Tick recvAtomicSnoop(PacketPtr pkt) 188 { return xbar.recvAtomicSnoop(pkt, id); } 189 190 /** 191 * When receiving a functional snoop request, pass it to the crossbar. 192 */ 193 virtual void recvFunctionalSnoop(PacketPtr pkt) 194 { xbar.recvFunctionalSnoop(pkt, id); } 195 196 /** When reciving a range change from the peer port (at id), 197 pass it to the crossbar. */ 198 virtual void recvRangeChange() 199 { xbar.recvRangeChange(id); } 200 201 /** When reciving a retry from the peer port (at id), 202 pass it to the crossbar. */ 203 virtual void recvReqRetry() 204 { xbar.recvReqRetry(id); } 205 206 }; 207 208 /** 209 * Internal class to bridge between an incoming snoop response 210 * from a slave port and forwarding it through an outgoing slave 211 * port. It is effectively a dangling master port. 212 */ 213 class SnoopRespPort : public MasterPort 214 { 215 216 private: 217 218 /** The port which we mirror internally. */ 219 QueuedSlavePort& slavePort; 220 221 public: 222 223 /** 224 * Create a snoop response port that mirrors a given slave port. 225 */ 226 SnoopRespPort(QueuedSlavePort& slave_port, CoherentXBar& _xbar) : 227 MasterPort(slave_port.name() + ".snoopRespPort", &_xbar), 228 slavePort(slave_port) { } 229 230 /** 231 * Override the sending of retries and pass them on through 232 * the mirrored slave port. 233 */ 234 void sendRetryResp() { 235 // forward it as a snoop response retry 236 slavePort.sendRetrySnoopResp(); 237 } 238 239 /** 240 * Provided as necessary. 241 */ 242 void recvReqRetry() { panic("SnoopRespPort should never see retry\n"); } 243 244 /** 245 * Provided as necessary. 246 */ 247 bool recvTimingResp(PacketPtr pkt) 248 { 249 panic("SnoopRespPort should never see timing response\n"); 250 return false; 251 } 252 253 }; 254 255 std::vector<SnoopRespPort*> snoopRespPorts; 256 257 std::vector<QueuedSlavePort*> snoopPorts; 258 259 /** 260 * Store the outstanding requests that we are expecting snoop 261 * responses from so we can determine which snoop responses we 262 * generated and which ones were merely forwarded. 263 */ 264 std::unordered_set<RequestPtr> outstandingSnoop; 265 266 /**
|
| 267 * Store the outstanding cache maintenance that we are expecting 268 * snoop responses from so we can determine when we received all 269 * snoop responses and if any of the agents satisfied the request. 270 */ 271 std::unordered_map<PacketId, PacketPtr> outstandingCMO; 272 273 /**
|
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 /** Is this crossbar the point of unification? **/ 282 const bool pointOfUnification; 283 284 /** 285 * Upstream caches need this packet until true is returned, so 286 * hold it for deletion until a subsequent call 287 */ 288 std::unique_ptr<Packet> pendingDelete; 289 290 /** Function called by the port when the crossbar is recieving a Timing 291 request packet.*/ 292 bool recvTimingReq(PacketPtr pkt, PortID slave_port_id); 293 294 /** Function called by the port when the crossbar is recieving a Timing 295 response packet.*/ 296 bool recvTimingResp(PacketPtr pkt, PortID master_port_id); 297 298 /** Function called by the port when the crossbar is recieving a timing 299 snoop request.*/ 300 void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id); 301 302 /** Function called by the port when the crossbar is recieving a timing 303 snoop response.*/ 304 bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id); 305 306 /** Timing function called by port when it is once again able to process 307 * requests. */ 308 void recvReqRetry(PortID master_port_id); 309 310 /** 311 * Forward a timing packet to our snoopers, potentially excluding 312 * one of the connected coherent masters to avoid sending a packet 313 * back to where it came from. 314 * 315 * @param pkt Packet to forward 316 * @param exclude_slave_port_id Id of slave port to exclude 317 */ 318 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id) { 319 forwardTiming(pkt, exclude_slave_port_id, snoopPorts); 320 } 321 322 /** 323 * Forward a timing packet to a selected list of snoopers, potentially 324 * excluding one of the connected coherent masters to avoid sending a packet 325 * back to where it came from. 326 * 327 * @param pkt Packet to forward 328 * @param exclude_slave_port_id Id of slave port to exclude 329 * @param dests Vector of destination ports for the forwarded pkt 330 */ 331 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id, 332 const std::vector<QueuedSlavePort*>& dests); 333 334 /** Function called by the port when the crossbar is recieving a Atomic 335 transaction.*/ 336 Tick recvAtomic(PacketPtr pkt, PortID slave_port_id); 337 338 /** Function called by the port when the crossbar is recieving an 339 atomic snoop transaction.*/ 340 Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id); 341 342 /** 343 * Forward an atomic packet to our snoopers, potentially excluding 344 * one of the connected coherent masters to avoid sending a packet 345 * back to where it came from. 346 * 347 * @param pkt Packet to forward 348 * @param exclude_slave_port_id Id of slave port to exclude 349 * 350 * @return a pair containing the snoop response and snoop latency 351 */ 352 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt, 353 PortID exclude_slave_port_id) 354 { 355 return forwardAtomic(pkt, exclude_slave_port_id, InvalidPortID, 356 snoopPorts); 357 } 358 359 /** 360 * Forward an atomic packet to a selected list of snoopers, potentially 361 * excluding one of the connected coherent masters to avoid sending a packet 362 * back to where it came from. 363 * 364 * @param pkt Packet to forward 365 * @param exclude_slave_port_id Id of slave port to exclude 366 * @param source_master_port_id Id of the master port for snoops from below 367 * @param dests Vector of destination ports for the forwarded pkt 368 * 369 * @return a pair containing the snoop response and snoop latency 370 */ 371 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt, 372 PortID exclude_slave_port_id, 373 PortID source_master_port_id, 374 const std::vector<QueuedSlavePort*>& 375 dests); 376 377 /** Function called by the port when the crossbar is recieving a Functional 378 transaction.*/ 379 void recvFunctional(PacketPtr pkt, PortID slave_port_id); 380 381 /** Function called by the port when the crossbar is recieving a functional 382 snoop transaction.*/ 383 void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id); 384 385 /** 386 * Forward a functional packet to our snoopers, potentially 387 * excluding one of the connected coherent masters to avoid 388 * sending a packet back to where it came from. 389 * 390 * @param pkt Packet to forward 391 * @param exclude_slave_port_id Id of slave port to exclude 392 */ 393 void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id); 394 395 /** 396 * Determine if the crossbar should sink the packet, as opposed to 397 * forwarding it, or responding. 398 */ 399 bool sinkPacket(const PacketPtr pkt) const; 400 401 /** 402 * Determine if the crossbar should forward the packet, as opposed to 403 * responding to it. 404 */ 405 bool forwardPacket(const PacketPtr pkt); 406 407 /** 408 * Determine if the packet's destination is the memory below 409 * 410 * The memory below is the destination for a cache mainteance 411 * operation to the Point of Coherence/Unification if this is the 412 * Point of Coherence/Unification. 413 * 414 * @param pkt The processed packet 415 * 416 * @return Whether the memory below is the destination for the packet 417 */ 418 bool isDestination(const PacketPtr pkt) const 419 { 420 return (pkt->req->isToPOC() && pointOfCoherency) || 421 (pkt->req->isToPOU() && pointOfUnification); 422 } 423 424 Stats::Scalar snoops; 425 Stats::Scalar snoopTraffic; 426 Stats::Distribution snoopFanout; 427 428 public: 429 430 virtual void init(); 431 432 CoherentXBar(const CoherentXBarParams *p); 433 434 virtual ~CoherentXBar(); 435 436 virtual void regStats(); 437}; 438 439#endif //__MEM_COHERENT_XBAR_HH__
| 274 * Keep a pointer to the system to be allow to querying memory system 275 * properties. 276 */ 277 System *system; 278 279 /** A snoop filter that tracks cache line residency and can restrict the 280 * broadcast needed for probes. NULL denotes an absent filter. */ 281 SnoopFilter *snoopFilter; 282 283 /** Cycles of snoop response latency.*/ 284 const Cycles snoopResponseLatency; 285 286 /** Is this crossbar the point of coherency? **/ 287 const bool pointOfCoherency; 288 289 /** Is this crossbar the point of unification? **/ 290 const bool pointOfUnification; 291 292 /** 293 * Upstream caches need this packet until true is returned, so 294 * hold it for deletion until a subsequent call 295 */ 296 std::unique_ptr<Packet> pendingDelete; 297 298 /** Function called by the port when the crossbar is recieving a Timing 299 request packet.*/ 300 bool recvTimingReq(PacketPtr pkt, PortID slave_port_id); 301 302 /** Function called by the port when the crossbar is recieving a Timing 303 response packet.*/ 304 bool recvTimingResp(PacketPtr pkt, PortID master_port_id); 305 306 /** Function called by the port when the crossbar is recieving a timing 307 snoop request.*/ 308 void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id); 309 310 /** Function called by the port when the crossbar is recieving a timing 311 snoop response.*/ 312 bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id); 313 314 /** Timing function called by port when it is once again able to process 315 * requests. */ 316 void recvReqRetry(PortID master_port_id); 317 318 /** 319 * Forward a timing packet to our snoopers, potentially excluding 320 * one of the connected coherent masters to avoid sending a packet 321 * back to where it came from. 322 * 323 * @param pkt Packet to forward 324 * @param exclude_slave_port_id Id of slave port to exclude 325 */ 326 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id) { 327 forwardTiming(pkt, exclude_slave_port_id, snoopPorts); 328 } 329 330 /** 331 * Forward a timing packet to a selected list of snoopers, potentially 332 * excluding one of the connected coherent masters to avoid sending a packet 333 * back to where it came from. 334 * 335 * @param pkt Packet to forward 336 * @param exclude_slave_port_id Id of slave port to exclude 337 * @param dests Vector of destination ports for the forwarded pkt 338 */ 339 void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id, 340 const std::vector<QueuedSlavePort*>& dests); 341 342 /** Function called by the port when the crossbar is recieving a Atomic 343 transaction.*/ 344 Tick recvAtomic(PacketPtr pkt, PortID slave_port_id); 345 346 /** Function called by the port when the crossbar is recieving an 347 atomic snoop transaction.*/ 348 Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id); 349 350 /** 351 * Forward an atomic packet to our snoopers, potentially excluding 352 * one of the connected coherent masters to avoid sending a packet 353 * back to where it came from. 354 * 355 * @param pkt Packet to forward 356 * @param exclude_slave_port_id Id of slave port to exclude 357 * 358 * @return a pair containing the snoop response and snoop latency 359 */ 360 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt, 361 PortID exclude_slave_port_id) 362 { 363 return forwardAtomic(pkt, exclude_slave_port_id, InvalidPortID, 364 snoopPorts); 365 } 366 367 /** 368 * Forward an atomic packet to a selected list of snoopers, potentially 369 * excluding one of the connected coherent masters to avoid sending a packet 370 * back to where it came from. 371 * 372 * @param pkt Packet to forward 373 * @param exclude_slave_port_id Id of slave port to exclude 374 * @param source_master_port_id Id of the master port for snoops from below 375 * @param dests Vector of destination ports for the forwarded pkt 376 * 377 * @return a pair containing the snoop response and snoop latency 378 */ 379 std::pair<MemCmd, Tick> forwardAtomic(PacketPtr pkt, 380 PortID exclude_slave_port_id, 381 PortID source_master_port_id, 382 const std::vector<QueuedSlavePort*>& 383 dests); 384 385 /** Function called by the port when the crossbar is recieving a Functional 386 transaction.*/ 387 void recvFunctional(PacketPtr pkt, PortID slave_port_id); 388 389 /** Function called by the port when the crossbar is recieving a functional 390 snoop transaction.*/ 391 void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id); 392 393 /** 394 * Forward a functional packet to our snoopers, potentially 395 * excluding one of the connected coherent masters to avoid 396 * sending a packet back to where it came from. 397 * 398 * @param pkt Packet to forward 399 * @param exclude_slave_port_id Id of slave port to exclude 400 */ 401 void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id); 402 403 /** 404 * Determine if the crossbar should sink the packet, as opposed to 405 * forwarding it, or responding. 406 */ 407 bool sinkPacket(const PacketPtr pkt) const; 408 409 /** 410 * Determine if the crossbar should forward the packet, as opposed to 411 * responding to it. 412 */ 413 bool forwardPacket(const PacketPtr pkt); 414 415 /** 416 * Determine if the packet's destination is the memory below 417 * 418 * The memory below is the destination for a cache mainteance 419 * operation to the Point of Coherence/Unification if this is the 420 * Point of Coherence/Unification. 421 * 422 * @param pkt The processed packet 423 * 424 * @return Whether the memory below is the destination for the packet 425 */ 426 bool isDestination(const PacketPtr pkt) const 427 { 428 return (pkt->req->isToPOC() && pointOfCoherency) || 429 (pkt->req->isToPOU() && pointOfUnification); 430 } 431 432 Stats::Scalar snoops; 433 Stats::Scalar snoopTraffic; 434 Stats::Distribution snoopFanout; 435 436 public: 437 438 virtual void init(); 439 440 CoherentXBar(const CoherentXBarParams *p); 441 442 virtual ~CoherentXBar(); 443 444 virtual void regStats(); 445}; 446 447#endif //__MEM_COHERENT_XBAR_HH__
|