snoop_filter.cc (11129:48c02e8b0bbb) | snoop_filter.cc (11131:22e739752f47) |
---|---|
1/* 2 * Copyright (c) 2013-2015 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 --- 56 unchanged lines hidden (view full) --- 65 DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n", 66 __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString()); 67 68 // Ultimately we should check if the packet came from an 69 // allocating source, not just if the port is snooping 70 bool allocate = !cpkt->req->isUncacheable() && slave_port.isSnooping(); 71 Addr line_addr = cpkt->getBlockAddr(linesize); 72 SnoopMask req_port = portToMask(slave_port); | 1/* 2 * Copyright (c) 2013-2015 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 --- 56 unchanged lines hidden (view full) --- 65 DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n", 66 __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString()); 67 68 // Ultimately we should check if the packet came from an 69 // allocating source, not just if the port is snooping 70 bool allocate = !cpkt->req->isUncacheable() && slave_port.isSnooping(); 71 Addr line_addr = cpkt->getBlockAddr(linesize); 72 SnoopMask req_port = portToMask(slave_port); |
73 auto sf_it = cachedLocations.find(line_addr); 74 bool is_hit = (sf_it != cachedLocations.end()); | 73 reqLookupResult = cachedLocations.find(line_addr); 74 bool is_hit = (reqLookupResult != cachedLocations.end()); |
75 76 // If the snoop filter has no entry, and we should not allocate, 77 // do not create a new snoop filter entry, simply return a NULL 78 // portlist. 79 if (!is_hit && !allocate) 80 return snoopDown(lookupLatency); 81 | 75 76 // If the snoop filter has no entry, and we should not allocate, 77 // do not create a new snoop filter entry, simply return a NULL 78 // portlist. 79 if (!is_hit && !allocate) 80 return snoopDown(lookupLatency); 81 |
82 // Create a new element through operator[] and modify in-place 83 SnoopItem& sf_item = is_hit ? sf_it->second : cachedLocations[line_addr]; | 82 // If no hit in snoop filter create a new element and update iterator 83 if (!is_hit) 84 reqLookupResult = cachedLocations.emplace(line_addr, SnoopItem()).first; 85 SnoopItem& sf_item = reqLookupResult->second; |
84 SnoopMask interested = sf_item.holder | sf_item.requested; 85 86 // Store unmodified value of snoop filter item in temp storage in 87 // case we need to revert because of a send retry in 88 // updateRequest. 89 retryItem = sf_item; 90 91 totRequests++; --- 47 unchanged lines hidden (view full) --- 139 __func__, sf_item.requested, sf_item.holder); 140 } 141 } 142 143 return snoopSelected(maskToPortList(interested & ~req_port), lookupLatency); 144} 145 146void | 86 SnoopMask interested = sf_item.holder | sf_item.requested; 87 88 // Store unmodified value of snoop filter item in temp storage in 89 // case we need to revert because of a send retry in 90 // updateRequest. 91 retryItem = sf_item; 92 93 totRequests++; --- 47 unchanged lines hidden (view full) --- 141 __func__, sf_item.requested, sf_item.holder); 142 } 143 } 144 145 return snoopSelected(maskToPortList(interested & ~req_port), lookupLatency); 146} 147 148void |
147SnoopFilter::updateRequest(const Packet* cpkt, const SlavePort& slave_port, 148 bool will_retry) | 149SnoopFilter::finishRequest(bool will_retry, const Packet* cpkt) |
149{ | 150{ |
150 DPRINTF(SnoopFilter, "%s: packet src %s addr 0x%x cmd %s\n", 151 __func__, slave_port.name(), cpkt->getAddr(), cpkt->cmdString()); | 151 if (reqLookupResult != cachedLocations.end()) { 152 // since we rely on the caller, do a basic check to ensure 153 // that finishRequest is being called following lookupRequest 154 assert(reqLookupResult->first == cpkt->getBlockAddr(linesize)); 155 if (will_retry) { 156 // Undo any changes made in lookupRequest to the snoop filter 157 // entry if the request will come again. retryItem holds 158 // the previous value of the snoopfilter entry. 159 reqLookupResult->second = retryItem; |
152 | 160 |
153 // Ultimately we should check if the packet came from an 154 // allocating source, not just if the port is snooping 155 bool allocate = !cpkt->req->isUncacheable() && slave_port.isSnooping(); 156 if (!allocate) 157 return; | 161 DPRINTF(SnoopFilter, "%s: restored SF value %x.%x\n", 162 __func__, retryItem.requested, retryItem.holder); 163 } |
158 | 164 |
159 Addr line_addr = cpkt->getBlockAddr(linesize); 160 auto sf_it = cachedLocations.find(line_addr); 161 assert(sf_it != cachedLocations.end()); 162 if (will_retry) { 163 // Undo any changes made in lookupRequest to the snoop filter 164 // entry if the request will come again. retryItem holds 165 // the previous value of the snoopfilter entry. 166 sf_it->second = retryItem; 167 168 DPRINTF(SnoopFilter, "%s: restored SF value %x.%x\n", 169 __func__, retryItem.requested, retryItem.holder); | 165 eraseIfNullEntry(reqLookupResult); |
170 } | 166 } |
171 172 eraseIfNullEntry(sf_it); | |
173} 174 175std::pair<SnoopFilter::SnoopList, Cycles> 176SnoopFilter::lookupSnoop(const Packet* cpkt) 177{ 178 DPRINTF(SnoopFilter, "%s: packet addr 0x%x cmd %s\n", 179 __func__, cpkt->getAddr(), cpkt->cmdString()); 180 --- 219 unchanged lines hidden --- | 167} 168 169std::pair<SnoopFilter::SnoopList, Cycles> 170SnoopFilter::lookupSnoop(const Packet* cpkt) 171{ 172 DPRINTF(SnoopFilter, "%s: packet addr 0x%x cmd %s\n", 173 __func__, cpkt->getAddr(), cpkt->cmdString()); 174 --- 219 unchanged lines hidden --- |