110923SN/A# Copyright (c) 2015 ARM Limited
210923SN/A# All rights reserved.
310923SN/A#
410923SN/A# The license below extends only to copyright in the software and shall
510923SN/A# not be construed as granting a license to any other intellectual
610923SN/A# property including but not limited to intellectual property relating
710923SN/A# to a hardware implementation of the functionality of the software
810923SN/A# licensed hereunder.  You may use the software subject to the license
910923SN/A# terms below provided that you ensure that this notice is replicated
1010923SN/A# unmodified and in its entirety in all distributions of the software,
1110923SN/A# modified or unmodified, in source code or in binary form.
1210923SN/A#
134486SN/A# Copyright (c) 2005-2007 The Regents of The University of Michigan
144486SN/A# All rights reserved.
154486SN/A#
164486SN/A# Redistribution and use in source and binary forms, with or without
174486SN/A# modification, are permitted provided that the following conditions are
184486SN/A# met: redistributions of source code must retain the above copyright
194486SN/A# notice, this list of conditions and the following disclaimer;
204486SN/A# redistributions in binary form must reproduce the above copyright
214486SN/A# notice, this list of conditions and the following disclaimer in the
224486SN/A# documentation and/or other materials provided with the distribution;
234486SN/A# neither the name of the copyright holders nor the names of its
244486SN/A# contributors may be used to endorse or promote products derived from
254486SN/A# this software without specific prior written permission.
264486SN/A#
274486SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
284486SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
294486SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
304486SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
314486SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
324486SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
334486SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
344486SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
354486SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
364486SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
374486SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
384486SN/A#
394486SN/A# Authors: Nathan Binkert
404486SN/A
4112056Sgabeblack@google.comfrom m5.defines import buildEnv
423102SN/Afrom m5.SimObject import SimObject
433102SN/Afrom m5.params import *
443102SN/Afrom m5.proxy import *
4513665Sandreas.sandberg@arm.comfrom m5.objects.PciDevice import PciDevice
461310SN/A
4713872Sgabeblack@google.comETHERNET_ROLE = 'ETHERNET'
4813872Sgabeblack@google.comPort.compat(ETHERNET_ROLE, ETHERNET_ROLE)
4913872Sgabeblack@google.com
5013872Sgabeblack@google.comclass EtherInt(Port):
5113872Sgabeblack@google.com    def __init__(self, desc):
5213872Sgabeblack@google.com        super(EtherInt, self).__init__(ETHERNET_ROLE, desc)
5313872Sgabeblack@google.com
5413872Sgabeblack@google.comclass VectorEtherInt(VectorPort):
5513872Sgabeblack@google.com    def __init__(self, desc):
5613872Sgabeblack@google.com        super(VectorEtherInt, self).__init__(ETHERNET_ROLE, desc)
5713872Sgabeblack@google.com
5813766Sgabeblack@google.comclass EtherLink(SimObject):
591366SN/A    type = 'EtherLink'
6011263Sandreas.sandberg@arm.com    cxx_header = "dev/net/etherlink.hh"
6113872Sgabeblack@google.com    int0 = EtherInt("interface 0")
6213872Sgabeblack@google.com    int1 = EtherInt("interface 1")
631634SN/A    delay = Param.Latency('0us', "packet transmit delay")
641952SN/A    delay_var = Param.Latency('0ns', "packet transmit delay variability")
651702SN/A    speed = Param.NetworkBandwidth('1Gbps', "link speed")
661310SN/A    dump = Param.EtherDump(NULL, "dump object")
671310SN/A
6813766Sgabeblack@google.comclass DistEtherLink(SimObject):
6911290Sgabor.dozsa@arm.com    type = 'DistEtherLink'
7011290Sgabor.dozsa@arm.com    cxx_header = "dev/net/dist_etherlink.hh"
7113872Sgabeblack@google.com    int0 = EtherInt("interface 0")
7210923SN/A    delay = Param.Latency('0us', "packet transmit delay")
7310923SN/A    delay_var = Param.Latency('0ns', "packet transmit delay variability")
7410923SN/A    speed = Param.NetworkBandwidth('1Gbps', "link speed")
7510923SN/A    dump = Param.EtherDump(NULL, "dump object")
7611290Sgabor.dozsa@arm.com    dist_rank = Param.UInt32('0', "Rank of this gem5 process (dist run)")
7711290Sgabor.dozsa@arm.com    dist_size = Param.UInt32('1', "Number of gem5 processes (dist run)")
7811290Sgabor.dozsa@arm.com    sync_start = Param.Latency('5200000000000t', "first dist sync barrier")
7911290Sgabor.dozsa@arm.com    sync_repeat = Param.Latency('10us', "dist sync barrier repeat")
8010923SN/A    server_name = Param.String('localhost', "Message server name")
8110923SN/A    server_port = Param.UInt32('2200', "Message server port")
8211290Sgabor.dozsa@arm.com    is_switch = Param.Bool(False, "true if this a link in etherswitch")
8311703Smichael.lebeane@amd.com    dist_sync_on_pseudo_op = Param.Bool(False, "Start sync with pseudo_op")
8411290Sgabor.dozsa@arm.com    num_nodes = Param.UInt32('2', "Number of simulate nodes")
8510923SN/A
8613766Sgabeblack@google.comclass EtherBus(SimObject):
871366SN/A    type = 'EtherBus'
8811263Sandreas.sandberg@arm.com    cxx_header = "dev/net/etherbus.hh"
891634SN/A    loopback = Param.Bool(True, "send packet back to the sending interface")
901310SN/A    dump = Param.EtherDump(NULL, "dump object")
911634SN/A    speed = Param.NetworkBandwidth('100Mbps', "bus speed in bits per second")
921310SN/A
9313766Sgabeblack@google.comclass EtherSwitch(SimObject):
9411317Sm.alian1369@gmail.com    type = 'EtherSwitch'
9511317Sm.alian1369@gmail.com    cxx_header = "dev/net/etherswitch.hh"
9611317Sm.alian1369@gmail.com    dump = Param.EtherDump(NULL, "dump object")
9711317Sm.alian1369@gmail.com    fabric_speed = Param.NetworkBandwidth('10Gbps', "switch fabric speed in bits "
9811317Sm.alian1369@gmail.com                                          "per second")
9913872Sgabeblack@google.com    interface = VectorEtherInt("Ethernet Interface")
10011317Sm.alian1369@gmail.com    output_buffer_size = Param.MemorySize('1MB', "size of output port buffers")
10111317Sm.alian1369@gmail.com    delay = Param.Latency('0us', "packet transmit delay")
10211317Sm.alian1369@gmail.com    delay_var = Param.Latency('0ns', "packet transmit delay variability")
10311317Sm.alian1369@gmail.com    time_to_live = Param.Latency('10ms', "time to live of MAC address maping")
10411317Sm.alian1369@gmail.com
10513766Sgabeblack@google.comclass EtherTapBase(SimObject):
10612055Sgabeblack@google.com    type = 'EtherTapBase'
10712055Sgabeblack@google.com    abstract = True
10811263Sandreas.sandberg@arm.com    cxx_header = "dev/net/ethertap.hh"
1091310SN/A    bufsz = Param.Int(10000, "tap buffer size")
1101310SN/A    dump = Param.EtherDump(NULL, "dump object")
11113872Sgabeblack@google.com    tap = EtherInt("Ethernet interface to connect to gem5's network")
11212055Sgabeblack@google.com
11312056Sgabeblack@google.comif buildEnv['USE_TUNTAP']:
11412056Sgabeblack@google.com    class EtherTap(EtherTapBase):
11512056Sgabeblack@google.com        type = 'EtherTap'
11612056Sgabeblack@google.com        cxx_header = "dev/net/ethertap.hh"
11712056Sgabeblack@google.com        tun_clone_device = Param.String('/dev/net/tun',
11812056Sgabeblack@google.com                                        "Path to the tun clone device node")
11912056Sgabeblack@google.com        tap_device_name = Param.String('gem5-tap', "Tap device name")
12012056Sgabeblack@google.com
12112055Sgabeblack@google.comclass EtherTapStub(EtherTapBase):
12212055Sgabeblack@google.com    type = 'EtherTapStub'
12312055Sgabeblack@google.com    cxx_header = "dev/net/ethertap.hh"
12412054Sgabeblack@google.com    port = Param.UInt16(3500, "Port helper should send packets to")
1251310SN/A
1261692SN/Aclass EtherDump(SimObject):
1271366SN/A    type = 'EtherDump'
12811263Sandreas.sandberg@arm.com    cxx_header = "dev/net/etherdump.hh"
1291310SN/A    file = Param.String("dump file")
1301880SN/A    maxlen = Param.Int(96, "max portion of packet data to dump")
1311310SN/A
1324981SN/Aclass EtherDevice(PciDevice):
1334981SN/A    type = 'EtherDevice'
1344981SN/A    abstract = True
13511263Sandreas.sandberg@arm.com    cxx_header = "dev/net/etherdevice.hh"
13613872Sgabeblack@google.com    interface = EtherInt("Ethernet Interface")
1374981SN/A
1384981SN/Aclass IGbE(EtherDevice):
1395763SN/A    # Base class for two IGbE adapters listed above
1403116SN/A    type = 'IGbE'
14111263Sandreas.sandberg@arm.com    cxx_header = "dev/net/i8254xGBe.hh"
1424597SN/A    hardware_address = Param.EthernetAddr(NextEthernetAddr,
1434597SN/A        "Ethernet Hardware Address")
1444283SN/A    rx_fifo_size = Param.MemorySize('384kB', "Size of the rx FIFO")
1454283SN/A    tx_fifo_size = Param.MemorySize('384kB', "Size of the tx FIFO")
1464486SN/A    rx_desc_cache_size = Param.Int(64,
1474486SN/A        "Number of enteries in the rx descriptor cache")
1484486SN/A    tx_desc_cache_size = Param.Int(64,
1494486SN/A        "Number of enteries in the rx descriptor cache")
1503116SN/A    VendorID = 0x8086
1513116SN/A    SubsystemID = 0x1008
1523116SN/A    SubsystemVendorID = 0x8086
1533116SN/A    Status = 0x0000
1543116SN/A    SubClassCode = 0x00
1553116SN/A    ClassCode = 0x02
1563116SN/A    ProgIF = 0x00
1573116SN/A    BAR0 = 0x00000000
1583116SN/A    BAR1 = 0x00000000
1593116SN/A    BAR2 = 0x00000000
1603116SN/A    BAR3 = 0x00000000
1613116SN/A    BAR4 = 0x00000000
1623116SN/A    BAR5 = 0x00000000
1633116SN/A    MaximumLatency = 0x00
1643116SN/A    MinimumGrant = 0xff
1653116SN/A    InterruptLine = 0x1e
1663116SN/A    InterruptPin = 0x01
1673116SN/A    BAR0Size = '128kB'
1685535SN/A    wb_delay = Param.Latency('10ns', "delay before desc writeback occurs")
1695535SN/A    fetch_delay = Param.Latency('10ns', "delay before desc fetch occurs")
1705535SN/A    fetch_comp_delay = Param.Latency('10ns', "delay after desc fetch occurs")
1715535SN/A    wb_comp_delay = Param.Latency('10ns', "delay after desc wb occurs")
1725535SN/A    tx_read_delay = Param.Latency('0ns', "delay after tx dma read")
1735535SN/A    rx_write_delay = Param.Latency('0ns', "delay after rx dma read")
1745781SN/A    phy_pid = Param.UInt16("Phy PID that corresponds to device ID")
1755781SN/A    phy_epid = Param.UInt16("Phy EPID that corresponds to device ID")
1763116SN/A
1775763SN/Aclass IGbE_e1000(IGbE):
1785763SN/A    # Older Intel 8254x based gigabit ethernet adapter
1795763SN/A    # Uses Intel e1000 driver
1805763SN/A    DeviceID = 0x1075
1815781SN/A    phy_pid = 0x02A8
1825781SN/A    phy_epid = 0x0380
1835763SN/A
1845763SN/Aclass IGbE_igb(IGbE):
1855763SN/A    # Newer Intel 8257x based gigabit ethernet adapter
1865763SN/A    # Uses Intel igb driver and in theory supports packet splitting and LRO
1875763SN/A    DeviceID = 0x10C9
1885781SN/A    phy_pid = 0x0141
1895781SN/A    phy_epid = 0x0CC0
1905763SN/A
1914981SN/Aclass EtherDevBase(EtherDevice):
1924597SN/A    type = 'EtherDevBase'
1934597SN/A    abstract = True
19411263Sandreas.sandberg@arm.com    cxx_header = "dev/net/etherdevice.hh"
1959339SN/A
1961310SN/A    hardware_address = Param.EthernetAddr(NextEthernetAddr,
1971310SN/A        "Ethernet Hardware Address")
1981310SN/A
1991634SN/A    dma_read_delay = Param.Latency('0us', "fixed delay for dma reads")
2001634SN/A    dma_read_factor = Param.Latency('0us', "multiplier for dma reads")
2011634SN/A    dma_write_delay = Param.Latency('0us', "fixed delay for dma writes")
2021634SN/A    dma_write_factor = Param.Latency('0us', "multiplier for dma writes")
2031647SN/A
2041925SN/A    rx_delay = Param.Latency('1us', "Receive Delay")
2051925SN/A    tx_delay = Param.Latency('1us', "Transmit Delay")
2061925SN/A    rx_fifo_size = Param.MemorySize('512kB', "max size of rx fifo")
2071925SN/A    tx_fifo_size = Param.MemorySize('512kB', "max size of tx fifo")
2081310SN/A
2091369SN/A    rx_filter = Param.Bool(True, "Enable Receive Filter")
2102008SN/A    intr_delay = Param.Latency('10us', "Interrupt propagation delay")
2112008SN/A    rx_thread = Param.Bool(False, "dedicated kernel thread for transmit")
2122008SN/A    tx_thread = Param.Bool(False, "dedicated kernel threads for receive")
2132210SN/A    rss = Param.Bool(False, "Receive Side Scaling")
2141310SN/A
2154982SN/Aclass NSGigE(EtherDevBase):
2164982SN/A    type = 'NSGigE'
21711263Sandreas.sandberg@arm.com    cxx_header = "dev/net/ns_gige.hh"
2184982SN/A
2194982SN/A    dma_data_free = Param.Bool(False, "DMA of Data is free")
2204982SN/A    dma_desc_free = Param.Bool(False, "DMA of Descriptors is free")
2214982SN/A    dma_no_allocate = Param.Bool(True, "Should we allocate cache on read")
2224982SN/A
2232916SN/A    VendorID = 0x100B
2242916SN/A    DeviceID = 0x0022
2252916SN/A    Status = 0x0290
2262916SN/A    SubClassCode = 0x00
2272916SN/A    ClassCode = 0x02
2282916SN/A    ProgIF = 0x00
2292916SN/A    BAR0 = 0x00000001
2302916SN/A    BAR1 = 0x00000000
2312916SN/A    BAR2 = 0x00000000
2322916SN/A    BAR3 = 0x00000000
2332916SN/A    BAR4 = 0x00000000
2342916SN/A    BAR5 = 0x00000000
2352916SN/A    MaximumLatency = 0x34
2362916SN/A    MinimumGrant = 0xb0
2372916SN/A    InterruptLine = 0x1e
2382916SN/A    InterruptPin = 0x01
2392916SN/A    BAR0Size = '256B'
2402916SN/A    BAR1Size = '4kB'
2412916SN/A
2421310SN/A
2431644SN/A
2444982SN/Aclass Sinic(EtherDevBase):
2454982SN/A    type = 'Sinic'
2465610SN/A    cxx_class = 'Sinic::Device'
24711263Sandreas.sandberg@arm.com    cxx_header = "dev/net/sinic.hh"
2482916SN/A
2494982SN/A    rx_max_copy = Param.MemorySize('1514B', "rx max copy")
2504982SN/A    tx_max_copy = Param.MemorySize('16kB', "tx max copy")
2514982SN/A    rx_max_intr = Param.UInt32(10, "max rx packets per interrupt")
2524982SN/A    rx_fifo_threshold = Param.MemorySize('384kB', "rx fifo high threshold")
2534982SN/A    rx_fifo_low_mark = Param.MemorySize('128kB', "rx fifo low threshold")
2544982SN/A    tx_fifo_high_mark = Param.MemorySize('384kB', "tx fifo high threshold")
2554982SN/A    tx_fifo_threshold = Param.MemorySize('128kB', "tx fifo low threshold")
2564982SN/A    virtual_count = Param.UInt32(1, "Virtualized SINIC")
2575603SN/A    zero_copy_size = Param.UInt32(64, "Bytes to copy if below threshold")
2585603SN/A    zero_copy_threshold = Param.UInt32(256,
2595603SN/A        "Only zero copy above this threshold")
2604982SN/A    zero_copy = Param.Bool(False, "Zero copy receive")
2614982SN/A    delay_copy = Param.Bool(False, "Delayed copy transmit")
2624982SN/A    virtual_addr = Param.Bool(False, "Virtual addressing")
2631310SN/A
2642916SN/A    VendorID = 0x1291
2652916SN/A    DeviceID = 0x1293
2662916SN/A    Status = 0x0290
2672916SN/A    SubClassCode = 0x00
2682916SN/A    ClassCode = 0x02
2692916SN/A    ProgIF = 0x00
2702916SN/A    BAR0 = 0x00000000
2712916SN/A    BAR1 = 0x00000000
2722916SN/A    BAR2 = 0x00000000
2732916SN/A    BAR3 = 0x00000000
2742916SN/A    BAR4 = 0x00000000
2752916SN/A    BAR5 = 0x00000000
2762916SN/A    MaximumLatency = 0x34
2772916SN/A    MinimumGrant = 0xb0
2782916SN/A    InterruptLine = 0x1e
2792916SN/A    InterruptPin = 0x01
2802916SN/A    BAR0Size = '64kB'
2812916SN/A
2821310SN/A
283