coherent_xbar.cc revision 10719
12497SN/A/*
210719SMarco.Balboni@ARM.com * Copyright (c) 2011-2015 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
432497SN/A */
442497SN/A
452497SN/A/**
462982SN/A * @file
4710405Sandreas.hansson@arm.com * Definition of a crossbar object.
482497SN/A */
492497SN/A
502846SN/A#include "base/misc.hh"
512548SN/A#include "base/trace.hh"
5210405Sandreas.hansson@arm.com#include "debug/AddrRanges.hh"
5310405Sandreas.hansson@arm.com#include "debug/CoherentXBar.hh"
5410405Sandreas.hansson@arm.com#include "mem/coherent_xbar.hh"
559524SN/A#include "sim/system.hh"
562497SN/A
5710405Sandreas.hansson@arm.comCoherentXBar::CoherentXBar(const CoherentXBarParams *p)
5810719SMarco.Balboni@ARM.com    : BaseXBar(p), system(p->system), snoopFilter(p->snoop_filter),
5910719SMarco.Balboni@ARM.com      snoopResponseLatency(p->snoop_response_latency)
607523SN/A{
618851SN/A    // create the ports based on the size of the master and slave
628948SN/A    // vector ports, and the presence of the default port, the ports
638948SN/A    // are enumerated starting from zero
648851SN/A    for (int i = 0; i < p->port_master_connection_count; ++i) {
659095SN/A        std::string portName = csprintf("%s.master[%d]", name(), i);
6610405Sandreas.hansson@arm.com        MasterPort* bp = new CoherentXBarMasterPort(portName, *this, i);
678922SN/A        masterPorts.push_back(bp);
689715SN/A        reqLayers.push_back(new ReqLayer(*bp, *this,
699715SN/A                                         csprintf(".reqLayer%d", i)));
7010713Sandreas.hansson@arm.com        snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
7110713Sandreas.hansson@arm.com                                                 csprintf(".snoopLayer%d", i)));
728851SN/A    }
738851SN/A
748948SN/A    // see if we have a default slave device connected and if so add
758948SN/A    // our corresponding master port
768915SN/A    if (p->port_default_connection_count) {
779031SN/A        defaultPortID = masterPorts.size();
789095SN/A        std::string portName = name() + ".default";
7910405Sandreas.hansson@arm.com        MasterPort* bp = new CoherentXBarMasterPort(portName, *this,
809036SN/A                                                   defaultPortID);
818922SN/A        masterPorts.push_back(bp);
829715SN/A        reqLayers.push_back(new ReqLayer(*bp, *this, csprintf(".reqLayer%d",
839715SN/A                                             defaultPortID)));
8410713Sandreas.hansson@arm.com        snoopLayers.push_back(new SnoopRespLayer(*bp, *this,
8510713Sandreas.hansson@arm.com                                                 csprintf(".snoopLayer%d",
8610713Sandreas.hansson@arm.com                                                          defaultPortID)));
878915SN/A    }
888915SN/A
898948SN/A    // create the slave ports, once again starting at zero
908851SN/A    for (int i = 0; i < p->port_slave_connection_count; ++i) {
919095SN/A        std::string portName = csprintf("%s.slave[%d]", name(), i);
9210405Sandreas.hansson@arm.com        SlavePort* bp = new CoherentXBarSlavePort(portName, *this, i);
938922SN/A        slavePorts.push_back(bp);
949715SN/A        respLayers.push_back(new RespLayer(*bp, *this,
959715SN/A                                           csprintf(".respLayer%d", i)));
969716SN/A        snoopRespPorts.push_back(new SnoopRespPort(*bp, *this));
978851SN/A    }
988851SN/A
9910402SN/A    if (snoopFilter)
10010402SN/A        snoopFilter->setSlavePorts(slavePorts);
10110402SN/A
1027523SN/A    clearPortCache();
1037523SN/A}
1047523SN/A
10510405Sandreas.hansson@arm.comCoherentXBar::~CoherentXBar()
1069715SN/A{
10710405Sandreas.hansson@arm.com    for (auto l: reqLayers)
10810405Sandreas.hansson@arm.com        delete l;
10910405Sandreas.hansson@arm.com    for (auto l: respLayers)
11010405Sandreas.hansson@arm.com        delete l;
11110405Sandreas.hansson@arm.com    for (auto l: snoopLayers)
11210405Sandreas.hansson@arm.com        delete l;
11310405Sandreas.hansson@arm.com    for (auto p: snoopRespPorts)
11410405Sandreas.hansson@arm.com        delete p;
1159715SN/A}
1169715SN/A
1172568SN/Avoid
11810405Sandreas.hansson@arm.comCoherentXBar::init()
1192568SN/A{
1209278SN/A    // the base class is responsible for determining the block size
12110405Sandreas.hansson@arm.com    BaseXBar::init();
1229278SN/A
1238948SN/A    // iterate over our slave ports and determine which of our
1248948SN/A    // neighbouring master ports are snooping and add them as snoopers
12510405Sandreas.hansson@arm.com    for (const auto& p: slavePorts) {
1269088SN/A        // check if the connected master port is snooping
12710405Sandreas.hansson@arm.com        if (p->isSnooping()) {
12810405Sandreas.hansson@arm.com            DPRINTF(AddrRanges, "Adding snooping master %s\n",
12910405Sandreas.hansson@arm.com                    p->getMasterPort().name());
13010405Sandreas.hansson@arm.com            snoopPorts.push_back(p);
1318711SN/A        }
1328711SN/A    }
1332568SN/A
1349036SN/A    if (snoopPorts.empty())
13510405Sandreas.hansson@arm.com        warn("CoherentXBar %s has no snooping ports attached!\n", name());
1363244SN/A}
1373244SN/A
1388948SN/Abool
13910405Sandreas.hansson@arm.comCoherentXBar::recvTimingReq(PacketPtr pkt, PortID slave_port_id)
1403244SN/A{
1418975SN/A    // determine the source port based on the id
1429032SN/A    SlavePort *src_port = slavePorts[slave_port_id];
1433244SN/A
1449091SN/A    // remember if the packet is an express snoop
1459091SN/A    bool is_express_snoop = pkt->isExpressSnoop();
14610656Sandreas.hansson@arm.com    bool is_inhibited = pkt->memInhibitAsserted();
14710656Sandreas.hansson@arm.com    // for normal requests, going downstream, the express snoop flag
14810656Sandreas.hansson@arm.com    // and the inhibited flag should always be the same
14910656Sandreas.hansson@arm.com    assert(is_express_snoop == is_inhibited);
1509091SN/A
1519612SN/A    // determine the destination based on the address
1529712SN/A    PortID master_port_id = findPort(pkt->getAddr());
1539612SN/A
15410405Sandreas.hansson@arm.com    // test if the crossbar should be considered occupied for the current
1559033SN/A    // port, and exclude express snoops from the check
1569715SN/A    if (!is_express_snoop && !reqLayers[master_port_id]->tryTiming(src_port)) {
15710405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "recvTimingReq: src %s %s 0x%x BUSY\n",
1588949SN/A                src_port->name(), pkt->cmdString(), pkt->getAddr());
1593244SN/A        return false;
1603244SN/A    }
1613244SN/A
16210405Sandreas.hansson@arm.com    DPRINTF(CoherentXBar, "recvTimingReq: src %s %s expr %d 0x%x\n",
1639091SN/A            src_port->name(), pkt->cmdString(), is_express_snoop,
1649091SN/A            pkt->getAddr());
1655197SN/A
1669712SN/A    // store size and command as they might be modified when
1679712SN/A    // forwarding the packet
1689712SN/A    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
1699712SN/A    unsigned int pkt_cmd = pkt->cmdToIndex();
1709712SN/A
17110719SMarco.Balboni@ARM.com    // store the old header delay so we can restore it if needed
17210719SMarco.Balboni@ARM.com    Tick old_header_delay = pkt->headerDelay;
17310719SMarco.Balboni@ARM.com
17410719SMarco.Balboni@ARM.com    // a request sees the frontend and forward latency
17510719SMarco.Balboni@ARM.com    Tick xbar_delay = (frontendLatency + forwardLatency) * clockPeriod();
17610719SMarco.Balboni@ARM.com
17710719SMarco.Balboni@ARM.com    // set the packet header and payload delay
17810719SMarco.Balboni@ARM.com    calcPacketTiming(pkt, xbar_delay);
17910719SMarco.Balboni@ARM.com
18010719SMarco.Balboni@ARM.com    // determine how long to be crossbar layer is busy
18110719SMarco.Balboni@ARM.com    Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
1824912SN/A
1838979SN/A    // uncacheable requests need never be snooped
1849524SN/A    if (!pkt->req->isUncacheable() && !system->bypassCaches()) {
1858979SN/A        // the packet is a memory-mapped request and should be
1868979SN/A        // broadcasted to our snoopers but the source
18710402SN/A        if (snoopFilter) {
18810402SN/A            // check with the snoop filter where to forward this packet
18910402SN/A            auto sf_res = snoopFilter->lookupRequest(pkt, *src_port);
19010719SMarco.Balboni@ARM.com            // If SnoopFilter is enabled, the total time required by a packet
19110719SMarco.Balboni@ARM.com            // to be delivered through the xbar has to be charged also with
19210719SMarco.Balboni@ARM.com            // to lookup latency of the snoop filter (sf_res.second).
19310719SMarco.Balboni@ARM.com            pkt->headerDelay += sf_res.second * clockPeriod();
19410402SN/A            packetFinishTime += sf_res.second * clockPeriod();
19510405Sandreas.hansson@arm.com            DPRINTF(CoherentXBar, "recvTimingReq: src %s %s 0x%x"\
19610402SN/A                    " SF size: %i lat: %i\n", src_port->name(),
19710402SN/A                    pkt->cmdString(), pkt->getAddr(), sf_res.first.size(),
19810402SN/A                    sf_res.second);
19910402SN/A            forwardTiming(pkt, slave_port_id, sf_res.first);
20010402SN/A        } else {
20110402SN/A            forwardTiming(pkt, slave_port_id);
20210402SN/A        }
2038979SN/A    }
2048948SN/A
20510656Sandreas.hansson@arm.com    // remember if the packet will generate a snoop response
20610656Sandreas.hansson@arm.com    const bool expect_snoop_resp = !is_inhibited && pkt->memInhibitAsserted();
20710656Sandreas.hansson@arm.com    const bool expect_response = pkt->needsResponse() &&
20810656Sandreas.hansson@arm.com        !pkt->memInhibitAsserted();
2098915SN/A
21010402SN/A    // Note: Cannot create a copy of the full packet, here.
21110402SN/A    MemCmd orig_cmd(pkt->cmd);
21210402SN/A
2139612SN/A    // since it is a normal request, attempt to send the packet
2149712SN/A    bool success = masterPorts[master_port_id]->sendTimingReq(pkt);
2158948SN/A
21610402SN/A    if (snoopFilter && !pkt->req->isUncacheable()
21710402SN/A        && !system->bypassCaches()) {
21810402SN/A        // The packet may already be overwritten by the sendTimingReq function.
21910402SN/A        // The snoop filter needs to see the original request *and* the return
22010402SN/A        // status of the send operation, so we need to recreate the original
22110402SN/A        // request.  Atomic mode does not have the issue, as there the send
22210402SN/A        // operation and the response happen instantaneously and don't need two
22310402SN/A        // phase tracking.
22410402SN/A        MemCmd tmp_cmd(pkt->cmd);
22510402SN/A        pkt->cmd = orig_cmd;
22610402SN/A        // Let the snoop filter know about the success of the send operation
22710402SN/A        snoopFilter->updateRequest(pkt, *src_port, !success);
22810402SN/A        pkt->cmd = tmp_cmd;
22910402SN/A    }
23010402SN/A
23110656Sandreas.hansson@arm.com    // check if we were successful in sending the packet onwards
23210656Sandreas.hansson@arm.com    if (!success)  {
23310656Sandreas.hansson@arm.com        // express snoops and inhibited packets should never be forced
23410656Sandreas.hansson@arm.com        // to retry
23510656Sandreas.hansson@arm.com        assert(!is_express_snoop);
23610656Sandreas.hansson@arm.com        assert(!pkt->memInhibitAsserted());
23710656Sandreas.hansson@arm.com
23810719SMarco.Balboni@ARM.com        // restore the header delay
23910719SMarco.Balboni@ARM.com        pkt->headerDelay = old_header_delay;
24010656Sandreas.hansson@arm.com
24110656Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "recvTimingReq: src %s %s 0x%x RETRY\n",
24210656Sandreas.hansson@arm.com                src_port->name(), pkt->cmdString(), pkt->getAddr());
24310656Sandreas.hansson@arm.com
24410656Sandreas.hansson@arm.com        // update the layer state and schedule an idle event
24510656Sandreas.hansson@arm.com        reqLayers[master_port_id]->failedTiming(src_port,
24610719SMarco.Balboni@ARM.com                                                clockEdge(Cycles(1)));
2479091SN/A    } else {
24810656Sandreas.hansson@arm.com        // express snoops currently bypass the crossbar state entirely
24910656Sandreas.hansson@arm.com        if (!is_express_snoop) {
25010656Sandreas.hansson@arm.com            // if this particular request will generate a snoop
25110656Sandreas.hansson@arm.com            // response
25210656Sandreas.hansson@arm.com            if (expect_snoop_resp) {
25310656Sandreas.hansson@arm.com                // we should never have an exsiting request outstanding
25410656Sandreas.hansson@arm.com                assert(outstandingSnoop.find(pkt->req) ==
25510656Sandreas.hansson@arm.com                       outstandingSnoop.end());
25610656Sandreas.hansson@arm.com                outstandingSnoop.insert(pkt->req);
2578948SN/A
25810656Sandreas.hansson@arm.com                // basic sanity check on the outstanding snoops
25910656Sandreas.hansson@arm.com                panic_if(outstandingSnoop.size() > 512,
26010656Sandreas.hansson@arm.com                         "Outstanding snoop requests exceeded 512\n");
26110656Sandreas.hansson@arm.com            }
2628948SN/A
26310656Sandreas.hansson@arm.com            // remember where to route the normal response to
26410656Sandreas.hansson@arm.com            if (expect_response || expect_snoop_resp) {
26510656Sandreas.hansson@arm.com                assert(routeTo.find(pkt->req) == routeTo.end());
26610656Sandreas.hansson@arm.com                routeTo[pkt->req] = slave_port_id;
2679549SN/A
26810656Sandreas.hansson@arm.com                panic_if(routeTo.size() > 512,
26910656Sandreas.hansson@arm.com                         "Routing table exceeds 512 packets\n");
27010656Sandreas.hansson@arm.com            }
2718948SN/A
27210405Sandreas.hansson@arm.com            // update the layer state and schedule an idle event
2739715SN/A            reqLayers[master_port_id]->succeededTiming(packetFinishTime);
2749091SN/A        }
2758975SN/A
27610656Sandreas.hansson@arm.com        // stats updates only consider packets that were successfully sent
2779712SN/A        pktCount[slave_port_id][master_port_id]++;
27810405Sandreas.hansson@arm.com        pktSize[slave_port_id][master_port_id] += pkt_size;
2799712SN/A        transDist[pkt_cmd]++;
28010656Sandreas.hansson@arm.com
28110656Sandreas.hansson@arm.com        if (is_express_snoop)
28210656Sandreas.hansson@arm.com            snoops++;
2839712SN/A    }
2849712SN/A
2859091SN/A    return success;
2868975SN/A}
2878975SN/A
2888975SN/Abool
28910405Sandreas.hansson@arm.comCoherentXBar::recvTimingResp(PacketPtr pkt, PortID master_port_id)
2908975SN/A{
2918975SN/A    // determine the source port based on the id
2929032SN/A    MasterPort *src_port = masterPorts[master_port_id];
2938975SN/A
29410656Sandreas.hansson@arm.com    // determine the destination
29510656Sandreas.hansson@arm.com    const auto route_lookup = routeTo.find(pkt->req);
29610656Sandreas.hansson@arm.com    assert(route_lookup != routeTo.end());
29710656Sandreas.hansson@arm.com    const PortID slave_port_id = route_lookup->second;
29810572Sandreas.hansson@arm.com    assert(slave_port_id != InvalidPortID);
29910572Sandreas.hansson@arm.com    assert(slave_port_id < respLayers.size());
3009713SN/A
30110405Sandreas.hansson@arm.com    // test if the crossbar should be considered occupied for the
30210405Sandreas.hansson@arm.com    // current port
3039715SN/A    if (!respLayers[slave_port_id]->tryTiming(src_port)) {
30410405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "recvTimingResp: src %s %s 0x%x BUSY\n",
3058975SN/A                src_port->name(), pkt->cmdString(), pkt->getAddr());
3068975SN/A        return false;
3078975SN/A    }
3088975SN/A
30910405Sandreas.hansson@arm.com    DPRINTF(CoherentXBar, "recvTimingResp: src %s %s 0x%x\n",
3108975SN/A            src_port->name(), pkt->cmdString(), pkt->getAddr());
3118975SN/A
3129712SN/A    // store size and command as they might be modified when
3139712SN/A    // forwarding the packet
3149712SN/A    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
3159712SN/A    unsigned int pkt_cmd = pkt->cmdToIndex();
3169712SN/A
31710719SMarco.Balboni@ARM.com    // a response sees the response latency
31810719SMarco.Balboni@ARM.com    Tick xbar_delay = responseLatency * clockPeriod();
31910719SMarco.Balboni@ARM.com
32010719SMarco.Balboni@ARM.com    // set the packet header and payload delay
32110719SMarco.Balboni@ARM.com    calcPacketTiming(pkt, xbar_delay);
32210719SMarco.Balboni@ARM.com
32310719SMarco.Balboni@ARM.com    // determine how long to be crossbar layer is busy
32410719SMarco.Balboni@ARM.com    Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
3258975SN/A
32610402SN/A    if (snoopFilter && !pkt->req->isUncacheable() && !system->bypassCaches()) {
32710402SN/A        // let the snoop filter inspect the response and update its state
32810402SN/A        snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
32910402SN/A    }
33010402SN/A
3319712SN/A    // send the packet through the destination slave port
3329712SN/A    bool success M5_VAR_USED = slavePorts[slave_port_id]->sendTimingResp(pkt);
3338975SN/A
3348975SN/A    // currently it is illegal to block responses... can lead to
3358975SN/A    // deadlock
3368975SN/A    assert(success);
3378975SN/A
33810656Sandreas.hansson@arm.com    // remove the request from the routing table
33910656Sandreas.hansson@arm.com    routeTo.erase(route_lookup);
34010656Sandreas.hansson@arm.com
3419715SN/A    respLayers[slave_port_id]->succeededTiming(packetFinishTime);
3428975SN/A
3439712SN/A    // stats updates
3449712SN/A    pktCount[slave_port_id][master_port_id]++;
34510405Sandreas.hansson@arm.com    pktSize[slave_port_id][master_port_id] += pkt_size;
3469712SN/A    transDist[pkt_cmd]++;
3479712SN/A
3488975SN/A    return true;
3498975SN/A}
3508975SN/A
3518975SN/Avoid
35210405Sandreas.hansson@arm.comCoherentXBar::recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id)
3538975SN/A{
35410405Sandreas.hansson@arm.com    DPRINTF(CoherentXBar, "recvTimingSnoopReq: src %s %s 0x%x\n",
3559032SN/A            masterPorts[master_port_id]->name(), pkt->cmdString(),
3568975SN/A            pkt->getAddr());
3578975SN/A
3589712SN/A    // update stats here as we know the forwarding will succeed
3599712SN/A    transDist[pkt->cmdToIndex()]++;
36010405Sandreas.hansson@arm.com    snoops++;
3619712SN/A
3628975SN/A    // we should only see express snoops from caches
3638975SN/A    assert(pkt->isExpressSnoop());
3648975SN/A
36510656Sandreas.hansson@arm.com    // remeber if the packet is inhibited so we can see if it changes
36610656Sandreas.hansson@arm.com    const bool is_inhibited = pkt->memInhibitAsserted();
3679032SN/A
36810402SN/A    if (snoopFilter) {
36910402SN/A        // let the Snoop Filter work its magic and guide probing
37010402SN/A        auto sf_res = snoopFilter->lookupSnoop(pkt);
37110402SN/A        // No timing here: packetFinishTime += sf_res.second * clockPeriod();
37210405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "recvTimingSnoopReq: src %s %s 0x%x"\
37310402SN/A                " SF size: %i lat: %i\n", masterPorts[master_port_id]->name(),
37410402SN/A                pkt->cmdString(), pkt->getAddr(), sf_res.first.size(),
37510402SN/A                sf_res.second);
37610402SN/A
37710402SN/A        // forward to all snoopers
37810402SN/A        forwardTiming(pkt, InvalidPortID, sf_res.first);
37910402SN/A    } else {
38010402SN/A        forwardTiming(pkt, InvalidPortID);
38110402SN/A    }
3828975SN/A
38310656Sandreas.hansson@arm.com    // if we can expect a response, remember how to route it
38410656Sandreas.hansson@arm.com    if (!is_inhibited && pkt->memInhibitAsserted()) {
38510656Sandreas.hansson@arm.com        assert(routeTo.find(pkt->req) == routeTo.end());
38610656Sandreas.hansson@arm.com        routeTo[pkt->req] = master_port_id;
38710656Sandreas.hansson@arm.com    }
38810656Sandreas.hansson@arm.com
3898975SN/A    // a snoop request came from a connected slave device (one of
3908975SN/A    // our master ports), and if it is not coming from the slave
3918975SN/A    // device responsible for the address range something is
3928975SN/A    // wrong, hence there is nothing further to do as the packet
3938975SN/A    // would be going back to where it came from
3949032SN/A    assert(master_port_id == findPort(pkt->getAddr()));
3958975SN/A}
3968975SN/A
3978975SN/Abool
39810405Sandreas.hansson@arm.comCoherentXBar::recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id)
3998975SN/A{
4008975SN/A    // determine the source port based on the id
4019032SN/A    SlavePort* src_port = slavePorts[slave_port_id];
4028975SN/A
40310656Sandreas.hansson@arm.com    // get the destination
40410656Sandreas.hansson@arm.com    const auto route_lookup = routeTo.find(pkt->req);
40510656Sandreas.hansson@arm.com    assert(route_lookup != routeTo.end());
40610656Sandreas.hansson@arm.com    const PortID dest_port_id = route_lookup->second;
40710572Sandreas.hansson@arm.com    assert(dest_port_id != InvalidPortID);
4089714SN/A
4099714SN/A    // determine if the response is from a snoop request we
4109714SN/A    // created as the result of a normal request (in which case it
41110656Sandreas.hansson@arm.com    // should be in the outstandingSnoop), or if we merely forwarded
4129714SN/A    // someone else's snoop request
41310656Sandreas.hansson@arm.com    const bool forwardAsSnoop = outstandingSnoop.find(pkt->req) ==
41410656Sandreas.hansson@arm.com        outstandingSnoop.end();
4159714SN/A
41610405Sandreas.hansson@arm.com    // test if the crossbar should be considered occupied for the
41710405Sandreas.hansson@arm.com    // current port, note that the check is bypassed if the response
41810405Sandreas.hansson@arm.com    // is being passed on as a normal response since this is occupying
41910405Sandreas.hansson@arm.com    // the response layer rather than the snoop response layer
4209715SN/A    if (forwardAsSnoop) {
42110572Sandreas.hansson@arm.com        assert(dest_port_id < snoopLayers.size());
4229715SN/A        if (!snoopLayers[dest_port_id]->tryTiming(src_port)) {
42310405Sandreas.hansson@arm.com            DPRINTF(CoherentXBar, "recvTimingSnoopResp: src %s %s 0x%x BUSY\n",
4249715SN/A                    src_port->name(), pkt->cmdString(), pkt->getAddr());
4259715SN/A            return false;
4269715SN/A        }
4279716SN/A    } else {
4289716SN/A        // get the master port that mirrors this slave port internally
4299716SN/A        MasterPort* snoop_port = snoopRespPorts[slave_port_id];
43010572Sandreas.hansson@arm.com        assert(dest_port_id < respLayers.size());
4319716SN/A        if (!respLayers[dest_port_id]->tryTiming(snoop_port)) {
43210405Sandreas.hansson@arm.com            DPRINTF(CoherentXBar, "recvTimingSnoopResp: src %s %s 0x%x BUSY\n",
4339716SN/A                    snoop_port->name(), pkt->cmdString(), pkt->getAddr());
4349716SN/A            return false;
4359716SN/A        }
4368975SN/A    }
4378975SN/A
43810405Sandreas.hansson@arm.com    DPRINTF(CoherentXBar, "recvTimingSnoopResp: src %s %s 0x%x\n",
4398975SN/A            src_port->name(), pkt->cmdString(), pkt->getAddr());
4408975SN/A
4419712SN/A    // store size and command as they might be modified when
4429712SN/A    // forwarding the packet
4439712SN/A    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
4449712SN/A    unsigned int pkt_cmd = pkt->cmdToIndex();
4459712SN/A
4468975SN/A    // responses are never express snoops
4478975SN/A    assert(!pkt->isExpressSnoop());
4488975SN/A
44910719SMarco.Balboni@ARM.com    // a snoop response sees the snoop response latency, and if it is
45010719SMarco.Balboni@ARM.com    // forwarded as a normal response, the response latency
45110719SMarco.Balboni@ARM.com    Tick xbar_delay =
45210719SMarco.Balboni@ARM.com        (forwardAsSnoop ? snoopResponseLatency : responseLatency) *
45310719SMarco.Balboni@ARM.com        clockPeriod();
45410719SMarco.Balboni@ARM.com
45510719SMarco.Balboni@ARM.com    // set the packet header and payload delay
45610719SMarco.Balboni@ARM.com    calcPacketTiming(pkt, xbar_delay);
45710719SMarco.Balboni@ARM.com
45810719SMarco.Balboni@ARM.com    // determine how long to be crossbar layer is busy
45910719SMarco.Balboni@ARM.com    Tick packetFinishTime = clockEdge(Cycles(1)) + pkt->payloadDelay;
4608975SN/A
4619714SN/A    // forward it either as a snoop response or a normal response
4629714SN/A    if (forwardAsSnoop) {
4639714SN/A        // this is a snoop response to a snoop request we forwarded,
4649714SN/A        // e.g. coming from the L1 and going to the L2, and it should
4659714SN/A        // be forwarded as a snoop response
46610402SN/A
46710402SN/A        if (snoopFilter) {
46810402SN/A            // update the probe filter so that it can properly track the line
46910402SN/A            snoopFilter->updateSnoopForward(pkt, *slavePorts[slave_port_id],
47010402SN/A                                            *masterPorts[dest_port_id]);
47110402SN/A        }
47210402SN/A
4739712SN/A        bool success M5_VAR_USED =
4749712SN/A            masterPorts[dest_port_id]->sendTimingSnoopResp(pkt);
4759712SN/A        pktCount[slave_port_id][dest_port_id]++;
47610405Sandreas.hansson@arm.com        pktSize[slave_port_id][dest_port_id] += pkt_size;
4778975SN/A        assert(success);
4789714SN/A
4799715SN/A        snoopLayers[dest_port_id]->succeededTiming(packetFinishTime);
4803244SN/A    } else {
4818975SN/A        // we got a snoop response on one of our slave ports,
48210405Sandreas.hansson@arm.com        // i.e. from a coherent master connected to the crossbar, and
48310405Sandreas.hansson@arm.com        // since we created the snoop request as part of recvTiming,
48410405Sandreas.hansson@arm.com        // this should now be a normal response again
48510656Sandreas.hansson@arm.com        outstandingSnoop.erase(pkt->req);
4868948SN/A
48710656Sandreas.hansson@arm.com        // this is a snoop response from a coherent master, hence it
48810656Sandreas.hansson@arm.com        // should never go back to where the snoop response came from,
48910656Sandreas.hansson@arm.com        // but instead to where the original request came from
4909712SN/A        assert(slave_port_id != dest_port_id);
4918948SN/A
49210402SN/A        if (snoopFilter) {
49310402SN/A            // update the probe filter so that it can properly track the line
49410402SN/A            snoopFilter->updateSnoopResponse(pkt, *slavePorts[slave_port_id],
49510402SN/A                                    *slavePorts[dest_port_id]);
49610402SN/A        }
49710402SN/A
49810405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "recvTimingSnoopResp: src %s %s 0x%x"\
49910402SN/A                " FWD RESP\n", src_port->name(), pkt->cmdString(),
50010402SN/A                pkt->getAddr());
50110402SN/A
5029714SN/A        // as a normal response, it should go back to a master through
5039714SN/A        // one of our slave ports, at this point we are ignoring the
5049714SN/A        // fact that the response layer could be busy and do not touch
5059714SN/A        // its state
5069712SN/A        bool success M5_VAR_USED =
5079712SN/A            slavePorts[dest_port_id]->sendTimingResp(pkt);
5088975SN/A
5099714SN/A        // @todo Put the response in an internal FIFO and pass it on
5109714SN/A        // to the response layer from there
5119714SN/A
5128975SN/A        // currently it is illegal to block responses... can lead
5138975SN/A        // to deadlock
5148948SN/A        assert(success);
5159716SN/A
5169716SN/A        respLayers[dest_port_id]->succeededTiming(packetFinishTime);
5173244SN/A    }
5183244SN/A
51910656Sandreas.hansson@arm.com    // remove the request from the routing table
52010656Sandreas.hansson@arm.com    routeTo.erase(route_lookup);
52110656Sandreas.hansson@arm.com
5229712SN/A    // stats updates
5239712SN/A    transDist[pkt_cmd]++;
52410405Sandreas.hansson@arm.com    snoops++;
5259712SN/A
5268948SN/A    return true;
5278948SN/A}
5288948SN/A
5293210SN/A
5308948SN/Avoid
53110405Sandreas.hansson@arm.comCoherentXBar::forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id,
53210402SN/A                           const std::vector<SlavePort*>& dests)
5338948SN/A{
53410405Sandreas.hansson@arm.com    DPRINTF(CoherentXBar, "%s for %s address %x size %d\n", __func__,
5359663SN/A            pkt->cmdString(), pkt->getAddr(), pkt->getSize());
5369663SN/A
5379524SN/A    // snoops should only happen if the system isn't bypassing caches
5389524SN/A    assert(!system->bypassCaches());
5399524SN/A
54010401SN/A    unsigned fanout = 0;
54110401SN/A
54210405Sandreas.hansson@arm.com    for (const auto& p: dests) {
5438948SN/A        // we could have gotten this request from a snooping master
5448948SN/A        // (corresponding to our own slave port that is also in
5458948SN/A        // snoopPorts) and should not send it back to where it came
5468948SN/A        // from
5479031SN/A        if (exclude_slave_port_id == InvalidPortID ||
5488948SN/A            p->getId() != exclude_slave_port_id) {
5498948SN/A            // cache is not allowed to refuse snoop
5508975SN/A            p->sendTimingSnoopReq(pkt);
55110401SN/A            fanout++;
5528948SN/A        }
5538948SN/A    }
55410401SN/A
55510401SN/A    // Stats for fanout of this forward operation
55610401SN/A    snoopFanout.sample(fanout);
5572497SN/A}
5582497SN/A
5599092SN/Avoid
56010713Sandreas.hansson@arm.comCoherentXBar::recvReqRetry(PortID master_port_id)
5619092SN/A{
5629093SN/A    // responses and snoop responses never block on forwarding them,
5639093SN/A    // so the retry will always be coming from a port to which we
5649093SN/A    // tried to forward a request
5659715SN/A    reqLayers[master_port_id]->recvRetry();
5669092SN/A}
5679092SN/A
5689036SN/ATick
56910405Sandreas.hansson@arm.comCoherentXBar::recvAtomic(PacketPtr pkt, PortID slave_port_id)
5702657SN/A{
57110405Sandreas.hansson@arm.com    DPRINTF(CoherentXBar, "recvAtomic: packet src %s addr 0x%x cmd %s\n",
5729032SN/A            slavePorts[slave_port_id]->name(), pkt->getAddr(),
5738949SN/A            pkt->cmdString());
5748915SN/A
57510405Sandreas.hansson@arm.com    unsigned int pkt_size = pkt->hasData() ? pkt->getSize() : 0;
57610405Sandreas.hansson@arm.com    unsigned int pkt_cmd = pkt->cmdToIndex();
5779712SN/A
5788979SN/A    MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
5798979SN/A    Tick snoop_response_latency = 0;
5808979SN/A
5818979SN/A    // uncacheable requests need never be snooped
5829524SN/A    if (!pkt->req->isUncacheable() && !system->bypassCaches()) {
5838979SN/A        // forward to all snoopers but the source
58410402SN/A        std::pair<MemCmd, Tick> snoop_result;
58510402SN/A        if (snoopFilter) {
58610402SN/A            // check with the snoop filter where to forward this packet
58710402SN/A            auto sf_res =
58810402SN/A                snoopFilter->lookupRequest(pkt, *slavePorts[slave_port_id]);
58910402SN/A            snoop_response_latency += sf_res.second * clockPeriod();
59010405Sandreas.hansson@arm.com            DPRINTF(CoherentXBar, "%s: src %s %s 0x%x"\
59110402SN/A                    " SF size: %i lat: %i\n", __func__,
59210402SN/A                    slavePorts[slave_port_id]->name(), pkt->cmdString(),
59310402SN/A                    pkt->getAddr(), sf_res.first.size(), sf_res.second);
59410402SN/A            snoop_result = forwardAtomic(pkt, slave_port_id, InvalidPortID,
59510402SN/A                                         sf_res.first);
59610402SN/A        } else {
59710402SN/A            snoop_result = forwardAtomic(pkt, slave_port_id);
59810402SN/A        }
5998979SN/A        snoop_response_cmd = snoop_result.first;
60010402SN/A        snoop_response_latency += snoop_result.second;
6018979SN/A    }
6028915SN/A
6038948SN/A    // even if we had a snoop response, we must continue and also
6048948SN/A    // perform the actual request at the destination
60510405Sandreas.hansson@arm.com    PortID master_port_id = findPort(pkt->getAddr());
60610405Sandreas.hansson@arm.com
60710405Sandreas.hansson@arm.com    // stats updates for the request
60810405Sandreas.hansson@arm.com    pktCount[slave_port_id][master_port_id]++;
60910405Sandreas.hansson@arm.com    pktSize[slave_port_id][master_port_id] += pkt_size;
61010405Sandreas.hansson@arm.com    transDist[pkt_cmd]++;
6118948SN/A
6128948SN/A    // forward the request to the appropriate destination
61310405Sandreas.hansson@arm.com    Tick response_latency = masterPorts[master_port_id]->sendAtomic(pkt);
6148948SN/A
61510402SN/A    // Lower levels have replied, tell the snoop filter
61610402SN/A    if (snoopFilter && !pkt->req->isUncacheable() && !system->bypassCaches() &&
61710402SN/A        pkt->isResponse()) {
61810402SN/A        snoopFilter->updateResponse(pkt, *slavePorts[slave_port_id]);
61910402SN/A    }
62010402SN/A
6218948SN/A    // if we got a response from a snooper, restore it here
6228948SN/A    if (snoop_response_cmd != MemCmd::InvalidCmd) {
6238948SN/A        // no one else should have responded
6248948SN/A        assert(!pkt->isResponse());
6258948SN/A        pkt->cmd = snoop_response_cmd;
6268948SN/A        response_latency = snoop_response_latency;
6278948SN/A    }
6288948SN/A
6299712SN/A    // add the response data
63010405Sandreas.hansson@arm.com    if (pkt->isResponse()) {
63110405Sandreas.hansson@arm.com        pkt_size = pkt->hasData() ? pkt->getSize() : 0;
63210405Sandreas.hansson@arm.com        pkt_cmd = pkt->cmdToIndex();
63310405Sandreas.hansson@arm.com
63410405Sandreas.hansson@arm.com        // stats updates
63510405Sandreas.hansson@arm.com        pktCount[slave_port_id][master_port_id]++;
63610405Sandreas.hansson@arm.com        pktSize[slave_port_id][master_port_id] += pkt_size;
63710405Sandreas.hansson@arm.com        transDist[pkt_cmd]++;
63810405Sandreas.hansson@arm.com    }
6399712SN/A
64010694SMarco.Balboni@ARM.com    // @todo: Not setting header time
64110694SMarco.Balboni@ARM.com    pkt->payloadDelay = response_latency;
6428948SN/A    return response_latency;
6438948SN/A}
6448948SN/A
6458948SN/ATick
64610405Sandreas.hansson@arm.comCoherentXBar::recvAtomicSnoop(PacketPtr pkt, PortID master_port_id)
6478948SN/A{
64810405Sandreas.hansson@arm.com    DPRINTF(CoherentXBar, "recvAtomicSnoop: packet src %s addr 0x%x cmd %s\n",
6499032SN/A            masterPorts[master_port_id]->name(), pkt->getAddr(),
6508949SN/A            pkt->cmdString());
6518948SN/A
6529712SN/A    // add the request snoop data
65310405Sandreas.hansson@arm.com    snoops++;
6549712SN/A
6558948SN/A    // forward to all snoopers
65610402SN/A    std::pair<MemCmd, Tick> snoop_result;
65710402SN/A    Tick snoop_response_latency = 0;
65810402SN/A    if (snoopFilter) {
65910402SN/A        auto sf_res = snoopFilter->lookupSnoop(pkt);
66010402SN/A        snoop_response_latency += sf_res.second * clockPeriod();
66110405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar, "%s: src %s %s 0x%x SF size: %i lat: %i\n",
66210402SN/A                __func__, masterPorts[master_port_id]->name(), pkt->cmdString(),
66310402SN/A                pkt->getAddr(), sf_res.first.size(), sf_res.second);
66410402SN/A        snoop_result = forwardAtomic(pkt, InvalidPortID, master_port_id,
66510402SN/A                                     sf_res.first);
66610402SN/A    } else {
66710402SN/A        snoop_result = forwardAtomic(pkt, InvalidPortID);
66810402SN/A    }
6698948SN/A    MemCmd snoop_response_cmd = snoop_result.first;
67010402SN/A    snoop_response_latency += snoop_result.second;
6718948SN/A
6728948SN/A    if (snoop_response_cmd != MemCmd::InvalidCmd)
6738948SN/A        pkt->cmd = snoop_response_cmd;
6748948SN/A
6759712SN/A    // add the response snoop data
67610401SN/A    if (pkt->isResponse()) {
67710405Sandreas.hansson@arm.com        snoops++;
67810401SN/A    }
6799712SN/A
68010694SMarco.Balboni@ARM.com    // @todo: Not setting header time
68110694SMarco.Balboni@ARM.com    pkt->payloadDelay = snoop_response_latency;
6828948SN/A    return snoop_response_latency;
6838948SN/A}
6848948SN/A
6858948SN/Astd::pair<MemCmd, Tick>
68610405Sandreas.hansson@arm.comCoherentXBar::forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id,
68710402SN/A                           PortID source_master_port_id,
68810402SN/A                           const std::vector<SlavePort*>& dests)
6898948SN/A{
6909032SN/A    // the packet may be changed on snoops, record the original
6919032SN/A    // command to enable us to restore it between snoops so that
6928948SN/A    // additional snoops can take place properly
6934626SN/A    MemCmd orig_cmd = pkt->cmd;
6944879SN/A    MemCmd snoop_response_cmd = MemCmd::InvalidCmd;
6954879SN/A    Tick snoop_response_latency = 0;
6963662SN/A
6979524SN/A    // snoops should only happen if the system isn't bypassing caches
6989524SN/A    assert(!system->bypassCaches());
6999524SN/A
70010401SN/A    unsigned fanout = 0;
70110401SN/A
70210405Sandreas.hansson@arm.com    for (const auto& p: dests) {
7038915SN/A        // we could have gotten this request from a snooping master
7048915SN/A        // (corresponding to our own slave port that is also in
7058915SN/A        // snoopPorts) and should not send it back to where it came
7068915SN/A        // from
70710402SN/A        if (exclude_slave_port_id != InvalidPortID &&
70810402SN/A            p->getId() == exclude_slave_port_id)
70910402SN/A            continue;
71010401SN/A
71110402SN/A        Tick latency = p->sendAtomicSnoop(pkt);
71210402SN/A        fanout++;
71310402SN/A
71410402SN/A        // in contrast to a functional access, we have to keep on
71510402SN/A        // going as all snoopers must be updated even if we get a
71610402SN/A        // response
71710402SN/A        if (!pkt->isResponse())
71810402SN/A            continue;
71910402SN/A
72010402SN/A        // response from snoop agent
72110402SN/A        assert(pkt->cmd != orig_cmd);
72210402SN/A        assert(pkt->memInhibitAsserted());
72310402SN/A        // should only happen once
72410402SN/A        assert(snoop_response_cmd == MemCmd::InvalidCmd);
72510402SN/A        // save response state
72610402SN/A        snoop_response_cmd = pkt->cmd;
72710402SN/A        snoop_response_latency = latency;
72810402SN/A
72910402SN/A        if (snoopFilter) {
73010402SN/A            // Handle responses by the snoopers and differentiate between
73110402SN/A            // responses to requests from above and snoops from below
73210402SN/A            if (source_master_port_id != InvalidPortID) {
73310402SN/A                // Getting a response for a snoop from below
73410402SN/A                assert(exclude_slave_port_id == InvalidPortID);
73510402SN/A                snoopFilter->updateSnoopForward(pkt, *p,
73610402SN/A                             *masterPorts[source_master_port_id]);
73710402SN/A            } else {
73810402SN/A                // Getting a response for a request from above
73910402SN/A                assert(source_master_port_id == InvalidPortID);
74010402SN/A                snoopFilter->updateSnoopResponse(pkt, *p,
74110402SN/A                             *slavePorts[exclude_slave_port_id]);
7424626SN/A            }
7434626SN/A        }
74410402SN/A        // restore original packet state for remaining snoopers
74510402SN/A        pkt->cmd = orig_cmd;
7464626SN/A    }
7474626SN/A
74810401SN/A    // Stats for fanout
74910401SN/A    snoopFanout.sample(fanout);
75010401SN/A
7518948SN/A    // the packet is restored as part of the loop and any potential
7528948SN/A    // snoop response is part of the returned pair
7538948SN/A    return std::make_pair(snoop_response_cmd, snoop_response_latency);
7542497SN/A}
7552497SN/A
7562497SN/Avoid
75710405Sandreas.hansson@arm.comCoherentXBar::recvFunctional(PacketPtr pkt, PortID slave_port_id)
7582497SN/A{
7598663SN/A    if (!pkt->isPrint()) {
7608663SN/A        // don't do DPRINTFs on PrintReq as it clutters up the output
76110405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar,
7628949SN/A                "recvFunctional: packet src %s addr 0x%x cmd %s\n",
7639032SN/A                slavePorts[slave_port_id]->name(), pkt->getAddr(),
7648663SN/A                pkt->cmdString());
7658663SN/A    }
7668663SN/A
7678979SN/A    // uncacheable requests need never be snooped
7689524SN/A    if (!pkt->req->isUncacheable() && !system->bypassCaches()) {
7698979SN/A        // forward to all snoopers but the source
7709032SN/A        forwardFunctional(pkt, slave_port_id);
7718979SN/A    }
7724912SN/A
7738948SN/A    // there is no need to continue if the snooping has found what we
7748948SN/A    // were looking for and the packet is already a response
7758948SN/A    if (!pkt->isResponse()) {
7769031SN/A        PortID dest_id = findPort(pkt->getAddr());
7778948SN/A
7788948SN/A        masterPorts[dest_id]->sendFunctional(pkt);
7798948SN/A    }
7808948SN/A}
7818948SN/A
7828948SN/Avoid
78310405Sandreas.hansson@arm.comCoherentXBar::recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id)
7848948SN/A{
7858948SN/A    if (!pkt->isPrint()) {
7868948SN/A        // don't do DPRINTFs on PrintReq as it clutters up the output
78710405Sandreas.hansson@arm.com        DPRINTF(CoherentXBar,
7888949SN/A                "recvFunctionalSnoop: packet src %s addr 0x%x cmd %s\n",
7899032SN/A                masterPorts[master_port_id]->name(), pkt->getAddr(),
7908948SN/A                pkt->cmdString());
7918948SN/A    }
7928948SN/A
7938948SN/A    // forward to all snoopers
7949031SN/A    forwardFunctional(pkt, InvalidPortID);
7958948SN/A}
7968948SN/A
7978948SN/Avoid
79810405Sandreas.hansson@arm.comCoherentXBar::forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id)
7998948SN/A{
8009524SN/A    // snoops should only happen if the system isn't bypassing caches
8019524SN/A    assert(!system->bypassCaches());
8029524SN/A
80310405Sandreas.hansson@arm.com    for (const auto& p: snoopPorts) {
8048915SN/A        // we could have gotten this request from a snooping master
8058915SN/A        // (corresponding to our own slave port that is also in
8068915SN/A        // snoopPorts) and should not send it back to where it came
8078915SN/A        // from
8089031SN/A        if (exclude_slave_port_id == InvalidPortID ||
8098948SN/A            p->getId() != exclude_slave_port_id)
8108948SN/A            p->sendFunctionalSnoop(pkt);
8118915SN/A
8128948SN/A        // if we get a response we are done
8138948SN/A        if (pkt->isResponse()) {
8148948SN/A            break;
8158915SN/A        }
8163650SN/A    }
8172497SN/A}
8182497SN/A
8199092SN/Aunsigned int
82010405Sandreas.hansson@arm.comCoherentXBar::drain(DrainManager *dm)
8219092SN/A{
8229093SN/A    // sum up the individual layers
8239715SN/A    unsigned int total = 0;
82410405Sandreas.hansson@arm.com    for (auto l: reqLayers)
82510405Sandreas.hansson@arm.com        total += l->drain(dm);
82610405Sandreas.hansson@arm.com    for (auto l: respLayers)
82710405Sandreas.hansson@arm.com        total += l->drain(dm);
82810405Sandreas.hansson@arm.com    for (auto l: snoopLayers)
82910405Sandreas.hansson@arm.com        total += l->drain(dm);
8309715SN/A    return total;
8319092SN/A}
8329092SN/A
8339712SN/Avoid
83410405Sandreas.hansson@arm.comCoherentXBar::regStats()
8359712SN/A{
83610405Sandreas.hansson@arm.com    // register the stats of the base class and our layers
83710405Sandreas.hansson@arm.com    BaseXBar::regStats();
83810405Sandreas.hansson@arm.com    for (auto l: reqLayers)
83910405Sandreas.hansson@arm.com        l->regStats();
84010405Sandreas.hansson@arm.com    for (auto l: respLayers)
84110405Sandreas.hansson@arm.com        l->regStats();
84210405Sandreas.hansson@arm.com    for (auto l: snoopLayers)
84310405Sandreas.hansson@arm.com        l->regStats();
8449712SN/A
84510405Sandreas.hansson@arm.com    snoops
84610405Sandreas.hansson@arm.com        .name(name() + ".snoops")
84710401SN/A        .desc("Total snoops (count)")
84810401SN/A    ;
84910401SN/A
85010401SN/A    snoopFanout
85110401SN/A        .init(0, snoopPorts.size(), 1)
85210401SN/A        .name(name() + ".snoop_fanout")
85310401SN/A        .desc("Request fanout histogram")
85410401SN/A    ;
8559712SN/A}
8569712SN/A
85710405Sandreas.hansson@arm.comCoherentXBar *
85810405Sandreas.hansson@arm.comCoherentXBarParams::create()
8592497SN/A{
86010405Sandreas.hansson@arm.com    return new CoherentXBar(this);
8612497SN/A}
862