2006-04-28 21:37:48 +02:00
|
|
|
/*
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
* Copyright (c) 2011-2012 ARM Limited
|
2012-01-17 19:55:09 +01:00
|
|
|
* All rights reserved
|
|
|
|
*
|
|
|
|
* The license below extends only to copyright in the software and shall
|
|
|
|
* not be construed as granting a license to any other intellectual
|
|
|
|
* property including but not limited to intellectual property relating
|
|
|
|
* to a hardware implementation of the functionality of the software
|
|
|
|
* licensed hereunder. You may use the software subject to the license
|
|
|
|
* terms below provided that you ensure that this notice is replicated
|
|
|
|
* unmodified and in its entirety in all distributions of the software,
|
|
|
|
* modified or unmodified, in source code or in binary form.
|
|
|
|
*
|
2006-04-28 21:37:48 +02:00
|
|
|
* Copyright (c) 2006 The Regents of The University of Michigan
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
|
|
|
* Authors: Ali Saidi
|
|
|
|
* Steve Reinhardt
|
2012-01-17 19:55:09 +01:00
|
|
|
* Andreas Hansson
|
2006-04-28 21:37:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2006-08-15 01:25:07 +02:00
|
|
|
* @file
|
2012-01-17 19:55:09 +01:00
|
|
|
* Implementation of a memory-mapped bus bridge that connects a master
|
|
|
|
* and a slave through a request and response queue.
|
2006-04-28 21:37:48 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "base/trace.hh"
|
2011-04-15 19:44:32 +02:00
|
|
|
#include "debug/BusBridge.hh"
|
2006-04-28 21:37:48 +02:00
|
|
|
#include "mem/bridge.hh"
|
2007-07-24 06:51:38 +02:00
|
|
|
#include "params/Bridge.hh"
|
2006-04-28 21:37:48 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeSlavePort::BridgeSlavePort(const std::string &_name,
|
|
|
|
Bridge* _bridge,
|
2012-02-24 17:43:53 +01:00
|
|
|
BridgeMasterPort& _masterPort,
|
2012-01-17 19:55:09 +01:00
|
|
|
int _delay, int _nack_delay,
|
|
|
|
int _resp_limit,
|
|
|
|
std::vector<Range<Addr> > _ranges)
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
: SlavePort(_name, _bridge), bridge(_bridge), masterPort(_masterPort),
|
2012-01-17 19:55:09 +01:00
|
|
|
delay(_delay), nackDelay(_nack_delay),
|
|
|
|
ranges(_ranges.begin(), _ranges.end()),
|
|
|
|
outstandingResponses(0), inRetry(false),
|
2012-02-24 17:43:53 +01:00
|
|
|
respQueueLimit(_resp_limit), sendEvent(*this)
|
2012-01-17 19:55:09 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Bridge::BridgeMasterPort::BridgeMasterPort(const std::string &_name,
|
|
|
|
Bridge* _bridge,
|
2012-02-24 17:43:53 +01:00
|
|
|
BridgeSlavePort& _slavePort,
|
2012-01-17 19:55:09 +01:00
|
|
|
int _delay, int _req_limit)
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
: MasterPort(_name, _bridge), bridge(_bridge), slavePort(_slavePort),
|
2012-02-24 17:43:53 +01:00
|
|
|
delay(_delay), inRetry(false), reqQueueLimit(_req_limit),
|
|
|
|
sendEvent(*this)
|
2006-05-26 20:29:29 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-05-10 00:20:24 +02:00
|
|
|
Bridge::Bridge(Params *p)
|
2007-08-30 21:16:59 +02:00
|
|
|
: MemObject(p),
|
2012-02-24 17:43:53 +01:00
|
|
|
slavePort(p->name + "-slave", this, masterPort, p->delay,
|
2012-01-17 19:55:09 +01:00
|
|
|
p->nack_delay, p->resp_size, p->ranges),
|
2012-02-24 17:43:53 +01:00
|
|
|
masterPort(p->name + "-master", this, slavePort, p->delay, p->req_size),
|
2007-05-10 00:20:24 +02:00
|
|
|
ackWrites(p->write_ack), _params(p)
|
2006-05-26 20:29:29 +02:00
|
|
|
{
|
2007-05-07 20:42:03 +02:00
|
|
|
if (ackWrites)
|
|
|
|
panic("No support for acknowledging writes\n");
|
2006-05-26 20:29:29 +02:00
|
|
|
}
|
|
|
|
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
MasterPort&
|
|
|
|
Bridge::getMasterPort(const std::string &if_name, int idx)
|
2006-05-26 20:29:29 +02:00
|
|
|
{
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
if (if_name == "master")
|
|
|
|
return masterPort;
|
|
|
|
else
|
|
|
|
// pass it along to our super class
|
|
|
|
return MemObject::getMasterPort(if_name, idx);
|
2006-05-26 20:29:29 +02:00
|
|
|
}
|
|
|
|
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
SlavePort&
|
|
|
|
Bridge::getSlavePort(const std::string &if_name, int idx)
|
|
|
|
{
|
|
|
|
if (if_name == "slave")
|
|
|
|
return slavePort;
|
|
|
|
else
|
|
|
|
// pass it along to our super class
|
|
|
|
return MemObject::getSlavePort(if_name, idx);
|
|
|
|
}
|
2006-05-26 20:29:29 +02:00
|
|
|
|
2006-04-28 21:37:48 +02:00
|
|
|
void
|
|
|
|
Bridge::init()
|
|
|
|
{
|
2012-01-17 19:55:09 +01:00
|
|
|
// make sure both sides are connected and have the same block size
|
|
|
|
if (!slavePort.isConnected() || !masterPort.isConnected())
|
2007-05-07 20:42:03 +02:00
|
|
|
fatal("Both ports of bus bridge are not connected to a bus.\n");
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
if (slavePort.peerBlockSize() != masterPort.peerBlockSize())
|
|
|
|
fatal("Slave port size %d, master port size %d \n " \
|
2009-11-18 22:55:57 +01:00
|
|
|
"Busses don't have the same block size... Not supported.\n",
|
2012-01-17 19:55:09 +01:00
|
|
|
slavePort.peerBlockSize(), masterPort.peerBlockSize());
|
|
|
|
|
|
|
|
// notify the master side of our address ranges
|
|
|
|
slavePort.sendRangeChange();
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2007-05-08 00:58:38 +02:00
|
|
|
bool
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeSlavePort::respQueueFull()
|
2007-05-08 00:58:38 +02:00
|
|
|
{
|
2012-01-17 19:55:09 +01:00
|
|
|
return outstandingResponses == respQueueLimit;
|
2007-05-10 00:20:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeMasterPort::reqQueueFull()
|
2007-05-10 00:20:24 +02:00
|
|
|
{
|
2012-01-17 19:55:09 +01:00
|
|
|
return requestQueue.size() == reqQueueLimit;
|
2007-05-08 00:58:38 +02:00
|
|
|
}
|
2006-04-28 21:37:48 +02:00
|
|
|
|
|
|
|
bool
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
Bridge::BridgeMasterPort::recvTimingResp(PacketPtr pkt)
|
2006-04-28 21:37:48 +02:00
|
|
|
{
|
2012-01-17 19:55:09 +01:00
|
|
|
// all checks are done when the request is accepted on the slave
|
|
|
|
// side, so we are guaranteed to have space for the response
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
DPRINTF(BusBridge, "recvTiming: response %s addr 0x%x\n",
|
|
|
|
pkt->cmdString(), pkt->getAddr());
|
2012-01-17 19:55:09 +01:00
|
|
|
|
|
|
|
DPRINTF(BusBridge, "Request queue size: %d\n", requestQueue.size());
|
2006-11-14 07:12:52 +01:00
|
|
|
|
2012-02-24 17:43:53 +01:00
|
|
|
slavePort.queueForSendTiming(pkt);
|
2012-01-17 19:55:09 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2007-05-13 07:44:42 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
bool
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
Bridge::BridgeSlavePort::recvTimingReq(PacketPtr pkt)
|
2012-01-17 19:55:09 +01:00
|
|
|
{
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
DPRINTF(BusBridge, "recvTiming: request %s addr 0x%x\n",
|
|
|
|
pkt->cmdString(), pkt->getAddr());
|
2012-01-17 19:55:09 +01:00
|
|
|
|
|
|
|
DPRINTF(BusBridge, "Response queue size: %d outresp: %d\n",
|
|
|
|
responseQueue.size(), outstandingResponses);
|
|
|
|
|
2012-02-24 17:43:53 +01:00
|
|
|
if (masterPort.reqQueueFull()) {
|
2012-01-17 19:55:09 +01:00
|
|
|
DPRINTF(BusBridge, "Request queue full, nacking\n");
|
2007-05-08 00:58:38 +02:00
|
|
|
nackRequest(pkt);
|
|
|
|
return true;
|
2006-11-14 07:12:52 +01:00
|
|
|
}
|
2007-05-08 00:58:38 +02:00
|
|
|
|
2008-09-26 17:18:57 +02:00
|
|
|
if (pkt->needsResponse()) {
|
2007-05-10 00:20:24 +02:00
|
|
|
if (respQueueFull()) {
|
2012-01-17 19:55:09 +01:00
|
|
|
DPRINTF(BusBridge,
|
|
|
|
"Response queue full, no space for response, nacking\n");
|
|
|
|
DPRINTF(BusBridge,
|
|
|
|
"queue size: %d outstanding resp: %d\n",
|
|
|
|
responseQueue.size(), outstandingResponses);
|
2007-05-08 00:58:38 +02:00
|
|
|
nackRequest(pkt);
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
DPRINTF(BusBridge, "Request Needs response, reserving space\n");
|
2012-01-17 19:55:09 +01:00
|
|
|
assert(outstandingResponses != respQueueLimit);
|
2007-05-08 00:58:38 +02:00
|
|
|
++outstandingResponses;
|
|
|
|
}
|
2008-09-26 17:18:57 +02:00
|
|
|
}
|
2007-05-08 00:58:38 +02:00
|
|
|
|
2012-02-24 17:43:53 +01:00
|
|
|
masterPort.queueForSendTiming(pkt);
|
2007-05-08 00:58:38 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeSlavePort::nackRequest(PacketPtr pkt)
|
2007-05-08 00:58:38 +02:00
|
|
|
{
|
|
|
|
// Nack the packet
|
2007-08-27 06:45:40 +02:00
|
|
|
pkt->makeTimingResponse();
|
2007-06-30 19:16:18 +02:00
|
|
|
pkt->setNacked();
|
2007-05-08 00:58:38 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
// The Nack packets are stored in the response queue just like any
|
|
|
|
// other response, but they do not occupy any space as this is
|
|
|
|
// tracked by the outstandingResponses, this guarantees space for
|
|
|
|
// the Nack packets, but implicitly means we have an (unrealistic)
|
|
|
|
// unbounded Nack queue.
|
|
|
|
|
|
|
|
// put it on the list to send
|
2011-01-08 06:50:29 +01:00
|
|
|
Tick readyTime = curTick() + nackDelay;
|
2007-05-08 00:58:38 +02:00
|
|
|
PacketBuffer *buf = new PacketBuffer(pkt, readyTime, true);
|
2007-05-10 00:20:24 +02:00
|
|
|
|
|
|
|
// nothing on the list, add it and we're done
|
2012-01-17 19:55:09 +01:00
|
|
|
if (responseQueue.empty()) {
|
2007-05-10 00:20:24 +02:00
|
|
|
assert(!sendEvent.scheduled());
|
2012-01-17 19:55:09 +01:00
|
|
|
bridge->schedule(sendEvent, readyTime);
|
2012-01-17 19:55:09 +01:00
|
|
|
responseQueue.push_back(buf);
|
2007-05-10 00:20:24 +02:00
|
|
|
return;
|
2006-11-14 07:12:52 +01:00
|
|
|
}
|
2007-05-10 00:20:24 +02:00
|
|
|
|
|
|
|
assert(sendEvent.scheduled() || inRetry);
|
|
|
|
|
|
|
|
// does it go at the end?
|
2012-01-17 19:55:09 +01:00
|
|
|
if (readyTime >= responseQueue.back()->ready) {
|
|
|
|
responseQueue.push_back(buf);
|
2007-05-10 00:20:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ok, somewhere in the middle, fun
|
2012-01-17 19:55:09 +01:00
|
|
|
std::list<PacketBuffer*>::iterator i = responseQueue.begin();
|
|
|
|
std::list<PacketBuffer*>::iterator end = responseQueue.end();
|
|
|
|
std::list<PacketBuffer*>::iterator begin = responseQueue.begin();
|
2007-05-10 00:20:24 +02:00
|
|
|
bool done = false;
|
|
|
|
|
|
|
|
while (i != end && !done) {
|
|
|
|
if (readyTime < (*i)->ready) {
|
|
|
|
if (i == begin)
|
2012-01-17 19:55:09 +01:00
|
|
|
bridge->reschedule(sendEvent, readyTime);
|
2012-01-17 19:55:09 +01:00
|
|
|
responseQueue.insert(i,buf);
|
2007-05-10 00:20:24 +02:00
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
assert(done);
|
2006-05-31 00:57:42 +02:00
|
|
|
}
|
|
|
|
|
2007-05-08 00:58:38 +02:00
|
|
|
void
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeMasterPort::queueForSendTiming(PacketPtr pkt)
|
2006-05-31 00:57:42 +02:00
|
|
|
{
|
2012-01-17 19:55:09 +01:00
|
|
|
Tick readyTime = curTick() + delay;
|
|
|
|
PacketBuffer *buf = new PacketBuffer(pkt, readyTime);
|
|
|
|
|
|
|
|
// If we're about to put this packet at the head of the queue, we
|
|
|
|
// need to schedule an event to do the transmit. Otherwise there
|
|
|
|
// should already be an event scheduled for sending the head
|
|
|
|
// packet.
|
|
|
|
if (requestQueue.empty()) {
|
|
|
|
bridge->schedule(sendEvent, readyTime);
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
assert(requestQueue.size() != reqQueueLimit);
|
2007-05-13 07:44:42 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
requestQueue.push_back(buf);
|
|
|
|
}
|
2007-05-13 07:44:42 +02:00
|
|
|
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
void
|
|
|
|
Bridge::BridgeSlavePort::queueForSendTiming(PacketPtr pkt)
|
|
|
|
{
|
|
|
|
// This is a response for a request we forwarded earlier. The
|
|
|
|
// corresponding PacketBuffer should be stored in the packet's
|
|
|
|
// senderState field.
|
|
|
|
PacketBuffer *buf = dynamic_cast<PacketBuffer*>(pkt->senderState);
|
|
|
|
assert(buf != NULL);
|
|
|
|
// set up new packet dest & senderState based on values saved
|
|
|
|
// from original request
|
|
|
|
buf->fixResponse(pkt);
|
|
|
|
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
// the bridge assumes that at least one bus has set the
|
|
|
|
// destination field of the packet
|
|
|
|
assert(pkt->isDestValid());
|
2012-01-17 19:55:09 +01:00
|
|
|
DPRINTF(BusBridge, "response, new dest %d\n", pkt->getDest());
|
|
|
|
delete buf;
|
2007-05-13 07:44:42 +02:00
|
|
|
|
2011-01-08 06:50:29 +01:00
|
|
|
Tick readyTime = curTick() + delay;
|
2012-01-17 19:55:09 +01:00
|
|
|
buf = new PacketBuffer(pkt, readyTime);
|
2006-05-26 20:29:29 +02:00
|
|
|
|
|
|
|
// If we're about to put this packet at the head of the queue, we
|
|
|
|
// need to schedule an event to do the transmit. Otherwise there
|
|
|
|
// should already be an event scheduled for sending the head
|
|
|
|
// packet.
|
2012-01-17 19:55:09 +01:00
|
|
|
if (responseQueue.empty()) {
|
2012-01-17 19:55:09 +01:00
|
|
|
bridge->schedule(sendEvent, readyTime);
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
2012-01-17 19:55:09 +01:00
|
|
|
responseQueue.push_back(buf);
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeMasterPort::trySend()
|
2006-04-28 21:37:48 +02:00
|
|
|
{
|
2012-01-17 19:55:09 +01:00
|
|
|
assert(!requestQueue.empty());
|
2006-05-26 20:29:29 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
PacketBuffer *buf = requestQueue.front();
|
2006-05-26 20:29:29 +02:00
|
|
|
|
2011-01-08 06:50:29 +01:00
|
|
|
assert(buf->ready <= curTick());
|
2006-05-26 20:29:29 +02:00
|
|
|
|
2006-10-20 09:10:12 +02:00
|
|
|
PacketPtr pkt = buf->pkt;
|
2006-05-26 20:29:29 +02:00
|
|
|
|
MEM: Remove the Broadcast destination from the packet
This patch simplifies the packet by removing the broadcast flag and
instead more firmly relying on (and enforcing) the semantics of
transactions in the classic memory system, i.e. request packets are
routed from a master to a slave based on the address, and when they
are created they have neither a valid source, nor destination. On
their way to the slave, the request packet is updated with a source
field for all modules that multiplex packets from multiple master
(e.g. a bus). When a request packet is turned into a response packet
(at the final slave), it moves the potentially populated source field
to the destination field, and the response packet is routed through
any multiplexing components back to the master based on the
destination field.
Modules that connect multiplexing components, such as caches and
bridges store any existing source and destination field in the sender
state as a stack (just as before).
The packet constructor is simplified in that there is no longer a need
to pass the Packet::Broadcast as the destination (this was always the
case for the classic memory system). In the case of Ruby, rather than
using the parameter to the constructor we now rely on setDest, as
there is already another three-argument constructor in the packet
class.
In many places where the packet information was printed as part of
DPRINTFs, request packets would be printed with a numeric "dest" that
would always be -1 (Broadcast) and that field is now removed from the
printing.
2012-04-14 11:45:55 +02:00
|
|
|
DPRINTF(BusBridge, "trySend: origSrc %d addr 0x%x\n",
|
|
|
|
buf->origSrc, pkt->getAddr());
|
2006-05-26 20:29:29 +02:00
|
|
|
|
2007-08-27 06:45:40 +02:00
|
|
|
// If the send was successful, make sure sender state was set to NULL
|
|
|
|
// otherwise we could get a NACK back of a packet that didn't expect a
|
|
|
|
// response and we would try to use freed memory.
|
|
|
|
|
|
|
|
Packet::SenderState *old_sender_state = pkt->senderState;
|
2012-01-17 19:55:09 +01:00
|
|
|
if (!buf->expectResponse)
|
2007-08-27 06:45:40 +02:00
|
|
|
pkt->senderState = NULL;
|
2007-05-07 20:42:03 +02:00
|
|
|
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
if (sendTimingReq(pkt)) {
|
2006-05-26 20:29:29 +02:00
|
|
|
// send successful
|
2012-01-17 19:55:09 +01:00
|
|
|
requestQueue.pop_front();
|
|
|
|
// we no longer own packet, so it's not safe to look at it
|
|
|
|
buf->pkt = NULL;
|
2006-05-31 00:57:42 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
if (!buf->expectResponse) {
|
2006-05-31 00:57:42 +02:00
|
|
|
// no response expected... deallocate packet buffer now.
|
|
|
|
DPRINTF(BusBridge, " successful: no response expected\n");
|
|
|
|
delete buf;
|
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
// If there are more packets to send, schedule event to try again.
|
|
|
|
if (!requestQueue.empty()) {
|
|
|
|
buf = requestQueue.front();
|
|
|
|
DPRINTF(BusBridge, "Scheduling next send\n");
|
|
|
|
bridge->schedule(sendEvent, std::max(buf->ready, curTick() + 1));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
DPRINTF(BusBridge, " unsuccessful\n");
|
|
|
|
pkt->senderState = old_sender_state;
|
|
|
|
inRetry = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(BusBridge, "trySend: request queue size: %d\n",
|
|
|
|
requestQueue.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Bridge::BridgeSlavePort::trySend()
|
|
|
|
{
|
|
|
|
assert(!responseQueue.empty());
|
|
|
|
|
|
|
|
PacketBuffer *buf = responseQueue.front();
|
|
|
|
|
|
|
|
assert(buf->ready <= curTick());
|
|
|
|
|
|
|
|
PacketPtr pkt = buf->pkt;
|
|
|
|
|
|
|
|
DPRINTF(BusBridge, "trySend: origSrc %d dest %d addr 0x%x\n",
|
|
|
|
buf->origSrc, pkt->getDest(), pkt->getAddr());
|
|
|
|
|
|
|
|
bool was_nacked_here = buf->nackedHere;
|
|
|
|
|
|
|
|
// no need to worry about the sender state since we are not
|
|
|
|
// modifying it
|
|
|
|
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
if (sendTimingResp(pkt)) {
|
2012-01-17 19:55:09 +01:00
|
|
|
DPRINTF(BusBridge, " successful\n");
|
|
|
|
// send successful
|
|
|
|
responseQueue.pop_front();
|
|
|
|
// this is a response... deallocate packet buffer now.
|
|
|
|
delete buf;
|
|
|
|
|
|
|
|
if (!was_nacked_here) {
|
|
|
|
assert(outstandingResponses != 0);
|
2007-08-27 06:45:40 +02:00
|
|
|
--outstandingResponses;
|
2012-01-17 19:55:09 +01:00
|
|
|
}
|
2007-05-08 00:58:38 +02:00
|
|
|
|
2006-05-31 00:57:42 +02:00
|
|
|
// If there are more packets to send, schedule event to try again.
|
2012-01-17 19:55:09 +01:00
|
|
|
if (!responseQueue.empty()) {
|
|
|
|
buf = responseQueue.front();
|
2007-05-08 00:58:38 +02:00
|
|
|
DPRINTF(BusBridge, "Scheduling next send\n");
|
2012-01-17 19:55:09 +01:00
|
|
|
bridge->schedule(sendEvent, std::max(buf->ready, curTick() + 1));
|
2006-05-31 00:57:42 +02:00
|
|
|
}
|
2006-05-26 20:29:29 +02:00
|
|
|
} else {
|
|
|
|
DPRINTF(BusBridge, " unsuccessful\n");
|
2007-05-10 00:20:24 +02:00
|
|
|
inRetry = true;
|
2006-05-26 20:29:29 +02:00
|
|
|
}
|
2007-08-27 06:45:40 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
DPRINTF(BusBridge, "trySend: queue size: %d outstanding resp: %d\n",
|
|
|
|
responseQueue.size(), outstandingResponses);
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
void
|
|
|
|
Bridge::BridgeMasterPort::recvRetry()
|
|
|
|
{
|
|
|
|
inRetry = false;
|
|
|
|
Tick nextReady = requestQueue.front()->ready;
|
|
|
|
if (nextReady <= curTick())
|
|
|
|
trySend();
|
|
|
|
else
|
|
|
|
bridge->schedule(sendEvent, nextReady);
|
|
|
|
}
|
2006-04-28 21:37:48 +02:00
|
|
|
|
2006-05-31 00:57:42 +02:00
|
|
|
void
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeSlavePort::recvRetry()
|
2006-04-28 21:37:48 +02:00
|
|
|
{
|
2007-05-10 00:20:24 +02:00
|
|
|
inRetry = false;
|
2012-01-17 19:55:09 +01:00
|
|
|
Tick nextReady = responseQueue.front()->ready;
|
2011-01-08 06:50:29 +01:00
|
|
|
if (nextReady <= curTick())
|
2007-05-10 00:20:24 +02:00
|
|
|
trySend();
|
|
|
|
else
|
2012-01-17 19:55:09 +01:00
|
|
|
bridge->schedule(sendEvent, nextReady);
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
Tick
|
|
|
|
Bridge::BridgeSlavePort::recvAtomic(PacketPtr pkt)
|
|
|
|
{
|
2012-02-24 17:43:53 +01:00
|
|
|
return delay + masterPort.sendAtomic(pkt);
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
void
|
|
|
|
Bridge::BridgeSlavePort::recvFunctional(PacketPtr pkt)
|
2006-04-28 21:37:48 +02:00
|
|
|
{
|
2006-05-26 20:29:29 +02:00
|
|
|
std::list<PacketBuffer*>::iterator i;
|
2006-04-28 21:37:48 +02:00
|
|
|
|
2008-01-02 21:20:15 +01:00
|
|
|
pkt->pushLabel(name());
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
// check the response queue
|
|
|
|
for (i = responseQueue.begin(); i != responseQueue.end(); ++i) {
|
2010-09-09 20:40:19 +02:00
|
|
|
if (pkt->checkFunctional((*i)->pkt)) {
|
|
|
|
pkt->makeResponse();
|
2007-06-18 02:27:53 +02:00
|
|
|
return;
|
2010-09-09 20:40:19 +02:00
|
|
|
}
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
// also check the master port's request queue
|
2012-02-24 17:43:53 +01:00
|
|
|
if (masterPort.checkFunctional(pkt)) {
|
2012-01-17 19:55:09 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-01-02 21:20:15 +01:00
|
|
|
pkt->popLabel();
|
|
|
|
|
2007-06-18 02:27:53 +02:00
|
|
|
// fall through if pkt still not satisfied
|
2012-02-24 17:43:53 +01:00
|
|
|
masterPort.sendFunctional(pkt);
|
2012-01-17 19:55:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Bridge::BridgeMasterPort::checkFunctional(PacketPtr pkt)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
std::list<PacketBuffer*>::iterator i = requestQueue.begin();
|
|
|
|
|
|
|
|
while(i != requestQueue.end() && !found) {
|
|
|
|
if (pkt->checkFunctional((*i)->pkt)) {
|
|
|
|
pkt->makeResponse();
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return found;
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
AddrRangeList
|
2012-01-17 19:55:09 +01:00
|
|
|
Bridge::BridgeSlavePort::getAddrRanges()
|
2006-04-28 21:37:48 +02:00
|
|
|
{
|
2012-01-17 19:55:09 +01:00
|
|
|
return ranges;
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
Bridge *
|
|
|
|
BridgeParams::create()
|
2006-04-28 21:37:48 +02:00
|
|
|
{
|
2007-07-24 06:51:38 +02:00
|
|
|
return new Bridge(this);
|
2006-04-28 21:37:48 +02:00
|
|
|
}
|