gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
packet_queue.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012,2015 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  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  *
40  * Authors: Ali Saidi
41  * Andreas Hansson
42  */
43 
44 #ifndef __MEM_PACKET_QUEUE_HH__
45 #define __MEM_PACKET_QUEUE_HH__
46 
55 #include <list>
56 
57 #include "mem/port.hh"
58 #include "sim/drain.hh"
59 #include "sim/eventq_impl.hh"
60 
65 class PacketQueue : public Drainable
66 {
67  private:
70  public:
74  : tick(t), pkt(p)
75  {}
76  };
77 
79 
82 
85 
87  void processSendEvent();
88 
91 
92  /*
93  * Optionally disable the sanity check
94  * on the size of the transmitList. The
95  * sanity check will be enabled by default.
96  */
98 
99  protected:
100 
102  const std::string label;
103 
106 
108  bool deferredPacketReady() const
109  { return !transmitList.empty() && transmitList.front().tick <= curTick(); }
110 
119  virtual void sendDeferredPacket();
120 
125  virtual bool sendTiming(PacketPtr pkt) = 0;
126 
136  PacketQueue(EventManager& _em, const std::string& _label,
137  bool disable_sanity_check = false);
138 
142  virtual ~PacketQueue();
143 
144  public:
145 
151  virtual const std::string name() const = 0;
152 
156  size_t size() const { return transmitList.size(); }
157 
162  { return transmitList.empty() ? MaxTick : transmitList.front().tick; }
163 
167  bool hasAddr(Addr addr) const;
168 
171  bool checkFunctional(PacketPtr pkt);
172 
182  void schedSendEvent(Tick when);
183 
191  void schedSendTiming(PacketPtr pkt, Tick when, bool force_order = false);
192 
198  void retry();
199 
207 
208  DrainState drain() override;
209 };
210 
212 {
213 
214  protected:
215 
217 
218  public:
219 
229  ReqPacketQueue(EventManager& _em, MasterPort& _masterPort,
230  const std::string _label = "ReqPacketQueue");
231 
232  virtual ~ReqPacketQueue() { }
233 
234  const std::string name() const
235  { return masterPort.name() + "-" + label; }
236 
237  bool sendTiming(PacketPtr pkt);
238 
239 };
240 
242 {
243 
244  protected:
245 
247 
248  public:
249 
259  SnoopRespPacketQueue(EventManager& _em, MasterPort& _masterPort,
260  const std::string _label = "SnoopRespPacketQueue");
261 
262  virtual ~SnoopRespPacketQueue() { }
263 
264  const std::string name() const
265  { return masterPort.name() + "-" + label; }
266 
267  bool sendTiming(PacketPtr pkt);
268 
269 };
270 
272 {
273 
274  protected:
275 
277 
278  public:
279 
289  RespPacketQueue(EventManager& _em, SlavePort& _slavePort,
290  const std::string _label = "RespPacketQueue");
291 
292  virtual ~RespPacketQueue() { }
293 
294  const std::string name() const
295  { return slavePort.name() + "-" + label; }
296 
297  bool sendTiming(PacketPtr pkt);
298 
299 };
300 
301 #endif // __MEM_PACKET_QUEUE_HH__
A MasterPort is a specialisation of a BaseMasterPort, which implements the default protocol for the t...
Definition: port.hh:167
void disableSanityCheck()
This allows a user to explicitly disable the sanity check on the size of the transmitList, which is enabled by default.
DrainState drain() override
Notify an object that it needs to drain its state.
RespPacketQueue(EventManager &_em, SlavePort &_slavePort, const std::string _label="RespPacketQueue")
Create a response packet queue, linked to an event manager, a slave port, and a label that will be us...
void retry()
Retry sending a packet from the queue.
Definition: packet_queue.cc:64
const std::string name() const
Provide a name to simplify debugging.
bool hasAddr(Addr addr) const
Check if a packets address exists in the queue.
Definition: packet_queue.cc:73
PacketPtr pkt
Pointer to the packet to transmit.
Definition: packet_queue.hh:72
void schedSendTiming(PacketPtr pkt, Tick when, bool force_order=false)
Add a packet to the transmit list, and schedule a send event.
EventWrapper< PacketQueue,&PacketQueue::processSendEvent > sendEvent
Event used to call processSendEvent.
Definition: packet_queue.hh:90
DrainState
Object drain/handover states.
Definition: drain.hh:71
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:99
bool _disableSanityCheck
Definition: packet_queue.hh:97
bool waitingOnRetry
Remember whether we're awaiting a retry.
ip6_addr_t addr
Definition: inet.hh:335
Port Object Declaration.
A deferred packet, buffered to transmit later.
Definition: packet_queue.hh:69
A SlavePort is a specialisation of a port.
Definition: port.hh:331
void schedSendEvent(Tick when)
Schedule a send event if we are not already waiting for a retry.
Tick tick
The tick when the packet is ready to transmit.
Definition: packet_queue.hh:71
ReqPacketQueue(EventManager &_em, MasterPort &_masterPort, const std::string _label="ReqPacketQueue")
Create a request packet queue, linked to an event manager, a master port, and a label that will be us...
virtual ~RespPacketQueue()
bool deferredPacketReady() const
Check whether we have a packet ready to go on the transmit list.
MasterPort & masterPort
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:223
const Tick MaxTick
Definition: types.hh:65
Tick curTick()
The current simulated tick.
Definition: core.hh:47
virtual ~ReqPacketQueue()
SlavePort & slavePort
uint64_t Tick
Tick count type.
Definition: types.hh:63
virtual bool sendTiming(PacketPtr pkt)=0
Send a packet using the appropriate method for the specific subclass (reuest, response or snoop respo...
EventManager & em
The manager which is used for the event queue.
Definition: packet_queue.hh:84
Tick deferredPacketReadyTime() const
Get the next packet ready time.
bool sendTiming(PacketPtr pkt)
Send a packet using the appropriate method for the specific subclass (reuest, response or snoop respo...
bool checkFunctional(PacketPtr pkt)
Check the list of buffered packets against the supplied functional request.
Definition: packet_queue.cc:85
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
bool sendTiming(PacketPtr pkt)
Send a packet using the appropriate method for the specific subclass (reuest, response or snoop respo...
A packet queue is a class that holds deferred packets and later sends them using the associated slave...
Definition: packet_queue.hh:65
MasterPort & masterPort
void processSendEvent()
Used to schedule sending of deferred packets.
virtual ~PacketQueue()
Virtual desctructor since the class may be used as a base class.
Definition: packet_queue.cc:59
virtual const std::string name() const =0
Provide a name to simplify debugging.
const std::string name() const
Provide a name to simplify debugging.
virtual ~SnoopRespPacketQueue()
const std::string name() const
Provide a name to simplify debugging.
DeferredPacket(Tick t, PacketPtr p)
Definition: packet_queue.hh:73
DeferredPacketList transmitList
A list of outgoing packets.
Definition: packet_queue.hh:81
Bitfield< 5 > t
Definition: miscregs.hh:1382
bool sendTiming(PacketPtr pkt)
Send a packet using the appropriate method for the specific subclass (reuest, response or snoop respo...
Bitfield< 0 > p
SnoopRespPacketQueue(EventManager &_em, MasterPort &_masterPort, const std::string _label="SnoopRespPacketQueue")
Create a snoop response packet queue, linked to an event manager, a master port, and a label that wil...
size_t size() const
Get the size of the queue.
PacketQueue(EventManager &_em, const std::string &_label, bool disable_sanity_check=false)
Create a packet queue, linked to an event manager, and a label that will be used for functional print...
Definition: packet_queue.cc:52
std::list< DeferredPacket > DeferredPacketList
Definition: packet_queue.hh:78
virtual void sendDeferredPacket()
Attempt to send a packet.
const std::string label
Label to use for print request packets label stack.

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6