snoop_filter.cc (10399:0644819fc32f) snoop_filter.cc (10403:b3231fc8ae9d)
1/*
2 * Copyright (c) 2013 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

--- 42 unchanged lines hidden (view full) ---

51std::pair<SnoopFilter::SnoopList, Cycles>
52SnoopFilter::lookupRequest(const Packet* cpkt, const SlavePort& slave_port)
53{
54 DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n",
55 __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString());
56
57 Addr line_addr = cpkt->getAddr() & ~(linesize - 1);
58 SnoopMask req_port = portToMask(slave_port);
1/*
2 * Copyright (c) 2013 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

--- 42 unchanged lines hidden (view full) ---

51std::pair<SnoopFilter::SnoopList, Cycles>
52SnoopFilter::lookupRequest(const Packet* cpkt, const SlavePort& slave_port)
53{
54 DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n",
55 __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString());
56
57 Addr line_addr = cpkt->getAddr() & ~(linesize - 1);
58 SnoopMask req_port = portToMask(slave_port);
59 SnoopItem& sf_item = cachedLocations[line_addr];
59 auto sf_it = cachedLocations.find(line_addr);
60 bool is_hit = (sf_it != cachedLocations.end());
61 // Create a new element through operator[] and modify in-place
62 SnoopItem& sf_item = is_hit ? sf_it->second : cachedLocations[line_addr];
63 SnoopMask interested = sf_item.holder | sf_item.requested;
60
64
65 totRequests++;
66 if (is_hit) {
67 // Single bit set -> value is a power of two
68 if (isPow2(interested))
69 hitSingleRequests++;
70 else
71 hitMultiRequests++;
72 }
73
61 DPRINTF(SnoopFilter, "%s: SF value %x.%x\n",
62 __func__, sf_item.requested, sf_item.holder);
63
64 if (cpkt->needsResponse()) {
65 if (!cpkt->memInhibitAsserted()) {
66 // Max one request per address per port
67 panic_if(sf_item.requested & req_port, "double request :( "\
68 "SF value %x.%x\n", sf_item.requested, sf_item.holder);

--- 7 unchanged lines hidden (view full) ---

76 // sure that we know that that cluster has a copy
77 panic_if(!(sf_item.holder & req_port), "Need to hold the value!");
78 DPRINTF(SnoopFilter, "%s: not marking request. SF value %x.%x\n",
79 __func__, sf_item.requested, sf_item.holder);
80 }
81 DPRINTF(SnoopFilter, "%s: new SF value %x.%x\n",
82 __func__, sf_item.requested, sf_item.holder);
83 }
74 DPRINTF(SnoopFilter, "%s: SF value %x.%x\n",
75 __func__, sf_item.requested, sf_item.holder);
76
77 if (cpkt->needsResponse()) {
78 if (!cpkt->memInhibitAsserted()) {
79 // Max one request per address per port
80 panic_if(sf_item.requested & req_port, "double request :( "\
81 "SF value %x.%x\n", sf_item.requested, sf_item.holder);

--- 7 unchanged lines hidden (view full) ---

89 // sure that we know that that cluster has a copy
90 panic_if(!(sf_item.holder & req_port), "Need to hold the value!");
91 DPRINTF(SnoopFilter, "%s: not marking request. SF value %x.%x\n",
92 __func__, sf_item.requested, sf_item.holder);
93 }
94 DPRINTF(SnoopFilter, "%s: new SF value %x.%x\n",
95 __func__, sf_item.requested, sf_item.holder);
96 }
84 SnoopMask interested = (sf_item.holder | sf_item.requested) & ~req_port;
85 return snoopSelected(maskToPortList(interested), lookupLatency);
97 return snoopSelected(maskToPortList(interested & ~req_port), lookupLatency);
86}
87
88void
89SnoopFilter::updateRequest(const Packet* cpkt, const SlavePort& slave_port,
90 bool will_retry)
91{
92 DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n",
93 __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString());

--- 42 unchanged lines hidden (view full) ---

136
137 // Broadcast / filter upward snoops
138 const bool filter_upward = true; // @todo: Make configurable
139
140 if (!filter_upward)
141 return snoopAll(lookupLatency);
142
143 Addr line_addr = cpkt->getAddr() & ~(linesize - 1);
98}
99
100void
101SnoopFilter::updateRequest(const Packet* cpkt, const SlavePort& slave_port,
102 bool will_retry)
103{
104 DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n",
105 __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString());

--- 42 unchanged lines hidden (view full) ---

148
149 // Broadcast / filter upward snoops
150 const bool filter_upward = true; // @todo: Make configurable
151
152 if (!filter_upward)
153 return snoopAll(lookupLatency);
154
155 Addr line_addr = cpkt->getAddr() & ~(linesize - 1);
144 SnoopItem& sf_item = cachedLocations[line_addr];
156 auto sf_it = cachedLocations.find(line_addr);
157 bool is_hit = (sf_it != cachedLocations.end());
158 // Create a new element through operator[] and modify in-place
159 SnoopItem& sf_item = is_hit ? sf_it->second : cachedLocations[line_addr];
145
146 DPRINTF(SnoopFilter, "%s: old SF value %x.%x\n",
147 __func__, sf_item.requested, sf_item.holder);
148
149 SnoopMask interested = (sf_item.holder | sf_item.requested);
160
161 DPRINTF(SnoopFilter, "%s: old SF value %x.%x\n",
162 __func__, sf_item.requested, sf_item.holder);
163
164 SnoopMask interested = (sf_item.holder | sf_item.requested);
165
166 totSnoops++;
167 if (is_hit) {
168 // Single bit set -> value is a power of two
169 if (isPow2(interested))
170 hitSingleSnoops++;
171 else
172 hitMultiSnoops++;
173 }
174
150 assert(cpkt->isInvalidate() == cpkt->needsExclusive());
151 if (cpkt->isInvalidate() && !sf_item.requested) {
152 // Early clear of the holder, if no other request is currently going on
153 // @todo: This should possibly be updated even though we do not filter
154 // upward snoops
155 sf_item.holder = 0;
156 }
157

--- 104 unchanged lines hidden (view full) ---

262 if (cpkt->needsExclusive() || !cpkt->sharedAsserted())
263 sf_item.holder = 0;
264 sf_item.holder |= slave_mask;
265 sf_item.requested &= ~slave_mask;
266 DPRINTF(SnoopFilter, "%s: new SF value %x.%x\n",
267 __func__, sf_item.requested, sf_item.holder);
268}
269
175 assert(cpkt->isInvalidate() == cpkt->needsExclusive());
176 if (cpkt->isInvalidate() && !sf_item.requested) {
177 // Early clear of the holder, if no other request is currently going on
178 // @todo: This should possibly be updated even though we do not filter
179 // upward snoops
180 sf_item.holder = 0;
181 }
182

--- 104 unchanged lines hidden (view full) ---

287 if (cpkt->needsExclusive() || !cpkt->sharedAsserted())
288 sf_item.holder = 0;
289 sf_item.holder |= slave_mask;
290 sf_item.requested &= ~slave_mask;
291 DPRINTF(SnoopFilter, "%s: new SF value %x.%x\n",
292 __func__, sf_item.requested, sf_item.holder);
293}
294
295void
296SnoopFilter::regStats()
297{
298 totRequests
299 .name(name() + ".tot_requests")
300 .desc("Total number of requests made to the snoop filter.");
301
302 hitSingleRequests
303 .name(name() + ".hit_single_requests")
304 .desc("Number of requests hitting in the snoop filter with a single "\
305 "holder of the requested data.");
306
307 hitMultiRequests
308 .name(name() + ".hit_multi_requests")
309 .desc("Number of requests hitting in the snoop filter with multiple "\
310 "(>1) holders of the requested data.");
311
312 totSnoops
313 .name(name() + ".tot_snoops")
314 .desc("Total number of snoops made to the snoop filter.");
315
316 hitSingleSnoops
317 .name(name() + ".hit_single_snoops")
318 .desc("Number of snoops hitting in the snoop filter with a single "\
319 "holder of the requested data.");
320
321 hitMultiSnoops
322 .name(name() + ".hit_multi_snoops")
323 .desc("Number of snoops hitting in the snoop filter with multiple "\
324 "(>1) holders of the requested data.");
325}
326
270SnoopFilter *
271SnoopFilterParams::create()
272{
273 return new SnoopFilter(this);
274}
327SnoopFilter *
328SnoopFilterParams::create()
329{
330 return new SnoopFilter(this);
331}