gem5 v24.1.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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/random.hh"
55#include "base/types.hh"
56#include "dev/net/etherlink.hh"
57#include "params/DistEtherLink.hh"
58#include "sim/serialize.hh"
59#include "sim/sim_object.hh"
60
61namespace gem5
62{
63
64class DistIface;
65class EthPacketData;
66
71{
72 protected:
73 class LocalIface;
74
81 class Link : public Serializable
82 {
83 protected:
84 std::string objName;
91
92 public:
93 Link(const std::string &name, DistEtherLink *p,
94 EtherDump *d, Event *e) :
95 objName(name), parent(p), localIface(nullptr), dump(d),
96 distIface(nullptr), event(e) {}
97
98 ~Link() {}
99
100 const std::string name() const { return objName; }
101 bool busy() const { return (bool)packet; }
103
104 void serialize(CheckpointOut &cp) const override;
105 void unserialize(CheckpointIn &cp) override;
106 };
107
111 class TxLink : public Link
112 {
113 protected:
122
126 void txDone();
128
130
131 public:
132 TxLink(const std::string &name, DistEtherLink *p,
133 double invBW, Tick delay_var, EtherDump *d) :
134 Link(name, p, d, &doneEvent), ticksPerByte(invBW),
135 delayVar(delay_var), doneEvent([this]{ txDone(); }, name) {}
137
143
150 };
151
155 class RxLink : public Link
156 {
157 protected:
158
163
167 void rxDone();
169
170 public:
171
172 RxLink(const std::string &name, DistEtherLink *p,
173 Tick delay, EtherDump *d) :
174 Link(name, p, d, &_doneEvent), linkDelay(delay),
175 _doneEvent([this]{ rxDone(); }, name) {}
177
181 void setDistInt(DistIface *m);
185 const EventFunctionWrapper *doneEvent() const { return &_doneEvent; }
186 };
187
191 class LocalIface : public EtherInt
192 {
193 private:
195
196 public:
197 LocalIface(const std::string &name, TxLink *tx, RxLink *rx,
198 DistIface *m);
199
200 bool recvPacket(EthPacketPtr pkt) { return txLink->transmit(pkt); }
201 void sendDone() { peer->sendDone(); }
202 bool isBusy() { return txLink->busy(); }
203 };
204
205
206 protected:
220
222
223 public:
224 using Params = DistEtherLinkParams;
225 DistEtherLink(const Params &p);
227
228 Port &getPort(const std::string &if_name,
229 PortID idx=InvalidPortID) override;
230
231 virtual void init() override;
232 virtual void startup() override;
233
234 void serialize(CheckpointOut &cp) const override;
235 void unserialize(CheckpointIn &cp) override;
236};
237
238} // namespace gem5
239
240#endif // __DEV_DIST_ETHERLINK_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
The interface class to talk to peer gem5 processes.
virtual void sendDone()=0
EtherInt * peer
Definition etherint.hh:54
const std::string & name() const
Return port name (for DPRINTF).
Definition etherint.hh:62
Ports are used to interface objects to each other.
Definition port.hh:62
std::shared_ptr< Random > RandomPtr
Definition random.hh:65
static RandomPtr genRandom()
Definition random.hh:68
Basic support for object serialization.
Definition serialize.hh:170
Abstract superclass for simulation objects.
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 9 > e
Definition misc_types.hh:65
Bitfield< 9 > d
Definition misc_types.hh:64
Bitfield< 0 > m
Bitfield< 0 > p
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
const PortID InvalidPortID
Definition types.hh:246
std::ostream CheckpointOut
Definition serialize.hh:66
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition types.hh:245
uint64_t Tick
Tick count type.
Definition types.hh:58
std::shared_ptr< EthPacketData > EthPacketPtr
Definition etherpkt.hh:90

Generated on Mon Jan 13 2025 04:28:34 for gem5 by doxygen 1.9.8