Gabe Black has uploaded this change for review. (
https://gem5-review.googlesource.com/3644
Change subject: dev: Rename EtherTap to be EtherTapStub.
......................................................................
dev: Rename EtherTap to be EtherTapStub.
The EtherTap object is going to be reworked so that it connects to a tap
device directly, but it's worthwhile to still be able to use the m5tap
utility to send/receive packets on systems which don't support tap but do
support the pcap API. It can also be used to replay ethernet frames, to
capture the ethernet frames coming from gem5 for analysis, to
programmatically consume and/or generate the frames, or even to forward
them to/from a remote system.
Change-Id: Ic7bd763d86cd913ac373dd10a8d6d1fc6b35f95a
---
M src/dev/net/Ethernet.py
M src/dev/net/ethertap.cc
M src/dev/net/ethertap.hh
3 files changed, 42 insertions(+), 39 deletions(-)
diff --git a/src/dev/net/Ethernet.py b/src/dev/net/Ethernet.py
index da1e572..1f8e752 100644
--- a/src/dev/net/Ethernet.py
+++ b/src/dev/net/Ethernet.py
@@ -95,13 +95,13 @@
delay_var = Param.Latency('0ns', "packet transmit delay variability")
time_to_live = Param.Latency('10ms', "time to live of MAC address
maping")
-class EtherTap(EtherObject):
- type = 'EtherTap'
+class EtherTapStub(EtherObject):
+ type = 'EtherTapStub'
cxx_header = "dev/net/ethertap.hh"
bufsz = Param.Int(10000, "tap buffer size")
dump = Param.EtherDump(NULL, "dump object")
- port = Param.UInt16(3500, "tap port")
- tap = SlavePort("Ethernet interface")
+ port = Param.UInt16(3500, "Port helper should send packets to")
+ tap = SlavePort("Ethernet interface to gem5's network")
class EtherDump(SimObject):
type = 'EtherDump'
diff --git a/src/dev/net/ethertap.cc b/src/dev/net/ethertap.cc
index e09b7a3..e7b9289 100644
--- a/src/dev/net/ethertap.cc
+++ b/src/dev/net/ethertap.cc
@@ -80,11 +80,11 @@
protected:
ListenSocket listener;
- EtherTap *tap;
+ EtherTapStub *tap;
int port;
public:
- TapListener(EtherTap *t, int p)
+ TapListener(EtherTapStub *t, int p)
: event(NULL), tap(t), port(p) {}
~TapListener() { if (event) delete event; }
@@ -126,20 +126,20 @@
class TapEvent : public PollEvent
{
protected:
- EtherTap *tap;
+ EtherTapStub *tap;
public:
- TapEvent(EtherTap *_tap, int fd, int e)
+ TapEvent(EtherTapStub *_tap, int fd, int e)
: PollEvent(fd, e), tap(_tap) {}
virtual void process(int revent) { tap->process(revent); }
};
-EtherTap::EtherTap(const Params *p)
+EtherTapStub::EtherTapStub(const Params *p)
: EtherObject(p), event(NULL), socket(-1), buflen(p->bufsz),
dump(p->dump),
interface(NULL), txEvent(this)
{
if (ListenSocket::allDisabled())
- fatal("All listeners are disabled! EtherTap can't work!");
+ fatal("All listeners are disabled! EtherTapStub can't work!");
buffer = new char[buflen];
listener = new TapListener(this, p->port);
@@ -147,7 +147,7 @@
interface = new EtherTapInt(name() + ".interface", this);
}
-EtherTap::~EtherTap()
+EtherTapStub::~EtherTapStub()
{
if (event)
delete event;
@@ -159,7 +159,7 @@
}
void
-EtherTap::attach(int fd)
+EtherTapStub::attach(int fd)
{
if (socket != -1)
close(fd);
@@ -167,15 +167,15 @@
buffer_offset = 0;
data_len = 0;
socket = fd;
- DPRINTF(Ethernet, "EtherTap attached\n");
+ DPRINTF(Ethernet, "EtherTapStub attached\n");
event = new TapEvent(this, socket, POLLIN|POLLERR);
pollQueue.schedule(event);
}
void
-EtherTap::detach()
+EtherTapStub::detach()
{
- DPRINTF(Ethernet, "EtherTap detached\n");
+ DPRINTF(Ethernet, "EtherTapStub detached\n");
delete event;
event = 0;
close(socket);
@@ -183,12 +183,12 @@
}
bool
-EtherTap::recvPacket(EthPacketPtr packet)
+EtherTapStub::recvPacket(EthPacketPtr packet)
{
if (dump)
dump->dump(packet);
- DPRINTF(Ethernet, "EtherTap output len=%d\n", packet->length);
+ DPRINTF(Ethernet, "EtherTapStub output len=%d\n", packet->length);
DDUMP(EthernetData, packet->data, packet->length);
uint32_t len = htonl(packet->length);
ssize_t ret = write(socket, &len, sizeof(len));
@@ -204,11 +204,11 @@
}
void
-EtherTap::sendDone()
+EtherTapStub::sendDone()
{}
void
-EtherTap::process(int revent)
+EtherTapStub::process(int revent)
{
if (revent & POLLERR) {
detach();
@@ -250,7 +250,7 @@
} else
data_len = 0;
- DPRINTF(Ethernet, "EtherTap input len=%d\n", packet->length);
+ DPRINTF(Ethernet, "EtherTapStub input len=%d\n", packet->length);
DDUMP(EthernetData, packet->data, packet->length);
if (!interface->sendPacket(packet)) {
DPRINTF(Ethernet, "bus busy...buffer for retransmission\n");
@@ -264,7 +264,7 @@
}
void
-EtherTap::retransmit()
+EtherTapStub::retransmit()
{
if (packetBuffer.empty())
return;
@@ -273,7 +273,7 @@
if (interface->sendPacket(packet)) {
if (dump)
dump->dump(packet);
- DPRINTF(Ethernet, "EtherTap retransmit\n");
+ DPRINTF(Ethernet, "EtherTapStub retransmit\n");
packetBuffer.front() = NULL;
packetBuffer.pop();
}
@@ -283,7 +283,7 @@
}
EtherInt*
-EtherTap::getEthPort(const std::string &if_name, int idx)
+EtherTapStub::getEthPort(const std::string &if_name, int idx)
{
if (if_name == "tap") {
if (interface->getPeer())
@@ -297,7 +297,7 @@
//=====================================================================
void
-EtherTap::serialize(CheckpointOut &cp) const
+EtherTapStub::serialize(CheckpointOut &cp) const
{
SERIALIZE_SCALAR(socket);
SERIALIZE_SCALAR(buflen);
@@ -318,7 +318,7 @@
}
void
-EtherTap::unserialize(CheckpointIn &cp)
+EtherTapStub::unserialize(CheckpointIn &cp)
{
UNSERIALIZE_SCALAR(socket);
UNSERIALIZE_SCALAR(buflen);
@@ -342,8 +342,8 @@
//=====================================================================
-EtherTap *
-EtherTapParams::create()
+EtherTapStub *
+EtherTapStubParams::create()
{
- return new EtherTap(this);
+ return new EtherTapStub(this);
}
diff --git a/src/dev/net/ethertap.hh b/src/dev/net/ethertap.hh
index b27b80f..b4af697 100644
--- a/src/dev/net/ethertap.hh
+++ b/src/dev/net/ethertap.hh
@@ -42,7 +42,7 @@
#include "dev/net/etherint.hh"
#include "dev/net/etherobject.hh"
#include "dev/net/etherpkt.hh"
-#include "params/EtherTap.hh"
+#include "params/EtherTapStub.hh"
#include "sim/eventq.hh"
#include "sim/sim_object.hh"
@@ -51,9 +51,12 @@
class EtherTapInt;
/*
- * Interface to connect a simulated ethernet device to the real world
+ * Interface to connect a simulated ethernet device to the real world. An
+ * external helper program bridges between this object's TCP port and a
+ * source/sink for Ethernet frames. Each frame going in either direction is
+ * prepended with the frame's length in a 32 bit integer in network byte
order.
*/
-class EtherTap : public EtherObject
+class EtherTapStub : public EtherObject
{
protected:
friend class TapEvent;
@@ -87,22 +90,22 @@
class TxEvent : public Event
{
protected:
- EtherTap *tap;
+ EtherTapStub *tap;
public:
- TxEvent(EtherTap *_tap) : tap(_tap) {}
+ TxEvent(EtherTapStub *_tap) : tap(_tap) {}
void process() { tap->retransmit(); }
virtual const char *description() const
- { return "EtherTap retransmit"; }
+ { return "EtherTapStub retransmit"; }
};
friend class TxEvent;
TxEvent txEvent;
public:
- typedef EtherTapParams Params;
- EtherTap(const Params *p);
- virtual ~EtherTap();
+ typedef EtherTapStubParams Params;
+ EtherTapStub(const Params *p);
+ virtual ~EtherTapStub();
const Params *
params() const
@@ -122,9 +125,9 @@
class EtherTapInt : public EtherInt
{
private:
- EtherTap *tap;
+ EtherTapStub *tap;
public:
- EtherTapInt(const std::string &name, EtherTap *t)
+ EtherTapInt(const std::string &name, EtherTapStub *t)
: EtherInt(name), tap(t)
{ }
--
To view, visit https://gem5-review.googlesource.com/3644
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic7bd763d86cd913ac373dd10a8d6d1fc6b35f95a
Gerrit-Change-Number: 3644
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev