44 #include <arpa/inet.h> 45 #include <sys/socket.h> 55 #include "debug/DistEthernet.hh" 56 #include "debug/DistEthernetPkt.hh" 57 #include "debug/EthernetData.hh" 64 #include "params/EtherLink.hh" 74 DPRINTF(DistEthernet,
"DistEtherLink::DistEtherLink() " 75 "link delay:%llu ticksPerByte:%f\n", p->delay, p->speed);
82 if (p->sync_repeat != 0) {
83 if (p->sync_repeat != p->delay)
84 warn(
"DistEtherLink(): sync_repeat is %lu and linkdelay is %lu",
85 p->sync_repeat, p->delay);
86 sync_repeat = p->sync_repeat;
88 sync_repeat = p->delay;
93 p->dist_rank, p->dist_size,
94 p->sync_start, sync_repeat,
this,
95 p->dist_sync_on_pseudo_op, p->is_switch,
112 if (if_name ==
"int0")
136 DPRINTF(DistEthernet,
"DistEtherLink::init() called\n");
143 DPRINTF(DistEthernet,
"DistEtherLink::startup() called\n");
165 DPRINTF(DistEthernetPkt,
"DistEtherLink::DistLink::rxDone() " 166 "packet received: len=%d\n", packet->length);
167 DDUMP(EthernetData, packet->data, packet->length);
190 DPRINTF(DistEthernet,
"packet not sent, link busy\n");
195 Tick delay = (
Tick)ceil(((
double)pkt->simLength * ticksPerByte) + 1.0);
204 parent->schedule(doneEvent,
curTick() + delay);
212 bool packet_exists = (packet !=
nullptr);
215 packet->serialize(
"packet", cp);
217 bool event_scheduled =
event->scheduled();
219 if (event_scheduled) {
220 Tick event_time =
event->when();
231 packet = make_shared<EthPacketData>();
232 packet->unserialize(
"packet", cp);
235 bool event_scheduled;
237 if (event_scheduled) {
240 parent->schedule(*
event, event_time);
257 DistEtherLinkParams::create()
Model for a receive link.
Ports are used to interface objects to each other.
void serialize(CheckpointOut &cp) const override
Serialize an object.
#define DDUMP(x, data, count)
DistEtherLink(const Params *p)
Overload hash function for BasicBlockRange type.
TxLink * txLink
Send link.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
std::enable_if< std::is_integral< T >::value, T >::type random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
DistEtherLinkParams Params
#define UNSERIALIZE_SCALAR(scalar)
Tick curTick()
The current simulated tick.
void packetOut(EthPacketPtr pkt, Tick send_delay)
Send out an Ethernet packet.
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
void setDistInt(DistIface *m)
Register our dist interface to talk to the peer gem5 processes.
DistIface * distIface
Interface to talk to the peer gem5 processes.
void init(const Event *e, Tick link_delay)
void setLocalInt(LocalIface *i)
uint64_t Tick
Tick count type.
const EventFunctionWrapper * doneEvent() const
Done events will be scheduled by DistIface (so we need the accessor)
void setDistInt(DistIface *m)
Register the dist interface to be used to talk to the peer gem5 processes.
Model for a fixed bandwidth full duplex ethernet link.
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::shared_ptr< EthPacketData > EthPacketPtr
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void serialize(CheckpointOut &cp) const override
Serialize an object.
#define SERIALIZE_SCALAR(scalar)
bool sendPacket(EthPacketPtr packet)
virtual void startup() override
startup() is the final initialization call before simulation.
virtual const std::string name() const
Interface to the local simulated system.
std::ostream CheckpointOut
void unserialize(CheckpointIn &cp) override
Unserialize an object.
RxLink * rxLink
Receive link.
EthPacketPtr packetIn()
Fetch the packet scheduled to be received next by the simulated network link.
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
LocalIface(const std::string &name, TxLink *tx, RxLink *rx, DistIface *m)
void dump()
Dump all statistics data to the registered outputs.
void txDone()
Send done callback.
void rxDone()
Receive done callback method.
The interface class to talk to peer gem5 processes.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Abstract superclass for simulation objects.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
bool transmit(EthPacketPtr packet)
Initiate sending of a packet via this link.