1/* |
2 * Copyright (c) 2013-2016,2019 ARM Limited |
3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 29 unchanged lines hidden (view full) --- 40/** 41 * @file 42 * Definition of a snoop filter. 43 */ 44 45#ifndef __MEM_SNOOP_FILTER_HH__ 46#define __MEM_SNOOP_FILTER_HH__ 47 |
48#include <bitset> |
49#include <unordered_map> 50#include <utility> 51 52#include "mem/packet.hh" 53#include "mem/port.hh" 54#include "mem/qport.hh" 55#include "params/SnoopFilter.hh" 56#include "sim/sim_object.hh" --- 25 unchanged lines hidden (view full) --- 82 * pkt, instead of proper messages through the bus 83 * (3) there are no clean evict messages telling the snoop filter that a local, 84 * upper cache dropped a line, making the snoop filter pessimistic for now 85 * (4) ordering: there is no single point of order in the system. Instead, 86 * requesting MSHRs track order between local requests and remote snoops 87 */ 88class SnoopFilter : public SimObject { 89 public: |
90 91 // Change for systems with more than 256 ports tracked by this object 92 static const int SNOOP_MASK_SIZE = 256; 93 |
94 typedef std::vector<QueuedSlavePort*> SnoopList; 95 96 SnoopFilter (const SnoopFilterParams *p) : 97 SimObject(p), reqLookupResult(cachedLocations.end()), retryItem{0, 0}, 98 linesize(p->system->cacheLineSize()), lookupLatency(p->lookup_latency), 99 maxEntryCount(p->max_capacity / p->system->cacheLineSize()) 100 { 101 } --- 12 unchanged lines hidden (view full) --- 114 // no need to track this port if it is not snooping 115 if (p->isSnooping()) { 116 slavePorts.push_back(p); 117 localSlavePortIds[p->getId()] = id++; 118 } 119 } 120 121 // make sure we can deal with this many ports |
122 fatal_if(id > SNOOP_MASK_SIZE, |
123 "Snoop filter only supports %d snooping ports, got %d\n", |
124 SNOOP_MASK_SIZE, id); |
125 } 126 127 /** 128 * Lookup a request (from a slave port) in the snoop filter and 129 * return a list of other slave ports that need forwarding of the 130 * resulting snoops. Additionally, update the tracking structures 131 * with new request information. Note that the caller must also 132 * call finishRequest once it is known if the request needs to --- 65 unchanged lines hidden (view full) --- 198 void updateResponse(const Packet *cpkt, const SlavePort& slave_port); 199 200 virtual void regStats(); 201 202 protected: 203 204 /** 205 * The underlying type for the bitmask we use for tracking. This |
206 * limits the number of snooping ports supported per crossbar. |
207 */ |
208 typedef std::bitset<SNOOP_MASK_SIZE> SnoopMask; |
209 210 /** 211 * Per cache line item tracking a bitmask of SlavePorts who have an 212 * outstanding request to this line (requested) or already share a 213 * cache line with this address (holder). 214 */ 215 struct SnoopItem { 216 SnoopMask requested; --- 93 unchanged lines hidden (view full) --- 310 ((SnoopMask)1) << localSlavePortIds[port.getId()]; 311} 312 313inline SnoopFilter::SnoopList 314SnoopFilter::maskToPortList(SnoopMask port_mask) const 315{ 316 SnoopList res; 317 for (const auto& p : slavePorts) |
318 if ((port_mask & portToMask(*p)).any()) |
319 res.push_back(p); 320 return res; 321} 322 323#endif // __MEM_SNOOP_FILTER_HH__ |