gem5  v21.1.0.2
NetworkInterface.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Advanced Micro Devices, Inc.
3  * Copyright (c) 2020 Inria
4  * Copyright (c) 2016 Georgia Institute of Technology
5  * Copyright (c) 2008 Princeton University
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met: redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer;
12  * redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution;
15  * neither the name of the copyright holders nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 
33 #ifndef __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
34 #define __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
35 
36 #include <iostream>
37 #include <vector>
38 
47 #include "params/GarnetNetworkInterface.hh"
48 
49 namespace gem5
50 {
51 
52 namespace ruby
53 {
54 
55 class MessageBuffer;
56 
57 namespace garnet
58 {
59 
60 class flitBuffer;
61 
62 class NetworkInterface : public ClockedObject, public Consumer
63 {
64  public:
65  typedef GarnetNetworkInterfaceParams Params;
66  NetworkInterface(const Params &p);
67  ~NetworkInterface() = default;
68 
69  void addInPort(NetworkLink *in_link, CreditLink *credit_link);
70  void addOutPort(NetworkLink *out_link, CreditLink *credit_link,
71  SwitchID router_id, uint32_t consumerVcs);
72 
73  void dequeueCallback();
74  void wakeup();
77 
78  void print(std::ostream& out) const;
79  int get_vnet(int vc);
80  void init_net_ptr(GarnetNetwork *net_ptr) { m_net_ptr = net_ptr; }
81 
82  uint32_t functionalWrite(Packet *);
83 
84  void scheduleFlit(flit *t_flit);
85 
86  int get_router_id(int vnet)
87  {
88  OutputPort *oPort = getOutportForVnet(vnet);
89  assert(oPort);
90  return oPort->routerID();
91  }
92 
93  class OutputPort
94  {
95  public:
96  OutputPort(NetworkLink *outLink, CreditLink *creditLink,
97  int routerID)
98  {
99  _vnets = outLink->mVnets;
100  _outFlitQueue = new flitBuffer();
101 
102  _outNetLink = outLink;
103  _inCreditLink = creditLink;
104 
106  _bitWidth = outLink->bitWidth;
107  _vcRoundRobin = 0;
108 
109  }
110 
111  flitBuffer *
113  {
114  return _outFlitQueue;
115  }
116 
117  NetworkLink *
119  {
120  return _outNetLink;
121  }
122 
123  CreditLink *
125  {
126  return _inCreditLink;
127  }
128 
129  int
131  {
132  return _routerID;
133  }
134 
135  uint32_t bitWidth()
136  {
137  return _bitWidth;
138  }
139 
140  bool isVnetSupported(int pVnet)
141  {
142  if (!_vnets.size()) {
143  return true;
144  }
145 
146  for (auto &it : _vnets) {
147  if (it == pVnet) {
148  return true;
149  }
150  }
151  return false;
152 
153  }
154 
155  std::string
157  {
158  std::stringstream ss;
159  for (auto &it : _vnets) {
160  ss << it;
161  ss << " ";
162  }
163  return ss.str();
164  }
165 
167  {
168  return _vcRoundRobin;
169  }
170 
171  void vcRoundRobin(int vc)
172  {
173  _vcRoundRobin = vc;
174  }
175 
176 
177  private:
180 
183 
184  int _vcRoundRobin; // For round robin scheduling
185 
187  uint32_t _bitWidth;
188  };
189 
190  class InputPort
191  {
192  public:
193  InputPort(NetworkLink *inLink, CreditLink *creditLink)
194  {
195  _vnets = inLink->mVnets;
196  _outCreditQueue = new flitBuffer();
197 
198  _inNetLink = inLink;
199  _outCreditLink = creditLink;
200  _bitWidth = inLink->bitWidth;
201  }
202 
203  flitBuffer *
205  {
206  return _outCreditQueue;
207  }
208 
209  NetworkLink *
211  {
212  return _inNetLink;
213  }
214 
215  CreditLink *
217  {
218  return _outCreditLink;
219  }
220 
221  bool isVnetSupported(int pVnet)
222  {
223  if (!_vnets.size()) {
224  return true;
225  }
226 
227  for (auto &it : _vnets) {
228  if (it == pVnet) {
229  return true;
230  }
231  }
232  return false;
233 
234  }
235 
236  void sendCredit(Credit *cFlit)
237  {
238  _outCreditQueue->insert(cFlit);
239  }
240 
241  uint32_t bitWidth()
242  {
243  return _bitWidth;
244  }
245 
246  std::string
248  {
249  std::stringstream ss;
250  for (auto &it : _vnets) {
251  ss << it;
252  ss << " ";
253  }
254  return ss.str();
255  }
256 
257  // Queue for stalled flits
260  private:
263 
266  uint32_t _bitWidth;
267  };
268 
269 
270  private:
272  const NodeID m_id;
280 
282 
283  // Input Flit Buffers
284  // The flit buffers which will serve the Consumer
287 
288  // The Message buffers that takes messages from the protocol
290  // The Message buffers that provides messages to the protocol
292  // When a vc stays busy for a long time, it indicates a deadlock
294 
295  void checkStallQueue();
296  bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
297  int calculateVC(int vnet);
298 
299 
300  void scheduleOutputPort(OutputPort *oPort);
301  void scheduleOutputLink();
302  void checkReschedule();
303 
304  void incrementStats(flit *t_flit);
305 
306  InputPort *getInportForVnet(int vnet);
307  OutputPort *getOutportForVnet(int vnet);
308 };
309 
310 } // namespace garnet
311 } // namespace ruby
312 } // namespace gem5
313 
314 #endif // __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
gem5::ruby::garnet::flit
Definition: flit.hh:50
gem5::ruby::garnet::NetworkInterface
Definition: NetworkInterface.hh:62
gem5::ruby::MsgPtr
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
gem5::ruby::garnet::NetworkInterface::outPorts
std::vector< OutputPort * > outPorts
Definition: NetworkInterface.hh:276
gem5::ruby::garnet::NetworkInterface::checkReschedule
void checkReschedule()
Definition: NetworkInterface.cc:623
gem5::ruby::garnet::NetworkInterface::OutputPort::_vnets
std::vector< int > _vnets
Definition: NetworkInterface.hh:178
gem5::ruby::garnet::NetworkInterface::wakeup
void wakeup()
Definition: NetworkInterface.cc:191
gem5::ruby::garnet::NetworkInterface::OutputPort
Definition: NetworkInterface.hh:93
gem5::ruby::garnet::NetworkInterface::scheduleOutputLink
void scheduleOutputLink()
This function looks at the NI buffers if some buffer has flits which are ready to traverse the link i...
Definition: NetworkInterface.cc:550
gem5::ruby::garnet::NetworkInterface::InputPort::outCreditLink
CreditLink * outCreditLink()
Definition: NetworkInterface.hh:216
gem5::ruby::garnet::Credit
Definition: Credit.hh:54
gem5::ruby::garnet::NetworkInterface::init_net_ptr
void init_net_ptr(GarnetNetwork *net_ptr)
Definition: NetworkInterface.hh:80
gem5::ruby::garnet::NetworkInterface::OutputPort::vcRoundRobin
int vcRoundRobin()
Definition: NetworkInterface.hh:166
gem5::ruby::garnet::NetworkInterface::outNode_ptr
std::vector< MessageBuffer * > outNode_ptr
Definition: NetworkInterface.hh:291
gem5::ruby::garnet::NetworkInterface::functionalWrite
uint32_t functionalWrite(Packet *)
Definition: NetworkInterface.cc:670
gem5::ruby::garnet::NetworkInterface::m_id
const NodeID m_id
Definition: NetworkInterface.hh:272
gem5::ruby::garnet::NetworkInterface::inPorts
std::vector< InputPort * > inPorts
Definition: NetworkInterface.hh:277
gem5::ruby::garnet::NetworkInterface::addNode
void addNode(std::vector< MessageBuffer * > &inNode, std::vector< MessageBuffer * > &outNode)
Definition: NetworkInterface.cc:130
gem5::ruby::garnet::NetworkInterface::InputPort::isVnetSupported
bool isVnetSupported(int pVnet)
Definition: NetworkInterface.hh:221
gem5::ruby::garnet::NetworkInterface::OutputPort::_bitWidth
uint32_t _bitWidth
Definition: NetworkInterface.hh:187
gem5::ruby::garnet::NetworkInterface::m_vc_per_vnet
int m_vc_per_vnet
Definition: NetworkInterface.hh:274
gem5::ruby::garnet::NetworkInterface::niOutVcs
std::vector< flitBuffer > niOutVcs
Definition: NetworkInterface.hh:285
gem5::ruby::garnet::NetworkInterface::OutputPort::_routerID
int _routerID
Definition: NetworkInterface.hh:186
gem5::ruby::garnet::NetworkInterface::OutputPort::routerID
int routerID()
Definition: NetworkInterface.hh:130
std::vector
STL vector class.
Definition: stl.hh:37
GarnetNetwork.hh
gem5::ruby::Consumer
Definition: Consumer.hh:61
gem5::ruby::garnet::NetworkInterface::incrementStats
void incrementStats(flit *t_flit)
Definition: NetworkInterface.cc:154
gem5::ruby::garnet::NetworkInterface::~NetworkInterface
~NetworkInterface()=default
gem5::ruby::garnet::NetworkInterface::OutputPort::bitWidth
uint32_t bitWidth()
Definition: NetworkInterface.hh:135
gem5::ruby::garnet::NetworkInterface::getOutportForVnet
OutputPort * getOutportForVnet(int vnet)
Definition: NetworkInterface.cc:577
gem5::ruby::garnet::NetworkInterface::InputPort::messageEnqueuedThisCycle
bool messageEnqueuedThisCycle
Definition: NetworkInterface.hh:259
CommonTypes.hh
gem5::ruby::garnet::NetworkInterface::addOutPort
void addOutPort(NetworkLink *out_link, CreditLink *credit_link, SwitchID router_id, uint32_t consumerVcs)
Definition: NetworkInterface.cc:84
gem5::ruby::garnet::NetworkInterface::InputPort::inNetLink
NetworkLink * inNetLink()
Definition: NetworkInterface.hh:210
gem5::ruby::garnet::NetworkInterface::get_router_id
int get_router_id(int vnet)
Definition: NetworkInterface.hh:86
gem5::ruby::garnet::NetworkInterface::calculateVC
int calculateVC(int vnet)
Definition: NetworkInterface.cc:458
gem5::ruby::garnet::NetworkInterface::OutputPort::_outFlitQueue
flitBuffer * _outFlitQueue
Definition: NetworkInterface.hh:179
gem5::ruby::garnet::NetworkInterface::InputPort::_vnets
std::vector< int > _vnets
Definition: NetworkInterface.hh:261
gem5::ruby::garnet::NetworkInterface::m_deadlock_threshold
int m_deadlock_threshold
Definition: NetworkInterface.hh:278
gem5::ruby::garnet::NetworkInterface::InputPort::m_stall_queue
std::deque< flit * > m_stall_queue
Definition: NetworkInterface.hh:258
gem5::ruby::garnet::NetworkInterface::dequeueCallback
void dequeueCallback()
Definition: NetworkInterface.cc:144
gem5::ruby::garnet::NetworkInterface::OutputPort::inCreditLink
CreditLink * inCreditLink()
Definition: NetworkInterface.hh:124
gem5::ruby::garnet::NetworkInterface::InputPort::_outCreditQueue
flitBuffer * _outCreditQueue
Definition: NetworkInterface.hh:262
gem5::ruby::garnet::NetworkInterface::m_ni_out_vcs_enqueue_time
std::vector< Tick > m_ni_out_vcs_enqueue_time
Definition: NetworkInterface.hh:286
gem5::ruby::garnet::NetworkInterface::OutputPort::isVnetSupported
bool isVnetSupported(int pVnet)
Definition: NetworkInterface.hh:140
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::ruby::garnet::NetworkInterface::OutputPort::OutputPort
OutputPort(NetworkLink *outLink, CreditLink *creditLink, int routerID)
Definition: NetworkInterface.hh:96
gem5::ruby::garnet::NetworkInterface::vc_busy_counter
std::vector< int > vc_busy_counter
Definition: NetworkInterface.hh:293
gem5::ruby::garnet::NetworkInterface::scheduleFlit
void scheduleFlit(flit *t_flit)
Definition: NetworkInterface.cc:588
gem5::ruby::garnet::NetworkInterface::checkStallQueue
void checkStallQueue()
Definition: NetworkInterface.cc:316
gem5::ruby::garnet::NetworkInterface::InputPort::_bitWidth
uint32_t _bitWidth
Definition: NetworkInterface.hh:266
gem5::ruby::garnet::flitBuffer::insert
void insert(flit *flt)
Definition: flitBuffer.hh:78
gem5::ruby::garnet::NetworkInterface::getInportForVnet
InputPort * getInportForVnet(int vnet)
Definition: NetworkInterface.cc:559
gem5::ruby::garnet::NetworkInterface::OutputPort::printVnets
std::string printVnets()
Definition: NetworkInterface.hh:156
gem5::ruby::garnet::NetworkInterface::m_virtual_networks
const int m_virtual_networks
Definition: NetworkInterface.hh:273
ss
std::stringstream ss
Definition: trace.test.cc:45
gem5::ruby::garnet::NetworkInterface::outVcState
std::vector< OutVcState > outVcState
Definition: NetworkInterface.hh:279
gem5::ruby::garnet::NetworkInterface::m_net_ptr
GarnetNetwork * m_net_ptr
Definition: NetworkInterface.hh:271
gem5::ruby::SwitchID
unsigned int SwitchID
Definition: TypeDefines.hh:41
gem5::ruby::garnet::NetworkInterface::scheduleOutputPort
void scheduleOutputPort(OutputPort *oPort)
Definition: NetworkInterface.cc:482
gem5::ruby::garnet::NetworkInterface::InputPort::InputPort
InputPort(NetworkLink *inLink, CreditLink *creditLink)
Definition: NetworkInterface.hh:193
gem5::ruby::garnet::NetworkInterface::flitisizeMessage
bool flitisizeMessage(MsgPtr msg_ptr, int vnet)
Definition: NetworkInterface.cc:369
gem5::ruby::garnet::NetworkInterface::InputPort::outCreditQueue
flitBuffer * outCreditQueue()
Definition: NetworkInterface.hh:204
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::ruby::garnet::NetworkInterface::OutputPort::outNetLink
NetworkLink * outNetLink()
Definition: NetworkInterface.hh:118
OutVcState.hh
gem5::ruby::garnet::NetworkInterface::inNode_ptr
std::vector< MessageBuffer * > inNode_ptr
Definition: NetworkInterface.hh:289
gem5::ruby::garnet::NetworkInterface::InputPort::sendCredit
void sendCredit(Credit *cFlit)
Definition: NetworkInterface.hh:236
gem5::ruby::garnet::GarnetNetwork
Definition: GarnetNetwork.hh:60
Consumer.hh
gem5::ruby::garnet::NetworkInterface::OutputPort::_vcRoundRobin
int _vcRoundRobin
Definition: NetworkInterface.hh:184
gem5::ruby::garnet::NetworkInterface::InputPort::printVnets
std::string printVnets()
Definition: NetworkInterface.hh:247
std::deque
STL deque class.
Definition: stl.hh:44
Credit.hh
gem5::ruby::garnet::NetworkInterface::m_stall_count
std::vector< int > m_stall_count
Definition: NetworkInterface.hh:281
gem5::ruby::garnet::NetworkInterface::m_vc_allocator
std::vector< int > m_vc_allocator
Definition: NetworkInterface.hh:275
gem5::ruby::garnet::flitBuffer
Definition: flitBuffer.hh:50
gem5::ruby::NodeID
unsigned int NodeID
Definition: TypeDefines.hh:40
gem5::ruby::garnet::NetworkInterface::InputPort::_inNetLink
NetworkLink * _inNetLink
Definition: NetworkInterface.hh:264
gem5::ruby::garnet::NetworkInterface::NetworkInterface
NetworkInterface(const Params &p)
Definition: NetworkInterface.cc:54
gem5::ruby::garnet::NetworkInterface::addInPort
void addInPort(NetworkLink *in_link, CreditLink *credit_link)
Definition: NetworkInterface.cc:66
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
Message.hh
gem5::ruby::garnet::NetworkInterface::OutputPort::_inCreditLink
CreditLink * _inCreditLink
Definition: NetworkInterface.hh:182
gem5::ruby::garnet::NetworkInterface::OutputPort::vcRoundRobin
void vcRoundRobin(int vc)
Definition: NetworkInterface.hh:171
gem5::ruby::garnet::NetworkInterface::OutputPort::_outNetLink
NetworkLink * _outNetLink
Definition: NetworkInterface.hh:181
gem5::ruby::garnet::NetworkInterface::InputPort
Definition: NetworkInterface.hh:190
gem5::ruby::garnet::NetworkInterface::Params
GarnetNetworkInterfaceParams Params
Definition: NetworkInterface.hh:65
gem5::ruby::garnet::NetworkInterface::get_vnet
int get_vnet(int vc)
Definition: NetworkInterface.cc:606
gem5::ruby::garnet::NetworkInterface::InputPort::_outCreditLink
CreditLink * _outCreditLink
Definition: NetworkInterface.hh:265
gem5::ruby::garnet::NetworkInterface::InputPort::bitWidth
uint32_t bitWidth()
Definition: NetworkInterface.hh:241
gem5::ruby::garnet::NetworkInterface::print
void print(std::ostream &out) const
Definition: NetworkInterface.cc:664
gem5::ruby::garnet::NetworkInterface::OutputPort::outFlitQueue
flitBuffer * outFlitQueue()
Definition: NetworkInterface.hh:112

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17