Deleted Added
sdiff udiff text old ( 4762:c94e103c83ad ) new ( 4870:fcc39d001154 )
full compact
1
2/*
3 * Copyright (c) 2006 The Regents of The University of Michigan
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

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

34 * @file
35 * Definition of a simple bus bridge without buffering.
36 */
37
38#include <algorithm>
39
40#include "base/trace.hh"
41#include "mem/bridge.hh"
42#include "sim/builder.hh"
43
44Bridge::BridgePort::BridgePort(const std::string &_name,
45 Bridge *_bridge, BridgePort *_otherPort,
46 int _delay, int _nack_delay, int _req_limit,
47 int _resp_limit, bool fix_partial_write)
48 : Port(_name), bridge(_bridge), otherPort(_otherPort),
49 delay(_delay), nackDelay(_nack_delay), fixPartialWrite(fix_partial_write),
50 outstandingResponses(0), queuedRequests(0), inRetry(false),

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

107 return queuedRequests >= reqQueueLimit;
108}
109
110/** Function called by the port when the bus is receiving a Timing
111 * transaction.*/
112bool
113Bridge::BridgePort::recvTiming(PacketPtr pkt)
114{
115 DPRINTF(BusBridge, "recvTiming: src %d dest %d addr 0x%x\n",
116 pkt->getSrc(), pkt->getDest(), pkt->getAddr());
117
118 DPRINTF(BusBridge, "Local queue size: %d outreq: %d outresp: %d\n",
119 sendQueue.size(), queuedRequests, outstandingResponses);
120 DPRINTF(BusBridge, "Remove queue size: %d outreq: %d outresp: %d\n",
121 otherPort->sendQueue.size(), otherPort->queuedRequests,
122 otherPort->outstandingResponses);
123
124 if (pkt->isRequest() && otherPort->reqQueueFull() && !pkt->wasNacked()) {
125 DPRINTF(BusBridge, "Remote queue full, nacking\n");
126 nackRequest(pkt);
127 return true;
128 }
129
130 if (pkt->needsResponse() && !pkt->wasNacked())
131 if (respQueueFull()) {
132 DPRINTF(BusBridge, "Local queue full, no space for response, nacking\n");
133 DPRINTF(BusBridge, "queue size: %d outreq: %d outstanding resp: %d\n",
134 sendQueue.size(), queuedRequests, outstandingResponses);
135 nackRequest(pkt);
136 return true;
137 } else {
138 DPRINTF(BusBridge, "Request Needs response, reserving space\n");

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

143
144 return true;
145}
146
147void
148Bridge::BridgePort::nackRequest(PacketPtr pkt)
149{
150 // Nack the packet
151 pkt->setNacked();
152 pkt->setDest(pkt->getSrc());
153
154 //put it on the list to send
155 Tick readyTime = curTick + nackDelay;
156 PacketBuffer *buf = new PacketBuffer(pkt, readyTime, true);
157
158 // nothing on the list, add it and we're done
159 if (sendQueue.empty()) {

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

188 }
189 assert(done);
190}
191
192
193void
194Bridge::BridgePort::queueForSendTiming(PacketPtr pkt)
195{
196 if (pkt->isResponse() || pkt->wasNacked()) {
197 // This is a response for a request we forwarded earlier. The
198 // corresponding PacketBuffer should be stored in the packet's
199 // senderState field.
200 PacketBuffer *buf = dynamic_cast<PacketBuffer*>(pkt->senderState);
201 assert(buf != NULL);
202 // set up new packet dest & senderState based on values saved
203 // from original request
204 buf->fixResponse(pkt);
205
206 // Check if this packet was expecting a response and it's a nacked
207 // packet, in which case we will never being seeing it
208 if (buf->expectResponse && pkt->wasNacked())
209 --outstandingResponses;
210
211
212 DPRINTF(BusBridge, "restoring sender state: %#X, from packet buffer: %#X\n",
213 pkt->senderState, buf);
214 DPRINTF(BusBridge, " is response, new dest %d\n", pkt->getDest());
215 delete buf;
216 }
217
218
219 if (pkt->isRequest() && !pkt->wasNacked()) {
220 ++queuedRequests;
221 }
222
223
224
225 Tick readyTime = curTick + delay;
226 PacketBuffer *buf = new PacketBuffer(pkt, readyTime);
227 DPRINTF(BusBridge, "old sender state: %#X, new sender state: %#X\n",
228 buf->origSenderState, buf);
229
230 // If we're about to put this packet at the head of the queue, we
231 // need to schedule an event to do the transmit. Otherwise there
232 // should already be an event scheduled for sending the head
233 // packet.
234 if (sendQueue.empty()) {
235 sendEvent.schedule(readyTime);
236 }

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

243 assert(!sendQueue.empty());
244
245 PacketBuffer *buf = sendQueue.front();
246
247 assert(buf->ready <= curTick);
248
249 PacketPtr pkt = buf->pkt;
250
251 // Ugly! @todo When multilevel coherence works this will be removed
252 if (pkt->cmd == MemCmd::WriteInvalidateReq && fixPartialWrite &&
253 !pkt->wasNacked()) {
254 PacketPtr funcPkt = new Packet(pkt->req, MemCmd::WriteReq,
255 Packet::Broadcast);
256 funcPkt->dataStatic(pkt->getPtr<uint8_t>());
257 sendFunctional(funcPkt);
258 pkt->cmd = MemCmd::WriteReq;
259 delete funcPkt;
260 }
261
262 DPRINTF(BusBridge, "trySend: origSrc %d dest %d addr 0x%x\n",
263 buf->origSrc, pkt->getDest(), pkt->getAddr());
264
265 bool wasReq = pkt->isRequest();
266 bool wasNacked = pkt->wasNacked();
267
268 if (sendTiming(pkt)) {
269 // send successful
270 sendQueue.pop_front();
271 buf->pkt = NULL; // we no longer own packet, so it's not safe to look at it
272
273 if (buf->expectResponse) {
274 // Must wait for response

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

333}
334
335/** Function called by the port when the bus is receiving a Functional
336 * transaction.*/
337void
338Bridge::BridgePort::recvFunctional(PacketPtr pkt)
339{
340 std::list<PacketBuffer*>::iterator i;
341
342 for (i = sendQueue.begin(); i != sendQueue.end(); ++i) {
343 if (pkt->checkFunctional((*i)->pkt))
344 return;
345 }
346
347 // fall through if pkt still not satisfied
348 otherPort->sendFunctional(pkt);
349}
350
351/** Function called by the port when the bus is receiving a status change.*/
352void
353Bridge::BridgePort::recvStatusChange(Port::Status status)
354{
355 otherPort->sendStatusChange(status);
356}
357
358void
359Bridge::BridgePort::getDeviceAddressRanges(AddrRangeList &resp,
360 bool &snoop)
361{
362 otherPort->getPeerAddressRanges(resp, snoop);
363}
364
365BEGIN_DECLARE_SIM_OBJECT_PARAMS(Bridge)
366
367 Param<int> req_size_a;
368 Param<int> req_size_b;
369 Param<int> resp_size_a;
370 Param<int> resp_size_b;
371 Param<Tick> delay;
372 Param<Tick> nack_delay;
373 Param<bool> write_ack;
374 Param<bool> fix_partial_write_a;
375 Param<bool> fix_partial_write_b;
376
377END_DECLARE_SIM_OBJECT_PARAMS(Bridge)
378
379BEGIN_INIT_SIM_OBJECT_PARAMS(Bridge)
380
381 INIT_PARAM(req_size_a, "The size of the queue for requests coming into side a"),
382 INIT_PARAM(req_size_b, "The size of the queue for requests coming into side b"),
383 INIT_PARAM(resp_size_a, "The size of the queue for responses coming into side a"),
384 INIT_PARAM(resp_size_b, "The size of the queue for responses coming into side b"),
385 INIT_PARAM(delay, "The miminum delay to cross this bridge"),
386 INIT_PARAM(nack_delay, "The minimum delay to nack a packet"),
387 INIT_PARAM(write_ack, "Acknowledge any writes that are received."),
388 INIT_PARAM(fix_partial_write_a, "Fixup any partial block writes that are received"),
389 INIT_PARAM(fix_partial_write_b, "Fixup any partial block writes that are received")
390
391END_INIT_SIM_OBJECT_PARAMS(Bridge)
392
393CREATE_SIM_OBJECT(Bridge)
394{
395 Bridge::Params *p = new Bridge::Params;
396 p->name = getInstanceName();
397 p->req_size_a = req_size_a;
398 p->req_size_b = req_size_b;
399 p->resp_size_a = resp_size_a;
400 p->resp_size_b = resp_size_b;
401 p->delay = delay;
402 p->nack_delay = nack_delay;
403 p->write_ack = write_ack;
404 p->fix_partial_write_a = fix_partial_write_a;
405 p->fix_partial_write_b = fix_partial_write_b;
406 return new Bridge(p);
407}
408
409REGISTER_SIM_OBJECT("Bridge", Bridge)
410
411