1/* 2 * Copyright (c) 2011-2012 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 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Copyright (c) 2006 The Regents of The University of Michigan 15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution; 24 * neither the name of the copyright holders nor the names of its 25 * contributors may be used to endorse or promote products derived from 26 * this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Ali Saidi 41 * Steve Reinhardt 42 * Andreas Hansson 43 */ 44 45/** 46 * @file 47 * Implementation of a memory-mapped bus bridge that connects a master 48 * and a slave through a request and response queue. 49 */ 50 51#include "base/trace.hh"
| 1/* 2 * Copyright (c) 2011-2012 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 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Copyright (c) 2006 The Regents of The University of Michigan 15 * All rights reserved. 16 * 17 * Redistribution and use in source and binary forms, with or without 18 * modification, are permitted provided that the following conditions are 19 * met: redistributions of source code must retain the above copyright 20 * notice, this list of conditions and the following disclaimer; 21 * redistributions in binary form must reproduce the above copyright 22 * notice, this list of conditions and the following disclaimer in the 23 * documentation and/or other materials provided with the distribution; 24 * neither the name of the copyright holders nor the names of its 25 * contributors may be used to endorse or promote products derived from 26 * this software without specific prior written permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Authors: Ali Saidi 41 * Steve Reinhardt 42 * Andreas Hansson 43 */ 44 45/** 46 * @file 47 * Implementation of a memory-mapped bus bridge that connects a master 48 * and a slave through a request and response queue. 49 */ 50 51#include "base/trace.hh"
|
52#include "debug/BusBridge.hh"
| 52#include "debug/Bridge.hh"
|
53#include "mem/bridge.hh" 54#include "params/Bridge.hh" 55
| 53#include "mem/bridge.hh" 54#include "params/Bridge.hh" 55
|
56Bridge::BridgeSlavePort::BridgeSlavePort(const std::string &_name, 57 Bridge* _bridge,
| 56Bridge::BridgeSlavePort::BridgeSlavePort(const std::string& _name, 57 Bridge& _bridge,
|
58 BridgeMasterPort& _masterPort,
| 58 BridgeMasterPort& _masterPort,
|
59 int _delay, int _nack_delay, 60 int _resp_limit,
| 59 int _delay, int _resp_limit,
|
61 std::vector<Range<Addr> > _ranges)
| 60 std::vector<Range<Addr> > _ranges)
|
62 : SlavePort(_name, _bridge), bridge(_bridge), masterPort(_masterPort), 63 delay(_delay), nackDelay(_nack_delay), 64 ranges(_ranges.begin(), _ranges.end()), 65 outstandingResponses(0), inRetry(false),
| 61 : SlavePort(_name, &_bridge), bridge(_bridge), masterPort(_masterPort), 62 delay(_delay), ranges(_ranges.begin(), _ranges.end()), 63 outstandingResponses(0), retryReq(false),
|
66 respQueueLimit(_resp_limit), sendEvent(*this) 67{ 68} 69
| 64 respQueueLimit(_resp_limit), sendEvent(*this) 65{ 66} 67
|
70Bridge::BridgeMasterPort::BridgeMasterPort(const std::string &_name, 71 Bridge* _bridge,
| 68Bridge::BridgeMasterPort::BridgeMasterPort(const std::string& _name, 69 Bridge& _bridge,
|
72 BridgeSlavePort& _slavePort, 73 int _delay, int _req_limit)
| 70 BridgeSlavePort& _slavePort, 71 int _delay, int _req_limit)
|
74 : MasterPort(_name, _bridge), bridge(_bridge), slavePort(_slavePort), 75 delay(_delay), inRetry(false), reqQueueLimit(_req_limit), 76 sendEvent(*this)
| 72 : MasterPort(_name, &_bridge), bridge(_bridge), slavePort(_slavePort), 73 delay(_delay), reqQueueLimit(_req_limit), sendEvent(*this)
|
77{ 78} 79 80Bridge::Bridge(Params *p) 81 : MemObject(p),
| 74{ 75} 76 77Bridge::Bridge(Params *p) 78 : MemObject(p),
|
82 slavePort(p->name + ".slave", this, masterPort, p->delay, 83 p->nack_delay, p->resp_size, p->ranges), 84 masterPort(p->name + ".master", this, slavePort, p->delay, p->req_size), 85 ackWrites(p->write_ack), _params(p)
| 79 slavePort(p->name + ".slave", *this, masterPort, p->delay, p->resp_size, 80 p->ranges), 81 masterPort(p->name + ".master", *this, slavePort, p->delay, p->req_size)
|
86{
| 82{
|
87 if (ackWrites) 88 panic("No support for acknowledging writes\n");
| |
89} 90 91MasterPort& 92Bridge::getMasterPort(const std::string &if_name, int idx) 93{ 94 if (if_name == "master") 95 return masterPort; 96 else 97 // pass it along to our super class 98 return MemObject::getMasterPort(if_name, idx); 99} 100 101SlavePort& 102Bridge::getSlavePort(const std::string &if_name, int idx) 103{ 104 if (if_name == "slave") 105 return slavePort; 106 else 107 // pass it along to our super class 108 return MemObject::getSlavePort(if_name, idx); 109} 110 111void 112Bridge::init() 113{ 114 // make sure both sides are connected and have the same block size 115 if (!slavePort.isConnected() || !masterPort.isConnected()) 116 fatal("Both ports of bus bridge are not connected to a bus.\n"); 117 118 if (slavePort.peerBlockSize() != masterPort.peerBlockSize()) 119 fatal("Slave port size %d, master port size %d \n " \ 120 "Busses don't have the same block size... Not supported.\n", 121 slavePort.peerBlockSize(), masterPort.peerBlockSize()); 122 123 // notify the master side of our address ranges 124 slavePort.sendRangeChange(); 125} 126 127bool 128Bridge::BridgeSlavePort::respQueueFull() 129{ 130 return outstandingResponses == respQueueLimit; 131} 132 133bool 134Bridge::BridgeMasterPort::reqQueueFull() 135{
| 83} 84 85MasterPort& 86Bridge::getMasterPort(const std::string &if_name, int idx) 87{ 88 if (if_name == "master") 89 return masterPort; 90 else 91 // pass it along to our super class 92 return MemObject::getMasterPort(if_name, idx); 93} 94 95SlavePort& 96Bridge::getSlavePort(const std::string &if_name, int idx) 97{ 98 if (if_name == "slave") 99 return slavePort; 100 else 101 // pass it along to our super class 102 return MemObject::getSlavePort(if_name, idx); 103} 104 105void 106Bridge::init() 107{ 108 // make sure both sides are connected and have the same block size 109 if (!slavePort.isConnected() || !masterPort.isConnected()) 110 fatal("Both ports of bus bridge are not connected to a bus.\n"); 111 112 if (slavePort.peerBlockSize() != masterPort.peerBlockSize()) 113 fatal("Slave port size %d, master port size %d \n " \ 114 "Busses don't have the same block size... Not supported.\n", 115 slavePort.peerBlockSize(), masterPort.peerBlockSize()); 116 117 // notify the master side of our address ranges 118 slavePort.sendRangeChange(); 119} 120 121bool 122Bridge::BridgeSlavePort::respQueueFull() 123{ 124 return outstandingResponses == respQueueLimit; 125} 126 127bool 128Bridge::BridgeMasterPort::reqQueueFull() 129{
|
136 return requestQueue.size() == reqQueueLimit;
| 130 return transmitList.size() == reqQueueLimit;
|
137} 138 139bool 140Bridge::BridgeMasterPort::recvTimingResp(PacketPtr pkt) 141{ 142 // all checks are done when the request is accepted on the slave 143 // side, so we are guaranteed to have space for the response
| 131} 132 133bool 134Bridge::BridgeMasterPort::recvTimingResp(PacketPtr pkt) 135{ 136 // all checks are done when the request is accepted on the slave 137 // side, so we are guaranteed to have space for the response
|
144 DPRINTF(BusBridge, "recvTiming: response %s addr 0x%x\n",
| 138 DPRINTF(Bridge, "recvTimingResp: %s addr 0x%x\n",
|
145 pkt->cmdString(), pkt->getAddr()); 146
| 139 pkt->cmdString(), pkt->getAddr()); 140
|
147 DPRINTF(BusBridge, "Request queue size: %d\n", requestQueue.size());
| 141 DPRINTF(Bridge, "Request queue size: %d\n", transmitList.size());
|
148
| 142
|
149 slavePort.queueForSendTiming(pkt);
| 143 slavePort.schedTimingResp(pkt, curTick() + delay);
|
150 151 return true; 152} 153 154bool 155Bridge::BridgeSlavePort::recvTimingReq(PacketPtr pkt) 156{
| 144 145 return true; 146} 147 148bool 149Bridge::BridgeSlavePort::recvTimingReq(PacketPtr pkt) 150{
|
157 DPRINTF(BusBridge, "recvTiming: request %s addr 0x%x\n",
| 151 DPRINTF(Bridge, "recvTimingReq: %s addr 0x%x\n",
|
158 pkt->cmdString(), pkt->getAddr()); 159
| 152 pkt->cmdString(), pkt->getAddr()); 153
|
160 DPRINTF(BusBridge, "Response queue size: %d outresp: %d\n", 161 responseQueue.size(), outstandingResponses);
| 154 // ensure we do not have something waiting to retry 155 if(retryReq) 156 return false;
|
162
| 157
|
163 if (masterPort.reqQueueFull()) { 164 DPRINTF(BusBridge, "Request queue full, nacking\n"); 165 nackRequest(pkt); 166 return true; 167 }
| 158 DPRINTF(Bridge, "Response queue size: %d outresp: %d\n", 159 transmitList.size(), outstandingResponses);
|
168
| 160
|
169 if (pkt->needsResponse()) {
| 161 if (masterPort.reqQueueFull()) { 162 DPRINTF(Bridge, "Request queue full\n"); 163 retryReq = true; 164 } else if (pkt->needsResponse()) {
|
170 if (respQueueFull()) {
| 165 if (respQueueFull()) {
|
171 DPRINTF(BusBridge, 172 "Response queue full, no space for response, nacking\n"); 173 DPRINTF(BusBridge, 174 "queue size: %d outstanding resp: %d\n", 175 responseQueue.size(), outstandingResponses); 176 nackRequest(pkt); 177 return true;
| 166 DPRINTF(Bridge, "Response queue full\n"); 167 retryReq = true;
|
178 } else {
| 168 } else {
|
179 DPRINTF(BusBridge, "Request Needs response, reserving space\n");
| 169 DPRINTF(Bridge, "Reserving space for response\n");
|
180 assert(outstandingResponses != respQueueLimit); 181 ++outstandingResponses;
| 170 assert(outstandingResponses != respQueueLimit); 171 ++outstandingResponses;
|
| 172 retryReq = false; 173 masterPort.schedTimingReq(pkt, curTick() + delay);
|
182 } 183 } 184
| 174 } 175 } 176
|
185 masterPort.queueForSendTiming(pkt); 186 187 return true;
| 177 // remember that we are now stalling a packet and that we have to 178 // tell the sending master to retry once space becomes available, 179 // we make no distinction whether the stalling is due to the 180 // request queue or response queue being full 181 return !retryReq;
|
188} 189 190void
| 182} 183 184void
|
191Bridge::BridgeSlavePort::nackRequest(PacketPtr pkt)
| 185Bridge::BridgeSlavePort::retryStalledReq()
|
192{
| 186{
|
193 // Nack the packet 194 pkt->makeTimingResponse(); 195 pkt->setNacked(); 196 197 // The Nack packets are stored in the response queue just like any 198 // other response, but they do not occupy any space as this is 199 // tracked by the outstandingResponses, this guarantees space for 200 // the Nack packets, but implicitly means we have an (unrealistic) 201 // unbounded Nack queue. 202 203 // put it on the list to send 204 Tick readyTime = curTick() + nackDelay; 205 DeferredResponse resp(pkt, readyTime, true); 206 207 // nothing on the list, add it and we're done 208 if (responseQueue.empty()) { 209 assert(!sendEvent.scheduled()); 210 bridge->schedule(sendEvent, readyTime); 211 responseQueue.push_back(resp); 212 return;
| 187 if (retryReq) { 188 DPRINTF(Bridge, "Request waiting for retry, now retrying\n"); 189 retryReq = false; 190 sendRetry();
|
213 }
| 191 }
|
214 215 assert(sendEvent.scheduled() || inRetry); 216 217 // does it go at the end? 218 if (readyTime >= responseQueue.back().ready) { 219 responseQueue.push_back(resp); 220 return; 221 } 222 223 // ok, somewhere in the middle, fun 224 std::list<DeferredResponse>::iterator i = responseQueue.begin(); 225 std::list<DeferredResponse>::iterator end = responseQueue.end(); 226 std::list<DeferredResponse>::iterator begin = responseQueue.begin(); 227 bool done = false; 228 229 while (i != end && !done) { 230 if (readyTime < (*i).ready) { 231 if (i == begin) 232 bridge->reschedule(sendEvent, readyTime); 233 responseQueue.insert(i, resp); 234 done = true; 235 } 236 i++; 237 } 238 assert(done);
| |
239} 240 241void
| 192} 193 194void
|
242Bridge::BridgeMasterPort::queueForSendTiming(PacketPtr pkt)
| 195Bridge::BridgeMasterPort::schedTimingReq(PacketPtr pkt, Tick when)
|
243{
| 196{
|
244 Tick readyTime = curTick() + delay; 245
| |
246 // If we expect to see a response, we need to restore the source 247 // and destination field that is potentially changed by a second 248 // bus 249 if (!pkt->memInhibitAsserted() && pkt->needsResponse()) { 250 // Update the sender state so we can deal with the response 251 // appropriately 252 RequestState *req_state = new RequestState(pkt); 253 pkt->senderState = req_state; 254 } 255 256 // If we're about to put this packet at the head of the queue, we 257 // need to schedule an event to do the transmit. Otherwise there 258 // should already be an event scheduled for sending the head 259 // packet.
| 197 // If we expect to see a response, we need to restore the source 198 // and destination field that is potentially changed by a second 199 // bus 200 if (!pkt->memInhibitAsserted() && pkt->needsResponse()) { 201 // Update the sender state so we can deal with the response 202 // appropriately 203 RequestState *req_state = new RequestState(pkt); 204 pkt->senderState = req_state; 205 } 206 207 // If we're about to put this packet at the head of the queue, we 208 // need to schedule an event to do the transmit. Otherwise there 209 // should already be an event scheduled for sending the head 210 // packet.
|
260 if (requestQueue.empty()) { 261 bridge->schedule(sendEvent, readyTime);
| 211 if (transmitList.empty()) { 212 bridge.schedule(sendEvent, when);
|
262 } 263
| 213 } 214
|
264 assert(requestQueue.size() != reqQueueLimit);
| 215 assert(transmitList.size() != reqQueueLimit);
|
265
| 216
|
266 requestQueue.push_back(DeferredRequest(pkt, readyTime));
| 217 transmitList.push_back(DeferredPacket(pkt, when));
|
267} 268 269 270void
| 218} 219 220 221void
|
271Bridge::BridgeSlavePort::queueForSendTiming(PacketPtr pkt)
| 222Bridge::BridgeSlavePort::schedTimingResp(PacketPtr pkt, Tick when)
|
272{ 273 // This is a response for a request we forwarded earlier. The 274 // corresponding request state should be stored in the packet's 275 // senderState field. 276 RequestState *req_state = dynamic_cast<RequestState*>(pkt->senderState); 277 assert(req_state != NULL); 278 // set up new packet dest & senderState based on values saved 279 // from original request 280 req_state->fixResponse(pkt);
| 223{ 224 // This is a response for a request we forwarded earlier. The 225 // corresponding request state should be stored in the packet's 226 // senderState field. 227 RequestState *req_state = dynamic_cast<RequestState*>(pkt->senderState); 228 assert(req_state != NULL); 229 // set up new packet dest & senderState based on values saved 230 // from original request 231 req_state->fixResponse(pkt);
|
| 232 delete req_state;
|
281 282 // the bridge assumes that at least one bus has set the 283 // destination field of the packet 284 assert(pkt->isDestValid());
| 233 234 // the bridge assumes that at least one bus has set the 235 // destination field of the packet 236 assert(pkt->isDestValid());
|
285 DPRINTF(BusBridge, "response, new dest %d\n", pkt->getDest()); 286 delete req_state;
| 237 DPRINTF(Bridge, "response, new dest %d\n", pkt->getDest());
|
287
| 238
|
288 Tick readyTime = curTick() + delay; 289
| |
290 // If we're about to put this packet at the head of the queue, we 291 // need to schedule an event to do the transmit. Otherwise there 292 // should already be an event scheduled for sending the head 293 // packet.
| 239 // If we're about to put this packet at the head of the queue, we 240 // need to schedule an event to do the transmit. Otherwise there 241 // should already be an event scheduled for sending the head 242 // packet.
|
294 if (responseQueue.empty()) { 295 bridge->schedule(sendEvent, readyTime);
| 243 if (transmitList.empty()) { 244 bridge.schedule(sendEvent, when);
|
296 }
| 245 }
|
297 responseQueue.push_back(DeferredResponse(pkt, readyTime));
| 246 247 transmitList.push_back(DeferredPacket(pkt, when));
|
298} 299 300void
| 248} 249 250void
|
301Bridge::BridgeMasterPort::trySend()
| 251Bridge::BridgeMasterPort::trySendTiming()
|
302{
| 252{
|
303 assert(!requestQueue.empty());
| 253 assert(!transmitList.empty());
|
304
| 254
|
305 DeferredRequest req = requestQueue.front();
| 255 DeferredPacket req = transmitList.front();
|
306
| 256
|
307 assert(req.ready <= curTick());
| 257 assert(req.tick <= curTick());
|
308 309 PacketPtr pkt = req.pkt; 310
| 258 259 PacketPtr pkt = req.pkt; 260
|
311 DPRINTF(BusBridge, "trySend request: addr 0x%x\n", pkt->getAddr());
| 261 DPRINTF(Bridge, "trySend request addr 0x%x, queue size %d\n", 262 pkt->getAddr(), transmitList.size());
|
312 313 if (sendTimingReq(pkt)) { 314 // send successful
| 263 264 if (sendTimingReq(pkt)) { 265 // send successful
|
315 requestQueue.pop_front();
| 266 transmitList.pop_front(); 267 DPRINTF(Bridge, "trySend request successful\n");
|
316 317 // If there are more packets to send, schedule event to try again.
| 268 269 // If there are more packets to send, schedule event to try again.
|
318 if (!requestQueue.empty()) { 319 req = requestQueue.front(); 320 DPRINTF(BusBridge, "Scheduling next send\n"); 321 bridge->schedule(sendEvent, 322 std::max(req.ready, curTick() + 1));
| 270 if (!transmitList.empty()) { 271 req = transmitList.front(); 272 DPRINTF(Bridge, "Scheduling next send\n"); 273 bridge.schedule(sendEvent, std::max(req.tick, 274 bridge.nextCycle()));
|
323 }
| 275 }
|
324 } else { 325 inRetry = true;
| 276 277 // if we have stalled a request due to a full request queue, 278 // then send a retry at this point, also note that if the 279 // request we stalled was waiting for the response queue 280 // rather than the request queue we might stall it again 281 slavePort.retryStalledReq();
|
326 } 327
| 282 } 283
|
328 DPRINTF(BusBridge, "trySend: request queue size: %d\n", 329 requestQueue.size());
| 284 // if the send failed, then we try again once we receive a retry, 285 // and therefore there is no need to take any action
|
330} 331 332void
| 286} 287 288void
|
333Bridge::BridgeSlavePort::trySend()
| 289Bridge::BridgeSlavePort::trySendTiming()
|
334{
| 290{
|
335 assert(!responseQueue.empty());
| 291 assert(!transmitList.empty());
|
336
| 292
|
337 DeferredResponse resp = responseQueue.front();
| 293 DeferredPacket resp = transmitList.front();
|
338
| 294
|
339 assert(resp.ready <= curTick());
| 295 assert(resp.tick <= curTick());
|
340 341 PacketPtr pkt = resp.pkt; 342
| 296 297 PacketPtr pkt = resp.pkt; 298
|
343 DPRINTF(BusBridge, "trySend response: dest %d addr 0x%x\n", 344 pkt->getDest(), pkt->getAddr());
| 299 DPRINTF(Bridge, "trySend response addr 0x%x, outstanding %d\n", 300 pkt->getAddr(), outstandingResponses);
|
345
| 301
|
346 bool was_nacked_here = resp.nackedHere; 347
| |
348 if (sendTimingResp(pkt)) {
| 302 if (sendTimingResp(pkt)) {
|
349 DPRINTF(BusBridge, " successful\n");
| |
350 // send successful
| 303 // send successful
|
351 responseQueue.pop_front();
| 304 transmitList.pop_front(); 305 DPRINTF(Bridge, "trySend response successful\n");
|
352
| 306
|
353 if (!was_nacked_here) { 354 assert(outstandingResponses != 0); 355 --outstandingResponses; 356 }
| 307 assert(outstandingResponses != 0); 308 --outstandingResponses;
|
357 358 // If there are more packets to send, schedule event to try again.
| 309 310 // If there are more packets to send, schedule event to try again.
|
359 if (!responseQueue.empty()) { 360 resp = responseQueue.front(); 361 DPRINTF(BusBridge, "Scheduling next send\n"); 362 bridge->schedule(sendEvent, 363 std::max(resp.ready, curTick() + 1));
| 311 if (!transmitList.empty()) { 312 resp = transmitList.front(); 313 DPRINTF(Bridge, "Scheduling next send\n"); 314 bridge.schedule(sendEvent, std::max(resp.tick, 315 bridge.nextCycle()));
|
364 }
| 316 }
|
365 } else { 366 DPRINTF(BusBridge, " unsuccessful\n"); 367 inRetry = true;
| 317 318 // if there is space in the request queue and we were stalling 319 // a request, it will definitely be possible to accept it now 320 // since there is guaranteed space in the response queue 321 if (!masterPort.reqQueueFull() && retryReq) { 322 DPRINTF(Bridge, "Request waiting for retry, now retrying\n"); 323 retryReq = false; 324 sendRetry(); 325 }
|
368 } 369
| 326 } 327
|
370 DPRINTF(BusBridge, "trySend: queue size: %d outstanding resp: %d\n", 371 responseQueue.size(), outstandingResponses);
| 328 // if the send failed, then we try again once we receive a retry, 329 // and therefore there is no need to take any action
|
372} 373 374void 375Bridge::BridgeMasterPort::recvRetry() 376{
| 330} 331 332void 333Bridge::BridgeMasterPort::recvRetry() 334{
|
377 inRetry = false; 378 Tick nextReady = requestQueue.front().ready;
| 335 Tick nextReady = transmitList.front().tick;
|
379 if (nextReady <= curTick())
| 336 if (nextReady <= curTick())
|
380 trySend();
| 337 trySendTiming();
|
381 else
| 338 else
|
382 bridge->schedule(sendEvent, nextReady);
| 339 bridge.schedule(sendEvent, nextReady);
|
383} 384 385void 386Bridge::BridgeSlavePort::recvRetry() 387{
| 340} 341 342void 343Bridge::BridgeSlavePort::recvRetry() 344{
|
388 inRetry = false; 389 Tick nextReady = responseQueue.front().ready;
| 345 Tick nextReady = transmitList.front().tick;
|
390 if (nextReady <= curTick())
| 346 if (nextReady <= curTick())
|
391 trySend();
| 347 trySendTiming();
|
392 else
| 348 else
|
393 bridge->schedule(sendEvent, nextReady);
| 349 bridge.schedule(sendEvent, nextReady);
|
394} 395 396Tick 397Bridge::BridgeSlavePort::recvAtomic(PacketPtr pkt) 398{ 399 return delay + masterPort.sendAtomic(pkt); 400} 401 402void 403Bridge::BridgeSlavePort::recvFunctional(PacketPtr pkt) 404{
| 350} 351 352Tick 353Bridge::BridgeSlavePort::recvAtomic(PacketPtr pkt) 354{ 355 return delay + masterPort.sendAtomic(pkt); 356} 357 358void 359Bridge::BridgeSlavePort::recvFunctional(PacketPtr pkt) 360{
|
405 std::list<DeferredResponse>::iterator i;
| 361 std::list<DeferredPacket>::iterator i;
|
406 407 pkt->pushLabel(name()); 408 409 // check the response queue
| 362 363 pkt->pushLabel(name()); 364 365 // check the response queue
|
410 for (i = responseQueue.begin(); i != responseQueue.end(); ++i) {
| 366 for (i = transmitList.begin(); i != transmitList.end(); ++i) {
|
411 if (pkt->checkFunctional((*i).pkt)) { 412 pkt->makeResponse(); 413 return; 414 } 415 } 416 417 // also check the master port's request queue 418 if (masterPort.checkFunctional(pkt)) { 419 return; 420 } 421 422 pkt->popLabel(); 423 424 // fall through if pkt still not satisfied 425 masterPort.sendFunctional(pkt); 426} 427 428bool 429Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt) 430{ 431 bool found = false;
| 367 if (pkt->checkFunctional((*i).pkt)) { 368 pkt->makeResponse(); 369 return; 370 } 371 } 372 373 // also check the master port's request queue 374 if (masterPort.checkFunctional(pkt)) { 375 return; 376 } 377 378 pkt->popLabel(); 379 380 // fall through if pkt still not satisfied 381 masterPort.sendFunctional(pkt); 382} 383 384bool 385Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt) 386{ 387 bool found = false;
|
432 std::list<DeferredRequest>::iterator i = requestQueue.begin();
| 388 std::list<DeferredPacket>::iterator i = transmitList.begin();
|
433
| 389
|
434 while(i != requestQueue.end() && !found) {
| 390 while(i != transmitList.end() && !found) {
|
435 if (pkt->checkFunctional((*i).pkt)) { 436 pkt->makeResponse(); 437 found = true; 438 } 439 ++i; 440 } 441 442 return found; 443} 444 445AddrRangeList 446Bridge::BridgeSlavePort::getAddrRanges() const 447{ 448 return ranges; 449} 450 451Bridge * 452BridgeParams::create() 453{ 454 return new Bridge(this); 455}
| 391 if (pkt->checkFunctional((*i).pkt)) { 392 pkt->makeResponse(); 393 found = true; 394 } 395 ++i; 396 } 397 398 return found; 399} 400 401AddrRangeList 402Bridge::BridgeSlavePort::getAddrRanges() const 403{ 404 return ranges; 405} 406 407Bridge * 408BridgeParams::create() 409{ 410 return new Bridge(this); 411}
|