gem5  v20.1.0.0
packet_queue.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012,2015,2018 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 
41 #ifndef __MEM_PACKET_QUEUE_HH__
42 #define __MEM_PACKET_QUEUE_HH__
43 
52 #include <list>
53 
54 #include "mem/port.hh"
55 #include "sim/drain.hh"
56 #include "sim/eventq.hh"
57 
62 class PacketQueue : public Drainable
63 {
64  private:
67  public:
71  : tick(t), pkt(p)
72  {}
73  };
74 
76 
79 
82 
84  void processSendEvent();
85 
88 
89  /*
90  * Optionally disable the sanity check
91  * on the size of the transmitList. The
92  * sanity check will be enabled by default.
93  */
95 
102 
103  protected:
104 
106  const std::string label;
107 
110 
112  bool deferredPacketReady() const
113  { return !transmitList.empty() && transmitList.front().tick <= curTick(); }
114 
123  virtual void sendDeferredPacket();
124 
129  virtual bool sendTiming(PacketPtr pkt) = 0;
130 
141  PacketQueue(EventManager& _em, const std::string& _label,
142  const std::string& _sendEventName,
143  bool force_order = false,
144  bool disable_sanity_check = false);
145 
149  virtual ~PacketQueue();
150 
151  public:
152 
158  virtual const std::string name() const = 0;
159 
163  size_t size() const { return transmitList.size(); }
164 
169  { return transmitList.empty() ? MaxTick : transmitList.front().tick; }
170 
179  bool checkConflict(const PacketPtr pkt, const int blk_size) const;
180 
184 
194  void schedSendEvent(Tick when);
195 
202  void schedSendTiming(PacketPtr pkt, Tick when);
203 
209  void retry();
210 
218 
219  DrainState drain() override;
220 };
221 
223 {
224 
225  protected:
226 
228 
229  // Static definition so it can be called when constructing the parent
230  // without us being completely initialized.
231  static const std::string name(const RequestPort& memSidePort,
232  const std::string& label)
233  { return memSidePort.name() + "-" + label; }
234 
235  public:
236 
246  ReqPacketQueue(EventManager& _em, RequestPort& _mem_side_port,
247  const std::string _label = "ReqPacketQueue");
248 
249  virtual ~ReqPacketQueue() { }
250 
251  const std::string name() const
252  { return name(memSidePort, label); }
253 
254  bool sendTiming(PacketPtr pkt);
255 
256 };
257 
259 {
260 
261  protected:
262 
264 
265  // Static definition so it can be called when constructing the parent
266  // without us being completely initialized.
267  static const std::string name(const RequestPort& memSidePort,
268  const std::string& label)
269  { return memSidePort.name() + "-" + label; }
270 
271  public:
272 
283  SnoopRespPacketQueue(EventManager& _em, RequestPort& _mem_side_port,
284  bool force_order = false,
285  const std::string _label = "SnoopRespPacketQueue");
286 
287  virtual ~SnoopRespPacketQueue() { }
288 
289  const std::string name() const
290  { return name(memSidePort, label); }
291 
292  bool sendTiming(PacketPtr pkt);
293 
294 };
295 
297 {
298 
299  protected:
300 
302 
303  // Static definition so it can be called when constructing the parent
304  // without us being completely initialized.
305  static const std::string name(const ResponsePort& cpuSidePort,
306  const std::string& label)
307  { return cpuSidePort.name() + "-" + label; }
308 
309  public:
310 
321  RespPacketQueue(EventManager& _em, ResponsePort& _cpu_side_port,
322  bool force_order = false,
323  const std::string _label = "RespPacketQueue");
324 
325  virtual ~RespPacketQueue() { }
326 
327  const std::string name() const
328  { return name(cpuSidePort, label); }
329 
330  bool sendTiming(PacketPtr pkt);
331 
332 };
333 
334 #endif // __MEM_PACKET_QUEUE_HH__
SnoopRespPacketQueue
Definition: packet_queue.hh:258
PacketQueue::sendDeferredPacket
virtual void sendDeferredPacket()
Attempt to send a packet.
Definition: packet_queue.cc:188
PacketQueue::transmitList
DeferredPacketList transmitList
A list of outgoing packets.
Definition: packet_queue.hh:78
PacketQueue::size
size_t size() const
Get the size of the queue.
Definition: packet_queue.hh:163
ResponsePort
A ResponsePort is a specialization of a port.
Definition: port.hh:265
PacketQueue::_disableSanityCheck
bool _disableSanityCheck
Definition: packet_queue.hh:94
PacketQueue::DeferredPacketList
std::list< DeferredPacket > DeferredPacketList
Definition: packet_queue.hh:75
SnoopRespPacketQueue::sendTiming
bool sendTiming(PacketPtr pkt)
Send a packet using the appropriate method for the specific subclass (request, response or snoop resp...
Definition: packet_queue.cc:258
PacketQueue::sendEvent
EventFunctionWrapper sendEvent
Event used to call processSendEvent.
Definition: packet_queue.hh:87
PacketQueue::DeferredPacket::tick
Tick tick
The tick when the packet is ready to transmit.
Definition: packet_queue.hh:68
PacketQueue::DeferredPacket::pkt
PacketPtr pkt
Pointer to the packet to transmit.
Definition: packet_queue.hh:69
ReqPacketQueue::memSidePort
RequestPort & memSidePort
Definition: packet_queue.hh:227
PacketQueue
A packet queue is a class that holds deferred packets and later sends them using the associated CPU-s...
Definition: packet_queue.hh:62
SnoopRespPacketQueue::SnoopRespPacketQueue
SnoopRespPacketQueue(EventManager &_em, RequestPort &_mem_side_port, bool force_order=false, const std::string _label="SnoopRespPacketQueue")
Create a snoop response packet queue, linked to an event manager, a memory-side port,...
Definition: packet_queue.cc:248
PacketQueue::waitingOnRetry
bool waitingOnRetry
Remember whether we're awaiting a retry.
Definition: packet_queue.hh:109
ReqPacketQueue::~ReqPacketQueue
virtual ~ReqPacketQueue()
Definition: packet_queue.hh:249
Tick
uint64_t Tick
Tick count type.
Definition: types.hh:63
SnoopRespPacketQueue::name
const std::string name() const
Provide a name to simplify debugging.
Definition: packet_queue.hh:289
PacketQueue::schedSendEvent
void schedSendEvent(Tick when)
Schedule a send event if we are not already waiting for a retry.
Definition: packet_queue.cc:152
RespPacketQueue::~RespPacketQueue
virtual ~RespPacketQueue()
Definition: packet_queue.hh:325
PacketQueue::forceOrder
bool forceOrder
if true, inserted packets have to be unconditionally scheduled after the last packet in the queue tha...
Definition: packet_queue.hh:101
SnoopRespPacketQueue::memSidePort
RequestPort & memSidePort
Definition: packet_queue.hh:263
PacketQueue::schedSendTiming
void schedSendTiming(PacketPtr pkt, Tick when)
Add a packet to the transmit list, and schedule a send event.
Definition: packet_queue.cc:104
PacketQueue::sendTiming
virtual bool sendTiming(PacketPtr pkt)=0
Send a packet using the appropriate method for the specific subclass (request, response or snoop resp...
PacketQueue::em
EventManager & em
The manager which is used for the event queue.
Definition: packet_queue.hh:81
EventFunctionWrapper
Definition: eventq.hh:1101
DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:71
RespPacketQueue::sendTiming
bool sendTiming(PacketPtr pkt)
Send a packet using the appropriate method for the specific subclass (request, response or snoop resp...
Definition: packet_queue.cc:273
ReqPacketQueue::ReqPacketQueue
ReqPacketQueue(EventManager &_em, RequestPort &_mem_side_port, const std::string _label="ReqPacketQueue")
Create a request packet queue, linked to an event manager, a memory-side port, and a label that will ...
Definition: packet_queue.cc:235
RespPacketQueue::name
static const std::string name(const ResponsePort &cpuSidePort, const std::string &label)
Definition: packet_queue.hh:305
Drainable
Interface for objects that might require draining before checkpointing.
Definition: drain.hh:230
port.hh
ReqPacketQueue::sendTiming
bool sendTiming(PacketPtr pkt)
Send a packet using the appropriate method for the specific subclass (request, response or snoop resp...
Definition: packet_queue.cc:243
PacketQueue::processSendEvent
void processSendEvent()
Used to schedule sending of deferred packets.
Definition: packet_queue.cc:218
PacketQueue::deferredPacketReady
bool deferredPacketReady() const
Check whether we have a packet ready to go on the transmit list.
Definition: packet_queue.hh:112
RequestPort
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
Definition: port.hh:74
PacketQueue::name
virtual const std::string name() const =0
Provide a name to simplify debugging.
Port::name
const std::string name() const
Return port name (for DPRINTF).
Definition: port.hh:106
RespPacketQueue
Definition: packet_queue.hh:296
RespPacketQueue::name
const std::string name() const
Provide a name to simplify debugging.
Definition: packet_queue.hh:327
PacketQueue::DeferredPacket
A deferred packet, buffered to transmit later.
Definition: packet_queue.hh:66
PacketQueue::trySatisfyFunctional
bool trySatisfyFunctional(PacketPtr pkt)
Check the list of buffered packets against the supplied functional request.
Definition: packet_queue.cc:84
SnoopRespPacketQueue::~SnoopRespPacketQueue
virtual ~SnoopRespPacketQueue()
Definition: packet_queue.hh:287
ArmISA::t
Bitfield< 5 > t
Definition: miscregs_types.hh:67
ReqPacketQueue::name
static const std::string name(const RequestPort &memSidePort, const std::string &label)
Definition: packet_queue.hh:231
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
PacketQueue::~PacketQueue
virtual ~PacketQueue()
Virtual desctructor since the class may be used as a base class.
Definition: packet_queue.cc:58
ReqPacketQueue::name
const std::string name() const
Provide a name to simplify debugging.
Definition: packet_queue.hh:251
RespPacketQueue::RespPacketQueue
RespPacketQueue(EventManager &_em, ResponsePort &_cpu_side_port, bool force_order=false, const std::string _label="RespPacketQueue")
Create a response packet queue, linked to an event manager, a CPU-side port, and a label that will be...
Definition: packet_queue.cc:263
PacketQueue::label
const std::string label
Label to use for print request packets label stack.
Definition: packet_queue.hh:106
drain.hh
PacketQueue::deferredPacketReadyTime
Tick deferredPacketReadyTime() const
Get the next packet ready time.
Definition: packet_queue.hh:168
EventManager
Definition: eventq.hh:973
PacketQueue::checkConflict
bool checkConflict(const PacketPtr pkt, const int blk_size) const
Check if a packet corresponding to the same address exists in the queue.
Definition: packet_queue.cc:72
RespPacketQueue::cpuSidePort
ResponsePort & cpuSidePort
Definition: packet_queue.hh:301
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
std::list< DeferredPacket >
PacketQueue::PacketQueue
PacketQueue(EventManager &_em, const std::string &_label, const std::string &_sendEventName, bool force_order=false, 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:47
PacketQueue::DeferredPacket::DeferredPacket
DeferredPacket(Tick t, PacketPtr p)
Definition: packet_queue.hh:70
MaxTick
const Tick MaxTick
Definition: types.hh:65
ReqPacketQueue
Definition: packet_queue.hh:222
SnoopRespPacketQueue::name
static const std::string name(const RequestPort &memSidePort, const std::string &label)
Definition: packet_queue.hh:267
PacketQueue::disableSanityCheck
void disableSanityCheck()
This allows a user to explicitly disable the sanity check on the size of the transmitList,...
Definition: packet_queue.hh:217
PacketQueue::drain
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: packet_queue.cc:225
PacketQueue::retry
void retry()
Retry sending a packet from the queue.
Definition: packet_queue.cc:63
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45
eventq.hh

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17