Go to the documentation of this file.
39 #include "debug/EthernetAll.hh"
76 intrDelay(
p->intr_delay), intrTick(0), cpuIntrEnable(false),
77 cpuPendingIntr(false), intrEvent(0), interface(NULL)
82 :
Base(
p), rxUnique(0), txUnique(0),
83 virtualRegs(
p->virtual_count < 1 ? 1 :
p->virtual_count),
84 rxFifo(
p->rx_fifo_size), txFifo(
p->tx_fifo_size),
85 rxKickTick(0), txKickTick(0),
87 rxDmaEvent([
this]{ rxDmaDone(); },
name()),
88 txDmaEvent([
this]{ txDmaDone(); },
name()),
89 dmaReadDelay(
p->dma_read_delay), dmaReadFactor(
p->dma_read_factor),
90 dmaWriteDelay(
p->dma_write_delay), dmaWriteFactor(
p->dma_write_factor)
92 interface = new Interface(
name() + ".int0", this);
109 .
desc(
"maximum vnic distance")
113 .
name(
name() +
".totalVnicDistance")
114 .
desc(
"total vnic distance")
118 .
desc(
"number of vnic distance measurements")
123 .
desc(
"average vnic distance")
140 if (if_name ==
"interface")
151 panic(
"Trying to access a vnic that doesn't exist %d > %d\n",
162 using namespace Regs;
168 uint64_t rxdone = vnic.
RxDone;
171 rxdone = set_RxDone_High(rxdone,
rxFifo.
size() >
regs.RxFifoHigh);
172 rxdone = set_RxDone_NotHigh(rxdone,
rxLow);
174 regs.RxDone = rxdone;
175 regs.RxWait = rxdone;
178 uint64_t txdone = vnic.
TxDone;
183 regs.TxDone = txdone;
184 regs.TxWait = txdone;
190 if (vnic != -1 &&
virtualRegs[vnic].rxPacketOffset > 0)
194 regs.RxStatus = set_RxStatus_Head(
regs.RxStatus, head);
221 panic(
"invalid register: cpu=%d vnic=%d da=%#x pa=%#x size=%d",
226 panic(
"read %s (write only): "
227 "cpu=%d vnic=%d da=%#x pa=%#x size=%d",
230 panic(
"read %s (invalid size): "
231 "cpu=%d vnic=%d da=%#x pa=%#x size=%d",
236 uint64_t value M5_VAR_USED = 0;
250 "read %s: cpu=%d vnic=%d da=%#x pa=%#x size=%d val=%#x\n",
255 if (raddr == Regs::IntrStatus)
306 panic(
"invalid register: cpu=%d, da=%#x pa=%#x size=%d",
311 panic(
"write %s (read only): "
312 "cpu=%d vnic=%d da=%#x pa=%#x size=%d",
316 panic(
"write %s (invalid size): "
317 "cpu=%d vnic=%d da=%#x pa=%#x size=%d",
323 "write %s vnic %d: cpu=%d val=%#x da=%#x pa=%#x size=%d\n",
325 pkt->
getLE<uint32_t>() : pkt->
getLE<uint64_t>(),
339 case Regs::IntrStatus:
341 pkt->
getLE<uint32_t>());
349 if (Regs::get_RxDone_Busy(vnic.
RxDone))
350 panic(
"receive machine busy with another request! rxState=%s",
354 vnic.
RxDone = Regs::RxDone_Busy;
358 if (Regs::get_RxData_Vaddr(pkt->
getLE<uint64_t>())) {
359 panic(
"vtophys not implemented in newmem");
361 DPRINTF(EthernetPIO,
"write RxData vnic %d (rxunique %d)\n",
366 DPRINTF(EthernetPIO,
"request new packet...appending to rxList\n");
369 DPRINTF(EthernetPIO,
"packet exists...appending to rxBusy\n");
380 if (Regs::get_TxDone_Busy(vnic.
TxDone))
381 panic(
"transmit machine busy with another request! txState=%s",
385 vnic.
TxDone = Regs::TxDone_Busy;
387 if (Regs::get_TxData_Vaddr(pkt->
getLE<uint64_t>())) {
388 panic(
"vtophys won't work here in newmem.\n");
390 DPRINTF(EthernetPIO,
"write TxData vnic %d (txunique %d)\n",
409 if ((interrupts & Regs::Intr_Res))
410 panic(
"Cannot set a reserved interrupt");
412 regs.IntrStatus |= interrupts;
415 "interrupt written to intStatus: intr=%#x status=%#x mask=%#x\n",
416 interrupts,
regs.IntrStatus,
regs.IntrMask);
418 interrupts =
regs.IntrStatus &
regs.IntrMask;
425 interrupts &= ~Regs::Intr_RxHigh;
432 interrupts &= ~Regs::Intr_TxLow;
436 if ((interrupts & Regs::Intr_NoDelay) == 0)
445 if ((interrupts & Regs::Intr_Res))
446 panic(
"Cannot clear a reserved interrupt");
448 regs.IntrStatus &= ~interrupts;
451 "interrupt cleared from intStatus: intr=%x status=%x mask=%x\n",
452 interrupts,
regs.IntrStatus,
regs.IntrMask);
454 if (!(
regs.IntrStatus &
regs.IntrMask))
461 if (
regs.IntrMask == newmask)
464 regs.IntrMask = newmask;
467 "interrupt mask changed: intStatus=%x intMask=%x masked=%x\n",
470 if (
regs.IntrStatus &
regs.IntrMask)
491 DPRINTF(EthernetIntr,
"interrupts not enabled.\n",
497 DPRINTF(EthernetIntr,
"don't need to schedule event...intrTick=%d\n",
507 DPRINTF(EthernetIntr,
"going to schedule an interrupt for intrTick=%d\n",
531 "would send an interrupt now, but there's already pending\n");
536 DPRINTF(EthernetIntr,
"posting interrupt\n");
556 DPRINTF(EthernetIntr,
"clearing cchip interrupt\n");
567 uint32_t changed =
regs.Config ^ newconf;
571 regs.Config = newconf;
573 if ((changed & Regs::Config_IntEn)) {
576 if (
regs.IntrStatus &
regs.IntrMask)
583 if ((changed & Regs::Config_TxEn)) {
589 if ((changed & Regs::Config_RxEn)) {
599 if (
command & Regs::Command_Intr)
602 if (
command & Regs::Command_Reset)
609 using namespace Regs;
615 regs.Config |= Config_RxThread;
617 regs.Config |= Config_TxThread;
619 regs.Config |= Config_RSS;
621 regs.Config |= Config_ZeroCopy;
623 regs.Config |= Config_DelayCopy;
624 if (
params()->virtual_addr)
625 regs.Config |= Config_Vaddr;
628 panic(
"Can't delay copy and zero copy");
630 regs.IntrMask = Intr_Soft | Intr_RxHigh | Intr_RxPacket | Intr_TxLow;
634 regs.ZeroCopyMark =
params()->zero_copy_threshold;
641 regs.RxFifoHigh =
params()->rx_fifo_threshold;
642 regs.TxFifoHigh =
params()->tx_fifo_high_mark;
645 if (
regs.RxMaxCopy <
regs.ZeroCopyMark)
646 panic(
"Must be able to copy at least as many bytes as the threshold");
648 if (
regs.ZeroCopySize >=
regs.ZeroCopyMark)
649 panic(
"The number of bytes to copy must be less than the threshold");
672 for (
int i = 0;
i < size; ++
i)
681 DPRINTF(EthernetDMA,
"end rx dma write paddr=%#x len=%d\n",
697 DPRINTF(EthernetSM,
"rxKick: rxState=%s (rxFifo.size=%d)\n",
701 DPRINTF(EthernetSM,
"rxKick: exiting, can't run till %d\n",
715 DPRINTF(EthernetSM,
"processing rxState=%s\n",
720 "processing rxState=%s for vnic %d (rxunique %d)\n",
729 for (
int i = 0;
i < size; ++
i) {
731 bool busy = Regs::get_RxDone_Busy(vn->
RxDone);
747 "vnic %d %s (rxunique %d), packet %d, slack %d\n",
753 DPRINTF(EthernetSM,
"vnic %d unmapped (rxunique %d)\n",
765 panic(
"continuing vnic without packet\n");
768 "continue processing for vnic %d (rxunique %d)\n",
785 DPRINTF(EthernetSM,
"receive waiting for data. Nothing to do.\n");
790 panic(
"Not idle, but nothing to do!");
799 "processing new packet for vnic %d (rxunique %d)\n",
814 DPRINTF(Ethernet,
"ID is %d\n",
ip->id());
818 DPRINTF(EthernetCksum,
"Rx IP Checksum Error\n");
825 "Src Port=%d, Dest Port=%d, Seq=%d, Ack=%d\n",
831 DPRINTF(EthernetCksum,
"Rx TCP Checksum Error\n");
837 if (
cksum(udp) != 0) {
838 DPRINTF(EthernetCksum,
"Rx UDP Checksum Error\n");
859 if ((Regs::get_Config_ZeroCopy(
regs.Config) ||
860 Regs::get_Config_DelayCopy(
regs.Config)) &&
861 !Regs::get_RxData_NoDelay(vnic->
RxData) &&
rxLow) {
876 DPRINTF(EthernetSM,
"receive machine still copying\n");
881 vnic->
RxDone |= Regs::RxDone_Complete;
892 "rxKick: packet complete on vnic %d (rxunique %d)\n",
903 vnic->
RxDone |= Regs::RxDone_More;
907 "rxKick: packet not complete on vnic %d (rxunique %d): "
930 panic(
"Invalid rxState!");
933 DPRINTF(EthernetSM,
"entering next rxState=%s\n",
942 DPRINTF(EthernetSM,
"rx state machine exited rxState=%s\n",
951 DPRINTF(EthernetDMA,
"tx dma read paddr=%#x len=%d\n",
966 DPRINTF(Ethernet,
"nothing to transmit\n");
973 DPRINTF(Ethernet,
"Packet Transmit: failed txFifo available %d\n",
983 DPRINTF(Ethernet,
"ID is %d\n",
ip->id());
987 "Src Port=%d, Dest Port=%d, Seq=%d, Ack=%d\n",
995 DDUMP(EthernetData, packet->data, packet->length);
999 DPRINTF(Ethernet,
"Packet Transmit: successful txFifo Available %d\n",
1002 interrupts = Regs::Intr_TxPacket;
1004 interrupts |= Regs::Intr_TxLow;
1012 DPRINTF(EthernetSM,
"txKick: txState=%s (txFifo.size=%d)\n",
1016 DPRINTF(EthernetSM,
"txKick: exiting, can't run till %d\n",
1030 assert(Regs::get_TxDone_Busy(vnic->
TxDone));
1033 txPacket = make_shared<EthPacketData>(16384);
1038 Regs::get_TxData_Len(vnic->
TxData)) {
1039 DPRINTF(EthernetSM,
"transmit fifo full. Nothing to do.\n");
1059 DPRINTF(EthernetSM,
"transmit machine still copying\n");
1066 if ((vnic->
TxData & Regs::TxData_More)) {
1074 if ((vnic->
TxData & Regs::TxData_Checksum)) {
1110 panic(
"Invalid txState!");
1113 DPRINTF(EthernetSM,
"entering next txState=%s\n",
1122 DPRINTF(EthernetSM,
"tx state machine exited txState=%s\n",
1130 DPRINTF(Ethernet,
"transfer complete: txFifo empty...nothing to do\n");
1134 DPRINTF(Ethernet,
"transfer complete: data in txFifo...schedule xmit\n");
1142 if (!Regs::get_Config_Filter(
regs.Config))
1145 panic(
"receive filter not implemented\n");
1156 DPRINTF(Ethernet,
"Receiving packet from wire, rxFifo Available is %d\n",
1160 DPRINTF(Ethernet,
"receive disabled...packet dropped\n");
1165 DPRINTF(Ethernet,
"packet filtered...dropped\n");
1174 "packet will not fit in receive buffer...packet dropped\n");
1218 Tick intrEventTick = 0;
1241 if (intrEventTick) {
1257 panic(
"can't serialize with an in flight dma request rxState=%s",
1261 panic(
"can't serialize with an in flight dma request txState=%s",
1278 for (
int i = 0;
i < virtualRegsSize; ++
i) {
1289 if (rxPacketExists) {
1315 VirtualList::const_iterator
i, end;
1318 int rxListSize =
count;
1323 int rxBusySize =
count;
1328 int txListSize =
count;
1347 bool txPacketExists =
txPacket !=
nullptr;
1349 if (txPacketExists) {
1386 for (
int i = 0;
i < rxListSize; ++
i) {
1395 for (
int i = 0;
i < rxBusySize; ++
i) {
1404 for (
int i = 0;
i < txListSize; ++
i) {
1438 bool txPacketExists;
1441 if (txPacketExists) {
1442 txPacket = make_shared<EthPacketData>(16384);
1454 int virtualRegsSize;
1458 for (
int i = 0;
i < virtualRegsSize; ++
i) {
1470 bool rxPacketExists;
1472 if (rxPacketExists) {
1503 SinicParams::create()
int countPacketsBefore(const_iterator i) const
static const int VirtualMask
PacketFifo::iterator rxIndex
bool scheduled() const
Determine if the current event is scheduled.
bool push(EthPacketPtr ptr)
#define LL(N)
int64_t constant
@ Running
Running normally.
void serialize(const std::string &base, CheckpointOut &cp) const
Serialization stuff.
#define UNSERIALIZE_SCALAR(scalar)
EventFunctionWrapper rxDmaEvent
Stats::Scalar txTcpChecksums
void unserialize(const std::string &base, CheckpointIn &cp)
void reschedule(Event &event, Tick when, bool always=false)
void cpuIntrPost(Tick when)
void regStats() override
Callback to set stat parameters.
virtual void drainResume() override
Resume execution after a successful drain.
int ContextID
Globally unique thread context ID.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Tick read(PacketPtr pkt) override
Memory Interface.
Tick write(PacketPtr pkt) override
IPR read of device register.
uint64_t Tick
Tick count type.
Stats::Scalar rxTcpChecksums
struct Sinic::Device::@93 regs
device register file
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
PCIConfig config
The current config space.
RequestPtr req
A pointer to the original request.
Stats::Scalar rxUdpChecksums
EventFunctionWrapper txEvent
void changeConfig(uint32_t newconfig)
device configuration
const Params * params() const
const char * RxStateStrings[]
Tick when() const
Get the time that the event is scheduled.
void devIntrChangeMask(uint32_t newmask)
void paramOut(CheckpointOut &cp, const string &name, ExtMachInst const &machInst)
Stats::Scalar rxIpChecksums
virtual void resetStats()
Callback to reset stats.
static const int VirtualShift
virtual void drainResume()
Resume execution after a successful drain.
Stats::Scalar txIpChecksums
void dmaRead(Addr addr, int size, Event *event, uint8_t *data, uint32_t sid, uint32_t ssid, Tick delay=0)
void prepareIO(ContextID cpu, int index)
void schedule(Event &event, Tick when)
uint32_t BARSize[6]
The size of the BARs.
void dmaWrite(Addr addr, int size, Event *event, uint8_t *data, uint32_t sid, uint32_t ssid, Tick delay=0)
void devIntrClear(uint32_t interrupts=Regs::Intr_All)
Stats::Formula avgVnicDistance
void resetStats() override
Callback to reset stats.
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Ports are used to interface objects to each other.
const char * TxStateStrings[]
RxState
Receive State Machine States.
const Regs::Info & regInfo(Addr daddr)
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
void regStats()
Callback to set stat parameters.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
bool cpuIntrPending() const
Stats::Scalar txUdpChecksums
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Port & getPort(const std::string &if_name, PortID idx=InvalidPortID) override
Get a port with a given name and index.
Stats::Scalar totalVnicDistance
Statistics.
void devIntrPost(uint32_t interrupts)
Interrupt management.
uint16_t cksum(const IpPtr &ptr)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
TxState
Transmit State Machine states.
void prepareWrite(ContextID cpu, int index)
fifo_list::iterator iterator
Derived & name(const std::string &name)
Set the name and marks this stat to print at the end of simulation.
void rxDmaDone()
DMA parameters.
void prepareRead(ContextID cpu, int index)
const std::string & name()
#define SERIALIZE_SCALAR(scalar)
void transmit()
Retransmit event.
#define DDUMP(x, data, count)
DPRINTF is a debugging trace facility that allows one to selectively enable tracing statements.
bool regValid(Addr daddr)
DrainState drainState() const
Return the current drain state of an object.
EventFunctionWrapper * intrEvent
virtual const std::string name() const
bool rxFilter(const EthPacketPtr &packet)
receive address filter
uint64_t & regData64(Addr daddr)
std::shared_ptr< EthPacketData > EthPacketPtr
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
bool recvPacket(EthPacketPtr packet)
device ethernet interface
EventFunctionWrapper txDmaEvent
Overload hash function for BasicBlockRange type.
uint32_t & regData32(Addr daddr)
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void command(uint32_t command)
Stats::Scalar maxVnicDistance
Stats::Scalar numVnicDistance
void paramIn(CheckpointIn &cp, const string &name, ExtMachInst &machInst)
void squash()
Squash the current event.
Cycles is a wrapper class for representing cycle counts, i.e.
void setLE(T v)
Set the value in the data pointer to v as little endian.
std::ostream CheckpointOut
bool sendPacket(EthPacketPtr packet)
Dummy class to keep the Python class hierarchy in sync with the C++ object hierarchy.
void serialize(CheckpointOut &cp) const override
Serialization stuff.
Addr BARAddrs[6]
The current address mapping of the BARs.
void sendRangeChange() const
Called by the owner to send a range change.
Derived & desc(const std::string &_desc)
Set the description and marks this stat to print at the end of simulation.
std::string csprintf(const char *format, const Args &...args)
int countPacketsAfter(const_iterator i) const
PacketFifo::iterator rxFifoPtr
Addr pciToDma(Addr pci_addr) const
#define panic(...)
This implements a cprintf based panic() function.
PioPort< PioDevice > pioPort
The pioPort that handles the requests for us and provides us requests that it sees.
Tick curTick()
The current simulated tick.
Generated on Wed Sep 30 2020 14:02:11 for gem5 by doxygen 1.8.17