gem5  v22.1.0.0
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  bool functionalRead(Packet *pkt, WriteMask &mask);
83  uint32_t functionalWrite(Packet *);
84 
85  void scheduleFlit(flit *t_flit);
86 
87  int get_router_id(int vnet)
88  {
89  OutputPort *oPort = getOutportForVnet(vnet);
90  assert(oPort);
91  return oPort->routerID();
92  }
93 
94  class OutputPort
95  {
96  public:
97  OutputPort(NetworkLink *outLink, CreditLink *creditLink,
98  int routerID)
99  {
100  _vnets = outLink->mVnets;
101  _outFlitQueue = new flitBuffer();
102 
103  _outNetLink = outLink;
104  _inCreditLink = creditLink;
105 
107  _bitWidth = outLink->bitWidth;
108  _vcRoundRobin = 0;
109 
110  }
111 
112  flitBuffer *
114  {
115  return _outFlitQueue;
116  }
117 
118  NetworkLink *
120  {
121  return _outNetLink;
122  }
123 
124  CreditLink *
126  {
127  return _inCreditLink;
128  }
129 
130  int
132  {
133  return _routerID;
134  }
135 
136  uint32_t bitWidth()
137  {
138  return _bitWidth;
139  }
140 
141  bool isVnetSupported(int pVnet)
142  {
143  if (!_vnets.size()) {
144  return true;
145  }
146 
147  for (auto &it : _vnets) {
148  if (it == pVnet) {
149  return true;
150  }
151  }
152  return false;
153 
154  }
155 
156  std::string
158  {
159  std::stringstream ss;
160  for (auto &it : _vnets) {
161  ss << it;
162  ss << " ";
163  }
164  return ss.str();
165  }
166 
168  {
169  return _vcRoundRobin;
170  }
171 
172  void vcRoundRobin(int vc)
173  {
174  _vcRoundRobin = vc;
175  }
176 
177 
178  private:
181 
184 
185  int _vcRoundRobin; // For round robin scheduling
186 
188  uint32_t _bitWidth;
189  };
190 
191  class InputPort
192  {
193  public:
194  InputPort(NetworkLink *inLink, CreditLink *creditLink)
195  {
196  _vnets = inLink->mVnets;
197  _outCreditQueue = new flitBuffer();
198 
199  _inNetLink = inLink;
200  _outCreditLink = creditLink;
201  _bitWidth = inLink->bitWidth;
202  }
203 
204  flitBuffer *
206  {
207  return _outCreditQueue;
208  }
209 
210  NetworkLink *
212  {
213  return _inNetLink;
214  }
215 
216  CreditLink *
218  {
219  return _outCreditLink;
220  }
221 
222  bool isVnetSupported(int pVnet)
223  {
224  if (!_vnets.size()) {
225  return true;
226  }
227 
228  for (auto &it : _vnets) {
229  if (it == pVnet) {
230  return true;
231  }
232  }
233  return false;
234 
235  }
236 
237  void sendCredit(Credit *cFlit)
238  {
239  _outCreditQueue->insert(cFlit);
240  }
241 
242  uint32_t bitWidth()
243  {
244  return _bitWidth;
245  }
246 
247  std::string
249  {
250  std::stringstream ss;
251  for (auto &it : _vnets) {
252  ss << it;
253  ss << " ";
254  }
255  return ss.str();
256  }
257 
258  // Queue for stalled flits
261  private:
264 
267  uint32_t _bitWidth;
268  };
269 
270 
271  private:
273  const NodeID m_id;
281 
283 
284  // Input Flit Buffers
285  // The flit buffers which will serve the Consumer
288 
289  // The Message buffers that takes messages from the protocol
291  // The Message buffers that provides messages to the protocol
293  // When a vc stays busy for a long time, it indicates a deadlock
295 
296  void checkStallQueue();
297  bool flitisizeMessage(MsgPtr msg_ptr, int vnet);
298  int calculateVC(int vnet);
299 
300 
301  void scheduleOutputPort(OutputPort *oPort);
302  void scheduleOutputLink();
303  void checkReschedule();
304 
305  void incrementStats(flit *t_flit);
306 
307  InputPort *getInportForVnet(int vnet);
308  OutputPort *getOutportForVnet(int vnet);
309 };
310 
311 } // namespace garnet
312 } // namespace ruby
313 } // namespace gem5
314 
315 #endif // __MEM_RUBY_NETWORK_GARNET_0_NETWORKINTERFACE_HH__
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
InputPort(NetworkLink *inLink, CreditLink *creditLink)
OutputPort(NetworkLink *outLink, CreditLink *creditLink, int routerID)
std::vector< OutputPort * > outPorts
bool functionalRead(Packet *pkt, WriteMask &mask)
std::vector< InputPort * > inPorts
void addInPort(NetworkLink *in_link, CreditLink *credit_link)
void init_net_ptr(GarnetNetwork *net_ptr)
void addOutPort(NetworkLink *out_link, CreditLink *credit_link, SwitchID router_id, uint32_t consumerVcs)
void print(std::ostream &out) const
GarnetNetworkInterfaceParams Params
std::vector< MessageBuffer * > outNode_ptr
void addNode(std::vector< MessageBuffer * > &inNode, std::vector< MessageBuffer * > &outNode)
void scheduleOutputPort(OutputPort *oPort)
OutputPort * getOutportForVnet(int vnet)
std::vector< MessageBuffer * > inNode_ptr
bool flitisizeMessage(MsgPtr msg_ptr, int vnet)
std::vector< OutVcState > outVcState
std::vector< flitBuffer > niOutVcs
void scheduleOutputLink()
This function looks at the NI buffers if some buffer has flits which are ready to traverse the link i...
STL deque class.
Definition: stl.hh:44
STL vector class.
Definition: stl.hh:37
constexpr uint64_t mask(unsigned nbits)
Generate a 64-bit mask of 'nbits' 1s, right justified.
Definition: bitfield.hh:63
Bitfield< 54 > p
Definition: pagetable.hh:70
std::shared_ptr< Message > MsgPtr
Definition: Message.hh:59
unsigned int SwitchID
Definition: TypeDefines.hh:43
unsigned int NodeID
Definition: TypeDefines.hh:42
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::stringstream ss
Definition: trace.test.cc:45

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1