dev: Use the new Port role mechanism to make an EtherInt Port type.
authorGabe Black <gabeblack@google.com>
Tue, 16 Apr 2019 02:47:28 +0000 (19:47 -0700)
committerGabe Black <gabeblack@google.com>
Wed, 24 Apr 2019 11:00:31 +0000 (11:00 +0000)
This type always uses the same "ETHERNET" role, and all connections are
symmetric and self compatible.

Change-Id: I1d060f8c098d52ae9f65c052f816bc813590ff9c
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18171
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/dev/net/Ethernet.py

index 7ef83744c7742c9511d56c85d59bb6e0c27b441e..2cbadba33445d0a13e2bc7a5eeb08596cab89288 100644 (file)
@@ -44,11 +44,22 @@ from m5.params import *
 from m5.proxy import *
 from m5.objects.PciDevice import PciDevice
 
+ETHERNET_ROLE = 'ETHERNET'
+Port.compat(ETHERNET_ROLE, ETHERNET_ROLE)
+
+class EtherInt(Port):
+    def __init__(self, desc):
+        super(EtherInt, self).__init__(ETHERNET_ROLE, desc)
+
+class VectorEtherInt(VectorPort):
+    def __init__(self, desc):
+        super(VectorEtherInt, self).__init__(ETHERNET_ROLE, desc)
+
 class EtherLink(SimObject):
     type = 'EtherLink'
     cxx_header = "dev/net/etherlink.hh"
-    int0 = SlavePort("interface 0")
-    int1 = SlavePort("interface 1")
+    int0 = EtherInt("interface 0")
+    int1 = EtherInt("interface 1")
     delay = Param.Latency('0us', "packet transmit delay")
     delay_var = Param.Latency('0ns', "packet transmit delay variability")
     speed = Param.NetworkBandwidth('1Gbps', "link speed")
@@ -57,7 +68,7 @@ class EtherLink(SimObject):
 class DistEtherLink(SimObject):
     type = 'DistEtherLink'
     cxx_header = "dev/net/dist_etherlink.hh"
-    int0 = SlavePort("interface 0")
+    int0 = EtherInt("interface 0")
     delay = Param.Latency('0us', "packet transmit delay")
     delay_var = Param.Latency('0ns', "packet transmit delay variability")
     speed = Param.NetworkBandwidth('1Gbps', "link speed")
@@ -85,7 +96,7 @@ class EtherSwitch(SimObject):
     dump = Param.EtherDump(NULL, "dump object")
     fabric_speed = Param.NetworkBandwidth('10Gbps', "switch fabric speed in bits "
                                           "per second")
-    interface = VectorMasterPort("Ethernet Interface")
+    interface = VectorEtherInt("Ethernet Interface")
     output_buffer_size = Param.MemorySize('1MB', "size of output port buffers")
     delay = Param.Latency('0us', "packet transmit delay")
     delay_var = Param.Latency('0ns', "packet transmit delay variability")
@@ -97,7 +108,7 @@ class EtherTapBase(SimObject):
     cxx_header = "dev/net/ethertap.hh"
     bufsz = Param.Int(10000, "tap buffer size")
     dump = Param.EtherDump(NULL, "dump object")
-    tap = SlavePort("Ethernet interface to connect to gem5's network")
+    tap = EtherInt("Ethernet interface to connect to gem5's network")
 
 if buildEnv['USE_TUNTAP']:
     class EtherTap(EtherTapBase):
@@ -122,7 +133,7 @@ class EtherDevice(PciDevice):
     type = 'EtherDevice'
     abstract = True
     cxx_header = "dev/net/etherdevice.hh"
-    interface = MasterPort("Ethernet Interface")
+    interface = EtherInt("Ethernet Interface")
 
 class IGbE(EtherDevice):
     # Base class for two IGbE adapters listed above