gem5 v24.0.0.0
Loading...
Searching...
No Matches
packet.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2019, 2021 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2006 The Regents of The University of Michigan
15 * Copyright (c) 2010,2015 Advanced Micro Devices, Inc.
16 * All rights reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions are
20 * met: redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer;
22 * redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution;
25 * neither the name of the copyright holders nor the names of its
26 * contributors may be used to endorse or promote products derived from
27 * this software without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 */
41
47#ifndef __MEM_PACKET_HH__
48#define __MEM_PACKET_HH__
49
50#include <bitset>
51#include <cassert>
52#include <initializer_list>
53#include <list>
54
55#include "base/addr_range.hh"
56#include "base/cast.hh"
57#include "base/compiler.hh"
58#include "base/extensible.hh"
59#include "base/flags.hh"
60#include "base/logging.hh"
61#include "base/printable.hh"
62#include "base/types.hh"
63#include "mem/htm.hh"
64#include "mem/request.hh"
65#include "sim/byteswap.hh"
66
67namespace gem5
68{
69
70class Packet;
71typedef Packet *PacketPtr;
72typedef uint8_t* PacketDataPtr;
74typedef uint64_t PacketId;
75
76class MemCmd
77{
78 friend class Packet;
79
80 public:
85 {
95 WriteClean, // writes dirty data below without evicting
104 SCUpgradeReq, // Special "weak" upgrade for StoreCond
106 SCUpgradeFailReq, // Failed SCUpgradeReq in MSHR (never sent)
107 UpgradeFailResp, // Valid for SCUpgradeReq only
114 StoreCondFailReq, // Failed StoreCondReq in MSHR (never sent)
122 // MessageReq and MessageResp are deprecated.
124 MemSyncReq, // memory synchronization request (e.g., cache invalidate)
125 MemSyncResp, // memory synchronization response
131 // Error responses
132 // @TODO these should be classified as responses rather than
133 // requests; coding them as requests initially for backwards
134 // compatibility
135 InvalidDestError, // packet dest field invalid
136 BadAddressError, // memory address invalid
137 ReadError, // packet dest unable to fulfill read command
138 WriteError, // packet dest unable to fulfill write command
139 FunctionalReadError, // unable to fulfill functional read
140 FunctionalWriteError, // unable to fulfill functional write
141 // Fake simulator-only commands
142 PrintReq, // Print state matching address
143 FlushReq, //request for a cache flush
144 InvalidateReq, // request for address to be invalidated
146 // hardware transactional memory
150 // Tlb shootdown
153 };
154
155 private:
182
183 static constexpr unsigned long long
184 buildAttributes(std::initializer_list<Attribute> attrs)
185 {
186 unsigned long long ret = 0;
187 for (const auto &attr: attrs)
188 ret |= (1ULL << attr);
189 return ret;
190 }
191
197 {
199 const std::bitset<NUM_COMMAND_ATTRIBUTES> attributes;
204 const std::string str;
205
206 CommandInfo(std::initializer_list<Attribute> attrs,
207 Command _response, const std::string &_str) :
208 attributes(buildAttributes(attrs)), response(_response), str(_str)
209 {}
210 };
211
213 static const CommandInfo commandInfo[];
214
215 private:
216
218
219 bool
221 {
222 return commandInfo[cmd].attributes[attrib] != 0;
223 }
224
225 public:
226
227 bool isRead() const { return testCmdAttrib(IsRead); }
228 bool isWrite() const { return testCmdAttrib(IsWrite); }
229 bool isUpgrade() const { return testCmdAttrib(IsUpgrade); }
230 bool isRequest() const { return testCmdAttrib(IsRequest); }
231 bool isResponse() const { return testCmdAttrib(IsResponse); }
232 bool needsWritable() const { return testCmdAttrib(NeedsWritable); }
233 bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
234 bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
235 bool isEviction() const { return testCmdAttrib(IsEviction); }
236 bool isClean() const { return testCmdAttrib(IsClean); }
237 bool fromCache() const { return testCmdAttrib(FromCache); }
238
242 bool isWriteback() const { return testCmdAttrib(IsEviction) &&
244
250 bool hasData() const { return testCmdAttrib(HasData); }
251 bool isLLSC() const { return testCmdAttrib(IsLlsc); }
252 bool isLockedRMW() const { return testCmdAttrib(IsLockedRMW); }
253 bool isSWPrefetch() const { return testCmdAttrib(IsSWPrefetch); }
254 bool isHWPrefetch() const { return testCmdAttrib(IsHWPrefetch); }
257 bool isError() const { return testCmdAttrib(IsError); }
258 bool isPrint() const { return testCmdAttrib(IsPrint); }
259 bool isFlush() const { return testCmdAttrib(IsFlush); }
260
261 bool
262 isDemand() const
263 {
264 return (cmd == ReadReq || cmd == WriteReq ||
265 cmd == WriteLineReq || cmd == ReadExReq ||
267 }
268
269 Command
271 {
272 return commandInfo[cmd].response;
273 }
274
276 const std::string &toString() const { return commandInfo[cmd].str; }
277 int toInt() const { return (int)cmd; }
278
279 MemCmd(Command _cmd) : cmd(_cmd) { }
280 MemCmd(int _cmd) : cmd((Command)_cmd) { }
282
283 bool operator==(MemCmd c2) const { return (cmd == c2.cmd); }
284 bool operator!=(MemCmd c2) const { return (cmd != c2.cmd); }
285};
286
294class Packet : public Printable, public Extensible<Packet>
295{
296 public:
297 typedef uint32_t FlagsType;
299
300 private:
301 enum : FlagsType
302 {
303 // Flags to transfer across when copying a packet
304 COPY_FLAGS = 0x000000FF,
305
306 // Flags that are used to create reponse packets
307 RESPONDER_FLAGS = 0x00000009,
308
309 // Does this packet have sharers (which means it should not be
310 // considered writable) or not. See setHasSharers below.
311 HAS_SHARERS = 0x00000001,
312
313 // Special control flags
315 EXPRESS_SNOOP = 0x00000002,
316
321
322 // Snoop co-ordination flag to indicate that a cache is
323 // responding to a snoop. See setCacheResponding below.
324 CACHE_RESPONDING = 0x00000008,
325
326 // The writeback/writeclean should be propagated further
327 // downstream by the receiver
328 WRITE_THROUGH = 0x00000010,
329
330 // Response co-ordination flag for cache maintenance
331 // operations
332 SATISFIED = 0x00000020,
333
334 // hardware transactional memory
335
336 // Indicates that this packet/request has returned from the
337 // cache hierarchy in a failed transaction. The core is
338 // notified like this.
339 FAILS_TRANSACTION = 0x00000040,
340
341 // Indicates that this packet/request originates in the CPU executing
342 // in transactional mode, i.e. in a transaction.
343 FROM_TRANSACTION = 0x00000080,
344
346 VALID_ADDR = 0x00000100,
347 VALID_SIZE = 0x00000200,
348
351 STATIC_DATA = 0x00001000,
355 DYNAMIC_DATA = 0x00002000,
356
360
361 // Signal block present to squash prefetch and cache evict packets
362 // through express snoop flag
363 BLOCK_CACHED = 0x00010000
364 };
365
367
368 public:
370
373
375
378
379 private:
388
392
395
397 unsigned size;
398
403
404 // Quality of Service priority value
405 uint8_t _qosValue;
406
407 // hardware transactional memory
408
415
421
422 public:
423
431 uint32_t headerDelay;
432
439 uint32_t snoopDelay;
440
449 uint32_t payloadDelay;
450
474
480 {
481 private:
486 {
487 const std::string label;
488 std::string *prefix;
490 LabelStackEntry(const std::string &_label, std::string *_prefix);
491 };
492
495
496 std::string *curPrefixPtr;
497
498 public:
499 std::ostream &os;
500 const int verbosity;
501
502 PrintReqState(std::ostream &os, int verbosity = 0);
504
508 const std::string &curPrefix() { return *curPrefixPtr; }
509
515 void pushLabel(const std::string &lbl,
516 const std::string &prefix = " ");
517
521 void popLabel();
522
528 void printLabels();
529
534 void printObj(Printable *obj);
535 };
536
546
555 void pushSenderState(SenderState *sender_state);
556
566
574 template <typename T>
576 {
577 T *t = NULL;
578 SenderState* sender_state = senderState;
579 while (t == NULL && sender_state != NULL) {
580 t = dynamic_cast<T*>(sender_state);
581 sender_state = sender_state->predecessor;
582 }
583 return t;
584 }
585
588 const std::string &cmdString() const { return cmd.toString(); }
589
591 inline int cmdToIndex() const { return cmd.toInt(); }
592
593 bool isRead() const { return cmd.isRead(); }
594 bool isWrite() const { return cmd.isWrite(); }
595 bool isDemand() const { return cmd.isDemand(); }
596 bool isUpgrade() const { return cmd.isUpgrade(); }
597 bool isRequest() const { return cmd.isRequest(); }
598 bool isResponse() const { return cmd.isResponse(); }
599 bool needsWritable() const
600 {
601 // we should never check if a response needsWritable, the
602 // request has this flag, and for a response we should rather
603 // look at the hasSharers flag (if not set, the response is to
604 // be considered writable)
605 assert(isRequest());
606 return cmd.needsWritable();
607 }
608 bool needsResponse() const { return cmd.needsResponse(); }
609 bool isInvalidate() const { return cmd.isInvalidate(); }
610 bool isEviction() const { return cmd.isEviction(); }
611 bool isClean() const { return cmd.isClean(); }
612 bool fromCache() const { return cmd.fromCache(); }
613 bool isWriteback() const { return cmd.isWriteback(); }
614 bool hasData() const { return cmd.hasData(); }
615 bool hasRespData() const
616 {
617 MemCmd resp_cmd = cmd.responseCommand();
618 return resp_cmd.hasData();
619 }
620 bool isLLSC() const { return cmd.isLLSC(); }
621 bool isLockedRMW() const { return cmd.isLockedRMW(); }
622 bool isError() const { return cmd.isError(); }
623 bool isPrint() const { return cmd.isPrint(); }
624 bool isFlush() const { return cmd.isFlush(); }
625
626 bool isWholeLineWrite(unsigned blk_size)
627 {
628 return (cmd == MemCmd::WriteReq || cmd == MemCmd::WriteLineReq) &&
629 getOffset(blk_size) == 0 && getSize() == blk_size &&
630 !isMaskedWrite();
631 }
632
634
654 {
655 assert(isRequest());
656 assert(!flags.isSet(CACHE_RESPONDING));
658 }
659 bool cacheResponding() const { return flags.isSet(CACHE_RESPONDING); }
686 bool hasSharers() const { return flags.isSet(HAS_SHARERS); }
688
702 bool isExpressSnoop() const { return flags.isSet(EXPRESS_SNOOP); }
703
714 {
715 assert(cacheResponding());
716 assert(!responderHadWritable());
718 }
721
729 void copyResponderFlags(const PacketPtr pkt);
730
736 {
737 assert(cmd.isWrite() &&
740 }
742 bool writeThrough() const { return flags.isSet(WRITE_THROUGH); }
743
750 {
751 assert(cmd.isClean());
752 assert(!flags.isSet(SATISFIED));
754 }
755 bool satisfied() const { return flags.isSet(SATISFIED); }
756
760 bool isBlockCached() const { return flags.isSet(BLOCK_CACHED); }
762
769 inline uint8_t qosValue() const { return _qosValue; }
770
777 inline void qosValue(const uint8_t qos_value)
778 { _qosValue = qos_value; }
779
780 inline RequestorID requestorId() const { return req->requestorId(); }
781
782 // Network error conditions... encapsulate them as methods since
783 // their encoding keeps changing (from result field to command
784 // field, etc.)
785 void
787 {
788 assert(isResponse());
790 }
791
792 // Command error conditions. The request is sent to target but the target
793 // cannot make it.
794 void
796 {
797 assert(isResponse());
798 if (isWrite()) {
800 } else {
802 }
803 }
804
805 void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; }
806
807 Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; }
815 void setAddr(Addr _addr) { assert(flags.isSet(VALID_ADDR)); addr = _addr; }
816
817 unsigned getSize() const { assert(flags.isSet(VALID_SIZE)); return size; }
818
824 AddrRange getAddrRange() const;
825
826 Addr getOffset(unsigned int blk_size) const
827 {
828 return getAddr() & Addr(blk_size - 1);
829 }
830
831 Addr getBlockAddr(unsigned int blk_size) const
832 {
833 return getAddr() & ~(Addr(blk_size - 1));
834 }
835
836 bool isSecure() const
837 {
838 assert(flags.isSet(VALID_ADDR));
839 return _isSecure;
840 }
841
845 AtomicOpFunctor *getAtomicOp() const { return req->getAtomicOpFunctor(); }
846 bool isAtomicOp() const { return req->isAtomic(); }
847
852 void
854 {
855 assert(isLLSC());
856 assert(isWrite());
858 }
859
864 void
866 {
867 assert(isLLSC());
868 assert(isRead());
870 }
871
877 Packet(const RequestPtr &_req, MemCmd _cmd)
878 : cmd(_cmd), id((PacketId)_req.get()), req(_req),
879 data(nullptr), addr(0), _isSecure(false), size(0),
880 _qosValue(0),
883 headerDelay(0), snoopDelay(0),
884 payloadDelay(0), senderState(NULL)
885 {
886 flags.clear();
887 if (req->hasPaddr()) {
888 addr = req->getPaddr();
890 _isSecure = req->isSecure();
891 }
892
903 if (req->isHTMCmd()) {
905 assert(addr == 0x0);
906 }
907 if (req->hasSize()) {
908 size = req->getSize();
910 }
911 }
912
918 Packet(const RequestPtr &_req, MemCmd _cmd, int _blkSize, PacketId _id = 0)
919 : cmd(_cmd), id(_id ? _id : (PacketId)_req.get()), req(_req),
920 data(nullptr), addr(0), _isSecure(false),
921 _qosValue(0),
924 headerDelay(0),
926 {
927 flags.clear();
928 if (req->hasPaddr()) {
929 addr = req->getPaddr() & ~(_blkSize - 1);
931 _isSecure = req->isSecure();
932 }
933 size = _blkSize;
935 }
936
944 Packet(const PacketPtr pkt, bool clear_flags, bool alloc_data)
945 : Extensible<Packet>(*pkt),
946 cmd(pkt->cmd), id(pkt->id), req(pkt->req),
947 data(nullptr),
948 addr(pkt->addr), _isSecure(pkt->_isSecure), size(pkt->size),
950 _qosValue(pkt->qosValue()),
954 snoopDelay(0),
957 {
958 if (!clear_flags)
959 flags.set(pkt->flags & COPY_FLAGS);
960
962
963 if (pkt->isHtmTransactional())
965
966 if (pkt->htmTransactionFailedInCache()) {
969 );
970 }
971
972 // should we allocate space for data, or not, the express
973 // snoops do not need to carry any data as they only serve to
974 // co-ordinate state changes
975 if (alloc_data) {
976 // even if asked to allocate data, if the original packet
977 // holds static data, then the sender will not be doing
978 // any memcpy on receiving the response, thus we simply
979 // carry the pointer forward
980 if (pkt->flags.isSet(STATIC_DATA)) {
981 data = pkt->data;
983 } else {
984 allocate();
985 }
986 }
987 }
988
992 static MemCmd
994 {
995 if (req->isHTMCmd()) {
996 if (req->isHTMAbort())
997 return MemCmd::HTMAbort;
998 else
999 return MemCmd::HTMReq;
1000 } else if (req->isLLSC())
1001 return MemCmd::LoadLockedReq;
1002 else if (req->isPrefetchEx())
1003 return MemCmd::SoftPFExReq;
1004 else if (req->isPrefetch())
1005 return MemCmd::SoftPFReq;
1006 else if (req->isLockedRMW())
1008 else
1009 return MemCmd::ReadReq;
1010 }
1011
1015 static MemCmd
1017 {
1018 if (req->isLLSC())
1019 return MemCmd::StoreCondReq;
1020 else if (req->isSwap() || req->isAtomic())
1021 return MemCmd::SwapReq;
1022 else if (req->isCacheInvalidate()) {
1023 return req->isCacheClean() ? MemCmd::CleanInvalidReq :
1025 } else if (req->isCacheClean()) {
1027 } else if (req->isLockedRMW()) {
1029 } else
1030 return MemCmd::WriteReq;
1031 }
1032
1037 static PacketPtr
1039 {
1040 return new Packet(req, makeReadCmd(req));
1041 }
1042
1043 static PacketPtr
1045 {
1046 return new Packet(req, makeWriteCmd(req));
1047 }
1048
1053 {
1054 deleteData();
1055 }
1056
1061 void
1063 {
1064 assert(needsResponse());
1065 assert(isRequest());
1067
1068 // responses are never express, even if the snoop that
1069 // triggered them was
1071 }
1072
1073 void
1075 {
1076 makeResponse();
1077 }
1078
1079 void
1081 {
1082 makeResponse();
1083 }
1084
1085 void
1087 {
1088 if (!success) {
1089 if (isWrite()) {
1091 } else {
1093 }
1094 }
1095 }
1096
1097 void
1098 setSize(unsigned size)
1099 {
1100 assert(!flags.isSet(VALID_SIZE));
1101
1102 this->size = size;
1104 }
1105
1113 bool isGLCSet() const { return req->isGLCSet();}
1114 bool isSLCSet() const { return req->isSLCSet();}
1115
1125 bool matchBlockAddr(const Addr addr, const bool is_secure,
1126 const int blk_size) const;
1127
1136 bool matchBlockAddr(const PacketPtr pkt, const int blk_size) const;
1137
1145 bool matchAddr(const Addr addr, const bool is_secure) const;
1146
1154 bool matchAddr(const PacketPtr pkt) const;
1155
1156 public:
1173 template <typename T>
1174 void
1176 {
1178 data = (PacketDataPtr)p;
1180 }
1181
1190 template <typename T>
1191 void
1193 {
1195 data = const_cast<PacketDataPtr>(p);
1197 }
1198
1211 template <typename T>
1212 void
1214 {
1216 data = (PacketDataPtr)p;
1218 }
1219
1223 template <typename T>
1224 T*
1226 {
1228 assert(!isMaskedWrite());
1229 return (T*)data;
1230 }
1231
1232 template <typename T>
1233 const T*
1235 {
1237 return (const T*)data;
1238 }
1239
1244 template <typename T>
1245 T getBE() const;
1246
1251 template <typename T>
1252 T getLE() const;
1253
1258 template <typename T>
1259 T get(ByteOrder endian) const;
1260
1262 template <typename T>
1263 void setBE(T v);
1264
1266 template <typename T>
1267 void setLE(T v);
1268
1273 template <typename T>
1274 void set(T v, ByteOrder endian);
1275
1280 uint64_t getUintX(ByteOrder endian) const;
1281
1287 void setUintX(uint64_t w, ByteOrder endian);
1288
1292 void
1293 setData(const uint8_t *p)
1294 {
1295 // we should never be copying data onto itself, which means we
1296 // must idenfity packets with static data, as they carry the
1297 // same pointer from source to destination and back
1298 assert(p != getPtr<uint8_t>() || flags.isSet(STATIC_DATA));
1299
1300 if (p != getPtr<uint8_t>()) {
1301 // for packet with allocated dynamic data, we copy data from
1302 // one to the other, e.g. a forwarded response to a response
1303 std::memcpy(getPtr<uint8_t>(), p, getSize());
1304 }
1305 }
1306
1311 void
1312 setDataFromBlock(const uint8_t *blk_data, int blkSize)
1313 {
1314 setData(blk_data + getOffset(blkSize));
1315 }
1316
1321 void
1322 writeData(uint8_t *p) const
1323 {
1324 if (!isMaskedWrite()) {
1325 std::memcpy(p, getConstPtr<uint8_t>(), getSize());
1326 } else {
1327 assert(req->getByteEnable().size() == getSize());
1328 // Write only the enabled bytes
1329 const uint8_t *base = getConstPtr<uint8_t>();
1330 for (unsigned int i = 0; i < getSize(); i++) {
1331 if (req->getByteEnable()[i]) {
1332 p[i] = *(base + i);
1333 }
1334 // Disabled bytes stay untouched
1335 }
1336 }
1337 }
1338
1345 void
1346 writeDataToBlock(uint8_t *blk_data, int blkSize) const
1347 {
1348 writeData(blk_data + getOffset(blkSize));
1349 }
1350
1355 void
1357 {
1359 delete [] data;
1360
1362 data = NULL;
1363 }
1364
1366 void
1368 {
1369 // if either this command or the response command has a data
1370 // payload, actually allocate space
1371 if (hasData() || hasRespData()) {
1374 data = new uint8_t[getSize()];
1375 }
1376 }
1377
1381 template <typename T>
1382 T getRaw() const;
1383
1385 template <typename T>
1386 void setRaw(T v);
1387
1388 public:
1398 bool
1400 {
1401 if (other->isMaskedWrite()) {
1402 // Do not forward data if overlapping with a masked write
1403 if (_isSecure == other->isSecure() &&
1404 getAddr() <= (other->getAddr() + other->getSize() - 1) &&
1405 other->getAddr() <= (getAddr() + getSize() - 1)) {
1406 warn("Trying to check against a masked write, skipping."
1407 " (addr: 0x%x, other addr: 0x%x)", getAddr(),
1408 other->getAddr());
1409 }
1410 return false;
1411 }
1412 // all packets that are carrying a payload should have a valid
1413 // data pointer
1414 return trySatisfyFunctional(other, other->getAddr(), other->isSecure(),
1415 other->getSize(),
1416 other->hasData() ?
1417 other->getPtr<uint8_t>() : NULL);
1418 }
1419
1424 bool
1426 {
1427 return cmd == MemCmd::HardPFReq || isEviction();
1428 }
1429
1434 bool
1436 {
1438 }
1439
1443 bool
1445 {
1446 return cmd == MemCmd::CleanInvalidReq;
1447 }
1448
1449 bool
1451 {
1452 return (cmd == MemCmd::WriteReq && req->isMasked());
1453 }
1454
1462 bool
1463 trySatisfyFunctional(Printable *obj, Addr base, bool is_secure, int size,
1464 uint8_t *_data);
1465
1469 void
1470 pushLabel(const std::string &lbl)
1471 {
1472 if (isPrint())
1473 safe_cast<PrintReqState*>(senderState)->pushLabel(lbl);
1474 }
1475
1479 void
1481 {
1482 if (isPrint())
1484 }
1485
1486 void print(std::ostream &o, int verbosity = 0,
1487 const std::string &prefix = "") const;
1488
1495 std::string print() const;
1496
1497 // hardware transactional memory
1498
1508
1513 void setHtmTransactional(uint64_t val);
1514
1519 bool isHtmTransactional() const;
1520
1527 uint64_t getHtmTransactionUid() const;
1528
1535
1541 bool htmTransactionFailedInCache() const;
1542
1548};
1549
1550} // namespace gem5
1551
1552#endif //__MEM_PACKET_HH
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...
Definition addr_range.hh:82
Wrapper that groups a few flag bits under the same undelying container.
Definition flags.hh:45
bool isFlush() const
Definition packet.hh:259
bool isSWPrefetch() const
Definition packet.hh:253
bool isInvalidate() const
Definition packet.hh:234
MemCmd(int _cmd)
Definition packet.hh:280
const std::string & toString() const
Return the string to a cmd given by idx.
Definition packet.hh:276
bool isRequest() const
Definition packet.hh:230
static constexpr unsigned long long buildAttributes(std::initializer_list< Attribute > attrs)
Definition packet.hh:184
bool isResponse() const
Definition packet.hh:231
bool isRead() const
Definition packet.hh:227
bool operator==(MemCmd c2) const
Definition packet.hh:283
bool isWriteback() const
A writeback is an eviction that carries data.
Definition packet.hh:242
static const CommandInfo commandInfo[]
Array to map Command enum to associated info.
Definition packet.hh:213
bool isEviction() const
Definition packet.hh:235
bool isHWPrefetch() const
Definition packet.hh:254
Command cmd
Definition packet.hh:217
Command
List of all commands associated with a packet.
Definition packet.hh:85
@ InvalidDestError
Definition packet.hh:135
@ FunctionalReadError
Definition packet.hh:139
@ ReadRespWithInvalidate
Definition packet.hh:89
@ WritebackDirty
Definition packet.hh:93
@ CleanInvalidResp
Definition packet.hh:130
@ StoreCondFailReq
Definition packet.hh:114
@ LockedRMWReadReq
Definition packet.hh:116
@ CleanSharedResp
Definition packet.hh:128
@ LockedRMWWriteReq
Definition packet.hh:118
@ BadAddressError
Definition packet.hh:136
@ LockedRMWReadResp
Definition packet.hh:117
@ WritebackClean
Definition packet.hh:94
@ LockedRMWWriteResp
Definition packet.hh:119
@ FunctionalWriteError
Definition packet.hh:140
@ SCUpgradeFailReq
Definition packet.hh:106
@ UpgradeFailResp
Definition packet.hh:107
@ CleanInvalidReq
Definition packet.hh:129
@ WriteCompleteResp
Definition packet.hh:92
MemCmd(Command _cmd)
Definition packet.hh:279
bool isLockedRMW() const
Definition packet.hh:252
bool isWrite() const
Definition packet.hh:228
bool operator!=(MemCmd c2) const
Definition packet.hh:284
bool needsResponse() const
Definition packet.hh:233
bool testCmdAttrib(MemCmd::Attribute attrib) const
Definition packet.hh:220
bool isLLSC() const
Definition packet.hh:251
bool isPrint() const
Definition packet.hh:258
Command responseCommand() const
Definition packet.hh:270
bool isError() const
Definition packet.hh:257
bool isDemand() const
Definition packet.hh:262
bool hasData() const
Check if this particular packet type carries payload data.
Definition packet.hh:250
bool needsWritable() const
Definition packet.hh:232
bool isUpgrade() const
Definition packet.hh:229
bool isClean() const
Definition packet.hh:236
bool isPrefetch() const
Definition packet.hh:255
int toInt() const
Definition packet.hh:277
bool fromCache() const
Definition packet.hh:237
Attribute
List of command attributes.
Definition packet.hh:160
@ IsLockedRMW
x86 locked RMW access
Definition packet.hh:174
@ NeedsResponse
Requester needs response from target.
Definition packet.hh:169
@ IsRead
Data flows from responder to requester.
Definition packet.hh:161
@ NeedsWritable
Requires writable copy to complete in-cache.
Definition packet.hh:166
@ IsFlush
Flush the address from caches.
Definition packet.hh:178
@ FromCache
Request originated from a caching agent.
Definition packet.hh:179
@ IsError
Error response.
Definition packet.hh:176
@ IsClean
Cleans any existing dirty blocks.
Definition packet.hh:165
@ IsWrite
Data flows from requester to responder.
Definition packet.hh:162
@ IsPrint
Print state matching address (for debugging)
Definition packet.hh:177
@ HasData
There is an associated payload.
Definition packet.hh:175
@ IsLlsc
Alpha/MIPS LL or SC access.
Definition packet.hh:173
@ IsResponse
Issue by responder.
Definition packet.hh:168
@ IsRequest
Issued by requester.
Definition packet.hh:167
@ NUM_COMMAND_ATTRIBUTES
Definition packet.hh:180
Object used to maintain state of a PrintReq.
Definition packet.hh:480
void popLabel()
Pop a label off the label stack.
Definition packet.cc:444
void printObj(Printable *obj)
Print a Printable object to os, because it matched the address on a PrintReq.
Definition packet.cc:470
PrintReqState(std::ostream &os, int verbosity=0)
Definition packet.cc:414
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.
Definition packet.cc:435
std::list< LabelStackEntry > LabelStack
Definition packet.hh:493
std::string * curPrefixPtr
Definition packet.hh:496
const std::string & curPrefix()
Returns the current line prefix.
Definition packet.hh:508
void printLabels()
Print all of the pending unprinted labels on the stack.
Definition packet.cc:453
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
void setExpressSnoop()
The express snoop flag is used for two purposes.
Definition packet.hh:701
bool responderHadWritable() const
Definition packet.hh:719
bool isUpgrade() const
Definition packet.hh:596
void setBadAddress()
Definition packet.hh:786
bool isRead() const
Definition packet.hh:593
bool isSecure() const
Definition packet.hh:836
const PacketId id
Definition packet.hh:374
Addr addr
The address of the request.
Definition packet.hh:391
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.
Definition packet.hh:1346
Addr getAddr() const
Definition packet.hh:807
@ FAILS_TRANSACTION
Definition packet.hh:339
@ VALID_ADDR
Are the 'addr' and 'size' fields valid?
Definition packet.hh:346
@ SUPPRESS_FUNC_ERROR
suppress the error if this packet encounters a functional access failure.
Definition packet.hh:359
@ RESPONDER_FLAGS
Definition packet.hh:307
@ DYNAMIC_DATA
The data pointer points to a value that should be freed when the packet is destroyed.
Definition packet.hh:355
@ EXPRESS_SNOOP
Special timing-mode atomic snoop for multi-level coherence.
Definition packet.hh:315
@ CACHE_RESPONDING
Definition packet.hh:324
@ STATIC_DATA
Is the data pointer set to a value that shouldn't be freed when the packet is destroyed?
Definition packet.hh:351
@ FROM_TRANSACTION
Definition packet.hh:343
@ RESPONDER_HAD_WRITABLE
Allow a responding cache to inform the cache hierarchy that it had a writable copy before responding.
Definition packet.hh:320
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
Definition packet.hh:1470
bool isError() const
Definition packet.hh:622
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 ...
Definition packet.cc:361
bool isLockedRMW() const
Definition packet.hh:621
void deleteData()
delete the data pointed to in the data pointer.
Definition packet.hh:1356
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.
Definition packet.hh:402
Packet(const PacketPtr pkt, bool clear_flags, bool alloc_data)
Alternate constructor for copying a packet.
Definition packet.hh:944
void setWriteThrough()
A writeback/writeclean cmd gets propagated further downstream by the receiver when the flag is set.
Definition packet.hh:735
gem5::Flags< FlagsType > Flags
Definition packet.hh:298
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,...
Definition packet.hh:918
bool isAtomicOp() const
Definition packet.hh:846
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).
Definition packet.hh:588
bool isResponse() const
Definition packet.hh:598
Flags flags
Definition packet.hh:366
uint32_t snoopDelay
Keep track of the extra delay incurred by snooping upwards before sending a request down the memory s...
Definition packet.hh:439
void setHtmTransactionFailedInCache(const HtmCacheFailure ret_code)
Stipulates that this packet/request has returned from the cache hierarchy in a failed transaction.
Definition packet.cc:493
void makeTimingResponse()
Definition packet.hh:1080
bool needsWritable() const
Definition packet.hh:599
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.
Definition packet.cc:243
bool isGLCSet() const
Accessor functions for the cache bypass flags.
Definition packet.hh:1113
void copyError(Packet *pkt)
Definition packet.hh:805
bool satisfied() const
Definition packet.hh:755
bool isDemand() const
Definition packet.hh:595
void setAddr(Addr _addr)
Update the address of this packet mid-transaction.
Definition packet.hh:815
static PacketPtr createWrite(const RequestPtr &req)
Definition packet.hh:1044
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
Definition packet.hh:1435
bool needsResponse() const
Definition packet.hh:608
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Definition packet.hh:1175
SenderState * senderState
This packet's sender state.
Definition packet.hh:545
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition packet.hh:449
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
Definition packet.hh:1062
bool matchAddr(const Addr addr, const bool is_secure) const
Check if packet corresponds to a given address and address space.
Definition packet.cc:403
RequestorID requestorId() const
Definition packet.hh:780
static MemCmd makeWriteCmd(const RequestPtr &req)
Generate the appropriate write MemCmd based on the Request flags.
Definition packet.hh:1016
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Definition packet.hh:431
int cmdToIndex() const
Return the index of this command.
Definition packet.hh:591
MemCmd::Command Command
Definition packet.hh:369
uint8_t _qosValue
Definition packet.hh:405
T * findNextSenderState() const
Go through the sender state stack and return the first instance that is of type T (as determined by a...
Definition packet.hh:575
uint32_t FlagsType
Definition packet.hh:297
void setResponderHadWritable()
On responding to a snoop request (which only happens for Modified or Owned lines),...
Definition packet.hh:713
Addr getOffset(unsigned int blk_size) const
Definition packet.hh:826
~Packet()
clean up packet variables
Definition packet.hh:1052
void clearBlockCached()
Definition packet.hh:761
bool mustCheckAbove() const
Does the request need to check for cached copies of the same block in the memory hierarchy above.
Definition packet.hh:1425
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...
Definition packet.cc:334
void setRaw(T v)
Set the value in the data pointer to v without byte swapping.
bool hasData() const
Definition packet.hh:614
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
Definition packet.hh:769
void copyResponderFlags(const PacketPtr pkt)
Copy the reponse flags from an input packet to this packet.
Definition packet.cc:324
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
Definition packet.cc:342
bool hasRespData() const
Definition packet.hh:615
bool writeThrough() const
Definition packet.hh:742
HtmCacheFailure getHtmTransactionFailedInCacheRC() const
If a packet/request has returned from the cache hierarchy in a failed transaction,...
Definition packet.cc:509
bool isHtmTransactional() const
Returns whether or not this packet/request originates in the CPU executing in transactional mode,...
Definition packet.cc:523
std::string print() const
A no-args wrapper of print(std::ostream...) meant to be invoked from DPRINTFs avoiding string overhea...
Definition packet.cc:382
T * getPtr()
get a pointer to the data ptr.
Definition packet.hh:1225
bool fromCache() const
Definition packet.hh:612
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
Definition packet.hh:1293
void convertScToWrite()
It has been determined that the SC packet should successfully update memory.
Definition packet.hh:853
bool isWrite() const
Definition packet.hh:594
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.
Definition packet.hh:1312
bool trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
Definition packet.hh:1399
uint64_t getHtmTransactionUid() const
If a packet/request originates in a CPU executing in transactional mode, i.e.
Definition packet.cc:529
Addr getBlockAddr(unsigned int blk_size) const
Definition packet.hh:831
void setBadCommand()
Definition packet.hh:795
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
Definition packet.hh:1038
RequestPtr req
A pointer to the original request.
Definition packet.hh:377
bool isPrint() const
Definition packet.hh:623
unsigned getSize() const
Definition packet.hh:817
bool isCleanInvalidateRequest() const
Is this packet a clean invalidate request, e.g., clflush/clflushopt?
Definition packet.hh:1444
unsigned size
The size of the request or transfer.
Definition packet.hh:397
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
Definition packet.hh:845
void setCacheResponding()
Snoop flags.
Definition packet.hh:653
bool isClean() const
Definition packet.hh:611
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
Definition packet.cc:352
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
Definition packet.hh:1480
bool isExpressSnoop() const
Definition packet.hh:702
void setFunctionalResponseStatus(bool success)
Definition packet.hh:1086
bool isWriteback() const
Definition packet.hh:613
bool _isSecure
True if the request targets the secure memory space.
Definition packet.hh:394
void convertLlToRead()
When ruby is in use, Ruby will monitor the cache line and the phys memory should treat LL ops as norm...
Definition packet.hh:865
const T * getConstPtr() const
Definition packet.hh:1234
void dataStaticConst(const T *p)
Set the data pointer to the following value that should not be freed.
Definition packet.hh:1192
void setHasSharers()
On fills, the hasSharers flag is used by the caches in combination with the cacheResponding flag,...
Definition packet.hh:685
void clearWriteThrough()
Definition packet.hh:741
Packet(const RequestPtr &_req, MemCmd _cmd)
Constructor.
Definition packet.hh:877
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.
Definition packet.cc:389
HtmCacheFailure htmReturnReason
Holds the return status of the transaction.
Definition packet.hh:414
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
Definition packet.hh:1213
void setHtmTransactional(uint64_t val)
Stipulates that this packet/request originates in the CPU executing in transactional mode,...
Definition packet.cc:516
void makeHtmTransactionalReqResponse(const HtmCacheFailure ret_code)
Communicates to the core that a packet was processed by the memory subsystem while running in transac...
Definition packet.cc:477
void setSize(unsigned size)
Definition packet.hh:1098
static MemCmd makeReadCmd(const RequestPtr &req)
Generate the appropriate read MemCmd based on the Request flags.
Definition packet.hh:993
bool isLLSC() const
Definition packet.hh:620
bool cacheResponding() const
Definition packet.hh:659
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.
Definition packet.hh:777
void makeAtomicResponse()
Definition packet.hh:1074
void setSatisfied()
Set when a request hits in a cache and the cache is not going to respond.
Definition packet.hh:749
MemCmd cmd
The command field of the packet.
Definition packet.hh:372
bool suppressFuncError() const
Definition packet.hh:758
bool isMaskedWrite() const
Definition packet.hh:1450
T get(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness.
bool isInvalidate() const
Definition packet.hh:609
bool htmTransactionFailedInCache() const
Returns whether or not this packet/request has returned from the cache hierarchy in a failed transact...
Definition packet.cc:503
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
bool isFlush() const
Definition packet.hh:624
void setSuppressFuncError()
Definition packet.hh:757
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
Definition packet.hh:1322
bool isWholeLineWrite(unsigned blk_size)
Definition packet.hh:626
bool isSLCSet() const
Definition packet.hh:1114
uint64_t htmTransactionUid
A global unique identifier of the transaction.
Definition packet.hh:420
bool hasSharers() const
Definition packet.hh:686
bool isBlockCached() const
Definition packet.hh:760
void setBlockCached()
Definition packet.hh:759
PacketDataPtr data
A pointer to the data being transferred.
Definition packet.hh:387
void allocate()
Allocate memory for the packet.
Definition packet.hh:1367
bool isEviction() const
Definition packet.hh:610
bool isRequest() const
Definition packet.hh:597
Abstract base class for objects which support being printed to a stream for debugging.
Definition printable.hh:48
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
void set(Type mask)
Set all flag's bits matching the given mask.
Definition flags.hh:116
bool isSet(Type mask) const
Verifies whether any bit matching the given mask is set.
Definition flags.hh:83
void clear()
Clear all flag's bits.
Definition flags.hh:102
bool noneSet(Type mask) const
Verifies whether no bits matching the given mask are set.
Definition flags.hh:99
#define warn(...)
Definition logging.hh:256
Bitfield< 28 > v
Definition misc_types.hh:54
Bitfield< 5 > t
Definition misc_types.hh:71
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 12, 11 > set
Bitfield< 0 > p
Bitfield< 6 > c2
Bitfield< 0 > w
Bitfield< 51, 12 > base
Definition pagetable.hh:141
Bitfield< 63 > val
Definition misc.hh:804
ProbePointArg< PacketInfo > Packet
Packet probe point.
Definition mem.hh:108
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
T safe_cast(U &&ref_or_ptr)
Definition cast.hh:74
std::shared_ptr< Request > RequestPtr
Definition request.hh:94
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t PacketId
Definition packet.hh:74
uint8_t * PacketDataPtr
Definition packet.hh:72
uint16_t RequestorID
Definition request.hh:95
Packet * PacketPtr
std::list< PacketPtr > PacketList
Definition packet.hh:73
HtmCacheFailure
Definition htm.hh:60
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.
Definition packet.hh:197
const Command response
Corresponding response for requests; InvalidCmd if no response is applicable.
Definition packet.hh:202
const std::bitset< NUM_COMMAND_ATTRIBUTES > attributes
Set of attribute flags.
Definition packet.hh:199
const std::string str
String representation (for printing)
Definition packet.hh:204
CommandInfo(std::initializer_list< Attribute > attrs, Command _response, const std::string &_str)
Definition packet.hh:206
An entry in the label stack.
Definition packet.hh:486
LabelStackEntry(const std::string &_label, std::string *_prefix)
Definition packet.cc:428
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition packet.hh:469
SenderState * predecessor
Definition packet.hh:470

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0