From 80c3bd3bdff45b508375d4e297c68a452a905c6f Mon Sep 17 00:00:00 2001 From: Yu-hsin Wang Date: Fri, 21 Oct 2022 11:53:12 +0800 Subject: [PATCH] mem: introduce bad command error to packet commands The bad command is used to model a request is sent to target but the target cannot make it. The bad command error is designed to model AXI SLVERR. Change-Id: I8142df36a5ed3e461493796266821a2b30a3415e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/64872 Maintainer: Jason Lowe-Power Reviewed-by: Jason Lowe-Power Tested-by: kokoro Reviewed-by: Earl Ou --- src/mem/packet.cc | 4 ++++ src/mem/packet.hh | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/mem/packet.cc b/src/mem/packet.cc index 3cd1bb9a29..31dc330cab 100644 --- a/src/mem/packet.cc +++ b/src/mem/packet.cc @@ -214,6 +214,10 @@ MemCmd::commandInfo[] = { {IsResponse, IsError}, InvalidCmd, "InvalidDestError" }, /* BadAddressError -- memory address invalid */ { {IsResponse, IsError}, InvalidCmd, "BadAddressError" }, + /* ReadError -- packet dest unable to fulfill read command */ + { {IsRead, IsResponse, IsError}, InvalidCmd, "ReadError" }, + /* WriteError -- packet dest unable to fulfill write command */ + { {IsWrite, IsResponse, IsError}, InvalidCmd, "WriteError" }, /* FunctionalReadError */ { {IsRead, IsResponse, IsError}, InvalidCmd, "FunctionalReadError" }, /* FunctionalWriteError */ diff --git a/src/mem/packet.hh b/src/mem/packet.hh index 7d3263412c..9238dbec00 100644 --- a/src/mem/packet.hh +++ b/src/mem/packet.hh @@ -133,6 +133,8 @@ class MemCmd // compatibility InvalidDestError, // packet dest field invalid BadAddressError, // memory address invalid + ReadError, // packet dest unable to fulfill read command + WriteError, // packet dest unable to fulfill write command FunctionalReadError, // unable to fulfill functional read FunctionalWriteError, // unable to fulfill functional write // Fake simulator-only commands @@ -785,6 +787,19 @@ class Packet : public Printable cmd = MemCmd::BadAddressError; } + // Command error conditions. The request is sent to target but the target + // cannot make it. + void + setBadCommand() + { + assert(isResponse()); + if (isWrite()) { + cmd = MemCmd::WriteError; + } else { + cmd = MemCmd::ReadError; + } + } + void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; } Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; }