packet.hh (9030:047bd5f02c6e) packet.hh (9031:32ecc0217c5e)
1/*
2 * Copyright (c) 2012 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

--- 27 unchanged lines hidden (view full) ---

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
1/*
2 * Copyright (c) 2012 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

--- 27 unchanged lines hidden (view full) ---

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
44 */
45
46/**
47 * @file
48 * Declaration of the Packet class.
49 */
50
51#ifndef __MEM_PACKET_HH__

--- 174 unchanged lines hidden (view full) ---

226 * ultimate destination and back, possibly being conveyed by several
227 * different Packets along the way.)
228 */
229class Packet : public FastAlloc, public Printable
230{
231 public:
232 typedef uint32_t FlagsType;
233 typedef ::Flags<FlagsType> Flags;
45 */
46
47/**
48 * @file
49 * Declaration of the Packet class.
50 */
51
52#ifndef __MEM_PACKET_HH__

--- 174 unchanged lines hidden (view full) ---

227 * ultimate destination and back, possibly being conveyed by several
228 * different Packets along the way.)
229 */
230class Packet : public FastAlloc, public Printable
231{
232 public:
233 typedef uint32_t FlagsType;
234 typedef ::Flags<FlagsType> Flags;
234 typedef short NodeID;
235
236 private:
237 static const FlagsType PUBLIC_FLAGS = 0x00000000;
238 static const FlagsType PRIVATE_FLAGS = 0x00007F0F;
239 static const FlagsType COPY_FLAGS = 0x0000000F;
240
241 static const FlagsType SHARED = 0x00000001;
242 // Special control flags
243 /// Special timing-mode atomic snoop for multi-level coherence.
244 static const FlagsType EXPRESS_SNOOP = 0x00000002;
245 /// Does supplier have exclusive copy?
246 /// Useful for multi-level coherence.
247 static const FlagsType SUPPLY_EXCLUSIVE = 0x00000004;
248 // Snoop response flags
249 static const FlagsType MEM_INHIBIT = 0x00000008;
250 /// Are the 'addr' and 'size' fields valid?
251 static const FlagsType VALID_ADDR = 0x00000100;
252 static const FlagsType VALID_SIZE = 0x00000200;
235
236 private:
237 static const FlagsType PUBLIC_FLAGS = 0x00000000;
238 static const FlagsType PRIVATE_FLAGS = 0x00007F0F;
239 static const FlagsType COPY_FLAGS = 0x0000000F;
240
241 static const FlagsType SHARED = 0x00000001;
242 // Special control flags
243 /// Special timing-mode atomic snoop for multi-level coherence.
244 static const FlagsType EXPRESS_SNOOP = 0x00000002;
245 /// Does supplier have exclusive copy?
246 /// Useful for multi-level coherence.
247 static const FlagsType SUPPLY_EXCLUSIVE = 0x00000004;
248 // Snoop response flags
249 static const FlagsType MEM_INHIBIT = 0x00000008;
250 /// Are the 'addr' and 'size' fields valid?
251 static const FlagsType VALID_ADDR = 0x00000100;
252 static const FlagsType VALID_SIZE = 0x00000200;
253 /// Is the 'src' field valid?
254 static const FlagsType VALID_SRC = 0x00000400;
255 static const FlagsType VALID_DST = 0x00000800;
256 /// Is the data pointer set to a value that shouldn't be freed
257 /// when the packet is destroyed?
258 static const FlagsType STATIC_DATA = 0x00001000;
259 /// The data pointer points to a value that should be freed when
260 /// the packet is destroyed.
261 static const FlagsType DYNAMIC_DATA = 0x00002000;
262 /// the data pointer points to an array (thus delete []) needs to
263 /// be called on it rather than simply delete.

--- 37 unchanged lines hidden (view full) ---

301 * the timing responses need this information to be routed back to
302 * the appropriate port at a later point in time. The field can be
303 * updated (over-written) as the request packet passes through
304 * additional multiplexing components, and it is their
305 * responsibility to remember the original source port identifier,
306 * for example by using an appropriate sender state. The latter is
307 * done in the cache and bridge.
308 */
253 /// Is the data pointer set to a value that shouldn't be freed
254 /// when the packet is destroyed?
255 static const FlagsType STATIC_DATA = 0x00001000;
256 /// The data pointer points to a value that should be freed when
257 /// the packet is destroyed.
258 static const FlagsType DYNAMIC_DATA = 0x00002000;
259 /// the data pointer points to an array (thus delete []) needs to
260 /// be called on it rather than simply delete.

--- 37 unchanged lines hidden (view full) ---

298 * the timing responses need this information to be routed back to
299 * the appropriate port at a later point in time. The field can be
300 * updated (over-written) as the request packet passes through
301 * additional multiplexing components, and it is their
302 * responsibility to remember the original source port identifier,
303 * for example by using an appropriate sender state. The latter is
304 * done in the cache and bridge.
305 */
309 NodeID src;
306 PortID src;
310
311 /**
312 * Destination port identifier that is present on all response
313 * packets that passed through a multiplexing component as a
314 * request packet. The source port identifier is turned into a
315 * destination port identifier when the packet is turned into a
316 * response, and the destination is used, e.g. by the bus, to
317 * select the appropriate path through the interconnect.
318 */
307
308 /**
309 * Destination port identifier that is present on all response
310 * packets that passed through a multiplexing component as a
311 * request packet. The source port identifier is turned into a
312 * destination port identifier when the packet is turned into a
313 * response, and the destination is used, e.g. by the bus, to
314 * select the appropriate path through the interconnect.
315 */
319 NodeID dest;
316 PortID dest;
320
321 /**
322 * The original value of the command field. Only valid when the
323 * current command field is an error condition; in that case, the
324 * previous contents of the command field are copied here. This
325 * field is *not* set on non-error responses.
326 */
327 MemCmd origCmd;

--- 154 unchanged lines hidden (view full) ---

482 assert(isResponse());
483 cmd = MemCmd::BadAddressError;
484 }
485
486 bool wasNacked() const { return cmd == MemCmd::NetworkNackError; }
487 bool hadBadAddress() const { return cmd == MemCmd::BadAddressError; }
488 void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; }
489
317
318 /**
319 * The original value of the command field. Only valid when the
320 * current command field is an error condition; in that case, the
321 * previous contents of the command field are copied here. This
322 * field is *not* set on non-error responses.
323 */
324 MemCmd origCmd;

