coherent_xbar.cc revision 12780
12497SN/A/*
214006Stiago.muck@arm.com * Copyright (c) 2011-2018 ARM Limited
38711SN/A * All rights reserved
48711SN/A *
58711SN/A * The license below extends only to copyright in the software and shall
68711SN/A * not be construed as granting a license to any other intellectual
78711SN/A * property including but not limited to intellectual property relating
88711SN/A * to a hardware implementation of the functionality of the software
98711SN/A * licensed hereunder.  You may use the software subject to the license
108711SN/A * terms below provided that you ensure that this notice is replicated
118711SN/A * unmodified and in its entirety in all distributions of the software,
128711SN/A * modified or unmodified, in source code or in binary form.
138711SN/A *
142497SN/A * Copyright (c) 2006 The Regents of The University of Michigan
152497SN/A * All rights reserved.
162497SN/A *
172497SN/A * Redistribution and use in source and binary forms, with or without
182497SN/A * modification, are permitted provided that the following conditions are
192497SN/A * met: redistributions of source code must retain the above copyright
202497SN/A * notice, this list of conditions and the following disclaimer;
212497SN/A * redistributions in binary form must reproduce the above copyright
222497SN/A * notice, this list of conditions and the following disclaimer in the
232497SN/A * documentation and/or other materials provided with the distribution;
242497SN/A * neither the name of the copyright holders nor the names of its
252497SN/A * contributors may be used to endorse or promote products derived from
262497SN/A * this software without specific prior written permission.
272497SN/A *
282497SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292497SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302497SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312497SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322497SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332497SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342497SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352497SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362497SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372497SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382497SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665SN/A *
402665SN/A * Authors: Ali Saidi
418715SN/A *          Andreas Hansson
428922SN/A *          William Wang
4312351Snikos.nikoleris@arm.com *          Nikos Nikoleris
442497SN/A */
452497SN/A
462497SN/A/**
472982SN/A * @file
4810405Sandreas.hansson@arm.com * Definition of a crossbar object.
492497SN/A */
502497SN/A
5111793Sbrandon.potter@amd.com#include "mem/coherent_xbar.hh"
5211793Sbrandon.potter@amd.com
5312334Sgabeblack@google.com#include "base/logging.hh"
542548SN/A#include "base/trace.hh"
5510405Sandreas.hansson@arm.com#include "debug/AddrRanges.hh"
5610405Sandreas.hansson@arm.com#include "debug/CoherentXBar.hh"
579524SN/A#include "sim/system.hh"
582497SN/A
5910405Sandreas.hansson@arm.comCoherentXBar::CoherentXBar(const CoherentXBarParams *p)
6010719SMarco.Balboni@ARM.com    : BaseXBar(p), system(p->system), snoopFilter(p->snoop_filter),
6111334Sandreas.hansson@arm.com      snoopResponseLatency(p->snoop_response_latency),
6214006Stiago.muck@arm.com      pointOfCoherency(p->point_of_coherency),
6314006Stiago.muck@arm.com      pointOfUnification(p->point_of_unification)
6412341Snikos.nikoleris@arm.com{
6512341Snikos.nikoleris@arm.com    // create the ports based on the size of the master and slave
667523SN/A    // vector ports, and the presence of the default port, the ports
678851SN/A    // are enumerated starting from zero
688948SN/A    for (int i = 0; i < p->port_master_connection_count; ++i) {
698948SN/A        std::string portName = csprintf("%s.master[%d]", name(), i);
708851SN/A        MasterPort* bp = new CoherentXBarMasterPort(portName, *this, i);
719095SN/A        masterPorts.push_back(bp);
7210405Sandreas.hansson@arm.com        reqLayers.push_back(new ReqLayer(*bp, *this,
738922SN/A                                         csprintf(".reqLayer%d", i)));
749715SN/A        snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
759715SN/A                                                 csprintf(".snoopLayer%d", i)));
7613808Sgabeblack@google.com    }
7713808Sgabeblack@google.com
788851SN/A    // see if we have a default slave device connected and if so add
798851SN/A    // our corresponding master port
808948SN/A    if (p->port_default_connection_count) {
818948SN/A        defaultPortID = masterPorts.size();
828915SN/A        std::string portName = name() + ".default";
839031SN/A        MasterPort* bp = new CoherentXBarMasterPort(portName, *this,
849095SN/A                                                   defaultPortID);
8510405Sandreas.hansson@arm.com        masterPorts.push_back(bp);
8613808Sgabeblack@google.com        reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d",
878922SN/A                                             defaultPortID)));
889715SN/A        snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
8913808Sgabeblack@google.com                                                 csprintf(".snoopLayer%d",
9010713Sandreas.hansson@arm.com                                                          defaultPortID)));
9110713Sandreas.hansson@arm.com    }
9210713Sandreas.hansson@arm.com
938915SN/A    // create the slave ports, once again starting at zero
948915SN/A    for (int i = 0; i < p->port_slave_connection_count; ++i) {
958948SN/A        std::string portName = csprintf("%s.slave[%d]", name(), i);
968851SN/A        QueuedSlavePort* bp = new CoherentXBarSlavePort(portName, *this, i);
979095SN/A        slavePorts.push_back(bp);
9810888Sandreas.hansson@arm.com        respLayers.push_back(new RespLayer(*bp, *this,
998922SN/A                                           csprintf(".respLayer%d", i)));
1009715SN/A        snoopRespPorts.push_back(new SnoopRespPort(*bp, *this));
1019715SN/A    }
1029716SN/A}
1038851SN/A
1047523SN/ACoherentXBar::~CoherentXBar()
1057523SN/A{
10610405Sandreas.hansson@arm.com    for (auto l: reqLayers)
1079715SN/A        delete l;
10810405Sandreas.hansson@arm.com    for (auto l: respLayers)
10910405Sandreas.hansson@arm.com        delete l;
11010405Sandreas.hansson@arm.com    for (auto l: snoopLayers)
11110405Sandreas.hansson@arm.com        delete l;
11210405Sandreas.hansson@arm.com    for (auto p: snoopRespPorts)
11310405Sandreas.hansson@arm.com        delete p;
11410405Sandreas.hansson@arm.com}
11510405Sandreas.hansson@arm.com
1169715SN/Avoid
1179715SN/ACoherentXBar::init()
1182568SN/A{
11910405Sandreas.hansson@arm.com    BaseXBar::init();
1202568SN/A
12110405Sandreas.hansson@arm.com    // iterate over our slave ports and determine which of our
1229278SN/A    // neighbouring master ports are snooping and add them as snoopers
1238948SN/A    for (const auto& p: slavePorts) {
1248948SN/A        // check if the connected master port is snooping
12510405Sandreas.hansson@arm.com        if (p->isSnooping()) {
1269088SN/A            DPRINTF(AddrRanges, "Adding snooping master %s\n",
12710405Sandreas.hansson@arm.com                    p->getMasterPort().name());
12814192Sgabeblack@google.com            snoopPorts.push_back(p);
12910405Sandreas.hansson@arm.com        }
1308711SN/A    }
1318711SN/A
1322568SN/A    if (snoopPorts.empty())
1339036SN/A        warn("CoherentXBar %s has no snooping ports attached!\n", name());
13410405Sandreas.hansson@arm.com
13511133Sandreas.hansson@arm.com    // inform the snoop filter about the slave ports so it can create
13611133Sandreas.hansson@arm.com    // its own internal representation
13711133Sandreas.hansson@arm.com    if (snoopFilter)
13811133Sandreas.hansson@arm.com        snoopFilter->setSlavePorts(slavePorts);
13911133Sandreas.hansson@arm.com}
1403244SN/A
1413244SN/Abool
1428948SN/ACoherentXBar::recvTimingReq(PacketPtr pkt, PortID slave_port_id)
14310405Sandreas.hansson@arm.com{
1443244SN/A    // determine the source port based on the id
1458975SN/A    SlavePort *src_port = slavePorts[slave_port_id];
1469032SN/A
1473244SN/A    // remember if the packet is an express snoop
1489091SN/A    bool is_express_snoop = pkt->isExpressSnoop();
1499091SN/A    bool cache_responding = pkt->cacheResponding();
15011284Sandreas.hansson@arm.com    // for normal requests, going downstream, the express snoop flag
15110656Sandreas.hansson@arm.com    // and the cache responding flag should always be the same
15211284Sandreas.hansson@arm.com    assert(is_express_snoop == cache_responding);
15311284Sandreas.hansson@arm.com
1549091SN/A    // determine the destination based on the destination address range
15512780Snikos.nikoleris@arm.com    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
15613856Sodanrc@yahoo.com.br    PortID master_port_id = findPort(addr_range);
1579612SN/A
15810405Sandreas.hansson@arm.com    // test if the crossbar should be considered occupied for the current
1599033SN/A    // port, and exclude express snoops from the check
1609715SN/A    if (!is_express_snoop && !reqLayers[master_port_id]->tryTiming(src_port)) {
16111744Snikos.nikoleris@arm.com        DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
16211744Snikos.nikoleris@arm.com                src_port->name(), pkt->print());
1633244SN/A        return false;
1643244SN/A    }
1653244SN/A
16611744Snikos.nikoleris@arm.com    DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
16711744Snikos.nikoleris@arm.com            src_port->name(), pkt->print());
1685197SN/A
1699712SN/A    // store size and command as they might be modified when
1709712SN/A    // forwarding the packet
1719712SN/A    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
1729712SN/A    unsigned int pkt_cmd = pkt->cmdToIndex();
1739712SN/A
17410719SMarco.Balboni@ARM.com    // store the old header delay so we can restore it if needed
17510719SMarco.Balboni@ARM.com    Tick old_header_delay = pkt->headerDelay;
17610719SMarco.Balboni@ARM.com
17710719SMarco.Balboni@ARM.com    // a request sees the frontend and forward latency
17810719SMarco.Balboni@ARM.com    Tick xbar_delay = (frontendLatency + forwardLatency) * clockPeriod();
17910719SMarco.Balboni@ARM.com
18010719SMarco.Balboni@ARM.com    // set the packet header and payload delay
18110719SMarco.Balboni@ARM.com    calcPacketTiming(pkt, xbar_delay);
18210719SMarco.Balboni@ARM.com
18310719SMarco.Balboni@ARM.com    // determine how long to be crossbar layer is busy
18410719SMarco.Balboni@ARM.com    Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
1854912SN/A
18612346Snikos.nikoleris@arm.com    // is this the destination point for this packet? (e.g. true if
18712346Snikos.nikoleris@arm.com    // this xbar is the PoC for a cache maintenance operation to the
18812346Snikos.nikoleris@arm.com    // PoC) otherwise the destination is any cache that can satisfy
18912346Snikos.nikoleris@arm.com    // the request
19012346Snikos.nikoleris@arm.com    const bool is_destination = isDestination(pkt);
19112346Snikos.nikoleris@arm.com
19212345Snikos.nikoleris@arm.com    const bool snoop_caches = !system->bypassCaches() &&
19312345Snikos.nikoleris@arm.com        pkt->cmd != MemCmd::WriteClean;
19412345Snikos.nikoleris@arm.com    if (snoop_caches) {
19511127Sandreas.hansson@arm.com        assert(pkt->snoopDelay == 0);
19611127Sandreas.hansson@arm.com
19712351Snikos.nikoleris@arm.com        if (pkt->isClean() && !is_destination) {
19812351Snikos.nikoleris@arm.com            // before snooping we need to make sure that the memory
19912351Snikos.nikoleris@arm.com            // below is not busy and the cache clean request can be
20012351Snikos.nikoleris@arm.com            // forwarded to it
20112351Snikos.nikoleris@arm.com            if (!masterPorts[master_port_id]->tryTiming(pkt)) {
20212351Snikos.nikoleris@arm.com                DPRINTF(CoherentXBar, "%s: src %s packet %s RETRY\n", __func__,
20312351Snikos.nikoleris@arm.com                        src_port->name(), pkt->print());
20412351Snikos.nikoleris@arm.com
20512351Snikos.nikoleris@arm.com                // update the layer state and schedule an idle event
20612351Snikos.nikoleris@arm.com                reqLayers[master_port_id]->failedTiming(src_port,
20712351Snikos.nikoleris@arm.com                                                        clockEdge(Cycles(1)));
20812351Snikos.nikoleris@arm.com                return false;
20912351Snikos.nikoleris@arm.com            }
21012351Snikos.nikoleris@arm.com        }
21112351Snikos.nikoleris@arm.com
21212351Snikos.nikoleris@arm.com
2138979SN/A        // the packet is a memory-mapped request and should be
2148979SN/A        // broadcasted to our snoopers but the source
21510402SN/A        if (snoopFilter) {
21610402SN/A            // check with the snoop filter where to forward this packet
21710402SN/A            auto sf_res = snoopFilter->lookupRequest(pkt, *src_port);
21811126Sandreas.hansson@arm.com            // the time required by a packet to be delivered through
21911126Sandreas.hansson@arm.com            // the xbar has to be charged also with to lookup latency
22011126Sandreas.hansson@arm.com            // of the snoop filter
22110719SMarco.Balboni@ARM.com            pkt->headerDelay += sf_res.second * clockPeriod();
22211744Snikos.nikoleris@arm.com            DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
22311744Snikos.nikoleris@arm.com                    __func__, src_port->name(), pkt->print(),
22411744Snikos.nikoleris@arm.com                    sf_res.first.size(), sf_res.second);
22511196Sali.jafri@arm.com
22611199Sandreas.hansson@arm.com            if (pkt->isEviction()) {
22711196Sali.jafri@arm.com                // for block-evicting packets, i.e. writebacks and
22811196Sali.jafri@arm.com                // clean evictions, there is no need to snoop up, as
22911196Sali.jafri@arm.com                // all we do is determine if the block is cached or
23011196Sali.jafri@arm.com                // not, instead just set it here based on the snoop
23111196Sali.jafri@arm.com                // filter result
23211196Sali.jafri@arm.com                if (!sf_res.first.empty())
23311196Sali.jafri@arm.com                    pkt->setBlockCached();
23411196Sali.jafri@arm.com            } else {
23511196Sali.jafri@arm.com                forwardTiming(pkt, slave_port_id, sf_res.first);
23611196Sali.jafri@arm.com            }
23710402SN/A        } else {
23810402SN/A            forwardTiming(pkt, slave_port_id);
23910402SN/A        }
24011127Sandreas.hansson@arm.com
24111127Sandreas.hansson@arm.com        // add the snoop delay to our header delay, and then reset it
24211127Sandreas.hansson@arm.com        pkt->headerDelay += pkt->snoopDelay;
24311127Sandreas.hansson@arm.com        pkt->snoopDelay = 0;
2448979SN/A    }
2458948SN/A
24611334Sandreas.hansson@arm.com    // set up a sensible starting point
24711334Sandreas.hansson@arm.com    bool success = true;
24810883Sali.jafri@arm.com
24911284Sandreas.hansson@arm.com    // remember if the packet will generate a snoop response by
25011284Sandreas.hansson@arm.com    // checking if a cache set the cacheResponding flag during the
25111284Sandreas.hansson@arm.com    // snooping above
25211284Sandreas.hansson@arm.com    const bool expect_snoop_resp = !cache_responding && pkt->cacheResponding();
25311334Sandreas.hansson@arm.com    bool expect_response = pkt->needsResponse() && !pkt->cacheResponding();
2548915SN/A
25511334Sandreas.hansson@arm.com    const bool sink_packet = sinkPacket(pkt);
25611334Sandreas.hansson@arm.com
25711334Sandreas.hansson@arm.com    // in certain cases the crossbar is responsible for responding
25811334Sandreas.hansson@arm.com    bool respond_directly = false;
25911544Snikos.nikoleris@arm.com    // store the original address as an address mapper could possibly
26011544Snikos.nikoleris@arm.com    // modify the address upon a sendTimingRequest
26111544Snikos.nikoleris@arm.com    const Addr addr(pkt->getAddr());
26211334Sandreas.hansson@arm.com    if (sink_packet) {
26311744Snikos.nikoleris@arm.com        DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
26411744Snikos.nikoleris@arm.com                pkt->print());
26511334Sandreas.hansson@arm.com    } else {
26611334Sandreas.hansson@arm.com        // determine if we are forwarding the packet, or responding to
26711334Sandreas.hansson@arm.com        // it
26812346Snikos.nikoleris@arm.com        if (forwardPacket(pkt)) {
26911334Sandreas.hansson@arm.com            // if we are passing on, rather than sinking, a packet to
27011334Sandreas.hansson@arm.com            // which an upstream cache has committed to responding,
27111334Sandreas.hansson@arm.com            // the line was needs writable, and the responding only
27211334Sandreas.hansson@arm.com            // had an Owned copy, so we need to immidiately let the
27311334Sandreas.hansson@arm.com            // downstream caches know, bypass any flow control
27411334Sandreas.hansson@arm.com            if (pkt->cacheResponding()) {
27511334Sandreas.hansson@arm.com                pkt->setExpressSnoop();
27611334Sandreas.hansson@arm.com            }
27711334Sandreas.hansson@arm.com
27812346Snikos.nikoleris@arm.com            // make sure that the write request (e.g., WriteClean)
27912346Snikos.nikoleris@arm.com            // will stop at the memory below if this crossbar is its
28012346Snikos.nikoleris@arm.com            // destination
28112346Snikos.nikoleris@arm.com            if (pkt->isWrite() && is_destination) {
28212346Snikos.nikoleris@arm.com                pkt->clearWriteThrough();
28312346Snikos.nikoleris@arm.com            }
28412346Snikos.nikoleris@arm.com
28511334Sandreas.hansson@arm.com            // since it is a normal request, attempt to send the packet
28611334Sandreas.hansson@arm.com            success = masterPorts[master_port_id]->sendTimingReq(pkt);
28711334Sandreas.hansson@arm.com        } else {
28811334Sandreas.hansson@arm.com            // no need to forward, turn this packet around and respond
28911334Sandreas.hansson@arm.com            // directly
29011334Sandreas.hansson@arm.com            assert(pkt->needsResponse());
29111334Sandreas.hansson@arm.com
29211334Sandreas.hansson@arm.com            respond_directly = true;
29311334Sandreas.hansson@arm.com            assert(!expect_snoop_resp);
29411334Sandreas.hansson@arm.com            expect_response = false;
29511334Sandreas.hansson@arm.com        }
29611334Sandreas.hansson@arm.com    }
2978948SN/A
29812345Snikos.nikoleris@arm.com    if (snoopFilter && snoop_caches) {
29910402SN/A        // Let the snoop filter know about the success of the send operation
30011605Snikos.nikoleris@arm.com        snoopFilter->finishRequest(!success, addr, pkt->isSecure());
30110402SN/A    }
30210402SN/A
30310656Sandreas.hansson@arm.com    // check if we were successful in sending the packet onwards
30410656Sandreas.hansson@arm.com    if (!success)  {
30511284Sandreas.hansson@arm.com        // express snoops should never be forced to retry
30610656Sandreas.hansson@arm.com        assert(!is_express_snoop);
30710656Sandreas.hansson@arm.com
30810719SMarco.Balboni@ARM.com        // restore the header delay
30910719SMarco.Balboni@ARM.com        pkt->headerDelay = old_header_delay;
31010656Sandreas.hansson@arm.com
31111744Snikos.nikoleris@arm.com        DPRINTF(CoherentXBar, "%s: src %s packet %s RETRY\n", __func__,
31211744Snikos.nikoleris@arm.com                src_port->name(), pkt->print());
31310656Sandreas.hansson@arm.com
31410656Sandreas.hansson@arm.com        // update the layer state and schedule an idle event
31510656Sandreas.hansson@arm.com        reqLayers[master_port_id]->failedTiming(src_port,
31610719SMarco.Balboni@ARM.com                                                clockEdge(Cycles(1)));
3179091SN/A    } else {
31810656Sandreas.hansson@arm.com        // express snoops currently bypass the crossbar state entirely
31910656Sandreas.hansson@arm.com        if (!is_express_snoop) {
32010656Sandreas.hansson@arm.com            // if this particular request will generate a snoop
32110656Sandreas.hansson@arm.com            // response
32210656Sandreas.hansson@arm.com            if (expect_snoop_resp) {
32310656Sandreas.hansson@arm.com                // we should never have an exsiting request outstanding
32410656Sandreas.hansson@arm.com                assert(outstandingSnoop.find(pkt->req) ==
32510656Sandreas.hansson@arm.com                       outstandingSnoop.end());
32610656Sandreas.hansson@arm.com                outstandingSnoop.insert(pkt->req);
3278948SN/A
32810656Sandreas.hansson@arm.com                // basic sanity check on the outstanding snoops
32914006Stiago.muck@arm.com                panic_if(outstandingSnoop.size() > 512,
33014006Stiago.muck@arm.com                         "Outstanding snoop requests exceeded 512\n");
33114006Stiago.muck@arm.com            }
33210656Sandreas.hansson@arm.com
3338948SN/A            // remember where to route the normal response to
33410656Sandreas.hansson@arm.com            if (expect_response || expect_snoop_resp) {
33510656Sandreas.hansson@arm.com                assert(routeTo.find(pkt->req) == routeTo.end());
33610656Sandreas.hansson@arm.com                routeTo[pkt->req] = slave_port_id;
33710656Sandreas.hansson@arm.com
3389549SN/A                panic_if(routeTo.size() > 512,
33914006Stiago.muck@arm.com                         "Routing table exceeds 512 packets\n");
34014006Stiago.muck@arm.com            }
34114006Stiago.muck@arm.com
34210656Sandreas.hansson@arm.com            // update the layer state and schedule an idle event
3438948SN/A            reqLayers[master_port_id]->succeededTiming(packetFinishTime);
34410405Sandreas.hansson@arm.com        }
3459715SN/A
3469091SN/A        // stats updates only consider packets that were successfully sent
3478975SN/A        pktCount[slave_port_id][master_port_id]++;
34810656Sandreas.hansson@arm.com        pktSize[slave_port_id][master_port_id] += pkt_size;
3499712SN/A        transDist[pkt_cmd]++;
35010405Sandreas.hansson@arm.com
3519712SN/A        if (is_express_snoop) {
35210656Sandreas.hansson@arm.com            snoops++;
35311564Sdavid.guillen@arm.com            snoopTraffic += pkt_size;
35410656Sandreas.hansson@arm.com        }
35511564Sdavid.guillen@arm.com    }
35611564Sdavid.guillen@arm.com
3579712SN/A    if (sink_packet)
3589712SN/A        // queue the packet for deletion
35911334Sandreas.hansson@arm.com        pendingDelete.reset(pkt);
36011334Sandreas.hansson@arm.com
36111334Sandreas.hansson@arm.com    // normally we respond to the packet we just received if we need to
36211334Sandreas.hansson@arm.com    PacketPtr rsp_pkt = pkt;
36312351Snikos.nikoleris@arm.com    PortID rsp_port_id = slave_port_id;
36412351Snikos.nikoleris@arm.com
36512351Snikos.nikoleris@arm.com    // If this is the destination of the cache clean operation the
36612351Snikos.nikoleris@arm.com    // crossbar is responsible for responding. This crossbar will
36712351Snikos.nikoleris@arm.com    // respond when the cache clean is complete. A cache clean
36812351Snikos.nikoleris@arm.com    // is complete either:
36912351Snikos.nikoleris@arm.com    // * direcly, if no cache above had a dirty copy of the block
37012351Snikos.nikoleris@arm.com    //   as indicated by the satisfied flag of the packet, or
37112351Snikos.nikoleris@arm.com    // * when the crossbar has seen both the cache clean request
37212351Snikos.nikoleris@arm.com    //   (CleanSharedReq, CleanInvalidReq) and the corresponding
37312351Snikos.nikoleris@arm.com    //   write (WriteClean) which updates the block in the memory
37412351Snikos.nikoleris@arm.com    //   below.
37512351Snikos.nikoleris@arm.com    if (success &&
37612351Snikos.nikoleris@arm.com        ((pkt->isClean() && pkt->satisfied()) ||
37712351Snikos.nikoleris@arm.com         pkt->cmd == MemCmd::WriteClean) &&
37812351Snikos.nikoleris@arm.com        is_destination) {
37912351Snikos.nikoleris@arm.com        PacketPtr deferred_rsp = pkt->isWrite() ? nullptr : pkt;
38012351Snikos.nikoleris@arm.com        auto cmo_lookup = outstandingCMO.find(pkt->id);
38112351Snikos.nikoleris@arm.com        if (cmo_lookup != outstandingCMO.end()) {
38212351Snikos.nikoleris@arm.com            // the cache clean request has already reached this xbar
38312351Snikos.nikoleris@arm.com            respond_directly = true;
38412351Snikos.nikoleris@arm.com            if (pkt->isWrite()) {
38512351Snikos.nikoleris@arm.com                rsp_pkt = cmo_lookup->second;
38612351Snikos.nikoleris@arm.com                assert(rsp_pkt);
38712351Snikos.nikoleris@arm.com
38812351Snikos.nikoleris@arm.com                // determine the destination
38912351Snikos.nikoleris@arm.com                const auto route_lookup = routeTo.find(rsp_pkt->req);
39012351Snikos.nikoleris@arm.com                assert(route_lookup != routeTo.end());
39112351Snikos.nikoleris@arm.com                rsp_port_id = route_lookup->second;
39212351Snikos.nikoleris@arm.com                assert(rsp_port_id != InvalidPortID);
39312351Snikos.nikoleris@arm.com                assert(rsp_port_id < respLayers.size());
39412351Snikos.nikoleris@arm.com                // remove the request from the routing table
39512351Snikos.nikoleris@arm.com                routeTo.erase(route_lookup);
39612351Snikos.nikoleris@arm.com            }
39712351Snikos.nikoleris@arm.com            outstandingCMO.erase(cmo_lookup);
39812351Snikos.nikoleris@arm.com        } else {
39912351Snikos.nikoleris@arm.com            respond_directly = false;
40012351Snikos.nikoleris@arm.com            outstandingCMO.emplace(pkt->id, deferred_rsp);
40112351Snikos.nikoleris@arm.com            if (!pkt->isWrite()) {
40212351Snikos.nikoleris@arm.com                assert(routeTo.find(pkt->req) == routeTo.end());
40312351Snikos.nikoleris@arm.com                routeTo[pkt->req] = slave_port_id;
40412351Snikos.nikoleris@arm.com
40512351Snikos.nikoleris@arm.com                panic_if(routeTo.size() > 512,
40612351Snikos.nikoleris@arm.com                         "Routing table exceeds 512 packets\n");
40714006Stiago.muck@arm.com            }
40814006Stiago.muck@arm.com        }
40914006Stiago.muck@arm.com    }
41012351Snikos.nikoleris@arm.com
41112351Snikos.nikoleris@arm.com
41212351Snikos.nikoleris@arm.com    if (respond_directly) {
41312351Snikos.nikoleris@arm.com        assert(rsp_pkt->needsResponse());
41412351Snikos.nikoleris@arm.com        assert(success);
41511334Sandreas.hansson@arm.com
41612351Snikos.nikoleris@arm.com        rsp_pkt->makeResponse();
41711334Sandreas.hansson@arm.com
41811334Sandreas.hansson@arm.com        if (snoopFilter && !system->bypassCaches()) {
41912351Snikos.nikoleris@arm.com            // let the snoop filter inspect the response and update its state
42011334Sandreas.hansson@arm.com            snoopFilter->updateResponse(rsp_pkt, *slavePorts[rsp_port_id]);
42111334Sandreas.hansson@arm.com        }
42211334Sandreas.hansson@arm.com
42312351Snikos.nikoleris@arm.com        // we send the response after the current packet, even if the
42411334Sandreas.hansson@arm.com        // response is not for this packet (e.g. cache clean operation
42511334Sandreas.hansson@arm.com        // where both the request and the write packet have to cross
42612351Snikos.nikoleris@arm.com        // the destination xbar before the response is sent.)
42712351Snikos.nikoleris@arm.com        Tick response_time = clockEdge() + pkt->headerDelay;
42812351Snikos.nikoleris@arm.com        rsp_pkt->headerDelay = 0;
42912351Snikos.nikoleris@arm.com
43011334Sandreas.hansson@arm.com        slavePorts[rsp_port_id]->schedTimingResp(rsp_pkt, response_time);
43112351Snikos.nikoleris@arm.com    }
43211334Sandreas.hansson@arm.com
43312351Snikos.nikoleris@arm.com    return success;
43411334Sandreas.hansson@arm.com}
43511334Sandreas.hansson@arm.com
4369091SN/Abool
4378975SN/ACoherentXBar::recvTimingResp(PacketPtr pkt, PortID master_port_id)
4388975SN/A{
4398975SN/A    // determine the source port based on the id
44010405Sandreas.hansson@arm.com    MasterPort *src_port = masterPorts[master_port_id];
4418975SN/A
4428975SN/A    // determine the destination
4439032SN/A    const auto route_lookup = routeTo.find(pkt->req);
4448975SN/A    assert(route_lookup != routeTo.end());
44510656Sandreas.hansson@arm.com    const PortID slave_port_id = route_lookup->second;
44610656Sandreas.hansson@arm.com    assert(slave_port_id != InvalidPortID);
44710656Sandreas.hansson@arm.com    assert(slave_port_id < respLayers.size());
44810656Sandreas.hansson@arm.com
44910572Sandreas.hansson@arm.com    // test if the crossbar should be considered occupied for the
45010572Sandreas.hansson@arm.com    // current port
4519713SN/A    if (!respLayers[slave_port_id]->tryTiming(src_port)) {
45210405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
45310405Sandreas.hansson@arm.com                src_port->name(), pkt->print());
4549715SN/A        return false;
45511744Snikos.nikoleris@arm.com    }
45611744Snikos.nikoleris@arm.com
4578975SN/A    DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
4588975SN/A            src_port->name(), pkt->print());
4598975SN/A
46011744Snikos.nikoleris@arm.com    // store size and command as they might be modified when
46111744Snikos.nikoleris@arm.com    // forwarding the packet
4628975SN/A    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
4639712SN/A    unsigned int pkt_cmd = pkt->cmdToIndex();
4649712SN/A
4659712SN/A    // a response sees the response latency
4669712SN/A    Tick xbar_delay = responseLatency * clockPeriod();
4679712SN/A
46810719SMarco.Balboni@ARM.com    // set the packet header and payload delay
46910719SMarco.Balboni@ARM.com    calcPacketTiming(pkt, xbar_delay);
47010719SMarco.Balboni@ARM.com
47110719SMarco.Balboni@ARM.com    // determine how long to be crossbar layer is busy
47210719SMarco.Balboni@ARM.com    Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
47310719SMarco.Balboni@ARM.com
47410719SMarco.Balboni@ARM.com    if (snoopFilter && !system->bypassCaches()) {
47510719SMarco.Balboni@ARM.com        // let the snoop filter inspect the response and update its state
4768975SN/A        snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
47710821Sandreas.hansson@arm.com    }
47810402SN/A
47910402SN/A    // send the packet through the destination slave port and pay for
48010402SN/A    // any outstanding header delay
48110402SN/A    Tick latency = pkt->headerDelay;
48210888Sandreas.hansson@arm.com    pkt->headerDelay = 0;
48310888Sandreas.hansson@arm.com    slavePorts[slave_port_id]->schedTimingResp(pkt, curTick() + latency);
48410888Sandreas.hansson@arm.com
48510888Sandreas.hansson@arm.com    // remove the request from the routing table
48610888Sandreas.hansson@arm.com    routeTo.erase(route_lookup);
4878975SN/A
48810656Sandreas.hansson@arm.com    respLayers[slave_port_id]->succeededTiming(packetFinishTime);
48910656Sandreas.hansson@arm.com
49010656Sandreas.hansson@arm.com    // stats updates
4919715SN/A    pktCount[slave_port_id][master_port_id]++;
4928975SN/A    pktSize[slave_port_id][master_port_id] += pkt_size;
4939712SN/A    transDist[pkt_cmd]++;
4949712SN/A
49510405Sandreas.hansson@arm.com    return true;
4969712SN/A}
4979712SN/A
4988975SN/Avoid
4998975SN/ACoherentXBar::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id)
5008975SN/A{
5018975SN/A    DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
50210405Sandreas.hansson@arm.com            masterPorts[master_port_id]->name(), pkt->print());
5038975SN/A
50411744Snikos.nikoleris@arm.com    // update stats here as we know the forwarding will succeed
50511744Snikos.nikoleris@arm.com    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
5068975SN/A    transDist[pkt->cmdToIndex()]++;
5079712SN/A    snoops++;
50811564Sdavid.guillen@arm.com    snoopTraffic += pkt_size;
5099712SN/A
51010405Sandreas.hansson@arm.com    // we should only see express snoops from caches
51111564Sdavid.guillen@arm.com    assert(pkt->isExpressSnoop());
5129712SN/A
5138975SN/A    // set the packet header and payload delay, for now use forward latency
5148975SN/A    // @todo Assess the choice of latency further
5158975SN/A    calcPacketTiming(pkt, forwardLatency * clockPeriod());
51611127Sandreas.hansson@arm.com
51711127Sandreas.hansson@arm.com    // remember if a cache has already committed to responding so we
51811127Sandreas.hansson@arm.com    // can see if it changes during the snooping
51911127Sandreas.hansson@arm.com    const bool cache_responding = pkt->cacheResponding();
52011284Sandreas.hansson@arm.com
52111284Sandreas.hansson@arm.com    assert(pkt->snoopDelay == 0);
52211284Sandreas.hansson@arm.com
5239032SN/A    if (snoopFilter) {
52411127Sandreas.hansson@arm.com        // let the Snoop Filter work its magic and guide probing
52511127Sandreas.hansson@arm.com        auto sf_res = snoopFilter->lookupSnoop(pkt);
52610402SN/A        // the time required by a packet to be delivered through
52710402SN/A        // the xbar has to be charged also with to lookup latency
52810402SN/A        // of the snoop filter
52911126Sandreas.hansson@arm.com        pkt->headerDelay += sf_res.second * clockPeriod();
53011126Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
53111126Sandreas.hansson@arm.com                __func__, masterPorts[master_port_id]->name(), pkt->print(),
53211126Sandreas.hansson@arm.com                sf_res.first.size(), sf_res.second);
53311744Snikos.nikoleris@arm.com
53411744Snikos.nikoleris@arm.com        // forward to all snoopers
53511744Snikos.nikoleris@arm.com        forwardTiming(pkt, InvalidPortID, sf_res.first);
53610402SN/A    } else {
53710402SN/A        forwardTiming(pkt, InvalidPortID);
53810402SN/A    }
53910402SN/A
54010402SN/A    // add the snoop delay to our header delay, and then reset it
54110402SN/A    pkt->headerDelay += pkt->snoopDelay;
5428975SN/A    pkt->snoopDelay = 0;
54311127Sandreas.hansson@arm.com
54411127Sandreas.hansson@arm.com    // if we can expect a response, remember how to route it
54511127Sandreas.hansson@arm.com    if (!cache_responding && pkt->cacheResponding()) {
54611127Sandreas.hansson@arm.com        assert(routeTo.find(pkt->req) == routeTo.end());
54710656Sandreas.hansson@arm.com        routeTo[pkt->req] = master_port_id;
54811284Sandreas.hansson@arm.com    }
54910656Sandreas.hansson@arm.com
55010656Sandreas.hansson@arm.com    // a snoop request came from a connected slave device (one of
55110656Sandreas.hansson@arm.com    // our master ports), and if it is not coming from the slave
55210656Sandreas.hansson@arm.com    // device responsible for the address range something is
5538975SN/A    // wrong, hence there is nothing further to do as the packet
5548975SN/A    // would be going back to where it came from
5558975SN/A    AddrRange addr_range M5_VAR_USED =
5568975SN/A        RangeSize(pkt->getAddr(), pkt->getSize());
5578975SN/A    assert(findPort(addr_range) == master_port_id);
55813856Sodanrc@yahoo.com.br}
5598975SN/A
5608975SN/Abool
5618975SN/ACoherentXBar::recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id)
56210405Sandreas.hansson@arm.com{
5638975SN/A    // determine the source port based on the id
5648975SN/A    SlavePort* src_port = slavePorts[slave_port_id];
5659032SN/A
5668975SN/A    // get the destination
56710656Sandreas.hansson@arm.com    const auto route_lookup = routeTo.find(pkt->req);
56810656Sandreas.hansson@arm.com    assert(route_lookup != routeTo.end());
56910656Sandreas.hansson@arm.com    const PortID dest_port_id = route_lookup->second;
57010656Sandreas.hansson@arm.com    assert(dest_port_id != InvalidPortID);
57110572Sandreas.hansson@arm.com
5729714SN/A    // determine if the response is from a snoop request we
5739714SN/A    // created as the result of a normal request (in which case it
5749714SN/A    // should be in the outstandingSnoop), or if we merely forwarded
57510656Sandreas.hansson@arm.com    // someone else's snoop request
5769714SN/A    const bool forwardAsSnoop = outstandingSnoop.find(pkt->req) ==
57710656Sandreas.hansson@arm.com        outstandingSnoop.end();
57810656Sandreas.hansson@arm.com
5799714SN/A    // test if the crossbar should be considered occupied for the
58010405Sandreas.hansson@arm.com    // current port, note that the check is bypassed if the response
58110405Sandreas.hansson@arm.com    // is being passed on as a normal response since this is occupying
58210405Sandreas.hansson@arm.com    // the response layer rather than the snoop response layer
58310405Sandreas.hansson@arm.com    if (forwardAsSnoop) {
5849715SN/A        assert(dest_port_id < snoopLayers.size());
58510572Sandreas.hansson@arm.com        if (!snoopLayers[dest_port_id]->tryTiming(src_port)) {
5869715SN/A            DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
58711744Snikos.nikoleris@arm.com                    src_port->name(), pkt->print());
58811744Snikos.nikoleris@arm.com            return false;
5899715SN/A        }
5909715SN/A    } else {
5919716SN/A        // get the master port that mirrors this slave port internally
5929716SN/A        MasterPort* snoop_port = snoopRespPorts[slave_port_id];
5939716SN/A        assert(dest_port_id < respLayers.size());
59410572Sandreas.hansson@arm.com        if (!respLayers[dest_port_id]->tryTiming(snoop_port)) {
5959716SN/A            DPRINTF(CoherentXBar, "%s: src %s packet %s BUSY\n", __func__,
59611744Snikos.nikoleris@arm.com                    snoop_port->name(), pkt->print());
59711744Snikos.nikoleris@arm.com            return false;
5989716SN/A        }
5999716SN/A    }
6008975SN/A
6018975SN/A    DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
60211744Snikos.nikoleris@arm.com            src_port->name(), pkt->print());
60311744Snikos.nikoleris@arm.com
6048975SN/A    // store size and command as they might be modified when
6059712SN/A    // forwarding the packet
6069712SN/A    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
6079712SN/A    unsigned int pkt_cmd = pkt->cmdToIndex();
6089712SN/A
6099712SN/A    // responses are never express snoops
6108975SN/A    assert(!pkt->isExpressSnoop());
6118975SN/A
6128975SN/A    // a snoop response sees the snoop response latency, and if it is
61310719SMarco.Balboni@ARM.com    // forwarded as a normal response, the response latency
61410719SMarco.Balboni@ARM.com    Tick xbar_delay =
61510719SMarco.Balboni@ARM.com        (forwardAsSnoop ? snoopResponseLatency : responseLatency) *
61610719SMarco.Balboni@ARM.com        clockPeriod();
61710719SMarco.Balboni@ARM.com
61810719SMarco.Balboni@ARM.com    // set the packet header and payload delay
61910719SMarco.Balboni@ARM.com    calcPacketTiming(pkt, xbar_delay);
62010719SMarco.Balboni@ARM.com
62110719SMarco.Balboni@ARM.com    // determine how long to be crossbar layer is busy
62210719SMarco.Balboni@ARM.com    Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
62310719SMarco.Balboni@ARM.com
6248975SN/A    // forward it either as a snoop response or a normal response
6259714SN/A    if (forwardAsSnoop) {
6269714SN/A        // this is a snoop response to a snoop request we forwarded,
6279714SN/A        // e.g. coming from the L1 and going to the L2, and it should
6289714SN/A        // be forwarded as a snoop response
6299714SN/A
63010402SN/A        if (snoopFilter) {
63110402SN/A            // update the probe filter so that it can properly track the line
63210402SN/A            snoopFilter->updateSnoopForward(pkt, *slavePorts[slave_port_id],
63310402SN/A                                            *masterPorts[dest_port_id]);
63410402SN/A        }
63510402SN/A
63610402SN/A        bool success M5_VAR_USED =
6379712SN/A            masterPorts[dest_port_id]->sendTimingSnoopResp(pkt);
6389712SN/A        pktCount[slave_port_id][dest_port_id]++;
6399712SN/A        pktSize[slave_port_id][dest_port_id] += pkt_size;
64010405Sandreas.hansson@arm.com        assert(success);
6418975SN/A
6429714SN/A        snoopLayers[dest_port_id]->succeededTiming(packetFinishTime);
6439715SN/A    } else {
6443244SN/A        // we got a snoop response on one of our slave ports,
6458975SN/A        // i.e. from a coherent master connected to the crossbar, and
64610405Sandreas.hansson@arm.com        // since we created the snoop request as part of recvTiming,
64710405Sandreas.hansson@arm.com        // this should now be a normal response again
64810405Sandreas.hansson@arm.com        outstandingSnoop.erase(pkt->req);
64910656Sandreas.hansson@arm.com
6508948SN/A        // this is a snoop response from a coherent master, hence it
65110656Sandreas.hansson@arm.com        // should never go back to where the snoop response came from,
65210656Sandreas.hansson@arm.com        // but instead to where the original request came from
65310656Sandreas.hansson@arm.com        assert(slave_port_id != dest_port_id);
6549712SN/A
6558948SN/A        if (snoopFilter) {
65610402SN/A            // update the probe filter so that it can properly track the line
65710402SN/A            snoopFilter->updateSnoopResponse(pkt, *slavePorts[slave_port_id],
65810402SN/A                                    *slavePorts[dest_port_id]);
65910402SN/A        }
66010402SN/A
66110402SN/A        DPRINTF(CoherentXBar, "%s: src %s packet %s FWD RESP\n", __func__,
66211744Snikos.nikoleris@arm.com                src_port->name(), pkt->print());
66311744Snikos.nikoleris@arm.com
66410402SN/A        // as a normal response, it should go back to a master through
6659714SN/A        // one of our slave ports, we also pay for any outstanding
66610888Sandreas.hansson@arm.com        // header latency
66710888Sandreas.hansson@arm.com        Tick latency = pkt->headerDelay;
66810888Sandreas.hansson@arm.com        pkt->headerDelay = 0;
66910888Sandreas.hansson@arm.com        slavePorts[dest_port_id]->schedTimingResp(pkt, curTick() + latency);
67010888Sandreas.hansson@arm.com
6719716SN/A        respLayers[dest_port_id]->succeededTiming(packetFinishTime);
6729716SN/A    }
6733244SN/A
6743244SN/A    // remove the request from the routing table
67510656Sandreas.hansson@arm.com    routeTo.erase(route_lookup);
67610656Sandreas.hansson@arm.com
67710656Sandreas.hansson@arm.com    // stats updates
6789712SN/A    transDist[pkt_cmd]++;
6799712SN/A    snoops++;
68010405Sandreas.hansson@arm.com    snoopTraffic += pkt_size;
68111564Sdavid.guillen@arm.com
6829712SN/A    return true;
6838948SN/A}
6848948SN/A
6858948SN/A
6863210SN/Avoid
6878948SN/ACoherentXBar::forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
68810405Sandreas.hansson@arm.com                           const std::vector<QueuedSlavePort*>& dests)
68910888Sandreas.hansson@arm.com{
6908948SN/A    DPRINTF(CoherentXBar, "%s for %s\n", __func__, pkt->print());
69111744Snikos.nikoleris@arm.com
6929663SN/A    // snoops should only happen if the system isn't bypassing caches
6939524SN/A    assert(!system->bypassCaches());
6949524SN/A
6959524SN/A    unsigned fanout = 0;
69610401SN/A
69710401SN/A    for (const auto& p: dests) {
69810405Sandreas.hansson@arm.com        // we could have gotten this request from a snooping master
6998948SN/A        // (corresponding to our own slave port that is also in
7008948SN/A        // snoopPorts) and should not send it back to where it came
7018948SN/A        // from
7028948SN/A        if (exclude_slave_port_id == InvalidPortID ||
7039031SN/A            p->getId() != exclude_slave_port_id) {
7048948SN/A            // cache is not allowed to refuse snoop
7058948SN/A            p->sendTimingSnoopReq(pkt);
7068975SN/A            fanout++;
70710401SN/A        }
7088948SN/A    }
7098948SN/A
71010401SN/A    // Stats for fanout of this forward operation
71110401SN/A    snoopFanout.sample(fanout);
71210401SN/A}
7132497SN/A
7142497SN/Avoid
7159092SN/ACoherentXBar::recvReqRetry(PortID master_port_id)
71610713Sandreas.hansson@arm.com{
7179092SN/A    // responses and snoop responses never block on forwarding them,
7189093SN/A    // so the retry will always be coming from a port to which we
7199093SN/A    // tried to forward a request
7209093SN/A    reqLayers[master_port_id]->recvRetry();
7219715SN/A}
7229092SN/A
7239092SN/ATick
7249036SN/ACoherentXBar::recvAtomic(PacketPtr pkt, PortID slave_port_id)
72513847Sgabeblack@google.com{
72613847Sgabeblack@google.com    DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
7272657SN/A            slavePorts[slave_port_id]->name(), pkt->print());
72811744Snikos.nikoleris@arm.com
72911744Snikos.nikoleris@arm.com    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
7308915SN/A    unsigned int pkt_cmd = pkt->cmdToIndex();
73110405Sandreas.hansson@arm.com
73210405Sandreas.hansson@arm.com    MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
7339712SN/A    Tick snoop_response_latency = 0;
7348979SN/A
7358979SN/A    // is this the destination point for this packet? (e.g. true if
7368979SN/A    // this xbar is the PoC for a cache maintenance operation to the
73712346Snikos.nikoleris@arm.com    // PoC) otherwise the destination is any cache that can satisfy
73812346Snikos.nikoleris@arm.com    // the request
73912346Snikos.nikoleris@arm.com    const bool is_destination = isDestination(pkt);
74012346Snikos.nikoleris@arm.com
74112346Snikos.nikoleris@arm.com    const bool snoop_caches = !system->bypassCaches() &&
74212346Snikos.nikoleris@arm.com        pkt->cmd != MemCmd::WriteClean;
74312345Snikos.nikoleris@arm.com    if (snoop_caches) {
74412345Snikos.nikoleris@arm.com        // forward to all snoopers but the source
74512345Snikos.nikoleris@arm.com        std::pair<MemCmd, Tick> snoop_result;
7468979SN/A        if (snoopFilter) {
74710402SN/A            // check with the snoop filter where to forward this packet
74810402SN/A            auto sf_res =
74910402SN/A                snoopFilter->lookupRequest(pkt, *slavePorts[slave_port_id]);
75010402SN/A            snoop_response_latency += sf_res.second * clockPeriod();
75110402SN/A            DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
75210402SN/A                    __func__, slavePorts[slave_port_id]->name(), pkt->print(),
75311744Snikos.nikoleris@arm.com                    sf_res.first.size(), sf_res.second);
75411744Snikos.nikoleris@arm.com
75511744Snikos.nikoleris@arm.com            // let the snoop filter know about the success of the send
75611130Sali.jafri@arm.com            // operation, and do it even before sending it onwards to
75711130Sali.jafri@arm.com            // avoid situations where atomic upward snoops sneak in
75811130Sali.jafri@arm.com            // between and change the filter state
75911130Sali.jafri@arm.com            snoopFilter->finishRequest(false, pkt->getAddr(), pkt->isSecure());
76011130Sali.jafri@arm.com
76111605Snikos.nikoleris@arm.com            if (pkt->isEviction()) {
76211130Sali.jafri@arm.com                // for block-evicting packets, i.e. writebacks and
76312241Snikos.nikoleris@arm.com                // clean evictions, there is no need to snoop up, as
76412241Snikos.nikoleris@arm.com                // all we do is determine if the block is cached or
76512241Snikos.nikoleris@arm.com                // not, instead just set it here based on the snoop
76612241Snikos.nikoleris@arm.com                // filter result
76712241Snikos.nikoleris@arm.com                if (!sf_res.first.empty())
76812241Snikos.nikoleris@arm.com                    pkt->setBlockCached();
76912241Snikos.nikoleris@arm.com            } else {
77012241Snikos.nikoleris@arm.com                snoop_result = forwardAtomic(pkt, slave_port_id, InvalidPortID,
77112241Snikos.nikoleris@arm.com                                             sf_res.first);
77212241Snikos.nikoleris@arm.com            }
77312241Snikos.nikoleris@arm.com        } else {
77412241Snikos.nikoleris@arm.com            snoop_result = forwardAtomic(pkt, slave_port_id);
77510402SN/A        }
77610402SN/A        snoop_response_cmd = snoop_result.first;
77710402SN/A        snoop_response_latency += snoop_result.second;
7788979SN/A    }
77910402SN/A
7808979SN/A    // set up a sensible default value
7818915SN/A    Tick response_latency = 0;
78211334Sandreas.hansson@arm.com
78311334Sandreas.hansson@arm.com    const bool sink_packet = sinkPacket(pkt);
78411334Sandreas.hansson@arm.com
78511334Sandreas.hansson@arm.com    // even if we had a snoop response, we must continue and also
78611130Sali.jafri@arm.com    // perform the actual request at the destination
7878948SN/A    AddrRange addr_range = RangeSize(pkt->getAddr(), pkt->getSize());
7888948SN/A    PortID master_port_id = findPort(addr_range);
78913856Sodanrc@yahoo.com.br
79010405Sandreas.hansson@arm.com    if (sink_packet) {
79111334Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "%s: Not forwarding %s\n", __func__,
79211744Snikos.nikoleris@arm.com                pkt->print());
79311744Snikos.nikoleris@arm.com    } else {
79411334Sandreas.hansson@arm.com        if (forwardPacket(pkt)) {
79512346Snikos.nikoleris@arm.com            // make sure that the write request (e.g., WriteClean)
79612346Snikos.nikoleris@arm.com            // will stop at the memory below if this crossbar is its
79712346Snikos.nikoleris@arm.com            // destination
79812346Snikos.nikoleris@arm.com            if (pkt->isWrite() && is_destination) {
79912346Snikos.nikoleris@arm.com                pkt->clearWriteThrough();
80012346Snikos.nikoleris@arm.com            }
80112346Snikos.nikoleris@arm.com
80212346Snikos.nikoleris@arm.com            // forward the request to the appropriate destination
80311334Sandreas.hansson@arm.com            response_latency = masterPorts[master_port_id]->sendAtomic(pkt);
80413847Sgabeblack@google.com        } else {
80513847Sgabeblack@google.com            // if it does not need a response we sink the packet above
80613847Sgabeblack@google.com            assert(pkt->needsResponse());
80713847Sgabeblack@google.com
80811334Sandreas.hansson@arm.com            pkt->makeResponse();
80911334Sandreas.hansson@arm.com        }
81011334Sandreas.hansson@arm.com    }
81111334Sandreas.hansson@arm.com
81211334Sandreas.hansson@arm.com    // stats updates for the request
81311334Sandreas.hansson@arm.com    pktCount[slave_port_id][master_port_id]++;
81411334Sandreas.hansson@arm.com    pktSize[slave_port_id][master_port_id] += pkt_size;
81511334Sandreas.hansson@arm.com    transDist[pkt_cmd]++;
81610405Sandreas.hansson@arm.com
81710405Sandreas.hansson@arm.com
81810405Sandreas.hansson@arm.com    // if lower levels have replied, tell the snoop filter
81910405Sandreas.hansson@arm.com    if (!system->bypassCaches() && snoopFilter && pkt->isResponse()) {
8208948SN/A        snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
8218948SN/A    }
82211130Sali.jafri@arm.com
82311130Sali.jafri@arm.com    // if we got a response from a snooper, restore it here
82410402SN/A    if (snoop_response_cmd != MemCmd::InvalidCmd) {
82510402SN/A        // no one else should have responded
82610402SN/A        assert(!pkt->isResponse());
8278948SN/A        pkt->cmd = snoop_response_cmd;
8288948SN/A        response_latency = snoop_response_latency;
8298948SN/A    }
8308948SN/A
8318948SN/A    // If this is the destination of the cache clean operation the
8328948SN/A    // crossbar is responsible for responding. This crossbar will
8338948SN/A    // respond when the cache clean is complete. An atomic cache clean
8348948SN/A    // is complete when the crossbars receives the cache clean
83512351Snikos.nikoleris@arm.com    // request (CleanSharedReq, CleanInvalidReq), as either:
83612351Snikos.nikoleris@arm.com    // * no cache above had a dirty copy of the block as indicated by
83712351Snikos.nikoleris@arm.com    //   the satisfied flag of the packet, or
83812351Snikos.nikoleris@arm.com    // * the crossbar has already seen the corresponding write
83912351Snikos.nikoleris@arm.com    //   (WriteClean) which updates the block in the memory below.
84012351Snikos.nikoleris@arm.com    if (pkt->isClean() && isDestination(pkt) && pkt->satisfied()) {
84112351Snikos.nikoleris@arm.com        auto it = outstandingCMO.find(pkt->id);
84212351Snikos.nikoleris@arm.com        assert(it != outstandingCMO.end());
84312351Snikos.nikoleris@arm.com        // we are responding right away
84412351Snikos.nikoleris@arm.com        outstandingCMO.erase(it);
84512351Snikos.nikoleris@arm.com    } else if (pkt->cmd == MemCmd::WriteClean && isDestination(pkt)) {
84612351Snikos.nikoleris@arm.com        // if this is the destination of the operation, the xbar
84712351Snikos.nikoleris@arm.com        // sends the responce to the cache clean operation only
84812351Snikos.nikoleris@arm.com        // after having encountered the cache clean request
84912351Snikos.nikoleris@arm.com        auto M5_VAR_USED ret = outstandingCMO.emplace(pkt->id, nullptr);
85012351Snikos.nikoleris@arm.com        // in atomic mode we know that the WriteClean packet should
85112351Snikos.nikoleris@arm.com        // precede the clean request
85212351Snikos.nikoleris@arm.com        assert(ret.second);
85312351Snikos.nikoleris@arm.com    }
85412351Snikos.nikoleris@arm.com
85512351Snikos.nikoleris@arm.com    // add the response data
85612351Snikos.nikoleris@arm.com    if (pkt->isResponse()) {
85712351Snikos.nikoleris@arm.com        pkt_size = pkt->hasData() ? pkt->getSize() : 0;
85812351Snikos.nikoleris@arm.com        pkt_cmd = pkt->cmdToIndex();
8599712SN/A
86010405Sandreas.hansson@arm.com        // stats updates
86110405Sandreas.hansson@arm.com        pktCount[slave_port_id][master_port_id]++;
86210405Sandreas.hansson@arm.com        pktSize[slave_port_id][master_port_id] += pkt_size;
86310405Sandreas.hansson@arm.com        transDist[pkt_cmd]++;
86410405Sandreas.hansson@arm.com    }
86510405Sandreas.hansson@arm.com
86610405Sandreas.hansson@arm.com    // @todo: Not setting header time
86710405Sandreas.hansson@arm.com    pkt->payloadDelay = response_latency;
86810405Sandreas.hansson@arm.com    return response_latency;
8699712SN/A}
87010694SMarco.Balboni@ARM.com
87110694SMarco.Balboni@ARM.comTick
8728948SN/ACoherentXBar::recvAtomicSnoop(PacketPtr pkt, PortID master_port_id)
8738948SN/A{
8748948SN/A    DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
8758948SN/A            masterPorts[master_port_id]->name(), pkt->print());
87610405Sandreas.hansson@arm.com
8778948SN/A    // add the request snoop data
87811744Snikos.nikoleris@arm.com    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
87911744Snikos.nikoleris@arm.com    snoops++;
8808948SN/A    snoopTraffic += pkt_size;
8819712SN/A
88211564Sdavid.guillen@arm.com    // forward to all snoopers
88310405Sandreas.hansson@arm.com    std::pair<MemCmd, Tick> snoop_result;
88411564Sdavid.guillen@arm.com    Tick snoop_response_latency = 0;
8859712SN/A    if (snoopFilter) {
8868948SN/A        auto sf_res = snoopFilter->lookupSnoop(pkt);
88710402SN/A        snoop_response_latency += sf_res.second * clockPeriod();
88810402SN/A        DPRINTF(CoherentXBar, "%s: src %s packet %s SF size: %i lat: %i\n",
88910402SN/A                __func__, masterPorts[master_port_id]->name(), pkt->print(),
89010402SN/A                sf_res.first.size(), sf_res.second);
89110402SN/A        snoop_result = forwardAtomic(pkt, InvalidPortID, master_port_id,
89211744Snikos.nikoleris@arm.com                                     sf_res.first);
89311744Snikos.nikoleris@arm.com    } else {
89411744Snikos.nikoleris@arm.com        snoop_result = forwardAtomic(pkt, InvalidPortID);
89510402SN/A    }
89610402SN/A    MemCmd snoop_response_cmd = snoop_result.first;
89710402SN/A    snoop_response_latency += snoop_result.second;
89810402SN/A
89910402SN/A    if (snoop_response_cmd != MemCmd::InvalidCmd)
9008948SN/A        pkt->cmd = snoop_response_cmd;
90110402SN/A
9028948SN/A    // add the response snoop data
9038948SN/A    if (pkt->isResponse()) {
9048948SN/A        snoops++;
9058948SN/A    }
9069712SN/A
90710401SN/A    // @todo: Not setting header time
90810405Sandreas.hansson@arm.com    pkt->payloadDelay = snoop_response_latency;
90910401SN/A    return snoop_response_latency;
9109712SN/A}
91110694SMarco.Balboni@ARM.com
91210694SMarco.Balboni@ARM.comstd::pair<MemCmd, Tick>
9138948SN/ACoherentXBar::forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id,
9148948SN/A                           PortID source_master_port_id,
9158948SN/A                           const std::vector<QueuedSlavePort*>& dests)
9168948SN/A{
91710405Sandreas.hansson@arm.com    // the packet may be changed on snoops, record the original
91810402SN/A    // command to enable us to restore it between snoops so that
91910888Sandreas.hansson@arm.com    // additional snoops can take place properly
9208948SN/A    MemCmd orig_cmd = pkt->cmd;
9219032SN/A    MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
9229032SN/A    Tick snoop_response_latency = 0;
9238948SN/A
9244626SN/A    // snoops should only happen if the system isn't bypassing caches
9254879SN/A    assert(!system->bypassCaches());
9264879SN/A
9273662SN/A    unsigned fanout = 0;
9289524SN/A
9299524SN/A    for (const auto& p: dests) {
9309524SN/A        // we could have gotten this request from a snooping master
93110401SN/A        // (corresponding to our own slave port that is also in
93210401SN/A        // snoopPorts) and should not send it back to where it came
93310405Sandreas.hansson@arm.com        // from
9348915SN/A        if (exclude_slave_port_id != InvalidPortID &&
9358915SN/A            p->getId() == exclude_slave_port_id)
9368915SN/A            continue;
9378915SN/A
93810402SN/A        Tick latency = p->sendAtomicSnoop(pkt);
93910402SN/A        fanout++;
94010402SN/A
94110401SN/A        // in contrast to a functional access, we have to keep on
94210402SN/A        // going as all snoopers must be updated even if we get a
94310402SN/A        // response
94410402SN/A        if (!pkt->isResponse())
94510402SN/A            continue;
94610402SN/A
94710402SN/A        // response from snoop agent
94810402SN/A        assert(pkt->cmd != orig_cmd);
94910402SN/A        assert(pkt->cacheResponding());
95010402SN/A        // should only happen once
95110402SN/A        assert(snoop_response_cmd == MemCmd::InvalidCmd);
95210402SN/A        // save response state
95311284Sandreas.hansson@arm.com        snoop_response_cmd = pkt->cmd;
95410402SN/A        snoop_response_latency = latency;
95510402SN/A
95610402SN/A        if (snoopFilter) {
95710402SN/A            // Handle responses by the snoopers and differentiate between
95810402SN/A            // responses to requests from above and snoops from below
95910402SN/A            if (source_master_port_id != InvalidPortID) {
96010402SN/A                // Getting a response for a snoop from below
96110402SN/A                assert(exclude_slave_port_id == InvalidPortID);
96210402SN/A                snoopFilter->updateSnoopForward(pkt, *p,
96310402SN/A                             *masterPorts[source_master_port_id]);
96410402SN/A            } else {
96510402SN/A                // Getting a response for a request from above
96610402SN/A                assert(source_master_port_id == InvalidPortID);
96710402SN/A                snoopFilter->updateSnoopResponse(pkt, *p,
96810402SN/A                             *slavePorts[exclude_slave_port_id]);
96910402SN/A            }
97010402SN/A        }
97110402SN/A        // restore original packet state for remaining snoopers
97210402SN/A        pkt->cmd = orig_cmd;
9734626SN/A    }
9744626SN/A
97510402SN/A    // Stats for fanout
97610402SN/A    snoopFanout.sample(fanout);
9774626SN/A
9784626SN/A    // the packet is restored as part of the loop and any potential
97910401SN/A    // snoop response is part of the returned pair
98010401SN/A    return std::make_pair(snoop_response_cmd, snoop_response_latency);
98110401SN/A}
9828948SN/A
9838948SN/Avoid
9848948SN/ACoherentXBar::recvFunctional(PacketPtr pkt, PortID slave_port_id)
9852497SN/A{
9862497SN/A    if (!pkt->isPrint()) {
9872497SN/A        // don't do DPRINTFs on PrintReq as it clutters up the output
98810405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
9892497SN/A                slavePorts[slave_port_id]->name(), pkt->print());
9908663SN/A    }
9918663SN/A
99211744Snikos.nikoleris@arm.com    if (!system->bypassCaches()) {
99311744Snikos.nikoleris@arm.com        // forward to all snoopers but the source
9948663SN/A        forwardFunctional(pkt, slave_port_id);
9958663SN/A    }
99610821Sandreas.hansson@arm.com
9978979SN/A    // there is no need to continue if the snooping has found what we
9989032SN/A    // were looking for and the packet is already a response
9998979SN/A    if (!pkt->isResponse()) {
10004912SN/A        // since our slave ports are queued ports we need to check them as well
10018948SN/A        for (const auto& p : slavePorts) {
10028948SN/A            // if we find a response that has the data, then the
10038948SN/A            // downstream caches/memories may be out of date, so simply stop
100410888Sandreas.hansson@arm.com            // here
100510888Sandreas.hansson@arm.com            if (p->checkFunctional(pkt)) {
100610888Sandreas.hansson@arm.com                if (pkt->needsResponse())
100710888Sandreas.hansson@arm.com                    pkt->makeResponse();
100810888Sandreas.hansson@arm.com                return;
100912823Srmk35@cl.cam.ac.uk            }
101010888Sandreas.hansson@arm.com        }
101110888Sandreas.hansson@arm.com
101210888Sandreas.hansson@arm.com        PortID dest_id = findPort(RangeSize(pkt->getAddr(), pkt->getSize()));
101310888Sandreas.hansson@arm.com
101410888Sandreas.hansson@arm.com        masterPorts[dest_id]->sendFunctional(pkt);
101510888Sandreas.hansson@arm.com    }
101613856Sodanrc@yahoo.com.br}
10178948SN/A
10188948SN/Avoid
10198948SN/ACoherentXBar::recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id)
10208948SN/A{
10218948SN/A    if (!pkt->isPrint()) {
10228948SN/A        // don't do DPRINTFs on PrintReq as it clutters up the output
102310405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "%s: src %s packet %s\n", __func__,
10248948SN/A                masterPorts[master_port_id]->name(), pkt->print());
10258948SN/A    }
10268948SN/A
102711744Snikos.nikoleris@arm.com    for (const auto& p : slavePorts) {
102811744Snikos.nikoleris@arm.com        if (p->checkFunctional(pkt)) {
10298948SN/A            if (pkt->needsResponse())
10308948SN/A                pkt->makeResponse();
103111188Sandreas.sandberg@arm.com            return;
103212823Srmk35@cl.cam.ac.uk        }
103311188Sandreas.sandberg@arm.com    }
103411188Sandreas.sandberg@arm.com
103511188Sandreas.sandberg@arm.com    // forward to all snoopers
103611188Sandreas.sandberg@arm.com    forwardFunctional(pkt, InvalidPortID);
103711188Sandreas.sandberg@arm.com}
103811188Sandreas.sandberg@arm.com
10398948SN/Avoid
10409031SN/ACoherentXBar::forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id)
10418948SN/A{
10428948SN/A    // snoops should only happen if the system isn't bypassing caches
10438948SN/A    assert(!system->bypassCaches());
104410405Sandreas.hansson@arm.com
10458948SN/A    for (const auto& p: snoopPorts) {
10469524SN/A        // we could have gotten this request from a snooping master
10479524SN/A        // (corresponding to our own slave port that is also in
10489524SN/A        // snoopPorts) and should not send it back to where it came
104910405Sandreas.hansson@arm.com        // from
10508915SN/A        if (exclude_slave_port_id == InvalidPortID ||
10518915SN/A            p->getId() != exclude_slave_port_id)
10528915SN/A            p->sendFunctionalSnoop(pkt);
10538915SN/A
10549031SN/A        // if we get a response we are done
10558948SN/A        if (pkt->isResponse()) {
10568948SN/A            break;
10578915SN/A        }
10588948SN/A    }
10598948SN/A}
10608948SN/A
10618915SN/Abool
10623650SN/ACoherentXBar::sinkPacket(const PacketPtr pkt) const
10632497SN/A{
10642497SN/A    // we can sink the packet if:
106511334Sandreas.hansson@arm.com    // 1) the crossbar is the point of coherency, and a cache is
106611334Sandreas.hansson@arm.com    //    responding after being snooped
106711334Sandreas.hansson@arm.com    // 2) the crossbar is the point of coherency, and the packet is a
106811334Sandreas.hansson@arm.com    //    coherency packet (not a read or a write) that does not
106911334Sandreas.hansson@arm.com    //    require a response
107011334Sandreas.hansson@arm.com    // 3) this is a clean evict or clean writeback, but the packet is
107111334Sandreas.hansson@arm.com    //    found in a cache above this crossbar
107211334Sandreas.hansson@arm.com    // 4) a cache is responding after being snooped, and the packet
107311334Sandreas.hansson@arm.com    //    either does not need the block to be writable, or the cache
107411334Sandreas.hansson@arm.com    //    that has promised to respond (setting the cache responding
107511334Sandreas.hansson@arm.com    //    flag) is providing writable and thus had a Modified block,
107611334Sandreas.hansson@arm.com    //    and no further action is needed
107711334Sandreas.hansson@arm.com    return (pointOfCoherency && pkt->cacheResponding()) ||
107811334Sandreas.hansson@arm.com        (pointOfCoherency && !(pkt->isRead() || pkt->isWrite()) &&
107911334Sandreas.hansson@arm.com         !pkt->needsResponse()) ||
108011334Sandreas.hansson@arm.com        (pkt->isCleanEviction() && pkt->isBlockCached()) ||
108111334Sandreas.hansson@arm.com        (pkt->cacheResponding() &&
108211334Sandreas.hansson@arm.com         (!pkt->needsWritable() || pkt->responderHadWritable()));
108311334Sandreas.hansson@arm.com}
108411334Sandreas.hansson@arm.com
108511334Sandreas.hansson@arm.combool
108611334Sandreas.hansson@arm.comCoherentXBar::forwardPacket(const PacketPtr pkt)
108711334Sandreas.hansson@arm.com{
108811334Sandreas.hansson@arm.com    // we are forwarding the packet if:
108912346Snikos.nikoleris@arm.com    // 1) this is a cache clean request to the PoU/PoC and this
109012346Snikos.nikoleris@arm.com    //    crossbar is above the PoU/PoC
109112346Snikos.nikoleris@arm.com    // 2) this is a read or a write
109212346Snikos.nikoleris@arm.com    // 3) this crossbar is above the point of coherency
109312351Snikos.nikoleris@arm.com    if (pkt->isClean()) {
109412351Snikos.nikoleris@arm.com        return !isDestination(pkt);
109512351Snikos.nikoleris@arm.com    }
109612351Snikos.nikoleris@arm.com    return pkt->isRead() || pkt->isWrite() || !pointOfCoherency;
109712351Snikos.nikoleris@arm.com}
109812351Snikos.nikoleris@arm.com
109912351Snikos.nikoleris@arm.com
110012346Snikos.nikoleris@arm.comvoid
110112346Snikos.nikoleris@arm.comCoherentXBar::regStats()
110212346Snikos.nikoleris@arm.com{
110312346Snikos.nikoleris@arm.com    // register the stats of the base class and our layers
11049712SN/A    BaseXBar::regStats();
110510405Sandreas.hansson@arm.com    for (auto l: reqLayers)
11069712SN/A        l->regStats();
110710405Sandreas.hansson@arm.com    for (auto l: respLayers)
110810405Sandreas.hansson@arm.com        l->regStats();
110910405Sandreas.hansson@arm.com    for (auto l: snoopLayers)
111010405Sandreas.hansson@arm.com        l->regStats();
111110405Sandreas.hansson@arm.com
111210405Sandreas.hansson@arm.com    snoops
111310405Sandreas.hansson@arm.com        .name(name() + ".snoops")
111410405Sandreas.hansson@arm.com        .desc("Total snoops (count)")
11159712SN/A    ;
111610405Sandreas.hansson@arm.com
111710405Sandreas.hansson@arm.com    snoopTraffic
111810401SN/A        .name(name() + ".snoopTraffic")
111910401SN/A        .desc("Total snoop traffic (bytes)")
112010401SN/A    ;
112111564Sdavid.guillen@arm.com
112211564Sdavid.guillen@arm.com    snoopFanout
112311564Sdavid.guillen@arm.com        .init(0, snoopPorts.size(), 1)
112411564Sdavid.guillen@arm.com        .name(name() + ".snoop_fanout")
112511564Sdavid.guillen@arm.com        .desc("Request fanout histogram")
112610401SN/A    ;
112710401SN/A}
112810401SN/A
112910401SN/ACoherentXBar *
113010401SN/ACoherentXBarParams::create()
11319712SN/A{
11329712SN/A    return new CoherentXBar(this);
113310405Sandreas.hansson@arm.com}
113410405Sandreas.hansson@arm.com