gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
packet.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2019 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  * Authors: Ron Dreslinski
42  * Steve Reinhardt
43  * Ali Saidi
44  * Andreas Hansson
45  * Nikos Nikoleris
46  */
47 
53 #ifndef __MEM_PACKET_HH__
54 #define __MEM_PACKET_HH__
55 
56 #include <bitset>
57 #include <cassert>
58 #include <list>
59 
60 #include "base/addr_range.hh"
61 #include "base/cast.hh"
62 #include "base/compiler.hh"
63 #include "base/flags.hh"
64 #include "base/logging.hh"
65 #include "base/printable.hh"
66 #include "base/types.hh"
67 #include "mem/request.hh"
68 #include "sim/core.hh"
69 
70 class Packet;
71 typedef Packet *PacketPtr;
72 typedef uint8_t* PacketDataPtr;
74 typedef uint64_t PacketId;
75 
76 class MemCmd
77 {
78  friend class Packet;
79 
80  public:
84  enum Command
85  {
94  WriteClean, // writes dirty data below without evicting
103  SCUpgradeReq, // Special "weak" upgrade for StoreCond
105  SCUpgradeFailReq, // Failed SCUpgradeReq in MSHR (never sent)
106  UpgradeFailResp, // Valid for SCUpgradeReq only
113  StoreCondFailReq, // Failed StoreCondReq in MSHR (never sent)
117  // MessageReq and MessageResp are deprecated.
124  // Error responses
125  // @TODO these should be classified as responses rather than
126  // requests; coding them as requests initially for backwards
127  // compatibility
128  InvalidDestError, // packet dest field invalid
129  BadAddressError, // memory address invalid
130  FunctionalReadError, // unable to fulfill functional read
131  FunctionalWriteError, // unable to fulfill functional write
132  // Fake simulator-only commands
133  PrintReq, // Print state matching address
134  FlushReq, //request for a cache flush
135  InvalidateReq, // request for address to be invalidated
138  };
139 
140  private:
145  {
165  };
166 
171  struct CommandInfo
172  {
174  const std::bitset<NUM_COMMAND_ATTRIBUTES> attributes;
179  const std::string str;
180  };
181 
183  static const CommandInfo commandInfo[];
184 
185  private:
186 
188 
189  bool
191  {
192  return commandInfo[cmd].attributes[attrib] != 0;
193  }
194 
195  public:
196 
197  bool isRead() const { return testCmdAttrib(IsRead); }
198  bool isWrite() const { return testCmdAttrib(IsWrite); }
199  bool isUpgrade() const { return testCmdAttrib(IsUpgrade); }
200  bool isRequest() const { return testCmdAttrib(IsRequest); }
201  bool isResponse() const { return testCmdAttrib(IsResponse); }
202  bool needsWritable() const { return testCmdAttrib(NeedsWritable); }
203  bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
204  bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
205  bool isEviction() const { return testCmdAttrib(IsEviction); }
206  bool isClean() const { return testCmdAttrib(IsClean); }
207  bool fromCache() const { return testCmdAttrib(FromCache); }
208 
212  bool isWriteback() const { return testCmdAttrib(IsEviction) &&
214 
220  bool hasData() const { return testCmdAttrib(HasData); }
221  bool isLLSC() const { return testCmdAttrib(IsLlsc); }
222  bool isSWPrefetch() const { return testCmdAttrib(IsSWPrefetch); }
223  bool isHWPrefetch() const { return testCmdAttrib(IsHWPrefetch); }
224  bool isPrefetch() const { return testCmdAttrib(IsSWPrefetch) ||
226  bool isError() const { return testCmdAttrib(IsError); }
227  bool isPrint() const { return testCmdAttrib(IsPrint); }
228  bool isFlush() const { return testCmdAttrib(IsFlush); }
229 
230  Command
232  {
233  return commandInfo[cmd].response;
234  }
235 
237  const std::string &toString() const { return commandInfo[cmd].str; }
238  int toInt() const { return (int)cmd; }
239 
240  MemCmd(Command _cmd) : cmd(_cmd) { }
241  MemCmd(int _cmd) : cmd((Command)_cmd) { }
242  MemCmd() : cmd(InvalidCmd) { }
243 
244  bool operator==(MemCmd c2) const { return (cmd == c2.cmd); }
245  bool operator!=(MemCmd c2) const { return (cmd != c2.cmd); }
246 };
247 
255 class Packet : public Printable
256 {
257  public:
258  typedef uint32_t FlagsType;
259  typedef ::Flags<FlagsType> Flags;
260 
261  private:
262 
263  enum : FlagsType {
264  // Flags to transfer across when copying a packet
265  COPY_FLAGS = 0x0000003F,
266 
267  // Flags that are used to create reponse packets
268  RESPONDER_FLAGS = 0x00000009,
269 
270  // Does this packet have sharers (which means it should not be
271  // considered writable) or not. See setHasSharers below.
272  HAS_SHARERS = 0x00000001,
273 
274  // Special control flags
276  EXPRESS_SNOOP = 0x00000002,
277 
281  RESPONDER_HAD_WRITABLE = 0x00000004,
282 
283  // Snoop co-ordination flag to indicate that a cache is
284  // responding to a snoop. See setCacheResponding below.
285  CACHE_RESPONDING = 0x00000008,
286 
287  // The writeback/writeclean should be propagated further
288  // downstream by the receiver
289  WRITE_THROUGH = 0x00000010,
290 
291  // Response co-ordination flag for cache maintenance
292  // operations
293  SATISFIED = 0x00000020,
294 
296  VALID_ADDR = 0x00000100,
297  VALID_SIZE = 0x00000200,
298 
301  STATIC_DATA = 0x00001000,
305  DYNAMIC_DATA = 0x00002000,
306 
309  SUPPRESS_FUNC_ERROR = 0x00008000,
310 
311  // Signal block present to squash prefetch and cache evict packets
312  // through express snoop flag
313  BLOCK_CACHED = 0x00010000
314  };
315 
316  Flags flags;
317 
318  public:
320 
323 
324  const PacketId id;
325 
328 
329  private:
338 
342 
344  bool _isSecure;
345 
347  unsigned size;
348 
353 
354  // Quality of Service priority value
355  uint8_t _qosValue;
356 
357  public:
358 
366  uint32_t headerDelay;
367 
374  uint32_t snoopDelay;
375 
384  uint32_t payloadDelay;
385 
403  struct SenderState
404  {
406  SenderState() : predecessor(NULL) {}
407  virtual ~SenderState() {}
408  };
409 
414  class PrintReqState : public SenderState
415  {
416  private:
421  {
422  const std::string label;
423  std::string *prefix;
425  LabelStackEntry(const std::string &_label, std::string *_prefix);
426  };
427 
429  LabelStack labelStack;
430 
431  std::string *curPrefixPtr;
432 
433  public:
434  std::ostream &os;
435  const int verbosity;
436 
437  PrintReqState(std::ostream &os, int verbosity = 0);
438  ~PrintReqState();
439 
443  const std::string &curPrefix() { return *curPrefixPtr; }
444 
450  void pushLabel(const std::string &lbl,
451  const std::string &prefix = " ");
452 
456  void popLabel();
457 
463  void printLabels();
464 
469  void printObj(Printable *obj);
470  };
471 
481 
490  void pushSenderState(SenderState *sender_state);
491 
500  SenderState *popSenderState();
501 
509  template <typename T>
511  {
512  T *t = NULL;
513  SenderState* sender_state = senderState;
514  while (t == NULL && sender_state != NULL) {
515  t = dynamic_cast<T*>(sender_state);
516  sender_state = sender_state->predecessor;
517  }
518  return t;
519  }
520 
523  const std::string &cmdString() const { return cmd.toString(); }
524 
526  inline int cmdToIndex() const { return cmd.toInt(); }
527 
528  bool isRead() const { return cmd.isRead(); }
529  bool isWrite() const { return cmd.isWrite(); }
530  bool isUpgrade() const { return cmd.isUpgrade(); }
531  bool isRequest() const { return cmd.isRequest(); }
532  bool isResponse() const { return cmd.isResponse(); }
533  bool needsWritable() const
534  {
535  // we should never check if a response needsWritable, the
536  // request has this flag, and for a response we should rather
537  // look at the hasSharers flag (if not set, the response is to
538  // be considered writable)
539  assert(isRequest());
540  return cmd.needsWritable();
541  }
542  bool needsResponse() const { return cmd.needsResponse(); }
543  bool isInvalidate() const { return cmd.isInvalidate(); }
544  bool isEviction() const { return cmd.isEviction(); }
545  bool isClean() const { return cmd.isClean(); }
546  bool fromCache() const { return cmd.fromCache(); }
547  bool isWriteback() const { return cmd.isWriteback(); }
548  bool hasData() const { return cmd.hasData(); }
549  bool hasRespData() const
550  {
551  MemCmd resp_cmd = cmd.responseCommand();
552  return resp_cmd.hasData();
553  }
554  bool isLLSC() const { return cmd.isLLSC(); }
555  bool isError() const { return cmd.isError(); }
556  bool isPrint() const { return cmd.isPrint(); }
557  bool isFlush() const { return cmd.isFlush(); }
558 
559  bool isWholeLineWrite(unsigned blk_size)
560  {
561  return (cmd == MemCmd::WriteReq || cmd == MemCmd::WriteLineReq) &&
562  getOffset(blk_size) == 0 && getSize() == blk_size;
563  }
564 
566 
586  {
587  assert(isRequest());
588  assert(!flags.isSet(CACHE_RESPONDING));
589  flags.set(CACHE_RESPONDING);
590  }
591  bool cacheResponding() const { return flags.isSet(CACHE_RESPONDING); }
617  void setHasSharers() { flags.set(HAS_SHARERS); }
618  bool hasSharers() const { return flags.isSet(HAS_SHARERS); }
620 
633  void setExpressSnoop() { flags.set(EXPRESS_SNOOP); }
634  bool isExpressSnoop() const { return flags.isSet(EXPRESS_SNOOP); }
635 
646  {
647  assert(cacheResponding());
648  assert(!responderHadWritable());
649  flags.set(RESPONDER_HAD_WRITABLE);
650  }
651  bool responderHadWritable() const
652  { return flags.isSet(RESPONDER_HAD_WRITABLE); }
653 
661  void copyResponderFlags(const PacketPtr pkt);
662 
668  {
669  assert(cmd.isWrite() &&
670  (cmd.isEviction() || cmd == MemCmd::WriteClean));
671  flags.set(WRITE_THROUGH);
672  }
673  void clearWriteThrough() { flags.clear(WRITE_THROUGH); }
674  bool writeThrough() const { return flags.isSet(WRITE_THROUGH); }
675 
682  {
683  assert(cmd.isClean());
684  assert(!flags.isSet(SATISFIED));
685  flags.set(SATISFIED);
686  }
687  bool satisfied() const { return flags.isSet(SATISFIED); }
688 
689  void setSuppressFuncError() { flags.set(SUPPRESS_FUNC_ERROR); }
690  bool suppressFuncError() const { return flags.isSet(SUPPRESS_FUNC_ERROR); }
691  void setBlockCached() { flags.set(BLOCK_CACHED); }
692  bool isBlockCached() const { return flags.isSet(BLOCK_CACHED); }
693  void clearBlockCached() { flags.clear(BLOCK_CACHED); }
694 
701  inline uint8_t qosValue() const { return _qosValue; }
702 
709  inline void qosValue(const uint8_t qos_value)
710  { _qosValue = qos_value; }
711 
712  inline MasterID masterId() const { return req->masterId(); }
713 
714  // Network error conditions... encapsulate them as methods since
715  // their encoding keeps changing (from result field to command
716  // field, etc.)
717  void
719  {
720  assert(isResponse());
722  }
723 
724  void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; }
725 
726  Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; }
734  void setAddr(Addr _addr) { assert(flags.isSet(VALID_ADDR)); addr = _addr; }
735 
736  unsigned getSize() const { assert(flags.isSet(VALID_SIZE)); return size; }
737 
743  AddrRange getAddrRange() const;
744 
745  Addr getOffset(unsigned int blk_size) const
746  {
747  return getAddr() & Addr(blk_size - 1);
748  }
749 
750  Addr getBlockAddr(unsigned int blk_size) const
751  {
752  return getAddr() & ~(Addr(blk_size - 1));
753  }
754 
755  bool isSecure() const
756  {
757  assert(flags.isSet(VALID_ADDR));
758  return _isSecure;
759  }
760 
764  AtomicOpFunctor *getAtomicOp() const { return req->getAtomicOpFunctor(); }
765  bool isAtomicOp() const { return req->isAtomic(); }
766 
771  void
773  {
774  assert(isLLSC());
775  assert(isWrite());
776  cmd = MemCmd::WriteReq;
777  }
778 
783  void
785  {
786  assert(isLLSC());
787  assert(isRead());
788  cmd = MemCmd::ReadReq;
789  }
790 
796  Packet(const RequestPtr &_req, MemCmd _cmd)
797  : cmd(_cmd), id((PacketId)_req.get()), req(_req),
798  data(nullptr), addr(0), _isSecure(false), size(0),
799  _qosValue(0), headerDelay(0), snoopDelay(0),
800  payloadDelay(0), senderState(NULL)
801  {
802  if (req->hasPaddr()) {
803  addr = req->getPaddr();
804  flags.set(VALID_ADDR);
805  _isSecure = req->isSecure();
806  }
807  if (req->hasSize()) {
808  size = req->getSize();
809  flags.set(VALID_SIZE);
810  }
811  }
812 
818  Packet(const RequestPtr &_req, MemCmd _cmd, int _blkSize, PacketId _id = 0)
819  : cmd(_cmd), id(_id ? _id : (PacketId)_req.get()), req(_req),
820  data(nullptr), addr(0), _isSecure(false),
821  _qosValue(0), headerDelay(0),
822  snoopDelay(0), payloadDelay(0), senderState(NULL)
823  {
824  if (req->hasPaddr()) {
825  addr = req->getPaddr() & ~(_blkSize - 1);
826  flags.set(VALID_ADDR);
827  _isSecure = req->isSecure();
828  }
829  size = _blkSize;
830  flags.set(VALID_SIZE);
831  }
832 
840  Packet(const PacketPtr pkt, bool clear_flags, bool alloc_data)
841  : cmd(pkt->cmd), id(pkt->id), req(pkt->req),
842  data(nullptr),
843  addr(pkt->addr), _isSecure(pkt->_isSecure), size(pkt->size),
844  bytesValid(pkt->bytesValid),
845  _qosValue(pkt->qosValue()),
846  headerDelay(pkt->headerDelay),
847  snoopDelay(0),
848  payloadDelay(pkt->payloadDelay),
849  senderState(pkt->senderState)
850  {
851  if (!clear_flags)
852  flags.set(pkt->flags & COPY_FLAGS);
853 
854  flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE));
855 
856  // should we allocate space for data, or not, the express
857  // snoops do not need to carry any data as they only serve to
858  // co-ordinate state changes
859  if (alloc_data) {
860  // even if asked to allocate data, if the original packet
861  // holds static data, then the sender will not be doing
862  // any memcpy on receiving the response, thus we simply
863  // carry the pointer forward
864  if (pkt->flags.isSet(STATIC_DATA)) {
865  data = pkt->data;
866  flags.set(STATIC_DATA);
867  } else {
868  allocate();
869  }
870  }
871  }
872 
876  static MemCmd
878  {
879  if (req->isLLSC())
880  return MemCmd::LoadLockedReq;
881  else if (req->isPrefetchEx())
882  return MemCmd::SoftPFExReq;
883  else if (req->isPrefetch())
884  return MemCmd::SoftPFReq;
885  else
886  return MemCmd::ReadReq;
887  }
888 
892  static MemCmd
894  {
895  if (req->isLLSC())
896  return MemCmd::StoreCondReq;
897  else if (req->isSwap() || req->isAtomic())
898  return MemCmd::SwapReq;
899  else if (req->isCacheInvalidate()) {
900  return req->isCacheClean() ? MemCmd::CleanInvalidReq :
902  } else if (req->isCacheClean()) {
903  return MemCmd::CleanSharedReq;
904  } else
905  return MemCmd::WriteReq;
906  }
907 
912  static PacketPtr
913  createRead(const RequestPtr &req)
914  {
915  return new Packet(req, makeReadCmd(req));
916  }
917 
918  static PacketPtr
920  {
921  return new Packet(req, makeWriteCmd(req));
922  }
923 
928  {
929  deleteData();
930  }
931 
936  void
938  {
939  assert(needsResponse());
940  assert(isRequest());
941  cmd = cmd.responseCommand();
942 
943  // responses are never express, even if the snoop that
944  // triggered them was
945  flags.clear(EXPRESS_SNOOP);
946  }
947 
948  void
950  {
951  makeResponse();
952  }
953 
954  void
956  {
957  makeResponse();
958  }
959 
960  void
962  {
963  if (!success) {
964  if (isWrite()) {
966  } else {
968  }
969  }
970  }
971 
972  void
973  setSize(unsigned size)
974  {
975  assert(!flags.isSet(VALID_SIZE));
976 
977  this->size = size;
978  flags.set(VALID_SIZE);
979  }
980 
990  bool matchBlockAddr(const Addr addr, const bool is_secure,
991  const int blk_size) const;
992 
1001  bool matchBlockAddr(const PacketPtr pkt, const int blk_size) const;
1002 
1010  bool matchAddr(const Addr addr, const bool is_secure) const;
1011 
1019  bool matchAddr(const PacketPtr pkt) const;
1020 
1021  public:
1038  template <typename T>
1039  void
1041  {
1042  assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
1043  data = (PacketDataPtr)p;
1044  flags.set(STATIC_DATA);
1045  }
1046 
1055  template <typename T>
1056  void
1057  dataStaticConst(const T *p)
1058  {
1059  assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
1060  data = const_cast<PacketDataPtr>(p);
1061  flags.set(STATIC_DATA);
1062  }
1063 
1076  template <typename T>
1077  void
1079  {
1080  assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
1081  data = (PacketDataPtr)p;
1082  flags.set(DYNAMIC_DATA);
1083  }
1084 
1088  template <typename T>
1089  T*
1091  {
1092  assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
1093  assert(!isMaskedWrite());
1094  return (T*)data;
1095  }
1096 
1097  template <typename T>
1098  const T*
1099  getConstPtr() const
1100  {
1101  assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
1102  return (const T*)data;
1103  }
1104 
1109  template <typename T>
1110  T getBE() const;
1111 
1116  template <typename T>
1117  T getLE() const;
1118 
1123  template <typename T>
1124  T get(ByteOrder endian) const;
1125 
1127  template <typename T>
1128  void setBE(T v);
1129 
1131  template <typename T>
1132  void setLE(T v);
1133 
1138  template <typename T>
1139  void set(T v, ByteOrder endian);
1140 
1145  uint64_t getUintX(ByteOrder endian) const;
1146 
1152  void setUintX(uint64_t w, ByteOrder endian);
1153 
1157  void
1158  setData(const uint8_t *p)
1159  {
1160  // we should never be copying data onto itself, which means we
1161  // must idenfity packets with static data, as they carry the
1162  // same pointer from source to destination and back
1163  assert(p != getPtr<uint8_t>() || flags.isSet(STATIC_DATA));
1164 
1165  if (p != getPtr<uint8_t>()) {
1166  // for packet with allocated dynamic data, we copy data from
1167  // one to the other, e.g. a forwarded response to a response
1168  std::memcpy(getPtr<uint8_t>(), p, getSize());
1169  }
1170  }
1171 
1176  void
1177  setDataFromBlock(const uint8_t *blk_data, int blkSize)
1178  {
1179  setData(blk_data + getOffset(blkSize));
1180  }
1181 
1186  void
1187  writeData(uint8_t *p) const
1188  {
1189  if (!isMaskedWrite()) {
1190  std::memcpy(p, getConstPtr<uint8_t>(), getSize());
1191  } else {
1192  assert(req->getByteEnable().size() == getSize());
1193  // Write only the enabled bytes
1194  const uint8_t *base = getConstPtr<uint8_t>();
1195  for (int i = 0; i < getSize(); i++) {
1196  if (req->getByteEnable()[i]) {
1197  p[i] = *(base + i);
1198  }
1199  // Disabled bytes stay untouched
1200  }
1201  }
1202  }
1203 
1210  void
1211  writeDataToBlock(uint8_t *blk_data, int blkSize) const
1212  {
1213  writeData(blk_data + getOffset(blkSize));
1214  }
1215 
1220  void
1222  {
1223  if (flags.isSet(DYNAMIC_DATA))
1224  delete [] data;
1225 
1226  flags.clear(STATIC_DATA|DYNAMIC_DATA);
1227  data = NULL;
1228  }
1229 
1231  void
1233  {
1234  // if either this command or the response command has a data
1235  // payload, actually allocate space
1236  if (hasData() || hasRespData()) {
1237  assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
1238  flags.set(DYNAMIC_DATA);
1239  data = new uint8_t[getSize()];
1240  }
1241  }
1242 
1246  template <typename T>
1247  T getRaw() const;
1248 
1250  template <typename T>
1251  void setRaw(T v);
1252 
1253  public:
1263  bool
1265  {
1266  if (other->isMaskedWrite()) {
1267  // Do not forward data if overlapping with a masked write
1268  if (_isSecure == other->isSecure() &&
1269  getAddr() <= (other->getAddr() + other->getSize() - 1) &&
1270  other->getAddr() <= (getAddr() + getSize() - 1)) {
1271  warn("Trying to check against a masked write, skipping."
1272  " (addr: 0x%x, other addr: 0x%x)", getAddr(),
1273  other->getAddr());
1274  }
1275  return false;
1276  }
1277  // all packets that are carrying a payload should have a valid
1278  // data pointer
1279  return trySatisfyFunctional(other, other->getAddr(), other->isSecure(),
1280  other->getSize(),
1281  other->hasData() ?
1282  other->getPtr<uint8_t>() : NULL);
1283  }
1284 
1289  bool
1291  {
1292  return cmd == MemCmd::HardPFReq || isEviction();
1293  }
1294 
1299  bool
1301  {
1302  return cmd == MemCmd::CleanEvict || cmd == MemCmd::WritebackClean;
1303  }
1304 
1305  bool
1307  {
1308  return (cmd == MemCmd::WriteReq && req->isMasked());
1309  }
1310 
1318  bool
1319  trySatisfyFunctional(Printable *obj, Addr base, bool is_secure, int size,
1320  uint8_t *_data);
1321 
1325  void
1326  pushLabel(const std::string &lbl)
1327  {
1328  if (isPrint())
1329  safe_cast<PrintReqState*>(senderState)->pushLabel(lbl);
1330  }
1331 
1335  void
1337  {
1338  if (isPrint())
1339  safe_cast<PrintReqState*>(senderState)->popLabel();
1340  }
1341 
1342  void print(std::ostream &o, int verbosity = 0,
1343  const std::string &prefix = "") const;
1344 
1351  std::string print() const;
1352 };
1353 
1354 #endif //__MEM_PACKET_HH
Alpha/MIPS LL or SC access.
Definition: packet.hh:158
MemCmd(int _cmd)
Definition: packet.hh:241
Requires writable copy to complete in-cache.
Definition: packet.hh:151
bool isPrint() const
Definition: packet.hh:227
std::vector< bool > bytesValid
Track the bytes found that satisfy a functional read.
Definition: packet.hh:352
const PacketId id
Definition: packet.hh:324
void setResponderHadWritable()
On responding to a snoop request (which only happens for Modified or Owned lines), make sure that we can transform an Owned response to a Modified one.
Definition: packet.hh:645
bool isExpressSnoop() const
Definition: packet.hh:634
void setSize(unsigned size)
Definition: packet.hh:973
bool suppressFuncError() const
Definition: packet.hh:690
void setHasSharers()
On fills, the hasSharers flag is used by the caches in combination with the cacheResponding flag...
Definition: packet.hh:617
bool mustCheckAbove() const
Does the request need to check for cached copies of the same block in the memory hierarchy above...
Definition: packet.hh:1290
Data flows from requester to responder.
Definition: packet.hh:147
Bitfield< 28 > v
MemCmd::Command Command
Definition: packet.hh:319
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:510
Definition: packet.hh:76
There is an associated payload.
Definition: packet.hh:159
AtomicOpFunctor * getAtomicOp() const
Accessor function to atomic op.
Definition: packet.hh:764
bool testCmdAttrib(MemCmd::Attribute attrib) const
Definition: packet.hh:190
void setSuppressFuncError()
Definition: packet.hh:689
Bitfield< 7 > i
void qosValue(const uint8_t qos_value)
QoS Value setter Interface for setting QoS priority value of the packet.
Definition: packet.hh:709
Object used to maintain state of a PrintReq.
Definition: packet.hh:414
uint32_t snoopDelay
Keep track of the extra delay incurred by snooping upwards before sending a request down the memory s...
Definition: packet.hh:374
void makeTimingResponse()
Definition: packet.hh:955
bool isUpgrade() const
Definition: packet.hh:530
Flush the address from caches.
Definition: packet.hh:162
bool isCleanEviction() const
Is this packet a clean eviction, including both actual clean evict packets, but also clean writebacks...
Definition: packet.hh:1300
const std::string & toString() const
Return the string to a cmd given by idx.
Definition: packet.hh:237
Declaration of a request, the overall memory request consisting of the parts of the request that are ...
std::shared_ptr< Request > RequestPtr
Definition: request.hh:83
::Flags< FlagsType > Flags
Definition: packet.hh:259
bool isSet() const
Definition: flags.hh:62
uint8_t * PacketDataPtr
Definition: packet.hh:72
LabelStack labelStack
Definition: packet.hh:429
Bitfield< 6 > c2
bool isSWPrefetch() const
Definition: packet.hh:222
void clear()
Definition: flags.hh:68
ip6_addr_t addr
Definition: inet.hh:335
static PacketPtr createWrite(const RequestPtr &req)
Definition: packet.hh:919
bool isClean() const
Definition: packet.hh:545
bool isFlush() const
Definition: packet.hh:228
bool cacheResponding() const
Definition: packet.hh:591
Requester needs response from target.
Definition: packet.hh:154
const int verbosity
Definition: packet.hh:435
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:818
uint32_t FlagsType
Definition: packet.hh:258
Cleans any existing dirty blocks.
Definition: packet.hh:150
static const CommandInfo commandInfo[]
Array to map Command enum to associated info.
Definition: packet.hh:183
const std::string & curPrefix()
Returns the current line prefix.
Definition: packet.hh:443
static MemCmd makeReadCmd(const RequestPtr &req)
Generate the appropriate read MemCmd based on the Request flags.
Definition: packet.hh:877
void pushLabel(const std::string &lbl)
Push label for PrintReq (safe to call unconditionally).
Definition: packet.hh:1326
bool isWrite() const
Definition: packet.hh:529
bool isInvalidate() const
Definition: packet.hh:543
T * getPtr()
get a pointer to the data ptr.
Definition: packet.hh:1090
void setSatisfied()
Set when a request hits in a cache and the cache is not going to respond.
Definition: packet.hh:681
bool isRead() const
Definition: packet.hh:528
void dataStatic(T *p)
Set the data pointer to the following value that should not be freed.
Definition: packet.hh:1040
bool isRequest() const
Definition: packet.hh:200
bool isAtomicOp() const
Definition: packet.hh:765
bool isError() const
Definition: packet.hh:226
bool needsWritable() const
Definition: packet.hh:533
Addr getBlockAddr(unsigned int blk_size) const
Definition: packet.hh:750
Flags flags
Definition: packet.hh:316
RequestPtr req
A pointer to the original request.
Definition: packet.hh:327
MemCmd()
Definition: packet.hh:242
std::ostream & os
Definition: packet.hh:434
bool isBlockCached() const
Definition: packet.hh:692
void setFunctionalResponseStatus(bool success)
Definition: packet.hh:961
unsigned getSize() const
Definition: packet.hh:736
Structure that defines attributes and other data associated with a Command.
Definition: packet.hh:171
PacketDataPtr data
A pointer to the data being transferred.
Definition: packet.hh:337
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:72
An entry in the label stack.
Definition: packet.hh:420
unsigned size
The size of the request or transfer.
Definition: packet.hh:347
bool isWriteback() const
A writeback is an eviction that carries data.
Definition: packet.hh:212
bool isRequest() const
Definition: packet.hh:531
void convertScToWrite()
It has been determined that the SC packet should successfully update memory.
Definition: packet.hh:772
bool isUpgrade() const
Definition: packet.hh:199
bool needsResponse() const
Definition: packet.hh:542
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Definition: packet.hh:366
bool isError() const
Definition: packet.hh:555
Addr getOffset(unsigned int blk_size) const
Definition: packet.hh:745
SenderState * predecessor
Definition: packet.hh:405
Attribute
List of command attributes.
Definition: packet.hh:144
void setData(const uint8_t *p)
Copy data into the packet from the provided pointer.
Definition: packet.hh:1158
Packet * PacketPtr
Definition: packet.hh:70
void makeAtomicResponse()
Definition: packet.hh:949
Issued by requester.
Definition: packet.hh:152
uint8_t qosValue() const
QoS Value getter Returns 0 if QoS value was never set (constructor default).
Definition: packet.hh:701
void deleteData()
delete the data pointed to in the data pointer.
Definition: packet.hh:1221
bool isResponse() const
Definition: packet.hh:532
bool trySatisfyFunctional(PacketPtr other)
Check a functional request against a memory value stored in another packet (i.e.
Definition: packet.hh:1264
void popLabel()
Pop label for PrintReq (safe to call unconditionally).
Definition: packet.hh:1336
bool isClean() const
Definition: packet.hh:206
ByteOrder
Definition: types.hh:247
Bitfield< 51, 12 > base
Definition: pagetable.hh:142
bool needsWritable() const
Definition: packet.hh:202
MemCmd(Command _cmd)
Definition: packet.hh:240
bool writeThrough() const
Definition: packet.hh:674
Addr getAddr() const
Definition: packet.hh:726
bool isHWPrefetch() const
Definition: packet.hh:223
void dataStaticConst(const T *p)
Set the data pointer to the following value that should not be freed.
Definition: packet.hh:1057
bool hasData() const
Definition: packet.hh:548
void writeData(uint8_t *p) const
Copy data from the packet to the memory at the provided pointer.
Definition: packet.hh:1187
MasterID masterId() const
Definition: packet.hh:712
Error response.
Definition: packet.hh:160
Addr getOffset(Addr addr)
Definition: Address.cc:48
STL list class.
Definition: stl.hh:54
bool isLLSC() const
Definition: packet.hh:221
bool isEviction() const
Definition: packet.hh:205
Bitfield< 0 > w
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
bool _isSecure
True if the request targets the secure memory space.
Definition: packet.hh:344
Addr addr
The address of the request.
Definition: packet.hh:341
friend class Packet
Packet probe point.
Definition: packet.hh:78
uint16_t MasterID
Definition: request.hh:86
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:784
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition: packet.hh:384
static PacketPtr createRead(const RequestPtr &req)
Constructor-like methods that return Packets based on Request objects.
Definition: packet.hh:913
T safe_cast(U ptr)
Definition: cast.hh:61
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
const std::bitset< NUM_COMMAND_ATTRIBUTES > attributes
Set of attribute flags.
Definition: packet.hh:174
Print state matching address (for debugging)
Definition: packet.hh:161
std::string * curPrefixPtr
Definition: packet.hh:431
Abstract base class for objects which support being printed to a stream for debugging.
Definition: printable.hh:44
bool isRead() const
Definition: packet.hh:197
void setBadAddress()
Definition: packet.hh:718
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:1177
bool responderHadWritable() const
Definition: packet.hh:651
A virtual base opaque structure used to hold state associated with the packet (e.g., an MSHR), specific to a SimObject that sees the packet.
Definition: packet.hh:403
static MemCmd makeWriteCmd(const RequestPtr &req)
Generate the appropriate write MemCmd based on the Request flags.
Definition: packet.hh:893
Command responseCommand() const
Definition: packet.hh:231
int cmdToIndex() const
Return the index of this command.
Definition: packet.hh:526
bool hasSharers() const
Definition: packet.hh:618
bool satisfied() const
Definition: packet.hh:687
bool isMaskedWrite() const
Definition: packet.hh:1306
bool isLLSC() const
Definition: packet.hh:554
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:937
void setAddr(Addr _addr)
Update the address of this packet mid-transaction.
Definition: packet.hh:734
bool fromCache() const
Definition: packet.hh:546
Packet(const RequestPtr &_req, MemCmd _cmd)
Constructor.
Definition: packet.hh:796
Issue by responder.
Definition: packet.hh:153
~Packet()
clean up packet variables
Definition: packet.hh:927
Data flows from responder to requester.
Definition: packet.hh:146
bool needsResponse() const
Definition: packet.hh:203
bool isWrite() const
Definition: packet.hh:198
bool hasRespData() const
Definition: packet.hh:549
const Command response
Corresponding response for requests; InvalidCmd if no response is applicable.
Definition: packet.hh:177
bool hasData() const
Check if this particular packet type carries payload data.
Definition: packet.hh:220
bool fromCache() const
Definition: packet.hh:207
SenderState * senderState
This packet&#39;s sender state.
Definition: packet.hh:480
MemCmd cmd
The command field of the packet.
Definition: packet.hh:322
bool isEviction() const
Definition: packet.hh:544
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:1211
std::list< PacketPtr > PacketList
Definition: packet.hh:73
int toInt() const
Definition: packet.hh:238
bool operator==(MemCmd c2) const
Definition: packet.hh:244
bool isPrint() const
Definition: packet.hh:556
bool isResponse() const
Definition: packet.hh:201
const T * getConstPtr() const
Definition: packet.hh:1099
void dataDynamic(T *p)
Set the data pointer to a value that should have delete [] called on it.
Definition: packet.hh:1078
void setBlockCached()
Definition: packet.hh:691
Request originated from a caching agent.
Definition: packet.hh:163
virtual ~SenderState()
Definition: packet.hh:407
bool isSecure() const
Definition: packet.hh:755
void copyError(Packet *pkt)
Definition: packet.hh:724
#define warn(...)
Definition: logging.hh:212
void setExpressSnoop()
The express snoop flag is used for two purposes.
Definition: packet.hh:633
Bitfield< 5 > t
Command
List of all commands associated with a packet.
Definition: packet.hh:84
bool isPrefetch() const
Definition: packet.hh:224
bool isWholeLineWrite(unsigned blk_size)
Definition: packet.hh:559
const std::string & cmdString() const
Return the string name of the cmd field (for debugging and tracing).
Definition: packet.hh:523
Packet(const PacketPtr pkt, bool clear_flags, bool alloc_data)
Alternate constructor for copying a packet.
Definition: packet.hh:840
const std::string str
String representation (for printing)
Definition: packet.hh:179
Bitfield< 0 > p
uint8_t _qosValue
Definition: packet.hh:355
const char data[]
bool isFlush() const
Definition: packet.hh:557
uint64_t PacketId
Definition: packet.hh:74
bool isInvalidate() const
Definition: packet.hh:204
void set(Type flags)
Definition: flags.hh:70
std::list< LabelStackEntry > LabelStack
Definition: packet.hh:428
Command cmd
Definition: packet.hh:187
bool isWriteback() const
Definition: packet.hh:547
bool operator!=(MemCmd c2) const
Definition: packet.hh:245
void allocate()
Allocate memory for the packet.
Definition: packet.hh:1232
void clearBlockCached()
Definition: packet.hh:693
bool noneSet() const
Definition: flags.hh:66
void clearWriteThrough()
Definition: packet.hh:673
void setCacheResponding()
Snoop flags.
Definition: packet.hh:585
void setWriteThrough()
A writeback/writeclean cmd gets propagated further downstream by the receiver when the flag is set...
Definition: packet.hh:667

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13