50 #include "debug/AddrRanges.hh" 51 #include "debug/CoherentXBar.hh" 56 snoopResponseLatency(p->snoop_response_latency),
57 maxOutstandingSnoopCheck(p->max_outstanding_snoops),
58 maxRoutingTableSizeCheck(p->max_routing_table_size),
59 pointOfCoherency(p->point_of_coherency),
60 pointOfUnification(p->point_of_unification),
62 snoops(this,
"snoops",
"Total snoops (count)"),
63 snoopTraffic(this,
"snoopTraffic",
"Total snoop traffic (bytes)"),
64 snoopFanout(this,
"snoop_fanout",
"Request fanout histogram")
69 for (
int i = 0;
i < p->port_master_connection_count; ++
i) {
81 if (p->port_default_connection_count) {
83 std::string portName =
name() +
".default";
95 for (
int i = 0;
i < p->port_slave_connection_count; ++
i) {
126 if (
p->isSnooping()) {
127 DPRINTF(AddrRanges,
"Adding snooping master %s\n",
p->getPeer());
133 warn(
"CoherentXBar %s has no snooping ports attached!\n",
name());
152 assert(is_express_snoop == cache_responding);
159 if (!is_express_snoop && !
reqLayers[master_port_id]->tryTiming(src_port)) {
196 if (pkt->
isClean() && !is_destination) {
200 if (!
masterPorts[master_port_id]->tryTiming(pkt)) {
205 reqLayers[master_port_id]->failedTiming(src_port,
222 __func__, src_port->
name(), pkt->
print(),
223 sf_res.first.size(), sf_res.second);
231 if (!sf_res.first.empty())
251 const bool expect_snoop_resp = !cache_responding && pkt->
cacheResponding();
257 bool respond_directly =
false;
280 if (pkt->
isWrite() && is_destination) {
285 success =
masterPorts[master_port_id]->sendTimingReq(pkt);
291 respond_directly =
true;
292 assert(!expect_snoop_resp);
293 expect_response =
false;
305 assert(!is_express_snoop);
314 reqLayers[master_port_id]->failedTiming(src_port,
318 if (!is_express_snoop) {
321 if (expect_snoop_resp) {
329 "%s: Outstanding snoop requests exceeded %d\n",
334 if (expect_response || expect_snoop_resp) {
339 "%s: Routing table exceeds %d packets\n",
344 reqLayers[master_port_id]->succeededTiming(packetFinishTime);
348 pktCount[slave_port_id][master_port_id]++;
349 pktSize[slave_port_id][master_port_id] += pkt_size;
352 if (is_express_snoop) {
364 PortID rsp_port_id = slave_port_id;
384 respond_directly =
true;
386 rsp_pkt = cmo_lookup->second;
390 const auto route_lookup =
routeTo.find(rsp_pkt->
req);
391 assert(route_lookup !=
routeTo.end());
392 rsp_port_id = route_lookup->second;
400 respond_directly =
false;
407 "%s: Routing table exceeds %d packets\n",
414 if (respond_directly) {
432 slavePorts[rsp_port_id]->schedTimingResp(rsp_pkt, response_time);
445 const auto route_lookup =
routeTo.find(pkt->
req);
446 assert(route_lookup !=
routeTo.end());
447 const PortID slave_port_id = route_lookup->second;
453 if (!
respLayers[slave_port_id]->tryTiming(src_port)) {
490 respLayers[slave_port_id]->succeededTiming(packetFinishTime);
493 pktCount[slave_port_id][master_port_id]++;
494 pktSize[slave_port_id][master_port_id] += pkt_size;
534 sf_res.first.size(), sf_res.second);
567 const auto route_lookup =
routeTo.find(pkt->
req);
568 assert(route_lookup !=
routeTo.end());
569 const PortID dest_port_id = route_lookup->second;
583 if (forwardAsSnoop) {
585 if (!
snoopLayers[dest_port_id]->tryTiming(src_port)) {
594 if (!
respLayers[dest_port_id]->tryTiming(snoop_port)) {
625 if (forwardAsSnoop) {
636 bool success M5_VAR_USED =
637 masterPorts[dest_port_id]->sendTimingSnoopResp(pkt);
638 pktCount[slave_port_id][dest_port_id]++;
639 pktSize[slave_port_id][dest_port_id] += pkt_size;
642 snoopLayers[dest_port_id]->succeededTiming(packetFinishTime);
653 assert(slave_port_id != dest_port_id);
671 respLayers[dest_port_id]->succeededTiming(packetFinishTime);
697 for (
const auto&
p: dests) {
703 p->getId() != exclude_slave_port_id) {
705 p->sendTimingSnoopReq(pkt);
734 Tick snoop_response_latency = 0;
751 snoop_response_latency += sf_res.second *
clockPeriod();
754 sf_res.first.size(), sf_res.second);
768 if (!sf_res.first.empty())
777 snoop_response_cmd = snoop_result.first;
778 snoop_response_latency += snoop_result.second;
782 Tick response_latency = 0;
798 if (pkt->
isWrite() && is_destination) {
804 response_latency = backdoor ?
805 master->sendAtomicBackdoor(pkt, *backdoor) :
806 master->sendAtomic(pkt);
816 pktCount[slave_port_id][master_port_id]++;
817 pktSize[slave_port_id][master_port_id] += pkt_size;
830 pkt->
cmd = snoop_response_cmd;
831 response_latency = snoop_response_latency;
864 pktCount[slave_port_id][master_port_id]++;
865 pktSize[slave_port_id][master_port_id] += pkt_size;
871 return response_latency;
887 Tick snoop_response_latency = 0;
890 snoop_response_latency += sf_res.second *
clockPeriod();
893 sf_res.first.size(), sf_res.second);
899 MemCmd snoop_response_cmd = snoop_result.first;
900 snoop_response_latency += snoop_result.second;
903 pkt->
cmd = snoop_response_cmd;
912 return snoop_response_latency;
917 PortID source_master_port_id,
925 Tick snoop_response_latency = 0;
932 for (
const auto&
p: dests) {
938 p->getId() == exclude_slave_port_id)
941 Tick latency =
p->sendAtomicSnoop(pkt);
951 assert(pkt->
cmd != orig_cmd);
956 snoop_response_cmd = pkt->
cmd;
957 snoop_response_latency = latency;
983 return std::make_pair(snoop_response_cmd, snoop_response_latency);
1008 if (
p->trySatisfyFunctional(pkt)) {
1031 if (
p->trySatisfyFunctional(pkt)) {
1054 p->getId() != exclude_slave_port_id)
1055 p->sendFunctionalSnoop(pkt);
1112 CoherentXBarParams::create()
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
std::vector< SnoopRespLayer * > snoopLayers
void updateSnoopForward(const Packet *cpkt, const SlavePort &rsp_port, const MasterPort &req_port)
Pass snoop responses that travel downward through the snoop filter and let them update the snoop filt...
bool isExpressSnoop() const
Cycles is a wrapper class for representing cycle counts, i.e.
std::vector< RespLayer * > respLayers
const PortID InvalidPortID
void finishRequest(bool will_retry, Addr addr, bool is_secure)
For an un-successful request, revert the change to the snoop filter.
uint32_t snoopDelay
Keep track of the extra delay incurred by snooping upwards before sending a request down the memory s...
const unsigned int maxOutstandingSnoopCheck
Maximum number of outstading snoops sanity check.
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
std::unique_ptr< Packet > pendingDelete
Upstream caches need this packet until true is returned, so hold it for deletion until a subsequent c...
PortID defaultPortID
Port that handles requests that don't match any of the interfaces.
void setSlavePorts(const SnoopList &slave_ports)
Init a new snoop filter and tell it about all the slave ports of the enclosing bus.
void recvReqRetry(PortID master_port_id)
Stats::Distribution snoopFanout
std::unordered_map< RequestPtr, PortID > routeTo
Remember where request packets came from so that we can route responses to the appropriate port...
bool cacheResponding() const
Internal class to bridge between an incoming snoop response from a slave port and forwarding it throu...
const Cycles responseLatency
A queued port is a port that has an infinite queue for outgoing packets and thus decouples the module...
A SlavePort is a specialisation of a port.
std::vector< ReqLayer * > reqLayers
Declare the layers of this crossbar, one vector for requests, one for responses, and one for snoop re...
Stats::Scalar snoopTraffic
const Cycles snoopResponseLatency
Cycles of snoop response latency.
System * system
Keep a pointer to the system to be allow to querying memory system properties.
Declaration of the coherent crossbar slave port type, one will be instantiated for each of the master...
std::unordered_set< RequestPtr > outstandingSnoop
Store the outstanding requests that we are expecting snoop responses from so we can determine which s...
bool sinkPacket(const PacketPtr pkt) const
Determine if the crossbar should sink the packet, as opposed to forwarding it, or responding...
void recvFunctionalSnoop(PacketPtr pkt, PortID master_port_id)
Function called by the port when the crossbar is recieving a functional snoop transaction.
bool recvTimingReq(PacketPtr pkt, PortID slave_port_id)
bool needsWritable() const
The base crossbar contains the common elements of the non-coherent and coherent crossbar.
std::pair< SnoopList, Cycles > lookupSnoop(const Packet *cpkt)
Handle an incoming snoop from below (the master port).
RequestPtr req
A pointer to the original request.
void regStats() override
Callback to set stat parameters.
bool isBlockCached() const
Tick curTick()
The current simulated tick.
std::string csprintf(const char *format, const Args &...args)
bool needsResponse() const
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
uint64_t Tick
Tick count type.
Stats::Vector transDist
Stats for transaction distribution and data passing through the crossbar.
bool isDestination(const PacketPtr pkt) const
Determine if the packet's destination is the memory below.
void recvTimingSnoopReq(PacketPtr pkt, PortID master_port_id)
const unsigned int maxRoutingTableSizeCheck
Maximum routing table size sanity check.
CoherentXBar(const CoherentXBarParams *p)
SnoopFilter * snoopFilter
A snoop filter that tracks cache line residency and can restrict the broadcast needed for probes...
AddrRange getAddrRange() const
Get address range to which this packet belongs.
void calcPacketTiming(PacketPtr pkt, Tick header_delay)
Calculate the timing parameters for the packet.
Distribution & init(Counter min, Counter max, Counter bkt)
Set the parameters of this distribution.
bool recvTimingResp(PacketPtr pkt, PortID master_port_id)
void forwardTiming(PacketPtr pkt, PortID exclude_slave_port_id)
Forward a timing packet to our snoopers, potentially excluding one of the connected coherent masters ...
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
A coherent crossbar connects a number of (potentially) snooping masters and slaves, and routes the request and response packets based on the address, and also forwards all requests to the snoopers and deals with the snoop responses.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
const Cycles frontendLatency
Cycles of front-end pipeline including the delay to accept the request and to decode the address...
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
void updateResponse(const Packet *cpkt, const SlavePort &slave_port)
Update the snoop filter with a response from below (outer / other cache, or memory) and update the tr...
bool responderHadWritable() const
Declaration of a coherent crossbar.
Tick recvAtomicSnoop(PacketPtr pkt, PortID master_port_id)
int cmdToIndex() const
Return the index of this command.
std::vector< MasterPort * > masterPorts
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
std::vector< SnoopRespPort * > snoopRespPorts
virtual const std::string name() const
std::vector< QueuedSlavePort * > slavePorts
The master and slave ports of the crossbar.
void print(std::ostream &o, int verbosity=0, const std::string &prefix="") const
MemCmd cmd
The command field of the packet.
bool bypassCaches() const
Should caches be bypassed?
const std::string name() const
Return port name (for DPRINTF).
PortID findPort(AddrRange addr_range)
Find which port connected to this crossbar (if any) should be given a packet with this address range...
void forwardFunctional(PacketPtr pkt, PortID exclude_slave_port_id)
Forward a functional packet to our snoopers, potentially excluding one of the connected coherent mast...
std::pair< MemCmd, Tick > forwardAtomic(PacketPtr pkt, PortID exclude_slave_port_id)
Forward an atomic packet to our snoopers, potentially excluding one of the connected coherent masters...
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
virtual void regStats()
Callback to set stat parameters.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
const Cycles forwardLatency
void setExpressSnoop()
The express snoop flag is used for two purposes.
bool forwardPacket(const PacketPtr pkt)
Determine if the crossbar should forward the packet, as opposed to responding to it.
const bool pointOfCoherency
Is this crossbar the point of coherency?
void updateSnoopResponse(const Packet *cpkt, const SlavePort &rsp_port, const SlavePort &req_port)
Let the snoop filter see any snoop responses that turn into request responses and indicate cache to c...
bool recvTimingSnoopResp(PacketPtr pkt, PortID slave_port_id)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
std::unordered_map< PacketId, PacketPtr > outstandingCMO
Store the outstanding cache maintenance that we are expecting snoop responses from so we can determin...
void sample(const U &v, int n=1)
Add a value to the distribtion n times.
std::pair< SnoopList, Cycles > lookupRequest(const Packet *cpkt, const SlavePort &slave_port)
Lookup a request (from a slave port) in the snoop filter and return a list of other slave ports that ...
Declaration of the coherent crossbar master port type, one will be instantiated for each of the slave...
Tick recvAtomicBackdoor(PacketPtr pkt, PortID slave_port_id, MemBackdoorPtr *backdoor=nullptr)
void recvFunctional(PacketPtr pkt, PortID slave_port_id)
Function called by the port when the crossbar is recieving a Functional transaction.
virtual void init()
init() is called after all C++ SimObjects have been created and all ports are connected.
std::vector< QueuedSlavePort * > snoopPorts