--- 154 unchanged lines hidden (view full) ---

479 assert(isResponse());
480 cmd = MemCmd::BadAddressError;
481 }
482
483 bool wasNacked() const { return cmd == MemCmd::NetworkNackError; }
484 bool hadBadAddress() const { return cmd == MemCmd::BadAddressError; }
485 void copyError(Packet *pkt) { assert(pkt->isError()); cmd = pkt->cmd; }
486
490 bool isSrcValid() { return flags.isSet(VALID_SRC); }
487 bool isSrcValid() const { return src != InvalidPortID; }
491 /// Accessor function to get the source index of the packet.
488 /// Accessor function to get the source index of the packet.
492 NodeID getSrc() const { assert(flags.isSet(VALID_SRC)); return src; }
489 PortID getSrc() const { assert(isSrcValid()); return src; }
493 /// Accessor function to set the source index of the packet.
490 /// Accessor function to set the source index of the packet.
494 void setSrc(NodeID _src) { src = _src; flags.set(VALID_SRC); }
491 void setSrc(PortID _src) { src = _src; }
495 /// Reset source field, e.g. to retransmit packet on different bus.
492 /// Reset source field, e.g. to retransmit packet on different bus.
496 void clearSrc() { flags.clear(VALID_SRC); }
493 void clearSrc() { src = InvalidPortID; }
497
494
498 bool isDestValid() { return flags.isSet(VALID_DST); }
495 bool isDestValid() const { return dest != InvalidPortID; }
499 /// Accessor function for the destination index of the packet.
496 /// Accessor function for the destination index of the packet.
500 NodeID getDest() const { assert(flags.isSet(VALID_DST)); return dest; }
497 PortID getDest() const { assert(isDestValid()); return dest; }
501 /// Accessor function to set the destination index of the packet.
498 /// Accessor function to set the destination index of the packet.
502 void setDest(NodeID _dest) { dest = _dest; flags.set(VALID_DST); }
499 void setDest(PortID _dest) { dest = _dest; }
503 /// Reset destination field, e.g. to turn a response into a request again.
500 /// Reset destination field, e.g. to turn a response into a request again.
504 void clearDest() { flags.clear(VALID_DST); }
501 void clearDest() { dest = InvalidPortID; }
505
506 Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; }
507 unsigned getSize() const { assert(flags.isSet(VALID_SIZE)); return size; }
508 Addr getOffset(int blkSize) const { return getAddr() & (Addr)(blkSize - 1); }
509
510 /**
511 * It has been determined that the SC packet should successfully update
512 * memory. Therefore, convert this SC packet to a normal write.

--- 20 unchanged lines hidden (view full) ---

533
534 /**
535 * Constructor. Note that a Request object must be constructed
536 * first, but the Requests's physical address and size fields need
537 * not be valid. The command must be supplied.
538 */
539 Packet(Request *_req, MemCmd _cmd)
540 : cmd(_cmd), req(_req), data(NULL),
502
503 Addr getAddr() const { assert(flags.isSet(VALID_ADDR)); return addr; }
504 unsigned getSize() const { assert(flags.isSet(VALID_SIZE)); return size; }
505 Addr getOffset(int blkSize) const { return getAddr() & (Addr)(blkSize - 1); }
506
507 /**
508 * It has been determined that the SC packet should successfully update
509 * memory. Therefore, convert this SC packet to a normal write.

--- 20 unchanged lines hidden (view full) ---

530
531 /**
532 * Constructor. Note that a Request object must be constructed
533 * first, but the Requests's physical address and size fields need
534 * not be valid. The command must be supplied.
535 */
536 Packet(Request *_req, MemCmd _cmd)
537 : cmd(_cmd), req(_req), data(NULL),
538 src(InvalidPortID), dest(InvalidPortID),
541 bytesValidStart(0), bytesValidEnd(0),
542 time(curTick()), senderState(NULL)
543 {
544 if (req->hasPaddr()) {
545 addr = req->getPaddr();
546 flags.set(VALID_ADDR);
547 }
548 if (req->hasSize()) {

--- 4 unchanged lines hidden (view full) ---

553
554 /**
555 * Alternate constructor if you are trying to create a packet with
556 * a request that is for a whole block, not the address from the
557 * req. this allows for overriding the size/addr of the req.
558 */
559 Packet(Request *_req, MemCmd _cmd, int _blkSize)
560 : cmd(_cmd), req(_req), data(NULL),
539 bytesValidStart(0), bytesValidEnd(0),
540 time(curTick()), senderState(NULL)
541 {
542 if (req->hasPaddr()) {
543 addr = req->getPaddr();
544 flags.set(VALID_ADDR);
545 }
546 if (req->hasSize()) {

--- 4 unchanged lines hidden (view full) ---

551
552 /**
553 * Alternate constructor if you are trying to create a packet with
554 * a request that is for a whole block, not the address from the
555 * req. this allows for overriding the size/addr of the req.
556 */
557 Packet(Request *_req, MemCmd _cmd, int _blkSize)
558 : cmd(_cmd), req(_req), data(NULL),
559 src(InvalidPortID), dest(InvalidPortID),
561 bytesValidStart(0), bytesValidEnd(0),
562 time(curTick()), senderState(NULL)
563 {
564 if (req->hasPaddr()) {
565 addr = req->getPaddr() & ~(_blkSize - 1);
566 flags.set(VALID_ADDR);
567 }
568 size = _blkSize;

--- 12 unchanged lines hidden (view full) ---

581 data(pkt->flags.isSet(STATIC_DATA) ? pkt->data : NULL),
582 addr(pkt->addr), size(pkt->size), src(pkt->src), dest(pkt->dest),
583 bytesValidStart(pkt->bytesValidStart), bytesValidEnd(pkt->bytesValidEnd),
584 time(curTick()), senderState(pkt->senderState)
585 {
586 if (!clearFlags)
587 flags.set(pkt->flags & COPY_FLAGS);
588
560 bytesValidStart(0), bytesValidEnd(0),
561 time(curTick()), senderState(NULL)
562 {
563 if (req->hasPaddr()) {
564 addr = req->getPaddr() & ~(_blkSize - 1);
565 flags.set(VALID_ADDR);
566 }
567 size = _blkSize;

--- 12 unchanged lines hidden (view full) ---

580 data(pkt->flags.isSet(STATIC_DATA) ? pkt->data : NULL),
581 addr(pkt->addr), size(pkt->size), src(pkt->src), dest(pkt->dest),
582 bytesValidStart(pkt->bytesValidStart), bytesValidEnd(pkt->bytesValidEnd),
583 time(curTick()), senderState(pkt->senderState)
584 {
585 if (!clearFlags)
586 flags.set(pkt->flags & COPY_FLAGS);
587
589 flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE|VALID_SRC|VALID_DST));
588 flags.set(pkt->flags & (VALID_ADDR|VALID_SIZE));
590 flags.set(pkt->flags & STATIC_DATA);
591
592 }
593
594 /**
595 * clean up packet variables
596 */
597 ~Packet()

--- 41 unchanged lines hidden (view full) ---

639 origCmd = cmd;
640 cmd = cmd.responseCommand();
641
642 // responses are never express, even if the snoop that
643 // triggered them was
644 flags.clear(EXPRESS_SNOOP);
645
646 dest = src;
589 flags.set(pkt->flags & STATIC_DATA);
590
591 }
592
593 /**
594 * clean up packet variables
595 */
596 ~Packet()

--- 41 unchanged lines hidden (view full) ---

638 origCmd = cmd;
639 cmd = cmd.responseCommand();
640
641 // responses are never express, even if the snoop that
642 // triggered them was
643 flags.clear(EXPRESS_SNOOP);
644
645 dest = src;
647 flags.set(VALID_DST, flags.isSet(VALID_SRC));
648 flags.clear(VALID_SRC);
646 clearSrc();
649 }
650
651 void
652 makeAtomicResponse()
653 {
654 makeResponse();
655 }
656

--- 219 unchanged lines hidden ---
647 }
648
649 void
650 makeAtomicResponse()
651 {
652 makeResponse();
653 }
654

--- 219 unchanged lines hidden ---