coherent_xbar.cc revision 9091
15245Sgblack@eecs.umich.edu/* 25245Sgblack@eecs.umich.edu * Copyright (c) 2011-2012 ARM Limited 35245Sgblack@eecs.umich.edu * All rights reserved 45245Sgblack@eecs.umich.edu * 57087Snate@binkert.org * The license below extends only to copyright in the software and shall 67087Snate@binkert.org * not be construed as granting a license to any other intellectual 77087Snate@binkert.org * property including but not limited to intellectual property relating 87087Snate@binkert.org * to a hardware implementation of the functionality of the software 97087Snate@binkert.org * licensed hereunder. You may use the software subject to the license 107087Snate@binkert.org * terms below provided that you ensure that this notice is replicated 117087Snate@binkert.org * unmodified and in its entirety in all distributions of the software, 127087Snate@binkert.org * modified or unmodified, in source code or in binary form. 135245Sgblack@eecs.umich.edu * 147087Snate@binkert.org * Copyright (c) 2006 The Regents of The University of Michigan 157087Snate@binkert.org * All rights reserved. 167087Snate@binkert.org * 177087Snate@binkert.org * Redistribution and use in source and binary forms, with or without 187087Snate@binkert.org * modification, are permitted provided that the following conditions are 197087Snate@binkert.org * met: redistributions of source code must retain the above copyright 207087Snate@binkert.org * notice, this list of conditions and the following disclaimer; 217087Snate@binkert.org * redistributions in binary form must reproduce the above copyright 225245Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the 237087Snate@binkert.org * documentation and/or other materials provided with the distribution; 245245Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its 255245Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 265245Sgblack@eecs.umich.edu * this software without specific prior written permission. 275245Sgblack@eecs.umich.edu * 285245Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 295245Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 305245Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 315245Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 325245Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 335245Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 345245Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 355245Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 365245Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 375245Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 385245Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 395245Sgblack@eecs.umich.edu * 405245Sgblack@eecs.umich.edu * Authors: Ali Saidi 415245Sgblack@eecs.umich.edu * Andreas Hansson 425245Sgblack@eecs.umich.edu * William Wang 435245Sgblack@eecs.umich.edu */ 445245Sgblack@eecs.umich.edu 455245Sgblack@eecs.umich.edu/** 465245Sgblack@eecs.umich.edu * @file 476216Snate@binkert.org * Definition of a bus object. 485245Sgblack@eecs.umich.edu */ 495245Sgblack@eecs.umich.edu 505245Sgblack@eecs.umich.edu#include "base/misc.hh" 517901Shestness@cs.utexas.edu#include "base/trace.hh" 528832SAli.Saidi@ARM.com#include "debug/BusAddrRanges.hh" 535245Sgblack@eecs.umich.edu#include "debug/CoherentBus.hh" 545245Sgblack@eecs.umich.edu#include "mem/coherent_bus.hh" 555245Sgblack@eecs.umich.edu 565245Sgblack@eecs.umich.eduCoherentBus::CoherentBus(const CoherentBusParams *p) 575245Sgblack@eecs.umich.edu : BaseBus(p) 585245Sgblack@eecs.umich.edu{ 595245Sgblack@eecs.umich.edu // create the ports based on the size of the master and slave 605245Sgblack@eecs.umich.edu // vector ports, and the presence of the default port, the ports 617912Shestness@cs.utexas.edu // are enumerated starting from zero 628922Swilliam.wang@arm.com for (int i = 0; i < p->port_master_connection_count; ++i) { 635245Sgblack@eecs.umich.edu std::string portName = csprintf("%s-p%d", name(), i); 645245Sgblack@eecs.umich.edu MasterPort* bp = new CoherentBusMasterPort(portName, *this, i); 655245Sgblack@eecs.umich.edu masterPorts.push_back(bp); 668922Swilliam.wang@arm.com } 675245Sgblack@eecs.umich.edu 685245Sgblack@eecs.umich.edu // see if we have a default slave device connected and if so add 695245Sgblack@eecs.umich.edu // our corresponding master port 708832SAli.Saidi@ARM.com if (p->port_default_connection_count) { 715245Sgblack@eecs.umich.edu defaultPortID = masterPorts.size(); 728975Sandreas.hansson@arm.com std::string portName = csprintf("%s-default", name()); 7310713Sandreas.hansson@arm.com MasterPort* bp = new CoherentBusMasterPort(portName, *this, 745245Sgblack@eecs.umich.edu defaultPortID); 755245Sgblack@eecs.umich.edu masterPorts.push_back(bp); 767912Shestness@cs.utexas.edu } 777912Shestness@cs.utexas.edu 785245Sgblack@eecs.umich.edu // create the slave ports, once again starting at zero 797912Shestness@cs.utexas.edu for (int i = 0; i < p->port_slave_connection_count; ++i) { 809044SAli.Saidi@ARM.com std::string portName = csprintf("%s-p%d", name(), i); 817912Shestness@cs.utexas.edu SlavePort* bp = new CoherentBusSlavePort(portName, *this, i); 829701Sgedare@rtems.org slavePorts.push_back(bp); 837912Shestness@cs.utexas.edu } 847912Shestness@cs.utexas.edu 857912Shestness@cs.utexas.edu clearPortCache(); 867912Shestness@cs.utexas.edu} 877912Shestness@cs.utexas.edu 887912Shestness@cs.utexas.eduvoid 897912Shestness@cs.utexas.eduCoherentBus::init() 907912Shestness@cs.utexas.edu{ 917912Shestness@cs.utexas.edu // iterate over our slave ports and determine which of our 927912Shestness@cs.utexas.edu // neighbouring master ports are snooping and add them as snoopers 937912Shestness@cs.utexas.edu for (SlavePortConstIter p = slavePorts.begin(); p != slavePorts.end(); 945245Sgblack@eecs.umich.edu ++p) { 957912Shestness@cs.utexas.edu // check if the connected master port is snooping 968832SAli.Saidi@ARM.com if ((*p)->isSnooping()) { 977912Shestness@cs.utexas.edu DPRINTF(BusAddrRanges, "Adding snooping master %s\n", 987912Shestness@cs.utexas.edu (*p)->getMasterPort().name()); 997912Shestness@cs.utexas.edu snoopPorts.push_back(*p); 1007912Shestness@cs.utexas.edu } 1017912Shestness@cs.utexas.edu } 1027912Shestness@cs.utexas.edu 1037912Shestness@cs.utexas.edu if (snoopPorts.empty()) 1047912Shestness@cs.utexas.edu warn("CoherentBus %s has no snooping ports attached!\n", name()); 1057912Shestness@cs.utexas.edu} 1067912Shestness@cs.utexas.edu 1077912Shestness@cs.utexas.edubool 1087912Shestness@cs.utexas.eduCoherentBus::recvTimingReq(PacketPtr pkt, PortID slave_port_id) 1097912Shestness@cs.utexas.edu{ 1107912Shestness@cs.utexas.edu // determine the source port based on the id 1117912Shestness@cs.utexas.edu SlavePort *src_port = slavePorts[slave_port_id]; 1127912Shestness@cs.utexas.edu 1137912Shestness@cs.utexas.edu // remember if the packet is an express snoop 1147912Shestness@cs.utexas.edu bool is_express_snoop = pkt->isExpressSnoop(); 1157912Shestness@cs.utexas.edu 11612749Sgiacomo.travaglini@arm.com // test if the bus should be considered occupied for the current 11712749Sgiacomo.travaglini@arm.com // port, and exclude express snoops from the check 11812749Sgiacomo.travaglini@arm.com if (!is_express_snoop && !tryTiming(src_port)) { 11912749Sgiacomo.travaglini@arm.com DPRINTF(CoherentBus, "recvTimingReq: src %s %s 0x%x BUSY\n", 12012749Sgiacomo.travaglini@arm.com src_port->name(), pkt->cmdString(), pkt->getAddr()); 12112749Sgiacomo.travaglini@arm.com return false; 1227912Shestness@cs.utexas.edu } 1237912Shestness@cs.utexas.edu 1247912Shestness@cs.utexas.edu DPRINTF(CoherentBus, "recvTimingReq: src %s %s expr %d 0x%x\n", 1257912Shestness@cs.utexas.edu src_port->name(), pkt->cmdString(), is_express_snoop, 1267912Shestness@cs.utexas.edu pkt->getAddr()); 1278953Sgblack@eecs.umich.edu 1287912Shestness@cs.utexas.edu // set the source port for routing of the response 1297912Shestness@cs.utexas.edu pkt->setSrc(slave_port_id); 1307912Shestness@cs.utexas.edu 1317912Shestness@cs.utexas.edu Tick headerFinishTime = is_express_snoop ? 0 : calcPacketTiming(pkt); 1327912Shestness@cs.utexas.edu Tick packetFinishTime = is_express_snoop ? 0 : pkt->finishTime; 1337912Shestness@cs.utexas.edu 1347912Shestness@cs.utexas.edu // uncacheable requests need never be snooped 1357912Shestness@cs.utexas.edu if (!pkt->req->isUncacheable()) { 1367912Shestness@cs.utexas.edu // the packet is a memory-mapped request and should be 1377912Shestness@cs.utexas.edu // broadcasted to our snoopers but the source 1387912Shestness@cs.utexas.edu forwardTiming(pkt, slave_port_id); 1397912Shestness@cs.utexas.edu } 1407912Shestness@cs.utexas.edu 1417912Shestness@cs.utexas.edu // remember if we add an outstanding req so we can undo it if 1427912Shestness@cs.utexas.edu // necessary, if the packet needs a response, we should add it 1437912Shestness@cs.utexas.edu // as outstanding and express snoops never fail so there is 1447912Shestness@cs.utexas.edu // not need to worry about them 1457912Shestness@cs.utexas.edu bool add_outstanding = !is_express_snoop && pkt->needsResponse(); 1467912Shestness@cs.utexas.edu 1477912Shestness@cs.utexas.edu // keep track that we have an outstanding request packet 1487912Shestness@cs.utexas.edu // matching this request, this is used by the coherency 1497912Shestness@cs.utexas.edu // mechanism in determining what to do with snoop responses 1507912Shestness@cs.utexas.edu // (in recvTimingSnoop) 1517912Shestness@cs.utexas.edu if (add_outstanding) { 1527912Shestness@cs.utexas.edu // we should never have an exsiting request outstanding 1539542Sandreas.hansson@arm.com assert(outstandingReq.find(pkt->req) == outstandingReq.end()); 1549542Sandreas.hansson@arm.com outstandingReq.insert(pkt->req); 1557912Shestness@cs.utexas.edu } 1567912Shestness@cs.utexas.edu 1577912Shestness@cs.utexas.edu // since it is a normal request, determine the destination 1587912Shestness@cs.utexas.edu // based on the address and attempt to send the packet 1597912Shestness@cs.utexas.edu bool success = masterPorts[findPort(pkt->getAddr())]->sendTimingReq(pkt); 16012749Sgiacomo.travaglini@arm.com 1617912Shestness@cs.utexas.edu // if this is an express snoop, we are done at this point 1628953Sgblack@eecs.umich.edu if (is_express_snoop) { 1639294Sandreas.hansson@arm.com assert(success); 1649294Sandreas.hansson@arm.com } else { 1657912Shestness@cs.utexas.edu // for normal requests, check if successful 1667912Shestness@cs.utexas.edu if (!success) { 1675245Sgblack@eecs.umich.edu // inhibited packets should never be forced to retry 1685245Sgblack@eecs.umich.edu assert(!pkt->memInhibitAsserted()); 1695245Sgblack@eecs.umich.edu 1708832SAli.Saidi@ARM.com // if it was added as outstanding and the send failed, then 1715245Sgblack@eecs.umich.edu // erase it again 1729701Sgedare@rtems.org if (add_outstanding) 1739701Sgedare@rtems.org outstandingReq.erase(pkt->req); 1749701Sgedare@rtems.org 1759701Sgedare@rtems.org DPRINTF(CoherentBus, "recvTimingReq: src %s %s 0x%x RETRY\n", 1769701Sgedare@rtems.org src_port->name(), pkt->cmdString(), pkt->getAddr()); 1779701Sgedare@rtems.org 17810654Sandreas.hansson@arm.com // update the bus state and schedule an idle event 17910654Sandreas.hansson@arm.com failedTiming(src_port, headerFinishTime); 18010654Sandreas.hansson@arm.com } else { 18112088Sspwilson2@wisc.edu // update the bus state and schedule an idle event 18210654Sandreas.hansson@arm.com succeededTiming(packetFinishTime); 1837912Shestness@cs.utexas.edu } 1848975Sandreas.hansson@arm.com } 18510713Sandreas.hansson@arm.com 1867912Shestness@cs.utexas.edu return success; 1875245Sgblack@eecs.umich.edu} 1885245Sgblack@eecs.umich.edu 1895245Sgblack@eecs.umich.edubool 1905245Sgblack@eecs.umich.eduCoherentBus::recvTimingResp(PacketPtr pkt, PortID master_port_id) 1915245Sgblack@eecs.umich.edu{ 1925245Sgblack@eecs.umich.edu // determine the source port based on the id 1935245Sgblack@eecs.umich.edu MasterPort *src_port = masterPorts[master_port_id]; 1945245Sgblack@eecs.umich.edu 1955245Sgblack@eecs.umich.edu // test if the bus should be considered occupied for the current 1965245Sgblack@eecs.umich.edu // port 1978832SAli.Saidi@ARM.com if (!tryTiming(src_port)) { 1988832SAli.Saidi@ARM.com DPRINTF(CoherentBus, "recvTimingResp: src %s %s 0x%x BUSY\n", 1998832SAli.Saidi@ARM.com src_port->name(), pkt->cmdString(), pkt->getAddr()); 2008832SAli.Saidi@ARM.com return false; 2018832SAli.Saidi@ARM.com } 2028832SAli.Saidi@ARM.com 2035245Sgblack@eecs.umich.edu DPRINTF(CoherentBus, "recvTimingResp: src %s %s 0x%x\n", 2047912Shestness@cs.utexas.edu src_port->name(), pkt->cmdString(), pkt->getAddr()); 2058832SAli.Saidi@ARM.com 20612680Sgiacomo.travaglini@arm.com calcPacketTiming(pkt); 20710654Sandreas.hansson@arm.com Tick packetFinishTime = pkt->finishTime; 20812088Sspwilson2@wisc.edu 2095245Sgblack@eecs.umich.edu // the packet is a normal response to a request that we should 2105245Sgblack@eecs.umich.edu // have seen passing through the bus 2115245Sgblack@eecs.umich.edu assert(outstandingReq.find(pkt->req) != outstandingReq.end()); 2125245Sgblack@eecs.umich.edu 2135245Sgblack@eecs.umich.edu // remove it as outstanding 214 outstandingReq.erase(pkt->req); 215 216 // send the packet to the destination through one of our slave 217 // ports, as determined by the destination field 218 bool success M5_VAR_USED = slavePorts[pkt->getDest()]->sendTimingResp(pkt); 219 220 // currently it is illegal to block responses... can lead to 221 // deadlock 222 assert(success); 223 224 succeededTiming(packetFinishTime); 225 226 return true; 227} 228 229void 230CoherentBus::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id) 231{ 232 DPRINTF(CoherentBus, "recvTimingSnoopReq: src %s %s 0x%x\n", 233 masterPorts[master_port_id]->name(), pkt->cmdString(), 234 pkt->getAddr()); 235 236 // we should only see express snoops from caches 237 assert(pkt->isExpressSnoop()); 238 239 // set the source port for routing of the response 240 pkt->setSrc(master_port_id); 241 242 // forward to all snoopers 243 forwardTiming(pkt, InvalidPortID); 244 245 // a snoop request came from a connected slave device (one of 246 // our master ports), and if it is not coming from the slave 247 // device responsible for the address range something is 248 // wrong, hence there is nothing further to do as the packet 249 // would be going back to where it came from 250 assert(master_port_id == findPort(pkt->getAddr())); 251} 252 253bool 254CoherentBus::recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id) 255{ 256 // determine the source port based on the id 257 SlavePort* src_port = slavePorts[slave_port_id]; 258 259 // test if the bus should be considered occupied for the current 260 // port 261 if (!tryTiming(src_port)) { 262 DPRINTF(CoherentBus, "recvTimingSnoopResp: src %s %s 0x%x BUSY\n", 263 src_port->name(), pkt->cmdString(), pkt->getAddr()); 264 return false; 265 } 266 267 DPRINTF(CoherentBus, "recvTimingSnoop: src %s %s 0x%x\n", 268 src_port->name(), pkt->cmdString(), pkt->getAddr()); 269 270 // get the destination from the packet 271 PortID dest = pkt->getDest(); 272 273 // responses are never express snoops 274 assert(!pkt->isExpressSnoop()); 275 276 calcPacketTiming(pkt); 277 Tick packetFinishTime = pkt->finishTime; 278 279 // determine if the response is from a snoop request we 280 // created as the result of a normal request (in which case it 281 // should be in the outstandingReq), or if we merely forwarded 282 // someone else's snoop request 283 if (outstandingReq.find(pkt->req) == outstandingReq.end()) { 284 // this is a snoop response to a snoop request we 285 // forwarded, e.g. coming from the L1 and going to the L2 286 // this should be forwarded as a snoop response 287 bool success M5_VAR_USED = masterPorts[dest]->sendTimingSnoopResp(pkt); 288 assert(success); 289 } else { 290 // we got a snoop response on one of our slave ports, 291 // i.e. from a coherent master connected to the bus, and 292 // since we created the snoop request as part of 293 // recvTiming, this should now be a normal response again 294 outstandingReq.erase(pkt->req); 295 296 // this is a snoop response from a coherent master, with a 297 // destination field set on its way through the bus as 298 // request, hence it should never go back to where the 299 // snoop response came from, but instead to where the 300 // original request came from 301 assert(slave_port_id != dest); 302 303 // as a normal response, it should go back to a master 304 // through one of our slave ports 305 bool success M5_VAR_USED = slavePorts[dest]->sendTimingResp(pkt); 306 307 // currently it is illegal to block responses... can lead 308 // to deadlock 309 assert(success); 310 } 311 312 succeededTiming(packetFinishTime); 313 314 return true; 315} 316 317 318void 319CoherentBus::forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id) 320{ 321 for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) { 322 SlavePort *p = *s; 323 // we could have gotten this request from a snooping master 324 // (corresponding to our own slave port that is also in 325 // snoopPorts) and should not send it back to where it came 326 // from 327 if (exclude_slave_port_id == InvalidPortID || 328 p->getId() != exclude_slave_port_id) { 329 // cache is not allowed to refuse snoop 330 p->sendTimingSnoopReq(pkt); 331 } 332 } 333} 334 335Tick 336CoherentBus::recvAtomic(PacketPtr pkt, PortID slave_port_id) 337{ 338 DPRINTF(CoherentBus, "recvAtomic: packet src %s addr 0x%x cmd %s\n", 339 slavePorts[slave_port_id]->name(), pkt->getAddr(), 340 pkt->cmdString()); 341 342 MemCmd snoop_response_cmd = MemCmd::InvalidCmd; 343 Tick snoop_response_latency = 0; 344 345 // uncacheable requests need never be snooped 346 if (!pkt->req->isUncacheable()) { 347 // forward to all snoopers but the source 348 std::pair<MemCmd, Tick> snoop_result = 349 forwardAtomic(pkt, slave_port_id); 350 snoop_response_cmd = snoop_result.first; 351 snoop_response_latency = snoop_result.second; 352 } 353 354 // even if we had a snoop response, we must continue and also 355 // perform the actual request at the destination 356 PortID dest_id = findPort(pkt->getAddr()); 357 358 // forward the request to the appropriate destination 359 Tick response_latency = masterPorts[dest_id]->sendAtomic(pkt); 360 361 // if we got a response from a snooper, restore it here 362 if (snoop_response_cmd != MemCmd::InvalidCmd) { 363 // no one else should have responded 364 assert(!pkt->isResponse()); 365 pkt->cmd = snoop_response_cmd; 366 response_latency = snoop_response_latency; 367 } 368 369 pkt->finishTime = curTick() + response_latency; 370 return response_latency; 371} 372 373Tick 374CoherentBus::recvAtomicSnoop(PacketPtr pkt, PortID master_port_id) 375{ 376 DPRINTF(CoherentBus, "recvAtomicSnoop: packet src %s addr 0x%x cmd %s\n", 377 masterPorts[master_port_id]->name(), pkt->getAddr(), 378 pkt->cmdString()); 379 380 // forward to all snoopers 381 std::pair<MemCmd, Tick> snoop_result = 382 forwardAtomic(pkt, InvalidPortID); 383 MemCmd snoop_response_cmd = snoop_result.first; 384 Tick snoop_response_latency = snoop_result.second; 385 386 if (snoop_response_cmd != MemCmd::InvalidCmd) 387 pkt->cmd = snoop_response_cmd; 388 389 pkt->finishTime = curTick() + snoop_response_latency; 390 return snoop_response_latency; 391} 392 393std::pair<MemCmd, Tick> 394CoherentBus::forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id) 395{ 396 // the packet may be changed on snoops, record the original 397 // command to enable us to restore it between snoops so that 398 // additional snoops can take place properly 399 MemCmd orig_cmd = pkt->cmd; 400 MemCmd snoop_response_cmd = MemCmd::InvalidCmd; 401 Tick snoop_response_latency = 0; 402 403 for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) { 404 SlavePort *p = *s; 405 // we could have gotten this request from a snooping master 406 // (corresponding to our own slave port that is also in 407 // snoopPorts) and should not send it back to where it came 408 // from 409 if (exclude_slave_port_id == InvalidPortID || 410 p->getId() != exclude_slave_port_id) { 411 Tick latency = p->sendAtomicSnoop(pkt); 412 // in contrast to a functional access, we have to keep on 413 // going as all snoopers must be updated even if we get a 414 // response 415 if (pkt->isResponse()) { 416 // response from snoop agent 417 assert(pkt->cmd != orig_cmd); 418 assert(pkt->memInhibitAsserted()); 419 // should only happen once 420 assert(snoop_response_cmd == MemCmd::InvalidCmd); 421 // save response state 422 snoop_response_cmd = pkt->cmd; 423 snoop_response_latency = latency; 424 // restore original packet state for remaining snoopers 425 pkt->cmd = orig_cmd; 426 } 427 } 428 } 429 430 // the packet is restored as part of the loop and any potential 431 // snoop response is part of the returned pair 432 return std::make_pair(snoop_response_cmd, snoop_response_latency); 433} 434 435void 436CoherentBus::recvFunctional(PacketPtr pkt, PortID slave_port_id) 437{ 438 if (!pkt->isPrint()) { 439 // don't do DPRINTFs on PrintReq as it clutters up the output 440 DPRINTF(CoherentBus, 441 "recvFunctional: packet src %s addr 0x%x cmd %s\n", 442 slavePorts[slave_port_id]->name(), pkt->getAddr(), 443 pkt->cmdString()); 444 } 445 446 // uncacheable requests need never be snooped 447 if (!pkt->req->isUncacheable()) { 448 // forward to all snoopers but the source 449 forwardFunctional(pkt, slave_port_id); 450 } 451 452 // there is no need to continue if the snooping has found what we 453 // were looking for and the packet is already a response 454 if (!pkt->isResponse()) { 455 PortID dest_id = findPort(pkt->getAddr()); 456 457 masterPorts[dest_id]->sendFunctional(pkt); 458 } 459} 460 461void 462CoherentBus::recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id) 463{ 464 if (!pkt->isPrint()) { 465 // don't do DPRINTFs on PrintReq as it clutters up the output 466 DPRINTF(CoherentBus, 467 "recvFunctionalSnoop: packet src %s addr 0x%x cmd %s\n", 468 masterPorts[master_port_id]->name(), pkt->getAddr(), 469 pkt->cmdString()); 470 } 471 472 // forward to all snoopers 473 forwardFunctional(pkt, InvalidPortID); 474} 475 476void 477CoherentBus::forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id) 478{ 479 for (SlavePortIter s = snoopPorts.begin(); s != snoopPorts.end(); ++s) { 480 SlavePort *p = *s; 481 // we could have gotten this request from a snooping master 482 // (corresponding to our own slave port that is also in 483 // snoopPorts) and should not send it back to where it came 484 // from 485 if (exclude_slave_port_id == InvalidPortID || 486 p->getId() != exclude_slave_port_id) 487 p->sendFunctionalSnoop(pkt); 488 489 // if we get a response we are done 490 if (pkt->isResponse()) { 491 break; 492 } 493 } 494} 495 496CoherentBus * 497CoherentBusParams::create() 498{ 499 return new CoherentBus(this); 500} 501