gem5  v21.1.0.2
dist_etherlink.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 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  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 /* @file
39  * Device module for a full duplex ethernet link for dist gem5 simulations.
40  *
41  * See comments in dev/net/dist_iface.hh for a generic description of dist
42  * gem5 simulations.
43  *
44  * This class is meant to be a drop in replacement for the EtherLink class for
45  * dist gem5 runs.
46  *
47  */
48 #ifndef __DEV_DIST_ETHERLINK_HH__
49 #define __DEV_DIST_ETHERLINK_HH__
50 
51 #include <cassert>
52 #include <iostream>
53 
54 #include "base/types.hh"
55 #include "dev/net/etherlink.hh"
56 #include "params/DistEtherLink.hh"
57 #include "sim/serialize.hh"
58 #include "sim/sim_object.hh"
59 
60 namespace gem5
61 {
62 
63 class DistIface;
64 class EthPacketData;
65 
69 class DistEtherLink : public SimObject
70 {
71  protected:
72  class LocalIface;
73 
80  class Link : public Serializable
81  {
82  protected:
83  std::string objName;
90 
91  public:
92  Link(const std::string &name, DistEtherLink *p,
93  EtherDump *d, Event *e) :
94  objName(name), parent(p), localIface(nullptr), dump(d),
95  distIface(nullptr), event(e) {}
96 
97  ~Link() {}
98 
99  const std::string name() const { return objName; }
100  bool busy() const { return (bool)packet; }
102 
103  void serialize(CheckpointOut &cp) const override;
104  void unserialize(CheckpointIn &cp) override;
105  };
106 
110  class TxLink : public Link
111  {
112  protected:
116  double ticksPerByte;
121 
125  void txDone();
127 
128  public:
129  TxLink(const std::string &name, DistEtherLink *p,
130  double invBW, Tick delay_var, EtherDump *d) :
131  Link(name, p, d, &doneEvent), ticksPerByte(invBW),
132  delayVar(delay_var), doneEvent([this]{ txDone(); }, name) {}
133  ~TxLink() {}
134 
139  void setDistInt(DistIface *m) { assert(!distIface); distIface=m; }
140 
147  };
148 
152  class RxLink : public Link
153  {
154  protected:
155 
160 
164  void rxDone();
166 
167  public:
168 
169  RxLink(const std::string &name, DistEtherLink *p,
170  Tick delay, EtherDump *d) :
171  Link(name, p, d, &_doneEvent), linkDelay(delay),
172  _doneEvent([this]{ rxDone(); }, name) {}
173  ~RxLink() {}
174 
178  void setDistInt(DistIface *m);
182  const EventFunctionWrapper *doneEvent() const { return &_doneEvent; }
183  };
184 
188  class LocalIface : public EtherInt
189  {
190  private:
192 
193  public:
194  LocalIface(const std::string &name, TxLink *tx, RxLink *rx,
195  DistIface *m);
196 
197  bool recvPacket(EthPacketPtr pkt) { return txLink->transmit(pkt); }
198  void sendDone() { peer->sendDone(); }
199  bool isBusy() { return txLink->busy(); }
200  };
201 
202 
203  protected:
217 
219 
220  public:
221  using Params = DistEtherLinkParams;
222  DistEtherLink(const Params &p);
223  ~DistEtherLink();
224 
225  Port &getPort(const std::string &if_name,
226  PortID idx=InvalidPortID) override;
227 
228  virtual void init() override;
229  virtual void startup() override;
230 
231  void serialize(CheckpointOut &cp) const override;
232  void unserialize(CheckpointIn &cp) override;
233 };
234 
235 } // namespace gem5
236 
237 #endif // __DEV_DIST_ETHERLINK_HH__
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:252
serialize.hh
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::ArmISA::e
Bitfield< 9 > e
Definition: misc_types.hh:64
gem5::EtherInt::name
const std::string & name() const
Return port name (for DPRINTF).
Definition: etherint.hh:62
gem5::EtherInt
Definition: etherint.hh:50
gem5::InvalidPortID
const PortID InvalidPortID
Definition: types.hh:253
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::Serializable
Basic support for object serialization.
Definition: serialize.hh:169
gem5::EthPacketPtr
std::shared_ptr< EthPacketData > EthPacketPtr
Definition: etherpkt.hh:90
sim_object.hh
gem5::Event
Definition: eventq.hh:251
gem5::ArmISA::d
Bitfield< 9 > d
Definition: misc_types.hh:63
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::EtherDump
Definition: etherdump.hh:48
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::EtherInt::peer
EtherInt * peer
Definition: etherint.hh:54
gem5::EventFunctionWrapper
Definition: eventq.hh:1115
gem5::ArmISA::m
Bitfield< 0 > m
Definition: misc_types.hh:394
gem5::EtherInt::sendDone
virtual void sendDone()=0
gem5::DistIface
The interface class to talk to peer gem5 processes.
Definition: dist_iface.hh:101
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
types.hh
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40

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