Ethernet.py revision 13665:9c7fe3811b88
110235Syasuko.eckert@amd.com# Copyright (c) 2015 ARM Limited
210235Syasuko.eckert@amd.com# All rights reserved.
310235Syasuko.eckert@amd.com#
410235Syasuko.eckert@amd.com# The license below extends only to copyright in the software and shall
510235Syasuko.eckert@amd.com# not be construed as granting a license to any other intellectual
610235Syasuko.eckert@amd.com# property including but not limited to intellectual property relating
710235Syasuko.eckert@amd.com# to a hardware implementation of the functionality of the software
810235Syasuko.eckert@amd.com# licensed hereunder.  You may use the software subject to the license
910235Syasuko.eckert@amd.com# terms below provided that you ensure that this notice is replicated
1010235Syasuko.eckert@amd.com# unmodified and in its entirety in all distributions of the software,
1110235Syasuko.eckert@amd.com# modified or unmodified, in source code or in binary form.
1210235Syasuko.eckert@amd.com#
1310235Syasuko.eckert@amd.com# Copyright (c) 2005-2007 The Regents of The University of Michigan
1410235Syasuko.eckert@amd.com# All rights reserved.
1510235Syasuko.eckert@amd.com#
1610235Syasuko.eckert@amd.com# Redistribution and use in source and binary forms, with or without
1710235Syasuko.eckert@amd.com# modification, are permitted provided that the following conditions are
1810235Syasuko.eckert@amd.com# met: redistributions of source code must retain the above copyright
1910235Syasuko.eckert@amd.com# notice, this list of conditions and the following disclaimer;
2010235Syasuko.eckert@amd.com# redistributions in binary form must reproduce the above copyright
2110235Syasuko.eckert@amd.com# notice, this list of conditions and the following disclaimer in the
2210235Syasuko.eckert@amd.com# documentation and/or other materials provided with the distribution;
2310235Syasuko.eckert@amd.com# neither the name of the copyright holders nor the names of its
2410235Syasuko.eckert@amd.com# contributors may be used to endorse or promote products derived from
2510235Syasuko.eckert@amd.com# this software without specific prior written permission.
2610235Syasuko.eckert@amd.com#
2710235Syasuko.eckert@amd.com# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2810235Syasuko.eckert@amd.com# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2910235Syasuko.eckert@amd.com# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3010235Syasuko.eckert@amd.com# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3110235Syasuko.eckert@amd.com# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3210235Syasuko.eckert@amd.com# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3310235Syasuko.eckert@amd.com# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3410235Syasuko.eckert@amd.com# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3510235Syasuko.eckert@amd.com# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3610235Syasuko.eckert@amd.com# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3710235Syasuko.eckert@amd.com# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3810235Syasuko.eckert@amd.com#
3910235Syasuko.eckert@amd.com# Authors: Nathan Binkert
4010235Syasuko.eckert@amd.com
4110235Syasuko.eckert@amd.comfrom m5.defines import buildEnv
4210235Syasuko.eckert@amd.comfrom m5.SimObject import SimObject
4310235Syasuko.eckert@amd.comfrom m5.params import *
4410235Syasuko.eckert@amd.comfrom m5.proxy import *
4510235Syasuko.eckert@amd.comfrom m5.objects.PciDevice import PciDevice
4610235Syasuko.eckert@amd.com
4710235Syasuko.eckert@amd.comclass EtherObject(SimObject):
4810235Syasuko.eckert@amd.com    type = 'EtherObject'
4910235Syasuko.eckert@amd.com    abstract = True
5010235Syasuko.eckert@amd.com    cxx_header = "dev/net/etherobject.hh"
5110235Syasuko.eckert@amd.com
5210235Syasuko.eckert@amd.comclass EtherLink(EtherObject):
5310235Syasuko.eckert@amd.com    type = 'EtherLink'
5410235Syasuko.eckert@amd.com    cxx_header = "dev/net/etherlink.hh"
5510235Syasuko.eckert@amd.com    int0 = SlavePort("interface 0")
5610235Syasuko.eckert@amd.com    int1 = SlavePort("interface 1")
5710235Syasuko.eckert@amd.com    delay = Param.Latency('0us', "packet transmit delay")
5810235Syasuko.eckert@amd.com    delay_var = Param.Latency('0ns', "packet transmit delay variability")
5910235Syasuko.eckert@amd.com    speed = Param.NetworkBandwidth('1Gbps', "link speed")
6010235Syasuko.eckert@amd.com    dump = Param.EtherDump(NULL, "dump object")
6110235Syasuko.eckert@amd.com
6210235Syasuko.eckert@amd.comclass DistEtherLink(EtherObject):
6310235Syasuko.eckert@amd.com    type = 'DistEtherLink'
6410235Syasuko.eckert@amd.com    cxx_header = "dev/net/dist_etherlink.hh"
6510235Syasuko.eckert@amd.com    int0 = SlavePort("interface 0")
6610235Syasuko.eckert@amd.com    delay = Param.Latency('0us', "packet transmit delay")
6710235Syasuko.eckert@amd.com    delay_var = Param.Latency('0ns', "packet transmit delay variability")
6810235Syasuko.eckert@amd.com    speed = Param.NetworkBandwidth('1Gbps', "link speed")
6910235Syasuko.eckert@amd.com    dump = Param.EtherDump(NULL, "dump object")
7010235Syasuko.eckert@amd.com    dist_rank = Param.UInt32('0', "Rank of this gem5 process (dist run)")
7110235Syasuko.eckert@amd.com    dist_size = Param.UInt32('1', "Number of gem5 processes (dist run)")
7210235Syasuko.eckert@amd.com    sync_start = Param.Latency('5200000000000t', "first dist sync barrier")
7310235Syasuko.eckert@amd.com    sync_repeat = Param.Latency('10us', "dist sync barrier repeat")
7410235Syasuko.eckert@amd.com    server_name = Param.String('localhost', "Message server name")
7510235Syasuko.eckert@amd.com    server_port = Param.UInt32('2200', "Message server port")
76    is_switch = Param.Bool(False, "true if this a link in etherswitch")
77    dist_sync_on_pseudo_op = Param.Bool(False, "Start sync with pseudo_op")
78    num_nodes = Param.UInt32('2', "Number of simulate nodes")
79
80class EtherBus(EtherObject):
81    type = 'EtherBus'
82    cxx_header = "dev/net/etherbus.hh"
83    loopback = Param.Bool(True, "send packet back to the sending interface")
84    dump = Param.EtherDump(NULL, "dump object")
85    speed = Param.NetworkBandwidth('100Mbps', "bus speed in bits per second")
86
87class EtherSwitch(EtherObject):
88    type = 'EtherSwitch'
89    cxx_header = "dev/net/etherswitch.hh"
90    dump = Param.EtherDump(NULL, "dump object")
91    fabric_speed = Param.NetworkBandwidth('10Gbps', "switch fabric speed in bits "
92                                          "per second")
93    interface = VectorMasterPort("Ethernet Interface")
94    output_buffer_size = Param.MemorySize('1MB', "size of output port buffers")
95    delay = Param.Latency('0us', "packet transmit delay")
96    delay_var = Param.Latency('0ns', "packet transmit delay variability")
97    time_to_live = Param.Latency('10ms', "time to live of MAC address maping")
98
99class EtherTapBase(EtherObject):
100    type = 'EtherTapBase'
101    abstract = True
102    cxx_header = "dev/net/ethertap.hh"
103    bufsz = Param.Int(10000, "tap buffer size")
104    dump = Param.EtherDump(NULL, "dump object")
105    tap = SlavePort("Ethernet interface to connect to gem5's network")
106
107if buildEnv['USE_TUNTAP']:
108    class EtherTap(EtherTapBase):
109        type = 'EtherTap'
110        cxx_header = "dev/net/ethertap.hh"
111        tun_clone_device = Param.String('/dev/net/tun',
112                                        "Path to the tun clone device node")
113        tap_device_name = Param.String('gem5-tap', "Tap device name")
114
115class EtherTapStub(EtherTapBase):
116    type = 'EtherTapStub'
117    cxx_header = "dev/net/ethertap.hh"
118    port = Param.UInt16(3500, "Port helper should send packets to")
119
120class EtherDump(SimObject):
121    type = 'EtherDump'
122    cxx_header = "dev/net/etherdump.hh"
123    file = Param.String("dump file")
124    maxlen = Param.Int(96, "max portion of packet data to dump")
125
126class EtherDevice(PciDevice):
127    type = 'EtherDevice'
128    abstract = True
129    cxx_header = "dev/net/etherdevice.hh"
130    interface = MasterPort("Ethernet Interface")
131
132class IGbE(EtherDevice):
133    # Base class for two IGbE adapters listed above
134    type = 'IGbE'
135    cxx_header = "dev/net/i8254xGBe.hh"
136    hardware_address = Param.EthernetAddr(NextEthernetAddr,
137        "Ethernet Hardware Address")
138    rx_fifo_size = Param.MemorySize('384kB', "Size of the rx FIFO")
139    tx_fifo_size = Param.MemorySize('384kB', "Size of the tx FIFO")
140    rx_desc_cache_size = Param.Int(64,
141        "Number of enteries in the rx descriptor cache")
142    tx_desc_cache_size = Param.Int(64,
143        "Number of enteries in the rx descriptor cache")
144    VendorID = 0x8086
145    SubsystemID = 0x1008
146    SubsystemVendorID = 0x8086
147    Status = 0x0000
148    SubClassCode = 0x00
149    ClassCode = 0x02
150    ProgIF = 0x00
151    BAR0 = 0x00000000
152    BAR1 = 0x00000000
153    BAR2 = 0x00000000
154    BAR3 = 0x00000000
155    BAR4 = 0x00000000
156    BAR5 = 0x00000000
157    MaximumLatency = 0x00
158    MinimumGrant = 0xff
159    InterruptLine = 0x1e
160    InterruptPin = 0x01
161    BAR0Size = '128kB'
162    wb_delay = Param.Latency('10ns', "delay before desc writeback occurs")
163    fetch_delay = Param.Latency('10ns', "delay before desc fetch occurs")
164    fetch_comp_delay = Param.Latency('10ns', "delay after desc fetch occurs")
165    wb_comp_delay = Param.Latency('10ns', "delay after desc wb occurs")
166    tx_read_delay = Param.Latency('0ns', "delay after tx dma read")
167    rx_write_delay = Param.Latency('0ns', "delay after rx dma read")
168    phy_pid = Param.UInt16("Phy PID that corresponds to device ID")
169    phy_epid = Param.UInt16("Phy EPID that corresponds to device ID")
170
171class IGbE_e1000(IGbE):
172    # Older Intel 8254x based gigabit ethernet adapter
173    # Uses Intel e1000 driver
174    DeviceID = 0x1075
175    phy_pid = 0x02A8
176    phy_epid = 0x0380
177
178class IGbE_igb(IGbE):
179    # Newer Intel 8257x based gigabit ethernet adapter
180    # Uses Intel igb driver and in theory supports packet splitting and LRO
181    DeviceID = 0x10C9
182    phy_pid = 0x0141
183    phy_epid = 0x0CC0
184
185class EtherDevBase(EtherDevice):
186    type = 'EtherDevBase'
187    abstract = True
188    cxx_header = "dev/net/etherdevice.hh"
189
190    hardware_address = Param.EthernetAddr(NextEthernetAddr,
191        "Ethernet Hardware Address")
192
193    dma_read_delay = Param.Latency('0us', "fixed delay for dma reads")
194    dma_read_factor = Param.Latency('0us', "multiplier for dma reads")
195    dma_write_delay = Param.Latency('0us', "fixed delay for dma writes")
196    dma_write_factor = Param.Latency('0us', "multiplier for dma writes")
197
198    rx_delay = Param.Latency('1us', "Receive Delay")
199    tx_delay = Param.Latency('1us', "Transmit Delay")
200    rx_fifo_size = Param.MemorySize('512kB', "max size of rx fifo")
201    tx_fifo_size = Param.MemorySize('512kB', "max size of tx fifo")
202
203    rx_filter = Param.Bool(True, "Enable Receive Filter")
204    intr_delay = Param.Latency('10us', "Interrupt propagation delay")
205    rx_thread = Param.Bool(False, "dedicated kernel thread for transmit")
206    tx_thread = Param.Bool(False, "dedicated kernel threads for receive")
207    rss = Param.Bool(False, "Receive Side Scaling")
208
209class NSGigE(EtherDevBase):
210    type = 'NSGigE'
211    cxx_header = "dev/net/ns_gige.hh"
212
213    dma_data_free = Param.Bool(False, "DMA of Data is free")
214    dma_desc_free = Param.Bool(False, "DMA of Descriptors is free")
215    dma_no_allocate = Param.Bool(True, "Should we allocate cache on read")
216
217    VendorID = 0x100B
218    DeviceID = 0x0022
219    Status = 0x0290
220    SubClassCode = 0x00
221    ClassCode = 0x02
222    ProgIF = 0x00
223    BAR0 = 0x00000001
224    BAR1 = 0x00000000
225    BAR2 = 0x00000000
226    BAR3 = 0x00000000
227    BAR4 = 0x00000000
228    BAR5 = 0x00000000
229    MaximumLatency = 0x34
230    MinimumGrant = 0xb0
231    InterruptLine = 0x1e
232    InterruptPin = 0x01
233    BAR0Size = '256B'
234    BAR1Size = '4kB'
235
236
237
238class Sinic(EtherDevBase):
239    type = 'Sinic'
240    cxx_class = 'Sinic::Device'
241    cxx_header = "dev/net/sinic.hh"
242
243    rx_max_copy = Param.MemorySize('1514B', "rx max copy")
244    tx_max_copy = Param.MemorySize('16kB', "tx max copy")
245    rx_max_intr = Param.UInt32(10, "max rx packets per interrupt")
246    rx_fifo_threshold = Param.MemorySize('384kB', "rx fifo high threshold")
247    rx_fifo_low_mark = Param.MemorySize('128kB', "rx fifo low threshold")
248    tx_fifo_high_mark = Param.MemorySize('384kB', "tx fifo high threshold")
249    tx_fifo_threshold = Param.MemorySize('128kB', "tx fifo low threshold")
250    virtual_count = Param.UInt32(1, "Virtualized SINIC")
251    zero_copy_size = Param.UInt32(64, "Bytes to copy if below threshold")
252    zero_copy_threshold = Param.UInt32(256,
253        "Only zero copy above this threshold")
254    zero_copy = Param.Bool(False, "Zero copy receive")
255    delay_copy = Param.Bool(False, "Delayed copy transmit")
256    virtual_addr = Param.Bool(False, "Virtual addressing")
257
258    VendorID = 0x1291
259    DeviceID = 0x1293
260    Status = 0x0290
261    SubClassCode = 0x00
262    ClassCode = 0x02
263    ProgIF = 0x00
264    BAR0 = 0x00000000
265    BAR1 = 0x00000000
266    BAR2 = 0x00000000
267    BAR3 = 0x00000000
268    BAR4 = 0x00000000
269    BAR5 = 0x00000000
270    MaximumLatency = 0x34
271    MinimumGrant = 0xb0
272    InterruptLine = 0x1e
273    InterruptPin = 0x01
274    BAR0Size = '64kB'
275
276
277