47#ifndef __MEM_PACKET_HH__
48#define __MEM_PACKET_HH__
52#include <initializer_list>
183 static constexpr unsigned long long
186 unsigned long long ret = 0;
187 for (
const auto &
attr: attrs)
188 ret |= (1ULL <<
attr);
207 Command _response,
const std::string &_str) :
516 const std::string &prefix =
" ");
574 template <
typename T>
579 while (
t == NULL && sender_state != NULL) {
580 t =
dynamic_cast<T*
>(sender_state);
887 if (
req->hasPaddr()) {
903 if (
req->isHTMCmd()) {
907 if (
req->hasSize()) {
928 if (
req->hasPaddr()) {
929 addr =
req->getPaddr() & ~(_blkSize - 1);
995 if (
req->isHTMCmd()) {
996 if (
req->isHTMAbort())
1000 }
else if (
req->isLLSC())
1002 else if (
req->isPrefetchEx())
1004 else if (
req->isPrefetch())
1006 else if (
req->isLockedRMW())
1020 else if (
req->isSwap() ||
req->isAtomic())
1022 else if (
req->isCacheInvalidate()) {
1025 }
else if (
req->isCacheClean()) {
1027 }
else if (
req->isLockedRMW()) {
1126 const int blk_size)
const;
1173 template <
typename T>
1190 template <
typename T>
1211 template <
typename T>
1223 template <
typename T>
1232 template <
typename T>
1237 return (
const T*)
data;
1244 template <
typename T>
1251 template <
typename T>
1258 template <
typename T>
1259 T
get(ByteOrder endian)
const;
1262 template <
typename T>
1266 template <
typename T>
1273 template <
typename T>
1274 void set(T
v, ByteOrder endian);
1280 uint64_t
getUintX(ByteOrder endian)
const;
1287 void setUintX(uint64_t
w, ByteOrder endian);
1327 assert(
req->getByteEnable().size() ==
getSize());
1330 for (
unsigned int i = 0;
i <
getSize();
i++) {
1331 if (
req->getByteEnable()[
i]) {
1381 template <
typename T>
1385 template <
typename T>
1406 warn(
"Trying to check against a masked write, skipping."
1407 " (addr: 0x%x, other addr: 0x%x)",
getAddr(),
1417 other->
getPtr<uint8_t>() : NULL);
1486 void print(std::ostream &o,
int verbosity = 0,
1487 const std::string &prefix =
"")
const;
1495 std::string
print()
const;
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Wrapper that groups a few flag bits under the same undelying container.
bool isSWPrefetch() const
bool isInvalidate() const
const std::string & toString() const
Return the string to a cmd given by idx.
static constexpr unsigned long long buildAttributes(std::initializer_list< Attribute > attrs)
bool operator==(MemCmd c2) const
bool isWriteback() const
A writeback is an eviction that carries data.
static const CommandInfo commandInfo[]
Array to map Command enum to associated info.
bool isHWPrefetch() const
Command
List of all commands associated with a packet.
bool operator!=(MemCmd c2) const
bool needsResponse() const
bool testCmdAttrib(MemCmd::Attribute attrib) const
Command responseCommand() const
bool hasData() const
Check if this particular packet type carries payload data.
bool needsWritable() const
Attribute
List of command attributes.
@ IsLockedRMW
x86 locked RMW access
@ NeedsResponse
Requester needs response from target.
@ IsRead
Data flows from responder to requester.
@ NeedsWritable
Requires writable copy to complete in-cache.
@ IsFlush
Flush the address from caches.
@ FromCache
Request originated from a caching agent.
@ IsClean
Cleans any existing dirty blocks.
@ IsWrite
Data flows from requester to responder.
@ IsPrint
Print state matching address (for debugging)
@ HasData
There is an associated payload.
@ IsLlsc
Alpha/MIPS LL or SC access.
@ IsResponse
Issue by responder.
@ IsRequest
Issued by requester.
Object used to maintain state of a PrintReq.
void popLabel()
Pop a label off the label stack.
void printObj(Printable *obj)
Print a Printable object to os, because it matched the address on a PrintReq.
PrintReqState(std::ostream &os, int verbosity=0)
void pushLabel(const std::string &lbl, const std::string &prefix=" ")
Push a label onto the label stack, and prepend the given prefix string onto the current prefix.
std::list< LabelStackEntry > LabelStack
std::string * curPrefixPtr
const std::string & curPrefix()
Returns the current line prefix.
void printLabels()
Print all of the pending unprinted labels on the stack.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void setExpressSnoop()
The express snoop flag is used for two purposes.
bool responderHadWritable() const
Addr addr
The address of the request.
void writeDataToBlock(uint8_t *blk_data, int blkSize) const
Copy data from the packet to the provided block pointer, which is aligned to the given block size.
@ VALID_ADDR
Are the 'addr' and 'size' fields valid?
@ SUPPRESS_FUNC_ERROR
suppress the error if this packet encounters a functional access failure.
@ DYNAMIC_DATA
The data pointer points to a value that should be freed when the packet is destroyed.
@ EXPRESS_SNOOP
Special timing-mode atomic snoop for multi-level coherence.
@ STATIC_DATA
Is the data pointer set to a value that shouldn't be freed when the packet is destroyed?
@ RESPONDER_HAD_WRITABLE
Allow a responding cache to inform the cache hierarchy that it had a writable copy before responding.
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
void setUintX(uint64_t w, ByteOrder endian)
Set the value in the word w after truncating it to the length of the packet and then byteswapping it ...
void deleteData()
delete the data pointed to in the data pointer.
void setLE(T v)
Set the value in the data pointer to v as little endian.
std::vector< bool > bytesValid
Track the bytes found that satisfy a functional read.
Packet(const PacketPtr pkt, bool clear_flags, bool alloc_data)
Alternate constructor for copying a packet.
void setWriteThrough()
A writeback/writeclean cmd gets propagated further downstream by the receiver when the flag is set.
gem5::Flags< FlagsType > Flags
Packet(const RequestPtr &_req, MemCmd _cmd, int _blkSize, PacketId _id=0)
Alternate constructor if you are trying to create a packet with a request that is for a whole block,...
void setBE(T v)
Set the value in the data pointer to v as big endian.
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
uint32_t snoopDelay
Keep track of the extra delay incurred by snooping upwards before sending a request down the memory s...
void setHtmTransactionFailedInCache(const HtmCacheFailure ret_code)
Stipulates that this packet/request has returned from the cache hierarchy in a failed transaction.
void makeTimingResponse()
bool needsWritable() const
T getBE() const
Get the data in the packet byte swapped from big endian to host endian.
AddrRange getAddrRange() const
Get address range to which this packet belongs.
bool isGLCSet() const
Accessor functions for the cache bypass flags.
void copyError(Packet *pkt)
void setAddr(Addr _addr)
Update the address of this packet mid-transaction.
static PacketPtr createWrite(const RequestPtr &req)
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
bool needsResponse() const
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
SenderState * senderState
This packet's sender state.
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
bool matchAddr(const Addr addr, const bool is_secure) const
Check if packet corresponds to a given address and address space.
RequestorID requestorId() const
static MemCmd makeWriteCmd(const RequestPtr &req)
Generate the appropriate write MemCmd based on the Request flags.
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
int cmdToIndex() const
Return the index of this command.
T * findNextSenderState() const
Go through the sender state stack and return the first instance that is of type T (as determined by a...
void setResponderHadWritable()
On responding to a snoop request (which only happens for Modified or Owned lines),...
Addr getOffset(unsigned int blk_size) const
~Packet()
clean up packet variables
bool mustCheckAbove() const
Does the request need to check for cached copies of the same block in the memory hierarchy above.
void pushSenderState(SenderState *sender_state)
Push a new sender state to the packet and make the current sender state the predecessor of the new on...
void setRaw(T v)
Set the value in the data pointer to v without byte swapping.
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
void copyResponderFlags(const PacketPtr pkt)
Copy the reponse flags from an input packet to this packet.
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
bool writeThrough() const
HtmCacheFailure getHtmTransactionFailedInCacheRC() const
If a packet/request has returned from the cache hierarchy in a failed transaction,...
bool isHtmTransactional() const
Returns whether or not this packet/request originates in the CPU executing in transactional mode,...
std::string print() const
A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overhea...
T * getPtr()
get a pointer to the data ptr.
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
void convertScToWrite()
It has been determined that the SC packet should successfully update memory.
void setDataFromBlock(const uint8_t *blk_data, int blkSize)
Copy data into the packet from the provided block pointer, which is aligned to the given block size.
bool trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
uint64_t getHtmTransactionUid() const
If a packet/request originates in a CPU executing in transactional mode, i.e.
Addr getBlockAddr(unsigned int blk_size) const
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
RequestPtr req
A pointer to the original request.
bool isCleanInvalidateRequest() const
Is this packet a clean invalidate request, e.g., clflush/clflushopt?
unsigned size
The size of the request or transfer.
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
void setCacheResponding()
Snoop flags.
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
bool isExpressSnoop() const
void setFunctionalResponseStatus(bool success)
bool _isSecure
True if the request targets the secure memory space.
void convertLlToRead()
When ruby is in use, Ruby will monitor the cache line and the phys memory should treat LL ops as norm...
const T * getConstPtr() const
void dataStaticConst(const T *p)
Set the data pointer to the following value that should not be freed.
void setHasSharers()
On fills, the hasSharers flag is used by the caches in combination with the cacheResponding flag,...
Packet(const RequestPtr &_req, MemCmd _cmd)
Constructor.
bool matchBlockAddr(const Addr addr, const bool is_secure, const int blk_size) const
Check if packet corresponds to a given block-aligned address and address space.
HtmCacheFailure htmReturnReason
Holds the return status of the transaction.
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
void setHtmTransactional(uint64_t val)
Stipulates that this packet/request originates in the CPU executing in transactional mode,...
void makeHtmTransactionalReqResponse(const HtmCacheFailure ret_code)
Communicates to the core that a packet was processed by the memory subsystem while running in transac...
void setSize(unsigned size)
static MemCmd makeReadCmd(const RequestPtr &req)
Generate the appropriate read MemCmd based on the Request flags.
bool cacheResponding() const
T getRaw() const
Get the data in the packet without byte swapping.
void qosValue(const uint8_t qos_value)
QoS Value setter Interface for setting QoS priority value of the packet.
void makeAtomicResponse()
void setSatisfied()
Set when a request hits in a cache and the cache is not going to respond.
MemCmd cmd
The command field of the packet.
bool suppressFuncError() const
bool isMaskedWrite() const
T get(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness.
bool isInvalidate() const
bool htmTransactionFailedInCache() const
Returns whether or not this packet/request has returned from the cache hierarchy in a failed transact...
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
void setSuppressFuncError()
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
bool isWholeLineWrite(unsigned blk_size)
uint64_t htmTransactionUid
A global unique identifier of the transaction.
bool isBlockCached() const
PacketDataPtr data
A pointer to the data being transferred.
void allocate()
Allocate memory for the packet.
Abstract base class for objects which support being printed to a stream for debugging.
void set(Type mask)
Set all flag's bits matching the given mask.
bool isSet(Type mask) const
Verifies whether any bit matching the given mask is set.
void clear()
Clear all flag's bits.
bool noneSet(Type mask) const
Verifies whether no bits matching the given mask are set.
ProbePointArg< PacketInfo > Packet
Packet probe point.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
T safe_cast(U &&ref_or_ptr)
std::shared_ptr< Request > RequestPtr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::list< PacketPtr > PacketList
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
Structure that defines attributes and other data associated with a Command.
const Command response
Corresponding response for requests; InvalidCmd if no response is applicable.
const std::bitset< NUM_COMMAND_ATTRIBUTES > attributes
Set of attribute flags.
const std::string str
String representation (for printing)
CommandInfo(std::initializer_list< Attribute > attrs, Command _response, const std::string &_str)
An entry in the label stack.
LabelStackEntry(const std::string &_label, std::string *_prefix)
A virtual base opaque structure used to hold state associated with the packet (e.g....
SenderState * predecessor