1/* 2 * Copyright (c) 2011-2016 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 --- 142 unchanged lines hidden (view full) --- 151 assert(is_express_snoop == cache_responding); 152 153 // determine the destination based on the address 154 PortID master_port_id = findPort(pkt->getAddr()); 155 156 // test if the crossbar should be considered occupied for the current 157 // port, and exclude express snoops from the check 158 if (!is_express_snoop && !reqLayers[master_port_id]->tryTiming(src_port)) { |
159 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__, 160 src_port->name(), pkt->print()); |
161 return false; 162 } 163 |
164 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 165 src_port->name(), pkt->print()); |
166 167 // store size and command as they might be modified when 168 // forwarding the packet 169 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 170 unsigned int pkt_cmd = pkt->cmdToIndex(); 171 172 // store the old header delay so we can restore it if needed 173 Tick old_header_delay = pkt->headerDelay; --- 14 unchanged lines hidden (view full) --- 188 // broadcasted to our snoopers but the source 189 if (snoopFilter) { 190 // check with the snoop filter where to forward this packet 191 auto sf_res = snoopFilter->lookupRequest(pkt, *src_port); 192 // the time required by a packet to be delivered through 193 // the xbar has to be charged also with to lookup latency 194 // of the snoop filter 195 pkt->headerDelay += sf_res.second * clockPeriod(); |
196 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n", 197 __func__, src_port->name(), pkt->print(), 198 sf_res.first.size(), sf_res.second); |
199 200 if (pkt->isEviction()) { 201 // for block-evicting packets, i.e. writebacks and 202 // clean evictions, there is no need to snoop up, as 203 // all we do is determine if the block is cached or 204 // not, instead just set it here based on the snoop 205 // filter result 206 if (!sf_res.first.empty()) --- 22 unchanged lines hidden (view full) --- 229 const bool sink_packet = sinkPacket(pkt); 230 231 // in certain cases the crossbar is responsible for responding 232 bool respond_directly = false; 233 // store the original address as an address mapper could possibly 234 // modify the address upon a sendTimingRequest 235 const Addr addr(pkt->getAddr()); 236 if (sink_packet) { |
237 DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__, 238 pkt->print()); |
239 } else { 240 // determine if we are forwarding the packet, or responding to 241 // it 242 if (!pointOfCoherency || pkt->isRead() || pkt->isWrite()) { 243 // if we are passing on, rather than sinking, a packet to 244 // which an upstream cache has committed to responding, 245 // the line was needs writable, and the responding only 246 // had an Owned copy, so we need to immidiately let the --- 23 unchanged lines hidden (view full) --- 270 // check if we were successful in sending the packet onwards 271 if (!success) { 272 // express snoops should never be forced to retry 273 assert(!is_express_snoop); 274 275 // restore the header delay 276 pkt->headerDelay = old_header_delay; 277 |
278 DPRINTF(CoherentXBar, "%s: src %s packet %s RETRY\n", __func__, 279 src_port->name(), pkt->print()); |
280 281 // update the layer state and schedule an idle event 282 reqLayers[master_port_id]->failedTiming(src_port, 283 clockEdge(Cycles(1))); 284 } else { 285 // express snoops currently bypass the crossbar state entirely 286 if (!is_express_snoop) { 287 // if this particular request will generate a snoop --- 68 unchanged lines hidden (view full) --- 356 assert(route_lookup != routeTo.end()); 357 const PortID slave_port_id = route_lookup->second; 358 assert(slave_port_id != InvalidPortID); 359 assert(slave_port_id < respLayers.size()); 360 361 // test if the crossbar should be considered occupied for the 362 // current port 363 if (!respLayers[slave_port_id]->tryTiming(src_port)) { |
364 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__, 365 src_port->name(), pkt->print()); |
366 return false; 367 } 368 |
369 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 370 src_port->name(), pkt->print()); |
371 372 // store size and command as they might be modified when 373 // forwarding the packet 374 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 375 unsigned int pkt_cmd = pkt->cmdToIndex(); 376 377 // a response sees the response latency 378 Tick xbar_delay = responseLatency * clockPeriod(); --- 26 unchanged lines hidden (view full) --- 405 transDist[pkt_cmd]++; 406 407 return true; 408} 409 410void 411CoherentXBar::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id) 412{ |
413 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 414 masterPorts[master_port_id]->name(), pkt->print()); |
415 416 // update stats here as we know the forwarding will succeed 417 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 418 transDist[pkt->cmdToIndex()]++; 419 snoops++; 420 snoopTraffic += pkt_size; 421 422 // we should only see express snoops from caches --- 11 unchanged lines hidden (view full) --- 434 435 if (snoopFilter) { 436 // let the Snoop Filter work its magic and guide probing 437 auto sf_res = snoopFilter->lookupSnoop(pkt); 438 // the time required by a packet to be delivered through 439 // the xbar has to be charged also with to lookup latency 440 // of the snoop filter 441 pkt->headerDelay += sf_res.second * clockPeriod(); |
442 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n", 443 __func__, masterPorts[master_port_id]->name(), pkt->print(), 444 sf_res.first.size(), sf_res.second); |
445 446 // forward to all snoopers 447 forwardTiming(pkt, InvalidPortID, sf_res.first); 448 } else { 449 forwardTiming(pkt, InvalidPortID); 450 } 451 452 // add the snoop delay to our header delay, and then reset it --- 35 unchanged lines hidden (view full) --- 488 489 // test if the crossbar should be considered occupied for the 490 // current port, note that the check is bypassed if the response 491 // is being passed on as a normal response since this is occupying 492 // the response layer rather than the snoop response layer 493 if (forwardAsSnoop) { 494 assert(dest_port_id < snoopLayers.size()); 495 if (!snoopLayers[dest_port_id]->tryTiming(src_port)) { |
496 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__, 497 src_port->name(), pkt->print()); |
498 return false; 499 } 500 } else { 501 // get the master port that mirrors this slave port internally 502 MasterPort* snoop_port = snoopRespPorts[slave_port_id]; 503 assert(dest_port_id < respLayers.size()); 504 if (!respLayers[dest_port_id]->tryTiming(snoop_port)) { |
505 DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__, 506 snoop_port->name(), pkt->print()); |
507 return false; 508 } 509 } 510 |
511 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 512 src_port->name(), pkt->print()); |
513 514 // store size and command as they might be modified when 515 // forwarding the packet 516 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 517 unsigned int pkt_cmd = pkt->cmdToIndex(); 518 519 // responses are never express snoops 520 assert(!pkt->isExpressSnoop()); --- 42 unchanged lines hidden (view full) --- 563 assert(slave_port_id != dest_port_id); 564 565 if (snoopFilter) { 566 // update the probe filter so that it can properly track the line 567 snoopFilter->updateSnoopResponse(pkt, *slavePorts[slave_port_id], 568 *slavePorts[dest_port_id]); 569 } 570 |
571 DPRINTF(CoherentXBar, "%s: src %s packet %s FWD RESP\n", __func__, 572 src_port->name(), pkt->print()); |
573 574 // as a normal response, it should go back to a master through 575 // one of our slave ports, we also pay for any outstanding 576 // header latency 577 Tick latency = pkt->headerDelay; 578 pkt->headerDelay = 0; 579 slavePorts[dest_port_id]->schedTimingResp(pkt, curTick() + latency); 580 --- 11 unchanged lines hidden (view full) --- 592 return true; 593} 594 595 596void 597CoherentXBar::forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id, 598 const std::vector<QueuedSlavePort*>& dests) 599{ |
600 DPRINTF(CoherentXBar, "%s for %s\n", __func__, pkt->print()); |
601 602 // snoops should only happen if the system isn't bypassing caches 603 assert(!system->bypassCaches()); 604 605 unsigned fanout = 0; 606 607 for (const auto& p: dests) { 608 // we could have gotten this request from a snooping master --- 19 unchanged lines hidden (view full) --- 628 // so the retry will always be coming from a port to which we 629 // tried to forward a request 630 reqLayers[master_port_id]->recvRetry(); 631} 632 633Tick 634CoherentXBar::recvAtomic(PacketPtr pkt, PortID slave_port_id) 635{ |
636 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 637 slavePorts[slave_port_id]->name(), pkt->print()); |
638 639 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 640 unsigned int pkt_cmd = pkt->cmdToIndex(); 641 642 MemCmd snoop_response_cmd = MemCmd::InvalidCmd; 643 Tick snoop_response_latency = 0; 644 645 if (!system->bypassCaches()) { 646 // forward to all snoopers but the source 647 std::pair<MemCmd, Tick> snoop_result; 648 if (snoopFilter) { 649 // check with the snoop filter where to forward this packet 650 auto sf_res = 651 snoopFilter->lookupRequest(pkt, *slavePorts[slave_port_id]); 652 snoop_response_latency += sf_res.second * clockPeriod(); |
653 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n", 654 __func__, slavePorts[slave_port_id]->name(), pkt->print(), 655 sf_res.first.size(), sf_res.second); |
656 657 // let the snoop filter know about the success of the send 658 // operation, and do it even before sending it onwards to 659 // avoid situations where atomic upward snoops sneak in 660 // between and change the filter state 661 snoopFilter->finishRequest(false, pkt->getAddr(), pkt->isSecure()); 662 663 snoop_result = forwardAtomic(pkt, slave_port_id, InvalidPortID, --- 10 unchanged lines hidden (view full) --- 674 675 const bool sink_packet = sinkPacket(pkt); 676 677 // even if we had a snoop response, we must continue and also 678 // perform the actual request at the destination 679 PortID master_port_id = findPort(pkt->getAddr()); 680 681 if (sink_packet) { |
682 DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__, 683 pkt->print()); |
684 } else { 685 if (!pointOfCoherency || pkt->isRead() || pkt->isWrite()) { 686 // forward the request to the appropriate destination 687 response_latency = masterPorts[master_port_id]->sendAtomic(pkt); 688 } else { 689 // if it does not need a response we sink the packet above 690 assert(pkt->needsResponse()); 691 --- 34 unchanged lines hidden (view full) --- 726 // @todo: Not setting header time 727 pkt->payloadDelay = response_latency; 728 return response_latency; 729} 730 731Tick 732CoherentXBar::recvAtomicSnoop(PacketPtr pkt, PortID master_port_id) 733{ |
734 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 735 masterPorts[master_port_id]->name(), pkt->print()); |
736 737 // add the request snoop data 738 unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0; 739 snoops++; 740 snoopTraffic += pkt_size; 741 742 // forward to all snoopers 743 std::pair<MemCmd, Tick> snoop_result; 744 Tick snoop_response_latency = 0; 745 if (snoopFilter) { 746 auto sf_res = snoopFilter->lookupSnoop(pkt); 747 snoop_response_latency += sf_res.second * clockPeriod(); |
748 DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n", 749 __func__, masterPorts[master_port_id]->name(), pkt->print(), 750 sf_res.first.size(), sf_res.second); |
751 snoop_result = forwardAtomic(pkt, InvalidPortID, master_port_id, 752 sf_res.first); 753 } else { 754 snoop_result = forwardAtomic(pkt, InvalidPortID); 755 } 756 MemCmd snoop_response_cmd = snoop_result.first; 757 snoop_response_latency += snoop_result.second; 758 --- 81 unchanged lines hidden (view full) --- 840 return std::make_pair(snoop_response_cmd, snoop_response_latency); 841} 842 843void 844CoherentXBar::recvFunctional(PacketPtr pkt, PortID slave_port_id) 845{ 846 if (!pkt->isPrint()) { 847 // don't do DPRINTFs on PrintReq as it clutters up the output |
848 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 849 slavePorts[slave_port_id]->name(), pkt->print()); |
850 } 851 852 if (!system->bypassCaches()) { 853 // forward to all snoopers but the source 854 forwardFunctional(pkt, slave_port_id); 855 } 856 857 // there is no need to continue if the snooping has found what we --- 17 unchanged lines hidden (view full) --- 875 } 876} 877 878void 879CoherentXBar::recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id) 880{ 881 if (!pkt->isPrint()) { 882 // don't do DPRINTFs on PrintReq as it clutters up the output |
883 DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__, 884 masterPorts[master_port_id]->name(), pkt->print()); |
885 } 886 887 for (const auto& p : slavePorts) { 888 if (p->checkFunctional(pkt)) { 889 if (pkt->needsResponse()) 890 pkt->makeResponse(); 891 return; 892 } --- 86 unchanged lines hidden --- |