46 #include <arpa/inet.h>
47 #include <sys/socket.h>
57 #include "debug/DistEthernet.hh"
58 #include "debug/DistEthernetPkt.hh"
59 #include "debug/EthernetData.hh"
67 #include "params/EtherLink.hh"
77 DPRINTF(DistEthernet,
"DistEtherLink::DistEtherLink() "
78 "link delay:%llu ticksPerByte:%f\n", p->delay, p->speed);
85 if (p->sync_repeat != 0) {
86 if (p->sync_repeat != p->delay)
87 warn(
"DistEtherLink(): sync_repeat is %lu and linkdelay is %lu",
88 p->sync_repeat, p->delay);
89 sync_repeat = p->sync_repeat;
91 sync_repeat = p->delay;
96 p->dist_rank, p->dist_size,
97 p->sync_start, sync_repeat,
this,
98 p->dist_sync_on_pseudo_op, p->is_switch,
115 if (if_name !=
"int0") {
142 DPRINTF(DistEthernet,
"DistEtherLink::init() called\n");
149 DPRINTF(DistEthernet,
"DistEtherLink::startup() called\n");
171 DPRINTF(DistEthernetPkt,
"DistEtherLink::DistLink::rxDone() "
172 "packet received: len=%d\n", packet->length);
173 DDUMP(EthernetData, packet->data, packet->length);
196 DPRINTF(DistEthernet,
"packet not sent, link busy\n");
201 Tick delay = (
Tick)ceil(((
double)pkt->simLength * ticksPerByte) + 1.0);
210 parent->schedule(doneEvent,
curTick() + delay);
218 bool packet_exists = (packet !=
nullptr);
221 packet->serialize(
"packet", cp);
223 bool event_scheduled =
event->scheduled();
225 if (event_scheduled) {
226 Tick event_time =
event->when();
237 packet = make_shared<EthPacketData>();
238 packet->unserialize(
"packet", cp);
241 bool event_scheduled;
243 if (event_scheduled) {
246 parent->schedule(*
event, event_time);
263 DistEtherLinkParams::create()
Model for a receive link.
void serialize(CheckpointOut &cp) const override
Serialize an object.
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
panic_if(!root,"Invalid expression\n")
#define DDUMP(x, data, count)
DistEtherLink(const Params *p)
TxLink * txLink
Send link.
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...
virtual EtherInt * getEthPort(const std::string &if_name, int idx) override
Additional function to return the Port of a memory object.
DistEtherLinkParams Params
#define UNSERIALIZE_SCALAR(scalar)
Tick curTick()
The current simulated tick.
void packetOut(EthPacketPtr pkt, Tick send_delay)
Send out an Ethernet packet.
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.
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.
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
const DoneEvent * doneEvent() const
Done events will be scheduled by DistIface (so we need the accessor)
virtual void init() override
init() is called after all C++ SimObjects have been created and all ports are connected.
std::shared_ptr< EthPacketData > EthPacketPtr
void serialize(CheckpointOut &cp) const override
Serialize an object.
The base EtherObject class, allows for an accesor function to a simobj that returns the Port...
#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.
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.
Base Ethernet Object declaration.
bool transmit(EthPacketPtr packet)
Initiate sending of a packet via this link.