55#include "debug/Ethernet.hh"
56#include "debug/EthernetData.hh"
60#include "params/EtherLink.hh"
72 p.delay,
p.delay_var,
p.dump);
74 p.delay,
p.delay_var,
p.dump);
93 if (if_name ==
"int0")
95 else if (if_name ==
"int1")
113 txQueueEvent([
this]{ processTxQueue(); },
name)
119 link[0]->serialize(
"link0",
cp);
120 link[1]->serialize(
"link1",
cp);
126 link[0]->unserialize(
"link0",
cp);
127 link[1]->unserialize(
"link1",
cp);
133 DPRINTF(Ethernet,
"packet received: len=%d\n",
packet->length);
169 assert(next.first >
curTick());
173 assert(cur.first ==
curTick());
181 DPRINTF(Ethernet,
"packet not sent, link busy\n");
185 DPRINTF(Ethernet,
"packet sent: len=%d\n", pkt->length);
186 DDUMP(EthernetData, pkt->data, pkt->length);
193 DPRINTF(Ethernet,
"scheduling packet: delay=%d, (rate=%f)\n",
203 bool packet_exists =
packet !=
nullptr;
208 bool event_scheduled =
doneEvent.scheduled();
210 if (event_scheduled) {
215 const size_t tx_queue_size(
txQueue.size());
232 packet = std::make_shared<EthPacketData>();
236 bool event_scheduled;
238 if (event_scheduled) {
244 size_t tx_queue_size = 0;
246 for (
size_t idx = 0; idx < tx_queue_size; ++idx) {
248 EthPacketPtr delayed_packet = std::make_shared<EthPacketData>();
251 delayed_packet->unserialize(
255 "Invalid txQueue packet order in EtherLink!\n");
256 txQueue.emplace_back(std::make_pair(tick, delayed_packet));
265 warn(
"Old-style EtherLink serialization format detected, "
266 "in-flight packets may have been dropped.\n");
#define DDUMP(x, data, count)
DPRINTF is a debugging trace facility that allows one to selectively enable tracing statements.
const std::string & name() const
Return port name (for DPRINTF).
EtherInt(const std::string &name, int idx=InvalidPortID)
Interface(const std::string &name, Link *txlink, Link *rxlink)
void unserialize(const std::string &base, CheckpointIn &cp)
const std::string objName
void serialize(const std::string &base, CheckpointOut &cp) const
Link(const std::string &name, EtherLink *p, int num, double rate, Tick delay, Tick delay_var, EtherDump *dump)
std::deque< std::pair< Tick, EthPacketPtr > > txQueue
Maintain a queue of in-flight packets.
EventFunctionWrapper txQueueEvent
const double ticksPerByte
const std::string name() const
bool transmit(EthPacketPtr packet)
void setRxInt(Interface *i)
void setTxInt(Interface *i)
EventFunctionWrapper doneEvent
void txComplete(EthPacketPtr packet)
EtherLink(const Params &p)
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void serialize(CheckpointOut &cp) const override
Serialize an object.
virtual std::string name() const
Ports are used to interface objects to each other.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m, bool do_warn=true)
This function is used for restoring optional parameters from the checkpoint.
SimObject(const Params &p)
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Copyright (c) 2024 Arm Limited All rights reserved.
Tick curTick()
The universal simulation clock.
std::ostream CheckpointOut
void paramOut(CheckpointOut &cp, const std::string &name, ExtMachInst const &machInst)
void paramIn(CheckpointIn &cp, const std::string &name, ExtMachInst &machInst)
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
uint64_t Tick
Tick count type.
std::string csprintf(const char *format, const Args &...args)
std::shared_ptr< EthPacketData > EthPacketPtr
const std::string & name()