mem: Add packet matching functions

Add both block and non-block-aligned packet matching functions,
so that both address and secure bits are checked when checking
whether a packet matches a request.

Change-Id: Id0069befb925d112e06f250741cb47d9dfa249cc
Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17533
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
This commit is contained in:
Daniel R. Carvalho
2019-02-11 14:19:57 +01:00
committed by Daniel Carvalho
parent 9f32d74db8
commit d4cee4dc66
8 changed files with 83 additions and 12 deletions

View File

@@ -2451,7 +2451,7 @@ BaseCache::CacheReqPacketQueue::sendDeferredPacket()
} else {
// let our snoop responses go first if there are responses to
// the same addresses
if (checkConflictingSnoop(entry->blkAddr)) {
if (checkConflictingSnoop(entry->getTarget()->pkt)) {
return;
}
waitingOnRetry = entry->sendPacket(cache);

View File

@@ -189,10 +189,12 @@ class BaseCache : public MemObject
* send out, and if so simply stall any requests, and schedule
* a send event at the same time as the next snoop response is
* being sent out.
*
* @param pkt The packet to check for conflicts against.
*/
bool checkConflictingSnoop(Addr addr)
bool checkConflictingSnoop(const PacketPtr pkt)
{
if (snoopRespQueue.hasAddr(addr)) {
if (snoopRespQueue.checkConflict(pkt, cache.blkSize)) {
DPRINTF(CachePort, "Waiting for snoop response to be "
"sent\n");
Tick when = snoopRespQueue.deferredPacketReadyTime();

View File

@@ -383,7 +383,7 @@ Cache::handleTimingReqMiss(PacketPtr pkt, CacheBlk *blk, Tick forward_time,
pkt->req->masterId());
pf = new Packet(req, pkt->cmd);
pf->allocate();
assert(pf->getAddr() == pkt->getAddr());
assert(pf->matchAddr(pkt));
assert(pf->getSize() == pkt->getSize());
}
@@ -781,7 +781,7 @@ Cache::serviceMSHRTargets(MSHR *mshr, const PacketPtr pkt, CacheBlk *blk)
pkt->payloadDelay;
if (pkt->isRead() && !is_error) {
// sanity check
assert(pkt->getAddr() == tgt_pkt->getAddr());
assert(pkt->matchAddr(tgt_pkt));
assert(pkt->getSize() >= tgt_pkt->getSize());
tgt_pkt->setData(pkt->getConstPtr<uint8_t>());

View File

@@ -396,6 +396,32 @@ Packet::print() const {
return str.str();
}
bool
Packet::matchBlockAddr(const Addr addr, const bool is_secure,
const int blk_size) const
{
return (getBlockAddr(blk_size) == addr) && (isSecure() == is_secure);
}
bool
Packet::matchBlockAddr(const PacketPtr pkt, const int blk_size) const
{
return matchBlockAddr(pkt->getBlockAddr(blk_size), pkt->isSecure(),
blk_size);
}
bool
Packet::matchAddr(const Addr addr, const bool is_secure) const
{
return (getAddr() == addr) && (isSecure() == is_secure);
}
bool
Packet::matchAddr(const PacketPtr pkt) const
{
return matchAddr(pkt->getAddr(), pkt->isSecure());
}
Packet::PrintReqState::PrintReqState(std::ostream &_os, int _verbosity)
: curPrefixPtr(new std::string("")), os(_os), verbosity(_verbosity)
{

View File

@@ -980,6 +980,45 @@ class Packet : public Printable
flags.set(VALID_SIZE);
}
/**
* Check if packet corresponds to a given block-aligned address and
* address space.
*
* @param addr The address to compare against.
* @param is_secure Whether addr belongs to the secure address space.
* @param blk_size Block size in bytes.
* @return Whether packet matches description.
*/
bool matchBlockAddr(const Addr addr, const bool is_secure,
const int blk_size) const;
/**
* Check if this packet refers to the same block-aligned address and
* address space as another packet.
*
* @param pkt The packet to compare against.
* @param blk_size Block size in bytes.
* @return Whether packet matches description.
*/
bool matchBlockAddr(const PacketPtr pkt, const int blk_size) const;
/**
* Check if packet corresponds to a given address and address space.
*
* @param addr The address to compare against.
* @param is_secure Whether addr belongs to the secure address space.
* @return Whether packet matches description.
*/
bool matchAddr(const Addr addr, const bool is_secure) const;
/**
* Check if this packet refers to the same address and address space as
* another packet.
*
* @param pkt The packet to compare against.
* @return Whether packet matches description.
*/
bool matchAddr(const PacketPtr pkt) const;
public:
/**

View File

@@ -72,12 +72,12 @@ PacketQueue::retry()
}
bool
PacketQueue::hasAddr(Addr addr) const
PacketQueue::checkConflict(const PacketPtr pkt, const int blk_size) const
{
// caller is responsible for ensuring that all packets have the
// same alignment
for (const auto& p : transmitList) {
if (p.pkt->getAddr() == addr)
if (p.pkt->matchBlockAddr(pkt, blk_size))
return true;
}
return false;
@@ -138,8 +138,7 @@ PacketQueue::schedSendTiming(PacketPtr pkt, Tick when)
auto it = transmitList.end();
while (it != transmitList.begin()) {
--it;
if ((forceOrder && it->pkt->getAddr() == pkt->getAddr()) ||
it->tick <= when) {
if ((forceOrder && it->pkt->matchAddr(pkt)) || it->tick <= when) {
// emplace inserts the element before the position pointed to by
// the iterator, so advance it one step
transmitList.emplace(++it, when, pkt);

View File

@@ -172,9 +172,14 @@ class PacketQueue : public Drainable
{ return transmitList.empty() ? MaxTick : transmitList.front().tick; }
/**
* Check if a packets address exists in the queue.
* Check if a packet corresponding to the same address exists in the
* queue.
*
* @param pkt The packet to compare against.
* @param blk_size Block size in bytes.
* @return Whether a corresponding packet is found.
*/
bool hasAddr(Addr addr) const;
bool checkConflict(const PacketPtr pkt, const int blk_size) const;
/** Check the list of buffered packets against the supplied
* functional request. */

View File

@@ -174,7 +174,7 @@ SimpleMemory::recvTimingReq(PacketPtr pkt)
auto i = packetQueue.end();
--i;
while (i != packetQueue.begin() && when_to_send < i->tick &&
i->pkt->getAddr() != pkt->getAddr())
!i->pkt->matchAddr(pkt))
--i;
// emplace inserts the element before the position pointed to by