diff options
Diffstat (limited to 'src/dev/net')
-rw-r--r-- | src/dev/net/Ethernet.py | 6 | ||||
-rw-r--r-- | src/dev/net/SConscript | 1 | ||||
-rw-r--r-- | src/dev/net/dist_etherlink.cc | 14 | ||||
-rw-r--r-- | src/dev/net/dist_etherlink.hh | 6 | ||||
-rw-r--r-- | src/dev/net/etherbus.cc | 4 | ||||
-rw-r--r-- | src/dev/net/etherbus.hh | 6 | ||||
-rw-r--r-- | src/dev/net/etherdevice.hh | 3 | ||||
-rw-r--r-- | src/dev/net/etherlink.cc | 16 | ||||
-rw-r--r-- | src/dev/net/etherlink.hh | 6 | ||||
-rw-r--r-- | src/dev/net/etherobject.hh | 54 | ||||
-rw-r--r-- | src/dev/net/etherswitch.cc | 15 | ||||
-rw-r--r-- | src/dev/net/etherswitch.hh | 6 | ||||
-rw-r--r-- | src/dev/net/ethertap.cc | 13 | ||||
-rw-r--r-- | src/dev/net/ethertap.hh | 6 | ||||
-rw-r--r-- | src/dev/net/i8254xGBe.cc | 14 | ||||
-rw-r--r-- | src/dev/net/i8254xGBe.hh | 3 | ||||
-rw-r--r-- | src/dev/net/ns_gige.cc | 13 | ||||
-rw-r--r-- | src/dev/net/ns_gige.hh | 3 | ||||
-rw-r--r-- | src/dev/net/python.cc | 48 | ||||
-rw-r--r-- | src/dev/net/sinic.cc | 14 | ||||
-rw-r--r-- | src/dev/net/sinic.hh | 3 |
21 files changed, 61 insertions, 193 deletions
diff --git a/src/dev/net/Ethernet.py b/src/dev/net/Ethernet.py index 0cf37e230..7ef83744c 100644 --- a/src/dev/net/Ethernet.py +++ b/src/dev/net/Ethernet.py @@ -47,7 +47,6 @@ from m5.objects.PciDevice import PciDevice 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") @@ -58,7 +57,6 @@ class EtherLink(SimObject): 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") @@ -77,7 +75,6 @@ class DistEtherLink(SimObject): 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") @@ -85,7 +82,6 @@ class EtherBus(SimObject): 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") @@ -99,7 +95,6 @@ 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") @@ -127,7 +122,6 @@ class EtherDevice(PciDevice): type = 'EtherDevice' abstract = True cxx_header = "dev/net/etherdevice.hh" - cxx_extra_bases = [ "EtherObject" ] interface = MasterPort("Ethernet Interface") class IGbE(EtherDevice): diff --git a/src/dev/net/SConscript b/src/dev/net/SConscript index 0bb6bbf01..908dd44e6 100644 --- a/src/dev/net/SConscript +++ b/src/dev/net/SConscript @@ -45,7 +45,6 @@ Import('*') SimObject('Ethernet.py') -Source('python.cc', add_tags='python') # Basic Ethernet infrastructure Source('etherbus.cc') diff --git a/src/dev/net/dist_etherlink.cc b/src/dev/net/dist_etherlink.cc index 477ad61b3..0cefb90fd 100644 --- a/src/dev/net/dist_etherlink.cc +++ b/src/dev/net/dist_etherlink.cc @@ -61,7 +61,6 @@ #include "dev/net/etherdump.hh" #include "dev/net/etherint.hh" #include "dev/net/etherlink.hh" -#include "dev/net/etherobject.hh" #include "dev/net/etherpkt.hh" #include "dev/net/tcp_iface.hh" #include "params/EtherLink.hh" @@ -109,15 +108,12 @@ DistEtherLink::~DistEtherLink() delete distIface; } -EtherInt* -DistEtherLink::getEthPort(const std::string &if_name, int idx) +Port & +DistEtherLink::getPort(const std::string &if_name, PortID idx) { - if (if_name != "int0") { - return nullptr; - } else { - panic_if(localIface->getPeer(), "interface already connected to"); - } - return localIface; + if (if_name == "int0") + return *localIface; + return SimObject::getPort(if_name, idx); } void diff --git a/src/dev/net/dist_etherlink.hh b/src/dev/net/dist_etherlink.hh index 51852a519..7d00602c9 100644 --- a/src/dev/net/dist_etherlink.hh +++ b/src/dev/net/dist_etherlink.hh @@ -53,7 +53,6 @@ #include <iostream> #include "dev/net/etherlink.hh" -#include "dev/net/etherobject.hh" #include "params/DistEtherLink.hh" class DistIface; @@ -62,7 +61,7 @@ class EthPacketData; /** * Model for a fixed bandwidth full duplex ethernet link. */ -class DistEtherLink : public SimObject, public EtherObject +class DistEtherLink : public SimObject { protected: class LocalIface; @@ -224,7 +223,8 @@ class DistEtherLink : public SimObject, public EtherObject return dynamic_cast<const Params *>(_params); } - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; virtual void init() override; virtual void startup() override; diff --git a/src/dev/net/etherbus.cc b/src/dev/net/etherbus.cc index dee772cc0..fa49b9900 100644 --- a/src/dev/net/etherbus.cc +++ b/src/dev/net/etherbus.cc @@ -81,8 +81,8 @@ EtherBus::txDone() packet = 0; } -EtherInt* -EtherBus::getEthPort(const std::string &if_name, int idx) +Port & +EtherBus::getPort(const std::string &if_name, PortID idx) { panic("Etherbus doesn't work\n"); } diff --git a/src/dev/net/etherbus.hh b/src/dev/net/etherbus.hh index 8c1260fc5..24333b53d 100644 --- a/src/dev/net/etherbus.hh +++ b/src/dev/net/etherbus.hh @@ -35,7 +35,6 @@ #ifndef __DEV_NET_ETHERBUS_HH__ #define __DEV_NET_ETHERBUS_HH__ -#include "dev/net/etherobject.hh" #include "dev/net/etherpkt.hh" #include "params/EtherBus.hh" #include "sim/eventq.hh" @@ -43,7 +42,7 @@ class EtherDump; class EtherInt; -class EtherBus : public SimObject, public EtherObject +class EtherBus : public SimObject { protected: typedef std::list<EtherInt *> devlist_t; @@ -72,7 +71,8 @@ class EtherBus : public SimObject, public EtherObject void reg(EtherInt *dev); bool busy() const { return (bool)packet; } bool send(EtherInt *sender, EthPacketPtr &packet); - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; }; #endif // __DEV_NET_ETHERBUS_HH__ diff --git a/src/dev/net/etherdevice.hh b/src/dev/net/etherdevice.hh index 7101ec80a..7de4d82a4 100644 --- a/src/dev/net/etherdevice.hh +++ b/src/dev/net/etherdevice.hh @@ -37,7 +37,6 @@ #define __DEV_NET_ETHERDEVICE_HH__ #include "base/statistics.hh" -#include "dev/net/etherobject.hh" #include "dev/pci/device.hh" #include "params/EtherDevBase.hh" #include "params/EtherDevice.hh" @@ -45,7 +44,7 @@ class EtherInt; -class EtherDevice : public PciDevice, public EtherObject +class EtherDevice : public PciDevice { public: typedef EtherDeviceParams Params; diff --git a/src/dev/net/etherlink.cc b/src/dev/net/etherlink.cc index b160e29d5..448bb8856 100644 --- a/src/dev/net/etherlink.cc +++ b/src/dev/net/etherlink.cc @@ -88,20 +88,14 @@ EtherLink::~EtherLink() delete interface[1]; } -EtherInt* -EtherLink::getEthPort(const std::string &if_name, int idx) +Port & +EtherLink::getPort(const std::string &if_name, PortID idx) { - Interface *i; if (if_name == "int0") - i = interface[0]; + return *interface[0]; else if (if_name == "int1") - i = interface[1]; - else - return NULL; - if (i->getPeer()) - panic("interface already connected to\n"); - - return i; + return *interface[1]; + return SimObject::getPort(if_name, idx); } diff --git a/src/dev/net/etherlink.hh b/src/dev/net/etherlink.hh index 37fa16859..9f12ca461 100644 --- a/src/dev/net/etherlink.hh +++ b/src/dev/net/etherlink.hh @@ -51,7 +51,6 @@ #include "base/types.hh" #include "dev/net/etherint.hh" -#include "dev/net/etherobject.hh" #include "dev/net/etherpkt.hh" #include "params/EtherLink.hh" #include "sim/eventq.hh" @@ -62,7 +61,7 @@ class Checkpoint; /* * Model for a fixed bandwidth full duplex ethernet link */ -class EtherLink : public EtherObject, public SimObject +class EtherLink : public SimObject { protected: class Interface; @@ -152,7 +151,8 @@ class EtherLink : public EtherObject, public SimObject return dynamic_cast<const Params *>(_params); } - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; void serialize(CheckpointOut &cp) const override; void unserialize(CheckpointIn &cp) override; diff --git a/src/dev/net/etherobject.hh b/src/dev/net/etherobject.hh deleted file mode 100644 index 638c50667..000000000 --- a/src/dev/net/etherobject.hh +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 - * 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: Ali Saidi - * Gabe Black - */ - -/** - * @file - * Base Ethernet Object declaration. - */ - -#ifndef __DEV_NET_ETHEROBJECT_HH__ -#define __DEV_NET_ETHEROBJECT_HH__ - -#include <string> - -class EtherInt; - -/** - * The base EtherObject interface. - */ -class EtherObject -{ - public: - virtual EtherInt *getEthPort(const std::string &if_name, int idx=-1) = 0; -}; - -#endif // __DEV_NET_ETHEROBJECT_HH__ diff --git a/src/dev/net/etherswitch.cc b/src/dev/net/etherswitch.cc index c03b59435..99e0621a2 100644 --- a/src/dev/net/etherswitch.cc +++ b/src/dev/net/etherswitch.cc @@ -62,16 +62,15 @@ EtherSwitch::~EtherSwitch() interfaces.clear(); } -EtherInt* -EtherSwitch::getEthPort(const std::string &if_name, int idx) +Port & +EtherSwitch::getPort(const std::string &if_name, PortID idx) { - if (idx < 0 || idx >= interfaces.size()) - return nullptr; - - Interface *interface = interfaces.at(idx); - panic_if(interface->getPeer(), "interface already connected\n"); + if (if_name == "interface") { + panic_if(idx < 0 || idx >= interfaces.size(), "index out of bounds"); + return *interfaces.at(idx); + } - return interface; + return SimObject::getPort(if_name, idx); } bool diff --git a/src/dev/net/etherswitch.hh b/src/dev/net/etherswitch.hh index 36a0c686a..9b60b8507 100644 --- a/src/dev/net/etherswitch.hh +++ b/src/dev/net/etherswitch.hh @@ -42,14 +42,13 @@ #include "base/inet.hh" #include "dev/net/etherint.hh" #include "dev/net/etherlink.hh" -#include "dev/net/etherobject.hh" #include "dev/net/etherpkt.hh" #include "dev/net/pktfifo.hh" #include "params/EtherSwitch.hh" #include "sim/eventq.hh" #include "sim/sim_object.hh" -class EtherSwitch : public SimObject, public EtherObject +class EtherSwitch : public SimObject { public: typedef EtherSwitchParams Params; @@ -62,7 +61,8 @@ class EtherSwitch : public SimObject, public EtherObject return dynamic_cast<const Params*>(_params); } - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; protected: /** diff --git a/src/dev/net/ethertap.cc b/src/dev/net/ethertap.cc index bf2dc6885..552296d5c 100644 --- a/src/dev/net/ethertap.cc +++ b/src/dev/net/ethertap.cc @@ -159,15 +159,12 @@ EtherTapBase::stopPolling() } -EtherInt* -EtherTapBase::getEthPort(const std::string &if_name, int idx) +Port & +EtherTapBase::getPort(const std::string &if_name, PortID idx) { - if (if_name == "tap") { - if (interface->getPeer()) - panic("Interface already connected to\n"); - return interface; - } - return NULL; + if (if_name == "tap") + return *interface; + return SimObject::getPort(if_name, idx); } bool diff --git a/src/dev/net/ethertap.hh b/src/dev/net/ethertap.hh index 7db73c5b4..5f59a390c 100644 --- a/src/dev/net/ethertap.hh +++ b/src/dev/net/ethertap.hh @@ -41,7 +41,6 @@ #include "base/pollevent.hh" #include "config/use_tuntap.hh" #include "dev/net/etherint.hh" -#include "dev/net/etherobject.hh" #include "dev/net/etherpkt.hh" #if USE_TUNTAP @@ -56,7 +55,7 @@ class TapEvent; class EtherTapInt; -class EtherTapBase : public SimObject, public EtherObject +class EtherTapBase : public SimObject { public: typedef EtherTapBaseParams Params; @@ -101,7 +100,8 @@ class EtherTapBase : public SimObject, public EtherObject EtherTapInt *interface; public: - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; bool recvSimulated(EthPacketPtr packet); void sendSimulated(void *data, size_t len); diff --git a/src/dev/net/i8254xGBe.cc b/src/dev/net/i8254xGBe.cc index 2d55603f1..9d83519df 100644 --- a/src/dev/net/i8254xGBe.cc +++ b/src/dev/net/i8254xGBe.cc @@ -139,16 +139,12 @@ IGbE::init() PciDevice::init(); } -EtherInt* -IGbE::getEthPort(const std::string &if_name, int idx) +Port & +IGbE::getPort(const std::string &if_name, PortID idx) { - - if (if_name == "interface") { - if (etherInt->getPeer()) - panic("Port already connected to\n"); - return etherInt; - } - return NULL; + if (if_name == "interface") + return *etherInt; + return EtherDevice::getPort(if_name, idx); } Tick diff --git a/src/dev/net/i8254xGBe.hh b/src/dev/net/i8254xGBe.hh index 402e61d95..031cb4d91 100644 --- a/src/dev/net/i8254xGBe.hh +++ b/src/dev/net/i8254xGBe.hh @@ -519,7 +519,8 @@ class IGbE : public EtherDevice ~IGbE(); void init() override; - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; Tick lastInterrupt; diff --git a/src/dev/net/ns_gige.cc b/src/dev/net/ns_gige.cc index 1a5adb275..29e886717 100644 --- a/src/dev/net/ns_gige.cc +++ b/src/dev/net/ns_gige.cc @@ -173,15 +173,12 @@ NSGigE::writeConfig(PacketPtr pkt) return configDelay; } -EtherInt* -NSGigE::getEthPort(const std::string &if_name, int idx) +Port & +NSGigE::getPort(const std::string &if_name, PortID idx) { - if (if_name == "interface") { - if (interface->getPeer()) - panic("interface already connected to\n"); - return interface; - } - return NULL; + if (if_name == "interface") + return *interface; + return EtherDevBase::getPort(if_name, idx); } /** diff --git a/src/dev/net/ns_gige.hh b/src/dev/net/ns_gige.hh index f9be02890..5745c3040 100644 --- a/src/dev/net/ns_gige.hh +++ b/src/dev/net/ns_gige.hh @@ -341,7 +341,8 @@ class NSGigE : public EtherDevBase NSGigE(Params *params); ~NSGigE(); - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; Tick writeConfig(PacketPtr pkt) override; diff --git a/src/dev/net/python.cc b/src/dev/net/python.cc deleted file mode 100644 index a012074c1..000000000 --- a/src/dev/net/python.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 diff --git a/src/dev/net/sinic.cc b/src/dev/net/sinic.cc index ce9fbb6a3..8d73d1542 100644 --- a/src/dev/net/sinic.cc +++ b/src/dev/net/sinic.cc @@ -142,16 +142,12 @@ Device::resetStats() _maxVnicDistance = 0; } -EtherInt* -Device::getEthPort(const std::string &if_name, int idx) +Port & +Device::getPort(const std::string &if_name, PortID idx) { - if (if_name == "interface") { - if (interface->getPeer()) - panic("interface already connected to\n"); - - return interface; - } - return NULL; + if (if_name == "interface") + return *interface; + return EtherDevBase::getPort(if_name, idx); } diff --git a/src/dev/net/sinic.hh b/src/dev/net/sinic.hh index 70d22f12d..ab79a5f6f 100644 --- a/src/dev/net/sinic.hh +++ b/src/dev/net/sinic.hh @@ -230,7 +230,8 @@ class Device : public Base public: bool recvPacket(EthPacketPtr packet); void transferDone(); - EtherInt *getEthPort(const std::string &if_name, int idx) override; + Port &getPort(const std::string &if_name, + PortID idx=InvalidPortID) override; /** * DMA parameters |