from m5.proxy import *
from m5.objects.PciDevice import PciDevice
-class EtherObject(SimObject):
- type = 'EtherObject'
- abstract = True
- cxx_header = "dev/net/etherobject.hh"
-
-class EtherLink(EtherObject):
+class EtherLink(SimObject):
type = 'EtherLink'
cxx_header = "dev/net/etherlink.hh"
+ cxx_extra_bases = [ "EtherObject" ]
int0 = SlavePort("interface 0")
int1 = SlavePort("interface 1")
delay = Param.Latency('0us', "packet transmit delay")
speed = Param.NetworkBandwidth('1Gbps', "link speed")
dump = Param.EtherDump(NULL, "dump object")
-class DistEtherLink(EtherObject):
+class DistEtherLink(SimObject):
type = 'DistEtherLink'
cxx_header = "dev/net/dist_etherlink.hh"
+ cxx_extra_bases = [ "EtherObject" ]
int0 = SlavePort("interface 0")
delay = Param.Latency('0us', "packet transmit delay")
delay_var = Param.Latency('0ns', "packet transmit delay variability")
dist_sync_on_pseudo_op = Param.Bool(False, "Start sync with pseudo_op")
num_nodes = Param.UInt32('2', "Number of simulate nodes")
-class EtherBus(EtherObject):
+class EtherBus(SimObject):
type = 'EtherBus'
cxx_header = "dev/net/etherbus.hh"
+ cxx_extra_bases = [ "EtherObject" ]
loopback = Param.Bool(True, "send packet back to the sending interface")
dump = Param.EtherDump(NULL, "dump object")
speed = Param.NetworkBandwidth('100Mbps', "bus speed in bits per second")
-class EtherSwitch(EtherObject):
+class EtherSwitch(SimObject):
type = 'EtherSwitch'
cxx_header = "dev/net/etherswitch.hh"
+ cxx_extra_bases = [ "EtherObject" ]
dump = Param.EtherDump(NULL, "dump object")
fabric_speed = Param.NetworkBandwidth('10Gbps', "switch fabric speed in bits "
"per second")
delay_var = Param.Latency('0ns', "packet transmit delay variability")
time_to_live = Param.Latency('10ms', "time to live of MAC address maping")
-class EtherTapBase(EtherObject):
+class EtherTapBase(SimObject):
type = 'EtherTapBase'
abstract = True
cxx_header = "dev/net/ethertap.hh"
+ cxx_extra_bases = [ "EtherObject" ]
bufsz = Param.Int(10000, "tap buffer size")
dump = Param.EtherDump(NULL, "dump object")
tap = SlavePort("Ethernet interface to connect to gem5's network")
Import('*')
SimObject('Ethernet.py')
+Source('python.cc', add_tags='python')
# Basic Ethernet infrastructure
Source('etherbus.cc')
using namespace std;
DistEtherLink::DistEtherLink(const Params *p)
- : EtherObject(p), linkDelay(p->delay)
+ : SimObject(p), linkDelay(p->delay)
{
DPRINTF(DistEthernet,"DistEtherLink::DistEtherLink() "
"link delay:%llu ticksPerByte:%f\n", p->delay, p->speed);
#include <iostream>
#include "dev/net/etherlink.hh"
+#include "dev/net/etherobject.hh"
#include "params/DistEtherLink.hh"
class DistIface;
/**
* Model for a fixed bandwidth full duplex ethernet link.
*/
-class DistEtherLink : public EtherObject
+class DistEtherLink : public SimObject, public EtherObject
{
protected:
class LocalIface;
return dynamic_cast<const Params *>(_params);
}
- virtual EtherInt *getEthPort(const std::string &if_name,
- int idx) override;
+ EtherInt *getEthPort(const std::string &if_name, int idx) override;
virtual void init() override;
virtual void startup() override;
using namespace std;
EtherBus::EtherBus(const Params *p)
- : EtherObject(p), ticksPerByte(p->speed), loopback(p->loopback),
+ : SimObject(p), ticksPerByte(p->speed), loopback(p->loopback),
event([this]{ txDone(); }, "ethernet bus completion"),
sender(0), dump(p->dump)
{
class EtherDump;
class EtherInt;
-class EtherBus : public EtherObject
+class EtherBus : public SimObject, public EtherObject
{
protected:
typedef std::list<EtherInt *> devlist_t;
void reg(EtherInt *dev);
bool busy() const { return (bool)packet; }
bool send(EtherInt *sender, EthPacketPtr &packet);
- virtual EtherInt *getEthPort(const std::string &if_name, int idx);
+ EtherInt *getEthPort(const std::string &if_name, int idx) override;
};
#endif // __DEV_NET_ETHERBUS_HH__
using namespace std;
EtherLink::EtherLink(const Params *p)
- : EtherObject(p)
+ : SimObject(p)
{
link[0] = new Link(name() + ".link0", this, 0, p->speed,
p->delay, p->delay_var, p->dump);
/*
* Model for a fixed bandwidth full duplex ethernet link
*/
-class EtherLink : public EtherObject
+class EtherLink : public EtherObject, public SimObject
{
protected:
class Interface;
/*
* Copyright (c) 2007 The Regents of The University of Michigan
+ * Copyright 2019 Google, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Ali Saidi
+ * Gabe Black
*/
/**
#ifndef __DEV_NET_ETHEROBJECT_HH__
#define __DEV_NET_ETHEROBJECT_HH__
-#include "params/EtherObject.hh"
-#include "sim/sim_object.hh"
+#include <string>
class EtherInt;
/**
- * The base EtherObject class, allows for an accesor function to a
- * simobj that returns the Port.
+ * The base EtherObject interface.
*/
-class EtherObject : public SimObject
+class EtherObject
{
public:
- typedef EtherObjectParams Params;
- EtherObject(const Params *params)
- : SimObject(params) {}
-
- const Params *
- params() const
- {
- return dynamic_cast<const Params *>(_params);
- }
-
- public:
- /** Additional function to return the Port of a memory object. */
- virtual EtherInt *getEthPort(const std::string &if_name, int idx = -1) = 0;
-
+ virtual EtherInt *getEthPort(const std::string &if_name, int idx=-1) = 0;
};
#endif // __DEV_NET_ETHEROBJECT_HH__
using namespace std;
EtherSwitch::EtherSwitch(const Params *p)
- : EtherObject(p), ttl(p->time_to_live)
+ : SimObject(p), ttl(p->time_to_live)
{
for (int i = 0; i < p->port_interface_connection_count; ++i) {
std::string interfaceName = csprintf("%s.interface%d", name(), i);
#include "dev/net/pktfifo.hh"
#include "params/EtherSwitch.hh"
#include "sim/eventq.hh"
+#include "sim/sim_object.hh"
-class EtherSwitch : public EtherObject
+class EtherSwitch : public SimObject, public EtherObject
{
public:
typedef EtherSwitchParams Params;
};
EtherTapBase::EtherTapBase(const Params *p)
- : EtherObject(p), buflen(p->bufsz), dump(p->dump), event(NULL),
+ : SimObject(p), buflen(p->bufsz), dump(p->dump), event(NULL),
interface(NULL),
txEvent([this]{ retransmit(); }, "EtherTapBase retransmit")
{
class TapEvent;
class EtherTapInt;
-class EtherTapBase : public EtherObject
+class EtherTapBase : public SimObject, public EtherObject
{
public:
typedef EtherTapBaseParams Params;
--- /dev/null
+/*
+ * Copyright 2019 Google, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Authors: Gabe Black
+ */
+
+#include "python/pybind11/pybind.hh"
+
+#include "dev/net/etherobject.hh"
+#include "sim/init.hh"
+
+namespace
+{
+
+void
+ethernet_pybind(pybind11::module &m_internal)
+{
+ pybind11::module m = m_internal.def_submodule("ethernet");
+ pybind11::class_<
+ EtherObject, std::unique_ptr<EtherObject, pybind11::nodelete>>(
+ m, "EtherObject");
+}
+EmbeddedPyBind embed_("ethernet", ðernet_pybind);
+
+} // anonymous namespace