request: add accessor and constructor for setting time other than curTick
[gem5.git] / src / mem / packet.hh
1 /*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Ron Dreslinski
29 * Steve Reinhardt
30 * Ali Saidi
31 */
32
33 /**
34 * @file
35 * Declaration of the Packet class.
36 */
37
38 #ifndef __MEM_PACKET_HH__
39 #define __MEM_PACKET_HH__
40
41 #include <cassert>
42 #include <list>
43 #include <bitset>
44
45 #include "base/cast.hh"
46 #include "base/compiler.hh"
47 #include "base/fast_alloc.hh"
48 #include "base/flags.hh"
49 #include "base/misc.hh"
50 #include "base/printable.hh"
51 #include "base/types.hh"
52 #include "mem/request.hh"
53 #include "sim/core.hh"
54
55 struct Packet;
56 typedef Packet *PacketPtr;
57 typedef uint8_t* PacketDataPtr;
58 typedef std::list<PacketPtr> PacketList;
59
60 class MemCmd
61 {
62 friend class Packet;
63
64 public:
65 /**
66 * List of all commands associated with a packet.
67 */
68 enum Command
69 {
70 InvalidCmd,
71 ReadReq,
72 ReadResp,
73 ReadRespWithInvalidate,
74 WriteReq,
75 WriteResp,
76 Writeback,
77 SoftPFReq,
78 HardPFReq,
79 SoftPFResp,
80 HardPFResp,
81 WriteInvalidateReq,
82 WriteInvalidateResp,
83 UpgradeReq,
84 UpgradeResp,
85 ReadExReq,
86 ReadExResp,
87 LoadLockedReq,
88 StoreCondReq,
89 StoreCondResp,
90 SwapReq,
91 SwapResp,
92 MessageReq,
93 MessageResp,
94 // Error responses
95 // @TODO these should be classified as responses rather than
96 // requests; coding them as requests initially for backwards
97 // compatibility
98 NetworkNackError, // nacked at network layer (not by protocol)
99 InvalidDestError, // packet dest field invalid
100 BadAddressError, // memory address invalid
101 // Fake simulator-only commands
102 PrintReq, // Print state matching address
103 NUM_MEM_CMDS
104 };
105
106 private:
107 /**
108 * List of command attributes.
109 */
110 enum Attribute
111 {
112 IsRead, //!< Data flows from responder to requester
113 IsWrite, //!< Data flows from requester to responder
114 IsPrefetch, //!< Not a demand access
115 IsInvalidate,
116 NeedsExclusive, //!< Requires exclusive copy to complete in-cache
117 IsRequest, //!< Issued by requester
118 IsResponse, //!< Issue by responder
119 NeedsResponse, //!< Requester needs response from target
120 IsSWPrefetch,
121 IsHWPrefetch,
122 IsLlsc, //!< Alpha/MIPS LL or SC access
123 HasData, //!< There is an associated payload
124 IsError, //!< Error response
125 IsPrint, //!< Print state matching address (for debugging)
126 NUM_COMMAND_ATTRIBUTES
127 };
128
129 /**
130 * Structure that defines attributes and other data associated
131 * with a Command.
132 */
133 struct CommandInfo
134 {
135 /// Set of attribute flags.
136 const std::bitset<NUM_COMMAND_ATTRIBUTES> attributes;
137 /// Corresponding response for requests; InvalidCmd if no
138 /// response is applicable.
139 const Command response;
140 /// String representation (for printing)
141 const std::string str;
142 };
143
144 /// Array to map Command enum to associated info.
145 static const CommandInfo commandInfo[];
146
147 private:
148
149 Command cmd;
150
151 bool
152 testCmdAttrib(MemCmd::Attribute attrib) const
153 {
154 return commandInfo[cmd].attributes[attrib] != 0;
155 }
156
157 public:
158
159 bool isRead() const { return testCmdAttrib(IsRead); }
160 bool isWrite() const { return testCmdAttrib(IsWrite); }
161 bool isRequest() const { return testCmdAttrib(IsRequest); }
162 bool isResponse() const { return testCmdAttrib(IsResponse); }
163 bool needsExclusive() const { return testCmdAttrib(NeedsExclusive); }
164 bool needsResponse() const { return testCmdAttrib(NeedsResponse); }
165 bool isInvalidate() const { return testCmdAttrib(IsInvalidate); }
166 bool hasData() const { return testCmdAttrib(HasData); }
167 bool isReadWrite() const { return isRead() && isWrite(); }
168 bool isLLSC() const { return testCmdAttrib(IsLlsc); }
169 bool isError() const { return testCmdAttrib(IsError); }
170 bool isPrint() const { return testCmdAttrib(IsPrint); }
171
172 const Command
173 responseCommand() const
174 {
175 return commandInfo[cmd].response;
176 }
177
178 /// Return the string to a cmd given by idx.
179 const std::string &toString() const { return commandInfo[cmd].str; }
180 int toInt() const { return (int)cmd; }
181
182 MemCmd(Command _cmd) : cmd(_cmd) { }
183 MemCmd(int _cmd) : cmd((Command)_cmd) { }
184 MemCmd() : cmd(InvalidCmd) { }
185
186 bool operator==(MemCmd c2) const { return (cmd == c2.cmd); }
187 bool operator!=(MemCmd c2) const { return (cmd != c2.cmd); }
188 };
189
190 /**
191 * A Packet is used to encapsulate a transfer between two objects in
192 * the memory system (e.g., the L1 and L2 cache). (In contrast, a
193 * single Request travels all the way from the requester to the
194 * ultimate destination and back, possibly being conveyed by several
195 * different Packets along the way.)
196 */
197 class Packet : public FastAlloc, public Printable
198 {
199 public:
200 typedef uint32_t FlagsType;
201 typedef ::Flags<FlagsType> Flags;
202 typedef short NodeID;
203
204 private:
205 static const FlagsType PUBLIC_FLAGS = 0x00000000;
206 static const FlagsType PRIVATE_FLAGS = 0x00007F0F;
207 static const FlagsType COPY_FLAGS = 0x0000000F;
208
209 static const FlagsType SHARED = 0x00000001;
210 // Special control flags
211 /// Special timing-mode atomic snoop for multi-level coherence.
212 static const FlagsType EXPRESS_SNOOP = 0x00000002;
213 /// Does supplier have exclusive copy?
214 /// Useful for multi-level coherence.
215 static const FlagsType SUPPLY_EXCLUSIVE = 0x00000004;
216 // Snoop response flags
217 static const FlagsType MEM_INHIBIT = 0x00000008;
218 /// Are the 'addr' and 'size' fields valid?
219 static const FlagsType VALID_ADDR = 0x00000100;
220 static const FlagsType VALID_SIZE = 0x00000200;
221 /// Is the 'src' field valid?
222 static const FlagsType VALID_SRC = 0x00000400;
223 static const FlagsType VALID_DST = 0x00000800;
224 /// Is the data pointer set to a value that shouldn't be freed
225 /// when the packet is destroyed?
226 static const FlagsType STATIC_DATA = 0x00001000;
227 /// The data pointer points to a value that should be freed when
228 /// the packet is destroyed.
229 static const FlagsType DYNAMIC_DATA = 0x00002000;
230 /// the data pointer points to an array (thus delete []) needs to
231 /// be called on it rather than simply delete.
232 static const FlagsType ARRAY_DATA = 0x00004000;
233
234 Flags flags;
235
236 public:
237 typedef MemCmd::Command Command;
238
239 /// The command field of the packet.
240 MemCmd cmd;
241
242 /// A pointer to the original request.
243 RequestPtr req;
244
245 private:
246 /**
247 * A pointer to the data being transfered. It can be differnt
248 * sizes at each level of the heirarchy so it belongs in the
249 * packet, not request. This may or may not be populated when a
250 * responder recieves the packet. If not populated it memory should
251 * be allocated.
252 */
253 PacketDataPtr data;
254
255 /// The address of the request. This address could be virtual or
256 /// physical, depending on the system configuration.
257 Addr addr;
258
259 /// The size of the request or transfer.
260 int size;
261
262 /**
263 * Device address (e.g., bus ID) of the source of the
264 * transaction. The source is not responsible for setting this
265 * field; it is set implicitly by the interconnect when the packet
266 * is first sent.
267 */
268 NodeID src;
269
270 /**
271 * Device address (e.g., bus ID) of the destination of the
272 * transaction. The special value Broadcast indicates that the
273 * packet should be routed based on its address. This field is
274 * initialized in the constructor and is thus always valid (unlike
275 * addr, size, and src).
276 */
277 NodeID dest;
278
279 /**
280 * The original value of the command field. Only valid when the
281 * current command field is an error condition; in that case, the
282 * previous contents of the command field are copied here. This
283 * field is *not* set on non-error responses.
284 */
285 MemCmd origCmd;
286
287 public:
288 /// Used to calculate latencies for each packet.
289 Tick time;
290
291 /// The time at which the packet will be fully transmitted
292 Tick finishTime;
293
294 /// The time at which the first chunk of the packet will be transmitted
295 Tick firstWordTime;
296
297 /// The special destination address indicating that the packet
298 /// should be routed based on its address.
299 static const NodeID Broadcast = -1;
300
301 /**
302 * A virtual base opaque structure used to hold state associated
303 * with the packet but specific to the sending device (e.g., an
304 * MSHR). A pointer to this state is returned in the packet's
305 * response so that the sender can quickly look up the state
306 * needed to process it. A specific subclass would be derived
307 * from this to carry state specific to a particular sending
308 * device.
309 */
310 struct SenderState
311 {
312 virtual ~SenderState() {}
313 };
314
315 /**
316 * Object used to maintain state of a PrintReq. The senderState
317 * field of a PrintReq should always be of this type.
318 */
319 class PrintReqState : public SenderState, public FastAlloc
320 {
321 private:
322 /**
323 * An entry in the label stack.
324 */
325 struct LabelStackEntry
326 {
327 const std::string label;
328 std::string *prefix;
329 bool labelPrinted;
330 LabelStackEntry(const std::string &_label, std::string *_prefix);
331 };
332
333 typedef std::list<LabelStackEntry> LabelStack;
334 LabelStack labelStack;
335
336 std::string *curPrefixPtr;
337
338 public:
339 std::ostream &os;
340 const int verbosity;
341
342 PrintReqState(std::ostream &os, int verbosity = 0);
343 ~PrintReqState();
344
345 /**
346 * Returns the current line prefix.
347 */
348 const std::string &curPrefix() { return *curPrefixPtr; }
349
350 /**
351 * Push a label onto the label stack, and prepend the given
352 * prefix string onto the current prefix. Labels will only be
353 * printed if an object within the label's scope is printed.
354 */
355 void pushLabel(const std::string &lbl,
356 const std::string &prefix = " ");
357
358 /**
359 * Pop a label off the label stack.
360 */
361 void popLabel();
362
363 /**
364 * Print all of the pending unprinted labels on the
365 * stack. Called by printObj(), so normally not called by
366 * users unless bypassing printObj().
367 */
368 void printLabels();
369
370 /**
371 * Print a Printable object to os, because it matched the
372 * address on a PrintReq.
373 */
374 void printObj(Printable *obj);
375 };
376
377 /**
378 * This packet's sender state. Devices should use dynamic_cast<>
379 * to cast to the state appropriate to the sender. The intent of
380 * this variable is to allow a device to attach extra information
381 * to a request. A response packet must return the sender state
382 * that was attached to the original request (even if a new packet
383 * is created).
384 */
385 SenderState *senderState;
386
387 /// Return the string name of the cmd field (for debugging and
388 /// tracing).
389 const std::string &cmdString() const { return cmd.toString(); }
390
391 /// Return the index of this command.
392 inline int cmdToIndex() const { return cmd.toInt(); }
393
394 bool isRead() const { return cmd.isRead(); }
395 bool isWrite() const { return cmd.isWrite(); }
396 bool isRequest() const { return cmd.isRequest(); }
397 bool isResponse() const { return cmd.isResponse(); }
398 bool needsExclusive() const { return cmd.needsExclusive(); }
399 bool needsResponse() const { return cmd.needsResponse(); }
400 bool isInvalidate() const { return cmd.isInvalidate(); }
401 bool hasData() const { return cmd.hasData(); }
402 bool isReadWrite() const { return cmd.isReadWrite(); }
403 bool isLLSC() const { return cmd.isLLSC(); }
404 bool isError() const { return cmd.isError(); }
405 bool isPrint() const { return cmd.isPrint(); }
406
407 // Snoop flags
408 void assertMemInhibit() { flags.set(MEM_INHIBIT); }
409 bool memInhibitAsserted() { return flags.isSet(MEM_INHIBIT); }
410 void assertShared() { flags.set(SHARED); }
411 bool sharedAsserted() { return flags.isSet(SHARED); }
412
413 // Special control flags
414 void setExpressSnoop() { flags.set(EXPRESS_SNOOP); }
415 bool isExpressSnoop() { return flags.isSet(EXPRESS_SNOOP); }
416 void setSupplyExclusive() { flags.set(SUPPLY_EXCLUSIVE); }
417 bool isSupplyExclusive() { return flags.isSet(SUPPLY_EXCLUSIVE); }
418
419 // Network error conditions... encapsulate them as methods since
420 // their encoding keeps changing (from result field to command
421 // field, etc.)
422 void
423 setNacked()
424 {
425 assert(isResponse());
426 cmd = MemCmd::NetworkNackError;
427 }
428
429 void
430 setBadAddress()
431 {
432 assert(isResponse());
433 cmd = MemCmd::BadAddressError;
434 }
435
436 bool wasNacked() const { return cmd == MemCmd::NetworkNackError; }
437 bool hadBadAddress() const { return cmd == MemCmd::BadAddressError; }
438 void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; }
439
440 /// Accessor function to get the source index of the packet.
441 NodeID getSrc() const { assert(flags.isSet(VALID_SRC)); return src; }
442 /// Accessor function to set the source index of the packet.
443 void setSrc(NodeID _src) { src = _src; flags.set(VALID_SRC); }
444 /// Reset source field, e.g. to retransmit packet on different bus.
445 void clearSrc() { flags.clear(VALID_SRC); }
446
447 /// Accessor function for the destination index of the packet.
448 NodeID getDest() const { assert(flags.isSet(VALID_DST)); return dest; }
449 /// Accessor function to set the destination index of the packet.
450 void setDest(NodeID _dest) { dest = _dest; flags.set(VALID_DST); }
451
452 Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; }
453 int getSize() const { assert(flags.isSet(VALID_SIZE)); return size; }
454 Addr getOffset(int blkSize) const { return getAddr() & (Addr)(blkSize - 1); }
455
456 /**
457 * Constructor. Note that a Request object must be constructed
458 * first, but the Requests's physical address and size fields need
459 * not be valid. The command and destination addresses must be
460 * supplied.
461 */
462 Packet(Request *_req, MemCmd _cmd, NodeID _dest)
463 : flags(VALID_DST), cmd(_cmd), req(_req), data(NULL),
464 dest(_dest), time(curTick), senderState(NULL)
465 {
466 if (req->hasPaddr()) {
467 addr = req->getPaddr();
468 flags.set(VALID_ADDR);
469 }
470 if (req->hasSize()) {
471 size = req->getSize();
472 flags.set(VALID_SIZE);
473 }
474 }
475
476 /**
477 * Alternate constructor if you are trying to create a packet with
478 * a request that is for a whole block, not the address from the
479 * req. this allows for overriding the size/addr of the req.
480 */
481 Packet(Request *_req, MemCmd _cmd, NodeID _dest, int _blkSize)
482 : flags(VALID_DST), cmd(_cmd), req(_req), data(NULL),
483 dest(_dest), time(curTick), senderState(NULL)
484 {
485 if (req->hasPaddr()) {
486 addr = req->getPaddr() & ~(_blkSize - 1);
487 flags.set(VALID_ADDR);
488 }
489 size = _blkSize;
490 flags.set(VALID_SIZE);
491 }
492
493 /**
494 * Alternate constructor for copying a packet. Copy all fields
495 * *except* if the original packet's data was dynamic, don't copy
496 * that, as we can't guarantee that the new packet's lifetime is
497 * less than that of the original packet. In this case the new
498 * packet should allocate its own data.
499 */
500 Packet(Packet *pkt, bool clearFlags = false)
501 : cmd(pkt->cmd), req(pkt->req),
502 data(pkt->flags.isSet(STATIC_DATA) ? pkt->data : NULL),
503 addr(pkt->addr), size(pkt->size), src(pkt->src), dest(pkt->dest),
504 time(curTick), senderState(pkt->senderState)
505 {
506 if (!clearFlags)
507 flags.set(pkt->flags & COPY_FLAGS);
508
509 flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE|VALID_SRC|VALID_DST));
510 flags.set(pkt->flags & STATIC_DATA);
511 }
512
513 /**
514 * clean up packet variables
515 */
516 ~Packet()
517 {
518 // If this is a request packet for which there's no response,
519 // delete the request object here, since the requester will
520 // never get the chance.
521 if (req && isRequest() && !needsResponse())
522 delete req;
523 deleteData();
524 }
525
526 /**
527 * Reinitialize packet address and size from the associated
528 * Request object, and reset other fields that may have been
529 * modified by a previous transaction. Typically called when a
530 * statically allocated Request/Packet pair is reused for multiple
531 * transactions.
532 */
533 void
534 reinitFromRequest()
535 {
536 assert(req->hasPaddr());
537 flags = 0;
538 addr = req->getPaddr();
539 size = req->getSize();
540 time = req->time();
541
542 flags.set(VALID_ADDR|VALID_SIZE);
543 deleteData();
544 }
545
546 /**
547 * Take a request packet and modify it in place to be suitable for
548 * returning as a response to that request. The source and
549 * destination fields are *not* modified, as is appropriate for
550 * atomic accesses.
551 */
552 void
553 makeResponse()
554 {
555 assert(needsResponse());
556 assert(isRequest());
557 origCmd = cmd;
558 cmd = cmd.responseCommand();
559
560 dest = src;
561 flags.set(VALID_DST, flags.isSet(VALID_SRC));
562 flags.clear(VALID_SRC);
563 }
564
565 void
566 makeAtomicResponse()
567 {
568 makeResponse();
569 }
570
571 void
572 makeTimingResponse()
573 {
574 makeResponse();
575 }
576
577 /**
578 * Take a request packet that has been returned as NACKED and
579 * modify it so that it can be sent out again. Only packets that
580 * need a response can be NACKED, so verify that that is true.
581 */
582 void
583 reinitNacked()
584 {
585 assert(wasNacked());
586 cmd = origCmd;
587 assert(needsResponse());
588 setDest(Broadcast);
589 }
590
591
592 /**
593 * Set the data pointer to the following value that should not be
594 * freed.
595 */
596 template <typename T>
597 void
598 dataStatic(T *p)
599 {
600 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
601 data = (PacketDataPtr)p;
602 flags.set(STATIC_DATA);
603 }
604
605 /**
606 * Set the data pointer to a value that should have delete []
607 * called on it.
608 */
609 template <typename T>
610 void
611 dataDynamicArray(T *p)
612 {
613 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
614 data = (PacketDataPtr)p;
615 flags.set(DYNAMIC_DATA|ARRAY_DATA);
616 }
617
618 /**
619 * set the data pointer to a value that should have delete called
620 * on it.
621 */
622 template <typename T>
623 void
624 dataDynamic(T *p)
625 {
626 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA));
627 data = (PacketDataPtr)p;
628 flags.set(DYNAMIC_DATA);
629 }
630
631 /**
632 * get a pointer to the data ptr.
633 */
634 template <typename T>
635 T*
636 getPtr()
637 {
638 assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
639 return (T*)data;
640 }
641
642 /**
643 * return the value of what is pointed to in the packet.
644 */
645 template <typename T>
646 T get();
647
648 /**
649 * set the value in the data pointer to v.
650 */
651 template <typename T>
652 void set(T v);
653
654 /**
655 * Copy data into the packet from the provided pointer.
656 */
657 void
658 setData(uint8_t *p)
659 {
660 std::memcpy(getPtr<uint8_t>(), p, getSize());
661 }
662
663 /**
664 * Copy data into the packet from the provided block pointer,
665 * which is aligned to the given block size.
666 */
667 void
668 setDataFromBlock(uint8_t *blk_data, int blkSize)
669 {
670 setData(blk_data + getOffset(blkSize));
671 }
672
673 /**
674 * Copy data from the packet to the provided block pointer, which
675 * is aligned to the given block size.
676 */
677 void
678 writeData(uint8_t *p)
679 {
680 std::memcpy(p, getPtr<uint8_t>(), getSize());
681 }
682
683 /**
684 * Copy data from the packet to the memory at the provided pointer.
685 */
686 void
687 writeDataToBlock(uint8_t *blk_data, int blkSize)
688 {
689 writeData(blk_data + getOffset(blkSize));
690 }
691
692 /**
693 * delete the data pointed to in the data pointer. Ok to call to
694 * matter how data was allocted.
695 */
696 void
697 deleteData()
698 {
699 if (flags.isSet(ARRAY_DATA))
700 delete [] data;
701 else if (flags.isSet(DYNAMIC_DATA))
702 delete data;
703
704 flags.clear(STATIC_DATA|DYNAMIC_DATA|ARRAY_DATA);
705 data = NULL;
706 }
707
708 /** If there isn't data in the packet, allocate some. */
709 void
710 allocate()
711 {
712 if (data) {
713 assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA));
714 return;
715 }
716
717 assert(flags.noneSet(STATIC_DATA|DYNAMIC_DATA));
718 flags.set(DYNAMIC_DATA|ARRAY_DATA);
719 data = new uint8_t[getSize()];
720 }
721
722
723 /**
724 * Check a functional request against a memory value represented
725 * by a base/size pair and an associated data array. If the
726 * functional request is a read, it may be satisfied by the memory
727 * value. If the functional request is a write, it may update the
728 * memory value.
729 */
730 bool checkFunctional(Printable *obj, Addr base, int size, uint8_t *data);
731
732 /**
733 * Check a functional request against a memory value stored in
734 * another packet (i.e. an in-transit request or response).
735 */
736 bool
737 checkFunctional(PacketPtr other)
738 {
739 uint8_t *data = other->hasData() ? other->getPtr<uint8_t>() : NULL;
740 return checkFunctional(other, other->getAddr(), other->getSize(),
741 data);
742 }
743
744 /**
745 * Push label for PrintReq (safe to call unconditionally).
746 */
747 void
748 pushLabel(const std::string &lbl)
749 {
750 if (isPrint())
751 safe_cast<PrintReqState*>(senderState)->pushLabel(lbl);
752 }
753
754 /**
755 * Pop label for PrintReq (safe to call unconditionally).
756 */
757 void
758 popLabel()
759 {
760 if (isPrint())
761 safe_cast<PrintReqState*>(senderState)->popLabel();
762 }
763
764 void print(std::ostream &o, int verbosity = 0,
765 const std::string &prefix = "") const;
766 };
767
768 #endif //__MEM_PACKET_HH